Peter Eisentraut wrote:
> On l?r, 2010-11-20 at 18:07 -0500, Bruce Momjian wrote:
> > The output is as expected:
> >
> > $ psql -h localhost test
> > psql: could not connect to server: Connection refused
> > Is the server running on host "localhost" (127.0.0.1) and
> > accepting
> > TCP/IP connections on port 5432?
> > $ psql -h 127.0.0.1 test
> > psql: could not connect to server: Connection refused
> > Is the server running on host "127.0.0.1" and accepting
> > TCP/IP connections on port 5432?
>
> Thanks for working on this. However, the example I posted at the
> beginning of this thread now does this:
>
> $ ./psql -p 55555 -h localhost
> psql: could not connect to server: Connection refused
> Is the server running on host "localhost" (???) and accepting
> TCP/IP connections on port 55555?
> could not connect to server: Connection refused
> Is the server running on host "localhost" (127.0.0.1) and accepting
> TCP/IP connections on port 55555?
>
> The "???" should presumably be "::1".
OK, I updated the code to always use cur_addr in the code --- let me
know if that doesn't fix it.
> Also, this comment should be updated:
>
> /*
> * Try to initiate a connection to one of the addresses
> * returned by pg_getaddrinfo_all(). conn->addr_cur is the
> * next one to try. We fail when we run out of addresses
> * (reporting the error returned for the *last* alternative,
> * which may not be what users expect :-().
> */
Thanks, comment udpated. It was wrong even before because we were
reporting all failures even before I Started.
--
Bruce Momjian <[email protected]> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ It's impossible for everything to be true. +
diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c
index 6593f21..8b55167 100644
*** /tmp/HkJ20a_fe-connect.c Fri Nov 26 11:48:13 2010
--- src/interfaces/libpq/fe-connect.c Fri Nov 26 11:36:28 2010
*************** connectFailureMessage(PGconn *conn, int
*** 989,996 ****
{
char host_addr[NI_MAXHOST];
bool display_host_addr;
- struct sockaddr_in *host_addr_struct = (struct sockaddr_in *)
- &conn->raddr.addr;
/*
* Optionally display the network address with the hostname.
--- 989,994 ----
*************** connectFailureMessage(PGconn *conn, int
*** 998,1005 ****
*/
if (conn->pghostaddr != NULL)
strlcpy(host_addr, conn->pghostaddr, NI_MAXHOST);
! else if (inet_net_ntop(conn->addr_cur->ai_family, &host_addr_struct->sin_addr,
! host_addr_struct->sin_family == AF_INET ? 32 : 128,
host_addr, sizeof(host_addr)) == NULL)
strcpy(host_addr, "???");
--- 996,1004 ----
*/
if (conn->pghostaddr != NULL)
strlcpy(host_addr, conn->pghostaddr, NI_MAXHOST);
! else if (inet_net_ntop(conn->addr_cur->ai_family,
! &conn->addr_cur->ai_addr,
! conn->addr_cur->ai_family == AF_INET ? 32 : 128,
host_addr, sizeof(host_addr)) == NULL)
strcpy(host_addr, "???");
--
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers