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

Commitc0aed69

Browse files
committed
Allow UNLISTEN in hot-standby mode.
Since LISTEN is (still) disallowed, UNLISTEN must be a no-op in ahot-standby session, and so there's no harm in allowing it. Thischange allows client code to not worry about whether it's connectedto a primary or standby server when performing session-state-resettype activities. (Note that DISCARD ALL, which includes UNLISTEN,was already allowed, making it inconsistent to reject UNLISTEN.)Per discussion, back-patch to all supported versions.Shay Rojansky, reviewed by Mi TarDiscussion:https://postgr.es/m/CADT4RqCf2gA_TJtPAjnGzkC3ZiexfBZiLmA-mV66e4UyuVv8bA@mail.gmail.com
1 parent28868f7 commitc0aed69

File tree

6 files changed

+16
-10
lines changed

6 files changed

+16
-10
lines changed

‎doc/src/sgml/high-availability.sgml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1774,6 +1774,11 @@ if (!triggered)
17741774
Plugins and extensions - <command>LOAD</command>
17751775
</para>
17761776
</listitem>
1777+
<listitem>
1778+
<para>
1779+
<command>UNLISTEN</command>
1780+
</para>
1781+
</listitem>
17771782
</itemizedlist>
17781783
</para>
17791784

@@ -1863,16 +1868,16 @@ if (!triggered)
18631868
</listitem>
18641869
<listitem>
18651870
<para>
1866-
<command>LISTEN</command>, <command>UNLISTEN</command>, <command>NOTIFY</command>
1871+
<command>LISTEN</command>, <command>NOTIFY</command>
18671872
</para>
18681873
</listitem>
18691874
</itemizedlist>
18701875
</para>
18711876

18721877
<para>
18731878
In normal operation, <quote>read-only</quote> transactions are allowed to
1874-
use <command>LISTEN</command>,<command>UNLISTEN</command>, and
1875-
<command>NOTIFY</command>,so Hot Standby sessions operate under slightly tighter
1879+
use <command>LISTEN</command> and<command>NOTIFY</command>,
1880+
so Hot Standby sessions operate under slightly tighter
18761881
restrictions than ordinary read-only sessions. It is possible that some
18771882
of these restrictions might be loosened in a future release.
18781883
</para>

‎src/backend/tcop/utility.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ standard_ProcessUtility(PlannedStmt *pstmt,
629629
{
630630
UnlistenStmt*stmt= (UnlistenStmt*)parsetree;
631631

632-
PreventCommandDuringRecovery("UNLISTEN");
632+
/* we allowUNLISTEN during recovery, as it's a noop */
633633
CheckRestrictedOperation("UNLISTEN");
634634
if (stmt->conditionname)
635635
Async_Unlisten(stmt->conditionname);

‎src/test/regress/expected/hs_standby_allowed.out

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,9 @@ LOCK hs1 IN ACCESS SHARE MODE;
208208
LOCK hs1 IN ROW SHARE MODE;
209209
LOCK hs1 IN ROW EXCLUSIVE MODE;
210210
COMMIT;
211+
-- UNLISTEN
212+
UNLISTEN a;
213+
UNLISTEN *;
211214
-- LOAD
212215
-- should work, easier if there is no test for that...
213216
-- ALLOWED COMMANDS

‎src/test/regress/expected/hs_standby_disallowed.out

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,6 @@ listen a;
118118
ERROR: cannot execute LISTEN during recovery
119119
notify a;
120120
ERROR: cannot execute NOTIFY during recovery
121-
unlisten a;
122-
ERROR: cannot execute UNLISTEN during recovery
123-
unlisten *;
124-
ERROR: cannot execute UNLISTEN during recovery
125121
-- disallowed commands
126122
ANALYZE hs1;
127123
ERROR: cannot execute ANALYZE during recovery

‎src/test/regress/sql/hs_standby_allowed.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ LOCK hs1 IN ROW SHARE MODE;
110110
LOCK hs1IN ROW EXCLUSIVE MODE;
111111
COMMIT;
112112

113+
-- UNLISTEN
114+
UNLISTEN a;
115+
UNLISTEN*;
116+
113117
-- LOAD
114118
-- should work, easier if there is no test for that...
115119

‎src/test/regress/sql/hs_standby_disallowed.sql

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ COMMIT;
8888
-- Listen
8989
listen a;
9090
notify a;
91-
unlisten a;
92-
unlisten*;
9391

9492
-- disallowed commands
9593

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp