Be more liberal and extendable in accepting psql options

This commit is contained in:
Jeroen van Ingen
2018-02-05 18:19:56 +01:00
parent 515ea06687
commit 51bd5dc21f

View File

@@ -14,9 +14,18 @@ register_worker({ phase => 'main' }, sub {
my $pass = setting('database')->{pass}; my $pass = setting('database')->{pass};
my $portnum = undef; my $portnum = undef;
if ($host and $host =~ m/([^;]+);port=(\d+)/) { if ($host and $host =~ m/([^;]+);(.+)/) {
$host = $1; $host = $1;
$portnum = $2; my $extra = $2;
my @opts = split(/;/, $extra);
debug sprintf("Host: %s, extra: %s\n", $host, $extra);
foreach my $opt (@opts) {
if ($opt =~ m/port=(\d+)/) {
$portnum = $1;
} else {
# Unhandled connection option, ignore for now
}
}
} }
$ENV{PGHOST} = $host if $host; $ENV{PGHOST} = $host if $host;