PQconninfo() doesn't return anything for host=/socket/directory - Mailing list pgsql-bugs

From Andres Freund
Subject PQconninfo() doesn't return anything for host=/socket/directory
Date
Msg-id 20131127084451.GA28863@alap2.anarazel.de
Whole thread Raw
List pgsql-bugs
Hi,

Programs that use PQconninfo() to build a new connection string, like in
my case pg_basebackup --write-recovery-conf, fail to do anything for
non-default socket directories leading to the newly built connection
string being unusable for connecting.
The reason for that is the following tidbit from
fe-connect.c:connectOptions2()

        /*
         * Allow unix socket specification in the host name
         */
        if (conn->pghost && is_absolute_path(conn->pghost))
        {
                if (conn->pgunixsocket)
                        free(conn->pgunixsocket);
                conn->pgunixsocket = conn->pghost;
                conn->pghost = NULL;
        }

This strikes me as unfortunate. Note that PQhost() does the right
thing...

I've attached a hack that fixes this, but I pretty much dislike the
direction it's going. Maybe the better fix is to simply not unset pghost
above and make connectDBStart() more intelligent?

Greetings,

Andres Freund

--
 Andres Freund                       http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services

Attachment

pgsql-bugs by date:

Previous
From: Michael Paquier
Date:
Subject: Re: BUG #8631: invalid page header
Next
From: "jonathan.camile"
Date:
Subject: Re: BUG #8629: Strange resultset when using CTE or a subselect