15#include "catalog/pg_operator_d.h"
118 errmsg(
"could not determine input data type")));
123 errmsg(
"input data type is not an array")));
167 errmsg(
"integer out of range")));
169 else if (
eah->ndims == 0)
174 errmsg(
"argument must be empty or one-dimensional array")));
209 arg->paramid ==
req->paramid)
249 errmsg(
"integer out of range")));
251 else if (
eah->ndims == 0)
259 errmsg(
"argument must be empty or one-dimensional array")));
302 arg->paramid ==
req->paramid)
371 errmsg(
"cannot concatenate incompatible arrays"),
372 errdetail(
"Arrays with element types %s and %s are not "
373 "compatible for concatenation.",
410 errmsg(
"cannot concatenate incompatible arrays"),
411 errdetail(
"Arrays of %d and %d dimensions are not "
412 "compatible for concatenation.",
442 for (
i = 1;
i < ndims;
i++)
447 errmsg(
"cannot concatenate incompatible arrays"),
448 errdetail(
"Arrays with differing element dimensions are "
449 "not compatible for concatenation.")));
476 errmsg(
"cannot concatenate incompatible arrays"),
477 errdetail(
"Arrays with differing dimensions are not "
478 "compatible for concatenation.")));
504 errmsg(
"cannot concatenate incompatible arrays"),
505 errdetail(
"Arrays with differing dimensions are not "
506 "compatible for concatenation.")));
528 result->
ndim = ndims;
565 errmsg(
"could not determine input data type")));
576 elog(
ERROR,
"array_agg_transfn called in non-aggregate context");
609 elog(
ERROR,
"aggregate function called in non-aggregate context");
651 else if (
state2->nelems > 0)
667 state1->alen *
sizeof(
bool));
683 sizeof(
bool) *
state2->nelems);
763 fcinfo->flinfo->fn_mcxt);
764 fcinfo->flinfo->fn_extra =
iodata;
797 elog(
ERROR,
"aggregate function called in non-aggregate context");
854 fcinfo->flinfo->fn_mcxt);
855 fcinfo->flinfo->fn_extra =
iodata;
858 for (
int i = 0;
i < nelems;
i++)
873 errmsg(
"insufficient data left in message")));
913 dims[0] =
state->nelems;
942 errmsg(
"could not determine input data type")));
953 elog(
ERROR,
"array_agg_array_transfn called in non-aggregate context");
985 elog(
ERROR,
"aggregate function called in non-aggregate context");
1007 agg_context,
false);
1014 int size = (
state2->aitems + 7) / 8;
1036 else if (
state2->nitems > 0)
1051 errmsg(
"cannot accumulate arrays of different dimensionality")));
1059 errmsg(
"cannot accumulate arrays of different dimensionality")));
1161 if (
state->nullbitmap)
1220 while (result->
abytes < nbytes)
1239 int size = (result->
aitems + 7) / 8;
1348 errmsg(
"searching for elements in multidimensional arrays is not supported")));
1377 errmsg(
"initial position must not be null")));
1398 if (
my_extra->element_type != element_type)
1410 errmsg(
"could not identify an equality operator for type %s",
1413 my_extra->element_type = element_type;
1502 errmsg(
"searching for elements in multidimensional arrays is not supported")));
1541 if (
my_extra->element_type != element_type)
1553 errmsg(
"could not identify an equality operator for type %s",
1556 my_extra->element_type = element_type;
1558 fcinfo->flinfo->fn_mcxt);
1641 if (ndim < 1 || dims[0] < 1 || n < 1)
1660 for (
int i = 0;
i < n;
i++)
1667 for (
int k = 0; k <
nelm; k++)
1721 fcinfo->flinfo->fn_extra = typentry;
1750 errmsg(
"sample size must be between 0 and %d", nitem)));
1757 fcinfo->flinfo->fn_extra = typentry;
1810 for (
int i = 0;
i < nitem / 2;
i++)
1812 int j = (nitem -
i - 1) *
nelm;
1817 for (
int k = 0; k <
nelm; k++)
1869 fcinfo->flinfo->fn_extra = (
void *) typentry;
1906 if (ndim < 1 || dims[0] < 2)
1950 errmsg(
"could not find array type for data type %s",
1963 errmsg(
"could not identify a comparison function for type %s",
static bool array_iterator(ArrayType *la, PGCALL2 callback, void *param, ltree **found)
#define PG_GETARG_ARRAYTYPE_P(n)
#define ARR_NULLBITMAP(a)
#define ARR_OVERHEAD_WITHNULLS(ndims, nitems)
#define DatumGetArrayTypeP(X)
#define PG_RETURN_ARRAYTYPE_P(x)
#define ARR_OVERHEAD_NONULLS(ndims)
#define ARR_DATA_OFFSET(a)
#define PG_GETARG_EXPANDED_ARRAYX(n, metacache)
Datum array_sample(PG_FUNCTION_ARGS)
Datum array_prepend(PG_FUNCTION_ARGS)
Datum array_agg_deserialize(PG_FUNCTION_ARGS)
Datum array_positions(PG_FUNCTION_ARGS)
static Datum array_position_common(FunctionCallInfo fcinfo)
Datum array_position(PG_FUNCTION_ARGS)
static ExpandedArrayHeader * fetch_array_arg_replace_nulls(FunctionCallInfo fcinfo, int argno)
Datum array_agg_combine(PG_FUNCTION_ARGS)
Datum array_sort(PG_FUNCTION_ARGS)
Datum array_reverse(PG_FUNCTION_ARGS)
Datum array_append(PG_FUNCTION_ARGS)
Datum array_agg_array_combine(PG_FUNCTION_ARGS)
Datum array_agg_serialize(PG_FUNCTION_ARGS)
Datum array_agg_array_deserialize(PG_FUNCTION_ARGS)
Datum array_append_support(PG_FUNCTION_ARGS)
Datum array_agg_finalfn(PG_FUNCTION_ARGS)
Datum array_agg_array_transfn(PG_FUNCTION_ARGS)
Datum array_position_start(PG_FUNCTION_ARGS)
static ArrayType * array_sort_internal(ArrayType *array, bool descending, bool nulls_first, FunctionCallInfo fcinfo)
Datum array_shuffle(PG_FUNCTION_ARGS)
Datum array_cat(PG_FUNCTION_ARGS)
static ArrayType * array_reverse_n(ArrayType *array, Oid elmtyp, TypeCacheEntry *typentry)
Datum array_sort_order(PG_FUNCTION_ARGS)
static ArrayType * array_shuffle_n(ArrayType *array, int n, bool keep_lb, Oid elmtyp, TypeCacheEntry *typentry)
Datum array_sort_order_nulls_first(PG_FUNCTION_ARGS)
Datum array_agg_transfn(PG_FUNCTION_ARGS)
Datum array_agg_array_finalfn(PG_FUNCTION_ARGS)
Datum array_agg_array_serialize(PG_FUNCTION_ARGS)
Datum array_prepend_support(PG_FUNCTION_ARGS)
ArrayBuildState * accumArrayResult(ArrayBuildState *astate, Datum dvalue, bool disnull, Oid element_type, MemoryContext rcontext)
ExpandedArrayHeader * construct_empty_expanded_array(Oid element_type, MemoryContext parentcontext, ArrayMetaState *metacache)
bool array_iterate(ArrayIterator iterator, Datum *value, bool *isnull)
void array_free_iterator(ArrayIterator iterator)
ArrayBuildStateAny * accumArrayResultAny(ArrayBuildStateAny *astate, Datum dvalue, bool disnull, Oid input_type, MemoryContext rcontext)
ArrayType * construct_empty_array(Oid elmtype)
bool array_contains_nulls(const ArrayType *array)
Datum makeArrayResultArr(ArrayBuildStateArr *astate, MemoryContext rcontext, bool release)
Datum makeArrayResultAny(ArrayBuildStateAny *astate, MemoryContext rcontext, bool release)
Datum array_set_element(Datum arraydatum, int nSubscripts, int *indx, Datum dataValue, bool isNull, int arraytyplen, int elmlen, bool elmbyval, char elmalign)
Datum makeMdArrayResult(ArrayBuildState *astate, int ndims, int *dims, int *lbs, MemoryContext rcontext, bool release)
ArrayBuildStateArr * initArrayResultArr(Oid array_type, Oid element_type, MemoryContext rcontext, bool subcontext)
ArrayBuildStateArr * accumArrayResultArr(ArrayBuildStateArr *astate, Datum dvalue, bool disnull, Oid array_type, MemoryContext rcontext)
ArrayIterator array_create_iterator(ArrayType *arr, int slice_ndim, ArrayMetaState *mstate)
ArrayBuildState * initArrayResultWithSize(Oid element_type, MemoryContext rcontext, bool subcontext, int initsize)
ArrayType * construct_md_array(Datum *elems, bool *nulls, int ndims, int *dims, int *lbs, Oid elmtype, int elmlen, bool elmbyval, char elmalign)
ArrayBuildState * initArrayResult(Oid element_type, MemoryContext rcontext, bool subcontext)
Datum makeArrayResult(ArrayBuildState *astate, MemoryContext rcontext)
void deconstruct_array(const ArrayType *array, Oid elmtype, int elmlen, bool elmbyval, char elmalign, Datum **elemsp, bool **nullsp, int *nelemsp)
void array_bitmap_copy(bits8 *destbitmap, int destoffset, const bits8 *srcbitmap, int srcoffset, int nitems)
int ArrayGetNItems(int ndim, const int *dims)
void ArrayCheckBounds(int ndim, const int *dims, const int *lb)
#define Assert(condition)
#define OidIsValid(objectId)
Datum datumCopy(Datum value, bool typByVal, int typLen)
int errdetail(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
static Datum EOHPGetRWDatum(const struct ExpandedObjectHeader *eohptr)
#define palloc_array(type, count)
Datum FunctionCall2Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2)
void fmgr_info_cxt(Oid functionId, FmgrInfo *finfo, MemoryContext mcxt)
bytea * SendFunctionCall(FmgrInfo *flinfo, Datum val)
Oid get_fn_expr_argtype(FmgrInfo *flinfo, int argnum)
Datum ReceiveFunctionCall(FmgrInfo *flinfo, StringInfo buf, Oid typioparam, int32 typmod)
#define PG_FREE_IF_COPY(ptr, n)
#define PG_GETARG_BYTEA_PP(n)
#define PG_RETURN_BYTEA_P(x)
#define PG_GETARG_POINTER(n)
#define PG_GETARG_DATUM(n)
#define PG_RETURN_INT32(x)
#define PG_GETARG_INT32(n)
#define PG_GETARG_BOOL(n)
#define PG_RETURN_DATUM(x)
#define PG_RETURN_POINTER(x)
#define PG_GET_COLLATION()
static bool pg_sub_s32_overflow(int32 a, int32 b, int32 *result)
static bool pg_add_s32_overflow(int32 a, int32 b, int32 *result)
void getTypeBinaryOutputInfo(Oid type, Oid *typSend, bool *typIsVarlena)
Oid get_element_type(Oid typid)
void get_typlenbyvalalign(Oid typid, int16 *typlen, bool *typbyval, char *typalign)
void getTypeBinaryInputInfo(Oid type, Oid *typReceive, Oid *typIOParam)
void * MemoryContextAlloc(MemoryContext context, Size size)
void * MemoryContextAllocZero(MemoryContext context, Size size)
void * repalloc(void *pointer, Size size)
void pfree(void *pointer)
void * palloc0(Size size)
MemoryContext CurrentMemoryContext
int AggCheckCallContext(FunctionCallInfo fcinfo, MemoryContext *aggcontext)
#define IsA(nodeptr, _type_)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
static uint32 pg_nextpower2_32(uint32 num)
uint64 pg_prng_uint64_range(pg_prng_state *state, uint64 rmin, uint64 rmax)
pg_prng_state pg_global_prng_state
static char buf[DEFAULT_XLOG_SEG_SIZE]
static bool DatumGetBool(Datum X)
static Datum Int32GetDatum(int32 X)
static void initReadOnlyStringInfo(StringInfo str, char *data, int len)
ArrayMetaState array_meta
void tuplesort_performsort(Tuplesortstate *state)
void tuplesort_end(Tuplesortstate *state)
void tuplesort_putdatum(Tuplesortstate *state, Datum val, bool isNull)
Tuplesortstate * tuplesort_begin_datum(Oid datumType, Oid sortOperator, Oid sortCollation, bool nullsFirstFlag, int workMem, SortCoordinate coordinate, int sortopt)
bool tuplesort_getdatum(Tuplesortstate *state, bool forward, bool copy, Datum *val, bool *isNull, Datum *abbrev)
TypeCacheEntry * lookup_type_cache(Oid type_id, int flags)
#define TYPECACHE_EQ_OPR_FINFO
static Size VARSIZE_ANY_EXHDR(const void *PTR)
static Size VARSIZE(const void *PTR)
static char * VARDATA(const void *PTR)
static char * VARDATA_ANY(const void *PTR)
static void SET_VARSIZE(void *PTR, Size len)