Re: Psql meta-command conninfo+

Alvaro Herrera <alvherre@alvh.no-ip.org>

From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: Hunaid Sohail <hunaidpgml@gmail.com>
Cc: Maiquel Grassi <grassi@hotmail.com.br>, Sami Imseih <samimseih@gmail.com>, "pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>, "David G. Johnston" <david.g.johnston@gmail.com>, Jim Jones <jim.jones@uni-muenster.de>, Tom Lane <tgl@sss.pgh.pa.us>, Nathan Bossart <nathandbossart@gmail.com>, "Imseih (AWS), Sami" <simseih@amazon.com>, Peter Eisentraut <peter@eisentraut.org>, Pavel Luzanov <p.luzanov@postgrespro.ru>, Erik Wienhold <ewie@ewie.name>, Dean Rasheed <dean.a.rasheed@gmail.com>
Date: 2025-02-21T18:19:10Z
Lists: pgsql-hackers

Attachments

I suggest the attached, which gets 99% there with 10% of the
complexity, and has \conninfo (no plus sign) output this:

             Connection Information
       Parámetro       │         Valor          
───────────────────────┼────────────────────────
 Base de Datos         │ alvherre
 Client User           │ alvherre
 Host                  │ 192.168.178.37
 Port                  │ 55432
 Opciones              │ 
 Protocol Version      │ 3
 Password Used?        │ false
 GSSAPI Authenticated? │ false
 Backend PID           │ 1589499
 TLS Connection?       │ true
 TLS Library           │ OpenSSL
 TLS Protocol          │ TLSv1.3
 TLS Key Bits          │ 256
 TLS Cipher            │ TLS_AES_256_GCM_SHA384
 TLS Compression       │ false
 ALPN                  │ postgresql
 Superuser?            │ on
 Hot standby?          │ off
(18 filas)

I have added the parameters is_superuser and in_hot_standby only, and
stayed away from the libpq part of the patch to enumerate parameters.
ISTM a hardcoded list is fine.

Maybe keeping track of 'role' via ParameterStatus messages is a good
idea for reasons unrelated to this patch -- maybe it can be useful for
applications to be aware of role changes -- but I'm not 100% sure about
that, and in particular I'm not sure how heavy the protocol traffic is
going to be if such messages are emitted every time you run a security
invoker function or things like that.  So I'm leaving that part out for
now, and it's easy to do both the libpq patch and \conninfo.


Also, I don't see why we have to keep the current free-format \conninfo.
When you run a query, you get things like

# select 99 as "Luftballons";
 Luftballons 
─────────────
          99

You don't get "There were only 99 Luftballons" or any such nonsense, and I
don't see why \conninfo gets to play different rules.  So I got rid of
\conninfo+.

Do people hate the question marks?

-- 
Álvaro Herrera               48°01'N 7°57'E  —  https://www.EnterpriseDB.com/

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.