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

Function initArrayResultAny

src/backend/utils/adt/arrayfuncs.c:5665–5700  ·  view source on GitHub ↗

* initArrayResultAny - initialize an empty ArrayBuildStateAny * * input_type is the input datatype (either element or array type) * rcontext is where to keep working state * subcontext is a flag determining whether to use a separate memory context */

Source from the content-addressed store, hash-verified

5663 * subcontext is a flag determining whether to use a separate memory context
5664 */
5665ArrayBuildStateAny *
5666initArrayResultAny(Oid input_type, MemoryContext rcontext, bool subcontext)
5667{
5668 ArrayBuildStateAny *astate;
5669 Oid element_type = get_element_type(input_type);
5670
5671 if (OidIsValid(element_type))
5672 {
5673 /* Array case */
5674 ArrayBuildStateArr *arraystate;
5675
5676 arraystate = initArrayResultArr(input_type, InvalidOid, rcontext, subcontext);
5677 astate = (ArrayBuildStateAny *)
5678 MemoryContextAlloc(arraystate->mcontext,
5679 sizeof(ArrayBuildStateAny));
5680 astate->scalarstate = NULL;
5681 astate->arraystate = arraystate;
5682 }
5683 else
5684 {
5685 /* Scalar case */
5686 ArrayBuildState *scalarstate;
5687
5688 /* Let's just check that we have a type that can be put into arrays */
5689 Assert(OidIsValid(get_array_type(input_type)));
5690
5691 scalarstate = initArrayResult(input_type, rcontext, subcontext);
5692 astate = (ArrayBuildStateAny *)
5693 MemoryContextAlloc(scalarstate->mcontext,
5694 sizeof(ArrayBuildStateAny));
5695 astate->scalarstate = scalarstate;
5696 astate->arraystate = NULL;
5697 }
5698
5699 return astate;
5700}
5701
5702/*
5703 * accumArrayResultAny - accumulate one (more) input for an array result

Callers 3

accumArrayResultAnyFunction · 0.85
ExecScanSubPlanFunction · 0.85
ExecSetParamPlanFunction · 0.85

Calls 5

get_element_typeFunction · 0.85
initArrayResultArrFunction · 0.85
MemoryContextAllocFunction · 0.85
get_array_typeFunction · 0.85
initArrayResultFunction · 0.85

Tested by

no test coverage detected