82 #define MaxArraySize ((Size) (MaxAllocSize / sizeof(Datum)))
113 #define EA_MAGIC 689375833
261 #define DatumGetArrayTypeP(X) ((ArrayType *) PG_DETOAST_DATUM(X))
262 #define DatumGetArrayTypePCopy(X) ((ArrayType *) PG_DETOAST_DATUM_COPY(X))
263 #define PG_GETARG_ARRAYTYPE_P(n) DatumGetArrayTypeP(PG_GETARG_DATUM(n))
264 #define PG_GETARG_ARRAYTYPE_P_COPY(n) DatumGetArrayTypePCopy(PG_GETARG_DATUM(n))
265 #define PG_RETURN_ARRAYTYPE_P(x) PG_RETURN_POINTER(x)
268 #define PG_GETARG_EXPANDED_ARRAY(n) DatumGetExpandedArray(PG_GETARG_DATUM(n))
269 #define PG_GETARG_EXPANDED_ARRAYX(n, metacache) \
270 DatumGetExpandedArrayX(PG_GETARG_DATUM(n), metacache)
271 #define PG_RETURN_EXPANDED_ARRAY(x) PG_RETURN_DATUM(EOHPGetRWDatum(&(x)->hdr))
274 #define PG_GETARG_ANY_ARRAY_P(n) DatumGetAnyArrayP(PG_GETARG_DATUM(n))
289 #define ARR_SIZE(a) VARSIZE(a)
290 #define ARR_NDIM(a) ((a)->ndim)
291 #define ARR_HASNULL(a) ((a)->dataoffset != 0)
292 #define ARR_ELEMTYPE(a) ((a)->elemtype)
294 #define ARR_DIMS(a) \
295 ((int *) (((char *) (a)) + sizeof(ArrayType)))
296 #define ARR_LBOUND(a) \
297 ((int *) (((char *) (a)) + sizeof(ArrayType) + \
298 sizeof(int) * ARR_NDIM(a)))
300 #define ARR_NULLBITMAP(a) \
302 (bits8 *) (((char *) (a)) + sizeof(ArrayType) + \
303 2 * sizeof(int) * ARR_NDIM(a)) \
310 #define ARR_OVERHEAD_NONULLS(ndims) \
311 MAXALIGN(sizeof(ArrayType) + 2 * sizeof(int) * (ndims))
312 #define ARR_OVERHEAD_WITHNULLS(ndims, nitems) \
313 MAXALIGN(sizeof(ArrayType) + 2 * sizeof(int) * (ndims) + \
316 #define ARR_DATA_OFFSET(a) \
317 (ARR_HASNULL(a) ? (a)->dataoffset : ARR_OVERHEAD_NONULLS(ARR_NDIM(a)))
322 #define ARR_DATA_PTR(a) \
323 (((char *) (a)) + ARR_DATA_OFFSET(a))
328 #define AARR_NDIM(a) \
329 (VARATT_IS_EXPANDED_HEADER(a) ? \
330 (a)->xpn.ndims : ARR_NDIM((ArrayType *) (a)))
331 #define AARR_HASNULL(a) \
332 (VARATT_IS_EXPANDED_HEADER(a) ? \
333 ((a)->xpn.dvalues != NULL ? (a)->xpn.dnulls != NULL : ARR_HASNULL((a)->xpn.fvalue)) : \
334 ARR_HASNULL((ArrayType *) (a)))
335 #define AARR_ELEMTYPE(a) \
336 (VARATT_IS_EXPANDED_HEADER(a) ? \
337 (a)->xpn.element_type : ARR_ELEMTYPE((ArrayType *) (a)))
338 #define AARR_DIMS(a) \
339 (VARATT_IS_EXPANDED_HEADER(a) ? \
340 (a)->xpn.dims : ARR_DIMS((ArrayType *) (a)))
341 #define AARR_LBOUND(a) \
342 (VARATT_IS_EXPANDED_HEADER(a) ? \
343 (a)->xpn.lbound : ARR_LBOUND((ArrayType *) (a)))
364 int arraytyplen,
int elmlen,
bool elmbyval,
char elmalign,
367 Datum dataValue,
bool isNull,
368 int arraytyplen,
int elmlen,
bool elmbyval,
char elmalign);
370 int *upperIndx,
int *lowerIndx,
371 bool *upperProvided,
bool *lowerProvided,
372 int arraytyplen,
int elmlen,
bool elmbyval,
char elmalign);
374 int *upperIndx,
int *lowerIndx,
375 bool *upperProvided,
bool *lowerProvided,
376 Datum srcArrayDatum,
bool isNull,
377 int arraytyplen,
int elmlen,
bool elmbyval,
char elmalign);
380 int arraytyplen,
int elmlen,
bool elmbyval,
char elmalign,
383 Datum dataValue,
bool isNull,
384 int arraytyplen,
int elmlen,
bool elmbyval,
char elmalign);
391 const bits8 *srcbitmap,
int srcoffset,
396 int elmlen,
bool elmbyval,
char elmalign);
403 Oid elmtype,
int elmlen,
bool elmbyval,
char elmalign);
410 int elmlen,
bool elmbyval,
char elmalign,
411 Datum **elemsp,
bool **nullsp,
int *nelemsp);
414 Datum **elemsp,
bool **nullsp,
int *nelemsp);
421 bool subcontext,
int initsize);
423 Datum dvalue,
bool disnull,
434 Datum dvalue,
bool disnull,
443 Datum dvalue,
bool disnull,
457 extern int ArrayGetOffset(
int n,
const int *dim,
const int *lb,
const int *indx);
460 struct Node *escontext);
463 struct Node *escontext);
464 extern void mda_get_range(
int n,
int *span,
const int *st,
const int *endp);
struct ArrayMapState ArrayMapState
void mda_get_offset_values(int n, int *dist, const int *prod, const int *span)
ExpandedArrayHeader * DatumGetExpandedArray(Datum d)
int ArrayGetNItemsSafe(int ndim, const int *dims, struct Node *escontext)
bool array_contains_nulls(ArrayType *array)
ArrayBuildState * accumArrayResult(ArrayBuildState *astate, Datum dvalue, bool disnull, Oid element_type, MemoryContext rcontext)
ArrayBuildState * initArrayResult(Oid element_type, MemoryContext rcontext, bool subcontext)
ArrayType * construct_array_builtin(Datum *elems, int nelems, Oid elmtype)
struct ExpandedArrayHeader ExpandedArrayHeader
bool array_iterate(ArrayIterator iterator, Datum *value, bool *isnull)
bool ArrayCheckBoundsSafe(int ndim, const int *dims, const int *lb, struct Node *escontext)
ArrayBuildState * initArrayResultWithSize(Oid element_type, MemoryContext rcontext, bool subcontext, int initsize)
void array_free_iterator(ArrayIterator iterator)
int ArrayGetOffset(int n, const int *dim, const int *lb, const int *indx)
ArrayBuildStateArr * initArrayResultArr(Oid array_type, Oid element_type, MemoryContext rcontext, bool subcontext)
ArrayBuildStateAny * initArrayResultAny(Oid input_type, MemoryContext rcontext, bool subcontext)
ArrayBuildStateAny * accumArrayResultAny(ArrayBuildStateAny *astate, Datum dvalue, bool disnull, Oid input_type, MemoryContext rcontext)
void CopyArrayEls(ArrayType *array, Datum *values, bool *nulls, int nitems, int typlen, bool typbyval, char typalign, bool freedata)
struct ArrayBuildStateAny ArrayBuildStateAny
Datum expand_array(Datum arraydatum, MemoryContext parentcontext, ArrayMetaState *metacache)
ArrayType * array_set(ArrayType *array, int nSubscripts, int *indx, Datum dataValue, bool isNull, int arraytyplen, int elmlen, bool elmbyval, char elmalign)
Datum makeArrayResultArr(ArrayBuildStateArr *astate, MemoryContext rcontext, bool release)
void mda_get_range(int n, int *span, const int *st, const int *endp)
int ArrayGetNItems(int ndim, const int *dims)
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)
void mda_get_prod(int n, const int *range, int *prod)
PGDLLIMPORT bool Array_nulls
ExpandedArrayHeader * DatumGetExpandedArrayX(Datum d, ArrayMetaState *metacache)
void ArrayCheckBounds(int ndim, const int *dims, const int *lb)
struct ArrayMetaState ArrayMetaState
ArrayIterator array_create_iterator(ArrayType *arr, int slice_ndim, ArrayMetaState *mstate)
int mda_next_tuple(int n, int *curr, const int *span)
ArrayType * construct_empty_array(Oid elmtype)
ArrayType * construct_array(Datum *elems, int nelems, Oid elmtype, int elmlen, bool elmbyval, char elmalign)
struct ArrayIteratorData * ArrayIterator
AnyArrayType * DatumGetAnyArrayP(Datum d)
Datum array_ref(ArrayType *array, int nSubscripts, int *indx, int arraytyplen, int elmlen, bool elmbyval, char elmalign, bool *isNull)
Datum array_map(Datum arrayd, struct ExprState *exprstate, struct ExprContext *econtext, Oid retType, ArrayMapState *amstate)
struct ArrayBuildStateArr ArrayBuildStateArr
void deconstruct_array(ArrayType *array, Oid elmtype, int elmlen, bool elmbyval, char elmalign, Datum **elemsp, bool **nullsp, int *nelemsp)
void deconstruct_array_builtin(ArrayType *array, Oid elmtype, Datum **elemsp, bool **nullsp, int *nelemsp)
void deconstruct_expanded_array(ExpandedArrayHeader *eah)
ArrayBuildStateArr * accumArrayResultArr(ArrayBuildStateArr *astate, Datum dvalue, bool disnull, Oid array_type, MemoryContext rcontext)
Datum makeArrayResult(ArrayBuildState *astate, MemoryContext rcontext)
ArrayType * construct_md_array(Datum *elems, bool *nulls, int ndims, int *dims, int *lbs, Oid elmtype, int elmlen, bool elmbyval, char elmalign)
struct ArrayType ArrayType
void array_bitmap_copy(bits8 *destbitmap, int destoffset, const bits8 *srcbitmap, int srcoffset, int nitems)
int32 * ArrayGetIntegerTypmods(ArrayType *arr, int *n)
struct ArrayBuildState ArrayBuildState
Datum array_get_element(Datum arraydatum, int nSubscripts, int *indx, int arraytyplen, int elmlen, bool elmbyval, char elmalign, bool *isNull)
Datum array_get_slice(Datum arraydatum, int nSubscripts, int *upperIndx, int *lowerIndx, bool *upperProvided, bool *lowerProvided, int arraytyplen, int elmlen, bool elmbyval, char elmalign)
ExpandedArrayHeader * construct_empty_expanded_array(Oid element_type, MemoryContext parentcontext, ArrayMetaState *metacache)
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)
union AnyArrayType AnyArrayType
static Datum values[MAXATTR]
static struct cvec * range(struct vars *v, chr a, chr b, int cases)
ArrayBuildStateArr * arraystate
ArrayBuildState * scalarstate