From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: rob@xzilla.net
Subject: BUG #16018: pg_sequence_last_value() doesn't give results for owners
Date: Mon, 23 Sep 2019 21:45:49 +0000
Message-ID: <16018-e617465560d648c5@postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 16018
Logged by: Robert Treat
Email address: rob@xzilla.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@54321:pagila=# create sequence x;
CREATE SEQUENCE
postgres@54321:pagila=# select pg_sequence_last_value('x'::regclass);
pg_sequence_last_value
------------------------
(1 row)
postgres@54321:pagila=# select * from x;
last_value | log_cnt | is_called
------------+---------+-----------
1 | 0 | f
(1 row)
postgres@54321:pagila=# select * from pg_sequences where sequencename =
'x';
-[ RECORD 1 ]-+--------------------
schemaname | public
sequencename | x
sequenceowner | postgres
data_type | bigint
start_value | 1
min_value | 1
max_value | 9223372036854775807
increment_by | 1
cycle | f
cache_size | 1
last_value |
Related, has_sequence_privilege() seems to indicate that this should all
work:
postgres@54321:pagila=# select has_sequence_privilege('x'::regclass,
'SELECT,USAGE'::text);
has_sequence_privilege
------------------------
t
(1 row)
The backend code for pg_sequence_last_value is checking this:
if (pg_class_aclcheck(relid, GetUserId(), ACL_SELECT | ACL_USAGE) !=
ACLCHECK_OK)
Robert Treat
https://xzilla.net
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: noreply@postgresql.org, rob@xzilla.net
Subject: Re: BUG #16018: pg_sequence_last_value() doesn't give results for owners
In-Reply-To: <16018-e617465560d648c5@postgresql.org>
References: <16018-e617465560d648c5@postgresql.org>
* 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