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