From 37a3e667efa59375863a8e21fd6627b292ab36c2 Mon Sep 17 00:00:00 2001 From: Nisha Moond Date: Thu, 18 Jun 2026 09:03:08 +0530 Subject: [PATCH v16 4/4] Documentation Patch --- doc/src/sgml/logical-replication.sgml | 3 +- doc/src/sgml/ref/alter_publication.sgml | 58 +++++++++++++++++++++++- doc/src/sgml/ref/create_publication.sgml | 37 ++++++++++++--- 3 files changed, 88 insertions(+), 10 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..037ddfa9404 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 [, ... ] @@ -69,6 +73,9 @@ ALTER PUBLICATION name RENAME TO ADD and DROP clauses will add and remove one or more tables/schemas from the publication. + The EXCEPT clause can be used with + ADD TABLES IN SCHEMA to exclude specific tables from a + schema-level publication. @@ -93,7 +100,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. @@ -198,6 +209,27 @@ 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. + + + Dropping a table always removes it from the EXCEPT + clause. + + + + SET ( publication_parameter [= value] [, ... ] ) @@ -288,6 +320,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 85cfcaddafa..5227dd716ed 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,13 +204,21 @@ 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. - Once a table is excluded, the exclusion applies to that table - regardless of its name or schema. Renaming the table or moving it to - another schema using ALTER TABLE ... SET SCHEMA does - not remove the exclusion. + Once a table is excluded under FOR ALL TABLES, the + exclusion applies to that table regardless of its name or schema. + Renaming the table or moving it to another schema using + ALTER TABLE ... SET SCHEMA does not remove the + exclusion. However, for FOR TABLES IN SCHEMA, because + the EXCEPT is schema-scoped, moving a schema-excluded + table to another schema does remove the exclusion; if the table is later + moved back, the exclusion is not restored and must be re-established + with ALTER PUBLICATION. For inherited tables, if ONLY is specified before the @@ -521,6 +535,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)