Re: Enhance pg_stat_wal_receiver view to display connected host

From: Haribabu Kommi <kommi(dot)haribabu(at)gmail(dot)com>
To: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Cc: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Enhance pg_stat_wal_receiver view to display connected host
Date: 2018-01-05 01:05:33
Message-ID: CAJrrPGeE0zY03phJByjofnN2TV9bSf4fu2yy=v4DyWw_Dj=bRQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Jan 5, 2018 at 12:05 AM, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
wrote:

> On Thu, Jan 04, 2018 at 08:54:37AM -0300, Alvaro Herrera wrote:
> > I think more attention should be given to the libpq side of this patch;
> > maybe have a 0001 with only the new libpq function, to easily verify
> > that it does all it needs to do. It needs docs for the new function in
> > libpq.sgml; also I wonder if checking conn->status before reporting
> > values is necessary; finally, has the application any good way to check
> > that the values can be safely read after calling the new function?
>
> Or instead of reinventing again the wheel, why not removing
> remote_hostaddr, and fetch the wanted values from PQhost() and PQport()
> after making sure that the connection status is good? There is no need
> for a new API this way. And as bonus points, we can also rely on
> defaults.
>

PQhost() doesn't provide the proper details even if we remove the
remote_hostaddr. For example with the following conninfo,

host=host1,host2 hostaddr=127.0.0.1,127.0.0.1 port=5434,5432

The connection type for both address of the above conninfo is
CHT_HOST_ADDRESS. so the PQhost() returns the conn->pghost
value i.e "host1,host2". That returned value doesn't give the clarity to
which host it is exactly connected. Because of this reason only, I came
up with a new function.

How about changing the PQhost() function behavior? Instead of checking
the connection type, checking whether there exists any host name or not?
And also not returning "default host" details, because for the conninfo
without any host details, the return value must be NULL. But this change
may break the backward compatibility of the function.

or

write two new functions PQconnhost() and PQconnhostaddr() to return the
connected host and hostaddr and reuse the PQport() function.

Regards,
Hari Babu
Fujitsu Australia

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2018-01-05 01:13:39 Re: [HACKERS] path toward faster partition pruning
Previous Message Michael Paquier 2018-01-05 01:00:11 Re: [JDBC] [HACKERS] Channel binding support for SCRAM-SHA-256