public inbox for [email protected]  
help / color / mirror / Atom feed
From: Noah Misch <[email protected]>
To: Michael Paquier <[email protected]>
Cc: Michael Banck <[email protected]>
Cc: Greg Sabino Mullane <[email protected]>
Cc: PostgreSQL Hackers <[email protected]>
Subject: Re: [PATCH] Add support for displaying database service in psql prompt
Date: Sun, 6 Jul 2025 20:00:09 -0700
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
	<CAKAnmmKhnHGp4X3FvMAicRsbyiKTWwMJ6oWdkRw2oLVzdeL-0A@mail.gmail.com>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>

On Mon, Jul 07, 2025 at 11:06:06AM +0900, Michael Paquier wrote:
> On Sun, Jul 06, 2025 at 09:13:19AM -0700, Noah Misch wrote:
> > This new PQservice() function from commit 4b99fed75 came up in the annual
> > exports.txt diff.  The standard in libpq has been to not clutter the API with
> > new functions that simply retrieve one PQconninfoOption value.  PQconninfo()
> > provides access to all those values in a generic way.  What do you think of
> > making psql use PQconninfo() for this, then removing PQservice()?  The rest of
> > the commit (adding the struct field, necessary for PQconninfo() to include the
> > value) looks good.
> 
> Sure, I was not aware of such a policy.  Relying on PQconninfoOption
> is less efficient because we would need to look through the whole set
> of options when looking for the service name, and this needs one extra
> allocation as PQconninfoFree() frees the values allocated.  With two
> callers perhaps this inefficiency is OK to live with anyway.

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.





view thread (14+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected], [email protected], [email protected]
  Subject: Re: [PATCH] Add support for displaying database service in psql prompt
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox