PQhost-update-to-return-proper-host-details_v2.patch

application/octet-stream

Filename: PQhost-update-to-return-proper-host-details_v2.patch
Type: application/octet-stream
Part: 0
Message: Re: Enhance pg_stat_wal_receiver view to display connected host

Patch

Format: format-patch
Series: patch v2
Subject: PQhost update to return proper host details
File+
src/interfaces/libpq/fe-connect.c 2 1
From 7c5e76f0b00fde298563a694268333129658bc02 Mon Sep 17 00:00:00 2001
From: Hari Babu <kommi.haribabu@gmail.com>
Date: Fri, 12 Jan 2018 16:29:14 +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 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c
index 8d543334ae..bad7769fe0 100644
--- a/src/interfaces/libpq/fe-connect.c
+++ b/src/interfaces/libpq/fe-connect.c
@@ -6018,7 +6018,8 @@ 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;
-- 
2.15.0.windows.1