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

Function findRangeSubtypeDiffFunction

src/backend/commands/typecmds.c:2499–2540  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2497}
2498
2499static Oid
2500findRangeSubtypeDiffFunction(List *procname, Oid subtype)
2501{
2502 Oid argList[2];
2503 Oid procOid;
2504 AclResult aclresult;
2505
2506 /*
2507 * Range subtype diff functions must take two arguments of the subtype,
2508 * must return float8, and must be immutable.
2509 */
2510 argList[0] = subtype;
2511 argList[1] = subtype;
2512
2513 procOid = LookupFuncName(procname, 2, argList, true);
2514
2515 if (!OidIsValid(procOid))
2516 ereport(ERROR,
2517 (errcode(ERRCODE_UNDEFINED_FUNCTION),
2518 errmsg("function %s does not exist",
2519 func_signature_string(procname, 2, NIL, argList))));
2520
2521 if (get_func_rettype(procOid) != FLOAT8OID)
2522 ereport(ERROR,
2523 (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2524 errmsg("range subtype diff function %s must return type %s",
2525 func_signature_string(procname, 2, NIL, argList),
2526 "double precision")));
2527
2528 if (func_volatile(procOid) != PROVOLATILE_IMMUTABLE)
2529 ereport(ERROR,
2530 (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
2531 errmsg("range subtype diff function %s must be immutable",
2532 func_signature_string(procname, 2, NIL, argList))));
2533
2534 /* Also, range type's creator must have permission to call function */
2535 aclresult = pg_proc_aclcheck(procOid, GetUserId(), ACL_EXECUTE);
2536 if (aclresult != ACLCHECK_OK)
2537 aclcheck_error(aclresult, OBJECT_FUNCTION, get_func_name(procOid));
2538
2539 return procOid;
2540}
2541
2542/*
2543 * AssignTypeArrayOid

Callers 1

DefineRangeFunction · 0.85

Calls 10

LookupFuncNameFunction · 0.85
func_signature_stringFunction · 0.85
get_func_rettypeFunction · 0.85
func_volatileFunction · 0.85
pg_proc_aclcheckFunction · 0.85
GetUserIdFunction · 0.85
aclcheck_errorFunction · 0.85
get_func_nameFunction · 0.85
errcodeFunction · 0.50
errmsgFunction · 0.50

Tested by

no test coverage detected