pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Robert Treat <rob@xzilla.net>
Cc: PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Subject: Re: BUG #16018: pg_sequence_last_value() doesn't give results for owners
Date: Mon, 23 Sep 2019 19:40:09 -0400
Message-ID: <9246.1569282009@sss.pgh.pa.us> (raw)
In-Reply-To: <CABV9wwMPmDyHM7A5eET_Yb0pOOO1n03OpyhdWdUezm1je0DhWw@mail.gmail.com>
References: <16018-e617465560d648c5@postgresql.org>
	<CAKFQuwaLu2vXFt40ZyRdk0ws+gH1iFWaVNndAOvez7bd9Kx9Kw@mail.gmail.com>
	<CABV9wwMPmDyHM7A5eET_Yb0pOOO1n03OpyhdWdUezm1je0DhWw@mail.gmail.com>

Robert Treat <rob@xzilla.net> writes:
> On Mon, Sep 23, 2019 at 6:34 PM David G. Johnston
> <david.g.johnston@gmail.com> wrote:
>> From pg_sequences:
>> last_value bigint The last sequence value written to disk. If caching is used, this value can be greater than the last value handed out from the sequence. Null if the sequence has not been read from yet. Also, if the current user does not have USAGE or SELECT privilege on the sequence, the value is null.

> Ugh... the situation is further complicated in that setval seems to
> cause a read, but alter sequence restart does not. Fun.

setval can set is_called to either true or false.  In the false
state, you get a null here.

>> The "last_value" on the sequence object has a different definition than the one on the relatively new pg_sequences catalog.

> Any chance you have a pointer to documentation on the differences?

David quoted the docs about pg_sequences.last_value.
pg_sequence_last_value() isn't documented separately because you're
not really supposed to call it directly, only through the view.

currval()/lastval() give the last sequence value actually returned in
the current session, independently of what other sessions did since.

			regards, tom lane





view thread (4+ messages)

Message-ID: <9246.1569282009@sss.pgh.pa.us>
Permalink:  ../9246.1569282009@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/9246.1569282009@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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, rob@xzilla.net
  Subject: Re: BUG #16018: pg_sequence_last_value() doesn't give results for owners
  In-Reply-To: <9246.1569282009@sss.pgh.pa.us>
  References: <16018-e617465560d648c5@postgresql.org> <CAKFQuwaLu2vXFt40ZyRdk0ws+gH1iFWaVNndAOvez7bd9Kx9Kw@mail.gmail.com> <CABV9wwMPmDyHM7A5eET_Yb0pOOO1n03OpyhdWdUezm1je0DhWw@mail.gmail.com> <9246.1569282009@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