summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Haas2016-12-01 19:36:39 +0000
committerRobert Haas2016-12-01 19:36:39 +0000
commit11003eb55658df0caf183eef69c7a97d56a4f2d7 (patch)
treedd07f1c196ff16f451513a8ef2aabcd261957034
parenta01a5013d9fa223a2e1b8ec1c6c6c2a47a6b808a (diff)
libpq: Fix inadvertent change in PQhost() behavior.
Commit 274bb2b3857cc987cfa21d14775cae9b0dababa5 caused PQhost() to return the value of the hostaddr parameter rather than the relevant host when the latter parameter was specified. That's wrong. Commit 9a1d0af4ad2cbd419115b453d811c141b80d872b then amplified the damage by using PQhost() in more places, so that the SSL test suite started failing. Report by Andreas Karlsson; patch by me.
-rw-r--r--src/interfaces/libpq/fe-connect.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c
index cd96ddb2f07..3b9b263a394 100644
--- a/src/interfaces/libpq/fe-connect.c
+++ b/src/interfaces/libpq/fe-connect.c
@@ -5736,7 +5736,8 @@ PQhost(const PGconn *conn)
{
if (!conn)
return NULL;
- if (conn->connhost != NULL)
+ if (conn->connhost != NULL &&
+ conn->connhost[conn->whichhost].type != CHT_HOST_ADDRESS)
return conn->connhost[conn->whichhost].host;
else if (conn->pghost != NULL && conn->pghost[0] != '\0')
return conn->pghost;