Add a warning about possible strange behavior of volatile functions
authorTom Lane
Wed, 10 Jun 2009 19:21:37 +0000 (19:21 +0000)
committerTom Lane
Wed, 10 Jun 2009 19:21:37 +0000 (19:21 +0000)
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.

doc/src/sgml/ref/declare.sgml

index 641971149ac93b387de7003d05c77b6c2ec23b2b..e93b4cf594df485a9ebaf6650919088705cf5f4f 100644 (file)
@@ -1,5 +1,5 @@
 
 
@@ -228,6 +228,20 @@ DECLARE name [ BINARY ] [ INSENSITI
     SCROLL may not be specified in this case.
    
 
+   
+    
+     Scrollable and WITH HOLD cursors may give unexpected
+     results if they invoke any volatile functions (see 
+     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 WITH HOLD 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.
+    
+   
+
    
     If the cursor's query includes FOR UPDATE or FOR
     SHARE, then returned rows are locked at the time they are first