]> granicus.if.org Git - postgresql/commit
libpq: PQhost to return active connected host or hostaddr
authorPeter Eisentraut <peter_e@gmx.net>
Tue, 27 Mar 2018 16:31:34 +0000 (12:31 -0400)
committerPeter Eisentraut <peter_e@gmx.net>
Tue, 27 Mar 2018 16:32:18 +0000 (12:32 -0400)
commit1944cdc98273dbb8439ad9b387ca2858531afcf0
tree27807d959a5e210d7569d1df367bc05d615b2549
parent44bd95846a526dd1f69bdc78b3832f2d2de77dd4
libpq: PQhost to return active connected host or hostaddr

Previously, PQhost didn't return the connected host details when the
connection type was CHT_HOST_ADDRESS (i.e., via hostaddr).  Instead, it
returned the complete host connection parameter (which could contain
multiple hosts) or the default host details, which was confusing and
arguably incorrect.

Change this to return the actually connected host or hostaddr
irrespective of the connection type.  When hostaddr but no host was
specified, hostaddr is now returned.  Never return the original host
connection parameter, and document that PQhost cannot be relied on
before the connection is established.

PQport is similarly changed to always return the active connection port
and never the original connection parameter.

Author: Hari Babu <kommi.haribabu@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>
Reviewed-by: David G. Johnston <david.g.johnston@gmail.com>
doc/src/sgml/libpq.sgml
src/interfaces/libpq/fe-connect.c