1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-05 07:21:24 +03:00

Disallow scrolling of FOR UPDATE/FOR SHARE cursors, so as to avoid problems

in corner cases such as re-fetching a just-deleted row.  We may be able to
relax this someday, but let's find out how many people really care before
we invest a lot of work in it.  Per report from Heikki and subsequent
discussion.

While in the neighborhood, make the combination of INSENSITIVE and FOR UPDATE
throw an error, since they are semantically incompatible.  (Up to now we've
accepted but just ignored the INSENSITIVE option of DECLARE CURSOR.)
This commit is contained in:
Tom Lane
2007-10-24 23:27:08 +00:00
parent 8a35b07e18
commit 048efc25e4
7 changed files with 62 additions and 35 deletions

View File

@ -1,5 +1,5 @@
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/declare.sgml,v 1.41 2007/06/11 01:16:21 tgl Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/declare.sgml,v 1.42 2007/10/24 23:27:07 tgl Exp $
PostgreSQL documentation
-->
@ -172,7 +172,7 @@ DECLARE <replaceable class="parameter">name</replaceable> [ BINARY ] [ INSENSITI
transaction. Thus, <command>DECLARE</> without <literal>WITH
HOLD</literal> is useless outside a transaction block: the cursor would
survive only to the completion of the statement. Therefore
<productname>PostgreSQL</productname> reports an error if this
<productname>PostgreSQL</productname> reports an error if such a
command is used outside a transaction block.
Use
<xref linkend="sql-begin" endterm="sql-begin-title">,
@ -230,6 +230,11 @@ DECLARE <replaceable class="parameter">name</replaceable> [ BINARY ] [ INSENSITI
will have no effect if the row was changed meanwhile.
</para>
<para>
<literal>SCROLL</literal> may not be specified when the query
includes <literal>FOR UPDATE</> or <literal>FOR SHARE</>.
</para>
<para>
The SQL standard only makes provisions for cursors in embedded
<acronym>SQL</acronym>. The <productname>PostgreSQL</productname>
@ -265,10 +270,11 @@ DECLARE liahona CURSOR FOR SELECT * FROM films;
<title>Compatibility</title>
<para>
The SQL standard specifies that by default, cursors are sensitive to
concurrent updates of the underlying data. In
The SQL standard says that it is implementation-dependent whether cursors
are sensitive to concurrent updates of the underlying data by default. In
<productname>PostgreSQL</productname>, cursors are insensitive by default,
and can be made sensitive by specifying <literal>FOR UPDATE</>.
and can be made sensitive by specifying <literal>FOR UPDATE</>. Other
products may work differently.
</para>
<para>