From d35e29387870fecfdb52ffd4c93c651f0c7c1b43 Mon Sep 17 00:00:00 2001 From: Michael Paquier Date: Fri, 20 Sep 2024 09:49:43 +0900 Subject: [PATCH] Add parameter "connstr" to PostgreSQL::Test::Cluster::background_psql Like for Cluster::psql, this can be handy to force the use of a connection string with some values overriden, like a "host". Author: Aidar Imamov Discussion: https://postgr.es/m/ecacb079efc533aed3c234cbcb5b07b6@postgrespro.ru --- src/test/perl/PostgreSQL/Test/Cluster.pm | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/test/perl/PostgreSQL/Test/Cluster.pm b/src/test/perl/PostgreSQL/Test/Cluster.pm index 143dc8c1015..90a842f96ab 100644 --- a/src/test/perl/PostgreSQL/Test/Cluster.pm +++ b/src/test/perl/PostgreSQL/Test/Cluster.pm @@ -2181,6 +2181,11 @@ returned. Set B to 0 to ignore errors instead. Set a timeout for a background psql session. By default, timeout of $PostgreSQL::Test::Utils::timeout_default is set up. +=item connstr => B + +If set, use this as the connection string for the connection to the +backend. + =item replication => B If set, add B to the conninfo string. @@ -2204,14 +2209,21 @@ sub background_psql my $replication = $params{replication}; my $timeout = undef; + # Build the connection string. + my $psql_connstr; + if (defined $params{connstr}) + { + $psql_connstr = $params{connstr}; + } + else + { + $psql_connstr = $self->connstr($dbname); + } + $psql_connstr .= defined $replication ? " replication=$replication" : ""; + my @psql_params = ( $self->installed_command('psql'), - '-XAtq', - '-d', - $self->connstr($dbname) - . (defined $replication ? " replication=$replication" : ""), - '-f', - '-'); + '-XAtq', '-d', $psql_connstr, '-f', '-'); $params{on_error_stop} = 1 unless defined $params{on_error_stop}; $timeout = $params{timeout} if defined $params{timeout}; -- 2.39.5