34#include "utils/fmgroids.h"
51#define AARR_FREE_IF_COPY(array,n) \
53 if (!VARATT_IS_EXPANDED_HEADER(array)) \
54 PG_FREE_IF_COPY(array, n); \
101 int typlen,
bool typbyval,
char typalign,
110 int typlen,
bool typbyval,
char typalign,
116 int elmlen,
bool elmbyval,
char elmalign,
122 int elmlen,
bool elmbyval,
char elmalign);
127 int typlen,
bool typbyval,
uint8 typalignby,
130 int typlen,
bool typbyval,
char typalign);
135 int typlen,
bool typbyval,
char typalign);
137 int ndim,
int *dim,
int *lb,
139 int typlen,
bool typbyval,
char typalign);
141 int ndim,
int *dim,
int *lb,
144 int typlen,
bool typbyval,
char typalign);
147 int ndim,
int *dim,
int *lb,
149 int typlen,
bool typbyval,
char typalign);
159 bool remove,
Oid collation,
187 Node *escontext = fcinfo->context;
221 if (
my_extra->element_type != element_type)
231 fcinfo->flinfo->fn_mcxt);
232 my_extra->element_type = element_type;
268 errmsg(
"malformed array literal: \"%s\"",
string),
269 errdetail(
"Array value must start with \"{\" or dimension information.")));
277 errmsg(
"malformed array literal: \"%s\"",
string),
278 errdetail(
"Missing \"%s\" after array dimensions.",
288 errmsg(
"malformed array literal: \"%s\"",
string),
289 errdetail(
"Array contents must start with \"{\".")));
294 &
my_extra->proc, typioparam, typmod,
311 errmsg(
"malformed array literal: \"%s\"",
string),
312 errdetail(
"Junk after closing right brace.")));
339 errmsg(
"array size exceeds the maximum allowed (%zu)",
346 nbytes += dataoffset;
435 errmsg(
"number of array dimensions exceeds the maximum allowed (%d)",
445 errdetail(
"\"[\" must introduce explicitly-specified array dimensions.")));
459 errdetail(
"Missing array dimension value.")));
471 errdetail(
"Missing \"%s\" after array dimensions.",
485 errmsg(
"upper bound cannot be less than lower bound")));
491 errmsg(
"array upper bound is too large: %d",
ub)));
498 errmsg(
"array size exceeds the maximum allowed (%zu)",
530 if (!
isdigit((
unsigned char) *p) && *p !=
'-' && *p !=
'+')
542 errmsg(
"array bound is out of integer range")));
641 errdetail(
"Unexpected \"%c\" character.",
'{')));
647 errmsg(
"number of array dimensions exceeds the maximum allowed (%d)",
650 nelems[nest_level] = 0;
652 if (nest_level > ndim)
673 errdetail(
"Unexpected \"%c\" character.",
678 nelems[nest_level - 1]++;
685 if (dim[nest_level] < 0)
688 dim[nest_level] = nelems[nest_level];
690 else if (nelems[nest_level] != dim[nest_level])
708 errdetail(
"Unexpected \"%c\" character.",
723 errdetail(
"Unexpected array element.")));
731 errmsg(
"array size exceeds the maximum allowed (%zu)",
754 if (nest_level != ndim)
757 nelems[nest_level - 1]++;
766 }
while (nest_level > 0);
782 errdetail(
"Specified array dimensions do not match array contents.")));
787 errdetail(
"Multidimensional arrays must have sub-arrays with matching dimensions.")));
864 while (*(++p) !=
'\0')
866 if (*p == typdelim || *p ==
'}' || *p ==
'{')
875 errdetail(
"Incorrectly quoted array element.")));
902 errdetail(
"Unexpected \"%c\" character.",
909 errdetail(
"Incorrectly quoted array element.")));
921 if (*p == typdelim || *p ==
'}')
986 if (nulls && nulls[
i])
989 elog(
ERROR,
"null array element where not supported");
1002 if (bitmask == 0x100)
1011 if (bitmap && bitmask != 1)
1068 if (
my_extra->element_type != element_type)
1078 fcinfo->flinfo->fn_mcxt);
1079 my_extra->element_type = element_type;
1101 for (
i = 0;
i < ndim;
i++)
1148 for (tmp =
values[
i]; *tmp !=
'\0'; tmp++)
1153 if (
ch ==
'"' ||
ch ==
'\\')
1158 else if (
ch ==
'{' ||
ch ==
'}' ||
ch == typdelim ||
1179 for (
i =
j = 0, k = 1;
i < ndim;
i++)
1181 j += k, k *= dims[
i];
1191 for (
i = 0;
i < ndim;
i++)
1193 sprintf(ptr,
"[%d:%d]", lb[
i], lb[
i] + dims[
i] - 1);
1205#define APPENDSTR(str) (strcpy(p, (str)), p += strlen(p))
1206#define APPENDCHAR(ch) (*p++ = (ch), *p = '\0')
1211 for (
i = 0;
i < ndim;
i++)
1217 for (
i =
j;
i < ndim - 1;
i++)
1223 for (tmp =
values[k]; *tmp; tmp++)
1227 if (
ch ==
'"' ||
ch ==
'\\')
1238 for (
i = ndim - 1;
i >= 0;
i--)
1240 if (++(
indx[
i]) < dims[
i])
1305 errmsg(
"invalid number of dimensions: %d", ndim)));
1309 errmsg(
"number of array dimensions (%d) exceeds the maximum allowed (%d)",
1313 if (flags != 0 && flags != 1)
1316 errmsg(
"invalid array flags")));
1338 errmsg(
"binary data has array element type %u (%s) instead of expected %u (%s)",
1348 for (
i = 0;
i < ndim;
i++)
1372 if (
my_extra->element_type != element_type)
1382 errmsg(
"no binary input function available for type %s",
1385 fcinfo->flinfo->fn_mcxt);
1386 my_extra->element_type = element_type;
1403 &
my_extra->proc, typioparam, typmod,
1410 nbytes += dataoffset;
1419 retval->
ndim = ndim;
1486 errmsg(
"insufficient data left in message")));
1492 typioparam, typmod);
1507 typioparam, typmod);
1514 errmsg(
"improper binary format in array element %d",
1538 errmsg(
"array size exceeds the maximum allowed (%zu)",
1583 if (
my_extra->element_type != element_type)
1593 errmsg(
"no binary output function available for type %s",
1596 fcinfo->flinfo->fn_mcxt);
1597 my_extra->element_type = element_type;
1614 for (
i = 0;
i < ndim;
i++)
1889 for (
i = 0;
i < ndim;
i++)
1928 int elmlen,
bool elmbyval,
char elmalign,
1961 for (
i = 0;
i < ndim;
i++)
1981 dvalues =
eah->dvalues;
1982 dnulls =
eah->dnulls;
1987 if (dnulls && dnulls[offset])
2000 return dvalues[offset];
2071 errmsg(
"slices of fixed-length arrays not implemented")));
2118 for (;
i < ndim;
i++)
2140 bytes += dataoffset;
2160 for (
i = 0;
i < ndim;
i++)
2250 errmsg(
"wrong number of array subscripts")));
2255 errmsg(
"array subscript out of range")));
2260 errmsg(
"cannot assign null value to an element of a fixed-length array")));
2272 errmsg(
"wrong number of array subscripts")));
2275 if (elmlen == -1 && !isNull)
2321 errmsg(
"wrong number of array subscripts")));
2338 if (
indx[0] < lb[0])
2346 errmsg(
"array size exceeds the maximum allowed (%zu)",
2352 if (
indx[0] >= (dim[0] + lb[0]))
2361 errmsg(
"array size exceeds the maximum allowed (%zu)",
2373 for (
i = 0;
i < ndim;
i++)
2379 errmsg(
"array subscript out of range")));
2510 int elmlen,
bool elmbyval,
char elmalign)
2542 memcpy(dim,
eah->dims, ndim *
sizeof(
int));
2543 memcpy(lb,
eah->lbound, ndim *
sizeof(
int));
2575 errmsg(
"wrong number of array subscripts")));
2593 if (!
eah->typbyval && !isNull)
2601 dvalues =
eah->dvalues;
2602 dnulls =
eah->dnulls;
2615 if (
indx[0] < lb[0])
2623 errmsg(
"array size exceeds the maximum allowed (%zu)",
2630 if (
indx[0] >= (dim[0] + lb[0]))
2639 errmsg(
"array size exceeds the maximum allowed (%zu)",
2652 for (
i = 0;
i < ndim;
i++)
2658 errmsg(
"array subscript out of range")));
2673 if (dim[0] >
eah->dvalueslen)
2676 int newlen = dim[0] + dim[0] / 8;
2682 eah->dnulls = dnulls = (
bool *)
2692 eah->dnulls = dnulls = (
bool *)
2694 eah->dvalueslen *
sizeof(
bool));
2710 memcpy(
eah->dims, dim, ndim *
sizeof(
int));
2711 memcpy(
eah->lbound, lb, ndim *
sizeof(
int));
2737 dnulls[
eah->nelems +
i] =
true;
2743 if (!
eah->typbyval && (dnulls ==
NULL || !dnulls[offset]))
2751 dnulls[offset] = isNull;
2860 errmsg(
"updates on slices of fixed-length arrays not implemented")));
2884 &dvalues, &dnulls, &nelems);
2891 errmsg(
"array slice subscript must provide both boundaries"),
2892 errdetail(
"When assigning to a slice of an empty array value,"
2893 " slice boundaries must be fully specified.")));
2900 errmsg(
"array size exceeds the maximum allowed (%zu)",
2910 errmsg(
"source array too small")));
2920 errmsg(
"wrong number of array subscripts")));
2945 errmsg(
"upper bound cannot be less than lower bound")));
2954 errmsg(
"array size exceeds the maximum allowed (%zu)",
2969 errmsg(
"array size exceeds the maximum allowed (%zu)",
2990 errmsg(
"upper bound cannot be less than lower bound")));
2995 errmsg(
"array subscript out of range")));
2998 for (;
i < ndim;
i++)
3005 errmsg(
"upper bound cannot be less than lower bound")));
3022 errmsg(
"source array too small")));
3275 typlen = ret_extra->
typlen;
3311 errmsg(
"array size exceeds the maximum allowed (%zu)",
3320 nbytes += dataoffset;
3330 result->dataoffset = dataoffset;
3369 int elmlen,
bool elmbyval,
char elmalign)
3420 elmlen =
sizeof(
int16);
3426 elmlen =
sizeof(
int32);
3432 elmlen =
sizeof(
int64);
3445 elmlen =
sizeof(
Oid);
3469 elog(
ERROR,
"type %u not supported by construct_array_builtin()",
elmtype);
3518 errmsg(
"invalid number of dimensions: %d", ndims)));
3522 errmsg(
"number of array dimensions (%d) exceeds the maximum allowed (%d)",
3536 for (
i = 0;
i < nelems;
i++)
3538 if (nulls && nulls[
i])
3552 errmsg(
"array size exceeds the maximum allowed (%zu)",
3560 nbytes += dataoffset;
3570 result->dataoffset = dataoffset;
3576 elems, nulls, nelems,
3640 int elmlen,
bool elmbyval,
char elmalign,
3666 for (
i = 0;
i < nelems;
i++)
3669 if (bitmap && (*bitmap & bitmask) == 0)
3677 errmsg(
"null array element not allowed in this context")));
3690 if (bitmask == 0x100)
3734 elmlen =
sizeof(
int16);
3740 elmlen =
sizeof(
int32);
3746 elmlen =
sizeof(
Oid);
3764 elog(
ERROR,
"type %u not supported by deconstruct_array_builtin()",
elmtype);
3798 if (*bitmap != 0xFF)
3808 if ((*bitmap & bitmask) == 0)
3854 errmsg(
"cannot compare arrays of different element types")));
3870 if (typentry ==
NULL ||
3871 typentry->
type_id != element_type)
3878 errmsg(
"could not identify an equality operator for type %s",
3880 fcinfo->flinfo->fn_extra = typentry;
3882 typlen = typentry->
typlen;
4023 errmsg(
"cannot compare arrays of different element types")));
4032 if (typentry ==
NULL ||
4033 typentry->
type_id != element_type)
4040 errmsg(
"could not identify a comparison function for type %s",
4044 typlen = typentry->
typlen;
4193 if (typentry ==
NULL ||
4194 typentry->
type_id != element_type)
4201 errmsg(
"could not identify a hash function for type %s",
4237 fcinfo->flinfo->fn_extra = typentry;
4240 typlen = typentry->
typlen;
4321 if (typentry ==
NULL ||
4322 typentry->
type_id != element_type)
4329 errmsg(
"could not identify an extended hash function for type %s",
4331 fcinfo->flinfo->fn_extra = typentry;
4333 typlen = typentry->
typlen;
4414 errmsg(
"cannot compare arrays of different element types")));
4423 if (typentry ==
NULL ||
4424 typentry->
type_id != element_type)
4431 errmsg(
"could not identify an equality operator for type %s",
4433 *fn_extra = typentry;
4435 typlen = typentry->
typlen;
4454 element_type, typlen, typbyval,
typalign,
4544 &fcinfo->flinfo->fn_extra);
4562 &fcinfo->flinfo->fn_extra);
4580 &fcinfo->flinfo->fn_extra);
4618 elog(
ERROR,
"invalid arguments to array_create_iterator");
4726 bool *nulls =
iterator->slice_nulls;
4796 if (nullbitmap ==
NULL)
4798 if (nullbitmap[offset / 8] & (1 << (offset % 8)))
4815 nullbitmap += offset / 8;
4816 bitmask = 1 << (offset % 8);
4820 *nullbitmap |= bitmask;
4880 int typlen,
bool typbyval,
char typalign)
4887 if (typlen > 0 && !nullbitmap)
4893 nullbitmap += offset / 8;
4894 bitmask = 1 << (offset % 8);
4898 if (*nullbitmap & bitmask)
4904 if (bitmask == 0x100)
4929 int typlen,
bool typbyval,
char typalign)
4952 int typlen,
bool typbyval,
char typalign)
5052 int ndim,
int *dim,
int *lb,
5054 int typlen,
bool typbyval,
char typalign)
5080 for (
i = 0;
i < ndim;
i++)
5143 for (
i = 0;
i < ndim;
i++)
5229 for (
i = 0;
i < ndim;
i++)
5316 subcontext ? 64 : 8);
5344 astate->
dnulls = (
bool *)
5392 errmsg(
"array size exceeds the maximum allowed (%zu)",
5396 astate->
dnulls = (
bool *)
5410 if (astate->
typlen == -1)
5443 ndims = (astate->
nelems > 0) ? 1 : 0;
5444 dims[0] = astate->
nelems;
5533 errmsg(
"data type %s is not an array type",
5540 "accumArrayResultArr",
5588 errmsg(
"cannot accumulate null arrays")));
5608 if (astate->
ndims == 0)
5616 errmsg(
"cannot accumulate empty arrays")));
5620 errmsg(
"number of array dimensions (%d) exceeds the maximum allowed (%d)",
5627 astate->
ndims = ndims + 1;
5628 astate->
dims[0] = 0;
5629 memcpy(&astate->
dims[1], dims, ndims *
sizeof(
int));
5631 memcpy(&astate->
lbs[1], lbs, ndims *
sizeof(
int));
5640 if (astate->
ndims != ndims + 1)
5643 errmsg(
"cannot accumulate arrays of different dimensionality")));
5644 for (
i = 0;
i < ndims;
i++)
5646 if (astate->
dims[
i + 1] != dims[
i] || astate->
lbs[
i + 1] != lbs[
i])
5649 errmsg(
"cannot accumulate arrays of different dimensionality")));
5699 astate->
dims[0] += 1;
5728 if (astate->
ndims == 0)
5747 nbytes += dataoffset;
5758 result->dataoffset = dataoffset;
6019 errmsg(
"dimension array or low bound array cannot be null")));
6037 elog(
ERROR,
"could not determine data type of input");
6059 errmsg(
"dimension array or low bound array cannot be null")));
6076 elog(
ERROR,
"could not determine data type of input");
6091 result->dataoffset = dataoffset;
6122 errmsg(
"wrong number of array subscripts"),
6123 errdetail(
"Dimension array must be one dimensional.")));
6128 errmsg(
"dimension values cannot be null")));
6136 errmsg(
"invalid number of dimensions: %d", ndims)));
6140 errmsg(
"number of array dimensions (%d) exceeds the maximum allowed (%d)",
6148 errmsg(
"wrong number of array subscripts"),
6149 errdetail(
"Dimension array must be one dimensional.")));
6154 errmsg(
"dimension values cannot be null")));
6159 errmsg(
"wrong number of array subscripts"),
6160 errdetail(
"Low bound array has different size than dimensions array.")));
6233 errmsg(
"array size exceeds the maximum allowed (%zu)",
6255 nbytes = dataoffset;
6339 if (
fctx->nextelem <
fctx->numelems)
6341 int offset =
fctx->nextelem++;
6401 bool remove,
Oid collation,
6440 if (remove && ndim > 1)
6443 errmsg(
"removing elements from multidimensional arrays is not supported")));
6450 if (typentry ==
NULL ||
6451 typentry->
type_id != element_type)
6458 errmsg(
"could not identify an equality operator for type %s",
6462 typlen = typentry->
typlen;
6503 if (bitmap && (*bitmap & bitmask) == 0)
6579 errmsg(
"array size exceeds the maximum allowed (%zu)",
6589 if (bitmask == 0x100)
6619 nbytes += dataoffset;
6629 result->dataoffset = dataoffset;
6630 result->elemtype = element_type;
6721 errmsg(
"thresholds must be one-dimensional array")));
6726 errmsg(
"thresholds array must not contain NULLs")));
6737 if (typentry ==
NULL ||
6738 typentry->
type_id != element_type)
6745 errmsg(
"could not identify a comparison function for type %s",
6747 fcinfo->flinfo->fn_extra = typentry;
6754 if (typentry->
typlen > 0)
6756 collation, typentry);
6759 collation, typentry);
6799 while (left < right)
6801 int mid = (left + right) / 2;
6823 int typlen = typentry->
typlen;
6824 bool typbyval = typentry->
typbyval;
6840 while (left < right)
6842 int mid = (left + right) / 2;
6878 int typlen = typentry->
typlen;
6879 bool typbyval = typentry->
typbyval;
6893 while (left < right)
6895 int mid = (left + right) / 2;
6902 for (
i = left;
i < mid;
i++)
6960 errmsg(
"number of elements to trim must be between 0 and %d",
#define PG_GETARG_ANY_ARRAY_P(n)
#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)
Datum expand_array(Datum arraydatum, MemoryContext parentcontext, ArrayMetaState *metacache)
void deconstruct_expanded_array(ExpandedArrayHeader *eah)
ExpandedArrayHeader * DatumGetExpandedArray(Datum d)
AnyArrayType * DatumGetAnyArrayP(Datum d)
static Datum array_iter_next(array_iter *it, bool *isnull, int i)
static void array_iter_setup(array_iter *it, AnyArrayType *a, int elmlen, bool elmbyval, char elmalign)
Datum array_eq(PG_FUNCTION_ARGS)
Datum arraycontained(PG_FUNCTION_ARGS)
Datum array_lt(PG_FUNCTION_ARGS)
ArrayType * array_set(ArrayType *array, int nSubscripts, int *indx, Datum dataValue, bool isNull, int arraytyplen, int elmlen, bool elmbyval, char elmalign)
static bool ReadArrayStr(char **srcptr, FmgrInfo *inputproc, Oid typioparam, int32 typmod, char typdelim, int typlen, bool typbyval, char typalign, int *ndim_p, int *dim, int *nitems_p, Datum **values_p, bool **nulls_p, const char *origStr, Node *escontext)
Datum array_fill(PG_FUNCTION_ARGS)
Datum array_replace(PG_FUNCTION_ARGS)
static ArrayType * array_replace_internal(ArrayType *array, Datum search, bool search_isnull, Datum replace, bool replace_isnull, bool remove, Oid collation, FunctionCallInfo fcinfo)
Datum array_smaller(PG_FUNCTION_ARGS)
ArrayBuildState * accumArrayResult(ArrayBuildState *astate, Datum dvalue, bool disnull, Oid element_type, MemoryContext rcontext)
static bool ReadArrayDimensions(char **srcptr, int *ndim_p, int *dim, int *lBound, const char *origStr, Node *escontext)
static int array_nelems_size(char *ptr, int offset, uint8 *nullbitmap, int nitems, int typlen, bool typbyval, char typalign)
Datum array_cardinality(PG_FUNCTION_ARGS)
ExpandedArrayHeader * construct_empty_expanded_array(Oid element_type, MemoryContext parentcontext, ArrayMetaState *metacache)
bool array_iterate(ArrayIterator iterator, Datum *value, bool *isnull)
static Datum array_set_element_expanded(Datum arraydatum, int nSubscripts, int *indx, Datum dataValue, bool isNull, int arraytyplen, int elmlen, bool elmbyval, char elmalign)
void array_free_iterator(ArrayIterator iterator)
Datum array_recv(PG_FUNCTION_ARGS)
Datum generate_subscripts_nodir(PG_FUNCTION_ARGS)
Datum hash_array(PG_FUNCTION_ARGS)
static int width_bucket_array_float8(Datum operand, ArrayType *thresholds)
static int array_slice_size(char *arraydataptr, uint8 *arraynullsptr, int ndim, int *dim, int *lb, int *st, int *endp, int typlen, bool typbyval, char typalign)
ArrayBuildStateAny * initArrayResultAny(Oid input_type, MemoryContext rcontext, bool subcontext)
ArrayBuildStateAny * accumArrayResultAny(ArrayBuildStateAny *astate, Datum dvalue, bool disnull, Oid input_type, MemoryContext rcontext)
ArrayType * construct_empty_array(Oid elmtype)
Datum array_dims(PG_FUNCTION_ARGS)
void array_bitmap_copy(uint8 *destbitmap, int destoffset, const uint8 *srcbitmap, int srcoffset, int nitems)
bool array_contains_nulls(const ArrayType *array)
static ArrayToken ReadArrayToken(char **srcptr, StringInfo elembuf, char typdelim, const char *origStr, Node *escontext)
Datum arraycontains(PG_FUNCTION_ARGS)
Datum makeArrayResultArr(ArrayBuildStateArr *astate, MemoryContext rcontext, bool release)
#define AARR_FREE_IF_COPY(array, n)
Datum array_upper(PG_FUNCTION_ARGS)
Datum makeArrayResultAny(ArrayBuildStateAny *astate, MemoryContext rcontext, bool release)
static ArrayType * array_fill_internal(ArrayType *dims, ArrayType *lbs, Datum value, bool isnull, Oid elmtype, FunctionCallInfo fcinfo)
ArrayType * construct_array(Datum *elems, int nelems, Oid elmtype, int elmlen, bool elmbyval, char elmalign)
Datum array_map(Datum arrayd, ExprState *exprstate, ExprContext *econtext, Oid retType, ArrayMapState *amstate)
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)
static bool ReadDimensionInt(char **srcptr, int *result, const char *origStr, Node *escontext)
ArrayBuildStateArr * initArrayResultArr(Oid array_type, Oid element_type, MemoryContext rcontext, bool subcontext)
static bool array_contain_compare(AnyArrayType *array1, AnyArrayType *array2, Oid collation, bool matchall, void **fn_extra)
Datum array_lower(PG_FUNCTION_ARGS)
static int width_bucket_array_fixed(Datum operand, ArrayType *thresholds, Oid collation, TypeCacheEntry *typentry)
static int array_copy(char *destptr, int nitems, char *srcptr, int offset, uint8 *nullbitmap, int typlen, bool typbyval, char typalign)
ArrayBuildStateArr * accumArrayResultArr(ArrayBuildStateArr *astate, Datum dvalue, bool disnull, Oid array_type, MemoryContext rcontext)
static int array_cmp(FunctionCallInfo fcinfo)
ArrayIterator array_create_iterator(ArrayType *arr, int slice_ndim, ArrayMetaState *mstate)
Datum btarraycmp(PG_FUNCTION_ARGS)
Datum array_ref(ArrayType *array, int nSubscripts, int *indx, int arraytyplen, int elmlen, bool elmbyval, char elmalign, bool *isNull)
static void ReadArrayBinary(StringInfo buf, int nitems, FmgrInfo *receiveproc, Oid typioparam, int32 typmod, int typlen, bool typbyval, char typalign, Datum *values, bool *nulls, bool *hasnulls, int32 *nbytes)
static Datum array_get_element_expanded(Datum arraydatum, int nSubscripts, int *indx, int arraytyplen, int elmlen, bool elmbyval, char elmalign, bool *isNull)
ArrayBuildState * initArrayResultWithSize(Oid element_type, MemoryContext rcontext, bool subcontext, int initsize)
Datum hash_array_extended(PG_FUNCTION_ARGS)
Datum generate_subscripts(PG_FUNCTION_ARGS)
static void array_insert_slice(ArrayType *destArray, ArrayType *origArray, ArrayType *srcArray, int ndim, int *dim, int *lb, int *st, int *endp, int typlen, bool typbyval, char typalign)
Datum array_send(PG_FUNCTION_ARGS)
static void array_extract_slice(ArrayType *newarray, int ndim, int *dim, int *lb, char *arraydataptr, uint8 *arraynullsptr, int *st, int *endp, int typlen, bool typbyval, char typalign)
Datum array_le(PG_FUNCTION_ARGS)
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 array_gt(PG_FUNCTION_ARGS)
Datum array_unnest(PG_FUNCTION_ARGS)
static ArrayType * create_array_envelope(int ndims, int *dimv, int *lbsv, int nbytes, Oid elmtype, int dataoffset)
Datum array_remove(PG_FUNCTION_ARGS)
Datum array_ne(PG_FUNCTION_ARGS)
Datum array_larger(PG_FUNCTION_ARGS)
Datum array_in(PG_FUNCTION_ARGS)
ArrayType * construct_array_builtin(Datum *elems, int nelems, Oid elmtype)
static int width_bucket_array_variable(Datum operand, ArrayType *thresholds, Oid collation, TypeCacheEntry *typentry)
Datum array_length(PG_FUNCTION_ARGS)
void deconstruct_array_builtin(const ArrayType *array, Oid elmtype, Datum **elemsp, bool **nullsp, int *nelemsp)
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)
static int ArrayCastAndSet(Datum src, int typlen, bool typbyval, uint8 typalignby, char *dest)
static char * array_seek(char *ptr, int offset, uint8 *nullbitmap, int nitems, int typlen, bool typbyval, char typalign)
static Datum ArrayCast(char *value, bool byval, int len)
static bool array_get_isnull(const uint8 *nullbitmap, int offset)
Datum array_get_element(Datum arraydatum, int nSubscripts, int *indx, int arraytyplen, int elmlen, bool elmbyval, char elmalign, bool *isNull)
Datum array_out(PG_FUNCTION_ARGS)
Datum array_fill_with_lower_bounds(PG_FUNCTION_ARGS)
Datum array_ndims(PG_FUNCTION_ARGS)
Datum array_get_slice(Datum arraydatum, int nSubscripts, int *upperIndx, int *lowerIndx, bool *upperProvided, bool *lowerProvided, int arraytyplen, int elmlen, bool elmbyval, char elmalign)
Datum array_ge(PG_FUNCTION_ARGS)
Datum width_bucket_array(PG_FUNCTION_ARGS)
Datum arrayoverlap(PG_FUNCTION_ARGS)
Datum array_set_slice(Datum arraydatum, int nSubscripts, int *upperIndx, int *lowerIndx, bool *upperProvided, bool *lowerProvided, Datum srcArrayDatum, bool isNull, int arraytyplen, int elmlen, bool elmbyval, char elmalign)
static void array_set_isnull(uint8 *nullbitmap, int offset, bool isNull)
void CopyArrayEls(ArrayType *array, const Datum *values, const bool *nulls, int nitems, int typlen, bool typbyval, char typalign, bool freedata)
Datum trim_array(PG_FUNCTION_ARGS)
Datum array_unnest_support(PG_FUNCTION_ARGS)
void mda_get_offset_values(int n, int *dist, const int *prod, const int *span)
int ArrayGetOffset(int n, const int *dim, const int *lb, const int *indx)
void mda_get_range(int n, int *span, const int *st, const int *endp)
int ArrayGetNItems(int ndim, const int *dims)
void mda_get_prod(int n, const int *range, int *prod)
void ArrayCheckBounds(int ndim, const int *dims, const int *lb)
int mda_next_tuple(int n, int *curr, const int *span)
static Datum values[MAXATTR]
#define FORMAT_TYPE_ALLOW_INVALID
#define Assert(condition)
#define OidIsValid(objectId)
memcpy(sums, checksumBaseOffsets, sizeof(checksumBaseOffsets))
Node * estimate_expression_value(PlannerInfo *root, Node *node)
Datum datumCopy(Datum value, bool typByVal, int typLen)
int errcode(int sqlerrcode)
#define ereturn(context, dummy_value,...)
int errdetail(const char *fmt,...) pg_attribute_printf(1
#define ereport(elevel,...)
static Datum ExecEvalExpr(ExprState *state, ExprContext *econtext, bool *isNull)
ExpandedObjectHeader * DatumGetEOHP(Datum d)
#define VARATT_IS_EXPANDED_HEADER(PTR)
static Datum EOHPGetRWDatum(const struct ExpandedObjectHeader *eohptr)
#define palloc_object(type)
#define repalloc_array(pointer, type, count)
#define palloc_array(type, count)
#define palloc0_array(type, count)
#define palloc0_object(type)
void fmgr_info(Oid functionId, FmgrInfo *finfo)
void fmgr_info_cxt(Oid functionId, FmgrInfo *finfo, MemoryContext mcxt)
bytea * SendFunctionCall(FmgrInfo *flinfo, Datum val)
bool InputFunctionCallSafe(FmgrInfo *flinfo, char *str, Oid typioparam, int32 typmod, Node *escontext, Datum *result)
char * OutputFunctionCall(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_RETURN_UINT32(x)
#define PG_RETURN_BYTEA_P(x)
#define PG_DETOAST_DATUM_COPY(datum)
#define PG_GETARG_POINTER(n)
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
#define PG_RETURN_CSTRING(x)
#define PG_GETARG_DATUM(n)
#define LOCAL_FCINFO(name, nargs)
#define PG_GETARG_CSTRING(n)
#define PG_GETARG_INT64(n)
#define PG_RETURN_UINT64(x)
#define PG_DETOAST_DATUM(datum)
#define FunctionCallInvoke(fcinfo)
#define PG_RETURN_TEXT_P(x)
#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()
#define PG_RETURN_BOOL(x)
#define SRF_IS_FIRSTCALL()
#define SRF_PERCALL_SETUP()
#define SRF_RETURN_NEXT(_funcctx, _result)
#define SRF_FIRSTCALL_INIT()
#define SRF_RETURN_DONE(_funcctx)
static bool pg_sub_s32_overflow(int32 a, int32 b, int32 *result)
static bool pg_add_s32_overflow(int32 a, int32 b, int32 *result)
Oid get_element_type(Oid typid)
void get_typlenbyvalalign(Oid typid, int16 *typlen, bool *typbyval, char *typalign)
void get_type_io_data(Oid typid, IOFuncSelector which_func, int16 *typlen, bool *typbyval, char *typalign, char *typdelim, Oid *typioparam, Oid *func)
Oid get_array_type(Oid typid)
void * MemoryContextAlloc(MemoryContext context, Size size)
void * MemoryContextAllocZero(MemoryContext context, Size size)
char * pstrdup(const char *in)
void * repalloc(void *pointer, Size size)
void pfree(void *pointer)
void * palloc0(Size size)
void MemoryContextDelete(MemoryContext context)
#define AllocSetContextCreate
#define ALLOCSET_DEFAULT_SIZES
#define AllocSizeIsValid(size)
static bool is_funcclause(const void *clause)
#define IsA(nodeptr, _type_)
Datum lower(PG_FUNCTION_ARGS)
Datum upper(PG_FUNCTION_ARGS)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
static uint32 pg_nextpower2_32(uint32 num)
static const struct exclude_list_item skip[]
static char buf[DEFAULT_XLOG_SEG_SIZE]
int pg_strcasecmp(const char *s1, const char *s2)
static uint32 DatumGetUInt32(Datum X)
static Datum Int64GetDatum(int64 X)
static uint64 DatumGetUInt64(Datum X)
static bool DatumGetBool(Datum X)
static float8 DatumGetFloat8(Datum X)
static Pointer DatumGetPointer(Datum X)
static Datum Int32GetDatum(int32 X)
static int32 DatumGetInt32(Datum X)
#define PointerGetDatum(X)
bool scanner_isspace(char ch)
double estimate_array_length(PlannerInfo *root, Node *arrayexpr)
struct StringInfoData * StringInfo
void resetStringInfo(StringInfo str)
void appendStringInfoChar(StringInfo str, char ch)
void initStringInfo(StringInfo str)
static void initReadOnlyStringInfo(StringInfo str, char *data, int len)
ArrayBuildStateArr * arraystate
ArrayBuildState * scalarstate
bool * innermost_casenull
Datum * innermost_caseval
FmgrInfo hash_extended_proc_finfo
#define FirstGenbkiObjectId
#define att_nominal_alignby(cur_offset, attalignby)
#define att_addlength_pointer(cur_offset, attlen, attptr)
static uint8 typalign_to_alignby(char typalign)
static Datum fetch_att(const void *T, bool attbyval, int attlen)
#define att_addlength_datum(cur_offset, attlen, attdatum)
static void store_att_byval(void *T, Datum newdatum, int attlen)
TypeCacheEntry * lookup_type_cache(Oid type_id, int flags)
#define TYPECACHE_HASH_PROC_FINFO
#define TYPECACHE_EQ_OPR_FINFO
#define TYPECACHE_HASH_EXTENDED_PROC_FINFO
#define TYPECACHE_CMP_PROC_FINFO
static Size VARSIZE(const void *PTR)
static char * VARDATA(const void *PTR)
static bool VARATT_IS_EXTERNAL_EXPANDED(const void *PTR)
static void SET_VARSIZE(void *PTR, Size len)
text * cstring_to_text(const char *s)