summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2009-06-10 19:21:37 +0000
committerTom Lane2009-06-10 19:21:37 +0000
commit2341c6c3a4093fb35f71cdb59b7f15027001946e (patch)
treea93c5eb62ee435578739cbb5109fa21eb3038d89
parent51ec830b663b4b8466bbc4bdf2511cd7dc3de35b (diff)
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.
-rw-r--r--doc/src/sgml/ref/declare.sgml14
1 files changed, 14 insertions, 0 deletions
diff --git a/doc/src/sgml/ref/declare.sgml b/doc/src/sgml/ref/declare.sgml
index 96e1f7d272..b7451bfb40 100644
--- a/doc/src/sgml/ref/declare.sgml
+++ b/doc/src/sgml/ref/declare.sgml
@@ -228,6 +228,20 @@ DECLARE <replaceable class="parameter">name</replaceable> [ BINARY ] [ INSENSITI
<literal>SCROLL</literal> may not be specified in this case.
</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>
If the cursor's query includes <literal>FOR UPDATE</> or <literal>FOR
SHARE</>, then returned rows are locked at the time they are first