Re: [9.1] pg_stat_get_backend_server_addr - Mailing list pgsql-hackers

From Jeff Davis
Subject Re: [9.1] pg_stat_get_backend_server_addr
Date
Msg-id 1279775549.23350.9.camel@jdavis
Whole thread Raw
In response to Re: [9.1] pg_stat_get_backend_server_addr  (Peter Eisentraut <peter_e@gmx.net>)
Responses Re: [9.1] pg_stat_get_backend_server_addr
List pgsql-hackers
On Fri, 2010-05-28 at 18:01 +0300, Peter Eisentraut wrote:
> Yes, I would like to know who is connecting to what IP address.  It's
> useful if you have HA setups and you need to check which way your
> connections are going.

A few comments on this patch:

The two functions aren't perfectly symmetric, because 
pg_stat_get_backend_server_port() returns -1 if it's a unix socket, and
pg_stat_get_backend_server_addr() returns NULL (which is also overloaded
to mean that you don't have permissions). So, perhaps it's better to
just have pg_stat_get_backend_server_addr(), which is the one you want,
anyway.

Also, for the permission check I'm inclined to throw an error rather
than return NULL. If the function is being called from a view, it's
understandable that we don't want to throw an error; but this function
isn't being called from a view. Based on your use-case, I'm more worried
about the HA system getting confused with a NULL result, and then
failing mysteriously with no error message.

Regards,Jeff Davis



pgsql-hackers by date:

Previous
From: Fujii Masao
Date:
Subject: Re: Preliminary review of Synchronous Replication patches
Next
From: Fujii Masao
Date:
Subject: little mistakes in HS/SR