On Tue, Feb 06, 2024 at 09:45:54PM +0000, Maiquel Grassi wrote: > My initial idea has always been that they should continue to appear > because \conninfo+ should show all the things that \conninfo shows and > add more information. I think that's the purpose of the 'plus.' Now we're > on a better path than the initial one. We can still add the socket > directory and the host.
Agreed. --//-- I believe it's resolved reasonably well this way: SELECT pg_catalog.current_database() AS "Database", current_user AS "User", pg_catalog.current_setting('server_version') AS "Server Version", CASE WHEN pg_catalog.inet_server_addr() IS NULL THEN 'NULL' ELSE pg_catalog.inet_server_addr()::text END AS "Server Address", pg_catalog.current_setting('port') AS "Port", CASE WHEN pg_catalog.inet_client_addr() IS NULL THEN 'NULL' ELSE pg_catalog.inet_client_addr()::text END AS "Client Address", CASE WHEN pg_catalog.inet_client_port() IS NULL THEN 'NULL' ELSE pg_catalog.inet_client_port()::text END AS "Client Port", pg_catalog.pg_backend_pid() AS "Session PID", CASE WHEN pg_catalog.current_setting('unix_socket_directories') = '' THEN 'NULL' ELSE pg_catalog.current_setting('unix_socket_directories') END AS "Socket Directory", CASE WHEN pg_catalog.inet_server_addr() IS NULL AND pg_catalog.inet_client_addr() IS NULL THEN 'NULL' WHEN pg_catalog.inet_server_addr() = pg_catalog.inet_client_addr() THEN 'localhost' ELSE pg_catalog.inet_server_addr()::text END AS "Host"; See below the tests: [postgres@localhost bin]$ ./psql psql (17devel) Type "help" for help. postgres=# \conninfo You are connected to database "postgres" as user "postgres" via socket in "/tmp" at port "5432". postgres=# \conninfo+ Current Connection Information Database | User | Server Version | Server Address | Port | Client Address | Client Port | Session PID | Socket Directory | Host ----------+----------+----------------+----------------+------+----------------+-------------+-------------+------------------+------ postgres | postgres | 17devel | NULL | 5432 | NULL | NULL | 14348 | /tmp | NULL (1 row) [postgres@localhost bin]$ ./psql -h localhost psql (17devel) Type "help" for help. postgres=# \conninfo You are connected to database "postgres" as user "postgres" on host "localhost" (address "::1") at port "5432". postgres=# \conninfo+ Current Connection Information Database | User | Server Version | Server Address | Port | Client Address | Client Port | Session PID | Socket Directory | Host ----------+----------+----------------+----------------+------+----------------+-------------+-------------+------------------+----------- postgres | postgres | 17devel | ::1/128 | 5432 | ::1/128 | 46988 | 14353 | /tmp | localhost (1 row) [postgres@localhost bin]$ ./psql -h ::1 psql (17devel) Type "help" for help. postgres=# \conninfo You are connected to database "postgres" as user "postgres" on host "::1" at port "5432". postgres=# \conninfo+ Current Connection Information Database | User | Server Version | Server Address | Port | Client Address | Client Port | Session PID | Socket Directory | Host ----------+----------+----------------+----------------+------+----------------+-------------+-------------+------------------+----------- postgres | postgres | 17devel | ::1/128 | 5432 | ::1/128 | 46990 | 14356 | /tmp | localhost (1 row) [postgres@localhost bin]$ ./psql -h 127.0.0.1 psql (17devel) Type "help" for help. postgres=# \conninfo You are connected to database "postgres" as user "postgres" on host "127.0.0.1" at port "5432". postgres=# \conninfo+ Current Connection Information Database | User | Server Version | Server Address | Port | Client Address | Client Port | Session PID | Socket Directory | Host ----------+----------+----------------+----------------+------+----------------+-------------+-------------+------------------+----------- postgres | postgres | 17devel | 127.0.0.1/32 | 5432 | 127.0.0.1/32 | 35042 | 14359 | /tmp | localhost (1 row) [postgres@localhost bin]$ ./psql -h 192.168.0.5 -p 5433 -U postgres -d postgres psql (17devel, server 16.1) Type "help" for help. postgres=# \conninfo You are connected to database "postgres" as user "postgres" on host "192.168.0.5" at port "5433". postgres=# \conninfo+ Current Connection Information Database | User | Server Version | Server Address | Port | Client Address | Client Port | Session PID | Socket Directory | Host ----------+----------+----------------+----------------+------+----------------+-------------+-------------+------------------+----------- postgres | postgres | 16.1 | 192.168.0.5/32 | 5433 | 192.168.0.5/32 | 52783 | 18212 | NULL | localhost (1 row) Regards, Maiquel O. Grassi.
v4-0001-psql-meta-command-conninfo-plus.patch
Description: v4-0001-psql-meta-command-conninfo-plus.patch