From cb74f395348ef9f966388ac655745ec79b19d582 Mon Sep 17 00:00:00 2001 From: Vignesh C Date: Wed, 9 Sep 2026 10:02:30 +0530 Subject: [PATCH v3 2/2] Improve EXCEPT publication tests Fix except publication test to ensure replication changes for an excluded partitioned table are actually checked. Also drop and recreate the subscription before the second multi-publication test so that it starts with a clean state, and use safe_psql() to ensure failures are reported. --- src/test/subscription/t/037_except.pl | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/test/subscription/t/037_except.pl b/src/test/subscription/t/037_except.pl index 43b51c8ff71..dd79fbb46e1 100644 --- a/src/test/subscription/t/037_except.pl +++ b/src/test/subscription/t/037_except.pl @@ -52,6 +52,10 @@ sub test_except_root_partition $result = $node_publisher->safe_psql('postgres', "SELECT count(*) = 0 FROM pg_logical_slot_get_binary_changes('test_slot', NULL, NULL, 'proto_version', '1', 'publication_names', 'tap_pub_part')" ); + is($result, qq(t), + "no changes for the partitioned table in the EXCEPT clause are present in the replication slot (publish_via_partition_root = $pubviaroot)" + ); + $node_publisher->wait_for_catchup('tap_sub_part'); # Verify that no rows are replicated to subscriber for root or partitions. @@ -235,7 +239,7 @@ $node_publisher->safe_psql( CREATE PUBLICATION tap_pub2 FOR TABLE tab1; INSERT INTO tab1 VALUES(1); )); -$node_subscriber->psql('postgres', +$node_subscriber->safe_psql('postgres', "CREATE SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr' PUBLICATION tap_pub1, tap_pub2" ); $node_subscriber->wait_for_subscription_sync($node_publisher, 'tap_sub'); @@ -249,12 +253,17 @@ is( $result, qq(1 2), "check replication of a table in the EXCEPT clause of one publication but included by another" ); + +$node_subscriber->safe_psql( + 'postgres', qq( + DROP SUBSCRIPTION tap_sub; + TRUNCATE tab1; +)); $node_publisher->safe_psql( 'postgres', qq( DROP PUBLICATION tap_pub2; TRUNCATE tab1; )); -$node_subscriber->safe_psql('postgres', qq(TRUNCATE tab1)); # OK when a table is excluded by pub1 EXCEPT clause, but it is included by pub2 # FOR ALL TABLES. @@ -263,7 +272,7 @@ $node_publisher->safe_psql( CREATE PUBLICATION tap_pub2 FOR ALL TABLES; INSERT INTO tab1 VALUES(1); )); -$node_subscriber->psql('postgres', +$node_subscriber->safe_psql('postgres', "CREATE SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr' PUBLICATION tap_pub1, tap_pub2" ); $node_subscriber->wait_for_subscription_sync($node_publisher, 'tap_sub'); @@ -278,10 +287,4 @@ is( $result, qq(1 "check replication of a table in the EXCEPT clause of one publication but included by another" ); -$node_subscriber->safe_psql('postgres', 'DROP SUBSCRIPTION tap_sub'); -$node_publisher->safe_psql('postgres', 'DROP PUBLICATION tap_pub1'); -$node_publisher->safe_psql('postgres', 'DROP PUBLICATION tap_pub2'); - -$node_publisher->stop('fast'); - done_testing(); -- 2.55.0