Re: [PATCH] Add support for displaying database service in psql prompt

Michael Paquier <michael@paquier.xyz>

From: Michael Paquier <michael@paquier.xyz>
To: Michael Banck <mbanck@gmx.net>
Cc: Greg Sabino Mullane <htamfids@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2024-12-17T07:43:21Z
Lists: pgsql-hackers
On Mon, Dec 16, 2024 at 10:57:49PM +0100, Michael Banck wrote:
> Thanks, I have added the documentation now in v2.

The doc additions seem fine to me.  I've just grabbed three tiny nits,
nothing critical.

+				case 's':
+					if (PQservice(pset.db))
+						strlcpy(buf, PQservice(pset.db), sizeof(buf));
+					break;

Other code paths of get_prompt check for pset.db being NULL.  True
that it does not matter when calling PQservice() with a connection
that does not exist.  For consistency with the surroundings this
should be done at least?

+        <para>
+        The service from <filename>pg_service.conf</filename>, if applicable.
+        </para>

pg_service.conf is not especially true as it depends on the
environment used.  For psql, perhaps just use "The service name, if
applicable".  No need to be fancy.

--- a/src/interfaces/libpq/exports.txt
+++ b/src/interfaces/libpq/exports.txt
@@ -205,3 +205,4 @@ PQcancelFinish            202
[...]
+PQservice                 206

You didn't miss that, nice.
 
+      <varlistentry id="app-psql-prompting-s">
+        <term><literal>%s</literal></term>
+        <listitem><para>The name of the service entry, if any.</para></listitem>
+      </varlistentry>

Other entries don't use "if any", would just cut it.
--
Michael

Commits

  1. libpq: Remove PQservice()

  2. psql: Add more information about service name

  3. libpq: Add service name to PGconn and PQservice()