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

Commit4d65d28

Browse files
committed
Document that SELECT ... ORDER BY .. FOR UPDATE/SHARE might return
results out of order because of locking, per bug report 4593
1 parent3b35a90 commit4d65d28

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

‎doc/src/sgml/ref/select.sgml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/select.sgml,v 1.118 2009/01/22 20:15:59 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/select.sgml,v 1.119 2009/01/23 14:05:28 momjian Exp $
33
PostgreSQL documentation
44
-->
55

@@ -1163,16 +1163,31 @@ ROLLBACK TO s;
11631163
<caution>
11641164
<para>
11651165
It is possible for a <command>SELECT</> command using both
1166-
<literal>LIMIT</literal> and<literal>FOR UPDATE/SHARE</literal>
1166+
<literal>LIMIT</literal> and <literal>FOR UPDATE/SHARE</literal>
11671167
clauses to return fewer rows than specified by <literal>LIMIT</literal>.
11681168
This is because <literal>LIMIT</> is applied first. The command
11691169
selects the specified number of rows,
1170-
but might then block trying to obtain lock on one or more of them.
1170+
but might then block trying to obtainalock on one or more of them.
11711171
Once the <literal>SELECT</> unblocks, the row might have been deleted
11721172
or updated so that it does not meet the query <literal>WHERE</> condition
11731173
anymore, in which case it will not be returned.
11741174
</para>
11751175
</caution>
1176+
1177+
<caution>
1178+
<para>
1179+
Similarly, it is possible for a <command>SELECT</> command
1180+
using <literal>ORDER BY</literal> and <literal>FOR
1181+
UPDATE/SHARE</literal> to return rows out of order. This is
1182+
because <literal>ORDER BY</> is applied first. The command
1183+
orders the result, but might then block trying to obtain a lock
1184+
on one or more of the rows. Once the <literal>SELECT</>
1185+
unblocks, one of the ordered columns might have been modified
1186+
and be returned out of order. A workaround is to perform
1187+
<command>SELECT ... FOR UPDATE/SHARE</> and then <command>SELECT
1188+
... ORDER BY</>.
1189+
</para>
1190+
</caution>
11761191
</refsect2>
11771192

11781193
<refsect2 id="SQL-TABLE">

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp