Handle EEOP_FUNCEXPR_[STRICT_]FUSAGE out of line.
authorAndres Freund <andres@anarazel.de>
Wed, 21 Mar 2018 00:32:21 +0000 (17:32 -0700)
committerAndres Freund <andres@anarazel.de>
Wed, 21 Mar 2018 00:32:21 +0000 (17:32 -0700)
This isn't a very common op, and it doesn't seem worth duplicating for
JIT.

Author: Andres Freund

src/backend/executor/execExprInterp.c
src/include/executor/execExpr.h

index 771b7e3945cae31c8788f61d92e2f3f7c559ec32..f7bcf6370b5e194ba84e28daebb4bed52e741ceb 100644 (file)
@@ -685,50 +685,17 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
 
                EEO_CASE(EEOP_FUNCEXPR_FUSAGE)
                {
-                       FunctionCallInfo fcinfo = op->d.func.fcinfo_data;
-                       PgStat_FunctionCallUsage fcusage;
-                       Datum           d;
-
-                       pgstat_init_function_usage(fcinfo, &fcusage);
-
-                       fcinfo->isnull = false;
-                       d = op->d.func.fn_addr(fcinfo);
-                       *op->resvalue = d;
-                       *op->resnull = fcinfo->isnull;
-
-                       pgstat_end_function_usage(&fcusage, true);
+                       /* not common enough to inline */
+                       ExecEvalFuncExprFusage(state, op, econtext);
 
                        EEO_NEXT();
                }
 
                EEO_CASE(EEOP_FUNCEXPR_STRICT_FUSAGE)
                {
-                       FunctionCallInfo fcinfo = op->d.func.fcinfo_data;
-                       PgStat_FunctionCallUsage fcusage;
-                       bool       *argnull = fcinfo->argnull;
-                       int                     argno;
-                       Datum           d;
+                       /* not common enough to inline */
+                       ExecEvalFuncExprStrictFusage(state, op, econtext);
 
-                       /* strict function, so check for NULL args */
-                       for (argno = 0; argno < op->d.func.nargs; argno++)
-                       {
-                               if (argnull[argno])
-                               {
-                                       *op->resnull = true;
-                                       goto strictfail_fusage;
-                               }
-                       }
-
-                       pgstat_init_function_usage(fcinfo, &fcusage);
-
-                       fcinfo->isnull = false;
-                       d = op->d.func.fn_addr(fcinfo);
-                       *op->resvalue = d;
-                       *op->resnull = fcinfo->isnull;
-
-                       pgstat_end_function_usage(&fcusage, true);
-
-       strictfail_fusage:
                        EEO_NEXT();
                }
 
@@ -2207,6 +2174,61 @@ ExecEvalStepOp(ExprState *state, ExprEvalStep *op)
  * Out-of-line helper functions for complex instructions.
  */
 
+/*
+ * Evaluate EEOP_FUNCEXPR_FUSAGE
+ */
+void
+ExecEvalFuncExprFusage(ExprState *state, ExprEvalStep *op,
+                                          ExprContext *econtext)
+{
+       FunctionCallInfo fcinfo = op->d.func.fcinfo_data;
+       PgStat_FunctionCallUsage fcusage;
+       Datum           d;
+
+       pgstat_init_function_usage(fcinfo, &fcusage);
+
+       fcinfo->isnull = false;
+       d = op->d.func.fn_addr(fcinfo);
+       *op->resvalue = d;
+       *op->resnull = fcinfo->isnull;
+
+       pgstat_end_function_usage(&fcusage, true);
+}
+
+/*
+ * Evaluate EEOP_FUNCEXPR_STRICT_FUSAGE
+ */
+void
+ExecEvalFuncExprStrictFusage(ExprState *state, ExprEvalStep *op,
+                                 ExprContext *econtext)
+{
+
+       FunctionCallInfo fcinfo = op->d.func.fcinfo_data;
+       PgStat_FunctionCallUsage fcusage;
+       bool       *argnull = fcinfo->argnull;
+       int                     argno;
+       Datum           d;
+
+       /* strict function, so check for NULL args */
+       for (argno = 0; argno < op->d.func.nargs; argno++)
+       {
+               if (argnull[argno])
+               {
+                       *op->resnull = true;
+                       return;
+               }
+       }
+
+       pgstat_init_function_usage(fcinfo, &fcusage);
+
+       fcinfo->isnull = false;
+       d = op->d.func.fn_addr(fcinfo);
+       *op->resvalue = d;
+       *op->resnull = fcinfo->isnull;
+
+       pgstat_end_function_usage(&fcusage, true);
+}
+
 /*
  * Evaluate a PARAM_EXEC parameter.
  *
index 0cab431f656d8c271249678c173dc33a3058d3a5..6fc4ed640b234aff2c4524f3bb65b377b749564f 100644 (file)
@@ -690,6 +690,10 @@ extern void CheckExprStillValid(ExprState *state, ExprContext *econtext);
  * execExprInterp.c, because that allows them to be used by other methods of
  * expression evaluation, reducing code duplication.
  */
+extern void ExecEvalFuncExprFusage(ExprState *state, ExprEvalStep *op,
+                                 ExprContext *econtext);
+extern void ExecEvalFuncExprStrictFusage(ExprState *state, ExprEvalStep *op,
+                                 ExprContext *econtext);
 extern void ExecEvalParamExec(ExprState *state, ExprEvalStep *op,
                                  ExprContext *econtext);
 extern void ExecEvalParamExecParams(Bitmapset *params, EState *estate);