PostgreSQL Source Code git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
nodeWindowAgg.h File Reference
#include "nodes/execnodes.h"
Include dependency graph for nodeWindowAgg.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

WindowAggStateExecInitWindowAgg (WindowAgg *node, EState *estate, int eflags)
 
void ExecEndWindowAgg (WindowAggState *node)
 
void ExecReScanWindowAgg (WindowAggState *node)
 

Function Documentation

◆ ExecEndWindowAgg()

void ExecEndWindowAgg ( WindowAggState node)

Definition at line 2811 of file nodeWindowAgg.c.

2812{
2814 int i;
2815
2816 if (node->buffer != NULL)
2817 {
2818 tuplestore_end(node->buffer);
2819
2820 /* nullify so that release_partition skips the tuplestore_clear() */
2821 node->buffer = NULL;
2822 }
2823
2824 release_partition(node);
2825
2826 for (i = 0; i < node->numaggs; i++)
2827 {
2828 if (node->peragg[i].aggcontext != node->aggcontext)
2830 }
2833
2834 pfree(node->perfunc);
2835 pfree(node->peragg);
2836
2837 outerPlan = outerPlanState(node);
2839}
void ExecEndNode(PlanState *node)
Definition: execProcnode.c:562
#define outerPlanState(node)
Definition: execnodes.h:1261
int i
Definition: isn.c:77
void pfree(void *pointer)
Definition: mcxt.c:1594
void MemoryContextDelete(MemoryContext context)
Definition: mcxt.c:469
static void release_partition(WindowAggState *winstate)
#define outerPlan(node)
Definition: plannodes.h:261
MemoryContext aggcontext
Definition: execnodes.h:2688
WindowStatePerAgg peragg
Definition: execnodes.h:2638
MemoryContext partcontext
Definition: execnodes.h:2687
Tuplestorestate * buffer
Definition: execnodes.h:2641
WindowStatePerFunc perfunc
Definition: execnodes.h:2637
MemoryContext aggcontext
void tuplestore_end(Tuplestorestate *state)
Definition: tuplestore.c:492

References WindowStatePerAggData::aggcontext, WindowAggState::aggcontext, WindowAggState::buffer, ExecEndNode(), i, MemoryContextDelete(), WindowAggState::numaggs, outerPlan, outerPlanState, WindowAggState::partcontext, WindowAggState::peragg, WindowAggState::perfunc, pfree(), release_partition(), and tuplestore_end().

Referenced by ExecEndNode().

◆ ExecInitWindowAgg()

WindowAggState * ExecInitWindowAgg ( WindowAgg node,
EState estate,
int  eflags 
)

Definition at line 2498 of file nodeWindowAgg.c.

2499{
2500 WindowAggState *winstate;
2501 Plan *outerPlan;
2502 ExprContext *econtext;
2503 ExprContext *tmpcontext;
2504 WindowStatePerFunc perfunc;
2505 WindowStatePerAgg peragg;
2506 int frameOptions = node->frameOptions;
2507 int numfuncs,
2508 wfuncno,
2509 numaggs,
2510 aggno;
2511 TupleDesc scanDesc;
2512 ListCell *l;
2513
2514 /* check for unsupported flags */
2515 Assert(!(eflags & (EXEC_FLAG_BACKWARD | EXEC_FLAG_MARK)));
2516
2517 /*
2518 * create state structure
2519 */
2520 winstate = makeNode(WindowAggState);
2521 winstate->ss.ps.plan = (Plan *) node;
2522 winstate->ss.ps.state = estate;
2523 winstate->ss.ps.ExecProcNode = ExecWindowAgg;
2524
2525 /* copy frame options to state node for easy access */
2526 winstate->frameOptions = frameOptions;
2527
2528 /*
2529 * Create expression contexts. We need two, one for per-input-tuple
2530 * processing and one for per-output-tuple processing. We cheat a little
2531 * by using ExecAssignExprContext() to build both.
2532 */
2533 ExecAssignExprContext(estate, &winstate->ss.ps);
2534 tmpcontext = winstate->ss.ps.ps_ExprContext;
2535 winstate->tmpcontext = tmpcontext;
2536 ExecAssignExprContext(estate, &winstate->ss.ps);
2537
2538 /* Create long-lived context for storage of partition-local memory etc */
2539 winstate->partcontext =
2541 "WindowAgg Partition",
2543
2544 /*
2545 * Create mid-lived context for aggregate trans values etc.
2546 *
2547 * Note that moving aggregates each use their own private context, not
2548 * this one.
2549 */
2550 winstate->aggcontext =
2552 "WindowAgg Aggregates",
2554
2555 /* Only the top-level WindowAgg may have a qual */
2556 Assert(node->plan.qual == NIL || node->topWindow);
2557
2558 /* Initialize the qual */
2559 winstate->ss.ps.qual = ExecInitQual(node->plan.qual,
2560 (PlanState *) winstate);
2561
2562 /*
2563 * Setup the run condition, if we received one from the query planner.
2564 * When set, this may allow us to move into pass-through mode so that we
2565 * don't have to perform any further evaluation of WindowFuncs in the
2566 * current partition or possibly stop returning tuples altogether when all
2567 * tuples are in the same partition.
2568 */
2569 winstate->runcondition = ExecInitQual(node->runCondition,
2570 (PlanState *) winstate);
2571
2572 /*
2573 * When we're not the top-level WindowAgg node or we are but have a
2574 * PARTITION BY clause we must move into one of the WINDOWAGG_PASSTHROUGH*
2575 * modes when the runCondition becomes false.
2576 */
2577 winstate->use_pass_through = !node->topWindow || node->partNumCols > 0;
2578
2579 /* remember if we're the top-window or we are below the top-window */
2580 winstate->top_window = node->topWindow;
2581
2582 /*
2583 * initialize child nodes
2584 */
2585 outerPlan = outerPlan(node);
2586 outerPlanState(winstate) = ExecInitNode(outerPlan, estate, eflags);
2587
2588 /*
2589 * initialize source tuple type (which is also the tuple type that we'll
2590 * store in the tuplestore and use in all our working slots).
2591 */
2593 scanDesc = winstate->ss.ss_ScanTupleSlot->tts_tupleDescriptor;
2594
2595 /* the outer tuple isn't the child's tuple, but always a minimal tuple */
2596 winstate->ss.ps.outeropsset = true;
2597 winstate->ss.ps.outerops = &TTSOpsMinimalTuple;
2598 winstate->ss.ps.outeropsfixed = true;
2599
2600 /*
2601 * tuple table initialization
2602 */
2603 winstate->first_part_slot = ExecInitExtraTupleSlot(estate, scanDesc,
2605 winstate->agg_row_slot = ExecInitExtraTupleSlot(estate, scanDesc,
2607 winstate->temp_slot_1 = ExecInitExtraTupleSlot(estate, scanDesc,
2609 winstate->temp_slot_2 = ExecInitExtraTupleSlot(estate, scanDesc,
2611
2612 /*
2613 * create frame head and tail slots only if needed (must create slots in
2614 * exactly the same cases that update_frameheadpos and update_frametailpos
2615 * need them)
2616 */
2617 winstate->framehead_slot = winstate->frametail_slot = NULL;
2618
2619 if (frameOptions & (FRAMEOPTION_RANGE | FRAMEOPTION_GROUPS))
2620 {
2621 if (((frameOptions & FRAMEOPTION_START_CURRENT_ROW) &&
2622 node->ordNumCols != 0) ||
2623 (frameOptions & FRAMEOPTION_START_OFFSET))
2624 winstate->framehead_slot = ExecInitExtraTupleSlot(estate, scanDesc,
2626 if (((frameOptions & FRAMEOPTION_END_CURRENT_ROW) &&
2627 node->ordNumCols != 0) ||
2628 (frameOptions & FRAMEOPTION_END_OFFSET))
2629 winstate->frametail_slot = ExecInitExtraTupleSlot(estate, scanDesc,
2631 }
2632
2633 /*
2634 * Initialize result slot, type and projection.
2635 */
2637 ExecAssignProjectionInfo(&winstate->ss.ps, NULL);
2638
2639 /* Set up data for comparing tuples */
2640 if (node->partNumCols > 0)
2641 winstate->partEqfunction =
2642 execTuplesMatchPrepare(scanDesc,
2643 node->partNumCols,
2644 node->partColIdx,
2645 node->partOperators,
2646 node->partCollations,
2647 &winstate->ss.ps);
2648
2649 if (node->ordNumCols > 0)
2650 winstate->ordEqfunction =
2651 execTuplesMatchPrepare(scanDesc,
2652 node->ordNumCols,
2653 node->ordColIdx,
2654 node->ordOperators,
2655 node->ordCollations,
2656 &winstate->ss.ps);
2657
2658 /*
2659 * WindowAgg nodes use aggvalues and aggnulls as well as Agg nodes.
2660 */
2661 numfuncs = winstate->numfuncs;
2662 numaggs = winstate->numaggs;
2663 econtext = winstate->ss.ps.ps_ExprContext;
2664 econtext->ecxt_aggvalues = (Datum *) palloc0(sizeof(Datum) * numfuncs);
2665 econtext->ecxt_aggnulls = (bool *) palloc0(sizeof(bool) * numfuncs);
2666
2667 /*
2668 * allocate per-wfunc/per-agg state information.
2669 */
2670 perfunc = (WindowStatePerFunc) palloc0(sizeof(WindowStatePerFuncData) * numfuncs);
2671 peragg = (WindowStatePerAgg) palloc0(sizeof(WindowStatePerAggData) * numaggs);
2672 winstate->perfunc = perfunc;
2673 winstate->peragg = peragg;
2674
2675 wfuncno = -1;
2676 aggno = -1;
2677 foreach(l, winstate->funcs)
2678 {
2679 WindowFuncExprState *wfuncstate = (WindowFuncExprState *) lfirst(l);
2680 WindowFunc *wfunc = wfuncstate->wfunc;
2681 WindowStatePerFunc perfuncstate;
2682 AclResult aclresult;
2683 int i;
2684
2685 if (wfunc->winref != node->winref) /* planner screwed up? */
2686 elog(ERROR, "WindowFunc with winref %u assigned to WindowAgg with winref %u",
2687 wfunc->winref, node->winref);
2688
2689 /*
2690 * Look for a previous duplicate window function, which needs the same
2691 * ignore_nulls value
2692 */
2693 for (i = 0; i <= wfuncno; i++)
2694 {
2695 if (equal(wfunc, perfunc[i].wfunc) &&
2696 !contain_volatile_functions((Node *) wfunc))
2697 break;
2698 }
2699 if (i <= wfuncno && wfunc->ignore_nulls == perfunc[i].ignore_nulls)
2700 {
2701 /* Found a match to an existing entry, so just mark it */
2702 wfuncstate->wfuncno = i;
2703 continue;
2704 }
2705
2706 /* Nope, so assign a new PerAgg record */
2707 perfuncstate = &perfunc[++wfuncno];
2708
2709 /* Mark WindowFunc state node with assigned index in the result array */
2710 wfuncstate->wfuncno = wfuncno;
2711
2712 /* Check permission to call window function */
2713 aclresult = object_aclcheck(ProcedureRelationId, wfunc->winfnoid, GetUserId(),
2714 ACL_EXECUTE);
2715 if (aclresult != ACLCHECK_OK)
2717 get_func_name(wfunc->winfnoid));
2718 InvokeFunctionExecuteHook(wfunc->winfnoid);
2719
2720 /* Fill in the perfuncstate data */
2721 perfuncstate->wfuncstate = wfuncstate;
2722 perfuncstate->wfunc = wfunc;
2723 perfuncstate->numArguments = list_length(wfuncstate->args);
2724 perfuncstate->winCollation = wfunc->inputcollid;
2725
2726 get_typlenbyval(wfunc->wintype,
2727 &perfuncstate->resulttypeLen,
2728 &perfuncstate->resulttypeByVal);
2729
2730 /*
2731 * If it's really just a plain aggregate function, we'll emulate the
2732 * Agg environment for it.
2733 */
2734 perfuncstate->plain_agg = wfunc->winagg;
2735 if (wfunc->winagg)
2736 {
2737 WindowStatePerAgg peraggstate;
2738
2739 perfuncstate->aggno = ++aggno;
2740 peraggstate = &winstate->peragg[aggno];
2741 initialize_peragg(winstate, wfunc, peraggstate);
2742 peraggstate->wfuncno = wfuncno;
2743 }
2744 else
2745 {
2747
2748 winobj->winstate = winstate;
2749 winobj->argstates = wfuncstate->args;
2750 winobj->localmem = NULL;
2751 perfuncstate->winobj = winobj;
2752 winobj->ignore_nulls = wfunc->ignore_nulls;
2753 init_notnull_info(winobj, perfuncstate);
2754
2755 /* It's a real window function, so set up to call it. */
2756 fmgr_info_cxt(wfunc->winfnoid, &perfuncstate->flinfo,
2757 econtext->ecxt_per_query_memory);
2758 fmgr_info_set_expr((Node *) wfunc, &perfuncstate->flinfo);
2759 }
2760 }
2761
2762 /* Update numfuncs, numaggs to match number of unique functions found */
2763 winstate->numfuncs = wfuncno + 1;
2764 winstate->numaggs = aggno + 1;
2765
2766 /* Set up WindowObject for aggregates, if needed */
2767 if (winstate->numaggs > 0)
2768 {
2770
2771 agg_winobj->winstate = winstate;
2772 agg_winobj->argstates = NIL;
2773 agg_winobj->localmem = NULL;
2774 /* make sure markptr = -1 to invalidate. It may not get used */
2775 agg_winobj->markptr = -1;
2776 agg_winobj->readptr = -1;
2777 winstate->agg_winobj = agg_winobj;
2778 }
2779
2780 /* Set the status to running */
2781 winstate->status = WINDOWAGG_RUN;
2782
2783 /* initialize frame bound offset expressions */
2784 winstate->startOffset = ExecInitExpr((Expr *) node->startOffset,
2785 (PlanState *) winstate);
2786 winstate->endOffset = ExecInitExpr((Expr *) node->endOffset,
2787 (PlanState *) winstate);
2788
2789 /* Lookup in_range support functions if needed */
2790 if (OidIsValid(node->startInRangeFunc))
2791 fmgr_info(node->startInRangeFunc, &winstate->startInRangeFunc);
2792 if (OidIsValid(node->endInRangeFunc))
2793 fmgr_info(node->endInRangeFunc, &winstate->endInRangeFunc);
2794 winstate->inRangeColl = node->inRangeColl;
2795 winstate->inRangeAsc = node->inRangeAsc;
2796 winstate->inRangeNullsFirst = node->inRangeNullsFirst;
2797
2798 winstate->all_first = true;
2799 winstate->partition_spooled = false;
2800 winstate->more_partitions = false;
2801 winstate->next_partition = true;
2802
2803 return winstate;
2804}
AclResult
Definition: acl.h:182
@ ACLCHECK_OK
Definition: acl.h:183
void aclcheck_error(AclResult aclerr, ObjectType objtype, const char *objectname)
Definition: aclchk.c:2652
AclResult object_aclcheck(Oid classid, Oid objectid, Oid roleid, AclMode mode)
Definition: aclchk.c:3834
#define OidIsValid(objectId)
Definition: c.h:778
bool contain_volatile_functions(Node *clause)
Definition: clauses.c:542
#define ERROR
Definition: elog.h:39
#define elog(elevel,...)
Definition: elog.h:226
bool equal(const void *a, const void *b)
Definition: equalfuncs.c:223
ExprState * ExecInitExpr(Expr *node, PlanState *parent)
Definition: execExpr.c:143
ExprState * ExecInitQual(List *qual, PlanState *parent)
Definition: execExpr.c:229
ExprState * execTuplesMatchPrepare(TupleDesc desc, int numCols, const AttrNumber *keyColIdx, const Oid *eqOperators, const Oid *collations, PlanState *parent)
Definition: execGrouping.c:58
PlanState * ExecInitNode(Plan *node, EState *estate, int eflags)
Definition: execProcnode.c:142
const TupleTableSlotOps TTSOpsVirtual
Definition: execTuples.c:84
TupleTableSlot * ExecInitExtraTupleSlot(EState *estate, TupleDesc tupledesc, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:2020
void ExecInitResultTupleSlotTL(PlanState *planstate, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:1988
const TupleTableSlotOps TTSOpsMinimalTuple
Definition: execTuples.c:86
void ExecCreateScanSlotFromOuterPlan(EState *estate, ScanState *scanstate, const TupleTableSlotOps *tts_ops)
Definition: execUtils.c:704
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Definition: execUtils.c:485
void ExecAssignProjectionInfo(PlanState *planstate, TupleDesc inputDesc)
Definition: execUtils.c:583
struct WindowStatePerAggData * WindowStatePerAgg
Definition: execnodes.h:2614
@ WINDOWAGG_RUN
Definition: execnodes.h:2622
struct WindowStatePerFuncData * WindowStatePerFunc
Definition: execnodes.h:2613
#define EXEC_FLAG_BACKWARD
Definition: executor.h:69
#define EXEC_FLAG_MARK
Definition: executor.h:70
void fmgr_info(Oid functionId, FmgrInfo *finfo)
Definition: fmgr.c:128
void fmgr_info_cxt(Oid functionId, FmgrInfo *finfo, MemoryContext mcxt)
Definition: fmgr.c:138
#define fmgr_info_set_expr(expr, finfo)
Definition: fmgr.h:135
Assert(PointerIsAligned(start, uint64))
void get_typlenbyval(Oid typid, int16 *typlen, bool *typbyval)
Definition: lsyscache.c:2418
char * get_func_name(Oid funcid)
Definition: lsyscache.c:1775
void * palloc0(Size size)
Definition: mcxt.c:1395
MemoryContext CurrentMemoryContext
Definition: mcxt.c:160
#define AllocSetContextCreate
Definition: memutils.h:129
#define ALLOCSET_DEFAULT_SIZES
Definition: memutils.h:160
Oid GetUserId(void)
Definition: miscinit.c:469
static TupleTableSlot * ExecWindowAgg(PlanState *pstate)
static void init_notnull_info(WindowObject winobj, WindowStatePerFunc perfuncstate)
static WindowStatePerAggData * initialize_peragg(WindowAggState *winstate, WindowFunc *wfunc, WindowStatePerAgg peraggstate)
#define makeNode(_type_)
Definition: nodes.h:161
#define InvokeFunctionExecuteHook(objectId)
Definition: objectaccess.h:213
#define FRAMEOPTION_END_CURRENT_ROW
Definition: parsenodes.h:619
#define FRAMEOPTION_END_OFFSET
Definition: parsenodes.h:630
#define FRAMEOPTION_START_CURRENT_ROW
Definition: parsenodes.h:618
#define FRAMEOPTION_START_OFFSET
Definition: parsenodes.h:628
@ OBJECT_FUNCTION
Definition: parsenodes.h:2344
#define FRAMEOPTION_RANGE
Definition: parsenodes.h:610
#define FRAMEOPTION_GROUPS
Definition: parsenodes.h:612
#define ACL_EXECUTE
Definition: parsenodes.h:83
#define lfirst(lc)
Definition: pg_list.h:172
static int list_length(const List *l)
Definition: pg_list.h:152
#define NIL
Definition: pg_list.h:68
uint64_t Datum
Definition: postgres.h:70
Datum * ecxt_aggvalues
Definition: execnodes.h:292
bool * ecxt_aggnulls
Definition: execnodes.h:294
MemoryContext ecxt_per_query_memory
Definition: execnodes.h:280
Definition: nodes.h:135
bool outeropsset
Definition: execnodes.h:1248
const TupleTableSlotOps * outerops
Definition: execnodes.h:1240
ExprState * qual
Definition: execnodes.h:1186
Plan * plan
Definition: execnodes.h:1165
bool outeropsfixed
Definition: execnodes.h:1244
EState * state
Definition: execnodes.h:1167
ExprContext * ps_ExprContext
Definition: execnodes.h:1204
ExecProcNodeMtd ExecProcNode
Definition: execnodes.h:1171
List * qual
Definition: plannodes.h:231
TupleTableSlot * ss_ScanTupleSlot
Definition: execnodes.h:1624
PlanState ps
Definition: execnodes.h:1621
TupleDesc tts_tupleDescriptor
Definition: tuptable.h:122
ExprState * endOffset
Definition: execnodes.h:2658
ScanState ss
Definition: execnodes.h:2630
FmgrInfo endInRangeFunc
Definition: execnodes.h:2664
TupleTableSlot * framehead_slot
Definition: execnodes.h:2707
bool next_partition
Definition: execnodes.h:2695
bool partition_spooled
Definition: execnodes.h:2693
FmgrInfo startInRangeFunc
Definition: execnodes.h:2663
bool more_partitions
Definition: execnodes.h:2696
TupleTableSlot * frametail_slot
Definition: execnodes.h:2708
ExprState * ordEqfunction
Definition: execnodes.h:2640
ExprState * runcondition
Definition: execnodes.h:2675
TupleTableSlot * temp_slot_2
Definition: execnodes.h:2713
WindowAggStatus status
Definition: execnodes.h:2654
TupleTableSlot * agg_row_slot
Definition: execnodes.h:2711
struct WindowObjectData * agg_winobj
Definition: execnodes.h:2651
bool inRangeNullsFirst
Definition: execnodes.h:2667
ExprState * partEqfunction
Definition: execnodes.h:2639
ExprState * startOffset
Definition: execnodes.h:2657
TupleTableSlot * first_part_slot
Definition: execnodes.h:2705
ExprContext * tmpcontext
Definition: execnodes.h:2690
TupleTableSlot * temp_slot_1
Definition: execnodes.h:2712
bool use_pass_through
Definition: execnodes.h:2670
int partNumCols
Definition: plannodes.h:1241
Oid endInRangeFunc
Definition: plannodes.h:1285
Node * endOffset
Definition: plannodes.h:1271
bool topWindow
Definition: plannodes.h:1300
Plan plan
Definition: plannodes.h:1232
Oid inRangeColl
Definition: plannodes.h:1288
Node * startOffset
Definition: plannodes.h:1268
List * runCondition
Definition: plannodes.h:1274
Oid startInRangeFunc
Definition: plannodes.h:1282
bool inRangeAsc
Definition: plannodes.h:1291
Index winref
Definition: plannodes.h:1238
bool inRangeNullsFirst
Definition: plannodes.h:1294
int ordNumCols
Definition: plannodes.h:1253
int frameOptions
Definition: plannodes.h:1265
WindowFunc * wfunc
Definition: execnodes.h:923
Index winref
Definition: primnodes.h:611
WindowAggState * winstate
Definition: nodeWindowAgg.c:65
WindowFuncExprState * wfuncstate
Definition: nodeWindowAgg.c:91

References ACL_EXECUTE, aclcheck_error(), ACLCHECK_OK, WindowAggState::agg_row_slot, WindowAggState::agg_winobj, WindowAggState::aggcontext, WindowStatePerFuncData::aggno, WindowAggState::all_first, ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, WindowFuncExprState::args, WindowObjectData::argstates, Assert(), contain_volatile_functions(), CurrentMemoryContext, ExprContext::ecxt_aggnulls, ExprContext::ecxt_aggvalues, ExprContext::ecxt_per_query_memory, elog, WindowAggState::endInRangeFunc, WindowAgg::endInRangeFunc, WindowAggState::endOffset, WindowAgg::endOffset, equal(), ERROR, EXEC_FLAG_BACKWARD, EXEC_FLAG_MARK, ExecAssignExprContext(), ExecAssignProjectionInfo(), ExecCreateScanSlotFromOuterPlan(), ExecInitExpr(), ExecInitExtraTupleSlot(), ExecInitNode(), ExecInitQual(), ExecInitResultTupleSlotTL(), PlanState::ExecProcNode, execTuplesMatchPrepare(), ExecWindowAgg(), WindowAggState::first_part_slot, WindowStatePerFuncData::flinfo, fmgr_info(), fmgr_info_cxt(), fmgr_info_set_expr, WindowAggState::framehead_slot, FRAMEOPTION_END_CURRENT_ROW, FRAMEOPTION_END_OFFSET, FRAMEOPTION_GROUPS, FRAMEOPTION_RANGE, FRAMEOPTION_START_CURRENT_ROW, FRAMEOPTION_START_OFFSET, WindowAggState::frameOptions, WindowAgg::frameOptions, WindowAggState::frametail_slot, WindowAggState::funcs, get_func_name(), get_typlenbyval(), GetUserId(), i, WindowObjectData::ignore_nulls, WindowFunc::ignore_nulls, init_notnull_info(), initialize_peragg(), WindowAggState::inRangeAsc, WindowAgg::inRangeAsc, WindowAggState::inRangeColl, WindowAgg::inRangeColl, WindowAggState::inRangeNullsFirst, WindowAgg::inRangeNullsFirst, InvokeFunctionExecuteHook, lfirst, list_length(), WindowObjectData::localmem, makeNode, WindowObjectData::markptr, WindowAggState::more_partitions, WindowAggState::next_partition, NIL, WindowAggState::numaggs, WindowStatePerFuncData::numArguments, WindowAggState::numfuncs, object_aclcheck(), OBJECT_FUNCTION, OidIsValid, WindowAggState::ordEqfunction, WindowAgg::ordNumCols, PlanState::outerops, PlanState::outeropsfixed, PlanState::outeropsset, outerPlan, outerPlanState, palloc0(), WindowAggState::partcontext, WindowAggState::partEqfunction, WindowAggState::partition_spooled, WindowAgg::partNumCols, WindowAggState::peragg, WindowAggState::perfunc, WindowStatePerFuncData::plain_agg, PlanState::plan, WindowAgg::plan, ScanState::ps, PlanState::ps_ExprContext, PlanState::qual, Plan::qual, WindowObjectData::readptr, WindowStatePerFuncData::resulttypeByVal, WindowStatePerFuncData::resulttypeLen, WindowAggState::runcondition, WindowAgg::runCondition, WindowAggState::ss, ScanState::ss_ScanTupleSlot, WindowAggState::startInRangeFunc, WindowAgg::startInRangeFunc, WindowAggState::startOffset, WindowAgg::startOffset, PlanState::state, WindowAggState::status, WindowAggState::temp_slot_1, WindowAggState::temp_slot_2, WindowAggState::tmpcontext, WindowAggState::top_window, WindowAgg::topWindow, TupleTableSlot::tts_tupleDescriptor, TTSOpsMinimalTuple, TTSOpsVirtual, WindowAggState::use_pass_through, WindowStatePerFuncData::wfunc, WindowFuncExprState::wfunc, WindowStatePerAggData::wfuncno, WindowFuncExprState::wfuncno, WindowStatePerFuncData::wfuncstate, WindowStatePerFuncData::winCollation, WINDOWAGG_RUN, WindowFunc::winfnoid, WindowStatePerFuncData::winobj, WindowAgg::winref, WindowFunc::winref, and WindowObjectData::winstate.

Referenced by ExecInitNode().

◆ ExecReScanWindowAgg()

void ExecReScanWindowAgg ( WindowAggState node)

Definition at line 2846 of file nodeWindowAgg.c.

2847{
2849 ExprContext *econtext = node->ss.ps.ps_ExprContext;
2850
2851 node->status = WINDOWAGG_RUN;
2852 node->all_first = true;
2853
2854 /* release tuplestore et al */
2855 release_partition(node);
2856
2857 /* release all temp tuples, but especially first_part_slot */
2863 if (node->framehead_slot)
2865 if (node->frametail_slot)
2867
2868 /* Forget current wfunc values */
2869 MemSet(econtext->ecxt_aggvalues, 0, sizeof(Datum) * node->numfuncs);
2870 MemSet(econtext->ecxt_aggnulls, 0, sizeof(bool) * node->numfuncs);
2871
2872 /*
2873 * if chgParam of subnode is not null then plan will be re-scanned by
2874 * first ExecProcNode.
2875 */
2876 if (outerPlan->chgParam == NULL)
2878}
#define MemSet(start, val, len)
Definition: c.h:1023
void ExecReScan(PlanState *node)
Definition: execAmi.c:77
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: tuptable.h:457

References WindowAggState::agg_row_slot, WindowAggState::all_first, ExprContext::ecxt_aggnulls, ExprContext::ecxt_aggvalues, ExecClearTuple(), ExecReScan(), WindowAggState::first_part_slot, WindowAggState::framehead_slot, WindowAggState::frametail_slot, MemSet, WindowAggState::numfuncs, outerPlan, outerPlanState, ScanState::ps, PlanState::ps_ExprContext, release_partition(), WindowAggState::ss, ScanState::ss_ScanTupleSlot, WindowAggState::status, WindowAggState::temp_slot_1, WindowAggState::temp_slot_2, and WINDOWAGG_RUN.

Referenced by ExecReScan().