89 errmsg(
"set-valued function called in context that cannot accept a set")));
94 errmsg(
"materialize mode required, but it is not allowed in this context")));
109 elog(
ERROR,
"return type must be a row type");
120 rsinfo->setResult = tupstore;
143 errmsg(
"set-valued function called in context that cannot accept a set")));
145 if (fcinfo->flinfo->fn_extra ==
NULL)
157 "SRF multi-call context",
180 fcinfo->flinfo->fn_extra = retval;
193 elog(
ERROR,
"init_MultiFuncCall cannot be called more than once");
349 else if (expr &&
IsA(expr,
Const) &&
446 elog(
ERROR,
"cache lookup failed for function %u", funcid);
496 errmsg(
"could not determine actual result type for function \"%s\" declared to return type %s",
569 errmsg(
"type %s is not composite",
574 errmsg(
"record type has not been registered")));
600 errmsg(
"argument declared %s is not an array but type %s",
614 errmsg(
"argument declared %s is not a range type but type %s",
632 errmsg(
"argument declared %s is not a multirange type but type %s",
642 errmsg(
"argument declared %s does not contain a range type but type %s",
648 elog(
ERROR,
"could not determine polymorphic type");
669 errmsg(
"could not find array type for data type %s",
674 elog(
ERROR,
"could not determine polymorphic type");
697 errmsg(
"argument declared %s is not a multirange type but type %s",
703 elog(
ERROR,
"could not determine polymorphic type");
725 errmsg(
"could not find multirange type for data type %s",
730 elog(
ERROR,
"could not determine polymorphic type");
747 int natts = tupdesc->
natts;
765 for (
i = 0;
i < natts;
i++)
824 for (
i = 0;
i < nargs;
i++)
969 for (
i = 0;
i < natts;
i++)
973 switch (
att->atttypid)
1089 for (
i = 0;
i < numargs;
i++)
1093 switch (argtypes[
i])
1279 for (
i = 0;
i < numargs;
i++)
1281 switch (argtypes[
i])
1411 elog(
ERROR,
"proallargtypes is not a 1-D Oid array or it contains nulls");
1415 numargs *
sizeof(
Oid));
1424 numargs *
sizeof(
Oid));
1436 &elems,
NULL, &nelems);
1437 if (nelems != numargs)
1438 elog(
ERROR,
"proargnames must have the same number of elements as the function has arguments");
1440 for (
i = 0;
i < numargs;
i++)
1457 elog(
ERROR,
"proargmodes is not a 1-D char array of length %d or it contains nulls",
1461 numargs *
sizeof(
char));
1500 elog(
ERROR,
"protrftypes is not a 1-D Oid array or it contains nulls");
1503 nelems *
sizeof(
Oid));
1549 elog(
ERROR,
"proargnames is not a 1-D text array or it contains nulls");
1558 elog(
ERROR,
"proargmodes is not a 1-D char array of length %d or it contains nulls",
1575 for (
i = 0;
i < numargs;
i++)
1584 if (
pname[0] !=
'\0')
1650 elog(
ERROR,
"proargmodes is not a 1-D char array or it contains nulls");
1657 elog(
ERROR,
"proargnames is not a 1-D text array of length %d or it contains nulls",
1665 for (
i = 0;
i < numargs;
i++)
1680 if (result ==
NULL || result[0] ==
'\0')
1784 elog(
ERROR,
"proallargtypes is not a 1-D Oid array or it contains nulls");
1791 elog(
ERROR,
"proargmodes is not a 1-D char array of length %d or it contains nulls",
1801 elog(
ERROR,
"proargnames is not a 1-D text array of length %d or it contains nulls",
1815 for (
i = 0;
i < numargs;
i++)
1922 int natts = tupdesc->
natts;
1929 errmsg(
"number of aliases does not match number of columns")));
1932 for (varattno = 0; varattno < natts; varattno++)
1955 errmsg(
"no column alias was provided")));
1961 errmsg(
"number of aliases does not match number of columns")));
1979 errmsg(
"could not determine row description for function returning record")));
1984 elog(
ERROR,
"function in FROM has unsupported return type");
2044 for (
i = 0;
i < nargs;
i++)
2055 for (
i = 0;
i < nargs;
i++)
2090 errmsg(
"could not determine data type for argument %d",
#define PG_GETARG_ARRAYTYPE_P(n)
#define DatumGetArrayTypeP(X)
Datum array_in(PG_FUNCTION_ARGS)
void deconstruct_array_builtin(const ArrayType *array, Oid elmtype, Datum **elemsp, bool **nullsp, int *nelemsp)
void deconstruct_array(const ArrayType *array, Oid elmtype, int elmlen, bool elmbyval, char elmalign, Datum **elemsp, bool **nullsp, int *nelemsp)
#define CStringGetTextDatum(s)
#define TextDatumGetCString(d)
#define Assert(condition)
#define OidIsValid(objectId)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
TupleDesc BlessTupleDesc(TupleDesc tupdesc)
void UnregisterExprContextCallback(ExprContext *econtext, ExprContextCallbackFunction function, Datum arg)
void RegisterExprContextCallback(ExprContext *econtext, ExprContextCallbackFunction function, Datum arg)
@ SFRM_Materialize_Random
#define palloc_array(type, count)
bool get_fn_expr_arg_stable(FmgrInfo *flinfo, int argnum)
bool get_fn_expr_variadic(FmgrInfo *flinfo)
Oid get_call_expr_argtype(Node *expr, int argnum)
Oid get_fn_expr_argtype(FmgrInfo *flinfo, int argnum)
#define DatumGetHeapTupleHeader(X)
#define PG_GETARG_POINTER(n)
#define PG_GETARG_DATUM(n)
static TypeFuncClass get_type_func_class(Oid typid, Oid *base_typeid)
void InitMaterializedSRF(FunctionCallInfo fcinfo, bits32 flags)
static TypeFuncClass internal_get_result_type(Oid funcid, Node *call_expr, ReturnSetInfo *rsinfo, Oid *resultTypeId, TupleDesc *resultTupleDesc)
int get_func_trftypes(HeapTuple procTup, Oid **p_trftypes)
TupleDesc build_function_result_tupdesc_t(HeapTuple procTuple)
char * get_func_result_name(Oid functionId)
TupleDesc build_function_result_tupdesc_d(char prokind, Datum proallargtypes, Datum proargmodes, Datum proargnames)
bool resolve_polymorphic_argtypes(int numargs, Oid *argtypes, char *argmodes, Node *call_expr)
void end_MultiFuncCall(PG_FUNCTION_ARGS, FuncCallContext *funcctx)
static void resolve_anyelement_from_others(polymorphic_actuals *actuals)
int get_func_input_arg_names(Datum proargnames, Datum proargmodes, char ***arg_names)
int get_func_arg_info(HeapTuple procTup, Oid **p_argtypes, char ***p_argnames, char **p_argmodes)
static bool resolve_polymorphic_tupdesc(TupleDesc tupdesc, oidvector *declared_args, Node *call_expr)
FuncCallContext * per_MultiFuncCall(PG_FUNCTION_ARGS)
FuncCallContext * init_MultiFuncCall(PG_FUNCTION_ARGS)
TupleDesc RelationNameGetTupleDesc(const char *relname)
TypeFuncClass get_call_result_type(FunctionCallInfo fcinfo, Oid *resultTypeId, TupleDesc *resultTupleDesc)
int extract_variadic_args(FunctionCallInfo fcinfo, int variadic_start, bool convert_unknown, Datum **args, Oid **types, bool **nulls)
static void resolve_anyrange_from_others(polymorphic_actuals *actuals)
static void shutdown_MultiFuncCall(Datum arg)
TupleDesc get_expr_result_tupdesc(Node *expr, bool noError)
static void resolve_anymultirange_from_others(polymorphic_actuals *actuals)
TupleDesc TypeGetTupleDesc(Oid typeoid, List *colaliases)
TypeFuncClass get_func_result_type(Oid functionId, Oid *resultTypeId, TupleDesc *resultTupleDesc)
static void resolve_anyarray_from_others(polymorphic_actuals *actuals)
TypeFuncClass get_expr_result_type(Node *expr, Oid *resultTypeId, TupleDesc *resultTupleDesc)
@ TYPEFUNC_COMPOSITE_DOMAIN
#define MAT_SRF_USE_EXPECTED_DESC
bool heap_attisnull(HeapTuple tup, int attnum, TupleDesc tupleDesc)
#define HeapTupleIsValid(tuple)
static int32 HeapTupleHeaderGetTypMod(const HeapTupleHeaderData *tup)
static void * GETSTRUCT(const HeapTupleData *tuple)
static Oid HeapTupleHeaderGetTypeId(const HeapTupleHeaderData *tup)
Oid get_range_subtype(Oid rangeOid)
Oid get_element_type(Oid typid)
Oid get_multirange_range(Oid multirangeOid)
void get_typlenbyvalalign(Oid typid, int16 *typlen, bool *typbyval, char *typalign)
RegProcedure get_opcode(Oid opno)
Oid get_typcollation(Oid typid)
Oid get_range_multirange(Oid rangeOid)
char get_typtype(Oid typid)
Oid getBaseType(Oid typid)
Oid get_array_type(Oid typid)
void * MemoryContextAllocZero(MemoryContext context, Size size)
void * palloc0(Size size)
void MemoryContextDelete(MemoryContext context)
#define AllocSetContextCreate
#define ALLOCSET_SMALL_SIZES
void namestrcpy(Name name, const char *str)
RangeVar * makeRangeVarFromNameList(const List *names)
Oid exprType(const Node *expr)
Oid exprInputCollation(const Node *expr)
int32 exprTypmod(const Node *expr)
Oid exprCollation(const Node *expr)
#define IsA(nodeptr, _type_)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
FormData_pg_attribute * Form_pg_attribute
static int list_length(const List *l)
#define forboth(cell1, list1, cell2, list2)
static void * list_nth(const List *list, int n)
FormData_pg_proc * Form_pg_proc
static Datum PointerGetDatum(const void *X)
static Datum ObjectIdGetDatum(Oid X)
static Pointer DatumGetPointer(Datum X)
char * psprintf(const char *fmt,...)
List * stringToQualifiedNameList(const char *string, Node *escontext)
#define RelationGetDescr(relation)
void relation_close(Relation relation, LOCKMODE lockmode)
Relation relation_openrv(const RangeVar *relation, LOCKMODE lockmode)
AttInMetadata * attinmeta
MemoryContext multi_call_memory_ctx
void ReleaseSysCache(HeapTuple tuple)
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
Datum SysCacheGetAttrNotNull(int cacheId, HeapTuple tup, AttrNumber attributeNumber)
TupleDesc CreateTemplateTupleDesc(int natts)
TupleDesc CreateTupleDescCopy(TupleDesc tupdesc)
void TupleDescInitEntryCollation(TupleDesc desc, AttrNumber attributeNumber, Oid collationid)
void TupleDescInitEntry(TupleDesc desc, AttrNumber attributeNumber, const char *attributeName, Oid oidtypeid, int32 typmod, int attdim)
static FormData_pg_attribute * TupleDescAttr(TupleDesc tupdesc, int i)
Tuplestorestate * tuplestore_begin_heap(bool randomAccess, bool interXact, int maxKBytes)
void assign_record_type_typmod(TupleDesc tupDesc)
TupleDesc lookup_rowtype_tupdesc_copy(Oid type_id, int32 typmod)