| 4659 | } |
| 4660 | |
| 4661 | void |
| 4662 | ExecEndAgg(AggState *node) |
| 4663 | { |
| 4664 | PlanState *outerPlan; |
| 4665 | |
| 4666 | ExecEagerFreeAgg(node); |
| 4667 | #if 0 |
| 4668 | /* The following code is wrapped in ExecEagerFreeAgg(). |
| 4669 | * Keep the code here to minimize code diverse with PG */ |
| 4670 | int transno; |
| 4671 | int numGroupingSets = Max(node->maxsets, 1); |
| 4672 | int setno; |
| 4673 | |
| 4674 | /* |
| 4675 | * When ending a parallel worker, copy the statistics gathered by the |
| 4676 | * worker back into shared memory so that it can be picked up by the main |
| 4677 | * process to report in EXPLAIN ANALYZE. |
| 4678 | */ |
| 4679 | if (node->shared_info && IsParallelWorker()) |
| 4680 | { |
| 4681 | AggregateInstrumentation *si; |
| 4682 | |
| 4683 | Assert(ParallelWorkerNumber <= node->shared_info->num_workers); |
| 4684 | si = &node->shared_info->sinstrument[ParallelWorkerNumber]; |
| 4685 | si->hash_batches_used = node->hash_batches_used; |
| 4686 | si->hash_disk_used = node->hash_disk_used; |
| 4687 | si->hash_mem_peak = node->hash_mem_peak; |
| 4688 | } |
| 4689 | |
| 4690 | /* Make sure we have closed any open tuplesorts */ |
| 4691 | |
| 4692 | if (node->sort_in) |
| 4693 | tuplesort_end(node->sort_in); |
| 4694 | if (node->sort_out) |
| 4695 | tuplesort_end(node->sort_out); |
| 4696 | |
| 4697 | hashagg_reset_spill_state(node); |
| 4698 | |
| 4699 | if (node->hash_metacxt != NULL) |
| 4700 | { |
| 4701 | MemoryContextDelete(node->hash_metacxt); |
| 4702 | node->hash_metacxt = NULL; |
| 4703 | } |
| 4704 | |
| 4705 | for (transno = 0; transno < node->numtrans; transno++) |
| 4706 | { |
| 4707 | AggStatePerTrans pertrans = &node->pertrans[transno]; |
| 4708 | |
| 4709 | for (setno = 0; setno < numGroupingSets; setno++) |
| 4710 | { |
| 4711 | if (pertrans->sortstates[setno]) |
| 4712 | tuplesort_end(pertrans->sortstates[setno]); |
| 4713 | } |
| 4714 | } |
| 4715 | |
| 4716 | /* And ensure any agg shutdown callbacks have been called */ |
| 4717 | for (setno = 0; setno < numGroupingSets; setno++) |
| 4718 | ReScanExprContext(node->aggcontexts[setno]); |
no test coverage detected