Skip to content

Commit 5525529

Browse files
committed
Fix bugs in PQhost().
In the platform that doesn't support Unix-domain socket, when neither host nor hostaddr are specified, the default host 'localhost' is used to connect to the server and PQhost() must return that, but it didn't. This patch fixes PQhost() so that it returns the default host in that case. Also this patch fixes PQhost() so that it doesn't return Unix-domain socket directory path in the platform that doesn't support Unix-domain socket. Back-patch to all supported versions.
1 parent 0fb4e3c commit 5525529

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/interfaces/libpq/fe-connect.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3520,7 +3520,16 @@ PQhost(const PGconn *conn)
35203520
{
35213521
if (!conn)
35223522
return NULL;
3523-
return conn->pghost ? conn->pghost : conn->pgunixsocket;
3523+
if (conn->pghost != NULL && conn->pghost[0] != '\0')
3524+
return conn->pghost;
3525+
else
3526+
{
3527+
#ifdef HAVE_UNIX_SOCKETS
3528+
return conn->pgunixsocket;
3529+
#else
3530+
return DefaultHost;
3531+
#endif
3532+
}
35243533
}
35253534

35263535
char *

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy