From bf8a662c9afad6fd07b42cdc5e71416c51f75d31 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 5 Jan 2021 16:18:01 -0500 Subject: Introduce a new GUC_REPORT setting "in_hot_standby". Aside from being queriable via SHOW, this value is sent to the client immediately at session startup, and again later on if the server gets promoted to primary during the session. The immediate report will be used in an upcoming patch to avoid an extra round trip when trying to connect to a primary server. Haribabu Kommi, Greg Nancarrow, Tom Lane; reviewed at various times by Laurenz Albe, Takayuki Tsunakawa, Peter Smith. Discussion: https://postgr.es/m/CAF3+xM+8-ztOkaV9gHiJ3wfgENTq97QcjXQt+rbFQ6F7oNzt9A@mail.gmail.com --- doc/src/sgml/config.sgml | 31 +++++++++++++++++++++++++------ doc/src/sgml/high-availability.sgml | 7 +++++-- doc/src/sgml/libpq.sgml | 6 +++++- doc/src/sgml/protocol.sgml | 6 +++++- 4 files changed, 40 insertions(+), 10 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index 67de4150b8e..2a90d011db5 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -9600,13 +9600,14 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir' Preset Options - The following parameters are read-only, and are determined - when PostgreSQL is compiled or when it is - installed. As such, they have been excluded from the sample + The following parameters are read-only. + As such, they have been excluded from the sample postgresql.conf file. These options report various aspects of PostgreSQL behavior that might be of interest to certain applications, particularly administrative front-ends. + Most of them are determined when PostgreSQL + is compiled or when it is installed. @@ -9651,10 +9652,11 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir' - On Unix systems this parameter reports the permissions of the data - directory defined by () at startup. + On Unix systems this parameter reports the permissions the data + directory (defined by ) + had at server startup. (On Microsoft Windows this parameter will always display - 0700). See + 0700.) See for more information. @@ -9695,6 +9697,23 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir' + + in_hot_standby (boolean) + + in_hot_standby configuration parameter + + + + + Reports whether the server is currently in hot standby mode. When + this is on, all transactions are forced to be + read-only. Within a session, this can change only if the server is + promoted to be primary. See for more + information. + + + + lc_collate (string) diff --git a/doc/src/sgml/high-availability.sgml b/doc/src/sgml/high-availability.sgml index 19d7bd2b28f..04f75020e44 100644 --- a/doc/src/sgml/high-availability.sgml +++ b/doc/src/sgml/high-availability.sgml @@ -1859,8 +1859,11 @@ if (!triggered) - Users will be able to tell whether their session is read-only by - issuing SHOW transaction_read_only. In addition, a set of + Users can determine whether hot standby is currently active for their + session by issuing SHOW in_hot_standby. + (In server versions before 14, the in_hot_standby + parameter did not exist; a workable substitute method for older servers + is SHOW transaction_read_only.) In addition, a set of functions () allow users to access information about the standby server. These allow you to write programs that are aware of the current state of the database. These diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml index a5db58d4680..2bb3bf77e43 100644 --- a/doc/src/sgml/libpq.sgml +++ b/doc/src/sgml/libpq.sgml @@ -2150,6 +2150,7 @@ const char *PQparameterStatus(const PGconn *conn, const char *paramName); server_encoding, client_encoding, application_name, + in_hot_standby, is_superuser, session_authorization, DateStyle, @@ -2162,7 +2163,10 @@ const char *PQparameterStatus(const PGconn *conn, const char *paramName); standard_conforming_strings was not reported by releases before 8.1; IntervalStyle was not reported by releases before 8.4; - application_name was not reported by releases before 9.0.) + application_name was not reported by releases before + 9.0; + in_hot_standby was not reported by releases before + 14.) Note that server_version, server_encoding and diff --git a/doc/src/sgml/protocol.sgml b/doc/src/sgml/protocol.sgml index 98b42bb2692..24f7b21ecbd 100644 --- a/doc/src/sgml/protocol.sgml +++ b/doc/src/sgml/protocol.sgml @@ -1278,6 +1278,7 @@ SELCT 1/0; server_encoding, client_encoding, application_name, + in_hot_standby, is_superuser, session_authorization, DateStyle, @@ -1290,7 +1291,10 @@ SELCT 1/0; standard_conforming_strings was not reported by releases before 8.1; IntervalStyle was not reported by releases before 8.4; - application_name was not reported by releases before 9.0.) + application_name was not reported by releases before + 9.0; + in_hot_standby was not reported by releases before + 14.) Note that server_version, server_encoding and -- cgit v1.2.3