| 871 | } |
| 872 | |
| 873 | static Oid |
| 874 | interpret_func_support(DefElem *defel) |
| 875 | { |
| 876 | List *procName = defGetQualifiedName(defel); |
| 877 | Oid procOid; |
| 878 | Oid argList[1]; |
| 879 | |
| 880 | /* |
| 881 | * Support functions always take one INTERNAL argument and return |
| 882 | * INTERNAL. |
| 883 | */ |
| 884 | argList[0] = INTERNALOID; |
| 885 | |
| 886 | procOid = LookupFuncName(procName, 1, argList, true); |
| 887 | if (!OidIsValid(procOid)) |
| 888 | ereport(ERROR, |
| 889 | (errcode(ERRCODE_UNDEFINED_FUNCTION), |
| 890 | errmsg("function %s does not exist", |
| 891 | func_signature_string(procName, 1, NIL, argList)))); |
| 892 | |
| 893 | if (get_func_rettype(procOid) != INTERNALOID) |
| 894 | ereport(ERROR, |
| 895 | (errcode(ERRCODE_INVALID_OBJECT_DEFINITION), |
| 896 | errmsg("support function %s must return type %s", |
| 897 | NameListToString(procName), "internal"))); |
| 898 | |
| 899 | /* |
| 900 | * Someday we might want an ACL check here; but for now, we insist that |
| 901 | * you be superuser to specify a support function, so privilege on the |
| 902 | * support function is moot. |
| 903 | */ |
| 904 | if (!superuser()) |
| 905 | ereport(ERROR, |
| 906 | (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), |
| 907 | errmsg("must be superuser to specify a support function"))); |
| 908 | |
| 909 | return procOid; |
| 910 | } |
| 911 | |
| 912 | |
| 913 | /* |
no test coverage detected