|
1 | 1 | <!-- |
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 $ |
3 | 3 | PostgreSQL documentation |
4 | 4 | --> |
5 | 5 |
|
@@ -1163,16 +1163,31 @@ ROLLBACK TO s; |
1163 | 1163 | <caution> |
1164 | 1164 | <para> |
1165 | 1165 | 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> |
1167 | 1167 | clauses to return fewer rows than specified by <literal>LIMIT</literal>. |
1168 | 1168 | This is because <literal>LIMIT</> is applied first. The command |
1169 | 1169 | 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. |
1171 | 1171 | Once the <literal>SELECT</> unblocks, the row might have been deleted |
1172 | 1172 | or updated so that it does not meet the query <literal>WHERE</> condition |
1173 | 1173 | anymore, in which case it will not be returned. |
1174 | 1174 | </para> |
1175 | 1175 | </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> |
1176 | 1191 | </refsect2> |
1177 | 1192 |
|
1178 | 1193 | <refsect2 id="SQL-TABLE"> |
|