Re: BUG #17428: last_value incorrect for uninitialized sequence

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Glen Edmonds <glen(dot)edmonds(at)gmail(dot)com>
Cc: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #17428: last_value incorrect for uninitialized sequence
Date: 2022-03-07 15:23:42
Message-ID: 192171.1646666622@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Glen Edmonds <glen(dot)edmonds(at)gmail(dot)com> writes:
> The problem really is that the two states of not initialized and post first
> usage are indistinguishable (both return 1), but the sequence next value is
> different.

They're not indistinguishable: if you look at the is_called flag
you'll see that it changes.

> ie it’s a reasonable expectation that the next value is
> last_value + 1. IMHO violating this makes it a bug.

You can call it that if you like, but it's operating as designed
and documented. I fear it's about twenty years too late to propose
a redesign.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message David G. Johnston 2022-03-07 15:40:33 Re: BUG #17428: last_value incorrect for uninitialized sequence
Previous Message Glen Edmonds 2022-03-07 15:14:44 Re: BUG #17428: last_value incorrect for uninitialized sequence