Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit be5d499

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 d1e3070 commit be5d499

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
@@ -5183,7 +5183,16 @@ PQhost(const PGconn *conn)
51835183
{
51845184
if (!conn)
51855185
return NULL;
5186-
return conn->pghost ? conn->pghost : conn->pgunixsocket;
5186+
if (conn->pghost != NULL && conn->pghost[0] != '\0')
5187+
return conn->pghost;
5188+
else
5189+
{
5190+
#ifdef HAVE_UNIX_SOCKETS
5191+
return conn->pgunixsocket;
5192+
#else
5193+
return DefaultHost;
5194+
#endif
5195+
}
51875196
}
51885197

51895198
char *

0 commit comments

Comments
 (0)