pgsql: Add decoding of sequences to built-in replication

From: Tomas Vondra <tomas(dot)vondra(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Add decoding of sequences to built-in replication
Date: 2022-03-24 17:49:45
Message-ID: E1nXRai-001CRk-Cw@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/75b1521dae1ff1fde17fda2e30e591f2e5d64b6a

Modified Files
--------------
doc/src/sgml/catalogs.sgml | 81 ++
doc/src/sgml/protocol.sgml | 119 +++
doc/src/sgml/ref/alter_publication.sgml | 25 +-
doc/src/sgml/ref/alter_subscription.sgml | 8 +-
doc/src/sgml/ref/create_publication.sgml | 51 +-
src/backend/catalog/objectaddress.c | 44 +-
src/backend/catalog/pg_publication.c | 328 +++++++-
src/backend/catalog/system_views.sql | 10 +
src/backend/commands/publicationcmds.c | 424 ++++++++--
src/backend/commands/sequence.c | 154 ++++
src/backend/commands/subscriptioncmds.c | 101 ++-
src/backend/commands/tablecmds.c | 27 +-
src/backend/executor/execReplication.c | 4 +-
src/backend/nodes/copyfuncs.c | 4 +-
src/backend/nodes/equalfuncs.c | 4 +-
src/backend/parser/gram.y | 52 +-
src/backend/replication/logical/proto.c | 52 ++
src/backend/replication/logical/tablesync.c | 109 ++-
src/backend/replication/logical/worker.c | 56 ++
src/backend/replication/pgoutput/pgoutput.c | 79 +-
src/backend/utils/cache/relcache.c | 28 +-
src/backend/utils/cache/syscache.c | 6 +-
src/bin/pg_dump/pg_dump.c | 65 +-
src/bin/pg_dump/pg_dump.h | 3 +
src/bin/pg_dump/t/002_pg_dump.pl | 40 +-
src/bin/psql/describe.c | 287 +++++--
src/bin/psql/tab-complete.c | 12 +-
src/include/catalog/pg_proc.dat | 5 +
src/include/catalog/pg_publication.h | 26 +-
src/include/catalog/pg_publication_namespace.h | 10 +-
src/include/commands/sequence.h | 1 +
src/include/nodes/parsenodes.h | 8 +-
src/include/replication/logicalproto.h | 19 +
src/include/replication/pgoutput.h | 1 +
src/test/regress/expected/object_address.out | 10 +-
src/test/regress/expected/publication.out | 1009 +++++++++++++++++++-----
src/test/regress/expected/rules.out | 8 +
src/test/regress/sql/object_address.sql | 5 +-
src/test/regress/sql/publication.sql | 226 +++++-
src/test/subscription/t/030_sequences.pl | 202 +++++
40 files changed, 3235 insertions(+), 468 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2022-03-24 18:09:49 Re: pgsql: Change fastgetattr and heap_getattr to inline functions
Previous Message Tom Lane 2022-03-24 17:34:45 pgsql: Doc: add some documentation about serialization failure handling