Commit 661b3e79 authored by Tom Lane's avatar Tom Lane

Add a warning about possible strange behavior of volatile functions

in cursors.  This has always been the case, but given the lack of user
complaints about it, I'm not going to bother back-patching this.
parent 61dd4185
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/ref/declare.sgml,v 1.46 2009/04/10 17:56:21 tgl Exp $ $PostgreSQL: pgsql/doc/src/sgml/ref/declare.sgml,v 1.47 2009/06/10 19:21:37 tgl Exp $
PostgreSQL documentation PostgreSQL documentation
--> -->
...@@ -228,6 +228,20 @@ DECLARE <replaceable class="parameter">name</replaceable> [ BINARY ] [ INSENSITI ...@@ -228,6 +228,20 @@ DECLARE <replaceable class="parameter">name</replaceable> [ BINARY ] [ INSENSITI
<literal>SCROLL</literal> may not be specified in this case. <literal>SCROLL</literal> may not be specified in this case.
</para> </para>
<caution>
<para>
Scrollable and <literal>WITH HOLD</literal> cursors may give unexpected
results if they invoke any volatile functions (see <xref
linkend="xfunc-volatility">). When a previously fetched row is
re-fetched, the functions might be re-executed, perhaps leading to
results different from the first time. One workaround for such cases
is to declare the cursor <literal>WITH HOLD</literal> and commit the
transaction before reading any rows from it. This will force the
entire output of the cursor to be materialized in temporary storage,
so that volatile functions are executed exactly once for each row.
</para>
</caution>
<para> <para>
If the cursor's query includes <literal>FOR UPDATE</> or <literal>FOR If the cursor's query includes <literal>FOR UPDATE</> or <literal>FOR
SHARE</>, then returned rows are locked at the time they are first SHARE</>, then returned rows are locked at the time they are first
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment