Package: postgresql-7.4
Version: 7.4.12-2
Tags: patch

When starting the PostgreSQL server (with "pg_ctl start") with a
specific directory (the -D flag), the "wait" code (triggered with the -w
option) fails to use the directory to find the Unix socket, and so it
fails to connect to the newly-started server.

To repeat, create a new database and start a server on it:

/usr/lib/postgresql/bin/initdb -D /some/directory
Edit /some/directory/postgresql.conf to define unix_socket_directory.
 (It may be a separate bug that this step is necessary.)
/usr/lib/postgresql/bin/pg_ctl start -w -D /some/directory -l 
/some/directory/postgres.log
Note the "failed" error message, even though the server did start.


The following simple patch passes the Unix socket directory to psql for
the wait check.

In PostgreSQL 8, the pg_ctl shell script has been replaced by a C
program.  I haven't tested it, but from looking at the code in pg_ctl.c,
I suspect the same bug is present.  Running "start -w" calls
test_postmaster_connection().  As with the buggy script, that routine
sets only the port and fails to set the host/directory as well.

 < Stephen

--- postgresql-7.4.12/src/bin/pg_ctl/pg_ctl.sh  2004-10-21 20:24:27.000000000 
-0400
+++ src/bin/pg_ctl/pg_ctl.sh    2006-03-20 13:31:23.000000000 -0500
@@ -387,20 +387,23 @@
     if [ -z "$PGPORT" ];then
         PGPORT=`sed -ne 's/^[  ]*port[^=]*=[   ]\+\([0-9]\+\).*/\1/p' 
$CONFFILE 2>/dev/null`
         if [ -z "$PGPORT" ];then
             PGPORT="$DEF_PGPORT"
         fi
     fi
+    if [ -z "$PGHOST" ];then
+        PGHOST=`sed -ne "s/^[  ]*unix_socket_directory[^=]*=[  
]\+'\([^'].*\)'/\1/p" "$CONFFILE" 2>/dev/null`
+    fi
 
     # wait for postmaster to start
     if [ "$wait" = yes ];then
        cnt=0
        $silence_echo $ECHO_N "waiting for postmaster to start..."$ECHO_C
        while :
        do
-           if "$PGPATH/psql" -p $PGPORT -l >/dev/null 2>&1
+           if "$PGPATH/psql" -p $PGPORT -h "$PGHOST" -l >/dev/null 2>&1
            then
                break;
            else
                $silence_echo $ECHO_N "."$ECHO_C
                cnt=`expr $cnt + 1`
                if [ "$cnt" -gt "$wait_seconds" ];then


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to