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");
351 else if (expr &&
IsA(expr,
Const) &&
448 elog(
ERROR,
"cache lookup failed for function %u", funcid);
498 errmsg(
"could not determine actual result type for function \"%s\" declared to return type %s",
571 errmsg(
"type %s is not composite",
576 errmsg(
"record type has not been registered")));
602 errmsg(
"argument declared %s is not an array but type %s",
616 errmsg(
"argument declared %s is not a range type but type %s",
634 errmsg(
"argument declared %s is not a multirange type but type %s",
644 errmsg(
"argument declared %s does not contain a range type but type %s",
650 elog(
ERROR,
"could not determine polymorphic type");
671 errmsg(
"could not find array type for data type %s",
676 elog(
ERROR,
"could not determine polymorphic type");
699 errmsg(
"argument declared %s is not a multirange type but type %s",
705 elog(
ERROR,
"could not determine polymorphic type");
727 errmsg(
"could not find multirange type for data type %s",
732 elog(
ERROR,
"could not determine polymorphic type");
749 int natts = tupdesc->
natts;
767 for (
i = 0;
i < natts;
i++)
826 for (
i = 0;
i < nargs;
i++)
971 for (
i = 0;
i < natts;
i++)
975 switch (
att->atttypid)
1092 for (
i = 0;
i < numargs;
i++)
1096 switch (argtypes[
i])
1282 for (
i = 0;
i < numargs;
i++)
1284 switch (argtypes[
i])
1414 elog(
ERROR,
"proallargtypes is not a 1-D Oid array or it contains nulls");
1418 numargs *
sizeof(
Oid));
1427 numargs *
sizeof(
Oid));
1439 &elems,
NULL, &nelems);
1440 if (nelems != numargs)
1441 elog(
ERROR,
"proargnames must have the same number of elements as the function has arguments");
1443 for (
i = 0;
i < numargs;
i++)
1460 elog(
ERROR,
"proargmodes is not a 1-D char array of length %d or it contains nulls",
1464 numargs *
sizeof(
char));
1503 elog(
ERROR,
"protrftypes is not a 1-D Oid array or it contains nulls");
1506 nelems *
sizeof(
Oid));
1552 elog(
ERROR,
"proargnames is not a 1-D text array or it contains nulls");
1561 elog(
ERROR,
"proargmodes is not a 1-D char array of length %d or it contains nulls",
1578 for (
i = 0;
i < numargs;
i++)
1587 if (
pname[0] !=
'\0')
1653 elog(
ERROR,
"proargmodes is not a 1-D char array or it contains nulls");
1660 elog(
ERROR,
"proargnames is not a 1-D text array of length %d or it contains nulls",
1668 for (
i = 0;
i < numargs;
i++)
1683 if (result ==
NULL || result[0] ==
'\0')
1787 elog(
ERROR,
"proallargtypes is not a 1-D Oid array or it contains nulls");
1794 elog(
ERROR,
"proargmodes is not a 1-D char array of length %d or it contains nulls",
1804 elog(
ERROR,
"proargnames is not a 1-D text array of length %d or it contains nulls",
1818 for (
i = 0;
i < numargs;
i++)
1927 int natts = tupdesc->
natts;
1934 errmsg(
"number of aliases does not match number of columns")));
1937 for (varattno = 0; varattno < natts; varattno++)
1960 errmsg(
"no column alias was provided")));
1966 errmsg(
"number of aliases does not match number of columns")));
1985 errmsg(
"could not determine row description for function returning record")));
1990 elog(
ERROR,
"function in FROM has unsupported return type");
2050 for (
i = 0;
i < nargs;
i++)
2061 for (
i = 0;
i < nargs;
i++)
2096 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)
#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)
END_CATALOG_STRUCT typedef 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)
Datum SysCacheGetAttrNotNull(SysCacheIdentifier cacheId, HeapTuple tup, AttrNumber attributeNumber)
HeapTuple SearchSysCache1(SysCacheIdentifier cacheId, Datum key1)
Datum SysCacheGetAttr(SysCacheIdentifier cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
TupleDesc CreateTemplateTupleDesc(int natts)
void TupleDescFinalize(TupleDesc tupdesc)
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)