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

Commitdcb7d3c

Browse files
committed
Have LookupFuncName accept NULL argtypes for 0 args
Prior to this change, it requires to be passed a valid pointer just tobe able to pass it to a zero-byte memcmp, per0a52d37. Given thestrange resulting code in callsites, it seems better to test for thecase specifically and remove the requirement.Reported-by: Ranier VilelaDiscussion:https://postgr.es/m/MN2PR18MB2927F24692485D754794F01BE3740@MN2PR18MB2927.namprd18.prod.outlook.comDiscussion:https://postgr.es/m/MN2PR18MB2927F6873DF2774A505AC298E3740@MN2PR18MB2927.namprd18.prod.outlook.com
1 parent8c95168 commitdcb7d3c

File tree

6 files changed

+11
-13
lines changed

6 files changed

+11
-13
lines changed

‎src/backend/commands/event_trigger.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ CreateEventTrigger(CreateEventTrigStmt *stmt)
171171
HeapTupletuple;
172172
Oidfuncoid;
173173
Oidfuncrettype;
174-
Oidfargtypes[1];/* dummy */
175174
Oidevtowner=GetUserId();
176175
ListCell*lc;
177176
List*tags=NULL;
@@ -237,7 +236,7 @@ CreateEventTrigger(CreateEventTrigStmt *stmt)
237236
stmt->trigname)));
238237

239238
/* Find and validate the trigger function. */
240-
funcoid=LookupFuncName(stmt->funcname,0,fargtypes, false);
239+
funcoid=LookupFuncName(stmt->funcname,0,NULL, false);
241240
funcrettype=get_func_rettype(funcoid);
242241
if (funcrettype!=EVTTRIGGEROID)
243242
ereport(ERROR,

‎src/backend/commands/foreigncmds.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,13 +475,12 @@ static Oid
475475
lookup_fdw_handler_func(DefElem*handler)
476476
{
477477
OidhandlerOid;
478-
Oidfuncargtypes[1];/* dummy */
479478

480479
if (handler==NULL||handler->arg==NULL)
481480
returnInvalidOid;
482481

483482
/* handlers have no arguments */
484-
handlerOid=LookupFuncName((List*)handler->arg,0,funcargtypes, false);
483+
handlerOid=LookupFuncName((List*)handler->arg,0,NULL, false);
485484

486485
/* check that handler has correct return type */
487486
if (get_func_rettype(handlerOid)!=FDW_HANDLEROID)

‎src/backend/commands/proclang.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ CreateProceduralLanguage(CreatePLangStmt *stmt)
105105
* return type.
106106
*/
107107
funcname=SystemFuncName(pltemplate->tmplhandler);
108-
handlerOid=LookupFuncName(funcname,0,funcargtypes, true);
108+
handlerOid=LookupFuncName(funcname,0,NULL, true);
109109
if (OidIsValid(handlerOid))
110110
{
111111
funcrettype=get_func_rettype(handlerOid);
@@ -263,7 +263,7 @@ CreateProceduralLanguage(CreatePLangStmt *stmt)
263263
* Lookup the PL handler function and check that it is of the expected
264264
* return type
265265
*/
266-
handlerOid=LookupFuncName(stmt->plhandler,0,funcargtypes, false);
266+
handlerOid=LookupFuncName(stmt->plhandler,0,NULL, false);
267267
funcrettype=get_func_rettype(handlerOid);
268268
if (funcrettype!=LANGUAGE_HANDLEROID)
269269
{

‎src/backend/commands/trigger.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString,
179179
ScanKeyDatakey;
180180
Relationpgrel;
181181
HeapTupletuple;
182-
Oidfargtypes[1];/* dummy */
183182
Oidfuncrettype;
184183
Oidtrigoid;
185184
charinternaltrigname[NAMEDATALEN];
@@ -690,7 +689,7 @@ CreateTrigger(CreateTrigStmt *stmt, const char *queryString,
690689
* Find and validate the trigger function.
691690
*/
692691
if (!OidIsValid(funcoid))
693-
funcoid=LookupFuncName(stmt->funcname,0,fargtypes, false);
692+
funcoid=LookupFuncName(stmt->funcname,0,NULL, false);
694693
if (!isInternal)
695694
{
696695
aclresult=pg_proc_aclcheck(funcoid,GetUserId(),ACL_EXECUTE);

‎src/backend/parser/parse_func.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2035,8 +2035,8 @@ LookupFuncNameInternal(List *funcname, int nargs, const Oid *argtypes,
20352035
{
20362036
FuncCandidateListclist;
20372037

2038-
/*PassingNULLforargtypesis no longer allowed */
2039-
Assert(argtypes);
2038+
/* NULL argtypesallowed for nullary functions only */
2039+
Assert(argtypes!=NULL||nargs==0);
20402040

20412041
/* Always set *lookupError, to forestall uninitialized-variable warnings */
20422042
*lookupError=FUNCLOOKUP_NOSUCHFUNC;
@@ -2070,7 +2070,9 @@ LookupFuncNameInternal(List *funcname, int nargs, const Oid *argtypes,
20702070
*/
20712071
while (clist)
20722072
{
2073-
if (memcmp(argtypes,clist->args,nargs*sizeof(Oid))==0)
2073+
/* if nargs==0, argtypes can be null; don't pass that to memcmp */
2074+
if (nargs==0||
2075+
memcmp(argtypes,clist->args,nargs*sizeof(Oid))==0)
20742076
returnclist->oid;
20752077
clist=clist->next;
20762078
}

‎src/pl/tcl/pltcl.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,6 @@ call_pltcl_start_proc(Oid prolang, bool pltrusted)
592592
constchar*gucname;
593593
ErrorContextCallbackerrcallback;
594594
List*namelist;
595-
Oidfargtypes[1];/* dummy */
596595
OidprocOid;
597596
HeapTupleprocTup;
598597
Form_pg_procprocStruct;
@@ -616,7 +615,7 @@ call_pltcl_start_proc(Oid prolang, bool pltrusted)
616615

617616
/* Parse possibly-qualified identifier and look up the function */
618617
namelist=stringToQualifiedNameList(start_proc);
619-
procOid=LookupFuncName(namelist,0,fargtypes, false);
618+
procOid=LookupFuncName(namelist,0,NULL, false);
620619

621620
/* Current user must have permission to call function */
622621
aclresult=pg_proc_aclcheck(procOid,GetUserId(),ACL_EXECUTE);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp