Re: Fix publisher-side sequence permission reporting

From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: vignesh C <vignesh21(at)gmail(dot)com>
Cc: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, Tristan Partin <tristan(at)partin(dot)io>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Fix publisher-side sequence permission reporting
Date: 2026-07-15 13:04:27
Message-ID: CAHGQGwEeGuy-DYbQfcqrAxc-rm-qJuoeDQD938Eb+kYKUxQ4QQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Jul 13, 2026 at 9:48 PM vignesh C <vignesh21(at)gmail(dot)com> wrote:
> I've attached a patch to handle this case by treating a 'NULL'
> privilege value as indicating that the sequence no longer exists and
> reporting it through the existing "missing sequence on publisher"
> path.
> Thoughts?

Thanks for the patch!
It looks good to me overall. I just have a couple of minor comments.

remote_has_select_priv = DatumGetBool(slot_getattr(slot, ++col, &isnull));
- Assert(!isnull);
+ if (isnull)
+ return COPYSEQ_SKIPPED;

Isn't it be better to call DatumGetBool() after checking isnull,
similar to how we handle seqinfo_local->last_value?

- * The remote sequence state can be NULL if the publisher lacks the
- * required privileges or if the sequence was dropped concurrently after
- * it was identified in the catalog snapshot (see pg_get_sequence_data()).

I think it's worth keeping this comment. How about something like
applying the following based on your patch?

----------------------------------------------
/*
* has_sequence_privilege() itself returns NULL, rather than false, when
* the sequence has been dropped concurrently after it was identified in
- * the catalog snapshot (see has_sequence_privilege_id()). Treat that the
- * same as the concurrent-drop case detected via the data columns below,
- * rather than misreporting it as an insufficient-privilege failure.
+ * the catalog snapshot (see has_sequence_privilege_id()). Treat that as
+ * a missing sequence on the publisher.
*/
- remote_has_select_priv = DatumGetBool(slot_getattr(slot, ++col, &isnull));
+ datum = slot_getattr(slot, ++col, &isnull);
if (isnull)
return COPYSEQ_SKIPPED;
+ remote_has_select_priv = DatumGetBool(datum);

+ /*
+ * The remote sequence state can be NULL if the publisher lacks the
+ * required privileges or if the sequence was dropped concurrently after
+ * it was identified in the catalog snapshot (see pg_get_sequence_data()).
+ */
datum = slot_getattr(slot, ++col, &isnull);
if (isnull)
return remote_has_select_priv ? COPYSEQ_SKIPPED :
----------------------------------------------

Regards,

--
Fujii Masao

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Anton Voloshin 2026-07-15 13:35:44 Re: NULL pointer dereference in syslogger with load_libraries() and -DEXEC_BACKEND at startup
Previous Message torikoshia 2026-07-15 12:40:58 Re: Why is the LSN reported for pg_logical_emit_message() different from other decoded operations?