On Fri, Jan 05, 2018 at 09:15:36AM -0300, Alvaro Herrera wrote: > Haribabu Kommi wrote: > > > 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. > > I wouldn't want to have to fight that battle.
Hm. Any users of psql's PROMPT would be equally confused, and this can actually lead to more confusion from the user prospective I think than just pg_stat_wal_receiver. If you take the case of Haribabu from upthread with say this bit in psqlrc: \set PROMPT1 '[host=%M;port=%>]=%# '
Then you get on HEAD the following set of results using different connection strings: 1) host=localhost,localhost hostaddr=127.0.0.1,127.0.0.1 port=5432,5433 [host=localhost,localhost;port=5432]=#
So for cases 2) and 4), mixing both hostaddr and host is hurting the experience. The documentation in [1] also specifies that if both host and hostaddrs are specified then host is ignored. The same rule applies for multiple values so for 2) and 4) the correct values ought to be "local" for both of them. This would be more consistent with the pre-9.6 behavior as well.
I think you mean to say for the cases 1) and 4)? because those are the
cases where it differs with pre-9.6 behavior. With the attached patch
of changing PQhost() to return the host if exists, irrespective of the
connection type will bring back the pre-9.6 behavior.