From 0a4889d0af6590b1a88b57b20824529b31120332 Mon Sep 17 00:00:00 2001 From: Andres Freund Date: Thu, 1 Dec 2016 15:32:28 -0800 Subject: [PATCH] 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. --- src/test/regress/pg_regress_multi.pl | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/test/regress/pg_regress_multi.pl b/src/test/regress/pg_regress_multi.pl index 99407ac51..ad9d55c18 100755 --- a/src/test/regress/pg_regress_multi.pl +++ b/src/test/regress/pg_regress_multi.pl @@ -82,6 +82,14 @@ if (defined $libdir) $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 $isolationRegress = "${postgresBuilddir}/src/test/isolation/pg_isolation_regress"; 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 or die "Could not create psql wrapper"; print $fh "#!/bin/bash\n"; -print $fh "exec $bindir/psql "; +print $fh "exec psql "; print $fh "--variable=master_port=$masterPort "; print $fh "--variable=SHOW_CONTEXT=always "; for my $workeroff (0 .. $#workerPorts) @@ -259,14 +267,14 @@ for my $port (@workerPorts) ### for my $port (@workerPorts) { - system("$bindir/psql", '-X', + system("psql", '-X', ('-h', $host, '-p', $port, '-U', $user, "postgres", '-c', "CREATE DATABASE regression;")) == 0 or die "Could not create regression database on worker"; for my $extension (@extensions) { - system("$bindir/psql", '-X', + system("psql", '-X', ('-h', $host, '-p', $port, '-U', $user, "regression", '-c', "CREATE EXTENSION IF NOT EXISTS \"$extension\";")) == 0 or die "Could not create extension on worker"; @@ -274,7 +282,7 @@ for my $port (@workerPorts) foreach my $dataType (keys %dataTypes) { - system("$bindir/psql", '-X', + system("psql", '-X', ('-h', $host, '-p', $port, '-U', $user, "regression", '-c', "CREATE TYPE $dataType AS $dataTypes{$dataType};")) == 0 or die "Could not create TYPE $dataType on worker"; @@ -282,7 +290,7 @@ for my $port (@workerPorts) foreach my $function (keys %functions) { - system("$bindir/psql", '-X', + system("psql", '-X', ('-h', $host, '-p', $port, '-U', $user, "regression", '-c', "CREATE FUNCTION $function RETURNS $functions{$function};")) == 0 or die "Could not create FUNCTION $function on worker"; @@ -290,7 +298,7 @@ for my $port (@workerPorts) foreach my $operator (keys %operators) { - system("$bindir/psql", '-X', + system("psql", '-X', ('-h', $host, '-p', $port, '-U', $user, "regression", '-c', "CREATE OPERATOR $operator $operators{$operator};")) == 0 or die "Could not create OPERATOR $operator on worker"; @@ -298,7 +306,7 @@ for my $port (@workerPorts) foreach my $fdw (keys %fdws) { - system("$bindir/psql", '-X', + system("psql", '-X', ('-h', $host, '-p', $port, '-U', $user, "regression", '-c', "CREATE FOREIGN DATA WRAPPER $fdw HANDLER $fdws{$fdw};")) == 0 or die "Could not create foreign data wrapper $fdw on worker"; @@ -306,7 +314,7 @@ for my $port (@workerPorts) foreach my $fdwServer (keys %fdwServers) { - system("$bindir/psql", '-X', + system("psql", '-X', ('-h', $host, '-p', $port, '-U', $user, "regression", '-c', "CREATE SERVER $fdwServer FOREIGN DATA WRAPPER $fdwServers{$fdwServer};")) == 0 or die "Could not create server $fdwServer on worker";