From 91754fd3c4d5b0771d9140f5956901b0d5b1a406 Mon Sep 17 00:00:00 2001 From: Nisha Moond Date: Tue, 16 Jun 2026 11:12:02 +0530 Subject: [PATCH v14 4/4] Documentation Patch --- doc/src/sgml/logical-replication.sgml | 3 +- doc/src/sgml/ref/alter_publication.sgml | 69 +++++++++++++++++++++++- doc/src/sgml/ref/create_publication.sgml | 24 +++++++-- 3 files changed, 90 insertions(+), 6 deletions(-) diff --git a/doc/src/sgml/logical-replication.sgml b/doc/src/sgml/logical-replication.sgml index 9e7868487de..1433d2660fe 100644 --- a/doc/src/sgml/logical-replication.sgml +++ b/doc/src/sgml/logical-replication.sgml @@ -117,7 +117,8 @@ or FOR ALL SEQUENCES. Unlike tables, sequences can be synchronized at any time. For more information, see . When a publication is - created with FOR ALL TABLES, a table or set of tables can + created with FOR ALL TABLES or + FOR TABLES IN SCHEMA, a table or set of tables can be explicitly excluded from publication using the EXCEPT clause. diff --git a/doc/src/sgml/ref/alter_publication.sgml b/doc/src/sgml/ref/alter_publication.sgml index 52114a16a39..152d3279935 100644 --- a/doc/src/sgml/ref/alter_publication.sgml +++ b/doc/src/sgml/ref/alter_publication.sgml @@ -31,7 +31,7 @@ ALTER PUBLICATION name RENAME TO where publication_object is one of: TABLE table_and_columns [, ... ] - TABLES IN SCHEMA { schema_name | CURRENT_SCHEMA } [, ... ] + TABLES IN SCHEMA tables_in_schema [, ... ] and publication_all_object is one of: @@ -47,6 +47,10 @@ ALTER PUBLICATION name RENAME TO table_object [ ( column_name [, ... ] ) ] [ WHERE ( expression ) ] +and tables_in_schema is: + + { schema_name | CURRENT_SCHEMA } [ EXCEPT ( except_table_object [, ... ] ) ] + and except_table_object is: TABLE table_object [, ... ] @@ -93,7 +97,11 @@ ALTER PUBLICATION name RENAME TO FOR TABLE or FOR TABLES IN SCHEMA, replaces the list of tables/schemas in the publication with the specified list; the existing tables or schemas - that were present in the publication will be removed. + that were present in the publication will be removed. When + SET TABLES IN SCHEMA is used with an + EXCEPT clause, the excluded tables for each schema are + replaced with the specified list; if EXCEPT is omitted + for a schema, any existing exclusions for that schema are cleared. @@ -110,6 +118,12 @@ ALTER PUBLICATION name RENAME TO ADD TABLE. + + The EXCEPT clause can be used with + ADD TABLES IN SCHEMA to exclude specific tables from a + schema-level publication. + + The fourth variant of this command listed in the synopsis can change all of the publication properties specified in @@ -198,6 +212,35 @@ ALTER PUBLICATION name RENAME TO + + EXCEPT + + + When used with ADD TABLES IN SCHEMA + or SET TABLES IN SCHEMA, specifies + tables to be excluded from the publication. Each named + table must belong to the schema specified in the same + TABLES IN SCHEMA clause. Table names may be + schema-qualified or unqualified; unqualified names are implicitly + qualified with the schema named in the same clause. See + for further details on the + semantics of EXCEPT. + + + For FOR TABLES IN SCHEMA publications, the + EXCEPT clause is schema-scoped. If a table listed in + the EXCEPT clause is later moved to a different schema + using ALTER TABLE ... SET SCHEMA, the exclusion is + removed; the table will then be published if its new schema is part of a + publication. If the table is subsequently moved back to the original + schema, the exclusion is not restored, and must be re-established + explicitly using ALTER PUBLICATION. Dropping a table + always removes it from the EXCEPT clause, regardless of + publication type. + + + + SET ( publication_parameter [= value] [, ... ] ) @@ -288,6 +331,28 @@ ALTER PUBLICATION sales_publication ADD TABLES IN SCHEMA marketing, sales; + + Add schema sales to the publication + sales_publication, excluding the + sales.internal and + sales.drafts tables: + +ALTER PUBLICATION sales_publication ADD TABLES IN SCHEMA sales EXCEPT (TABLE internal, drafts); + + + + + Replace the schema list of sales_publication with + sales, excluding only + sales.drafts. Other than + sales.drafts, any previously excluded tables for schema + sales are no longer excluded. Any schemas previously in + sales_publication are removed: + +ALTER PUBLICATION sales_publication SET TABLES IN SCHEMA sales EXCEPT (TABLE drafts); + + + Add tables users, departments and schema diff --git a/doc/src/sgml/ref/create_publication.sgml b/doc/src/sgml/ref/create_publication.sgml index f82d640e6ca..1017396f476 100644 --- a/doc/src/sgml/ref/create_publication.sgml +++ b/doc/src/sgml/ref/create_publication.sgml @@ -28,7 +28,7 @@ CREATE PUBLICATION name where publication_object is one of: TABLE table_and_columns [, ... ] - TABLES IN SCHEMA { schema_name | CURRENT_SCHEMA } [, ... ] + TABLES IN SCHEMA tables_in_schema [, ... ] and publication_all_object is one of: @@ -39,6 +39,10 @@ CREATE PUBLICATION name table_object [ ( column_name [, ... ] ) ] [ WHERE ( expression ) ] +and tables_in_schema is: + + { schema_name | CURRENT_SCHEMA } [ EXCEPT ( except_table_object [, ... ] ) ] + and except_table_object is: TABLE table_object [, ... ] @@ -142,6 +146,8 @@ CREATE PUBLICATION name Marks the publication as one that replicates changes for all tables in the specified list of schemas, including tables created in the future. + Tables listed in the EXCEPT clause for a given schema + are excluded from the publication. @@ -173,7 +179,7 @@ CREATE PUBLICATION name Marks the publication as one that replicates changes for all tables in the database, including tables created in the future. Tables listed in - EXCEPT clause are excluded from the publication. + the EXCEPT clause are excluded from the publication. @@ -198,7 +204,10 @@ CREATE PUBLICATION name This clause specifies a list of tables to be excluded from the - publication. + publication. It can be used with FOR ALL TABLES or + FOR TABLES IN SCHEMA. For FOR TABLES IN + SCHEMA, the exclusion applies only to tables in the schema + associated with the EXCEPT. For inherited tables, if ONLY is specified before the @@ -515,6 +524,15 @@ CREATE PUBLICATION production_publication FOR TABLE users, departments, TABLES I CREATE PUBLICATION sales_publication FOR TABLES IN SCHEMA marketing, sales; + + Create a publication that publishes all changes for all the tables present in + the schema sales, except + internal and drafts: + +CREATE PUBLICATION sales_filtered FOR TABLES IN SCHEMA sales EXCEPT (TABLE internal, drafts); + + + Create a publication that publishes all changes for table users, but replicates only columns user_id and -- 2.50.1 (Apple Git-155)