Thread: InitPostgres() fails through libpq

InitPostgres() fails through libpq

From
Egon Schmid
Date:
I'm using the latest CVS and PHP can't get a connection. Starting the
postmaster with or without the -i flag is not the problem. Also psql
works fine.

If I try to use PHP to access postgres I get the following:

-------------------------------------------------------------------------------
postmaster: ServerLoop:         handling reading 5
postmaster: ServerLoop:         handling reading 5
postmaster: ServerLoop:         handling writing 5
postmaster: BackendStartup: environ dump:
-----------------------------------------
        HOSTNAME=marliesle
        LOGNAME=postgres
        MACHTYPE=i586-debian-linux
        TERM=xterm
        HOSTTYPE=i586

PATH=/usr/local/pgsql/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11
        HOME=/home/postgres
        SHELL=/bin/bash
        PS1=\h\$
        PGLIB=/usr/local/pgsql/lib
        USER=postgres
        PGDATA=/usr/local/pgsql/data
        MANPATH=/usr/local/pgsql/man
        LANG=de_DE
        OSTYPE=linux
        SHLVL=1
        _=/usr/local/pgsql/bin/postmaster
        _652_GNU_nonoption_argv_flags_=0000
        POSTPORT=5432
        POSTID=2147483646
        PG_USER=nobody
        IPC_KEY=5432000
-----------------------------------------
postmaster: BackendStartup: pid 658 user nobody db verlag socket 5
postmaster child[658]: starting with (/usr/local/pgsql/bin/postgres, -p,
-d3, -P5, -v131072, verlag, )
FindExec: found "/usr/local/pgsql/bin/postgres" using argv[0]
        ---debug info---
        Quiet =        f
        Noversion =    f
        timings   =    f
        dates     =    Normal
        bufsize   =    64
        sortmem   =    512
        query echo =   f
        DatabaseName = [verlag]
        ----------------

        InitPostgres()..
An connection error occured. # <- A PHP message #
postmaster: reaping dead processes...
postmaster: CleanupProc: pid 658 exited with status 0
marliesle$
--------------------------------------------------------------------------------

Between InitPostgres()... and "An connection error occured" 'psql
verlag' show's a "Welcome to the POSTGRESQL interactive sql monitor:"

I append here the last lines from a strace (postmaster startet with -i):

--------------------------------------------------------------------------------
munmap(0x40158000, 4096)                = 0
socket(PF_UNIX, SOCK_STREAM, 0)         = 5
connect(5, {sun_family=AF_UNIX, sun_path="/tmp/.s.PGSQL.5432"}, 20) = 0
fcntl(5, F_SETFL, O_RDONLY|O_NONBLOCK)  = 0
getsockname(5, {sun_family=AF_UNIX, sun_path=""}, [3]) = 0
send(5, "\0\0\1(\0\2\0\0verlag\0\0\0\0\0\0"..., 296, 0) = 296
oldselect(6, [5], [], NULL, NULL)       = 1 (in [5])
recv(5, "R\0\0\0\0", 8192, 0)           = 5
oldselect(6, [5], [], NULL, NULL)       = 1 (in [5])
recv(5, "K\0\0\2_\262\263\247\212Z", 8192, 0) = 10
close(5)                                = 0
write(1, "An connection error occured.\n", 29) = 29
munmap(0x40126000, 200704)              = 0
close(4)                                = 0
munmap(0x40009000, 4096)                = 0
setitimer(ITIMER_PROF, {it_interval={0, 0}, it_value={0, 0}}, NULL) = 0
_exit(0)                                = ?
--------------------------------------------------------------------------------

-Egon