Re: fix psql \conninfo & \connect when using hostaddr
Alvaro Herrera <alvherre@2ndquadrant.com>
From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Fabien COELHO <coelho@cri.ensmp.fr>
Cc: PostgreSQL Developers <pgsql-hackers@lists.postgresql.org>, Arthur Zakirov <a.zakirov@postgrespro.ru>, Robert Haas <robertmhaas@gmail.com>
Date: 2018-11-19T15:53:15Z
Lists: pgsql-hackers
Attachments
On 2018-Nov-17, Fabien COELHO wrote: > Here is the updated v2 > > - libpq internal function getHostaddr get a length, > and I added an assert about it. > - added a few braces on if/if/else/if/else/else > - added an UNKNOWN_HOST macro to hide "???" > - moved host_addr[] declaration earlier to avoid some braces You forgot to free(conn->connip) during freePGconn(). I found the UNKNOWN_HOST business quite dubious -- not only in your patch but also in the existing coding. I changed the getHostname API so that instead of returning "???" it sets the output buffer to the empty string. AFAICS the only user-visible behavior is that we no longer display the "???" in a parenthical comment next to the server address when a connection fails (this is pre-existing behavior, not changed by your patch.) Now, maybe the thinking was that upon seeing this message: could not connect to server: some error here Is the server running on host "pg.mines-paristech.fr" (???) and accepting connections on port 5432? the user was going to think "oh, my machine must have run out of memory, I'll reboot and retry". However, I highly doubt that anybody would reach that conclusion without reading the source code. So I deem this useless. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Commits
-
Tweak libpq's PQhost, PQhostaddr, and psql's \connect
- 313f56ce2d1b 12.0 landed
-
psql: Show IP address in \conninfo
- 6e5f8d489acc 12.0 landed