From cf1d26e4fab61b559248c0e52ea9bd120836d5dd Mon Sep 17 00:00:00 2001 From: Nisha Moond Date: Wed, 18 Nov 2026 10:36:00 +0530 Subject: [PATCH v94 3/4] 002 comments top up patch for review --- doc/src/sgml/logical-replication.sgml | 8 +++++ src/bin/pg_dump/pg_dump.c | 5 +-- src/bin/pg_dump/t/002_pg_dump.pl | 51 +++++++++++++++++---------- 3 files changed, 43 insertions(+), 21 deletions(-) diff --git a/doc/src/sgml/logical-replication.sgml b/doc/src/sgml/logical-replication.sgml index 74f1df30ced..da3ae18c38f 100644 --- a/doc/src/sgml/logical-replication.sgml +++ b/doc/src/sgml/logical-replication.sgml @@ -3154,6 +3154,14 @@ CONTEXT: processing remote data for replication origin "pg_16395" during "INSER dependencies on clusters before version 17.0 will silently be ignored. + + pg_upgrade also preserves the subscription's + OID and its + conflict log table, + if conflict_log_destination + is set to table or all. + + Commit timestamps and origin data are not preserved during the upgrade. diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index ddf5b3bef3b..498d0107796 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -2080,14 +2080,15 @@ selectDumpableTable(TableInfo *tbinfo, Archive *fout) * CREATE SUBSCRIPTION can reuse it. Otherwise the table is created * again when the subscription is restored. Also dump the privileges * that were granted on the table, for example to let non-superusers - * delete conflicts. + * delete conflicts, and its comments and security labels. * * The pg_conflict schema itself is created by initdb and is not * dumped, so the tables in it are selected here, regardless of the * schema and table switches. */ if (dopt->binary_upgrade) - tbinfo->dobj.dump = DUMP_COMPONENT_DEFINITION | DUMP_COMPONENT_ACL; + tbinfo->dobj.dump = DUMP_COMPONENT_DEFINITION | DUMP_COMPONENT_ACL | + DUMP_COMPONENT_COMMENT | DUMP_COMPONENT_SECLABEL; else tbinfo->dobj.dump = DUMP_COMPONENT_NONE; diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl index 0282b3cc0d7..24a1e41586c 100644 --- a/src/bin/pg_dump/t/002_pg_dump.pl +++ b/src/bin/pg_dump/t/002_pg_dump.pl @@ -3435,25 +3435,6 @@ my %tests = ( }, }, - # In binary-upgrade mode, the subscription OID is preserved and the - # conflict log table is dumped, to be reused by the CREATE SUBSCRIPTION - # above. - 'binary upgrade: pg_subscription OID of sub3' => { - regexp => qr/^ - \Q-- For binary upgrade, must preserve pg_subscription.oid\E\n - \QSELECT pg_catalog.binary_upgrade_set_next_pg_subscription_oid(\E'\d+'\Q::pg_catalog.oid);\E\n+ - \QCREATE SUBSCRIPTION sub3 \E - /xm, - like => { binary_upgrade => 1, }, - }, - - 'binary upgrade: conflict log table of sub3' => { - regexp => qr/^ - \QCREATE TABLE pg_conflict.pg_conflict_log_\E\d+\Q (\E - /xm, - like => { binary_upgrade => 1, }, - }, - 'CREATE SUBSCRIPTION sub4' => { create_order => 50, create_sql => 'CREATE SUBSCRIPTION sub4 @@ -3469,6 +3450,38 @@ my %tests = ( }, }, + # Conflict log tables are dumped only in binary-upgrade mode. + 'binary upgrade: conflict log tables' => { + regexp => qr/^ + \QCREATE TABLE pg_conflict.pg_conflict_log_\E\d+\Q (\E + /xm, + like => { binary_upgrade => 1, }, + }, + + # In binary-upgrade mode, the subscription OID is preserved, and the + # conflict log table named after it is dumped, so that CREATE + # SUBSCRIPTION can reuse it. The OID is not known here, so check that + # the table name and the preserved OID have the same number. + 'binary upgrade: conflict log table of sub3' => { + regexp => qr/^ + \QCREATE TABLE pg_conflict.pg_conflict_log_\E(\d+)\Q (\E + .*? + ^\QSELECT pg_catalog.binary_upgrade_set_next_pg_subscription_oid('\E\1\Q'::pg_catalog.oid);\E\n+ + \QCREATE SUBSCRIPTION sub3 \E + /xms, + like => { binary_upgrade => 1, }, + }, + + 'binary upgrade: conflict log table of sub4' => { + regexp => qr/^ + \QCREATE TABLE pg_conflict.pg_conflict_log_\E(\d+)\Q (\E + .*? + ^\QSELECT pg_catalog.binary_upgrade_set_next_pg_subscription_oid('\E\1\Q'::pg_catalog.oid);\E\n+ + \QCREATE SUBSCRIPTION sub4 \E + /xms, + like => { binary_upgrade => 1, }, + }, + # Regardless of whether the table or schema is excluded, publications must # still be dumped, as excluded objects do not apply to publications. We # perform table and schema exclusion via full_runs. -- 2.54.0 (Apple Git-157)