Re: Psql meta-command conninfo+

From: Hunaid Sohail <hunaidpgml(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Cc: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>, Maiquel Grassi <grassi(at)hotmail(dot)com(dot)br>, Nathan Bossart <nathandbossart(at)gmail(dot)com>, "Imseih (AWS), Sami" <simseih(at)amazon(dot)com>, Peter Eisentraut <peter(at)eisentraut(dot)org>, Pavel Luzanov <p(dot)luzanov(at)postgrespro(dot)ru>, Erik Wienhold <ewie(at)ewie(dot)name>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: Psql meta-command conninfo+
Date: 2024-09-16 06:51:04
Message-ID: CAMWA6yYHBPwqkf=6j=+CumyzenC2FWhKwLukviTcF9hkeFdKcA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

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

> Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)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

Attachment Content-Type Size
v34-0001-Add-psql-meta-command-conninfo.patch application/octet-stream 12.2 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Denis Garsh 2024-09-16 07:19:13 Re: Add system column support to the USING clause
Previous Message Tony Wayne 2024-09-16 06:49:27 Re: A starter task