mirror of
https://github.com/postgres/postgres.git
synced 2025-05-01 01:04:50 +03:00
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
This commit is contained in:
parent
126ec0bc76
commit
d35e293878
@ -2181,6 +2181,11 @@ returned. Set B<on_error_stop> to 0 to ignore errors instead.
|
|||||||
Set a timeout for a background psql session. By default, timeout of
|
Set a timeout for a background psql session. By default, timeout of
|
||||||
$PostgreSQL::Test::Utils::timeout_default is set up.
|
$PostgreSQL::Test::Utils::timeout_default is set up.
|
||||||
|
|
||||||
|
=item connstr => B<value>
|
||||||
|
|
||||||
|
If set, use this as the connection string for the connection to the
|
||||||
|
backend.
|
||||||
|
|
||||||
=item replication => B<value>
|
=item replication => B<value>
|
||||||
|
|
||||||
If set, add B<replication=value> to the conninfo string.
|
If set, add B<replication=value> to the conninfo string.
|
||||||
@ -2204,14 +2209,21 @@ sub background_psql
|
|||||||
my $replication = $params{replication};
|
my $replication = $params{replication};
|
||||||
my $timeout = undef;
|
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 = (
|
my @psql_params = (
|
||||||
$self->installed_command('psql'),
|
$self->installed_command('psql'),
|
||||||
'-XAtq',
|
'-XAtq', '-d', $psql_connstr, '-f', '-');
|
||||||
'-d',
|
|
||||||
$self->connstr($dbname)
|
|
||||||
. (defined $replication ? " replication=$replication" : ""),
|
|
||||||
'-f',
|
|
||||||
'-');
|
|
||||||
|
|
||||||
$params{on_error_stop} = 1 unless defined $params{on_error_stop};
|
$params{on_error_stop} = 1 unless defined $params{on_error_stop};
|
||||||
$timeout = $params{timeout} if defined $params{timeout};
|
$timeout = $params{timeout} if defined $params{timeout};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user