From e91c1c0da6cbb987ef57abf01d420ea863a041a6 Mon Sep 17 00:00:00 2001 From: Hari Babu Date: Wed, 10 Jan 2018 15:33:25 +1100 Subject: [PATCH] PQhost update to return proper host details Earlier PQhost doesn't return the connected host details when the connection type is CHT_HOST_ADDRESS instead it returns the provided connection host parameter or the default host details. Providing specified connection host parameter or default host leads to use confusion, it is better to provide the host details of the connected host irrespective of the connection type if exists. --- src/interfaces/libpq/fe-connect.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c index 8d543334ae..886d042f91 100644 --- a/src/interfaces/libpq/fe-connect.c +++ b/src/interfaces/libpq/fe-connect.c @@ -6018,10 +6018,9 @@ PQhost(const PGconn *conn) if (!conn) return NULL; if (conn->connhost != NULL && - conn->connhost[conn->whichhost].type != CHT_HOST_ADDRESS) + conn->connhost[conn->whichhost].host != NULL && + conn->connhost[conn->whichhost].host[0] != '\0') return conn->connhost[conn->whichhost].host; - else if (conn->pghost != NULL && conn->pghost[0] != '\0') - return conn->pghost; else { #ifdef HAVE_UNIX_SOCKETS -- 2.15.0.windows.1