• Alvaro Herrera's avatar
    Tweak libpq's PQhost, PQhostaddr, and psql's \connect · 313f56ce
    Alvaro Herrera authored
    Fixes some problems introduced by 6e5f8d48:
    
    * 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
    313f56ce
psql-ref.sgml 192 KB