Commit d0dd4e19 authored by Christoph Berg's avatar Christoph Berg

Consistently call psql -X. (Closes: #877920)

parent afde8d4b
......@@ -899,7 +899,7 @@ sub get_db_encoding {
$ENV{'LC_ALL'} = 'C';
my $orig_euid = $>;
$> = (stat (cluster_data_directory $version, $cluster))[4];
open PSQL, '-|', $psql, '-h', $socketdir, '-p', $port, '-Atc',
open PSQL, '-|', $psql, '-h', $socketdir, '-p', $port, '-AXtc',
'select getdatabaseencoding()', $db or
die "Internal error: could not call $psql to determine db encoding: $!";
my $out = <PSQL>;
......@@ -925,18 +925,18 @@ sub get_db_locales {
return undef unless ($port && $socketdir && $psql);
my ($ctype, $collate);
# try to swich to cluster owner
# try to switch to cluster owner
prepare_exec 'LC_ALL';
$ENV{'LC_ALL'} = 'C';
my $orig_euid = $>;
$> = (stat (cluster_data_directory $version, $cluster))[4];
open PSQL, '-|', $psql, '-h', $socketdir, '-p', $port, '-Atc',
open PSQL, '-|', $psql, '-h', $socketdir, '-p', $port, '-AXtc',
'SHOW lc_ctype', $db or
die "Internal error: could not call $psql to determine db lc_ctype: $!";
my $out = <PSQL> // error 'could not determine db lc_ctype';
close PSQL;
($ctype) = $out =~ /^([\w.\@-]+)$/; # untaint
open PSQL, '-|', $psql, '-h', $socketdir, '-p', $port, '-Atc',
open PSQL, '-|', $psql, '-h', $socketdir, '-p', $port, '-AXtc',
'SHOW lc_collate', $db or
die "Internal error: could not call $psql to determine db lc_collate: $!";
$out = <PSQL> // error 'could not determine db lc_collate';
......@@ -1033,7 +1033,7 @@ sub get_cluster_databases {
my @dbs;
my @fields;
if (open PSQL, '-|', $psql, '-h', $socketdir, '-p', $port, '-Atl') {
if (open PSQL, '-|', $psql, '-h', $socketdir, '-p', $port, '-AXtl') {
while (<PSQL>) {
chomp;
@fields = split '\|';
......
postgresql-common (187) UNRELEASED; urgency=medium
* Consistently call psql -X. (Closes: #877920)
-- Christoph Berg <myon@debian.org> Sat, 07 Oct 2017 14:24:15 +0200
postgresql-common (186) unstable; urgency=medium
* Team upload.
......
......@@ -86,7 +86,7 @@ sub cluster_port_ready {
my $out;
while ($n < ($result ? 10 : 3)) {
select undef, undef, undef, 0.5;
$out = `$psql -h '$sd' --port $p -l 2>&1 >/dev/null`;
$out = `$psql -h '$sd' --port $p -Xl 2>&1 >/dev/null`;
if ($? == $result) {
$n++;
......
......@@ -452,7 +452,7 @@ if (!fork) {
# get list of databases (value = datallowconn)
my %databases;
open F, '-|', $oldpsql, '-h', $oldsocket, '-p', $info{'port'},
'-F|', '-d', $maintenance_db, '-Atc',
'-F|', '-d', $maintenance_db, '-AXtc',
'SELECT datname, datallowconn FROM pg_database' or
error 'Could not get pg_database list';
while (<F>) {
......@@ -469,7 +469,7 @@ if (!fork) {
unless ($databases{$db}) {
print "Temporarily enabling access to database $db\n";
(system $oldpsql, '-h', $oldsocket, '-p', $info{'port'}, '-q',
(system $oldpsql, '-h', $oldsocket, '-p', $info{'port'}, '-qX',
'-d', $maintenance_db, '-c',
"BEGIN READ WRITE; UPDATE pg_database SET datallowconn = 't' WHERE datname = '$db'; COMMIT") == 0 or
error 'Could not enable access to database';
......@@ -493,7 +493,7 @@ if (!fork) {
# create global objects in target cluster
open SINK, '|-', $psql, '-h', $newsocket, '-p', $newinfo{'port'},
'-q', '-d', $maintenance_db or
'-qX', '-d', $maintenance_db or
error 'Could not execute psql for new cluster';
# ensure that we can upgrade tables for DBs with default read-only
......@@ -514,14 +514,14 @@ if (!fork) {
# starting from 9.0, replace() works on strings; for earlier versions it
# works on bytea
if ($version >= '9.0') {
(system $psql, '-h', $oldsocket, '-p', $info{'port'}, '-q', '-d',
(system $psql, '-h', $oldsocket, '-p', $info{'port'}, '-qX', '-d',
$db, '-c', "BEGIN READ WRITE; \
UPDATE pg_proc SET probin = replace(\
replace(probin, '/usr/lib/postgresql/lib', '\$libdir'), \
'/usr/lib/postgresql/$version/lib', '\$libdir'); COMMIT") == 0 or
error 'Could not fix library paths';
} else {
(system $psql, '-h', $oldsocket, '-p', $info{'port'}, '-q', '-d',
(system $psql, '-h', $oldsocket, '-p', $info{'port'}, '-qX', '-d',
$db, '-c', "BEGIN READ WRITE; \
UPDATE pg_proc SET probin = decode(replace(\
replace(encode(probin, 'escape'), '/usr/lib/postgresql/lib', '\$libdir'), \
......@@ -558,17 +558,17 @@ if (!fork) {
# clean up
print 'Analyzing database ', $db, "...\n";
(system $psql, '-h', $newsocket, '-p', $newinfo{'port'}, '-q',
(system $psql, '-h', $newsocket, '-p', $newinfo{'port'}, '-qX',
'-d', $db, '-c', 'ANALYZE') == 0 or
error 'Could not ANALYZE database';
unless ($databases{$db}) {
print "Disabling access to database $db again\n";
(system $oldpsql, '-h', $oldsocket, '-p', $info{'port'}, '-q',
(system $oldpsql, '-h', $oldsocket, '-p', $info{'port'}, '-qX',
'-d', $maintenance_db, '-c',
"BEGIN READ WRITE; UPDATE pg_database SET datallowconn = 'f' where datname = '$db'; COMMIT") == 0 or
error 'Could not disable access to database in old cluster';
(system $psql, '-h', $newsocket, '-p', $newinfo{'port'}, '-q',
(system $psql, '-h', $newsocket, '-p', $newinfo{'port'}, '-qX',
'-d', $maintenance_db, '-c',
"BEGIN READ WRITE; UPDATE pg_database SET datallowconn = 'f' where datname = '$db'; COMMIT") == 0 or
error 'Could not disable access to database in new cluster';
......@@ -576,7 +576,7 @@ if (!fork) {
}
# reset owner specific override for default read-only transactions
(system $psql, '-h', $newsocket, '-p', $newinfo{'port'}, '-q', $maintenance_db, '-c',
(system $psql, '-h', $newsocket, '-p', $newinfo{'port'}, '-qX', $maintenance_db, '-c',
"BEGIN READ WRITE; ALTER USER $owner RESET default_transaction_read_only; COMMIT;\n") == 0 or
error 'Could not reset default_transaction_read_only value for superuser';
} else {
......
......@@ -51,17 +51,17 @@ sub call_sql {
$< = $> = (stat (PgCommon::cluster_data_directory $version, $cluster))[4];
# temporarily enable connections
my $conallow = `/usr/bin/psql --cluster '$version/$cluster' template1 -Atqc "select datallowconn from pg_database where datname='$db'"`;
my $conallow = `psql --cluster '$version/$cluster' template1 -AXtqc "select datallowconn from pg_database where datname='$db'"`;
chomp $conallow;
if ($conallow eq 'f') {
system "/usr/bin/psql --cluster '$version/$cluster' template1 -Atqc \"update pg_database set datallowconn = 't' where datname='$db'\"";
system "psql --cluster '$version/$cluster' template1 -AXtqc \"update pg_database set datallowconn = 't' where datname='$db'\"";
}
my $out = `ON_ERROR_STOP=1 /usr/bin/psql --cluster '$version/$cluster' -f '$script' '$db' 2>&1`;
my $out = `ON_ERROR_STOP=1 psql --cluster '$version/$cluster' -f '$script' '$db' 2>&1`;
# reset allowconn
if ($conallow eq 'f') {
system "/usr/bin/psql --cluster '$version/$cluster' template1 -Atqc \"update pg_database set datallowconn = 'f' where datname='$db'\"";
system "psql --cluster '$version/$cluster' template1 -AXtqc \"update pg_database set datallowconn = 'f' where datname='$db'\"";
}
print "[FAIL]\n$out" if $?;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment