Re: Enhance pg_stat_wal_receiver view to display connected host
Fujii Masao <masao.fujii@gmail.com>
From: Fujii Masao <masao.fujii@gmail.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: Haribabu Kommi <kommi.haribabu@gmail.com>,
Michael Paquier <michael.paquier@gmail.com>, Pg Hackers <pgsql-hackers@postgresql.org>,
Alvaro Herrera <alvherre@alvh.no-ip.org>
Date: 2018-03-29T20:26:30Z
Lists: pgsql-hackers
On Wed, Mar 28, 2018 at 3:09 PM, Michael Paquier <michael@paquier.xyz> wrote:
> On Wed, Mar 28, 2018 at 03:41:33PM +1100, Haribabu Kommi wrote:
>> On Wed, Mar 28, 2018 at 12:54 PM, Michael Paquier <michael@paquier.xyz>
>> wrote:
>> Updated patch attached.
Thanks for the patch! I'd like to commit this feature for v11.
@@ -753,4 +753,6 @@ CREATE VIEW pg_stat_wal_receiver AS
s.latest_end_time,
s.slot_name,
+ s.remote_server,
+ s.remote_port,
As the column names, aren't sender_host and sender_port more intuitive
rather than remote_server and remote_port?
+ ret = PQhost(conn->streamConn);
+ if (ret)
+ *remote_server = pstrdup(ret);
When the connection has an error, PQhost() and PQport() return an empty string.
In this case, pg_stat_wal_receiver reports an empty string in remote_server and
NULL in remote_port. Which looks inconsistent to me. In that case, both of them
should be reported NULL, I think. So I think that the above "if (ret)" condition
should be "if (ret & strcmp(ret, "") == 0)". Thought?
Of course, currently it's basically impossible that PQhost() and PQport() return
an empty string in libpqrcv_get_remoteserver_info() because it's called just
after the replication connection is successfully established. But it's better to
handle also that case for robustness of the code.
Regards,
--
Fujii Masao
Commits
-
Enhance pg_stat_wal_receiver view to display host and port of sender server.
- 9a895462d940 11.0 landed
-
Allow multiple hostaddrs to go with multiple hostnames.
- 7b02ba62e9ff 10.0 cited
-
libpq: Fix inadvertent change in PQhost() behavior.
- 11003eb55658 10.0 cited
-
libpq: Allow connection strings and URIs to specify multiple hosts.
- 274bb2b3857c 10.0 cited