public inbox for [email protected]  
help / color / mirror / Atom feed
From: Nathan Bossart <[email protected]>
To: Jim Jones <[email protected]>
Cc: Fujii Masao <[email protected]>
Cc: Srinath Reddy Sadipiralla <[email protected]>
Cc: Greg Sabino Mullane <[email protected]>
Cc: PostgreSQL Hackers <[email protected]>
Subject: Re: display hot standby state in psql prompt
Date: Tue, 28 Oct 2025 11:42:52 -0500
Message-ID: <aQDyjGLkBN-Oowty@nathan> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
	<CAHGQGwHnx96uspkmOsrpytew0A25wm4ozpe2=GzZpHoAph+t0g@mail.gmail.com>
	<[email protected]>
	<CAHGQGwHzNr71zQ7i73Jt55gnW0D-DYJtdoXHKEs0BgsjXAXw5Q@mail.gmail.com>
	<[email protected]>
	<aP-ccJv1iyOmrieo@nathan>
	<[email protected]>
	<aP_dUTvY6a34RqJH@nathan>
	<CAHGQGwERmS5gprymr6mEhVLZRuaNuig9N3jXvOsct-kMf5Ky3A@mail.gmail.com>
	<[email protected]>

On Tue, Oct 28, 2025 at 12:03:48PM +0100, Jim Jones wrote:
> On 28/10/2025 00:55, Fujii Masao wrote:
>> If we mark transaction_read_only as GUC_REPORT, wouldn't the reset value
>> be sent automatically at the end of the transaction? It seems like we wouldn't
>> need any new mechanism for that. However, the downside might be that
>> more ParameterStatus messages would be sent, potentially adding overhead.
> 
> I tried that, but simply marking it as GUC_REPORT does not reset the
> variable when the transaction ends.

IIUC the problem is that we use GUC_ACTION_SET for those even though they
are reset at transaction end by the routines in xact.c.  Something like the
following seems to be enough to get it working as expected in some basic
tests, but there are probably other things to consider.  Keep in mind that
previous proposals to mark transaction_read_only as GUC_REPORT have been
rejected, too.

diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index a82286cc98a..d0bbb5aff19 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -3349,6 +3349,12 @@ set_config_with_handle(const char *name, config_handle *handle,
     bool        prohibitValueChange = false;
     bool        makeDefault;

+    if (action == GUC_ACTION_SET &&
+        (strcmp(name, "transaction_isolation") == 0 ||
+         strcmp(name, "transaction_read_only") == 0 ||
+         strcmp(name, "transaction_deferrable") == 0))
+        action = GUC_ACTION_LOCAL;
+
     if (elevel == 0)
     {
         if (source == PGC_S_DEFAULT || source == PGC_S_FILE)

-- 
nathan





view thread (43+ 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], [email protected]
  Subject: Re: display hot standby state in psql prompt
  In-Reply-To: <aQDyjGLkBN-Oowty@nathan>

* 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