Re: fix psql \conninfo & \connect when using hostaddr
Fabien COELHO <coelho@cri.ensmp.fr>
From: Fabien COELHO <coelho@cri.ensmp.fr>
To: Robert Haas <robertmhaas@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>,
Artur Zakirov <a.zakirov@postgrespro.ru>
Date: 2018-11-08T10:54:27Z
Lists: pgsql-hackers
Hello Robert, >> psql> \conninfo >> You are connected to database "fabien" as user "fabien" on host "foo" at port "5432". > > I remain of the opinion that this is not a bug. You told it that foo > has address 127.0.0.1 and it believed you; that's YOUR fault. Hmmm. For me, if a user asks \conninfo for connection information, they expect to be told what the connection actually is, regardless of the initial connection string. Another more stricking instance: sh> psql "host=/tmp port=5432 hostaddr=127.0.0.1" ... fabien=# \conninfo You are connected to database "fabien" as user "fabien" via socket in "/tmp" at port "5432". SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off) It says that there is a socket, but there is none. The SSL bit is a giveaway, there is no SSL on Unix-domain sockets. >> sh> psql "host=foo hostaddr=127.0.0.1" >> >> psql> \conninfo >> You are connected to database "fabien" as user "fabien" on host "foo" (address "127.0.0.1") at port "5432". > > Nevertheless, that seems like a reasonable change to the output. Will > your patch show the IP address in all cases or only when hostaddr is > specified? It is always printed, unless both host & address are equal. The rational is that it is also potentially useful for multi-ip dns resolutions, and generating a valid hostaddr allows \connect defaults to reuse the actual same connection, including the IP that was chosen. Also, the added information is quite short, and if a user explicitely asks for connection information, I think they can handle the slightly expanded answer. -- Fabien.
Commits
-
Tweak libpq's PQhost, PQhostaddr, and psql's \connect
- 313f56ce2d1b 12.0 landed
-
psql: Show IP address in \conninfo
- 6e5f8d489acc 12.0 landed