Re: Psql meta-command conninfo+

Hunaid Sohail <hunaidpgml@gmail.com>

From: Hunaid Sohail <hunaidpgml@gmail.com>
To: pgsql-hackers@postgresql.org
Cc: Alvaro Herrera <alvherre@alvh.no-ip.org>, Jim Jones <jim.jones@uni-muenster.de>, Maiquel Grassi <grassi@hotmail.com.br>, 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>, Tom Lane <tgl@sss.pgh.pa.us>
Date: 2024-09-16T06:51:04Z
Lists: pgsql-hackers

Attachments

Hi,

On Sat, Sep 14, 2024 at 10:50 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:

> Alvaro Herrera <alvherre@alvh.no-ip.org> writes:
> > I don't understand why this is is printing half the information in
> > free-form plain text and the other half in tabular format.  All these
> > items that you have in the free-form text lines should be part of the
> > table, I think.
>
> +1, that was my reaction as well.  I can see the point of showing
> those items the same way as plain \conninfo does, but I think
> we're better off just making \conninfo+ produce a table and nothing
> else.
>

I have attached a new patch that now prints all info in tabular format for
\conninfo+. I have also made the table output dynamic, so if the connection
uses SSL, the columns in the table will expand accordingly.

```
$ bin/psql "port=5430 sslmode=require dbname=postgres" -x -h localhost

postgres=# \conninfo+
Connection Information
-[ RECORD 1 ]--------+-----------------------
Database             | postgres
Current User         | hunaid
Session User         | hunaid
Host                 | localhost
Host Address         | 127.0.0.1
Port                 | 5430
Protocol Version     | 3
SSL Connection       | yes
SSL Protocol         | TLSv1.3
Cipher               | TLS_AES_256_GCM_SHA384
Compression          | off
ALPN                 | postgresql
GSSAPI Authenticated | no
Client Encoding      | UTF8
Server Encoding      | UTF8
Backend PID          | 88803


$ bin/psql "port=5430 sslmode=disable dbname=postgres" -x -h localhost

postgres=# \conninfo+
Connection Information
-[ RECORD 1 ]--------+----------
Database             | postgres
Current User         | hunaid
Session User         | hunaid
Host                 | localhost
Host Address         | 127.0.0.1
Port                 | 5430
Protocol Version     | 3
SSL Connection       | no
GSSAPI Authenticated | no
Client Encoding      | UTF8
Server Encoding      | UTF8
Backend PID          | 88900


$ bin/psql "port=5430 sslmode=disable dbname=postgres" -x

postgres=# \conninfo+
Connection Information
-[ RECORD 1 ]--------+---------
Database             | postgres
Current User         | hunaid
Session User         | hunaid
Socket Directory     | /tmp
Port                 | 5430
Protocol Version     | 3
SSL Connection       | no
GSSAPI Authenticated | no
Client Encoding      | UTF8
Server Encoding      | UTF8
Backend PID          | 89035
```

I have also updated the documentation.

Regards,
Hunaid Sohail

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.