PostgreSQL Source Code  git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
array.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * array.h
4  * Declarations for Postgres arrays.
5  *
6  * A standard varlena array has the following internal structure:
7  * <vl_len_> - standard varlena header word
8  * <ndim> - number of dimensions of the array
9  * <dataoffset> - offset to stored data, or 0 if no nulls bitmap
10  * <elemtype> - element type OID
11  * <dimensions> - length of each array axis (C array of int)
12  * <lower bnds> - lower boundary of each dimension (C array of int)
13  * <null bitmap> - bitmap showing locations of nulls (OPTIONAL)
14  * <actual data> - whatever is the stored data
15  *
16  * The <dimensions> and <lower bnds> arrays each have ndim elements.
17  *
18  * The <null bitmap> may be omitted if the array contains no NULL elements.
19  * If it is absent, the <dataoffset> field is zero and the offset to the
20  * stored data must be computed on-the-fly. If the bitmap is present,
21  * <dataoffset> is nonzero and is equal to the offset from the array start
22  * to the first data element (including any alignment padding). The bitmap
23  * follows the same conventions as tuple null bitmaps, ie, a 1 indicates
24  * a non-null entry and the LSB of each bitmap byte is used first.
25  *
26  * The actual data starts on a MAXALIGN boundary. Individual items in the
27  * array are aligned as specified by the array element type. They are
28  * stored in row-major order (last subscript varies most rapidly).
29  *
30  * NOTE: it is important that array elements of toastable datatypes NOT be
31  * toasted, since the tupletoaster won't know they are there. (We could
32  * support compressed toasted items; only out-of-line items are dangerous.
33  * However, it seems preferable to store such items uncompressed and allow
34  * the toaster to compress the whole array as one input.)
35  *
36  *
37  * The OIDVECTOR and INT2VECTOR datatypes are storage-compatible with
38  * generic arrays, but they support only one-dimensional arrays with no
39  * nulls (and no null bitmap). They don't support being toasted, either.
40  *
41  * There are also some "fixed-length array" datatypes, such as NAME and
42  * POINT. These are simply a sequence of a fixed number of items each
43  * of a fixed-length datatype, with no overhead; the item size must be
44  * a multiple of its alignment requirement, because we do no padding.
45  * We support subscripting on these types, but array_in() and array_out()
46  * only work with varlena arrays.
47  *
48  * In addition, arrays are a major user of the "expanded object" TOAST
49  * infrastructure. This allows a varlena array to be converted to a
50  * separate representation that may include "deconstructed" Datum/isnull
51  * arrays holding the elements.
52  *
53  *
54  * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
55  * Portions Copyright (c) 1994, Regents of the University of California
56  *
57  * src/include/utils/array.h
58  *
59  *-------------------------------------------------------------------------
60  */
61 #ifndef ARRAY_H
62 #define ARRAY_H
63 
64 #include "fmgr.h"
65 #include "utils/expandeddatum.h"
66 
67 /* avoid including execnodes.h here */
68 struct ExprState;
69 struct ExprContext;
70 
71 
72 /*
73  * Maximum number of array subscripts (arbitrary limit)
74  */
75 #define MAXDIM 6
76 
77 /*
78  * Maximum number of elements in an array. We limit this to at most about a
79  * quarter billion elements, so that it's not necessary to check for overflow
80  * in quite so many places --- for instance when palloc'ing Datum arrays.
81  */
82 #define MaxArraySize ((Size) (MaxAllocSize / sizeof(Datum)))
83 
84 /*
85  * Arrays are varlena objects, so must meet the varlena convention that
86  * the first int32 of the object contains the total object size in bytes.
87  * Be sure to use VARSIZE() and SET_VARSIZE() to access it, though!
88  *
89  * CAUTION: if you change the header for ordinary arrays you will also
90  * need to change the headers for oidvector and int2vector!
91  */
92 typedef struct ArrayType
93 {
94  int32 vl_len_; /* varlena header (do not touch directly!) */
95  int ndim; /* # of dimensions */
96  int32 dataoffset; /* offset to data, or 0 if no bitmap */
97  Oid elemtype; /* element type OID */
99 
100 /*
101  * An expanded array is contained within a private memory context (as
102  * all expanded objects must be) and has a control structure as below.
103  *
104  * The expanded array might contain a regular "flat" array if that was the
105  * original input and we've not modified it significantly. Otherwise, the
106  * contents are represented by Datum/isnull arrays plus dimensionality and
107  * type information. We could also have both forms, if we've deconstructed
108  * the original array for access purposes but not yet changed it. For pass-
109  * by-reference element types, the Datums would point into the flat array in
110  * this situation. Once we start modifying array elements, new pass-by-ref
111  * elements are separately palloc'd within the memory context.
112  */
113 #define EA_MAGIC 689375833 /* ID for debugging crosschecks */
114 
115 typedef struct ExpandedArrayHeader
116 {
117  /* Standard header for expanded objects */
119 
120  /* Magic value identifying an expanded array (for debugging only) */
121  int ea_magic;
122 
123  /* Dimensionality info (always valid) */
124  int ndims; /* # of dimensions */
125  int *dims; /* array dimensions */
126  int *lbound; /* index lower bounds for each dimension */
127 
128  /* Element type info (always valid) */
129  Oid element_type; /* element type OID */
130  int16 typlen; /* needed info about element datatype */
131  bool typbyval;
132  char typalign;
133 
134  /*
135  * If we have a Datum-array representation of the array, it's kept here;
136  * else dvalues/dnulls are NULL. The dvalues and dnulls arrays are always
137  * palloc'd within the object private context, but may change size from
138  * time to time. For pass-by-ref element types, dvalues entries might
139  * point either into the fstartptr..fendptr area, or to separately
140  * palloc'd chunks. Elements should always be fully detoasted, as they
141  * are in the standard flat representation.
142  *
143  * Even when dvalues is valid, dnulls can be NULL if there are no null
144  * elements.
145  */
146  Datum *dvalues; /* array of Datums */
147  bool *dnulls; /* array of is-null flags for Datums */
148  int dvalueslen; /* allocated length of above arrays */
149  int nelems; /* number of valid entries in above arrays */
150 
151  /*
152  * flat_size is the current space requirement for the flat equivalent of
153  * the expanded array, if known; otherwise it's 0. We store this to make
154  * consecutive calls of get_flat_size cheap.
155  */
157 
158  /*
159  * fvalue points to the flat representation if it is valid, else it is
160  * NULL. If we have or ever had a flat representation then
161  * fstartptr/fendptr point to the start and end+1 of its data area; this
162  * is so that we can tell which Datum pointers point into the flat
163  * representation rather than being pointers to separately palloc'd data.
164  */
165  ArrayType *fvalue; /* must be a fully detoasted array */
166  char *fstartptr; /* start of its data area */
167  char *fendptr; /* end+1 of its data area */
169 
170 /*
171  * Functions that can handle either a "flat" varlena array or an expanded
172  * array use this union to work with their input. Don't refer to "flt";
173  * instead, cast to ArrayType. This struct nominally requires 8-byte
174  * alignment on 64-bit, but it's often used for an ArrayType having 4-byte
175  * alignment. UBSan complains about referencing "flt" in such cases.
176  */
177 typedef union AnyArrayType
178 {
182 
183 /*
184  * working state for accumArrayResult() and friends
185  * note that the input must be scalars (legal array elements)
186  */
187 typedef struct ArrayBuildState
188 {
189  MemoryContext mcontext; /* where all the temp stuff is kept */
190  Datum *dvalues; /* array of accumulated Datums */
191  bool *dnulls; /* array of is-null flags for Datums */
192  int alen; /* allocated length of above arrays */
193  int nelems; /* number of valid entries in above arrays */
194  Oid element_type; /* data type of the Datums */
195  int16 typlen; /* needed info about datatype */
196  bool typbyval;
197  char typalign;
198  bool private_cxt; /* use private memory context */
200 
201 /*
202  * working state for accumArrayResultArr() and friends
203  * note that the input must be arrays, and the same array type is returned
204  */
205 typedef struct ArrayBuildStateArr
206 {
207  MemoryContext mcontext; /* where all the temp stuff is kept */
208  char *data; /* accumulated data */
209  bits8 *nullbitmap; /* bitmap of is-null flags, or NULL if none */
210  int abytes; /* allocated length of "data" */
211  int nbytes; /* number of bytes used so far */
212  int aitems; /* allocated length of bitmap (in elements) */
213  int nitems; /* total number of elements in result */
214  int ndims; /* current dimensions of result */
215  int dims[MAXDIM];
216  int lbs[MAXDIM];
217  Oid array_type; /* data type of the arrays */
218  Oid element_type; /* data type of the array elements */
219  bool private_cxt; /* use private memory context */
221 
222 /*
223  * working state for accumArrayResultAny() and friends
224  * these functions handle both cases
225  */
226 typedef struct ArrayBuildStateAny
227 {
228  /* Exactly one of these is not NULL: */
232 
233 /*
234  * structure to cache type metadata needed for array manipulation
235  */
236 typedef struct ArrayMetaState
237 {
240  bool typbyval;
241  char typalign;
242  char typdelim;
247 
248 /*
249  * private state needed by array_map (here because caller must provide it)
250  */
251 typedef struct ArrayMapState
252 {
256 
257 /* ArrayIteratorData is private in arrayfuncs.c */
259 
260 /* fmgr macros for regular varlena array objects */
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)
266 
267 /* fmgr macros for expanded array objects */
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))
272 
273 /* fmgr macros for AnyArrayType (ie, get either varlena or expanded form) */
274 #define PG_GETARG_ANY_ARRAY_P(n) DatumGetAnyArrayP(PG_GETARG_DATUM(n))
275 
276 /*
277  * Access macros for varlena array header fields.
278  *
279  * ARR_DIMS returns a pointer to an array of array dimensions (number of
280  * elements along the various array axes).
281  *
282  * ARR_LBOUND returns a pointer to an array of array lower bounds.
283  *
284  * That is: if the third axis of an array has elements 5 through 8, then
285  * ARR_DIMS(a)[2] == 4 and ARR_LBOUND(a)[2] == 5.
286  *
287  * Unlike C, the default lower bound is 1.
288  */
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)
293 
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)))
299 
300 #define ARR_NULLBITMAP(a) \
301  (ARR_HASNULL(a) ? \
302  (bits8 *) (((char *) (a)) + sizeof(ArrayType) + \
303  2 * sizeof(int) * ARR_NDIM(a)) \
304  : (bits8 *) NULL)
305 
306 /*
307  * The total array header size (in bytes) for an array with the specified
308  * number of dimensions and total number of items.
309  */
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) + \
314  ((nitems) + 7) / 8)
315 
316 #define ARR_DATA_OFFSET(a) \
317  (ARR_HASNULL(a) ? (a)->dataoffset : ARR_OVERHEAD_NONULLS(ARR_NDIM(a)))
318 
319 /*
320  * Returns a pointer to the actual array data.
321  */
322 #define ARR_DATA_PTR(a) \
323  (((char *) (a)) + ARR_DATA_OFFSET(a))
324 
325 /*
326  * Macros for working with AnyArrayType inputs. Beware multiple references!
327  */
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)))
344 
345 
346 /*
347  * GUC parameter
348  */
349 extern PGDLLIMPORT bool Array_nulls;
350 
351 /*
352  * prototypes for functions defined in arrayfuncs.c
353  */
354 extern void CopyArrayEls(ArrayType *array,
355  Datum *values,
356  bool *nulls,
357  int nitems,
358  int typlen,
359  bool typbyval,
360  char typalign,
361  bool freedata);
362 
363 extern Datum array_get_element(Datum arraydatum, int nSubscripts, int *indx,
364  int arraytyplen, int elmlen, bool elmbyval, char elmalign,
365  bool *isNull);
366 extern Datum array_set_element(Datum arraydatum, int nSubscripts, int *indx,
367  Datum dataValue, bool isNull,
368  int arraytyplen, int elmlen, bool elmbyval, char elmalign);
369 extern Datum array_get_slice(Datum arraydatum, int nSubscripts,
370  int *upperIndx, int *lowerIndx,
371  bool *upperProvided, bool *lowerProvided,
372  int arraytyplen, int elmlen, bool elmbyval, char elmalign);
373 extern Datum array_set_slice(Datum arraydatum, int nSubscripts,
374  int *upperIndx, int *lowerIndx,
375  bool *upperProvided, bool *lowerProvided,
376  Datum srcArrayDatum, bool isNull,
377  int arraytyplen, int elmlen, bool elmbyval, char elmalign);
378 
379 extern Datum array_ref(ArrayType *array, int nSubscripts, int *indx,
380  int arraytyplen, int elmlen, bool elmbyval, char elmalign,
381  bool *isNull);
382 extern ArrayType *array_set(ArrayType *array, int nSubscripts, int *indx,
383  Datum dataValue, bool isNull,
384  int arraytyplen, int elmlen, bool elmbyval, char elmalign);
385 
386 extern Datum array_map(Datum arrayd,
387  struct ExprState *exprstate, struct ExprContext *econtext,
388  Oid retType, ArrayMapState *amstate);
389 
390 extern void array_bitmap_copy(bits8 *destbitmap, int destoffset,
391  const bits8 *srcbitmap, int srcoffset,
392  int nitems);
393 
394 extern ArrayType *construct_array(Datum *elems, int nelems,
395  Oid elmtype,
396  int elmlen, bool elmbyval, char elmalign);
397 extern ArrayType *construct_array_builtin(Datum *elems, int nelems, Oid elmtype);
398 extern ArrayType *construct_md_array(Datum *elems,
399  bool *nulls,
400  int ndims,
401  int *dims,
402  int *lbs,
403  Oid elmtype, int elmlen, bool elmbyval, char elmalign);
404 extern ArrayType *construct_empty_array(Oid elmtype);
406  MemoryContext parentcontext,
407  ArrayMetaState *metacache);
408 extern void deconstruct_array(ArrayType *array,
409  Oid elmtype,
410  int elmlen, bool elmbyval, char elmalign,
411  Datum **elemsp, bool **nullsp, int *nelemsp);
412 extern void deconstruct_array_builtin(ArrayType *array,
413  Oid elmtype,
414  Datum **elemsp, bool **nullsp, int *nelemsp);
415 extern bool array_contains_nulls(ArrayType *array);
416 
417 extern ArrayBuildState *initArrayResult(Oid element_type,
418  MemoryContext rcontext, bool subcontext);
419 extern ArrayBuildState *initArrayResultWithSize(Oid element_type,
420  MemoryContext rcontext,
421  bool subcontext, int initsize);
423  Datum dvalue, bool disnull,
424  Oid element_type,
425  MemoryContext rcontext);
426 extern Datum makeArrayResult(ArrayBuildState *astate,
427  MemoryContext rcontext);
428 extern Datum makeMdArrayResult(ArrayBuildState *astate, int ndims,
429  int *dims, int *lbs, MemoryContext rcontext, bool release);
430 
431 extern ArrayBuildStateArr *initArrayResultArr(Oid array_type, Oid element_type,
432  MemoryContext rcontext, bool subcontext);
434  Datum dvalue, bool disnull,
435  Oid array_type,
436  MemoryContext rcontext);
438  MemoryContext rcontext, bool release);
439 
440 extern ArrayBuildStateAny *initArrayResultAny(Oid input_type,
441  MemoryContext rcontext, bool subcontext);
443  Datum dvalue, bool disnull,
444  Oid input_type,
445  MemoryContext rcontext);
447  MemoryContext rcontext, bool release);
448 
450 extern bool array_iterate(ArrayIterator iterator, Datum *value, bool *isnull);
451 extern void array_free_iterator(ArrayIterator iterator);
452 
453 /*
454  * prototypes for functions defined in arrayutils.c
455  */
456 
457 extern int ArrayGetOffset(int n, const int *dim, const int *lb, const int *indx);
458 extern int ArrayGetNItems(int ndim, const int *dims);
459 extern int ArrayGetNItemsSafe(int ndim, const int *dims,
460  struct Node *escontext);
461 extern void ArrayCheckBounds(int ndim, const int *dims, const int *lb);
462 extern bool ArrayCheckBoundsSafe(int ndim, const int *dims, const int *lb,
463  struct Node *escontext);
464 extern void mda_get_range(int n, int *span, const int *st, const int *endp);
465 extern void mda_get_prod(int n, const int *range, int *prod);
466 extern void mda_get_offset_values(int n, int *dist, const int *prod, const int *span);
467 extern int mda_next_tuple(int n, int *curr, const int *span);
468 extern int32 *ArrayGetIntegerTypmods(ArrayType *arr, int *n);
469 
470 /*
471  * prototypes for functions defined in array_expanded.c
472  */
473 extern Datum expand_array(Datum arraydatum, MemoryContext parentcontext,
474  ArrayMetaState *metacache);
477  ArrayMetaState *metacache);
480 
481 #endif /* ARRAY_H */
struct ArrayMapState ArrayMapState
void mda_get_offset_values(int n, int *dist, const int *prod, const int *span)
Definition: arrayutils.c:183
ExpandedArrayHeader * DatumGetExpandedArray(Datum d)
int ArrayGetNItemsSafe(int ndim, const int *dims, struct Node *escontext)
Definition: arrayutils.c:67
bool array_contains_nulls(ArrayType *array)
Definition: arrayfuncs.c:3767
ArrayBuildState * accumArrayResult(ArrayBuildState *astate, Datum dvalue, bool disnull, Oid element_type, MemoryContext rcontext)
Definition: arrayfuncs.c:5350
ArrayBuildState * initArrayResult(Oid element_type, MemoryContext rcontext, bool subcontext)
Definition: arrayfuncs.c:5293
ArrayType * construct_array_builtin(Datum *elems, int nelems, Oid elmtype)
Definition: arrayfuncs.c:3381
struct ExpandedArrayHeader ExpandedArrayHeader
bool array_iterate(ArrayIterator iterator, Datum *value, bool *isnull)
Definition: arrayfuncs.c:4676
bool ArrayCheckBoundsSafe(int ndim, const int *dims, const int *lb, struct Node *escontext)
Definition: arrayutils.c:127
ArrayBuildState * initArrayResultWithSize(Oid element_type, MemoryContext rcontext, bool subcontext, int initsize)
Definition: arrayfuncs.c:5310
void array_free_iterator(ArrayIterator iterator)
Definition: arrayfuncs.c:4759
int ArrayGetOffset(int n, const int *dim, const int *lb, const int *indx)
Definition: arrayutils.c:32
ArrayBuildStateArr * initArrayResultArr(Oid array_type, Oid element_type, MemoryContext rcontext, bool subcontext)
Definition: arrayfuncs.c:5504
ArrayBuildStateAny * initArrayResultAny(Oid input_type, MemoryContext rcontext, bool subcontext)
Definition: arrayfuncs.c:5782
ArrayBuildStateAny * accumArrayResultAny(ArrayBuildStateAny *astate, Datum dvalue, bool disnull, Oid input_type, MemoryContext rcontext)
Definition: arrayfuncs.c:5827
void CopyArrayEls(ArrayType *array, Datum *values, bool *nulls, int nitems, int typlen, bool typbyval, char typalign, bool freedata)
Definition: arrayfuncs.c:961
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)
Definition: arrayfuncs.c:3163
Datum makeArrayResultArr(ArrayBuildStateArr *astate, MemoryContext rcontext, bool release)
Definition: arrayfuncs.c:5703
void mda_get_range(int n, int *span, const int *st, const int *endp)
Definition: arrayutils.c:153
int ArrayGetNItems(int ndim, const int *dims)
Definition: arrayutils.c:57
Datum makeArrayResultAny(ArrayBuildStateAny *astate, MemoryContext rcontext, bool release)
Definition: arrayfuncs.c:5855
#define MAXDIM
Definition: array.h:75
Datum array_set_element(Datum arraydatum, int nSubscripts, int *indx, Datum dataValue, bool isNull, int arraytyplen, int elmlen, bool elmbyval, char elmalign)
Definition: arrayfuncs.c:2201
Datum makeMdArrayResult(ArrayBuildState *astate, int ndims, int *dims, int *lbs, MemoryContext rcontext, bool release)
Definition: arrayfuncs.c:5452
void mda_get_prod(int n, const int *range, int *prod)
Definition: arrayutils.c:167
PGDLLIMPORT bool Array_nulls
Definition: arrayfuncs.c:43
ExpandedArrayHeader * DatumGetExpandedArrayX(Datum d, ArrayMetaState *metacache)
void ArrayCheckBounds(int ndim, const int *dims, const int *lb)
Definition: arrayutils.c:117
struct ArrayMetaState ArrayMetaState
ArrayIterator array_create_iterator(ArrayType *arr, int slice_ndim, ArrayMetaState *mstate)
Definition: arrayfuncs.c:4597
int mda_next_tuple(int n, int *curr, const int *span)
Definition: arrayutils.c:208
ArrayType * construct_empty_array(Oid elmtype)
Definition: arrayfuncs.c:3580
ArrayType * construct_array(Datum *elems, int nelems, Oid elmtype, int elmlen, bool elmbyval, char elmalign)
Definition: arrayfuncs.c:3361
struct ArrayIteratorData * ArrayIterator
Definition: array.h:258
AnyArrayType * DatumGetAnyArrayP(Datum d)
Datum array_ref(ArrayType *array, int nSubscripts, int *indx, int arraytyplen, int elmlen, bool elmbyval, char elmalign, bool *isNull)
Definition: arrayfuncs.c:3146
Datum array_map(Datum arrayd, struct ExprState *exprstate, struct ExprContext *econtext, Oid retType, ArrayMapState *amstate)
Definition: arrayfuncs.c:3201
struct ArrayBuildStateArr ArrayBuildStateArr
void deconstruct_array(ArrayType *array, Oid elmtype, int elmlen, bool elmbyval, char elmalign, Datum **elemsp, bool **nullsp, int *nelemsp)
Definition: arrayfuncs.c:3631
void deconstruct_array_builtin(ArrayType *array, Oid elmtype, Datum **elemsp, bool **nullsp, int *nelemsp)
Definition: arrayfuncs.c:3697
void deconstruct_expanded_array(ExpandedArrayHeader *eah)
ArrayBuildStateArr * accumArrayResultArr(ArrayBuildStateArr *astate, Datum dvalue, bool disnull, Oid array_type, MemoryContext rcontext)
Definition: arrayfuncs.c:5550
Datum makeArrayResult(ArrayBuildState *astate, MemoryContext rcontext)
Definition: arrayfuncs.c:5420
ArrayType * construct_md_array(Datum *elems, bool *nulls, int ndims, int *dims, int *lbs, Oid elmtype, int elmlen, bool elmbyval, char elmalign)
Definition: arrayfuncs.c:3494
struct ArrayType ArrayType
void array_bitmap_copy(bits8 *destbitmap, int destoffset, const bits8 *srcbitmap, int srcoffset, int nitems)
Definition: arrayfuncs.c:4966
int32 * ArrayGetIntegerTypmods(ArrayType *arr, int *n)
Definition: arrayutils.c:233
struct ArrayBuildState ArrayBuildState
Datum array_get_element(Datum arraydatum, int nSubscripts, int *indx, int arraytyplen, int elmlen, bool elmbyval, char elmalign, bool *isNull)
Definition: arrayfuncs.c:1820
Datum array_get_slice(Datum arraydatum, int nSubscripts, int *upperIndx, int *lowerIndx, bool *upperProvided, bool *lowerProvided, int arraytyplen, int elmlen, bool elmbyval, char elmalign)
Definition: arrayfuncs.c:2030
ExpandedArrayHeader * construct_empty_expanded_array(Oid element_type, MemoryContext parentcontext, ArrayMetaState *metacache)
Definition: arrayfuncs.c:3597
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)
Definition: arrayfuncs.c:2806
union AnyArrayType AnyArrayType
static Datum values[MAXATTR]
Definition: bootstrap.c:151
#define PGDLLIMPORT
Definition: c.h:1321
signed short int16
Definition: c.h:507
signed int int32
Definition: c.h:508
uint8 bits8
Definition: c.h:524
size_t Size
Definition: c.h:610
#define nitems(x)
Definition: indent.h:31
static struct @160 value
char typalign
Definition: pg_type.h:176
uintptr_t Datum
Definition: postgres.h:64
unsigned int Oid
Definition: postgres_ext.h:31
static struct cvec * range(struct vars *v, chr a, chr b, int cases)
Definition: regc_locale.c:412
ArrayBuildStateArr * arraystate
Definition: array.h:230
ArrayBuildState * scalarstate
Definition: array.h:229
bits8 * nullbitmap
Definition: array.h:209
int lbs[MAXDIM]
Definition: array.h:216
bool private_cxt
Definition: array.h:219
MemoryContext mcontext
Definition: array.h:207
int dims[MAXDIM]
Definition: array.h:215
bool * dnulls
Definition: array.h:191
bool typbyval
Definition: array.h:196
MemoryContext mcontext
Definition: array.h:189
int16 typlen
Definition: array.h:195
bool private_cxt
Definition: array.h:198
char typalign
Definition: array.h:197
Oid element_type
Definition: array.h:194
Datum * dvalues
Definition: array.h:190
ArrayType * arr
Definition: arrayfuncs.c:71
ArrayMetaState inp_extra
Definition: array.h:253
ArrayMetaState ret_extra
Definition: array.h:254
Oid typioparam
Definition: array.h:243
char typalign
Definition: array.h:241
Oid typiofunc
Definition: array.h:244
int16 typlen
Definition: array.h:239
Oid element_type
Definition: array.h:238
FmgrInfo proc
Definition: array.h:245
char typdelim
Definition: array.h:242
bool typbyval
Definition: array.h:240
Oid elemtype
Definition: array.h:97
int ndim
Definition: array.h:95
int32 dataoffset
Definition: array.h:96
int32 vl_len_
Definition: array.h:94
char * fstartptr
Definition: array.h:166
char * fendptr
Definition: array.h:167
ExpandedObjectHeader hdr
Definition: array.h:118
Datum * dvalues
Definition: array.h:146
ArrayType * fvalue
Definition: array.h:165
Definition: fmgr.h:57
Definition: nodes.h:129
ArrayType flt
Definition: array.h:179
ExpandedArrayHeader xpn
Definition: array.h:180