1
0
mirror of https://github.com/postgres/postgres.git synced 2025-04-21 12:05:57 +03:00

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 bfb456c1.

Reported-by: Alexander Lakhin
Author: Alexander Lakhin, Michael Paquier
Discussion: https://postgr.es/m/3d068be5-f617-a5ee-99f6-458a407bfd65@gmail.com
Backpatch-through: 10
This commit is contained in:
Michael Paquier 2019-06-25 11:16:04 +09:00
parent 956611e4c4
commit 131e545ac3

View File

@ -1950,9 +1950,10 @@ LookupFuncName(List *funcname, int nargs, const Oid *argtypes, bool noError)
errmsg("function name \"%s\" is not unique", errmsg("function name \"%s\" is not unique",
NameListToString(funcname)), NameListToString(funcname)),
errhint("Specify the argument list to select the function unambiguously."))); errhint("Specify the argument list to select the function unambiguously.")));
return InvalidOid;
} }
else /* Otherwise return the match */
return clist->oid; return clist->oid;
} }
else else
{ {
@ -1961,9 +1962,14 @@ LookupFuncName(List *funcname, int nargs, const Oid *argtypes, bool noError)
(errcode(ERRCODE_UNDEFINED_FUNCTION), (errcode(ERRCODE_UNDEFINED_FUNCTION),
errmsg("could not find a function named \"%s\"", errmsg("could not find a function named \"%s\"",
NameListToString(funcname)))); NameListToString(funcname))));
return InvalidOid;
} }
} }
/*
* Otherwise, look for a match to the arg types. FuncnameGetCandidates
* has ensured that there's at most one match in the returned list.
*/
while (clist) while (clist)
{ {
if (memcmp(argtypes, clist->args, nargs * sizeof(Oid)) == 0) if (memcmp(argtypes, clist->args, nargs * sizeof(Oid)) == 0)