MCPcopy Create free account
hub / github.com/apache/cloudberry / ExecEvalArrayExpr

Function ExecEvalArrayExpr

src/backend/executor/execExprInterp.c:2786–2988  ·  view source on GitHub ↗

* Evaluate an ARRAY[] expression. * * The individual array elements (or subarrays) have already been evaluated * into op->d.arrayexpr.elemvalues[]/elemnulls[]. */

Source from the content-addressed store, hash-verified

2784 * into op->d.arrayexpr.elemvalues[]/elemnulls[].
2785 */
2786void
2787ExecEvalArrayExpr(ExprState *state, ExprEvalStep *op)
2788{
2789 ArrayType *result;
2790 Oid element_type = op->d.arrayexpr.elemtype;
2791 int nelems = op->d.arrayexpr.nelems;
2792 int ndims = 0;
2793 int dims[MAXDIM];
2794 int lbs[MAXDIM];
2795
2796 /* Set non-null as default */
2797 *op->resnull = false;
2798
2799 if (!op->d.arrayexpr.multidims)
2800 {
2801 /* Elements are presumably of scalar type */
2802 Datum *dvalues = op->d.arrayexpr.elemvalues;
2803 bool *dnulls = op->d.arrayexpr.elemnulls;
2804
2805 /* setup for 1-D array of the given length */
2806 ndims = 1;
2807 dims[0] = nelems;
2808 lbs[0] = 1;
2809
2810 result = construct_md_array(dvalues, dnulls, ndims, dims, lbs,
2811 element_type,
2812 op->d.arrayexpr.elemlength,
2813 op->d.arrayexpr.elembyval,
2814 op->d.arrayexpr.elemalign);
2815 }
2816 else
2817 {
2818 /* Must be nested array expressions */
2819 int nbytes = 0;
2820 int nitems = 0;
2821 int outer_nelems = 0;
2822 int elem_ndims = 0;
2823 int *elem_dims = NULL;
2824 int *elem_lbs = NULL;
2825 bool firstone = true;
2826 bool havenulls = false;
2827 bool haveempty = false;
2828 char **subdata;
2829 bits8 **subbitmaps;
2830 int *subbytes;
2831 int *subnitems;
2832 int32 dataoffset;
2833 char *dat;
2834 int iitem;
2835
2836 subdata = (char **) palloc(nelems * sizeof(char *));
2837 subbitmaps = (bits8 **) palloc(nelems * sizeof(bits8 *));
2838 subbytes = (int *) palloc(nelems * sizeof(int));
2839 subnitems = (int *) palloc(nelems * sizeof(int));
2840
2841 /* loop through and get data area from each element */
2842 for (int elemoff = 0; elemoff < nelems; elemoff++)
2843 {

Callers 1

ExecInterpExprFunction · 0.85

Calls 10

construct_md_arrayFunction · 0.85
format_type_beFunction · 0.85
ArrayGetNItemsFunction · 0.85
construct_empty_arrayFunction · 0.85
ArrayCheckBoundsFunction · 0.85
array_bitmap_copyFunction · 0.85
pallocFunction · 0.50
errcodeFunction · 0.50
errmsgFunction · 0.50
errdetailFunction · 0.50

Tested by

no test coverage detected