* Free resources related to a spilled HashAgg. */
| 3456 | * Free resources related to a spilled HashAgg. |
| 3457 | */ |
| 3458 | static void |
| 3459 | hashagg_reset_spill_state(AggState *aggstate) |
| 3460 | { |
| 3461 | /* free spills from initial pass */ |
| 3462 | if (aggstate->hash_spills != NULL) |
| 3463 | { |
| 3464 | int setno; |
| 3465 | |
| 3466 | for (setno = 0; setno < aggstate->num_hashes; setno++) |
| 3467 | { |
| 3468 | HashAggSpill *spill = &aggstate->hash_spills[setno]; |
| 3469 | |
| 3470 | pfree(spill->ntuples); |
| 3471 | pfree(spill->partitions); |
| 3472 | } |
| 3473 | pfree(aggstate->hash_spills); |
| 3474 | aggstate->hash_spills = NULL; |
| 3475 | } |
| 3476 | |
| 3477 | /* free batches */ |
| 3478 | list_free_deep(aggstate->hash_batches); |
| 3479 | aggstate->hash_batches = NIL; |
| 3480 | |
| 3481 | /* close tape set */ |
| 3482 | if (aggstate->hash_tapeinfo != NULL) |
| 3483 | { |
| 3484 | HashTapeInfo *tapeinfo = aggstate->hash_tapeinfo; |
| 3485 | |
| 3486 | LogicalTapeSetClose(tapeinfo->tapeset); |
| 3487 | pfree(tapeinfo->freetapes); |
| 3488 | pfree(tapeinfo); |
| 3489 | aggstate->hash_tapeinfo = NULL; |
| 3490 | } |
| 3491 | } |
| 3492 | |
| 3493 | |
| 3494 | /* ----------------- |
no test coverage detected