1
0
mirror of https://github.com/postgres/postgres.git synced 2026-01-26 09:41:40 +03:00

Add TAP test for GUC settings passed via CONNECTION in logical replication.

Commit d926462d81 restored the behavior of passing GUC settings from
the CONNECTION string to the publisher's walsender, allowing per-connection
configuration.

This commit adds a TAP test to verify that behavior works correctly.

Since commit d926462d81 was recently applied and backpatched to v15,
this follow-up commit is also backpatched accordingly.

Author: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Chao Li <lic@highgo.com>
Reviewed-by: Kirill Reshke <reshkekirill@gmail.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Reviewed-by: Japin Li <japinli@hotmail.com>
Discussion: https://postgr.es/m/CAHGQGwGYV+-abbKwdrM2UHUe-JYOFWmsrs6=QicyJO-j+-Widw@mail.gmail.com
Backpatch-through: 15
This commit is contained in:
Fujii Masao
2026-01-06 11:57:12 +09:00
parent d926462d81
commit 5f13999aa1

View File

@@ -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';"
@@ -456,6 +473,16 @@ $node_publisher->poll_query_until('postgres',
or die
"Timed out while waiting for apply to restart after changing CONNECTION";
# 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'
);
$oldpid = $node_publisher->safe_psql('postgres',
"SELECT pid FROM pg_stat_replication WHERE application_name = 'tap_sub' AND state = 'streaming';"
);