Re: BUG #17428: last_value incorrect for uninitialized sequence - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #17428: last_value incorrect for uninitialized sequence
Date
Msg-id 189261.1646664485@sss.pgh.pa.us
Whole thread Raw
In response to Re: BUG #17428: last_value incorrect for uninitialized sequence  ("David G. Johnston" <david.g.johnston@gmail.com>)
Responses Re: BUG #17428: last_value incorrect for uninitialized sequence  (Glen Edmonds <glen.edmonds@gmail.com>)
List pgsql-bugs
"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



pgsql-bugs by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: BUG #17428: last_value incorrect for uninitialized sequence
Next
From: Glen Edmonds
Date:
Subject: Re: BUG #17428: last_value incorrect for uninitialized sequence