aboutsummaryrefslogtreecommitdiff
path: root/doc/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2021-03-02 20:17:45 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2021-03-02 20:17:48 -0500
commitee28cacf619f4d9c23af5a80e1171a5adae97381 (patch)
treedda36f982a797351cb56e3baf188a775f985512a /doc/src
parent57e6db706e81fd2609fa385677e6ae72471822fe (diff)
downloadpostgresql-ee28cacf619f4d9c23af5a80e1171a5adae97381.tar.gz
postgresql-ee28cacf619f4d9c23af5a80e1171a5adae97381.zip
Extend the abilities of libpq's target_session_attrs parameter.
In addition to the existing options of "any" and "read-write", we now support "read-only", "primary", "standby", and "prefer-standby". "read-write" retains its previous meaning of "transactions are read-write by default", and "read-only" inverts that. The other three modes test specifically for hot-standby status, which is not quite the same thing. (Setting default_transaction_read_only on a primary server renders it read-only to this logic, but not a standby.) Furthermore, if talking to a v14 or later server, no extra network round trip is needed to detect the session's status; the GUC_REPORT variables delivered by the server are enough. When talking to an older server, a SHOW or SELECT query is issued to detect session read-only-ness or server hot-standby state, as needed. Haribabu Kommi, Greg Nancarrow, Vignesh C, 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
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/sgml/libpq.sgml79
1 files changed, 68 insertions, 11 deletions
diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml
index 42b02b0a00c..cc20b0f234a 100644
--- a/doc/src/sgml/libpq.sgml
+++ b/doc/src/sgml/libpq.sgml
@@ -1877,18 +1877,75 @@ postgresql://%2Fvar%2Flib%2Fpostgresql/dbname
<term><literal>target_session_attrs</literal></term>
<listitem>
<para>
- If this parameter is set to <literal>read-write</literal>, only a
- connection in which read-write transactions are accepted by default
- is considered acceptable. The query
- <literal>SHOW transaction_read_only</literal> will be sent upon any
- successful connection; if it returns <literal>on</literal>, the connection
- will be closed. If multiple hosts were specified in the connection
- string, any remaining servers will be tried just as if the connection
- attempt had failed. The default value of this parameter,
- <literal>any</literal>, regards all connections as acceptable.
- </para>
+ This option determines whether the session must have certain
+ properties to be acceptable. It's typically used in combination
+ with multiple host names to select the first acceptable alternative
+ among several hosts. There are six modes:
+
+ <variablelist>
+ <varlistentry>
+ <term><literal>any</literal> (default)</term>
+ <listitem>
+ <para>
+ any successful connection is acceptable
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><literal>read-write</literal></term>
+ <listitem>
+ <para>
+ session must accept read-write transactions by default (that
+ is, the server must not be in hot standby mode and
+ the <varname>default_transaction_read_only</varname> parameter
+ must be <literal>off</literal>)
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><literal>read-only</literal></term>
+ <listitem>
+ <para>
+ session must not accept read-write transactions by default (the
+ converse)
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><literal>primary</literal></term>
+ <listitem>
+ <para>
+ server must not be in hot standby mode
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><literal>standby</literal></term>
+ <listitem>
+ <para>
+ server must be in hot standby mode
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><literal>prefer-standby</literal></term>
+ <listitem>
+ <para>
+ first try to find a standby server, but if none of the listed
+ hosts is a standby server, try again in <literal>all</literal>
+ mode
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </para>
</listitem>
- </varlistentry>
+ </varlistentry>
</variablelist>
</para>
</sect2>