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

Function findTypeSubscriptingFunction

src/backend/commands/typecmds.c:2372–2409  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2370}
2371
2372static Oid
2373findTypeSubscriptingFunction(List *procname, Oid typeOid)
2374{
2375 Oid argList[1];
2376 Oid procOid;
2377
2378 /*
2379 * Subscripting support functions always take one INTERNAL argument and
2380 * return INTERNAL. (The argument is not used, but we must have it to
2381 * maintain type safety.)
2382 */
2383 argList[0] = INTERNALOID;
2384
2385 procOid = LookupFuncName(procname, 1, argList, true);
2386 if (!OidIsValid(procOid))
2387 ereport(ERROR,
2388 (errcode(ERRCODE_UNDEFINED_FUNCTION),
2389 errmsg("function %s does not exist",
2390 func_signature_string(procname, 1, NIL, argList))));
2391
2392 if (get_func_rettype(procOid) != INTERNALOID)
2393 ereport(ERROR,
2394 (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2395 errmsg("type subscripting function %s must return type %s",
2396 NameListToString(procname), "internal")));
2397
2398 /*
2399 * We disallow array_subscript_handler() from being selected explicitly,
2400 * since that must only be applied to autogenerated array types.
2401 */
2402 if (procOid == F_ARRAY_SUBSCRIPT_HANDLER)
2403 ereport(ERROR,
2404 (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2405 errmsg("user-defined types cannot use subscripting function %s",
2406 NameListToString(procname))));
2407
2408 return procOid;
2409}
2410
2411/*
2412 * Find suitable support functions and opclasses for a range type.

Callers 2

DefineTypeFunction · 0.85
AlterTypeFunction · 0.85

Calls 6

LookupFuncNameFunction · 0.85
func_signature_stringFunction · 0.85
get_func_rettypeFunction · 0.85
NameListToStringFunction · 0.85
errcodeFunction · 0.50
errmsgFunction · 0.50

Tested by

no test coverage detected