Re: Fix publisher-side sequence permission reporting
Fujii Masao <masao.fujii@gmail.com>
From: Fujii Masao <masao.fujii@gmail.com>
To: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Cc: Amit Kapila <amit.kapila16@gmail.com>, Tristan Partin <tristan@partin.io>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2026-07-01T16:08:44Z
Lists: pgsql-hackers
Attachments
- v2-0001-Add-hints-for-sequence-synchronization-permission.patch (application/octet-stream) patch v2-0001
On Wed, Jun 24, 2026 at 2:40 PM Bharath Rupireddy
<bharath.rupireddyforpostgres@gmail.com> wrote:
>
> Hi,
>
> On Tue, Jun 23, 2026 at 5:41 PM Fujii Masao <masao.fujii@gmail.com> wrote:
> >
> > BTW, isn't the current documentation a bit misleading? It says:
> >
> > This function returns a row of NULL values if the sequence does not exist.
> >
> > But if the specified object does not exist, pg_get_sequence_data()
> > raises an error rather than returning a row of NULL values. On the
> > other hand, it does return a row of NULL values if the specified
> > object exists but is not a sequence. Is my understanding correct? If
> > so, how about something like:
>
> When the provided relation oid doesn't exist, returns NULL:
> postgres=# select pg_get_sequence_data(99999999);
> pg_get_sequence_data
> ----------------------
> (,,)
> (1 row)
Yes. If the specified OID does not exist, the function returns a row of
NULL values. However, if the object is specified by name and it does
not exist, an error is raised because the argument has type regclass.
That's why I find the current wording "This function returns a row of
NULL values if the sequence does not exist." a bit misleading.
How about something like this instead?
This function returns a row of NULL values if the specified relation
OID does not exist, if it is not a sequence, if the current user lacks
<literal>SELECT</literal> privilege on the sequence, if the sequence
is another session's temporary sequence, or if it is an unlogged
sequence on a standby server.
> > The attached patch adds those HINT messages. It also updates the
> > related documentation.
>
> Nice! This looks more explicit and clarifying. The patch LGTM.
Thanks for the review!
I've updated the patch furthermore. Attached.
Regards,
--
Fujii Masao
Commits
-
Fix unlogged sequence corruption after standby promotion
- d2980067bc3b 15 (unreleased) landed
- 913d3b610ccd 16 (unreleased) landed
- a1ed6a9a031a 17 (unreleased) landed
- 627605713074 18 (unreleased) landed
- 22af34b98362 19 (unreleased) landed
- 8e684ce11dda master landed
-
doc: Clarify pg_get_sequence_data() privileges and NULL results
- 031904048aa2 19 (unreleased) landed
-
Fix misreporting of publisher sequence permissions during sync
- d4a657b0a4db 19 (unreleased) landed
-
Introduce pg_sequence_read_tuple().
- c8b06bb969bf 18.0 cited