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

Commit6ab98db

Browse files
committed
Fix minor violations of FunctionCallInvoke usage protocol.
Working on commit1c45507 led me to check through FunctionCallInvokecall sites to see if every one was being honest about (a) making surethat fcinfo.isnull is initially false, and (b) checking its state afterthe call. Sure enough, I found some violations.The main one is that finalize_partialaggregate re-used serialfn_fcinfowithout resetting isnull, even though it clearly intends to cater forserialfns that return NULL. There would only be an issue with anon-strict serialfn, since it's unlikely that a serialfn would returnNULL for non-null input. We have no non-strict serialfns in core, andthere may be none in the wild either, which would account for the lackof complaints. Still, it's clearly wrong, so back-patch that fix to9.6 where finalize_partialaggregate was introduced.Also, arrayfuncs.c and rowtypes.c contained various callers that werenot bothering to check for result nulls. While what's being called isa comparison or hash function that probably *shouldn't* return null,that's a lousy excuse for not having any check at all. There areexisting places that just Assert(!fcinfo->isnull) in comparablesituations, so I added that to the places that were calling btreecomparison or hash support functions. In the places callingboolean-returning equality functions, it's quite cheap to have themtreat isnull as FALSE, so make those places do that. Also remove some"locfcinfo->isnull = false" assignments that are unnecessary given theassumption that no previous call returned null. These changes seem likemostly neatnik-ism or debugging support, so I didn't back-patch.
1 parent0b83c47 commit6ab98db

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

‎src/backend/executor/nodeAgg.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,6 +1014,7 @@ finalize_partialaggregate(AggState *aggstate,
10141014
pergroupstate->transValueIsNull,
10151015
pertrans->transtypeLen);
10161016
fcinfo->argnull[0]=pergroupstate->transValueIsNull;
1017+
fcinfo->isnull= false;
10171018

10181019
*resultVal=FunctionCallInvoke(fcinfo);
10191020
*resultIsNull=fcinfo->isnull;

‎src/include/fmgr.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,11 @@ extern void fmgr_symbol(Oid functionId, char **mod, char **fn);
138138
* caller must still check fcinfo->isnull!Also, if function is strict,
139139
* it is caller's responsibility to verify that no null arguments are present
140140
* before calling.
141+
*
142+
* Some code performs multiple calls without redoing InitFunctionCallInfoData,
143+
* possibly altering the argument values. This is okay, but be sure to reset
144+
* the fcinfo->isnull flag before each call, since callees are permitted to
145+
* assume that starts out false.
141146
*/
142147
#defineFunctionCallInvoke(fcinfo)((* (fcinfo)->flinfo->fn_addr) (fcinfo))
143148

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp