Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitbd9b4a9

Browse files
committed
Use InitFunctionCallInfoData() macro instead of MemSet in performance
critical places in execQual. By Atsushi Ogawa; some minor cleanup by moi.
1 parent94e0333 commitbd9b4a9

File tree

5 files changed

+61
-84
lines changed

5 files changed

+61
-84
lines changed

‎src/backend/executor/execQual.c

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.173 2005/03/16 21:38:06 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/executor/execQual.c,v 1.174 2005/03/22 20:13:06 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -832,8 +832,7 @@ ExecMakeFunctionResult(FuncExprState *fcache,
832832
if (!fcache->setArgsValid)
833833
{
834834
/* Need to prep callinfo structure */
835-
MemSet(&fcinfo,0,sizeof(fcinfo));
836-
fcinfo.flinfo=&(fcache->func);
835+
InitFunctionCallInfoData(fcinfo,&(fcache->func),0,NULL,NULL);
837836
argDone=ExecEvalFuncArgs(&fcinfo,arguments,econtext);
838837
if (argDone==ExprEndResult)
839838
{
@@ -1046,9 +1045,6 @@ ExecMakeFunctionResultNoSets(FuncExprState *fcache,
10461045
if (isDone)
10471046
*isDone=ExprSingleResult;
10481047

1049-
MemSet(&fcinfo,0,sizeof(fcinfo));
1050-
fcinfo.flinfo=&(fcache->func);
1051-
10521048
/* inlined, simplified version of ExecEvalFuncArgs */
10531049
i=0;
10541050
foreach(arg,fcache->args)
@@ -1067,7 +1063,8 @@ ExecMakeFunctionResultNoSets(FuncExprState *fcache,
10671063
errmsg("set-valued function called in context that cannot accept a set")));
10681064
i++;
10691065
}
1070-
fcinfo.nargs=i;
1066+
1067+
InitFunctionCallInfoData(fcinfo,&(fcache->func),i,NULL,NULL);
10711068

10721069
/*
10731070
* If function is strict, and there are any NULL arguments, skip
@@ -1084,7 +1081,7 @@ ExecMakeFunctionResultNoSets(FuncExprState *fcache,
10841081
}
10851082
}
10861083
}
1087-
/* fcinfo.isnull = false; *//* handled byMemSet */
1084+
/* fcinfo.isnull = false; *//* handled byInitFunctionCallInfoData */
10881085
result=FunctionCallInvoke(&fcinfo);
10891086
*isNull=fcinfo.isnull;
10901087

@@ -1132,8 +1129,7 @@ ExecMakeTableFunctionResult(ExprState *funcexpr,
11321129
* doesn't actually get to see the resultinfo, but set it up anyway
11331130
* because we use some of the fields as our own state variables.
11341131
*/
1135-
MemSet(&fcinfo,0,sizeof(fcinfo));
1136-
fcinfo.resultinfo= (Node*)&rsinfo;
1132+
InitFunctionCallInfoData(fcinfo,NULL,0,NULL, (Node*)&rsinfo);
11371133
rsinfo.type=T_ReturnSetInfo;
11381134
rsinfo.econtext=econtext;
11391135
rsinfo.expectedDesc=expectedDesc;
@@ -1499,8 +1495,7 @@ ExecEvalDistinct(FuncExprState *fcache,
14991495
argList=fcache->args;
15001496

15011497
/* Need to prep callinfo structure */
1502-
MemSet(&fcinfo,0,sizeof(fcinfo));
1503-
fcinfo.flinfo=&(fcache->func);
1498+
InitFunctionCallInfoData(fcinfo,&(fcache->func),0,NULL,NULL);
15041499
argDone=ExecEvalFuncArgs(&fcinfo,argList,econtext);
15051500
if (argDone!=ExprSingleResult)
15061501
ereport(ERROR,
@@ -1573,8 +1568,7 @@ ExecEvalScalarArrayOp(ScalarArrayOpExprState *sstate,
15731568
}
15741569

15751570
/* Need to prep callinfo structure */
1576-
MemSet(&fcinfo,0,sizeof(fcinfo));
1577-
fcinfo.flinfo=&(sstate->fxprstate.func);
1571+
InitFunctionCallInfoData(fcinfo,&(sstate->fxprstate.func),0,NULL,NULL);
15781572
argDone=ExecEvalFuncArgs(&fcinfo,sstate->fxprstate.args,econtext);
15791573
if (argDone!=ExprSingleResult)
15801574
ereport(ERROR,
@@ -2287,8 +2281,7 @@ ExecEvalNullIf(FuncExprState *nullIfExpr,
22872281
argList=nullIfExpr->args;
22882282

22892283
/* Need to prep callinfo structure */
2290-
MemSet(&fcinfo,0,sizeof(fcinfo));
2291-
fcinfo.flinfo=&(nullIfExpr->func);
2284+
InitFunctionCallInfoData(fcinfo,&(nullIfExpr->func),0,NULL,NULL);
22922285
argDone=ExecEvalFuncArgs(&fcinfo,argList,econtext);
22932286
if (argDone!=ExprSingleResult)
22942287
ereport(ERROR,

‎src/backend/executor/nodeAgg.c

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
* Portions Copyright (c) 1994, Regents of the University of California
6262
*
6363
* IDENTIFICATION
64-
* $PostgreSQL: pgsql/src/backend/executor/nodeAgg.c,v 1.130 2005/03/16 21:38:07 tgl Exp $
64+
* $PostgreSQL: pgsql/src/backend/executor/nodeAgg.c,v 1.131 2005/03/22 20:13:06 tgl Exp $
6565
*
6666
*-------------------------------------------------------------------------
6767
*/
@@ -373,18 +373,9 @@ advance_transition_function(AggState *aggstate,
373373

374374
/*
375375
* OK to call the transition function
376-
*
377-
* This is heavily-used code, so manually zero just the necessary fields
378-
* instead of using MemSet(). Compare FunctionCall2().
379376
*/
380-
381-
/* MemSet(&fcinfo, 0, sizeof(fcinfo)); */
382-
fcinfo.context= (void*)aggstate;
383-
fcinfo.resultinfo=NULL;
384-
fcinfo.isnull= false;
385-
386-
fcinfo.flinfo=&peraggstate->transfn;
387-
fcinfo.nargs=2;
377+
InitFunctionCallInfoData(fcinfo,&(peraggstate->transfn),2,
378+
(void*)aggstate,NULL);
388379
fcinfo.arg[0]=pergroupstate->transValue;
389380
fcinfo.argnull[0]=pergroupstate->transValueIsNull;
390381
fcinfo.arg[1]=newVal;
@@ -556,10 +547,8 @@ finalize_aggregate(AggState *aggstate,
556547
{
557548
FunctionCallInfoDatafcinfo;
558549

559-
MemSet(&fcinfo,0,sizeof(fcinfo));
560-
fcinfo.context= (void*)aggstate;
561-
fcinfo.flinfo=&peraggstate->finalfn;
562-
fcinfo.nargs=1;
550+
InitFunctionCallInfoData(fcinfo,&(peraggstate->finalfn),1,
551+
(void*)aggstate,NULL);
563552
fcinfo.arg[0]=pergroupstate->transValue;
564553
fcinfo.argnull[0]=pergroupstate->transValueIsNull;
565554
if (fcinfo.flinfo->fn_strict&&pergroupstate->transValueIsNull)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp