| 2456 | } |
| 2457 | |
| 2458 | static Oid |
| 2459 | findRangeCanonicalFunction(List *procname, Oid typeOid) |
| 2460 | { |
| 2461 | Oid argList[1]; |
| 2462 | Oid procOid; |
| 2463 | AclResult aclresult; |
| 2464 | |
| 2465 | /* |
| 2466 | * Range canonical functions must take and return the range type, and must |
| 2467 | * be immutable. |
| 2468 | */ |
| 2469 | argList[0] = typeOid; |
| 2470 | |
| 2471 | procOid = LookupFuncName(procname, 1, argList, true); |
| 2472 | |
| 2473 | if (!OidIsValid(procOid)) |
| 2474 | ereport(ERROR, |
| 2475 | (errcode(ERRCODE_UNDEFINED_FUNCTION), |
| 2476 | errmsg("function %s does not exist", |
| 2477 | func_signature_string(procname, 1, NIL, argList)))); |
| 2478 | |
| 2479 | if (get_func_rettype(procOid) != typeOid) |
| 2480 | ereport(ERROR, |
| 2481 | (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), |
| 2482 | errmsg("range canonical function %s must return range type", |
| 2483 | func_signature_string(procname, 1, NIL, argList)))); |
| 2484 | |
| 2485 | if (func_volatile(procOid) != PROVOLATILE_IMMUTABLE) |
| 2486 | ereport(ERROR, |
| 2487 | (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), |
| 2488 | errmsg("range canonical function %s must be immutable", |
| 2489 | func_signature_string(procname, 1, NIL, argList)))); |
| 2490 | |
| 2491 | /* Also, range type's creator must have permission to call function */ |
| 2492 | aclresult = pg_proc_aclcheck(procOid, GetUserId(), ACL_EXECUTE); |
| 2493 | if (aclresult != ACLCHECK_OK) |
| 2494 | aclcheck_error(aclresult, OBJECT_FUNCTION, get_func_name(procOid)); |
| 2495 | |
| 2496 | return procOid; |
| 2497 | } |
| 2498 | |
| 2499 | static Oid |
| 2500 | findRangeSubtypeDiffFunction(List *procname, Oid subtype) |
no test coverage detected