PostgreSQL Bugs

Collected from the PG bugs email list.

Bug ID16018
PG Version11.5
OSosx
Opened2019-09-23 21:45:49+00
Reported byRobert Treat
StatusNew

Body of first available message related to this bug follows.

The following bug has been logged on the website:

Bug reference:      16018
Logged by:          Robert Treat
Email address:      (redacted)
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

Messages

DateAuthorSubject
2019-09-23 21:45:49+00PG Bug reporting formBUG #16018: pg_sequence_last_value() doesn't give results for owners
2019-09-23 22:33:46+00"David G(dot) Johnston"Re: BUG #16018: pg_sequence_last_value() doesn't give results for owners
2019-09-23 23:34:03+00Robert TreatRe: BUG #16018: pg_sequence_last_value() doesn't give results for owners
2019-09-23 23:40:09+00Tom LaneRe: BUG #16018: pg_sequence_last_value() doesn't give results for owners