Skip to content

Commit 131e545

Browse files
committed
Fix thinkos in LookupFuncName() for function name lookups
This could trigger valgrind failures when doing ambiguous function name lookups when no arguments are provided by the caller. The problem has been introduced in aefeb68, so backpatch to v10. HEAD is fine thanks to the refactoring done in bfb456c. Reported-by: Alexander Lakhin Author: Alexander Lakhin, Michael Paquier Discussion: https://postgr.es/m/3d068be5-f617-a5ee-99f6-458a407bfd65@gmail.com Backpatch-through: 10
1 parent 956611e commit 131e545

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/backend/parser/parse_func.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1950,9 +1950,10 @@ LookupFuncName(List *funcname, int nargs, const Oid *argtypes, bool noError)
19501950
errmsg("function name \"%s\" is not unique",
19511951
NameListToString(funcname)),
19521952
errhint("Specify the argument list to select the function unambiguously.")));
1953+
return InvalidOid;
19531954
}
1954-
else
1955-
return clist->oid;
1955+
/* Otherwise return the match */
1956+
return clist->oid;
19561957
}
19571958
else
19581959
{
@@ -1961,9 +1962,14 @@ LookupFuncName(List *funcname, int nargs, const Oid *argtypes, bool noError)
19611962
(errcode(ERRCODE_UNDEFINED_FUNCTION),
19621963
errmsg("could not find a function named \"%s\"",
19631964
NameListToString(funcname))));
1965+
return InvalidOid;
19641966
}
19651967
}
19661968

1969+
/*
1970+
* Otherwise, look for a match to the arg types. FuncnameGetCandidates
1971+
* has ensured that there's at most one match in the returned list.
1972+
*/
19671973
while (clist)
19681974
{
19691975
if (memcmp(argtypes, clist->args, nargs * sizeof(Oid)) == 0)

0 commit comments

Comments
 (0)