Use system psql if available, to fix travis build errors.

On some systems a new libpq is available than what we're compiling
against, but until now we used psql in the version we're compiling
against.  That' a problem, because (quoting Jason):

  With 9.6, libpq's default handling of CONTEXT changed: it is hidden
  unless the level is ERROR or higher. We addressed this ourselves using
  the SHOW_CONTEXT variable (by setting "always" in pg_regress_multi): in
  9.5, this is ignored (and unneeded), in 9.6, it ensures old behavior is
  preserved.

For 9.6 we'd already worked around the problem by specifying that
context should always be shown, but < 9.6 psql doesn't know how to do
that.

As there's no csql anymore, which strictly tied us to a specific version
of psql/csql, we can now just use the system's psql if available. We
still fall back to the psql of the installation we're compiling against,
if there's no other psql in PATH.
pull/1004/head
Andres Freund 2016-12-01 15:32:28 -08:00
parent 89352ae83f
commit 0a4889d0af
1 changed files with 16 additions and 8 deletions

View File

@ -82,6 +82,14 @@ if (defined $libdir)
$ENV{PATH} = "$libdir:".($ENV{PATH} || ''); $ENV{PATH} = "$libdir:".($ENV{PATH} || '');
} }
# Put $bindir to the end of PATH. We want to prefer system binaries by
# default (as e.g. new libpq and old psql can cause issues), but still
# want to find binaries if they're not in PATH.
if (defined $bindir)
{
$ENV{PATH} = ($ENV{PATH} || '').":$bindir";
}
my $plainRegress = "$pgxsdir/src/test/regress/pg_regress"; my $plainRegress = "$pgxsdir/src/test/regress/pg_regress";
my $isolationRegress = "${postgresBuilddir}/src/test/isolation/pg_isolation_regress"; my $isolationRegress = "${postgresBuilddir}/src/test/isolation/pg_isolation_regress";
if ($isolationtester && ! -f "$isolationRegress") if ($isolationtester && ! -f "$isolationRegress")
@ -171,7 +179,7 @@ system("mkdir", ('-p', "tmp_check/tmp-bin")) == 0
sysopen my $fh, "tmp_check/tmp-bin/psql", O_CREAT|O_TRUNC|O_RDWR, 0700 sysopen my $fh, "tmp_check/tmp-bin/psql", O_CREAT|O_TRUNC|O_RDWR, 0700
or die "Could not create psql wrapper"; or die "Could not create psql wrapper";
print $fh "#!/bin/bash\n"; print $fh "#!/bin/bash\n";
print $fh "exec $bindir/psql "; print $fh "exec psql ";
print $fh "--variable=master_port=$masterPort "; print $fh "--variable=master_port=$masterPort ";
print $fh "--variable=SHOW_CONTEXT=always "; print $fh "--variable=SHOW_CONTEXT=always ";
for my $workeroff (0 .. $#workerPorts) for my $workeroff (0 .. $#workerPorts)
@ -259,14 +267,14 @@ for my $port (@workerPorts)
### ###
for my $port (@workerPorts) for my $port (@workerPorts)
{ {
system("$bindir/psql", '-X', system("psql", '-X',
('-h', $host, '-p', $port, '-U', $user, "postgres", ('-h', $host, '-p', $port, '-U', $user, "postgres",
'-c', "CREATE DATABASE regression;")) == 0 '-c', "CREATE DATABASE regression;")) == 0
or die "Could not create regression database on worker"; or die "Could not create regression database on worker";
for my $extension (@extensions) for my $extension (@extensions)
{ {
system("$bindir/psql", '-X', system("psql", '-X',
('-h', $host, '-p', $port, '-U', $user, "regression", ('-h', $host, '-p', $port, '-U', $user, "regression",
'-c', "CREATE EXTENSION IF NOT EXISTS \"$extension\";")) == 0 '-c', "CREATE EXTENSION IF NOT EXISTS \"$extension\";")) == 0
or die "Could not create extension on worker"; or die "Could not create extension on worker";
@ -274,7 +282,7 @@ for my $port (@workerPorts)
foreach my $dataType (keys %dataTypes) foreach my $dataType (keys %dataTypes)
{ {
system("$bindir/psql", '-X', system("psql", '-X',
('-h', $host, '-p', $port, '-U', $user, "regression", ('-h', $host, '-p', $port, '-U', $user, "regression",
'-c', "CREATE TYPE $dataType AS $dataTypes{$dataType};")) == 0 '-c', "CREATE TYPE $dataType AS $dataTypes{$dataType};")) == 0
or die "Could not create TYPE $dataType on worker"; or die "Could not create TYPE $dataType on worker";
@ -282,7 +290,7 @@ for my $port (@workerPorts)
foreach my $function (keys %functions) foreach my $function (keys %functions)
{ {
system("$bindir/psql", '-X', system("psql", '-X',
('-h', $host, '-p', $port, '-U', $user, "regression", ('-h', $host, '-p', $port, '-U', $user, "regression",
'-c', "CREATE FUNCTION $function RETURNS $functions{$function};")) == 0 '-c', "CREATE FUNCTION $function RETURNS $functions{$function};")) == 0
or die "Could not create FUNCTION $function on worker"; or die "Could not create FUNCTION $function on worker";
@ -290,7 +298,7 @@ for my $port (@workerPorts)
foreach my $operator (keys %operators) foreach my $operator (keys %operators)
{ {
system("$bindir/psql", '-X', system("psql", '-X',
('-h', $host, '-p', $port, '-U', $user, "regression", ('-h', $host, '-p', $port, '-U', $user, "regression",
'-c', "CREATE OPERATOR $operator $operators{$operator};")) == 0 '-c', "CREATE OPERATOR $operator $operators{$operator};")) == 0
or die "Could not create OPERATOR $operator on worker"; or die "Could not create OPERATOR $operator on worker";
@ -298,7 +306,7 @@ for my $port (@workerPorts)
foreach my $fdw (keys %fdws) foreach my $fdw (keys %fdws)
{ {
system("$bindir/psql", '-X', system("psql", '-X',
('-h', $host, '-p', $port, '-U', $user, "regression", ('-h', $host, '-p', $port, '-U', $user, "regression",
'-c', "CREATE FOREIGN DATA WRAPPER $fdw HANDLER $fdws{$fdw};")) == 0 '-c', "CREATE FOREIGN DATA WRAPPER $fdw HANDLER $fdws{$fdw};")) == 0
or die "Could not create foreign data wrapper $fdw on worker"; or die "Could not create foreign data wrapper $fdw on worker";
@ -306,7 +314,7 @@ for my $port (@workerPorts)
foreach my $fdwServer (keys %fdwServers) foreach my $fdwServer (keys %fdwServers)
{ {
system("$bindir/psql", '-X', system("psql", '-X',
('-h', $host, '-p', $port, '-U', $user, "regression", ('-h', $host, '-p', $port, '-U', $user, "regression",
'-c', "CREATE SERVER $fdwServer FOREIGN DATA WRAPPER $fdwServers{$fdwServer};")) == 0 '-c', "CREATE SERVER $fdwServer FOREIGN DATA WRAPPER $fdwServers{$fdwServer};")) == 0
or die "Could not create server $fdwServer on worker"; or die "Could not create server $fdwServer on worker";