* makeMdArrayResult - produce multi-D final result of accumArrayResult * * beware: no check that specified dimensions match the number of values * accumulated. * * Note: if the astate was not initialized within a separate memory context * (that is, initArrayResultWithSize was called with subcontext=false), then using * release=true is illegal. Instead, release astate along with the rest of
| 5333 | * release is true if okay to release working state |
| 5334 | */ |
| 5335 | Datum |
| 5336 | makeMdArrayResult(ArrayBuildState *astate, |
| 5337 | int ndims, |
| 5338 | int *dims, |
| 5339 | int *lbs, |
| 5340 | MemoryContext rcontext, |
| 5341 | bool release) |
| 5342 | { |
| 5343 | ArrayType *result; |
| 5344 | MemoryContext oldcontext; |
| 5345 | |
| 5346 | /* Build the final array result in rcontext */ |
| 5347 | oldcontext = MemoryContextSwitchTo(rcontext); |
| 5348 | |
| 5349 | result = construct_md_array(astate->dvalues, |
| 5350 | astate->dnulls, |
| 5351 | ndims, |
| 5352 | dims, |
| 5353 | lbs, |
| 5354 | astate->element_type, |
| 5355 | astate->typlen, |
| 5356 | astate->typbyval, |
| 5357 | astate->typalign); |
| 5358 | |
| 5359 | MemoryContextSwitchTo(oldcontext); |
| 5360 | |
| 5361 | /* Clean up all the junk */ |
| 5362 | if (release) |
| 5363 | { |
| 5364 | Assert(astate->private_cxt); |
| 5365 | MemoryContextDelete(astate->mcontext); |
| 5366 | } |
| 5367 | |
| 5368 | return PointerGetDatum(result); |
| 5369 | } |
| 5370 | |
| 5371 | /* |
| 5372 | * The following three functions provide essentially the same API as |
no test coverage detected