Fix misreporting of publisher sequence permissions during sync

When synchronizing sequences for logical replication, a
publisher-side permission failure could be reported as if the sequence
were missing on the publisher, making the real cause harder to
identify.

This happened because pg_get_sequence_data() returns a row of NULL
values when the replication connection lacks permission to read a
sequence. Sequence synchronization treated that the same as a missing
sequence, causing it to emit a misleading "missing sequence on
publisher" warning.

Fix this by distinguishing permission failures from genuinely missing
sequences. The synchronization query now checks whether the
replication connection has the required privilege for each published
sequence, allowing the worker to report permission failures
separately.

Author: Fujii Masao <[email protected]>
Reviewed-by: Tristan Partin <[email protected]>
Discussion: 
https://postgr.es/m/cahgqgwgntaxnbkuv510_p1kwhdbht+kgz4zu5njbhy7ncqd...@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/d4a657b0a4db72ca3fe1a02e851f776276a8d8a1

Modified Files
--------------
src/backend/replication/logical/sequencesync.c | 95 ++++++++++++++++++--------
src/test/subscription/t/036_sequences.pl       | 22 +++++-
2 files changed, 86 insertions(+), 31 deletions(-)

Reply via email to