mirror of
https://github.com/postgres/postgres.git
synced 2025-06-30 21:42:05 +03:00
Have LookupFuncName accept NULL argtypes for 0 args
Prior to this change, it requires to be passed a valid pointer just to
be able to pass it to a zero-byte memcmp, per 0a52d378b0
. Given the
strange resulting code in callsites, it seems better to test for the
case specifically and remove the requirement.
Reported-by: Ranier Vilela
Discussion: https://postgr.es/m/MN2PR18MB2927F24692485D754794F01BE3740@MN2PR18MB2927.namprd18.prod.outlook.com
Discussion: https://postgr.es/m/MN2PR18MB2927F6873DF2774A505AC298E3740@MN2PR18MB2927.namprd18.prod.outlook.com
This commit is contained in:
@ -2035,8 +2035,8 @@ LookupFuncNameInternal(List *funcname, int nargs, const Oid *argtypes,
|
||||
{
|
||||
FuncCandidateList clist;
|
||||
|
||||
/* Passing NULL for argtypes is no longer allowed */
|
||||
Assert(argtypes);
|
||||
/* NULL argtypes allowed for nullary functions only */
|
||||
Assert(argtypes != NULL || nargs == 0);
|
||||
|
||||
/* Always set *lookupError, to forestall uninitialized-variable warnings */
|
||||
*lookupError = FUNCLOOKUP_NOSUCHFUNC;
|
||||
@ -2070,7 +2070,9 @@ LookupFuncNameInternal(List *funcname, int nargs, const Oid *argtypes,
|
||||
*/
|
||||
while (clist)
|
||||
{
|
||||
if (memcmp(argtypes, clist->args, nargs * sizeof(Oid)) == 0)
|
||||
/* if nargs==0, argtypes can be null; don't pass that to memcmp */
|
||||
if (nargs == 0 ||
|
||||
memcmp(argtypes, clist->args, nargs * sizeof(Oid)) == 0)
|
||||
return clist->oid;
|
||||
clist = clist->next;
|
||||
}
|
||||
|
Reference in New Issue
Block a user