diff --git a/src/backend/executor/nodeAgg.c b/src/backend/executor/nodeAgg.c index 5c20b8a45ab..cced591d02c 100644 --- a/src/backend/executor/nodeAgg.c +++ b/src/backend/executor/nodeAgg.c @@ -1495,6 +1495,7 @@ finalize_partialaggregate(AggState *aggstate, pergroupstate->transValueIsNull, pertrans->transtypeLen); fcinfo->argnull[0] = pergroupstate->transValueIsNull; + fcinfo->isnull = false; *resultVal = FunctionCallInvoke(fcinfo); *resultIsNull = fcinfo->isnull; diff --git a/src/include/fmgr.h b/src/include/fmgr.h index 0878418516e..71c3213503e 100644 --- a/src/include/fmgr.h +++ b/src/include/fmgr.h @@ -125,6 +125,11 @@ extern void fmgr_info_copy(FmgrInfo *dstinfo, FmgrInfo *srcinfo, * caller must still check fcinfo->isnull! Also, if function is strict, * it is caller's responsibility to verify that no null arguments are present * before calling. + * + * Some code performs multiple calls without redoing InitFunctionCallInfoData, + * possibly altering the argument values. This is okay, but be sure to reset + * the fcinfo->isnull flag before each call, since callees are permitted to + * assume that starts out false. */ #define FunctionCallInvoke(fcinfo) ((* (fcinfo)->flinfo->fn_addr) (fcinfo))