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

Function ExecInitWindowAgg

src/backend/executor/nodeWindowAgg.c:2603–2888  ·  view source on GitHub ↗

----------------- * ExecInitWindowAgg * * Creates the run-time information for the WindowAgg node produced by the * planner and initializes its outer subtree * ----------------- */

Source from the content-addressed store, hash-verified

2601 * -----------------
2602 */
2603WindowAggState *
2604ExecInitWindowAgg(WindowAgg *node, EState *estate, int eflags)
2605{
2606 WindowAggState *winstate;
2607 Plan *outerPlan;
2608 ExprContext *econtext;
2609 ExprContext *tmpcontext;
2610 WindowStatePerFunc perfunc;
2611 WindowStatePerAgg peragg;
2612 int frameOptions = node->frameOptions;
2613 int numfuncs,
2614 wfuncno,
2615 numaggs,
2616 aggno;
2617 TupleDesc scanDesc;
2618 ListCell *l;
2619
2620 /* check for unsupported flags */
2621 Assert(!(eflags & (EXEC_FLAG_BACKWARD | EXEC_FLAG_MARK)));
2622
2623 /*
2624 * create state structure
2625 */
2626 winstate = makeNode(WindowAggState);
2627 winstate->ss.ps.plan = (Plan *) node;
2628 winstate->ss.ps.state = estate;
2629 winstate->ss.ps.ExecProcNode = ExecWindowAgg;
2630
2631 /*
2632 * Create expression contexts. We need two, one for per-input-tuple
2633 * processing and one for per-output-tuple processing. We cheat a little
2634 * by using ExecAssignExprContext() to build both.
2635 */
2636 ExecAssignExprContext(estate, &winstate->ss.ps);
2637 tmpcontext = winstate->ss.ps.ps_ExprContext;
2638 winstate->tmpcontext = tmpcontext;
2639 ExecAssignExprContext(estate, &winstate->ss.ps);
2640
2641 /* Create long-lived context for storage of partition-local memory etc */
2642 winstate->partcontext =
2643 AllocSetContextCreate(CurrentMemoryContext,
2644 "WindowAgg Partition",
2645 ALLOCSET_DEFAULT_SIZES);
2646
2647 /*
2648 * Create mid-lived context for aggregate trans values etc.
2649 *
2650 * Note that moving aggregates each use their own private context, not
2651 * this one.
2652 */
2653 winstate->aggcontext =
2654 AllocSetContextCreate(CurrentMemoryContext,
2655 "WindowAgg Aggregates",
2656 ALLOCSET_DEFAULT_SIZES);
2657
2658 /*
2659 * WindowAgg nodes never have quals, since they can only occur at the
2660 * logical top level of a query (ie, after any WHERE or HAVING filters)

Callers 1

ExecInitNodeFunction · 0.85

Calls 15

ExecAssignExprContextFunction · 0.85
ExecInitNodeFunction · 0.85
ExecInitExtraTupleSlotFunction · 0.85
ExecAssignProjectionInfoFunction · 0.85
execTuplesMatchPrepareFunction · 0.85
equalFunction · 0.85
pg_proc_aclcheckFunction · 0.85
GetUserIdFunction · 0.85
aclcheck_errorFunction · 0.85

Tested by

no test coverage detected