Add decoding of sequences to built-in replication
authorTomas Vondra <tomas.vondra@postgresql.org>
Thu, 24 Mar 2022 17:20:21 +0000 (18:20 +0100)
committerTomas Vondra <tomas.vondra@postgresql.org>
Thu, 24 Mar 2022 17:49:27 +0000 (18:49 +0100)
commit75b1521dae1ff1fde17fda2e30e591f2e5d64b6a
tree924b88a40d67da7b5b441f2f37a7a5d6daa79f49
parent0adb3dc68bfb9a347ff2c7fe63200419bb649265
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
40 files changed:
doc/src/sgml/catalogs.sgml
doc/src/sgml/protocol.sgml
doc/src/sgml/ref/alter_publication.sgml
doc/src/sgml/ref/alter_subscription.sgml
doc/src/sgml/ref/create_publication.sgml
src/backend/catalog/objectaddress.c
src/backend/catalog/pg_publication.c
src/backend/catalog/system_views.sql
src/backend/commands/publicationcmds.c
src/backend/commands/sequence.c
src/backend/commands/subscriptioncmds.c
src/backend/commands/tablecmds.c
src/backend/executor/execReplication.c
src/backend/nodes/copyfuncs.c
src/backend/nodes/equalfuncs.c
src/backend/parser/gram.y
src/backend/replication/logical/proto.c
src/backend/replication/logical/tablesync.c
src/backend/replication/logical/worker.c
src/backend/replication/pgoutput/pgoutput.c
src/backend/utils/cache/relcache.c
src/backend/utils/cache/syscache.c
src/bin/pg_dump/pg_dump.c
src/bin/pg_dump/pg_dump.h
src/bin/pg_dump/t/002_pg_dump.pl
src/bin/psql/describe.c
src/bin/psql/tab-complete.c
src/include/catalog/pg_proc.dat
src/include/catalog/pg_publication.h
src/include/catalog/pg_publication_namespace.h
src/include/commands/sequence.h
src/include/nodes/parsenodes.h
src/include/replication/logicalproto.h
src/include/replication/pgoutput.h
src/test/regress/expected/object_address.out
src/test/regress/expected/publication.out
src/test/regress/expected/rules.out
src/test/regress/sql/object_address.sql
src/test/regress/sql/publication.sql
src/test/subscription/t/030_sequences.pl [new file with mode: 0644]