Re: display hot standby state in psql prompt

From: Nathan Bossart <nathandbossart(at)gmail(dot)com>
To: Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>
Cc: Fujii Masao <masao(dot)fujii(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>
Subject: Re: display hot standby state in psql prompt
Date: 2025-10-27 16:23:12
Message-ID: aP-ccJv1iyOmrieo@nathan
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Oct 27, 2025 at 09:08:17AM +0100, Jim Jones wrote:
> + Displays the session's read-only status as <literal>read-only</literal>
> + if the server is in hot standby (<literal>in_hot_standby</literal> is
> + <literal>on</literal>) or the default transaction mode is read-only
> + (<literal>default_transaction_read_only</literal> is <literal>on</literal>),
> + or <literal>read-write</literal> otherwise. Useful for identifying
> + sessions that cannot perform writes, such as in replication setups.

This was briefly mentioned upthread, but I'm a little concerned that this
doesn't respond to commands like SET TRANSACTION READ ONLY. I wonder if we
should mark transaction_read_only as GUC_REPORT and use that instead. FWIW
I see that we marked search_path as GUC_REPORT somewhat recently (see
commit 28a1121).

--
nathan

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Mark Wong 2025-10-27 16:45:10 Re: [PATCH] Add pg_get_policy_ddl() function to reconstruct CREATE POLICY statement
Previous Message Tomas Vondra 2025-10-27 16:18:50 Re: Batching in executor