Skip to content

Commit e05f154

Browse files
committed
Communicate PGPORT and PGHOST via environment, not command line
1 parent 5ba666b commit e05f154

File tree

1 file changed

+25
-11
lines changed

1 file changed

+25
-11
lines changed

src/test/regress/pg_regress.sh

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#! /bin/sh
2-
# $Header: /cvsroot/pgsql/src/test/regress/Attic/pg_regress.sh,v 1.3 2000/10/02 06:03:25 tgl Exp $
2+
# $Header: /cvsroot/pgsql/src/test/regress/Attic/pg_regress.sh,v 1.4 2000/10/02 11:47:30 petere Exp $
33

44
me=`basename $0`
55
: ${TMPDIR=/tmp}
@@ -81,6 +81,9 @@ unset top_builddir
8181
unset temp_install
8282
unset multibyte
8383

84+
export PGHOST
85+
export PGPORT
86+
8487
dbname=regression
8588
hostname=`hostname` || hostname=localhost
8689

@@ -154,8 +157,6 @@ case $host_platform in
154157
unix_sockets=yes;;
155158
esac
156159

157-
[ "$unix_sockets" = no ] && psql_options="$psql_options -h $PGHOST"
158-
159160

160161
# ----------
161162
# Set up diff to ignore horizontal white space differences.
@@ -257,7 +258,11 @@ then
257258
libdir=$temp_install/$libdir
258259
datadir=$temp_install/$datadir
259260
PGDATA=$temp_install/data
260-
PGHOST=$hostname
261+
if [ "$unix_sockets" = no ]; then
262+
PGHOST=$hostname
263+
else
264+
unset PGHOST
265+
fi
261266
PGPORT=65432
262267

263268
# ----------
@@ -314,7 +319,7 @@ then
314319
message "starting postmaster"
315320
[ "$debug" = yes ] && postmaster_options="$postmaster_options -d 5"
316321
[ "$unix_sockets" = no ] && postmaster_options="$postmaster_options -i"
317-
"$bindir/postmaster" -D "$PGDATA" -p "$PGPORT" -F $postmaster_options >"$LOGDIR/postmaster.log" 2>&1 &
322+
"$bindir/postmaster" -D "$PGDATA" -F $postmaster_options >"$LOGDIR/postmaster.log" 2>&1 &
318323
postmaster_pid=$!
319324

320325
if kill -0 $postmaster_pid >/dev/null 2>&1
@@ -333,13 +338,22 @@ then
333338

334339
else # not temp-install
335340

341+
# If Unix sockets are not available, use the local host by default.
342+
[ "$unix_sockets" = no ] && ${PGHOST=$hostname}
343+
344+
if [ -n "$PGPORT" ]; then
345+
port_info="port $PGPORT"
346+
else
347+
port_info="default port"
348+
fi
349+
336350
if [ -n "$PGHOST" ]; then
337-
echo "(using postmaster on $PGHOST at port $PGPORT)"
351+
echo "(using postmaster on $PGHOST, $port_info)"
338352
else
339-
echo "(using postmaster on Unix socket with port $PGPORT)"
353+
echo "(using postmaster on Unix socket, $port_info)"
340354
fi
341355
message "dropping database \"$dbname\""
342-
"$bindir/dropdb" -p "$PGPORT" $psql_options "$dbname" >/dev/null 2>&1
356+
"$bindir/dropdb" $psql_options "$dbname" >/dev/null 2>&1
343357
# errors can be ignored
344358
fi
345359

@@ -348,7 +362,7 @@ fi
348362
# Set up SQL shell for the test.
349363
# ----------
350364

351-
PSQL="$bindir/psql -a -q -X $psql_options -p $PGPORT"
365+
PSQL="$bindir/psql -a -q -X $psql_options"
352366

353367

354368
# ----------
@@ -377,7 +391,7 @@ fi
377391
# ----------
378392

379393
message "creating database \"$dbname\""
380-
"$bindir/createdb" -p "$PGPORT" $encoding_opt $psql_options "$dbname"
394+
"$bindir/createdb" $encoding_opt $psql_options "$dbname"
381395
if [ $? -ne 0 ]; then
382396
echo "$me: createdb failed"
383397
(exit 2); exit
@@ -392,7 +406,7 @@ case $host_platform in
392406
*-*-qnx*) : ;;
393407
*)
394408
message "installing PL/pgSQL"
395-
"$bindir/createlang" -p "$PGPORT" -L "$libdir" $psql_options plpgsql $dbname
409+
"$bindir/createlang" -L "$libdir" $psql_options plpgsql $dbname
396410
if [ $? -ne 0 ] && [ $? -ne 2 ]; then
397411
echo "$me: createlang failed"
398412
(exit 2); exit

0 commit comments

Comments
 (0)