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

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

  1. psql: Change new \conninfo to use SSL instead of TLS

  2. Change \conninfo to use tabular format

  3. Update extension lookup routines to use the syscache

  4. Improve COPY TO performance when server and client encodings match

  5. doc: Remove superfluous bracket in synopsis

  6. Remove psql support for server versions preceding 9.2.