Re: display hot standby state in psql prompt - Mailing list pgsql-hackers

From Nathan Bossart
Subject Re: display hot standby state in psql prompt
Date
Msg-id aQDyjGLkBN-Oowty@nathan
Whole thread Raw
In response to Re: display hot standby state in psql prompt  (Jim Jones <jim.jones@uni-muenster.de>)
Responses Re: display hot standby state in psql prompt
List pgsql-hackers
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



pgsql-hackers by date:

Previous
From: Dagfinn Ilmari Mannsåker
Date:
Subject: Re: Add uuid_to_base32hex() and base32hex_to_uuid() built-in functions
Next
From: Nico Williams
Date:
Subject: Re: Channel binding for post-quantum cryptography