1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-02 04:21:28 +03:00

Tweak libpq's PQhost, PQhostaddr, and psql's \connect

Fixes some problems introduced by 6e5f8d489a:

* When reusing conninfo data from the previous connection in \connect,
  the host address should only be reused if it was specified as
  hostaddr; if it wasn't, then 'host' is resolved afresh.  We were
  reusing the same IP address, which ignores a possible DNS change
  as well as any other addresses that the name resolves to than the
  one that was used in the original connection.

* PQhost, PQhostaddr: Don't present user-specified hostaddr when we have
  an inet_net_ntop-produced equivalent address.  The latter has been
  put in canonical format, which is cleaner (so it produces "127.0.0.1"
  when given "host=2130706433", for example).

* Document the hostaddr-reusing aspect of \connect.

* Fix some code comments

Author: Fabien Coelho
Reported-by: Noah Misch
Discussion: https://postgr.es/m/20190527203713.GA58392@gust.leadboat.com
This commit is contained in:
Alvaro Herrera
2019-06-14 18:02:26 -04:00
parent 3da73d6839
commit 313f56ce2d
3 changed files with 43 additions and 21 deletions

View File

@@ -911,6 +911,9 @@ testdb=>
<replaceable class="parameter">host</replaceable> or
<replaceable class="parameter">port</replaceable>
as <literal>-</literal> is equivalent to omitting that parameter.
If <literal>hostaddr</literal> was specified in the original
connection's <structname>conninfo</structname>, that address is reused
for the new connection (disregarding any other host specification).
</para>
<para>