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

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Noah Misch <noah(at)leadboat(dot)com>
Cc: Michael Banck <mbanck(at)gmx(dot)net>, Greg Sabino Mullane <htamfids(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: [PATCH] Add support for displaying database service in psql prompt
Date: 2025-07-07 23:52:08
Message-ID: aGxdqG-tibbxXY1D@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Jul 06, 2025 at 08:00:09PM -0700, Noah Misch wrote:
> I think the choice to make there is whether to call PQconninfo() once per
> prompt emission or to cache the value, invalidating that cache e.g. once per
> SyncVariables(). My first thought was to cache, but the decision is not too
> important. A PQconninfo() call is likely negligible relative to all that
> happens between prompts. Even if not negligible, the overhead of not caching
> will affect only prompts using the new escape sequence.

SyncVariables() happens at startup and when re-syncing a connection
during a check, so that does not really worry me.

By the way, there is a second change in the CF that's suggesting the
addition of a SERVICEFILE variable, which also uses a separate libpq
API (forgot about this one):
https://commitfest.postgresql.org/patch/5387/

Changing the patch on the other thread to use a conninfo is
stright-forward. How about extending the get_service_name()@common.c
I've proposed upthread so as it takes a string in input and it could
be reused for more connection options than only "service" so as it
could be reused there as well?
--
Michael

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Vik Fearing 2025-07-08 00:03:29 Re: What is a typical precision of gettimeofday()?
Previous Message Michael Paquier 2025-07-07 23:42:54 Re: Can can I make an injection point wait occur no more than once?