MCPcopy Create free account
hub / github.com/apache/cloudberry / LookupFuncWithArgs

Function LookupFuncWithArgs

src/backend/parser/parse_func.c:2260–2552  ·  view source on GitHub ↗

* LookupFuncWithArgs * * Like LookupFuncName, but the argument types are specified by an * ObjectWithArgs node. Also, this function can check whether the result is a * function, procedure, or aggregate, based on the objtype argument. Pass * OBJECT_ROUTINE to accept any of them. * * For historical reasons, we also accept aggregates when looking for a * function. * * When missing_ok is t

Source from the content-addressed store, hash-verified

2258 * of the value of missing_ok.
2259 */
2260Oid
2261LookupFuncWithArgs(ObjectType objtype, ObjectWithArgs *func, bool missing_ok)
2262{
2263 Oid argoids[FUNC_MAX_ARGS] = {InvalidOid,};
2264 int argcount;
2265 int nargs;
2266 int i;
2267 ListCell *args_item;
2268 Oid oid;
2269 FuncLookupError lookupError;
2270
2271 Assert(objtype == OBJECT_AGGREGATE ||
2272 objtype == OBJECT_FUNCTION ||
2273 objtype == OBJECT_PROCEDURE ||
2274 objtype == OBJECT_ROUTINE);
2275
2276 argcount = list_length(func->objargs);
2277 if (argcount > FUNC_MAX_ARGS)
2278 {
2279 if (objtype == OBJECT_PROCEDURE)
2280 ereport(ERROR,
2281 (errcode(ERRCODE_TOO_MANY_ARGUMENTS),
2282 errmsg_plural("procedures cannot have more than %d argument",
2283 "procedures cannot have more than %d arguments",
2284 FUNC_MAX_ARGS,
2285 FUNC_MAX_ARGS)));
2286 else
2287 ereport(ERROR,
2288 (errcode(ERRCODE_TOO_MANY_ARGUMENTS),
2289 errmsg_plural("functions cannot have more than %d argument",
2290 "functions cannot have more than %d arguments",
2291 FUNC_MAX_ARGS,
2292 FUNC_MAX_ARGS)));
2293 }
2294
2295 /*
2296 * First, perform a lookup considering only input arguments (traditional
2297 * Postgres rules).
2298 */
2299 i = 0;
2300 foreach(args_item, func->objargs)
2301 {
2302 TypeName *t = lfirst_node(TypeName, args_item);
2303
2304 argoids[i] = LookupTypeNameOid(NULL, t, missing_ok);
2305 if (!OidIsValid(argoids[i]))
2306 return InvalidOid; /* missing_ok must be true */
2307 i++;
2308 }
2309
2310 /*
2311 * Set nargs for LookupFuncNameInternal. It expects -1 to mean no args
2312 * were specified.
2313 */
2314 nargs = func->args_unspecified ? -1 : argcount;
2315
2316 /*
2317 * In args_unspecified mode, also tell LookupFuncNameInternal to consider

Callers 7

AlterFunctionFunction · 0.85
CreateCastFunction · 0.85
CreateTransformFunction · 0.85
DefineOpClassFunction · 0.85
AlterOpFamilyAddFunction · 0.85
objectNamesToOidsFunction · 0.85
get_object_addressFunction · 0.85

Calls 11

list_lengthFunction · 0.85
LookupTypeNameOidFunction · 0.85
LookupFuncNameInternalFunction · 0.85
get_func_prokindFunction · 0.85
func_signature_stringFunction · 0.85
NameListToStringFunction · 0.85
errcodeFunction · 0.50
errmsg_pluralFunction · 0.50
foreachFunction · 0.50
errmsgFunction · 0.50
errhintFunction · 0.50

Tested by

no test coverage detected