Re: display hot standby state in psql prompt

From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>
Cc: Andreas Karlsson <andreas(at)proxel(dot)se>, Nathan Bossart <nathandbossart(at)gmail(dot)com>, Srinath Reddy Sadipiralla <srinath2133(at)gmail(dot)com>, Greg Sabino Mullane <htamfids(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Subject: Re: display hot standby state in psql prompt
Date: 2025-11-12 03:48:43
Message-ID: CAHGQGwE0-XjD6USv-v90Ks04S2b6qGWvJ8HUyYtyvx9g9U3B-g@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Nov 10, 2025 at 5:14 PM Jim Jones <jim(dot)jones(at)uni-muenster(dot)de> wrote:
>
>
>
> On 10/11/2025 08:30, Fujii Masao wrote:
> > If the main goal of this feature is to help users easily determine
> > whether they're connected to a primary or a standby,
> > seems simply showing whether the server is in hot standby
> > should be sufficient. I'm not sure how useful it would be in practice
> > to show information based on default_transaction_read_only or
> > transaction_read_only.
>
> This "primary" or "standby" approach was actually the initial proposal,
> but it evolved after a few reviews. Extending it to use
> transaction_read_only and default_transaction_read_only adds real value
> to the feature, but doing so requires either:
>
> 1. Marking transaction_read_only as GUC_REPORT (controversial and
> rejected in the past), or
> 2. Querying transaction_read_only with SHOW every time the prompt is
> displayed within a transaction block (IMO minimal overhead -- but
> unconventional?).
>
> Although I lean toward the initial proposal, I can totally live with
> either approach, since both would be able to distinguish if a server is
> in hot standby or not.
>
> Should we switch back to the initial proposal?

I'm fine with the initial proposal. I think showing whether the connected
server is a primary or standby in the prompt would be helpful when managing
multiple servers. OTOH, I'm not sure how useful it would be to display
whether the current transaction is read-only.

That said, this is just my view, so I'd like to hear what others think.

Regards,

--
Fujii Masao

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2025-11-12 04:11:39 Re: Trying out read streams in pgvector (an extension)
Previous Message jian he 2025-11-12 02:51:51 Re: Extended Statistics set/restore/clear functions.