Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4c0000b

Browse filesBrowse files
committed
Handle EEOP_FUNCEXPR_[STRICT_]FUSAGE out of line.
This isn't a very common op, and it doesn't seem worth duplicating for JIT. Author: Andres Freund
1 parent 5b2526c commit 4c0000b
Copy full SHA for 4c0000b

File tree

Expand file treeCollapse file tree

2 files changed

+63
-37
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+63
-37
lines changed

‎src/backend/executor/execExprInterp.c

Copy file name to clipboardExpand all lines: src/backend/executor/execExprInterp.c
+59-37Lines changed: 59 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -685,50 +685,17 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
685685

686686
EEO_CASE(EEOP_FUNCEXPR_FUSAGE)
687687
{
688-
FunctionCallInfo fcinfo = op->d.func.fcinfo_data;
689-
PgStat_FunctionCallUsage fcusage;
690-
Datum d;
691-
692-
pgstat_init_function_usage(fcinfo, &fcusage);
693-
694-
fcinfo->isnull = false;
695-
d = op->d.func.fn_addr(fcinfo);
696-
*op->resvalue = d;
697-
*op->resnull = fcinfo->isnull;
698-
699-
pgstat_end_function_usage(&fcusage, true);
688+
/* not common enough to inline */
689+
ExecEvalFuncExprFusage(state, op, econtext);
700690

701691
EEO_NEXT();
702692
}
703693

704694
EEO_CASE(EEOP_FUNCEXPR_STRICT_FUSAGE)
705695
{
706-
FunctionCallInfo fcinfo = op->d.func.fcinfo_data;
707-
PgStat_FunctionCallUsage fcusage;
708-
bool *argnull = fcinfo->argnull;
709-
int argno;
710-
Datum d;
696+
/* not common enough to inline */
697+
ExecEvalFuncExprStrictFusage(state, op, econtext);
711698

712-
/* strict function, so check for NULL args */
713-
for (argno = 0; argno < op->d.func.nargs; argno++)
714-
{
715-
if (argnull[argno])
716-
{
717-
*op->resnull = true;
718-
goto strictfail_fusage;
719-
}
720-
}
721-
722-
pgstat_init_function_usage(fcinfo, &fcusage);
723-
724-
fcinfo->isnull = false;
725-
d = op->d.func.fn_addr(fcinfo);
726-
*op->resvalue = d;
727-
*op->resnull = fcinfo->isnull;
728-
729-
pgstat_end_function_usage(&fcusage, true);
730-
731-
strictfail_fusage:
732699
EEO_NEXT();
733700
}
734701

@@ -2207,6 +2174,61 @@ ExecEvalStepOp(ExprState *state, ExprEvalStep *op)
22072174
* Out-of-line helper functions for complex instructions.
22082175
*/
22092176

2177+
/*
2178+
* Evaluate EEOP_FUNCEXPR_FUSAGE
2179+
*/
2180+
void
2181+
ExecEvalFuncExprFusage(ExprState *state, ExprEvalStep *op,
2182+
ExprContext *econtext)
2183+
{
2184+
FunctionCallInfo fcinfo = op->d.func.fcinfo_data;
2185+
PgStat_FunctionCallUsage fcusage;
2186+
Datum d;
2187+
2188+
pgstat_init_function_usage(fcinfo, &fcusage);
2189+
2190+
fcinfo->isnull = false;
2191+
d = op->d.func.fn_addr(fcinfo);
2192+
*op->resvalue = d;
2193+
*op->resnull = fcinfo->isnull;
2194+
2195+
pgstat_end_function_usage(&fcusage, true);
2196+
}
2197+
2198+
/*
2199+
* Evaluate EEOP_FUNCEXPR_STRICT_FUSAGE
2200+
*/
2201+
void
2202+
ExecEvalFuncExprStrictFusage(ExprState *state, ExprEvalStep *op,
2203+
ExprContext *econtext)
2204+
{
2205+
2206+
FunctionCallInfo fcinfo = op->d.func.fcinfo_data;
2207+
PgStat_FunctionCallUsage fcusage;
2208+
bool *argnull = fcinfo->argnull;
2209+
int argno;
2210+
Datum d;
2211+
2212+
/* strict function, so check for NULL args */
2213+
for (argno = 0; argno < op->d.func.nargs; argno++)
2214+
{
2215+
if (argnull[argno])
2216+
{
2217+
*op->resnull = true;
2218+
return;
2219+
}
2220+
}
2221+
2222+
pgstat_init_function_usage(fcinfo, &fcusage);
2223+
2224+
fcinfo->isnull = false;
2225+
d = op->d.func.fn_addr(fcinfo);
2226+
*op->resvalue = d;
2227+
*op->resnull = fcinfo->isnull;
2228+
2229+
pgstat_end_function_usage(&fcusage, true);
2230+
}
2231+
22102232
/*
22112233
* Evaluate a PARAM_EXEC parameter.
22122234
*

‎src/include/executor/execExpr.h

Copy file name to clipboardExpand all lines: src/include/executor/execExpr.h
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,10 @@ extern void CheckExprStillValid(ExprState *state, ExprContext *econtext);
690690
* execExprInterp.c, because that allows them to be used by other methods of
691691
* expression evaluation, reducing code duplication.
692692
*/
693+
extern void ExecEvalFuncExprFusage(ExprState *state, ExprEvalStep *op,
694+
ExprContext *econtext);
695+
extern void ExecEvalFuncExprStrictFusage(ExprState *state, ExprEvalStep *op,
696+
ExprContext *econtext);
693697
extern void ExecEvalParamExec(ExprState *state, ExprEvalStep *op,
694698
ExprContext *econtext);
695699
extern void ExecEvalParamExecParams(Bitmapset *params, EState *estate);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.