Skip to content

Commit 9060cb9

Browse files
committed
Work around NetBSD shell issue in pg_upgrade test script.
The NetBSD shell apparently returns non-zero from an unset command if the variable is already unset. This matters when, as in pg_upgrade's test.sh, we are working under 'set -e'. To protect against this, we first set the PG variables to an empty string before unsetting them completely. Error found on buildfarm member coypu, solution from Rémi Zara.
1 parent 4da24f1 commit 9060cb9

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

contrib/pg_upgrade/test.sh

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,20 @@ PGDATA="$BASE_PGDATA.old"
6767
export PGDATA
6868
rm -rf "$BASE_PGDATA" "$PGDATA"
6969

70-
unset PGDATABASE
71-
unset PGUSER
72-
unset PGSERVICE
73-
unset PGSSLMODE
74-
unset PGREQUIRESSL
75-
unset PGCONNECT_TIMEOUT
76-
unset PGHOST
77-
unset PGHOSTADDR
70+
# Clear out any environment vars that might cause libpq to connect to
71+
# the wrong postmaster (cf pg_regress.c)
72+
#
73+
# Some shells, such as NetBSD's, return non-zero from unset if the variable
74+
# is already unset. Since we are operating under 'set -e', this causes the
75+
# script to fail. To guard against this, set them all to an empty string first.
76+
PGDATABASE=""; unset PGDATABASE
77+
PGUSER=""; unset PGUSER
78+
PGSERVICE=""; unset PGSERVICE
79+
PGSSLMODE="" unset PGSSLMODE
80+
PGREQUIRESSL=""; unset PGREQUIRESSL
81+
PGCONNECT_TIMEOUT=""; unset PGCONNECT_TIMEOUT
82+
PGHOST="" unset PGHOST
83+
PGHOSTADDR=""; unset PGHOSTADDR
7884

7985
logdir=$PWD/log
8086
rm -rf "$logdir"

0 commit comments

Comments
 (0)