MCPcopy Create free account
hub / github.com/apache/cloudberry / release_partition

Function release_partition

src/backend/executor/nodeWindowAgg.c:1573–1605  ·  view source on GitHub ↗

* release_partition * clear information kept within a partition, including * tuplestore and aggregate results. */

Source from the content-addressed store, hash-verified

1571 * tuplestore and aggregate results.
1572 */
1573static void
1574release_partition(WindowAggState *winstate)
1575{
1576 int i;
1577
1578 for (i = 0; i < winstate->numfuncs; i++)
1579 {
1580 WindowStatePerFunc perfuncstate = &(winstate->perfunc[i]);
1581
1582 /* Release any partition-local state of this window function */
1583 if (perfuncstate->winobj)
1584 perfuncstate->winobj->localmem = NULL;
1585 }
1586
1587 /*
1588 * Release all partition-local memory (in particular, any partition-local
1589 * state that we might have trashed our pointers to in the above loop, and
1590 * any aggregate temp data). We don't rely on retail pfree because some
1591 * aggregates might have allocated data we don't have direct pointers to.
1592 */
1593 MemoryContextResetAndDeleteChildren(winstate->partcontext);
1594 MemoryContextResetAndDeleteChildren(winstate->aggcontext);
1595 for (i = 0; i < winstate->numaggs; i++)
1596 {
1597 if (winstate->peragg[i].aggcontext != winstate->aggcontext)
1598 MemoryContextResetAndDeleteChildren(winstate->peragg[i].aggcontext);
1599 }
1600
1601 if (winstate->buffer)
1602 tuplestore_end(winstate->buffer);
1603 winstate->buffer = NULL;
1604 winstate->partition_spooled = false;
1605}
1606
1607/*
1608 * row_is_in_frame

Callers 3

ExecWindowAggFunction · 0.85
ExecEndWindowAggFunction · 0.85
ExecReScanWindowAggFunction · 0.85

Calls 1

tuplestore_endFunction · 0.85

Tested by

no test coverage detected