| 2370 | } |
| 2371 | |
| 2372 | static Oid |
| 2373 | findTypeSubscriptingFunction(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. |
no test coverage detected