Add decoding of sequences to built-in replication

Tomas Vondra <tomas.vondra@postgresql.org>

Commit: 75b1521dae1ff1fde17fda2e30e591f2e5d64b6a
Author: Tomas Vondra <tomas.vondra@postgresql.org>
Date: 2022-03-24T17:49:27Z
Releases: 15.0
Add decoding of sequences to built-in replication

This commit adds support for decoding of sequences to the built-in
replication (the infrastructure was added by commit 0da92dc530).

The syntax and behavior mostly mimics handling of tables, i.e. a
publication may be defined as FOR ALL SEQUENCES (replicating all
sequences in a database), FOR ALL SEQUENCES IN SCHEMA (replicating
all sequences in a particular schema) or individual sequences.

To publish sequence modifications, the publication has to include
'sequence' action. The protocol is extended with a new message,
describing sequence increments.

A new system view pg_publication_sequences lists all the sequences
added to a publication, both directly and indirectly. Various psql
commands (\d and \dRp) are improved to also display publications
including a given sequence, or sequences included in a publication.

Author: Tomas Vondra, Cary Huang
Reviewed-by: Peter Eisentraut, Amit Kapila, Hannu Krosing, Andres
             Freund, Petr Jelinek
Discussion: https://postgr.es/m/d045f3c2-6cfb-06d3-5540-e63c320df8bc@enterprisedb.com
Discussion: https://postgr.es/m/1710ed7e13b.cd7177461430746.3372264562543607781@highgo.ca

Files

PathChange+/−
doc/src/sgml/catalogs.sgml modified +81 −0
doc/src/sgml/protocol.sgml modified +119 −0
doc/src/sgml/ref/alter_publication.sgml modified +18 −7
doc/src/sgml/ref/alter_subscription.sgml modified +4 −4
doc/src/sgml/ref/create_publication.sgml modified +36 −15
src/backend/catalog/objectaddress.c modified +33 −11
src/backend/catalog/pg_publication.c modified +299 −29
src/backend/catalog/system_views.sql modified +10 −0
src/backend/commands/publicationcmds.c modified +357 −67
src/backend/commands/sequence.c modified +154 −0
src/backend/commands/subscriptioncmds.c modified +88 −13
src/backend/commands/tablecmds.c modified +26 −1
src/backend/executor/execReplication.c modified +3 −1
src/backend/nodes/copyfuncs.c modified +2 −2
src/backend/nodes/equalfuncs.c modified +2 −2
src/backend/parser/gram.y modified +39 −13
src/backend/replication/logical/proto.c modified +52 −0
src/backend/replication/logical/tablesync.c modified +105 −4
src/backend/replication/logical/worker.c modified +56 −0
src/backend/replication/pgoutput/pgoutput.c modified +74 −5
src/backend/utils/cache/relcache.c modified +25 −3
src/backend/utils/cache/syscache.c modified +3 −3
src/bin/pg_dump/pg_dump.c modified +56 −9
src/bin/pg_dump/pg_dump.h modified +3 −0
src/bin/pg_dump/t/002_pg_dump.pl modified +36 −4
src/bin/psql/describe.c modified +216 −71
src/bin/psql/tab-complete.c modified +8 −4
src/include/catalog/pg_proc.dat modified +5 −0
src/include/catalog/pg_publication.h modified +21 −5
src/include/catalog/pg_publication_namespace.h modified +9 −1
src/include/commands/sequence.h modified +1 −0
src/include/nodes/parsenodes.h modified +6 −2
src/include/replication/logicalproto.h modified +19 −0
src/include/replication/pgoutput.h modified +1 −0
src/test/regress/expected/object_address.out modified +7 −3
src/test/regress/expected/publication.out modified +822 −187
src/test/regress/expected/rules.out modified +8 −0
src/test/regress/sql/object_address.sql modified +4 −1
src/test/regress/sql/publication.sql modified +225 −1
src/test/subscription/t/030_sequences.pl added +202 −0

Documentation touched

Discussion