On 16.04.2013 14:38, Simon Riggs wrote:
On 15 April 2013 21:53, Simon Riggs<si...@2ndquadrant.com> wrote:
So I'll treat this as two separate cases:
* add special case for sequences
Patch attached.
+ if (IsA(node, FuncExpr))
+ {
+ FuncExpr *expr = (FuncExpr *) node;
+
+ /*
+ * For this case only, we want to ignore the volatility of the
+ * nextval() function, since some callers want this. nextval()
+ * has no other args other than sequence name, so we can just
+ * return false immediately in this case.
+ */
+ if (expr->funcid == F_NEXTVAL_OID)
+ return false;
+ else if (func_volatile(expr->funcid) == PROVOLATILE_VOLATILE)
+ return true;
+ /* else fall through to check args */
+ } ...
You still need to check the args, if the function is nextval, otherwise
you incorrectly perform the optimization for something like
"nextval(myvolatilefunc())".
- Heikki
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers