* 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 */
| 5663 | * subcontext is a flag determining whether to use a separate memory context |
| 5664 | */ |
| 5665 | ArrayBuildStateAny * |
| 5666 | initArrayResultAny(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 |
no test coverage detected