Re: Psql meta-command conninfo+

From: Nathan Bossart <nathandbossart(at)gmail(dot)com>
To: Maiquel Grassi <grassi(at)hotmail(dot)com(dot)br>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Psql meta-command conninfo+
Date: 2024-02-06 18:19:19
Message-ID: 20240206181919.GA3853632@nathanxps13
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Feb 06, 2024 at 05:27:01PM +0000, Maiquel Grassi wrote:
> I'm seeking to improve the \conninfo meta-command in psql. Currently, it
> provides limited information about the current connection. I believe that
> expanding it using the concept of "plus" [+] could ease the work of DBAs,
> SysAdmins, DevOps, etc., who manage a large volume of databases and/or
> multiple PostgreSQL servers. The objective of this enhancement is to
> obtain quick information about the current connection (session). I
> believe that for a PostgreSQL administrator, it is not feasible to write
> a plpgsql function and apply it to all databases (for example, imagine
> managing over 200 databases). I have an example on GitHub
> https://github.com/maiquelgrassi/DBA-toolkit/blob/main/cluster/dba_whoami_function.sql
> of a plpgsql function demonstrating exactly what I believe is impractical
> for the daily routine of a PostgreSQL professional. I see psql's
> meta-commands as significant allies in daily work in productive
> environments.

This seems like a reasonable idea to me.

> postgres=# \conninfo+
> Current Connection Information
> Attribute | Value
> ----------------+----------------
> Database | postgres
> User | postgres
> Server Version | 16.1
> Server Address | 192.168.0.5/32
> Server Port | 5433
> Client Address | 192.168.0.5/32
> Client Port | 52716
> Session PID | 21624
> (8 rows)

My first reaction is that this should instead return a single row with the
same set of columns for any connection type (the not-applicable ones would
just be set to NULL). That would match the other meta-commands like \l and
\du, and you could still get an expanded display with \x if needed. Also,
I think it would simplify the code a bit.

--
Nathan Bossart
Amazon Web Services: https://aws.amazon.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bharath Rupireddy 2024-02-06 18:52:07 Re: Introduce XID age and inactive timeout based replication slot invalidation
Previous Message Amonson, Paul D 2024-02-06 18:16:23 RE: Popcount optimization using AVX512