v6-0002-Add-TAP-test-for-GUC-settings-passed-via-CONNECTI.patch
application/octet-stream
Filename: v6-0002-Add-TAP-test-for-GUC-settings-passed-via-CONNECTI.patch
Type: application/octet-stream
Part: 1
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch v6-0002
Subject: Add TAP test for GUC settings passed via CONNECTION in logical replication.
| File | + | − |
|---|---|---|
| src/test/subscription/t/001_rep_changes.pl | 28 | 1 |
From 0e49936016a81eccf095cf710aa6c5ea1ca761cf Mon Sep 17 00:00:00 2001
From: Fujii Masao <fujii@postgresql.org>
Date: Thu, 27 Nov 2025 12:36:59 +0900
Subject: [PATCH v6 2/2] Add TAP test for GUC settings passed via CONNECTION in
logical replication.
This commit adds a TAP test to verify that GUC settings provided in
the CONNECTION string of CREATE/ALTER SUBSCRIPTION are correctly
passed through to and applied by the publisher's walsender.
---
src/test/subscription/t/001_rep_changes.pl | 29 +++++++++++++++++++++-
1 file changed, 28 insertions(+), 1 deletion(-)
diff --git a/src/test/subscription/t/001_rep_changes.pl b/src/test/subscription/t/001_rep_changes.pl
index 430c1246d14..9db7e8219de 100644
--- a/src/test/subscription/t/001_rep_changes.pl
+++ b/src/test/subscription/t/001_rep_changes.pl
@@ -438,17 +438,34 @@ is( $result, qq(11.11|baz|1
22.22|bar|2),
'update works with dropped subscriber column');
+# Verify that GUC settings supplied in the CONNECTION string take effect on
+# the publisher's walsender. We do this by enabling log_statement_stats in
+# the CONNECTION string later and checking that the publisher's log contains a
+# QUERY STATISTICS message.
+#
+# First, confirm that no such QUERY STATISTICS message appears before enabling
+# log_statement_stats.
+$logfile = slurp_file($node_publisher->logfile, $log_location);
+unlike(
+ $logfile,
+ qr/QUERY STATISTICS/,
+ 'log_statement_stats has not been enabled yet');
+
# check that change of connection string and/or publication list causes
# restart of subscription workers. We check the state along with
# application_name to ensure that the walsender is (re)started.
#
# Not all of these are registered as tests as we need to poll for a change
# but the test suite will fail nonetheless when something goes wrong.
+#
+# Enable log_statement_stats as the change of connection string,
+# which is also for the above mentioned test of GUC settings passed through
+# CONNECTION.
my $oldpid = $node_publisher->safe_psql('postgres',
"SELECT pid FROM pg_stat_replication WHERE application_name = 'tap_sub' AND state = 'streaming';"
);
$node_subscriber->safe_psql('postgres',
- "ALTER SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr sslmode=disable'"
+ "ALTER SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr options=''-c log_statement_stats=on'''"
);
$node_publisher->poll_query_until('postgres',
"SELECT pid != $oldpid FROM pg_stat_replication WHERE application_name = 'tap_sub' AND state = 'streaming';"
@@ -552,6 +569,16 @@ $node_publisher->poll_query_until('postgres',
or die
"Timed out while waiting for apply to restart after renaming SUBSCRIPTION";
+# Check that the expected QUERY STATISTICS message appears,
+# which shows that log_statement_stats=on from the CONNECTION string
+# was correctly passed through to and honored by the walsender.
+$logfile = slurp_file($node_publisher->logfile, $log_location);
+like(
+ $logfile,
+ qr/QUERY STATISTICS/,
+ 'log_statement_stats in CONNECTION string had effect on publisher\'s walsender'
+);
+
# check all the cleanup
$node_subscriber->safe_psql('postgres', "DROP SUBSCRIPTION tap_sub_renamed");
--
2.51.2