* LookupFuncName * * Given a possibly-qualified function name and optionally a set of argument * types, look up the function. Pass nargs == -1 to indicate that the number * and types of the arguments are unspecified (this is NOT the same as * specifying that there are no arguments). * * If the function name is not schema-qualified, it is sought in the current * namespace search path. *
| 2196 | * aggregates or window functions here.) |
| 2197 | */ |
| 2198 | Oid |
| 2199 | LookupFuncName(List *funcname, int nargs, const Oid *argtypes, bool missing_ok) |
| 2200 | { |
| 2201 | Oid funcoid; |
| 2202 | FuncLookupError lookupError; |
| 2203 | |
| 2204 | funcoid = LookupFuncNameInternal(OBJECT_FUNCTION, |
| 2205 | funcname, nargs, argtypes, |
| 2206 | false, missing_ok, |
| 2207 | &lookupError); |
| 2208 | |
| 2209 | if (OidIsValid(funcoid)) |
| 2210 | return funcoid; |
| 2211 | |
| 2212 | switch (lookupError) |
| 2213 | { |
| 2214 | case FUNCLOOKUP_NOSUCHFUNC: |
| 2215 | /* Let the caller deal with it when missing_ok is true */ |
| 2216 | if (missing_ok) |
| 2217 | return InvalidOid; |
| 2218 | |
| 2219 | if (nargs < 0) |
| 2220 | ereport(ERROR, |
| 2221 | (errcode(ERRCODE_UNDEFINED_FUNCTION), |
| 2222 | errmsg("could not find a function named \"%s\"", |
| 2223 | NameListToString(funcname)))); |
| 2224 | else |
| 2225 | ereport(ERROR, |
| 2226 | (errcode(ERRCODE_UNDEFINED_FUNCTION), |
| 2227 | errmsg("function %s does not exist", |
| 2228 | func_signature_string(funcname, nargs, |
| 2229 | NIL, argtypes)))); |
| 2230 | break; |
| 2231 | |
| 2232 | case FUNCLOOKUP_AMBIGUOUS: |
| 2233 | /* Raise an error regardless of missing_ok */ |
| 2234 | ereport(ERROR, |
| 2235 | (errcode(ERRCODE_AMBIGUOUS_FUNCTION), |
| 2236 | errmsg("function name \"%s\" is not unique", |
| 2237 | NameListToString(funcname)), |
| 2238 | errhint("Specify the argument list to select the function unambiguously."))); |
| 2239 | break; |
| 2240 | } |
| 2241 | |
| 2242 | return InvalidOid; /* Keep compiler quiet */ |
| 2243 | } |
| 2244 | |
| 2245 | /* |
| 2246 | * LookupFuncWithArgs |
no test coverage detected