mirror of https://github.com/citusdata/citus.git
Add FunctionOidExtended function
parent
4af40eee76
commit
3e0cff94a6
|
@ -18,11 +18,27 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* FunctionOid looks for a function that has the given name and the given number
|
* FunctionOid searches for a function that has the given name and the given
|
||||||
* of arguments, and returns the corresponding function's oid.
|
* number of arguments, and returns the corresponding function's oid. The
|
||||||
|
* function reports error if the target function is not found, or it found more
|
||||||
|
* matching instances.
|
||||||
*/
|
*/
|
||||||
Oid
|
Oid
|
||||||
FunctionOid(const char *schemaName, const char *functionName, int argumentCount)
|
FunctionOid(const char *schemaName, const char *functionName, int argumentCount)
|
||||||
|
{
|
||||||
|
return FunctionOidExtended(schemaName, functionName, argumentCount, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* FunctionOidExtended searches for a given function identified by schema,
|
||||||
|
* functionName, and argumentCount. It reports error if the function is not
|
||||||
|
* found or there are more than one match. If the missingOK parameter is set
|
||||||
|
* and there are no matches, then the function returns InvalidOid.
|
||||||
|
*/
|
||||||
|
Oid
|
||||||
|
FunctionOidExtended(const char *schemaName, const char *functionName, int argumentCount,
|
||||||
|
bool missingOK)
|
||||||
{
|
{
|
||||||
FuncCandidateList functionList = NULL;
|
FuncCandidateList functionList = NULL;
|
||||||
Oid functionOid = InvalidOid;
|
Oid functionOid = InvalidOid;
|
||||||
|
@ -32,14 +48,18 @@ FunctionOid(const char *schemaName, const char *functionName, int argumentCount)
|
||||||
List *argumentList = NIL;
|
List *argumentList = NIL;
|
||||||
const bool findVariadics = false;
|
const bool findVariadics = false;
|
||||||
const bool findDefaults = false;
|
const bool findDefaults = false;
|
||||||
const bool missingOK = true;
|
|
||||||
|
|
||||||
functionList = FuncnameGetCandidates(qualifiedFunctionNameList, argumentCount,
|
functionList = FuncnameGetCandidates(qualifiedFunctionNameList, argumentCount,
|
||||||
argumentList, findVariadics,
|
argumentList, findVariadics,
|
||||||
findDefaults, missingOK);
|
findDefaults, true);
|
||||||
|
|
||||||
if (functionList == NULL)
|
if (functionList == NULL)
|
||||||
{
|
{
|
||||||
|
if (missingOK)
|
||||||
|
{
|
||||||
|
return InvalidOid;
|
||||||
|
}
|
||||||
|
|
||||||
ereport(ERROR, (errcode(ERRCODE_UNDEFINED_FUNCTION),
|
ereport(ERROR, (errcode(ERRCODE_UNDEFINED_FUNCTION),
|
||||||
errmsg("function \"%s\" does not exist", functionName)));
|
errmsg("function \"%s\" does not exist", functionName)));
|
||||||
}
|
}
|
||||||
|
@ -51,6 +71,7 @@ FunctionOid(const char *schemaName, const char *functionName, int argumentCount)
|
||||||
|
|
||||||
/* get function oid from function list's head */
|
/* get function oid from function list's head */
|
||||||
functionOid = functionList->oid;
|
functionOid = functionList->oid;
|
||||||
|
|
||||||
return functionOid;
|
return functionOid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,5 +14,7 @@
|
||||||
/* Function declaration for getting oid for the given function name */
|
/* Function declaration for getting oid for the given function name */
|
||||||
extern Oid FunctionOid(const char *schemaName, const char *functionName,
|
extern Oid FunctionOid(const char *schemaName, const char *functionName,
|
||||||
int argumentCount);
|
int argumentCount);
|
||||||
|
extern Oid FunctionOidExtended(const char *schemaName, const char *functionName, int
|
||||||
|
argumentCount, bool missingOK);
|
||||||
extern ReturnSetInfo * FunctionCallGetTupleStore1(PGFunction function, Oid functionId,
|
extern ReturnSetInfo * FunctionCallGetTupleStore1(PGFunction function, Oid functionId,
|
||||||
Datum argument);
|
Datum argument);
|
||||||
|
|
Loading…
Reference in New Issue