]> granicus.if.org Git - postgresql/commitdiff
Save one syscache lookup when examining volatility or strictness of
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 22 Nov 2007 19:09:23 +0000 (19:09 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 22 Nov 2007 19:09:23 +0000 (19:09 +0000)
OpExpr and related nodes.  We're going to have to set the opfuncid of
such nodes eventually (if we haven't already), so we might as well
exploit the opportunity to cache the function OID.  Buys back some
of the extra planner overhead noted by Guillaume Smet, though I still
need to fool with equivclass.c to really respond to that.

src/backend/optimizer/util/clauses.c

index 5b0ca6deec593fbc923e11e3a5d96a5cb4704d0d..71a5783104b6c43017915701e899bdd2be65d27f 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/optimizer/util/clauses.c,v 1.251 2007/11/15 21:14:36 momjian Exp $
+ *       $PostgreSQL: pgsql/src/backend/optimizer/util/clauses.c,v 1.252 2007/11/22 19:09:23 tgl Exp $
  *
  * HISTORY
  *       AUTHOR                        DATE                    MAJOR EVENT
@@ -715,7 +715,8 @@ contain_mutable_functions_walker(Node *node, void *context)
        {
                OpExpr     *expr = (OpExpr *) node;
 
-               if (op_volatile(expr->opno) != PROVOLATILE_IMMUTABLE)
+               set_opfuncid(expr);
+               if (func_volatile(expr->opfuncid) != PROVOLATILE_IMMUTABLE)
                        return true;
                /* else fall through to check args */
        }
@@ -723,7 +724,8 @@ contain_mutable_functions_walker(Node *node, void *context)
        {
                DistinctExpr *expr = (DistinctExpr *) node;
 
-               if (op_volatile(expr->opno) != PROVOLATILE_IMMUTABLE)
+               set_opfuncid((OpExpr *) expr);  /* rely on struct equivalence */
+               if (func_volatile(expr->opfuncid) != PROVOLATILE_IMMUTABLE)
                        return true;
                /* else fall through to check args */
        }
@@ -731,7 +733,8 @@ contain_mutable_functions_walker(Node *node, void *context)
        {
                ScalarArrayOpExpr *expr = (ScalarArrayOpExpr *) node;
 
-               if (op_volatile(expr->opno) != PROVOLATILE_IMMUTABLE)
+               set_sa_opfuncid(expr);
+               if (func_volatile(expr->opfuncid) != PROVOLATILE_IMMUTABLE)
                        return true;
                /* else fall through to check args */
        }
@@ -767,7 +770,8 @@ contain_mutable_functions_walker(Node *node, void *context)
        {
                NullIfExpr *expr = (NullIfExpr *) node;
 
-               if (op_volatile(expr->opno) != PROVOLATILE_IMMUTABLE)
+               set_opfuncid((OpExpr *) expr);  /* rely on struct equivalence */
+               if (func_volatile(expr->opfuncid) != PROVOLATILE_IMMUTABLE)
                        return true;
                /* else fall through to check args */
        }
@@ -826,7 +830,8 @@ contain_volatile_functions_walker(Node *node, void *context)
        {
                OpExpr     *expr = (OpExpr *) node;
 
-               if (op_volatile(expr->opno) == PROVOLATILE_VOLATILE)
+               set_opfuncid(expr);
+               if (func_volatile(expr->opfuncid) == PROVOLATILE_VOLATILE)
                        return true;
                /* else fall through to check args */
        }
@@ -834,7 +839,8 @@ contain_volatile_functions_walker(Node *node, void *context)
        {
                DistinctExpr *expr = (DistinctExpr *) node;
 
-               if (op_volatile(expr->opno) == PROVOLATILE_VOLATILE)
+               set_opfuncid((OpExpr *) expr);  /* rely on struct equivalence */
+               if (func_volatile(expr->opfuncid) == PROVOLATILE_VOLATILE)
                        return true;
                /* else fall through to check args */
        }
@@ -842,7 +848,8 @@ contain_volatile_functions_walker(Node *node, void *context)
        {
                ScalarArrayOpExpr *expr = (ScalarArrayOpExpr *) node;
 
-               if (op_volatile(expr->opno) == PROVOLATILE_VOLATILE)
+               set_sa_opfuncid(expr);
+               if (func_volatile(expr->opfuncid) == PROVOLATILE_VOLATILE)
                        return true;
                /* else fall through to check args */
        }
@@ -878,7 +885,8 @@ contain_volatile_functions_walker(Node *node, void *context)
        {
                NullIfExpr *expr = (NullIfExpr *) node;
 
-               if (op_volatile(expr->opno) == PROVOLATILE_VOLATILE)
+               set_opfuncid((OpExpr *) expr);  /* rely on struct equivalence */
+               if (func_volatile(expr->opfuncid) == PROVOLATILE_VOLATILE)
                        return true;
                /* else fall through to check args */
        }
@@ -951,7 +959,8 @@ contain_nonstrict_functions_walker(Node *node, void *context)
        {
                OpExpr     *expr = (OpExpr *) node;
 
-               if (!op_strict(expr->opno))
+               set_opfuncid(expr);
+               if (!func_strict(expr->opfuncid))
                        return true;
                /* else fall through to check args */
        }
@@ -1091,7 +1100,8 @@ find_nonnullable_rels_walker(Node *node, bool top_level)
        {
                OpExpr     *expr = (OpExpr *) node;
 
-               if (op_strict(expr->opno))
+               set_opfuncid(expr);
+               if (func_strict(expr->opfuncid))
                        result = find_nonnullable_rels_walker((Node *) expr->args, false);
        }
        else if (IsA(node, ScalarArrayOpExpr))
@@ -1228,7 +1238,8 @@ is_strict_saop(ScalarArrayOpExpr *expr, bool falseOK)
        Node       *rightop;
 
        /* The contained operator must be strict. */
-       if (!op_strict(expr->opno))
+       set_sa_opfuncid(expr);
+       if (!func_strict(expr->opfuncid))
                return false;
        /* If ANY and falseOK, that's all we need to check. */
        if (expr->useOr && falseOK)