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

Commitc184470

Browse files
committed
Document the recently-understood hazard that a rollback can release row-level
locks that logically should not be released, because when a subtransactionoverwrites XMAX all knowledge of the previous lock state is lost. It seemsunlikely that we will be able to fix this before 8.3...
1 parent3049fe7 commitc184470

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

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

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/select.sgml,v 1.93 2006/09/18 19:54:01 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/select.sgml,v 1.94 2006/12/01 20:49:53 tgl Exp $
33
PostgreSQL documentation
44
-->
55

@@ -883,6 +883,31 @@ FOR SHARE [ OF <replaceable class="parameter">table_name</replaceable> [, ...] ]
883883
individual table rows; for example they can't be used with aggregation.
884884
</para>
885885

886+
<caution>
887+
<para>
888+
Avoid locking a row and then modifying it within a later savepoint or
889+
<application>PL/pgSQL</application> exception block. A subsequent
890+
rollback would cause the lock to be lost. For example,
891+
<programlisting>
892+
BEGIN;
893+
SELECT * FROM mytable WHERE key = 1 FOR UPDATE;
894+
SAVEPOINT s;
895+
UPDATE mytable SET ... WHERE key = 1;
896+
ROLLBACK TO s;
897+
</programlisting>
898+
After the <command>ROLLBACK</>, the row is effectively unlocked, rather
899+
than returned to its pre-savepoint state of being locked but not modified.
900+
This hazard occurs if a row locked in the current transaction is updated
901+
or deleted, or if a shared lock is upgraded to exclusive: in all these
902+
cases, the former lock state is forgotten. If the transaction is then
903+
rolled back to a state between the original locking command and the
904+
subsequent change, the row will appear not to be locked at all. This is
905+
an implementation deficiency which will be addressed in a future release
906+
of <productname>PostgreSQL</productname>.
907+
</para>
908+
</caution>
909+
910+
<caution>
886911
<para>
887912
It is possible for a <command>SELECT</> command using both
888913
<literal>LIMIT</literal> and <literal>FOR UPDATE/SHARE</literal>
@@ -894,6 +919,7 @@ FOR SHARE [ OF <replaceable class="parameter">table_name</replaceable> [, ...] ]
894919
or updated so that it does not meet the query <literal>WHERE</> condition
895920
anymore, in which case it will not be returned.
896921
</para>
922+
</caution>
897923
</refsect2>
898924
</refsect1>
899925

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp