Re: BUG #16018: pg_sequence_last_value() doesn't give results for owners

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: PG Bug reporting form <noreply(at)postgresql(dot)org>
Cc: PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>, rob(at)xzilla(dot)net
Subject: Re: BUG #16018: pg_sequence_last_value() doesn't give results for owners
Date: 2019-09-23 22:33:46
Message-ID: CAKFQuwaLu2vXFt40ZyRdk0ws+gH1iFWaVNndAOvez7bd9Kx9Kw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Mon, Sep 23, 2019 at 2:46 PM PG Bug reporting form <
noreply(at)postgresql(dot)org> wrote:

> The following bug has been logged on the website:
>
> Bug reference: 16018
> Logged by: Robert Treat
> Email address: rob(at)xzilla(dot)net
> PostgreSQL version: 11.5
> Operating system: osx
> Description:
>
> I think there is a bug of sorts with pg_sequence_last_value(), in that the
> security checks prevent a superuser (or owner) from seeing the last_value
> of
> a sequence by way of this function. That seems like a use case that should
> be supported (and since it isn't, it causes problems for a lot of other use
> cases). As an example:
>
> postgres(at)54321:pagila=# create sequence x;
> CREATE SEQUENCE
>
> postgres(at)54321:pagila=# select pg_sequence_last_value('x'::regclass);
> pg_sequence_last_value
> ------------------------
>
> (1 row)
>
>
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.
"""

The null in the example seems to be due to the first condition (not been
read from) not the second (privileges).

postgres(at)54321:pagila=# select * from x;
> last_value | log_cnt | is_called
> ------------+---------+-----------
> 1 | 0 | f
> (1 row)
>

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

I'm not seeing where a bug has been shown to exist though I'll agree that
the quick reading of the documentation leaves some level of confusion.

David J.

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Robert Treat 2019-09-23 23:34:03 Re: BUG #16018: pg_sequence_last_value() doesn't give results for owners
Previous Message PG Bug reporting form 2019-09-23 21:45:49 BUG #16018: pg_sequence_last_value() doesn't give results for owners