Allow publishing the tables of schema.
authorAmit Kapila <[email protected]>
Wed, 27 Oct 2021 02:14:52 +0000 (07:44 +0530)
committerAmit Kapila <[email protected]>
Wed, 27 Oct 2021 02:14:52 +0000 (07:44 +0530)
commit5a2832465fd8984d089e8c44c094e6900d987fcd
tree68a10449d24643fcdac2b5363accfa7af2196128
parentf0b051e322d530a340e62f2ae16d99acdbcb3d05
Allow publishing the tables of schema.

A new option "FOR ALL TABLES IN SCHEMA" in Create/Alter Publication allows
one or more schemas to be specified, whose tables are selected by the
publisher for sending the data to the subscriber.

The new syntax allows specifying both the tables and schemas. For example:
CREATE PUBLICATION pub1 FOR TABLE t1,t2,t3, ALL TABLES IN SCHEMA s1,s2;
OR
ALTER PUBLICATION pub1 ADD TABLE t1,t2,t3, ALL TABLES IN SCHEMA s1,s2;

A new system table "pg_publication_namespace" has been added, to maintain
the schemas that the user wants to publish through the publication.
Modified the output plugin (pgoutput) to publish the changes if the
relation is part of schema publication.

Updates pg_dump to identify and dump schema publications. Updates the \d
family of commands to display schema publications and \dRp+ variant will
now display associated schemas if any.

Author: Vignesh C, Hou Zhijie, Amit Kapila
Syntax-Suggested-by: Tom Lane, Alvaro Herrera
Reviewed-by: Greg Nancarrow, Masahiko Sawada, Hou Zhijie, Amit Kapila, Haiying Tang, Ajin Cherian, Rahila Syed, Bharath Rupireddy, Mark Dilger
Tested-by: Haiying Tang
Discussion: https://www.postgresql.org/message-id/CALDaNm0OANxuJ6RXqwZsM1MSY4s19nuH3734j4a72etDwvBETQ@mail.gmail.com
46 files changed:
doc/src/sgml/catalogs.sgml
doc/src/sgml/logical-replication.sgml
doc/src/sgml/ref/alter_publication.sgml
doc/src/sgml/ref/create_publication.sgml
doc/src/sgml/ref/psql-ref.sgml
src/backend/catalog/Makefile
src/backend/catalog/aclchk.c
src/backend/catalog/dependency.c
src/backend/catalog/objectaddress.c
src/backend/catalog/pg_publication.c
src/backend/commands/alter.c
src/backend/commands/event_trigger.c
src/backend/commands/publicationcmds.c
src/backend/commands/seclabel.c
src/backend/commands/tablecmds.c
src/backend/nodes/copyfuncs.c
src/backend/nodes/equalfuncs.c
src/backend/parser/gram.y
src/backend/replication/pgoutput/pgoutput.c
src/backend/utils/cache/relcache.c
src/backend/utils/cache/syscache.c
src/bin/pg_dump/common.c
src/bin/pg_dump/pg_backup_archiver.c
src/bin/pg_dump/pg_dump.c
src/bin/pg_dump/pg_dump.h
src/bin/pg_dump/pg_dump_sort.c
src/bin/pg_dump/t/002_pg_dump.pl
src/bin/psql/describe.c
src/bin/psql/tab-complete.c
src/include/catalog/catversion.h
src/include/catalog/dependency.h
src/include/catalog/pg_publication.h
src/include/catalog/pg_publication_namespace.h [new file with mode: 0644]
src/include/commands/publicationcmds.h
src/include/nodes/nodes.h
src/include/nodes/parsenodes.h
src/include/utils/syscache.h
src/test/regress/expected/alter_table.out
src/test/regress/expected/object_address.out
src/test/regress/expected/oidjoins.out
src/test/regress/expected/publication.out
src/test/regress/expected/sanity_check.out
src/test/regress/sql/alter_table.sql
src/test/regress/sql/object_address.sql
src/test/regress/sql/publication.sql
src/tools/pgindent/typedefs.list