pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: glen.edmonds@gmail.com, PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Subject: Re: BUG #17428: last_value incorrect for uninitialized sequence
Date: Mon, 07 Mar 2022 09:48:05 -0500
Message-ID: <189261.1646664485@sss.pgh.pa.us> (raw)
In-Reply-To: <CAKFQuwaZ06rmQQsdZh3zQoeTby7=Yu0Pp=z5ts+5iGo80-EXyw@mail.gmail.com>
References: <17428-848dee31a3b899ab@postgresql.org>
	<CAKFQuwaZ06rmQQsdZh3zQoeTby7=Yu0Pp=z5ts+5iGo80-EXyw@mail.gmail.com>

"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Mon, Mar 7, 2022 at 12:15 AM PG Bug reporting form <
> noreply@postgresql.org> wrote:
>> For a freshly defined sequence, the following:
>> select last_value from mytable_id_seq
>> should return 0, but returns 1.

> One seems as good a choice as zero if a non-null value is to be returned.

The larger point here is that any change is much more likely to
break applications expecting the historical behavior than it is
to make anyone's life better.  In a green field I'd tend to
agree that returning NULL (and dispensing with is_called) would
be a better design, but that opportunity was missed decades ago.

			regards, tom lane





view thread (6+ messages)  latest in thread

Message-ID: <189261.1646664485@sss.pgh.pa.us>
Permalink:  ../189261.1646664485@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/189261.1646664485@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, david.g.johnston@gmail.com, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #17428: last_value incorrect for uninitialized sequence
  In-Reply-To: <189261.1646664485@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox