Re: Psql meta-command conninfo+

From: Nathan Bossart <nathandbossart(at)gmail(dot)com>
To: Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>
Cc: Maiquel Grassi <grassi(at)hotmail(dot)com(dot)br>, Pavel Luzanov <p(dot)luzanov(at)postgrespro(dot)ru>, Erik Wienhold <ewie(at)ewie(dot)name>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Psql meta-command conninfo+
Date: 2024-02-16 15:54:49
Message-ID: 20240216155449.GA1236054@nathanxps13
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Thanks for your work on this. I haven't been keeping up with the
discussion, but I took a quick look at the latest patch.

+ <para>
+ "Database", "Authenticated User", "System User" (only for PostgreSQL 16 or higher),
+ "Current User", "Session User", "Backend PID", "Server Address", "Server Port",
+ "Client Address", "Client Port", "Socket Directory", and "Host" columns are listed
+ by default when <literal>\conninfo+</literal> is invoked. The columns "Encryption",
+ "Protocol", "Cipher", and "Compression" are added to this output when TLS (SSL)
+ authentication is used. The same applies to GSS authentication is used, where the
+ "GSSAPI" column is also added to the <literal>\conninfo+</literal> output.
</para>

I might be alone on this, but I think this command should output the same
columns regardless of the version, whether it's using SSL, etc. and just
put NULL in any that do not apply. IMHO that would simplify the code and
help prevent confusion. Plus, I'm not aware of any existing meta-commands
that provide certain columns conditionally.

+ if (PQsslInUse(pset.db))
+ {
+ protocol = PQsslAttribute(pset.db, "protocol");
+ cipher = PQsslAttribute(pset.db, "cipher");
+ compression = PQsslAttribute(pset.db, "compression");
+ appendPQExpBuffer(&buf,
+ " ,'SSL' AS \"Encryption\",\n"
+ " '%s' AS \"Protocol\",\n"
+ " '%s' AS \"Cipher\",\n"
+ " '%s' AS \"Compression\"\n",
+ protocol ? protocol : _("unknown"),
+ cipher ? cipher : _("unknown"),
+ (compression && strcmp(compression, "off") != 0) ? _("on") : _("off"));
+ }

Could we pull some of this information from pg_stat_ssl instead of from
libpq? The reason I suggest this is because I think it would be nice if
the query that \conninfo+ uses could be copy/pasted as needed and not rely
on hard-coded values chosen by the client.

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeff Davis 2024-02-16 17:31:18 Re: Improve WALRead() to suck data directly from WAL buffers when possible
Previous Message Aleksander Alekseev 2024-02-16 15:15:57 Re: psql: Add command to use extended query protocol