| 521 | } |
| 522 | |
| 523 | Datum |
| 524 | array_agg_finalfn(PG_FUNCTION_ARGS) |
| 525 | { |
| 526 | Datum result; |
| 527 | ArrayBuildState *state; |
| 528 | int dims[1]; |
| 529 | int lbs[1]; |
| 530 | |
| 531 | /* cannot be called directly because of internal-type argument */ |
| 532 | Assert(AggCheckCallContext(fcinfo, NULL)); |
| 533 | |
| 534 | state = PG_ARGISNULL(0) ? NULL : (ArrayBuildState *) PG_GETARG_POINTER(0); |
| 535 | |
| 536 | if (state == NULL) |
| 537 | PG_RETURN_NULL(); /* returns null iff no input values */ |
| 538 | |
| 539 | dims[0] = state->nelems; |
| 540 | lbs[0] = 1; |
| 541 | |
| 542 | /* |
| 543 | * Make the result. We cannot release the ArrayBuildState because |
| 544 | * sometimes aggregate final functions are re-executed. Rather, it is |
| 545 | * nodeAgg.c's responsibility to reset the aggcontext when it's safe to do |
| 546 | * so. |
| 547 | */ |
| 548 | result = makeMdArrayResult(state, 1, dims, lbs, |
| 549 | CurrentMemoryContext, |
| 550 | false); |
| 551 | |
| 552 | PG_RETURN_DATUM(result); |
| 553 | } |
| 554 | |
| 555 | Datum |
| 556 | array_agg_combine(PG_FUNCTION_ARGS) |
nothing calls this directly
no test coverage detected