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-10 07:30:38
Message-ID: CAHGQGwFvQ3Sec36iASGq7Vx_R0OOGgCOxvGqimMYGptzQ6KtcA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Nov 8, 2025 at 7:21 PM Jim Jones <jim(dot)jones(at)uni-muenster(dot)de> wrote:
> > I personally lean towards that maybe we should keep it simple and go
> > back to the origins of the patch which just tried to show if it is a
> > standby or not given how complex it is to tell that we are in read-only
> > or not. The alternative would be to update the protocol so the client if
> > informed if a transaction is read-only or not but I do not think it
> > would be possible to convince people to update the protocol just for
> > psql. Maybe if some connection pooler would also be interest but I am
> > not sure what they would need this for.
>
>
> If we decide to not consider transaction_read_only for this feature, I
> guess we should prevent the prompt to show anything if inside of a
> transaction block. Simply ignoring it and showing a potentially wrong
> status wouldn't be a good idea.
>
> What do you guys think?

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.

Regards,

--
Fujii Masao

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bertrand Drouvot 2025-11-10 07:57:39 Re: Consistently use the XLogRecPtrIsInvalid() macro
Previous Message Fujii Masao 2025-11-10 07:04:04 Re: [PATCH] libpq: Wrap out-of-memory error messages with libpq_gettext()