RE: Psql meta-command conninfo+
Maiquel Grassi <grassi@hotmail.com.br>
From: Maiquel Grassi <grassi@hotmail.com.br>
To: Nathan Bossart <nathandbossart@gmail.com>
Cc: Jim Jones <jim.jones@uni-muenster.de>, Pavel Luzanov <p.luzanov@postgrespro.ru>, Erik Wienhold <ewie@ewie.name>, "pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>
Date: 2024-03-18T22:05:17Z
Lists: pgsql-hackers
Attachments
- v20-0001-psql-meta-command-conninfo-plus.patch (application/octet-stream) patch v20-0001
On Thu, Feb 29, 2024 at 10:02:21PM +0000, Maiquel Grassi wrote:
> Sorry for the delay. I will make the adjustments as requested soon.
Looking forward to it.
----//----
Hi Nathan!
Sorry for the delay, I was busy with other professional as well as personal activities.
I made all the changes you suggested. I removed the variables and started using
views "pg_stat_ssl" and "pg_stat_gssapi". I handled the PostgreSQL versioning regarding the views used.
Here's a brief demonstration of the result:
[postgres@localhost ~]$ /home/pgsql-17devel/bin/psql -E -x -p 5433
psql (17devel)
Type "help" for help.
postgres=# \conninfo+
/******** QUERY *********/
SELECT
pg_catalog.current_database() AS "Database",
'postgres' AS "Authenticated User",
pg_catalog.system_user() AS "System User",
pg_catalog.current_user() AS "Current User",
pg_catalog.session_user() AS "Session User",
pg_catalog.pg_backend_pid() AS "Backend PID",
pg_catalog.inet_server_addr() AS "Server Address",
pg_catalog.current_setting('port') AS "Server Port",
pg_catalog.inet_client_addr() AS "Client Address",
pg_catalog.inet_client_port() AS "Client Port",
'/tmp' AS "Socket Directory",
CASE
WHEN
pg_catalog.inet_server_addr() IS NULL
AND pg_catalog.inet_client_addr() IS NULL
THEN NULL
ELSE '/tmp'
END AS "Host",
(SELECT gss_authenticated AS "GSSAPI"
FROM pg_catalog.pg_stat_gssapi
WHERE pid = pg_catalog.pg_backend_pid()),
ssl.ssl AS "SSL Connection",
ssl.version AS "SSL Protocol",
ssl.cipher AS "SSL Cipher",
NULL AS "SSL Compression"
FROM
pg_catalog.pg_stat_ssl ssl
WHERE
pid = pg_catalog.pg_backend_pid()
;
/************************/
Current Connection Information
-[ RECORD 1 ]------+---------
Database | postgres
Authenticated User | postgres
System User |
Current User | postgres
Session User | postgres
Backend PID | 29007
Server Address |
Server Port | 5433
Client Address |
Client Port |
Socket Directory | /tmp
Host |
GSSAPI | f
SSL Connection | f
SSL Protocol |
SSL Cipher |
SSL Compression |
Rergards,
Maiquel Grassi.
Commits
-
psql: Change new \conninfo to use SSL instead of TLS
- 6d6480066c1a 18.0 landed
-
Change \conninfo to use tabular format
- bba2fbc6238b 18.0 landed
-
Update extension lookup routines to use the syscache
- d8df7ac5c04c 18.0 cited
-
Improve COPY TO performance when server and client encodings match
- b619852086ed 17.0 cited
-
doc: Remove superfluous bracket in synopsis
- fdfb92c0307c 17.0 cited
-
Remove psql support for server versions preceding 9.2.
- cf0cab868aa4 15.0 cited