=== Applying patches on top of PostgreSQL commit ID 3e8e05596a020f043f1efd6406e4511ea85170bd === /etc/rc.d/jail: WARNING: Per-jail configuration via jail_* variables is obsolete. Please consider migrating to /etc/jail.conf. Tue Oct 28 06:47:24 UTC 2025 On branch cf/6099 nothing to commit, working tree clean === using 'git am' to apply patch ./v24-0001-Add-RESET-clause-to-Alter-Publication-which-will.patch === Applying: Add RESET clause to Alter Publication which will reset the publication with default values. Using index info to reconstruct a base tree... M doc/src/sgml/ref/alter_publication.sgml M src/backend/commands/publicationcmds.c M src/backend/parser/gram.y M src/bin/psql/tab-complete.in.c M src/include/nodes/parsenodes.h M src/test/regress/expected/publication.out M src/test/regress/sql/publication.sql Falling back to patching base and 3-way merge... Auto-merging src/test/regress/sql/publication.sql Auto-merging src/test/regress/expected/publication.out Auto-merging src/include/nodes/parsenodes.h Auto-merging src/bin/psql/tab-complete.in.c Auto-merging src/backend/parser/gram.y Auto-merging src/backend/commands/publicationcmds.c Auto-merging doc/src/sgml/ref/alter_publication.sgml === using 'git am' to apply patch ./v24-0002-Skip-publishing-the-tables-specified-in-EXCEPT-T.patch === Applying: Skip publishing the tables specified in EXCEPT TABLE. Using index info to reconstruct a base tree... M doc/src/sgml/catalogs.sgml M doc/src/sgml/logical-replication.sgml M doc/src/sgml/ref/alter_publication.sgml M doc/src/sgml/ref/create_publication.sgml M src/backend/catalog/pg_publication.c M src/backend/commands/publicationcmds.c M src/backend/commands/tablecmds.c M src/backend/parser/gram.y M src/backend/replication/pgoutput/pgoutput.c M src/bin/pg_dump/pg_dump.c M src/bin/pg_dump/pg_dump.h M src/bin/pg_dump/pg_dump_sort.c M src/bin/pg_dump/t/002_pg_dump.pl M src/bin/psql/describe.c M src/bin/psql/tab-complete.in.c M src/include/catalog/pg_publication.h M src/include/nodes/parsenodes.h M src/test/regress/expected/publication.out M src/test/regress/sql/publication.sql M src/test/subscription/meson.build Falling back to patching base and 3-way merge... Auto-merging src/test/subscription/meson.build CONFLICT (content): Merge conflict in src/test/subscription/meson.build Auto-merging src/test/regress/sql/publication.sql Auto-merging src/test/regress/expected/publication.out CONFLICT (content): Merge conflict in src/test/regress/expected/publication.out Auto-merging src/include/nodes/parsenodes.h Auto-merging src/include/catalog/pg_publication.h CONFLICT (content): Merge conflict in src/include/catalog/pg_publication.h Auto-merging src/bin/psql/tab-complete.in.c Auto-merging src/bin/psql/describe.c Auto-merging src/bin/pg_dump/t/002_pg_dump.pl CONFLICT (content): Merge conflict in src/bin/pg_dump/t/002_pg_dump.pl Auto-merging src/bin/pg_dump/pg_dump_sort.c Auto-merging src/bin/pg_dump/pg_dump.h Auto-merging src/bin/pg_dump/pg_dump.c CONFLICT (content): Merge conflict in src/bin/pg_dump/pg_dump.c Auto-merging src/backend/replication/pgoutput/pgoutput.c Auto-merging src/backend/parser/gram.y CONFLICT (content): Merge conflict in src/backend/parser/gram.y Auto-merging src/backend/commands/tablecmds.c Auto-merging src/backend/commands/publicationcmds.c CONFLICT (content): Merge conflict in src/backend/commands/publicationcmds.c Auto-merging src/backend/catalog/pg_publication.c CONFLICT (content): Merge conflict in src/backend/catalog/pg_publication.c Auto-merging doc/src/sgml/ref/create_publication.sgml CONFLICT (content): Merge conflict in doc/src/sgml/ref/create_publication.sgml Auto-merging doc/src/sgml/ref/alter_publication.sgml Auto-merging doc/src/sgml/logical-replication.sgml Auto-merging doc/src/sgml/catalogs.sgml error: Failed to merge in the changes. hint: Use 'git am --show-current-patch=diff' to see the failed patch Patch failed at 0001 Skip publishing the tables specified in EXCEPT TABLE. When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort". Unstaged changes after reset: M doc/src/sgml/catalogs.sgml M doc/src/sgml/logical-replication.sgml M doc/src/sgml/ref/alter_publication.sgml M doc/src/sgml/ref/create_publication.sgml M doc/src/sgml/ref/psql-ref.sgml M src/backend/catalog/pg_publication.c M src/backend/commands/publicationcmds.c M src/backend/commands/tablecmds.c M src/backend/parser/gram.y M src/backend/replication/pgoutput/pgoutput.c M src/backend/utils/cache/relcache.c M src/bin/pg_dump/pg_dump.c M src/bin/pg_dump/pg_dump.h M src/bin/pg_dump/pg_dump_sort.c M src/bin/pg_dump/t/002_pg_dump.pl M src/bin/psql/describe.c M src/bin/psql/tab-complete.in.c M src/include/catalog/pg_publication.h M src/include/catalog/pg_publication_rel.h M src/include/commands/publicationcmds.h M src/include/nodes/parsenodes.h M src/test/regress/expected/publication.out M src/test/regress/sql/publication.sql M src/test/subscription/meson.build Removing src/test/subscription/t/036_rep_changes_except_table.pl === using patch(1) to apply patch ./v24-0002-Skip-publishing-the-tables-specified-in-EXCEPT-T.patch === patching file doc/src/sgml/catalogs.sgml Hunk #1 succeeded at 6581 (offset 13 lines). patching file doc/src/sgml/logical-replication.sgml Hunk #1 succeeded at 2301 (offset 2 lines). patching file doc/src/sgml/ref/alter_publication.sgml Hunk #4 succeeded at 137 (offset 1 line). Hunk #5 succeeded at 247 (offset 2 lines). patching file doc/src/sgml/ref/create_publication.sgml Hunk #1 FAILED at 22. Hunk #2 FAILED at 30. Hunk #3 succeeded at 160 (offset 35 lines). Hunk #4 succeeded at 182 (offset 19 lines). Hunk #5 succeeded at 495 (offset 21 lines). 2 out of 5 hunks FAILED -- saving rejects to file doc/src/sgml/ref/create_publication.sgml.rej patching file doc/src/sgml/ref/psql-ref.sgml patching file src/backend/catalog/pg_publication.c Hunk #1 succeeded at 354 (offset 3 lines). Hunk #2 succeeded at 367 (offset 3 lines). Hunk #3 succeeded at 479 (offset 3 lines). Hunk #4 succeeded at 506 (offset 3 lines). Hunk #5 succeeded at 775 (offset 3 lines). Hunk #6 succeeded at 791 (offset 3 lines). Hunk #7 FAILED at 798. Hunk #8 succeeded at 832 (offset 3 lines). Hunk #9 FAILED at 891. Hunk #10 succeeded at 921 (offset 7 lines). Hunk #11 succeeded at 943 (offset 7 lines). Hunk #12 FAILED at 1192. Hunk #13 succeeded at 1210 (offset 9 lines). 3 out of 13 hunks FAILED -- saving rejects to file src/backend/catalog/pg_publication.c.rej patching file src/backend/commands/publicationcmds.c Hunk #7 FAILED at 927. Hunk #8 succeeded at 1057 (offset 23 lines). Hunk #9 succeeded at 1177 (offset 23 lines). Hunk #10 succeeded at 1273 (offset 23 lines). Hunk #11 succeeded at 1321 (offset 23 lines). Hunk #12 succeeded at 1342 (offset 23 lines). Hunk #13 succeeded at 1453 (offset 23 lines). Hunk #14 succeeded at 1555 (offset 23 lines). Hunk #15 succeeded at 1606 (offset 23 lines). Hunk #16 succeeded at 1760 (offset 53 lines). Hunk #17 succeeded at 1986 (offset 53 lines). Hunk #18 succeeded at 2059 (offset 53 lines). 1 out of 18 hunks FAILED -- saving rejects to file src/backend/commands/publicationcmds.c.rej patching file src/backend/commands/tablecmds.c Hunk #1 succeeded at 8626 (offset -1 lines). Hunk #2 succeeded at 18821 (offset -1 lines). patching file src/backend/parser/gram.y Hunk #1 FAILED at 446. Hunk #2 FAILED at 584. Hunk #3 FAILED at 10703. Hunk #4 FAILED at 10723. Hunk #5 succeeded at 10781 (offset 15 lines). Hunk #6 succeeded at 10879 with fuzz 2 (offset 37 lines). Hunk #7 succeeded at 10910 (offset 37 lines). Hunk #8 succeeded at 10938 (offset 37 lines). 4 out of 8 hunks FAILED -- saving rejects to file src/backend/parser/gram.y.rej patching file src/backend/replication/pgoutput/pgoutput.c Hunk #1 succeeded at 2084 (offset 19 lines). Hunk #2 succeeded at 2196 (offset 19 lines). Hunk #3 succeeded at 2214 (offset 19 lines). Hunk #4 succeeded at 2230 (offset 19 lines). Hunk #5 succeeded at 2310 (offset 19 lines). patching file src/backend/utils/cache/relcache.c patching file src/bin/pg_dump/pg_dump.c Hunk #2 FAILED at 4653. Hunk #3 succeeded at 4833 (offset 13 lines). Hunk #4 succeeded at 4845 (offset 13 lines). Hunk #5 succeeded at 4865 (offset 13 lines). Hunk #6 succeeded at 4881 (offset 13 lines). Hunk #7 succeeded at 4893 (offset 13 lines). Hunk #8 succeeded at 4907 (offset 13 lines). Hunk #9 succeeded at 4952 (offset 13 lines). Hunk #10 succeeded at 11833 (offset 15 lines). Hunk #11 succeeded at 20202 (offset 10 lines). 1 out of 11 hunks FAILED -- saving rejects to file src/bin/pg_dump/pg_dump.c.rej patching file src/bin/pg_dump/pg_dump.h patching file src/bin/pg_dump/pg_dump_sort.c Hunk #3 succeeded at 445 (offset 1 line). Hunk #4 succeeded at 1728 (offset 1 line). patching file src/bin/pg_dump/t/002_pg_dump.pl Hunk #1 succeeded at 3170 (offset -262 lines). patching file src/bin/psql/describe.c Hunk #1 succeeded at 3073 (offset 34 lines). Hunk #2 succeeded at 6770 (offset 60 lines). Hunk #3 succeeded at 6793 (offset 60 lines). patching file src/bin/psql/tab-complete.in.c Hunk #1 succeeded at 2280 (offset 1 line). Hunk #2 succeeded at 3597 with fuzz 2 (offset 1 line). patching file src/include/catalog/pg_publication.h Hunk #1 succeeded at 146 (offset 7 lines). Hunk #2 FAILED at 162. Hunk #3 succeeded at 182 (offset 7 lines). 1 out of 3 hunks FAILED -- saving rejects to file src/include/catalog/pg_publication.h.rej patching file src/include/catalog/pg_publication_rel.h patching file src/include/commands/publicationcmds.h patching file src/include/nodes/parsenodes.h Hunk #1 succeeded at 4271 (offset 3 lines). Hunk #2 succeeded at 4280 (offset 3 lines). Hunk #3 succeeded at 4344 (offset 21 lines). patching file src/test/regress/expected/publication.out Hunk #1 succeeded at 213 with fuzz 1. Hunk #2 FAILED at 262. Hunk #3 succeeded at 2036 (offset 86 lines). Hunk #4 succeeded at 2061 (offset 86 lines). Hunk #5 succeeded at 2097 (offset 86 lines). Hunk #6 succeeded at 2120 (offset 86 lines). Hunk #7 succeeded at 2143 (offset 86 lines). Hunk #8 succeeded at 2187 (offset 86 lines). 1 out of 8 hunks FAILED -- saving rejects to file src/test/regress/expected/publication.out.rej patching file src/test/regress/sql/publication.sql Hunk #1 succeeded at 105 with fuzz 2. Hunk #2 succeeded at 1284 (offset 46 lines). Hunk #3 succeeded at 1315 (offset 46 lines). Hunk #4 succeeded at 1325 (offset 46 lines). Hunk #5 succeeded at 1336 (offset 46 lines). Hunk #6 succeeded at 1356 (offset 46 lines). patching file src/test/subscription/meson.build Hunk #1 FAILED at 45. 1 out of 1 hunk FAILED -- saving rejects to file src/test/subscription/meson.build.rej patching file src/test/subscription/t/036_rep_changes_except_table.pl Unstaged changes after reset: M doc/src/sgml/catalogs.sgml M doc/src/sgml/logical-replication.sgml M doc/src/sgml/ref/alter_publication.sgml M doc/src/sgml/ref/create_publication.sgml M doc/src/sgml/ref/psql-ref.sgml M src/backend/catalog/pg_publication.c M src/backend/commands/publicationcmds.c M src/backend/commands/tablecmds.c M src/backend/parser/gram.y M src/backend/replication/pgoutput/pgoutput.c M src/backend/utils/cache/relcache.c M src/bin/pg_dump/pg_dump.c M src/bin/pg_dump/pg_dump.h M src/bin/pg_dump/pg_dump_sort.c M src/bin/pg_dump/t/002_pg_dump.pl M src/bin/psql/describe.c M src/bin/psql/tab-complete.in.c M src/include/catalog/pg_publication.h M src/include/catalog/pg_publication_rel.h M src/include/commands/publicationcmds.h M src/include/nodes/parsenodes.h M src/test/regress/expected/publication.out M src/test/regress/sql/publication.sql Removing doc/src/sgml/ref/create_publication.sgml.rej Removing src/backend/catalog/pg_publication.c.rej Removing src/backend/commands/publicationcmds.c.rej Removing src/backend/parser/gram.y.rej Removing src/bin/pg_dump/pg_dump.c.rej Removing src/include/catalog/pg_publication.h.rej Removing src/test/regress/expected/publication.out.rej Removing src/test/subscription/meson.build.rej Removing src/test/subscription/t/036_rep_changes_except_table.pl === using 'git apply' to apply patch ./v24-0002-Skip-publishing-the-tables-specified-in-EXCEPT-T.patch === Applied patch to 'doc/src/sgml/catalogs.sgml' cleanly. Applied patch to 'doc/src/sgml/logical-replication.sgml' cleanly. Applied patch to 'doc/src/sgml/ref/alter_publication.sgml' cleanly. Applied patch to 'doc/src/sgml/ref/create_publication.sgml' with conflicts. Applied patch to 'doc/src/sgml/ref/psql-ref.sgml' cleanly. Applied patch to 'src/backend/catalog/pg_publication.c' with conflicts. Applied patch to 'src/backend/commands/publicationcmds.c' with conflicts. Applied patch to 'src/backend/commands/tablecmds.c' cleanly. Applied patch to 'src/backend/parser/gram.y' with conflicts. Applied patch to 'src/backend/replication/pgoutput/pgoutput.c' cleanly. Applied patch to 'src/backend/utils/cache/relcache.c' cleanly. Applied patch to 'src/bin/pg_dump/pg_dump.c' with conflicts. Applied patch to 'src/bin/pg_dump/pg_dump.h' cleanly. Applied patch to 'src/bin/pg_dump/pg_dump_sort.c' cleanly. Applied patch to 'src/bin/pg_dump/t/002_pg_dump.pl' with conflicts. Applied patch to 'src/bin/psql/describe.c' cleanly. Applied patch to 'src/bin/psql/tab-complete.in.c' cleanly. Applied patch to 'src/include/catalog/pg_publication.h' with conflicts. Applied patch to 'src/include/catalog/pg_publication_rel.h' cleanly. Applied patch to 'src/include/commands/publicationcmds.h' cleanly. Applied patch to 'src/include/nodes/parsenodes.h' cleanly. Applied patch to 'src/test/regress/expected/publication.out' with conflicts. Applied patch to 'src/test/regress/sql/publication.sql' cleanly. Applied patch to 'src/test/subscription/meson.build' with conflicts. Falling back to direct application... U doc/src/sgml/ref/create_publication.sgml U src/backend/catalog/pg_publication.c U src/backend/commands/publicationcmds.c U src/backend/parser/gram.y U src/bin/pg_dump/pg_dump.c U src/bin/pg_dump/t/002_pg_dump.pl U src/include/catalog/pg_publication.h U src/test/regress/expected/publication.out U src/test/subscription/meson.build diff --cc doc/src/sgml/ref/create_publication.sgml index 66a70e5c5b5,bddff9ca0cc..00000000000 --- a/doc/src/sgml/ref/create_publication.sgml +++ b/doc/src/sgml/ref/create_publication.sgml @@@ -22,7 -22,8 +22,12 @@@ PostgreSQL documentatio CREATE PUBLICATION name ++<<<<<<< ours + [ FOR { publication_object [, ... ] | all_publication_object [, ... ] } ] ++======= + [ FOR ALL TABLES [ EXCEPT [ TABLE ] exception_object [, ... ] ] + | FOR publication_object [, ... ] ] ++>>>>>>> theirs [ WITH ( publication_parameter [= value] [, ... ] ) ] where publication_object is one of: @@@ -30,10 -31,9 +35,16 @@@ TABLE [ ONLY ] table_name [ * ] [ ( column_name [, ... ] ) ] [ WHERE ( expression ) ] [, ... ] TABLES IN SCHEMA { schema_name | CURRENT_SCHEMA } [, ... ] ++<<<<<<< ours +where all_publication_object is one of: + + ALL TABLES + ALL SEQUENCES ++======= + where exception_object is: + + [ ONLY ] table_name [ * ] ++>>>>>>> theirs @@@ -124,6 -124,18 +135,21 @@@ ++<<<<<<< ours ++======= + + FOR ALL TABLES + + + Marks the publication as one that replicates changes for all tables in + the database, including tables created in the future. If + EXCEPT TABLE is specified, then exclude replicating + the changes for the specified tables. + + + + ++>>>>>>> theirs FOR TABLES IN SCHEMA @@@ -155,27 -167,32 +181,56 @@@ ++<<<<<<< ours + + FOR ALL TABLES + + + Marks the publication as one that replicates changes for all tables in + the database, including tables created in the future. + + + + + + FOR ALL SEQUENCES + + + Marks the publication as one that synchronizes changes for all sequences + in the database, including sequences created in the future. + + + + Only persistent sequences are included in the publication. Temporary + sequences and unlogged sequences are excluded from the publication. ++======= + + EXCEPT TABLE + + + This clause specifies a list of tables to be excluded from the + publication. It can only be used with FOR ALL TABLES. + If ONLY is specified before the table name, only + that table is excluded from the publication. If ONLY is + not specified, the table and all its descendant tables (if any) are + excluded. Optionally, * can be specified after the + table name to explicitly indicate that descendant tables are excluded. + This does not apply to a partitioned table, however. The partitioned + table or its partitions are excluded from the publication based on the + parameter publish_via_partition_root. + + + When publish_via_partition_root is set to + true, specifying a root partitioned table in + EXCEPT TABLE excludes it and all its partitions from + replication. Specifying a leaf partition has no effect, as its changes are + still replicated via the root partitioned table. When + publish_via_partition_root is set to + false, specifying a partitioned table or non-leaf + partition has no effect, as changes are replicated via the leaf + partitions. Specifying a leaf partition excludes only that partition from + replication. ++>>>>>>> theirs diff --cc src/backend/catalog/pg_publication.c index ac2f4ee3561,af1b8c9ed67..00000000000 --- a/src/backend/catalog/pg_publication.c +++ b/src/backend/catalog/pg_publication.c @@@ -774,13 -798,14 +801,14 @@@ GetRelationPublications(Oid relid, boo } /* - * Gets list of relation oids for a publication. + * Gets list of relation oids for a publication that matches the except_flag. * - * This should only be used FOR TABLE publications, the FOR ALL TABLES - * should use GetAllTablesPublicationRelations(). + * This should only be used FOR TABLE publications, the FOR ALL TABLES/SEQUENCES + * should use GetAllPublicationRelations(). */ List * - GetPublicationRelations(Oid pubid, PublicationPartOpt pub_partopt) + GetPublicationRelations(Oid pubid, PublicationPartOpt pub_partopt, + bool except_flag) { List *result; Relation pubrelsrel; @@@ -862,20 -889,23 +893,30 @@@ GetAllTablesPublications(void * * If the publication publishes partition changes via their respective root * partitioned tables, we must exclude partitions in favor of including the - * root partitioned tables. + * root partitioned tables. This is not applicable to FOR ALL SEQUENCES + * publication. */ List * ++<<<<<<< ours +GetAllPublicationRelations(char relkind, bool pubviaroot) ++======= + GetAllTablesPublicationRelations(Oid pubid, bool pubviaroot) ++>>>>>>> theirs { Relation classRel; ScanKeyData key[1]; TableScanDesc scan; HeapTuple tuple; List *result = NIL; + List *exceptlist; + + exceptlist = GetPublicationRelations(pubid, pubviaroot ? + PUBLICATION_PART_ALL : + PUBLICATION_PART_ROOT, + true); + Assert(!(relkind == RELKIND_SEQUENCE && pubviaroot)); + classRel = table_open(RelationRelationId, AccessShareLock); ScanKeyInit(&key[0], @@@ -1168,8 -1199,8 +1211,13 @@@ pg_get_publication_tables(PG_FUNCTION_A * those. Otherwise, get the partitioned table itself. */ if (pub_elem->alltables) ++<<<<<<< ours + pub_elem_tables = GetAllPublicationRelations(RELKIND_RELATION, + pub_elem->pubviaroot); ++======= + pub_elem_tables = GetAllTablesPublicationRelations(pub_elem->oid, + pub_elem->pubviaroot); ++>>>>>>> theirs else { List *relids, diff --cc src/backend/commands/publicationcmds.c index 355d5c234af,7f847b116bf..00000000000 --- a/src/backend/commands/publicationcmds.c +++ b/src/backend/commands/publicationcmds.c @@@ -932,52 -927,39 +939,56 @@@ CreatePublication(ParseState *pstate, C /* Make the changes visible. */ CommandCounterIncrement(); ++<<<<<<< ours + /* Associate objects with the publication. */ + if (stmt->for_all_tables) + { + /* + * Invalidate relcache so that publication info is rebuilt. Sequences + * publication doesn't require invalidation, as replica identity + * checks don't apply to them. + */ + CacheInvalidateRelcacheAll(); + } + else if (!stmt->for_all_sequences) + { + ObjectsInPublicationToOids(stmt->pubobjects, pstate, &relations, + &schemaidlist); ++======= + ObjectsInPublicationToOids(stmt->pubobjects, pstate, &relations, + &schemaidlist); ++>>>>>>> theirs - /* FOR TABLES IN SCHEMA requires superuser */ - if (schemaidlist != NIL && !superuser()) - ereport(ERROR, - errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), - errmsg("must be superuser to create FOR TABLES IN SCHEMA publication")); + /* FOR TABLES IN SCHEMA requires superuser */ + if (schemaidlist != NIL && !superuser()) + ereport(ERROR, + errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), + errmsg("must be superuser to create FOR TABLES IN SCHEMA publication")); - if (relations != NIL) - { - List *rels; + if (relations != NIL) + { + List *rels; - rels = OpenTableList(relations); - TransformPubWhereClauses(rels, pstate->p_sourcetext, - publish_via_partition_root); + rels = OpenTableList(relations); + TransformPubWhereClauses(rels, pstate->p_sourcetext, + publish_via_partition_root); - CheckPubRelationColumnList(stmt->pubname, rels, - schemaidlist != NIL, - publish_via_partition_root); + CheckPubRelationColumnList(stmt->pubname, rels, + schemaidlist != NIL, + publish_via_partition_root); - PublicationAddTables(puboid, rels, true, NULL); - CloseTableList(rels); - } + PublicationAddTables(puboid, rels, true, NULL); + CloseTableList(rels); + } - if (schemaidlist != NIL) - { - /* - * Schema lock is held until the publication is created to prevent - * concurrent schema deletion. - */ - LockSchemaList(schemaidlist); - PublicationAddSchemas(puboid, schemaidlist, true, NULL); - } + if (schemaidlist != NIL) + { + /* + * Schema lock is held until the publication is created to prevent + * concurrent schema deletion. + */ + LockSchemaList(schemaidlist); + PublicationAddSchemas(puboid, schemaidlist, true, NULL); } table_close(rel, RowExclusiveLock); diff --cc src/backend/parser/gram.y index d577732a474,2512889cb9e..00000000000 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@@ -452,7 -446,7 +452,11 @@@ static Node *makeRecursiveViewSelect(ch transform_element_list transform_type_list TriggerTransitions TriggerReferencing vacuum_relation_list opt_vacuum_relation_list ++<<<<<<< ours + drop_option_list pub_obj_list pub_obj_type_list ++======= + drop_option_list pub_obj_list except_pub_obj_list ++>>>>>>> theirs %type returning_clause %type returning_option @@@ -590,7 -584,7 +594,11 @@@ %type var_value zone_value %type auth_ident RoleSpec opt_granted_by %type PublicationObjSpec ++<<<<<<< ours +%type PublicationAllObjSpec ++======= + %type ExceptPublicationObjSpec ++>>>>>>> theirs %type unreserved_keyword type_func_name_keyword %type col_name_keyword reserved_keyword @@@ -10710,12 -10704,7 +10718,16 @@@ AlterOwnerStmt: ALTER AGGREGATE aggrega * * CREATE PUBLICATION name [WITH options] * ++<<<<<<< ours + * CREATE PUBLICATION FOR ALL pub_obj_type [, ...] [WITH options] + * + * pub_obj_type is one of: + * + * TABLES + * SEQUENCES ++======= + * CREATE PUBLICATION FOR ALL TABLES [EXCEPT [TABLE] table [, ...]] [WITH options] ++>>>>>>> theirs * * CREATE PUBLICATION FOR pub_obj [, ...] [WITH options] * @@@ -10735,16 -10724,14 +10747,26 @@@ CreatePublicationStmt n->options = $4; $$ = (Node *) n; } ++<<<<<<< ours + | CREATE PUBLICATION name FOR pub_obj_type_list opt_definition ++======= + | CREATE PUBLICATION name FOR ALL TABLES except_pub_obj_list opt_definition ++>>>>>>> theirs { CreatePublicationStmt *n = makeNode(CreatePublicationStmt); n->pubname = $3; ++<<<<<<< ours + n->pubobjects = (List *) $5; + preprocess_pub_all_objtype_list($5, &n->for_all_tables, + &n->for_all_sequences, + yyscanner); + n->options = $6; ++======= + n->options = $8; + n->pubobjects = (List *)$7; + n->for_all_tables = true; ++>>>>>>> theirs $$ = (Node *) n; } | CREATE PUBLICATION name FOR pub_obj_list opt_definition @@@ -10856,28 -10844,25 +10879,50 @@@ pub_obj_list: PublicationObjSpe { $$ = lappend($1, $3); } ; ++<<<<<<< ours +PublicationAllObjSpec: + ALL TABLES + { + $$ = makeNode(PublicationAllObjSpec); + $$->pubobjtype = PUBLICATION_ALL_TABLES; + $$->location = @1; + } + | ALL SEQUENCES + { + $$ = makeNode(PublicationAllObjSpec); + $$->pubobjtype = PUBLICATION_ALL_SEQUENCES; + $$->location = @1; + } + ; + +pub_obj_type_list: PublicationAllObjSpec + { $$ = list_make1($1); } + | pub_obj_type_list ',' PublicationAllObjSpec + { $$ = lappend($1, $3); } + ; + + ++======= + ExceptPublicationObjSpec: + relation_expr + { + $$ = makeNode(PublicationObjSpec); + $$->pubobjtype = PUBLICATIONOBJ_EXCEPT_TABLE; + $$->pubtable = makeNode(PublicationTable); + $$->pubtable->except = true; + $$->pubtable->relation = $1; + $$->location = @1; + } + ; + + except_pub_obj_list: EXCEPT opt_table ExceptPublicationObjSpec + { $$ = list_make1($3); } + | except_pub_obj_list ',' ExceptPublicationObjSpec + { $$ = lappend($1, $3); } + | /*EMPTY*/ { $$ = NULL; } + ; + ++>>>>>>> theirs /***************************************************************************** * * ALTER PUBLICATION name SET ( options ) diff --cc src/bin/pg_dump/pg_dump.c index 47913178a93,5b8cb277026..00000000000 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@@ -4659,13 -4652,35 +4661,43 @@@ dumpPublication(Archive *fout, const Pu appendPQExpBuffer(query, "CREATE PUBLICATION %s", qpubname); ++<<<<<<< ours + if (pubinfo->puballtables && pubinfo->puballsequences) + appendPQExpBufferStr(query, " FOR ALL TABLES, ALL SEQUENCES"); + else if (pubinfo->puballtables) ++======= + if (pubinfo->puballtables) + { + SimplePtrListCell *cell; + ++>>>>>>> theirs appendPQExpBufferStr(query, " FOR ALL TABLES"); + else if (pubinfo->puballsequences) + appendPQExpBufferStr(query, " FOR ALL SEQUENCES"); + /* Include exception tables if the publication has except tables */ + for (cell = exceptinfo.head; cell; cell = cell->next) + { + PublicationRelInfo *pubrinfo = (PublicationRelInfo *) cell->ptr; + TableInfo *tbinfo; + + if (pubinfo == pubrinfo->publication) + { + tbinfo = pubrinfo->pubtable; + + if (first) + { + appendPQExpBufferStr(query, " EXCEPT TABLE"); + first = false; + } + else + appendPQExpBufferStr(query, ","); + appendPQExpBuffer(query, " ONLY %s", fmtQualifiedDumpable(tbinfo)); + } + } + } + + first = true; appendPQExpBufferStr(query, " WITH (publish = '"); if (pubinfo->pubinsert) { diff --cc src/bin/pg_dump/t/002_pg_dump.pl index 445a541abf6,2aa8eb074fd..00000000000 --- a/src/bin/pg_dump/t/002_pg_dump.pl +++ b/src/bin/pg_dump/t/002_pg_dump.pl @@@ -3151,21 -3434,20 +3151,35 @@@ my %tests = 'CREATE PUBLICATION pub6' => { create_order => 50, ++<<<<<<< ours + create_sql => 'CREATE PUBLICATION pub6 + FOR ALL SEQUENCES;', + regexp => qr/^ + \QCREATE PUBLICATION pub6 FOR ALL SEQUENCES WITH (publish = 'insert, update, delete, truncate');\E ++======= + create_sql => + 'CREATE PUBLICATION pub6 FOR ALL TABLES EXCEPT dump_test.test_table;', + regexp => qr/^ + \QCREATE PUBLICATION pub6 FOR ALL TABLES EXCEPT TABLE ONLY dump_test.test_table WITH (publish = 'insert, update, delete, truncate');\E ++>>>>>>> theirs /xm, like => { %full_runs, section_post_data => 1, }, }, 'CREATE PUBLICATION pub7' => { create_order => 50, ++<<<<<<< ours + create_sql => 'CREATE PUBLICATION pub7 + FOR ALL SEQUENCES, ALL TABLES + WITH (publish = \'\');', + regexp => qr/^ + \QCREATE PUBLICATION pub7 FOR ALL TABLES, ALL SEQUENCES WITH (publish = '');\E ++======= + create_sql => + 'CREATE PUBLICATION pub7 FOR ALL TABLES EXCEPT TABLE dump_test.test_table, dump_test.test_second_table;', + regexp => qr/^ + \QCREATE PUBLICATION pub7 FOR ALL TABLES EXCEPT TABLE ONLY dump_test.test_table, ONLY dump_test.test_second_table WITH (publish = 'insert, update, delete, truncate');\E ++>>>>>>> theirs /xm, like => { %full_runs, section_post_data => 1, }, }, diff --cc src/include/catalog/pg_publication.h index 22f48bb8975,022467fb45c..00000000000 --- a/src/include/catalog/pg_publication.h +++ b/src/include/catalog/pg_publication.h @@@ -168,9 -162,10 +169,14 @@@ typedef enum PublicationPartOp PUBLICATION_PART_ALL, } PublicationPartOpt; - extern List *GetPublicationRelations(Oid pubid, PublicationPartOpt pub_partopt); + extern List *GetPublicationRelations(Oid pubid, PublicationPartOpt pub_partopt, + bool except_flag); extern List *GetAllTablesPublications(void); ++<<<<<<< ours +extern List *GetAllPublicationRelations(char relkind, bool pubviaroot); ++======= + extern List *GetAllTablesPublicationRelations(Oid pubid, bool pubviaroot); ++>>>>>>> theirs extern List *GetPublicationSchemas(Oid pubid); extern List *GetSchemaPublications(Oid schemaid); extern List *GetSchemaPublicationRelations(Oid schemaid, diff --cc src/test/regress/expected/publication.out index bb614ba5d0a,9bfc43344d5..00000000000 --- a/src/test/regress/expected/publication.out +++ b/src/test/regress/expected/publication.out @@@ -207,25 -207,49 +207,49 @@@ Not-null constraints "testpub_tbl2_id_not_null" NOT NULL "id" \dRp+ testpub_foralltables - Publication testpub_foralltables - Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root ---------------------------+------------+---------+---------+---------+-----------+-------------------+---------- - regress_publication_user | t | t | t | f | f | none | f + Publication testpub_foralltables + Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root +--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+---------- + regress_publication_user | t | f | t | t | f | f | none | f (1 row) + SET client_min_messages = 'ERROR'; + CREATE PUBLICATION testpub_foralltables_excepttable FOR ALL TABLES EXCEPT TABLE testpub_tbl1, testpub_tbl2; + -- specify EXCEPT without TABLE + CREATE PUBLICATION testpub_foralltables_excepttable1 FOR ALL TABLES EXCEPT testpub_tbl1; + RESET client_min_messages; + \dRp+ testpub_foralltables_excepttable + Publication testpub_foralltables_excepttable + Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root + --------------------------+------------+---------+---------+---------+-----------+-------------------+---------- + regress_publication_user | t | t | t | t | t | none | f + Except tables: + "public.testpub_tbl1" + "public.testpub_tbl2" + + \dRp+ testpub_foralltables_excepttable1 + Publication testpub_foralltables_excepttable1 + Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root + --------------------------+------------+---------+---------+---------+-----------+-------------------+---------- + regress_publication_user | t | t | t | t | t | none | f + Except tables: + "public.testpub_tbl1" + DROP TABLE testpub_tbl2; - DROP PUBLICATION testpub_foralltables, testpub_fortable, testpub_forschema, testpub_for_tbl_schema; + DROP PUBLICATION testpub_foralltables, testpub_fortable, testpub_forschema, testpub_for_tbl_schema, testpub_foralltables_excepttable, testpub_foralltables_excepttable1; CREATE TABLE testpub_tbl3 (a int); CREATE TABLE testpub_tbl3a (b text) INHERITS (testpub_tbl3); SET client_min_messages = 'ERROR'; CREATE PUBLICATION testpub3 FOR TABLE testpub_tbl3; CREATE PUBLICATION testpub4 FOR TABLE ONLY testpub_tbl3; + CREATE PUBLICATION testpub5 FOR ALL TABLES EXCEPT TABLE testpub_tbl3; + CREATE PUBLICATION testpub6 FOR ALL TABLES EXCEPT TABLE ONLY testpub_tbl3; RESET client_min_messages; \dRp+ testpub3 - Publication testpub3 - Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root ---------------------------+------------+---------+---------+---------+-----------+-------------------+---------- - regress_publication_user | f | t | t | t | t | none | f + Publication testpub3 + Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root +--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+---------- + regress_publication_user | f | f | t | t | t | t | none | f Tables: "public.testpub_tbl3" "public.testpub_tbl3a" @@@ -238,94 -262,25 +262,115 @@@ Tables: "public.testpub_tbl3" + \dRp+ testpub5 + Publication testpub5 + Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root + --------------------------+------------+---------+---------+---------+-----------+-------------------+---------- + regress_publication_user | t | t | t | t | t | none | f + Except tables: + "public.testpub_tbl3" + "public.testpub_tbl3a" + + \dRp+ testpub6 + Publication testpub6 + Owner | All tables | Inserts | Updates | Deletes | Truncates | Generated columns | Via root + --------------------------+------------+---------+---------+---------+-----------+-------------------+---------- + regress_publication_user | t | t | t | t | t | none | f + Except tables: + "public.testpub_tbl3" + DROP TABLE testpub_tbl3, testpub_tbl3a; ++<<<<<<< ours +DROP PUBLICATION testpub3, testpub4; +--- Tests for publications with SEQUENCES +CREATE SEQUENCE regress_pub_seq0; +CREATE SEQUENCE pub_test.regress_pub_seq1; +-- FOR ALL SEQUENCES +SET client_min_messages = 'ERROR'; +CREATE PUBLICATION regress_pub_forallsequences1 FOR ALL SEQUENCES; +RESET client_min_messages; +SELECT pubname, puballtables, puballsequences FROM pg_publication WHERE pubname = 'regress_pub_forallsequences1'; + pubname | puballtables | puballsequences +------------------------------+--------------+----------------- + regress_pub_forallsequences1 | f | t +(1 row) + +\d+ regress_pub_seq0 + Sequence "public.regress_pub_seq0" + Type | Start | Minimum | Maximum | Increment | Cycles? | Cache +--------+-------+---------+---------------------+-----------+---------+------- + bigint | 1 | 1 | 9223372036854775807 | 1 | no | 1 +Publications: + "regress_pub_forallsequences1" + +\dRp+ regress_pub_forallsequences1 + Publication regress_pub_forallsequences1 + Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root +--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+---------- + regress_publication_user | f | t | t | t | t | t | none | f +(1 row) + +SET client_min_messages = 'ERROR'; +CREATE PUBLICATION regress_pub_forallsequences2 FOR ALL SEQUENCES; +RESET client_min_messages; +-- check that describe sequence lists both publications the sequence belongs to +\d+ pub_test.regress_pub_seq1 + Sequence "pub_test.regress_pub_seq1" + Type | Start | Minimum | Maximum | Increment | Cycles? | Cache +--------+-------+---------+---------------------+-----------+---------+------- + bigint | 1 | 1 | 9223372036854775807 | 1 | no | 1 +Publications: + "regress_pub_forallsequences1" + "regress_pub_forallsequences2" + +--- Specifying both ALL TABLES and ALL SEQUENCES +SET client_min_messages = 'ERROR'; +CREATE PUBLICATION regress_pub_for_allsequences_alltables FOR ALL SEQUENCES, ALL TABLES; +-- Specifying WITH clause in an ALL SEQUENCES publication will emit a NOTICE. +SET client_min_messages = 'NOTICE'; +CREATE PUBLICATION regress_pub_for_allsequences_alltables_withclause FOR ALL SEQUENCES, ALL TABLES WITH (publish = 'insert'); +NOTICE: publication parameters are not applicable to sequence synchronization and will be ignored for sequences +WARNING: "wal_level" is insufficient to publish logical changes +HINT: Set "wal_level" to "logical" before creating subscriptions. +CREATE PUBLICATION regress_pub_for_allsequences_withclause FOR ALL SEQUENCES WITH (publish_generated_columns = 'stored'); +NOTICE: publication parameters are not applicable to sequence synchronization and will be ignored for sequences +WARNING: "wal_level" is insufficient to publish logical changes +HINT: Set "wal_level" to "logical" before creating subscriptions. +RESET client_min_messages; +SELECT pubname, puballtables, puballsequences FROM pg_publication WHERE pubname = 'regress_pub_for_allsequences_alltables'; + pubname | puballtables | puballsequences +----------------------------------------+--------------+----------------- + regress_pub_for_allsequences_alltables | t | t +(1 row) + +\dRp+ regress_pub_for_allsequences_alltables + Publication regress_pub_for_allsequences_alltables + Owner | All tables | All sequences | Inserts | Updates | Deletes | Truncates | Generated columns | Via root +--------------------------+------------+---------------+---------+---------+---------+-----------+-------------------+---------- + regress_publication_user | t | t | t | t | t | t | none | f +(1 row) + +DROP SEQUENCE regress_pub_seq0, pub_test.regress_pub_seq1; +DROP PUBLICATION regress_pub_forallsequences1; +DROP PUBLICATION regress_pub_forallsequences2; +DROP PUBLICATION regress_pub_for_allsequences_alltables; +DROP PUBLICATION regress_pub_for_allsequences_alltables_withclause; +DROP PUBLICATION regress_pub_for_allsequences_withclause; +-- fail - Specifying ALL TABLES more than once +CREATE PUBLICATION regress_pub_for_allsequences_alltables FOR ALL SEQUENCES, ALL TABLES, ALL TABLES; +ERROR: invalid publication object list +LINE 1: ...equences_alltables FOR ALL SEQUENCES, ALL TABLES, ALL TABLES... + ^ +DETAIL: ALL TABLES can be specified only once. +-- fail - Specifying ALL SEQUENCES more than once +CREATE PUBLICATION regress_pub_for_allsequences_alltables FOR ALL SEQUENCES, ALL TABLES, ALL SEQUENCES; +ERROR: invalid publication object list +LINE 1: ...equences_alltables FOR ALL SEQUENCES, ALL TABLES, ALL SEQUEN... + ^ +DETAIL: ALL SEQUENCES can be specified only once. ++======= + DROP PUBLICATION testpub3, testpub4, testpub5, testpub6; ++>>>>>>> theirs -- Tests for partitioned tables SET client_min_messages = 'ERROR'; CREATE PUBLICATION testpub_forparted; diff --cc src/test/subscription/meson.build index 85d10a89994,c4c1efd27bc..00000000000 --- a/src/test/subscription/meson.build +++ b/src/test/subscription/meson.build @@@ -45,7 -45,7 +45,11 @@@ tests += 't/033_run_as_table_owner.pl', 't/034_temporal.pl', 't/035_conflicts.pl', ++<<<<<<< ours + 't/036_sequences.pl', ++======= + 't/036_rep_changes_except_table.pl', ++>>>>>>> theirs 't/100_bugs.pl', ], },