105 errmsg(
"SQL function cannot return shell type %s",
110 errmsg(
"return type %s is only a shell",
139 errmsg(
"type modifier cannot be specified for shell type \"%s\"",
146 errdetail(
"Creating a shell type definition.")));
224 foreach(
x, parameters)
247 errmsg(
"SQL function cannot accept shell type %s",
254 errmsg(
"aggregate cannot accept shell type %s",
260 errmsg(
"argument type %s is only a shell",
271 errmsg(
"type %s does not exist",
286 errmsg(
"aggregates cannot accept set arguments"),
291 errmsg(
"procedures cannot accept set arguments"),
296 errmsg(
"functions cannot accept set arguments"),
307 errmsg(
"VARIADIC parameter must be the last input parameter"),
328 errmsg(
"VARIADIC parameter must be the last parameter"),
333 else if (outCount == 0)
354 errmsg(
"VARIADIC parameter must be an array"),
374 foreach(
px, parameters)
400 errmsg(
"parameter name \"%s\" used more than once",
419 errmsg(
"only input parameters can have default values"),
435 errmsg(
"cannot use table references in parameter default value"),
460 errmsg(
"input parameters after one with a default value must also have defaults"),
471 errmsg(
"procedure OUT parameters cannot appear after one with a default value"),
614 errmsg(
"invalid attribute in procedure definition"),
652 errmsg(
"parameter \"parallel\" must be SAFE, RESTRICTED, or UNSAFE")));
704 errmsg(
"function %s does not exist",
710 errmsg(
"support function %s must return type %s",
721 errmsg(
"must be superuser to specify a support function")));
793 errmsg(
"invalid attribute in procedure definition"),
814 elog(
ERROR,
"option \"%s\" not recognized",
842 errmsg(
"COST must be positive")));
850 errmsg(
"ROWS must be positive")));
874 const char *queryString)
879 errmsg(
"no function body specified")));
884 errmsg(
"duplicate function body specified")));
889 errmsg(
"inline SQL function body only valid for language SQL")));
931 errmsg(
"SQL function with unquoted function body cannot have polymorphic arguments")));
957 errmsg(
"%s is not yet supported in unquoted SQL function body",
976 errmsg(
"%s is not yet supported in unquoted SQL function body",
1004 errmsg(
"only one AS item needed for language \"%s\"",
1110 errmsg(
"no language specified")));
1120 errhint(
"Use CREATE EXTENSION to load the language into the database.") : 0)));
1153 errmsg(
"only superuser can define a leakproof function")));
1166 typeid =
elt ?
elt :
typeid;
1191 if (
stmt->is_procedure)
1197 else if (
stmt->returnType)
1201 &prorettype, &returnsSet);
1205 errmsg(
"function result type must be %s because of OUT parameters",
1218 errmsg(
"function result type must be specified")));
1268 else if (!returnsSet)
1271 errmsg(
"ROWS is not applicable when function does not return a set")));
1327 elog(
ERROR,
"cache lookup failed for function %u", funcOid);
1348 elog(
ERROR,
"cache lookup failed for pg_aggregate tuple for function %u", funcOid);
1391 elog(
ERROR,
"cache lookup failed for function %u", funcOid);
1403 errmsg(
"\"%s\" is an aggregate function",
1409 foreach(l,
stmt->actions)
1440 errmsg(
"only superuser can define a leakproof function")));
1448 errmsg(
"COST must be positive")));
1456 errmsg(
"ROWS must be positive")));
1460 errmsg(
"ROWS is not applicable when function does not return a set")));
1473 elog(
ERROR,
"could not change support dependency for function %s",
1567 errmsg(
"source data type %s is a pseudo-type",
1573 errmsg(
"target data type %s is a pseudo-type",
1581 errmsg(
"must be owner of type %s or type %s",
1597 errmsg(
"cast will be ignored because the source data type is a domain")));
1602 errmsg(
"cast will be ignored because the target data type is a domain")));
1607 else if (
stmt->inout)
1620 elog(
ERROR,
"cache lookup failed for function %u", funcid);
1627 errmsg(
"cast function must take one to three arguments")));
1633 errmsg(
"argument of cast function must match or be binary-coercible from source data type")));
1637 errmsg(
"second argument of cast function must be type %s",
1642 errmsg(
"third argument of cast function must be type %s",
1649 errmsg(
"return data type of cast function must match or be binary-coercible to target data type")));
1660 errmsg(
"cast function must not be volatile")));
1665 errmsg(
"cast function must be a normal function")));
1669 errmsg(
"cast function must not return a set")));
1695 errmsg(
"must be superuser to create a cast WITHOUT FUNCTION")));
1710 errmsg(
"source and target data types are not physically compatible")));
1730 errmsg(
"composite data types are not binary-compatible")));
1736 errmsg(
"array data types are not binary-compatible")));
1744 errmsg(
"range data types are not binary-compatible")));
1750 errmsg(
"enum data types are not binary-compatible")));
1767 errmsg(
"domain data types must not be marked binary-compatible")));
1777 errmsg(
"source data type and target data type are the same")));
1780 switch (
stmt->context)
1793 elog(
ERROR,
"unrecognized CoercionContext: %d",
stmt->context);
1810 errmsg(
"transform function must not be volatile")));
1814 errmsg(
"transform function must be a normal function")));
1818 errmsg(
"transform function must not return a set")));
1822 errmsg(
"transform function must take one argument")));
1826 errmsg(
"first argument of transform function must be type %s",
1865 errmsg(
"data type %s is a pseudo-type",
1871 errmsg(
"data type %s is a domain",
1911 errmsg(
"return data type of FROM SQL function must be %s",
1937 errmsg(
"return data type of TO SQL function must be the transform data type")));
1964 errmsg(
"transform for type %s language \"%s\" already exists",
2050 errmsg(
"transform for type %s language \"%s\" does not exist",
2074 errmsg(
"function %s already exists in schema \"%s\"",
2116 elog(
ERROR,
"option \"%s\" not recognized",
2125 errmsg(
"no inline code specified")));
2140 errhint(
"Use CREATE EXTENSION to load the language into the database.") : 0)));
2171 errmsg(
"language \"%s\" does not support inline code execution",
2239 elog(
ERROR,
"cache lookup failed for function %u",
fexpr->funcid);
2266 errmsg_plural(
"cannot pass more than %d argument to a procedure",
2267 "cannot pass more than %d arguments to a procedure",
2307 fcinfo->args[
i].value =
val;
2308 fcinfo->args[
i].isnull = isnull;
2339 elog(
ERROR,
"procedure returned null record");
2376 elog(
ERROR,
"unexpected result type for procedure: %u",
2377 fexpr->funcresulttype);
2396 elog(
ERROR,
"cache lookup failed for procedure %u",
fexpr->funcid);
2415 for (
int i = 0;
i < tupdesc->
natts;
i++)
void aclcheck_error(AclResult aclerr, ObjectType objtype, const char *objectname)
AclResult object_aclcheck(Oid classid, Oid objectid, Oid roleid, AclMode mode)
bool object_ownercheck(Oid classid, Oid objectid, Oid roleid)
void aclcheck_error_type(AclResult aclerr, Oid typeOid)
#define DatumGetArrayTypeP(X)
ArrayType * construct_array_builtin(Datum *elems, int nelems, Oid elmtype)
static Datum values[MAXATTR]
#define CStringGetTextDatum(s)
#define Assert(condition)
#define OidIsValid(objectId)
Oid GetNewOidWithIndex(Relation relation, Oid indexId, AttrNumber oidcolumn)
const char * GetCommandTagName(CommandTag commandTag)
List * defGetQualifiedName(DefElem *def)
void errorConflictingDefElem(DefElem *defel, ParseState *pstate)
double defGetNumeric(DefElem *def)
void record_object_address_dependencies(const ObjectAddress *depender, ObjectAddresses *referenced, DependencyType behavior)
void add_exact_object_address(const ObjectAddress *object, ObjectAddresses *addrs)
ObjectAddresses * new_object_addresses(void)
void free_object_addresses(ObjectAddresses *addrs)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
int errhint(const char *fmt,...) pg_attribute_printf(1
int errdetail(const char *fmt,...) pg_attribute_printf(1
int int int errmsg_plural(const char *fmt_singular, const char *fmt_plural, unsigned long n,...) pg_attribute_printf(1
#define ereport(elevel,...)
ExprState * ExecPrepareExpr(Expr *node, EState *estate)
void end_tup_output(TupOutputState *tstate)
const TupleTableSlotOps TTSOpsHeapTuple
TupOutputState * begin_tup_output_tupdesc(DestReceiver *dest, TupleDesc tupdesc, const TupleTableSlotOps *tts_ops)
TupleTableSlot * ExecStoreHeapTuple(HeapTuple tuple, TupleTableSlot *slot, bool shouldFree)
ExprContext * CreateExprContext(EState *estate)
void FreeExecutorState(EState *estate)
EState * CreateExecutorState(void)
static Datum ExecEvalExprSwitchContext(ExprState *state, ExprContext *econtext, bool *isNull)
bool extension_file_exists(const char *extensionName)
#define palloc0_object(type)
void fmgr_info(Oid functionId, FmgrInfo *finfo)
#define OidFunctionCall1(functionId, arg1)
#define DatumGetHeapTupleHeader(X)
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
#define LOCAL_FCINFO(name, nargs)
#define FunctionCallInvoke(fcinfo)
#define fmgr_info_set_expr(expr, finfo)
TupleDesc build_function_result_tupdesc_t(HeapTuple procTuple)
void ExecuteCallStmt(CallStmt *stmt, ParamListInfo params, bool atomic, DestReceiver *dest)
ObjectAddress CreateCast(CreateCastStmt *stmt)
static void compute_return_type(TypeName *returnType, Oid languageOid, Oid *prorettype_p, bool *returnsSet_p)
static Oid interpret_func_support(DefElem *defel)
static void compute_function_attributes(ParseState *pstate, bool is_procedure, List *options, List **as, char **language, Node **transform, bool *windowfunc_p, char *volatility_p, bool *strict_p, bool *security_definer, bool *leakproof_p, ArrayType **proconfig, float4 *procost, float4 *prorows, Oid *prosupport, char *parallel_p)
void interpret_function_parameter_list(ParseState *pstate, List *parameters, Oid languageOid, ObjectType objtype, oidvector **parameterTypes, List **parameterTypes_list, ArrayType **allParameterTypes, ArrayType **parameterModes, ArrayType **parameterNames, List **inParameterNames_list, List **parameterDefaults, Oid *variadicArgType, Oid *requiredResultType)
static bool compute_common_attribute(ParseState *pstate, bool is_procedure, DefElem *defel, DefElem **volatility_item, DefElem **strict_item, DefElem **security_item, DefElem **leakproof_item, List **set_items, DefElem **cost_item, DefElem **rows_item, DefElem **support_item, DefElem **parallel_item)
static char interpret_func_volatility(DefElem *defel)
ObjectAddress CreateFunction(ParseState *pstate, CreateFunctionStmt *stmt)
void IsThereFunctionInNamespace(const char *proname, int pronargs, oidvector *proargtypes, Oid nspOid)
ObjectAddress AlterFunction(ParseState *pstate, AlterFunctionStmt *stmt)
TupleDesc CallStmtResultDesc(CallStmt *stmt)
static void interpret_AS_clause(Oid languageOid, const char *languageName, char *funcname, List *as, Node *sql_body_in, List *parameterTypes, List *inParameterNames, char **prosrc_str_p, char **probin_str_p, Node **sql_body_out, const char *queryString)
Oid get_transform_oid(Oid type_id, Oid lang_id, bool missing_ok)
void ExecuteDoStmt(ParseState *pstate, DoStmt *stmt, bool atomic)
static void check_transform_function(Form_pg_proc procstruct)
ObjectAddress CreateTransform(CreateTransformStmt *stmt)
static ArrayType * update_proconfig_value(ArrayType *a, List *set_items)
void RemoveFunctionById(Oid funcOid)
static char interpret_func_parallel(DefElem *defel)
void sql_fn_parser_setup(struct ParseState *pstate, SQLFunctionParseInfoPtr pinfo)
void px(PlannerInfo *root, Gene *tour1, Gene *tour2, Gene *offspring, int num_gene, City *city_table)
ArrayType * GUCArrayAdd(ArrayType *array, const char *name, const char *value)
ArrayType * GUCArrayDelete(ArrayType *array, const char *name)
char * ExtractSetVariableArgs(VariableSetStmt *stmt)
HeapTuple heap_modify_tuple(HeapTuple tuple, TupleDesc tupleDesc, const Datum *replValues, const bool *replIsnull, const bool *doReplace)
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
bool heap_attisnull(HeapTuple tup, int attnum, TupleDesc tupleDesc)
void heap_freetuple(HeapTuple htup)
#define HeapTupleIsValid(tuple)
static int32 HeapTupleHeaderGetTypMod(const HeapTupleHeaderData *tup)
static uint32 HeapTupleHeaderGetDatumLength(const HeapTupleHeaderData *tup)
static void * GETSTRUCT(const HeapTupleData *tuple)
static Oid HeapTupleHeaderGetTypeId(const HeapTupleHeaderData *tup)
void CatalogTupleUpdate(Relation heapRel, const ItemPointerData *otid, HeapTuple tup)
void CatalogTupleInsert(Relation heapRel, HeapTuple tup)
void CatalogTupleDelete(Relation heapRel, const ItemPointerData *tid)
static void ItemPointerSetInvalid(ItemPointerData *pointer)
List * lappend(List *list, void *datum)
List * lappend_oid(List *list, Oid datum)
Oid get_element_type(Oid typid)
void get_typlenbyvalalign(Oid typid, int16 *typlen, bool *typbyval, char *typalign)
char * get_language_name(Oid langoid, bool missing_ok)
char * get_func_name(Oid funcid)
char get_typtype(Oid typid)
Oid get_base_element_type(Oid typid)
char * get_namespace_name(Oid nspid)
Oid get_func_rettype(Oid funcid)
char * pstrdup(const char *in)
void * palloc0(Size size)
char * NameListToString(const List *names)
Oid QualifiedNameGetCreationNamespace(const List *names, char **objname_p)
Oid exprType(const Node *expr)
#define IsA(nodeptr, _type_)
#define castNode(_type_, nodeptr)
#define InvokeObjectPostCreateHook(classId, objectId, subId)
#define InvokeObjectPostAlterHook(classId, objectId, subId)
#define InvokeFunctionExecuteHook(objectId)
#define ObjectAddressSet(addr, class_id, object_id)
oidvector * buildoidvector(const Oid *oids, int n)
Node * coerce_to_specific_type(ParseState *pstate, Node *node, Oid targetTypeId, const char *constructName)
bool IsBinaryCoercibleWithCast(Oid srctype, Oid targettype, Oid *castoid)
void assign_expr_collations(ParseState *pstate, Node *expr)
Node * transformExpr(ParseState *pstate, Node *expr, ParseExprKind exprKind)
const char * funcname_signature_string(const char *funcname, int nargs, List *argnames, const Oid *argtypes)
const char * func_signature_string(List *funcname, int nargs, List *argnames, const Oid *argtypes)
Oid LookupFuncWithArgs(ObjectType objtype, ObjectWithArgs *func, bool missing_ok)
Oid LookupFuncName(List *funcname, int nargs, const Oid *argtypes, bool missing_ok)
void free_parsestate(ParseState *pstate)
int parser_errposition(ParseState *pstate, int location)
ParseState * make_parsestate(ParseState *parentParseState)
@ EXPR_KIND_FUNCTION_DEFAULT
char * TypeNameToString(const TypeName *typeName)
Type LookupTypeName(ParseState *pstate, const TypeName *typeName, int32 *typmod_p, bool missing_ok)
Oid typenameTypeId(ParseState *pstate, const TypeName *typeName)
Query * transformStmt(ParseState *pstate, Node *parseTree)
FormData_pg_attribute * Form_pg_attribute
ObjectAddress CastCreate(Oid sourcetypeid, Oid targettypeid, Oid funcid, Oid incastid, Oid outcastid, char castcontext, char castmethod, DependencyType behavior)
void recordDependencyOn(const ObjectAddress *depender, const ObjectAddress *referenced, DependencyType behavior)
long changeDependencyFor(Oid classId, Oid objectId, Oid refClassId, Oid oldRefObjectId, Oid newRefObjectId)
long deleteDependencyRecordsFor(Oid classId, Oid objectId, bool skipExtensionDeps)
void recordDependencyOnCurrentExtension(const ObjectAddress *object, bool isReplace)
END_CATALOG_STRUCT typedef FormData_pg_language * Form_pg_language
#define lfirst_node(type, lc)
static int list_length(const List *l)
#define linitial_node(type, l)
static Oid list_nth_oid(const List *list, int n)
static void * list_nth(const List *list, int n)
ObjectAddress ProcedureCreate(const char *procedureName, Oid procNamespace, bool replace, bool returnsSet, Oid returnType, Oid proowner, Oid languageObjectId, Oid languageValidator, const char *prosrc, const char *probin, Node *prosqlbody, char prokind, bool security_definer, bool isLeakProof, bool isStrict, char volatility, char parallel, oidvector *parameterTypes, Datum allParameterTypes, Datum parameterModes, Datum parameterNames, List *parameterDefaults, Datum trftypes, List *trfoids, Datum proconfig, Oid prosupport, float4 procost, float4 prorows)
END_CATALOG_STRUCT typedef FormData_pg_proc * Form_pg_proc
ObjectAddress TypeShellMake(const char *typeName, Oid typeNamespace, Oid ownerId)
END_CATALOG_STRUCT typedef FormData_pg_type * Form_pg_type
void pgstat_drop_function(Oid proid)
void pgstat_init_function_usage(FunctionCallInfo fcinfo, PgStat_FunctionCallUsage *fcu)
void pgstat_end_function_usage(PgStat_FunctionCallUsage *fcu, bool finalize)
static Datum PointerGetDatum(const void *X)
static Datum ObjectIdGetDatum(Oid X)
static Datum CStringGetDatum(const char *X)
static Datum CharGetDatum(char X)
void EnsurePortalSnapshotExists(void)
Oid get_language_oid(const char *langname, bool missing_ok)
#define RelationGetDescr(relation)
Snapshot GetTransactionSnapshot(void)
void PushActiveSnapshot(Snapshot snapshot)
void PopActiveSnapshot(void)
#define ERRCODE_DUPLICATE_OBJECT
ParamListInfo es_param_list_info
FunctionParameterMode mode
const char * p_sourcetext
void ReleaseSysCache(HeapTuple tuple)
HeapTuple SearchSysCache2(SysCacheIdentifier cacheId, Datum key1, Datum key2)
HeapTuple SearchSysCache1(SysCacheIdentifier cacheId, Datum key1)
Datum SysCacheGetAttr(SysCacheIdentifier cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
#define SearchSysCacheCopy1(cacheId, key1)
#define SearchSysCacheExists3(cacheId, key1, key2, key3)
#define GetSysCacheOid2(cacheId, oidcol, key1, key2)
void table_close(Relation relation, LOCKMODE lockmode)
Relation table_open(Oid relationId, LOCKMODE lockmode)
void TupleDescInitEntry(TupleDesc desc, AttrNumber attributeNumber, const char *attributeName, Oid oidtypeid, int32 typmod, int attdim)
#define ReleaseTupleDesc(tupdesc)
static FormData_pg_attribute * TupleDescAttr(TupleDesc tupdesc, int i)
TupleDesc lookup_rowtype_tupdesc(Oid type_id, int32 typmod)
CommandTag CreateCommandTag(Node *parsetree)
String * makeString(char *str)
bool contain_var_clause(Node *node)
void CommandCounterIncrement(void)