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

Function ExecEvalArrayCoerce

src/backend/executor/execExprInterp.c:2995–3028  ·  view source on GitHub ↗

* Evaluate an ArrayCoerceExpr expression. * * Source array is in step's result variable. */

Source from the content-addressed store, hash-verified

2993 * Source array is in step's result variable.
2994 */
2995void
2996ExecEvalArrayCoerce(ExprState *state, ExprEvalStep *op, ExprContext *econtext)
2997{
2998 Datum arraydatum;
2999
3000 /* NULL array -> NULL result */
3001 if (*op->resnull)
3002 return;
3003
3004 arraydatum = *op->resvalue;
3005
3006 /*
3007 * If it's binary-compatible, modify the element type in the array header,
3008 * but otherwise leave the array as we received it.
3009 */
3010 if (op->d.arraycoerce.elemexprstate == NULL)
3011 {
3012 /* Detoast input array if necessary, and copy in any case */
3013 ArrayType *array = DatumGetArrayTypePCopy(arraydatum);
3014
3015 ARR_ELEMTYPE(array) = op->d.arraycoerce.resultelemtype;
3016 *op->resvalue = PointerGetDatum(array);
3017 return;
3018 }
3019
3020 /*
3021 * Use array_map to apply the sub-expression to each array element.
3022 */
3023 *op->resvalue = array_map(arraydatum,
3024 op->d.arraycoerce.elemexprstate,
3025 econtext,
3026 op->d.arraycoerce.resultelemtype,
3027 op->d.arraycoerce.amstate);
3028}
3029
3030/*
3031 * Evaluate a ROW() expression.

Callers 1

ExecInterpExprFunction · 0.85

Calls 1

array_mapFunction · 0.85

Tested by

no test coverage detected