Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitee28cac

Browse files
committed
Extend the abilities of libpq's target_session_attrs parameter.
In addition to the existing options of "any" and "read-write", wenow support "read-only", "primary", "standby", and "prefer-standby"."read-write" retains its previous meaning of "transactions areread-write by default", and "read-only" inverts that. The otherthree modes test specifically for hot-standby status, which is notquite the same thing. (Setting default_transaction_read_only ona primary server renders it read-only to this logic, but not astandby.)Furthermore, if talking to a v14 or later server, no extra networkround trip is needed to detect the session's status; the GUC_REPORTvariables delivered by the server are enough. When talking to anolder server, a SHOW or SELECT query is issued to detect sessionread-only-ness or server hot-standby state, as needed.Haribabu Kommi, Greg Nancarrow, Vignesh C, Tom Lane; reviewed atvarious times by Laurenz Albe, Takayuki Tsunakawa, Peter Smith.Discussion:https://postgr.es/m/CAF3+xM+8-ztOkaV9gHiJ3wfgENTq97QcjXQt+rbFQ6F7oNzt9A@mail.gmail.com
1 parent57e6db7 commitee28cac

File tree

6 files changed

+456
-114
lines changed

6 files changed

+456
-114
lines changed

‎doc/src/sgml/libpq.sgml

Lines changed: 68 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1877,18 +1877,75 @@ postgresql://%2Fvar%2Flib%2Fpostgresql/dbname
18771877
<term><literal>target_session_attrs</literal></term>
18781878
<listitem>
18791879
<para>
1880-
If this parameter is set to <literal>read-write</literal>, only a
1881-
connection in which read-write transactions are accepted by default
1882-
is considered acceptable. The query
1883-
<literal>SHOW transaction_read_only</literal> will be sent upon any
1884-
successful connection; if it returns <literal>on</literal>, the connection
1885-
will be closed. If multiple hosts were specified in the connection
1886-
string, any remaining servers will be tried just as if the connection
1887-
attempt had failed. The default value of this parameter,
1888-
<literal>any</literal>, regards all connections as acceptable.
1889-
</para>
1880+
This option determines whether the session must have certain
1881+
properties to be acceptable. It's typically used in combination
1882+
with multiple host names to select the first acceptable alternative
1883+
among several hosts. There are six modes:
1884+
1885+
<variablelist>
1886+
<varlistentry>
1887+
<term><literal>any</literal> (default)</term>
1888+
<listitem>
1889+
<para>
1890+
any successful connection is acceptable
1891+
</para>
1892+
</listitem>
1893+
</varlistentry>
1894+
1895+
<varlistentry>
1896+
<term><literal>read-write</literal></term>
1897+
<listitem>
1898+
<para>
1899+
session must accept read-write transactions by default (that
1900+
is, the server must not be in hot standby mode and
1901+
the <varname>default_transaction_read_only</varname> parameter
1902+
must be <literal>off</literal>)
1903+
</para>
1904+
</listitem>
1905+
</varlistentry>
1906+
1907+
<varlistentry>
1908+
<term><literal>read-only</literal></term>
1909+
<listitem>
1910+
<para>
1911+
session must not accept read-write transactions by default (the
1912+
converse)
1913+
</para>
1914+
</listitem>
1915+
</varlistentry>
1916+
1917+
<varlistentry>
1918+
<term><literal>primary</literal></term>
1919+
<listitem>
1920+
<para>
1921+
server must not be in hot standby mode
1922+
</para>
1923+
</listitem>
1924+
</varlistentry>
1925+
1926+
<varlistentry>
1927+
<term><literal>standby</literal></term>
1928+
<listitem>
1929+
<para>
1930+
server must be in hot standby mode
1931+
</para>
1932+
</listitem>
1933+
</varlistentry>
1934+
1935+
<varlistentry>
1936+
<term><literal>prefer-standby</literal></term>
1937+
<listitem>
1938+
<para>
1939+
first try to find a standby server, but if none of the listed
1940+
hosts is a standby server, try again in <literal>all</literal>
1941+
mode
1942+
</para>
1943+
</listitem>
1944+
</varlistentry>
1945+
</variablelist>
1946+
</para>
18901947
</listitem>
1891-
</varlistentry>
1948+
</varlistentry>
18921949
</variablelist>
18931950
</para>
18941951
</sect2>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp