PostgreSQL Source Code git master
Loading...
Searching...
No Matches
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)
extern

Definition at line 2861 of file nodeWindowAgg.c.

2862{
2864 int i;
2865
2866 if (node->buffer != NULL)
2867 {
2868 tuplestore_end(node->buffer);
2869
2870 /* nullify so that release_partition skips the tuplestore_clear() */
2871 node->buffer = NULL;
2872 }
2873
2874 release_partition(node);
2875
2876 for (i = 0; i < node->numaggs; i++)
2877 {
2878 if (node->peragg[i].aggcontext != node->aggcontext)
2880 }
2883
2884 pfree(node->perfunc);
2885 pfree(node->peragg);
2886
2887 outerPlan = outerPlanState(node);
2889}
void ExecEndNode(PlanState *node)
#define outerPlanState(node)
Definition execnodes.h:1299
int i
Definition isn.c:77
void pfree(void *pointer)
Definition mcxt.c:1616
void MemoryContextDelete(MemoryContext context)
Definition mcxt.c:472
static void release_partition(WindowAggState *winstate)
#define outerPlan(node)
Definition plannodes.h:267
static int fb(int x)
MemoryContext aggcontext
Definition execnodes.h:2587
WindowStatePerAgg peragg
Definition execnodes.h:2537
MemoryContext partcontext
Definition execnodes.h:2586
Tuplestorestate * buffer
Definition execnodes.h:2540
WindowStatePerFunc perfunc
Definition execnodes.h:2536
MemoryContext aggcontext
void tuplestore_end(Tuplestorestate *state)
Definition tuplestore.c:493

References WindowStatePerAggData::aggcontext, WindowAggState::aggcontext, WindowAggState::buffer, ExecEndNode(), fb(), 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 
)
extern

Definition at line 2548 of file nodeWindowAgg.c.

2549{
2550 WindowAggState *winstate;
2551 Plan *outerPlan;
2552 ExprContext *econtext;
2553 ExprContext *tmpcontext;
2554 WindowStatePerFunc perfunc;
2555 WindowStatePerAgg peragg;
2556 int frameOptions = node->frameOptions;
2557 int numfuncs,
2558 wfuncno,
2559 numaggs,
2560 aggno;
2562 ListCell *l;
2563
2564 /* check for unsupported flags */
2565 Assert(!(eflags & (EXEC_FLAG_BACKWARD | EXEC_FLAG_MARK)));
2566
2567 /*
2568 * create state structure
2569 */
2570 winstate = makeNode(WindowAggState);
2571 winstate->ss.ps.plan = (Plan *) node;
2572 winstate->ss.ps.state = estate;
2573 winstate->ss.ps.ExecProcNode = ExecWindowAgg;
2574
2575 /* copy frame options to state node for easy access */
2576 winstate->frameOptions = frameOptions;
2577
2578 /*
2579 * Create expression contexts. We need two, one for per-input-tuple
2580 * processing and one for per-output-tuple processing. We cheat a little
2581 * by using ExecAssignExprContext() to build both.
2582 */
2583 ExecAssignExprContext(estate, &winstate->ss.ps);
2584 tmpcontext = winstate->ss.ps.ps_ExprContext;
2585 winstate->tmpcontext = tmpcontext;
2586 ExecAssignExprContext(estate, &winstate->ss.ps);
2587
2588 /* Create long-lived context for storage of partition-local memory etc */
2589 winstate->partcontext =
2591 "WindowAgg Partition",
2593
2594 /*
2595 * Create mid-lived context for aggregate trans values etc.
2596 *
2597 * Note that moving aggregates each use their own private context, not
2598 * this one.
2599 */
2600 winstate->aggcontext =
2602 "WindowAgg Aggregates",
2604
2605 /* Only the top-level WindowAgg may have a qual */
2606 Assert(node->plan.qual == NIL || node->topWindow);
2607
2608 /* Initialize the qual */
2609 winstate->ss.ps.qual = ExecInitQual(node->plan.qual,
2610 (PlanState *) winstate);
2611
2612 /*
2613 * Setup the run condition, if we received one from the query planner.
2614 * When set, this may allow us to move into pass-through mode so that we
2615 * don't have to perform any further evaluation of WindowFuncs in the
2616 * current partition or possibly stop returning tuples altogether when all
2617 * tuples are in the same partition.
2618 */
2619 winstate->runcondition = ExecInitQual(node->runCondition,
2620 (PlanState *) winstate);
2621
2622 /*
2623 * When we're not the top-level WindowAgg node or we are but have a
2624 * PARTITION BY clause we must move into one of the WINDOWAGG_PASSTHROUGH*
2625 * modes when the runCondition becomes false.
2626 */
2627 winstate->use_pass_through = !node->topWindow || node->partNumCols > 0;
2628
2629 /* remember if we're the top-window or we are below the top-window */
2630 winstate->top_window = node->topWindow;
2631
2632 /*
2633 * initialize child nodes
2634 */
2635 outerPlan = outerPlan(node);
2636 outerPlanState(winstate) = ExecInitNode(outerPlan, estate, eflags);
2637
2638 /*
2639 * initialize source tuple type (which is also the tuple type that we'll
2640 * store in the tuplestore and use in all our working slots).
2641 */
2644
2645 /* the outer tuple isn't the child's tuple, but always a minimal tuple */
2646 winstate->ss.ps.outeropsset = true;
2647 winstate->ss.ps.outerops = &TTSOpsMinimalTuple;
2648 winstate->ss.ps.outeropsfixed = true;
2649
2650 /*
2651 * tuple table initialization
2652 */
2655 winstate->agg_row_slot = ExecInitExtraTupleSlot(estate, scanDesc,
2657 winstate->temp_slot_1 = ExecInitExtraTupleSlot(estate, scanDesc,
2659 winstate->temp_slot_2 = ExecInitExtraTupleSlot(estate, scanDesc,
2661
2662 /*
2663 * create frame head and tail slots only if needed (must create slots in
2664 * exactly the same cases that update_frameheadpos and update_frametailpos
2665 * need them)
2666 */
2667 winstate->framehead_slot = winstate->frametail_slot = NULL;
2668
2669 if (frameOptions & (FRAMEOPTION_RANGE | FRAMEOPTION_GROUPS))
2670 {
2671 if (((frameOptions & FRAMEOPTION_START_CURRENT_ROW) &&
2672 node->ordNumCols != 0) ||
2673 (frameOptions & FRAMEOPTION_START_OFFSET))
2676 if (((frameOptions & FRAMEOPTION_END_CURRENT_ROW) &&
2677 node->ordNumCols != 0) ||
2678 (frameOptions & FRAMEOPTION_END_OFFSET))
2681 }
2682
2683 /*
2684 * Initialize result slot, type and projection.
2685 */
2687 ExecAssignProjectionInfo(&winstate->ss.ps, NULL);
2688
2689 /* Set up data for comparing tuples */
2690 if (node->partNumCols > 0)
2691 winstate->partEqfunction =
2693 node->partNumCols,
2694 node->partColIdx,
2695 node->partOperators,
2696 node->partCollations,
2697 &winstate->ss.ps);
2698
2699 if (node->ordNumCols > 0)
2700 winstate->ordEqfunction =
2702 node->ordNumCols,
2703 node->ordColIdx,
2704 node->ordOperators,
2705 node->ordCollations,
2706 &winstate->ss.ps);
2707
2708 /*
2709 * WindowAgg nodes use aggvalues and aggnulls as well as Agg nodes.
2710 */
2711 numfuncs = winstate->numfuncs;
2712 numaggs = winstate->numaggs;
2713 econtext = winstate->ss.ps.ps_ExprContext;
2714 econtext->ecxt_aggvalues = palloc0_array(Datum, numfuncs);
2715 econtext->ecxt_aggnulls = palloc0_array(bool, numfuncs);
2716
2717 /*
2718 * allocate per-wfunc/per-agg state information.
2719 */
2720 perfunc = palloc0_array(WindowStatePerFuncData, numfuncs);
2721 peragg = palloc0_array(WindowStatePerAggData, numaggs);
2722 winstate->perfunc = perfunc;
2723 winstate->peragg = peragg;
2724
2725 wfuncno = -1;
2726 aggno = -1;
2727 foreach(l, winstate->funcs)
2728 {
2729 WindowFuncExprState *wfuncstate = (WindowFuncExprState *) lfirst(l);
2730 WindowFunc *wfunc = wfuncstate->wfunc;
2733 int i;
2734
2735 if (wfunc->winref != node->winref) /* planner screwed up? */
2736 elog(ERROR, "WindowFunc with winref %u assigned to WindowAgg with winref %u",
2737 wfunc->winref, node->winref);
2738
2739 /*
2740 * Look for a previous duplicate window function, which needs the same
2741 * ignore_nulls value
2742 */
2743 for (i = 0; i <= wfuncno; i++)
2744 {
2745 if (equal(wfunc, perfunc[i].wfunc) &&
2746 !contain_volatile_functions((Node *) wfunc))
2747 break;
2748 }
2749 if (i <= wfuncno && wfunc->ignore_nulls == perfunc[i].ignore_nulls)
2750 {
2751 /* Found a match to an existing entry, so just mark it */
2752 wfuncstate->wfuncno = i;
2753 continue;
2754 }
2755
2756 /* Nope, so assign a new PerAgg record */
2757 perfuncstate = &perfunc[++wfuncno];
2758
2759 /* Mark WindowFunc state node with assigned index in the result array */
2760 wfuncstate->wfuncno = wfuncno;
2761
2762 /* Check permission to call window function */
2764 ACL_EXECUTE);
2765 if (aclresult != ACLCHECK_OK)
2767 get_func_name(wfunc->winfnoid));
2768 InvokeFunctionExecuteHook(wfunc->winfnoid);
2769
2770 /* Fill in the perfuncstate data */
2771 perfuncstate->wfuncstate = wfuncstate;
2772 perfuncstate->wfunc = wfunc;
2773 perfuncstate->numArguments = list_length(wfuncstate->args);
2774 perfuncstate->winCollation = wfunc->inputcollid;
2775
2776 get_typlenbyval(wfunc->wintype,
2777 &perfuncstate->resulttypeLen,
2778 &perfuncstate->resulttypeByVal);
2779
2780 /*
2781 * If it's really just a plain aggregate function, we'll emulate the
2782 * Agg environment for it.
2783 */
2784 perfuncstate->plain_agg = wfunc->winagg;
2785 if (wfunc->winagg)
2786 {
2788
2789 perfuncstate->aggno = ++aggno;
2790 peraggstate = &winstate->peragg[aggno];
2791 initialize_peragg(winstate, wfunc, peraggstate);
2792 peraggstate->wfuncno = wfuncno;
2793 }
2794 else
2795 {
2797
2798 winobj->winstate = winstate;
2799 winobj->argstates = wfuncstate->args;
2800 winobj->localmem = NULL;
2801 perfuncstate->winobj = winobj;
2802 winobj->ignore_nulls = wfunc->ignore_nulls;
2804
2805 /* It's a real window function, so set up to call it. */
2806 fmgr_info_cxt(wfunc->winfnoid, &perfuncstate->flinfo,
2807 econtext->ecxt_per_query_memory);
2808 fmgr_info_set_expr((Node *) wfunc, &perfuncstate->flinfo);
2809 }
2810 }
2811
2812 /* Update numfuncs, numaggs to match number of unique functions found */
2813 winstate->numfuncs = wfuncno + 1;
2814 winstate->numaggs = aggno + 1;
2815
2816 /* Set up WindowObject for aggregates, if needed */
2817 if (winstate->numaggs > 0)
2818 {
2820
2821 agg_winobj->winstate = winstate;
2822 agg_winobj->argstates = NIL;
2823 agg_winobj->localmem = NULL;
2824 /* make sure markptr = -1 to invalidate. It may not get used */
2825 agg_winobj->markptr = -1;
2826 agg_winobj->readptr = -1;
2827 winstate->agg_winobj = agg_winobj;
2828 }
2829
2830 /* Set the status to running */
2831 winstate->status = WINDOWAGG_RUN;
2832
2833 /* initialize frame bound offset expressions */
2834 winstate->startOffset = ExecInitExpr((Expr *) node->startOffset,
2835 (PlanState *) winstate);
2836 winstate->endOffset = ExecInitExpr((Expr *) node->endOffset,
2837 (PlanState *) winstate);
2838
2839 /* Lookup in_range support functions if needed */
2840 if (OidIsValid(node->startInRangeFunc))
2841 fmgr_info(node->startInRangeFunc, &winstate->startInRangeFunc);
2842 if (OidIsValid(node->endInRangeFunc))
2843 fmgr_info(node->endInRangeFunc, &winstate->endInRangeFunc);
2844 winstate->inRangeColl = node->inRangeColl;
2845 winstate->inRangeAsc = node->inRangeAsc;
2846 winstate->inRangeNullsFirst = node->inRangeNullsFirst;
2847
2848 winstate->all_first = true;
2849 winstate->partition_spooled = false;
2850 winstate->more_partitions = false;
2851 winstate->next_partition = true;
2852
2853 return winstate;
2854}
AclResult
Definition acl.h:183
@ ACLCHECK_OK
Definition acl.h:184
void aclcheck_error(AclResult aclerr, ObjectType objtype, const char *objectname)
Definition aclchk.c:2672
AclResult object_aclcheck(Oid classid, Oid objectid, Oid roleid, AclMode mode)
Definition aclchk.c:3879
#define Assert(condition)
Definition c.h:943
#define OidIsValid(objectId)
Definition c.h:858
bool contain_volatile_functions(Node *clause)
Definition clauses.c:549
#define ERROR
Definition elog.h:40
#define elog(elevel,...)
Definition elog.h:228
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:250
ExprState * execTuplesMatchPrepare(TupleDesc desc, int numCols, const AttrNumber *keyColIdx, const Oid *eqOperators, const Oid *collations, PlanState *parent)
PlanState * ExecInitNode(Plan *node, EState *estate, int eflags)
const TupleTableSlotOps TTSOpsVirtual
Definition execTuples.c:84
TupleTableSlot * ExecInitExtraTupleSlot(EState *estate, TupleDesc tupledesc, const TupleTableSlotOps *tts_ops)
void ExecInitResultTupleSlotTL(PlanState *planstate, const TupleTableSlotOps *tts_ops)
const TupleTableSlotOps TTSOpsMinimalTuple
Definition execTuples.c:86
void ExecCreateScanSlotFromOuterPlan(EState *estate, ScanState *scanstate, const TupleTableSlotOps *tts_ops)
Definition execUtils.c:709
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Definition execUtils.c:490
void ExecAssignProjectionInfo(PlanState *planstate, TupleDesc inputDesc)
Definition execUtils.c:588
@ WINDOWAGG_RUN
Definition execnodes.h:2521
#define EXEC_FLAG_BACKWARD
Definition executor.h:70
#define EXEC_FLAG_MARK
Definition executor.h:71
#define palloc0_array(type, count)
Definition fe_memutils.h:77
void fmgr_info(Oid functionId, FmgrInfo *finfo)
Definition fmgr.c:129
void fmgr_info_cxt(Oid functionId, FmgrInfo *finfo, MemoryContext mcxt)
Definition fmgr.c:139
#define fmgr_info_set_expr(expr, finfo)
Definition fmgr.h:135
void get_typlenbyval(Oid typid, int16 *typlen, bool *typbyval)
Definition lsyscache.c:2471
char * get_func_name(Oid funcid)
Definition lsyscache.c:1828
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:470
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)
#define FRAMEOPTION_END_CURRENT_ROW
Definition parsenodes.h:622
#define FRAMEOPTION_END_OFFSET
Definition parsenodes.h:633
#define FRAMEOPTION_START_CURRENT_ROW
Definition parsenodes.h:621
#define FRAMEOPTION_START_OFFSET
Definition parsenodes.h:631
@ OBJECT_FUNCTION
#define FRAMEOPTION_RANGE
Definition parsenodes.h:613
#define FRAMEOPTION_GROUPS
Definition parsenodes.h:615
#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:306
bool * ecxt_aggnulls
Definition execnodes.h:308
MemoryContext ecxt_per_query_memory
Definition execnodes.h:294
Definition nodes.h:135
bool outeropsset
Definition execnodes.h:1286
const TupleTableSlotOps * outerops
Definition execnodes.h:1278
ExprState * qual
Definition execnodes.h:1224
Plan * plan
Definition execnodes.h:1201
bool outeropsfixed
Definition execnodes.h:1282
EState * state
Definition execnodes.h:1203
ExprContext * ps_ExprContext
Definition execnodes.h:1242
ExecProcNodeMtd ExecProcNode
Definition execnodes.h:1207
List * qual
Definition plannodes.h:237
TupleTableSlot * ss_ScanTupleSlot
Definition execnodes.h:1662
PlanState ps
Definition execnodes.h:1659
TupleDesc tts_tupleDescriptor
Definition tuptable.h:129
ExprState * endOffset
Definition execnodes.h:2557
ScanState ss
Definition execnodes.h:2529
FmgrInfo endInRangeFunc
Definition execnodes.h:2563
TupleTableSlot * framehead_slot
Definition execnodes.h:2606
bool partition_spooled
Definition execnodes.h:2592
FmgrInfo startInRangeFunc
Definition execnodes.h:2562
TupleTableSlot * frametail_slot
Definition execnodes.h:2607
ExprState * ordEqfunction
Definition execnodes.h:2539
ExprState * runcondition
Definition execnodes.h:2574
TupleTableSlot * temp_slot_2
Definition execnodes.h:2612
WindowAggStatus status
Definition execnodes.h:2553
TupleTableSlot * agg_row_slot
Definition execnodes.h:2610
struct WindowObjectData * agg_winobj
Definition execnodes.h:2550
bool inRangeNullsFirst
Definition execnodes.h:2566
ExprState * partEqfunction
Definition execnodes.h:2538
ExprState * startOffset
Definition execnodes.h:2556
TupleTableSlot * first_part_slot
Definition execnodes.h:2604
ExprContext * tmpcontext
Definition execnodes.h:2589
TupleTableSlot * temp_slot_1
Definition execnodes.h:2611
bool use_pass_through
Definition execnodes.h:2569
int partNumCols
Definition plannodes.h:1262
Oid endInRangeFunc
Definition plannodes.h:1306
Node * endOffset
Definition plannodes.h:1292
bool topWindow
Definition plannodes.h:1321
Oid inRangeColl
Definition plannodes.h:1309
Node * startOffset
Definition plannodes.h:1289
List * runCondition
Definition plannodes.h:1295
Oid startInRangeFunc
Definition plannodes.h:1303
bool inRangeAsc
Definition plannodes.h:1312
Index winref
Definition plannodes.h:1259
bool inRangeNullsFirst
Definition plannodes.h:1315
int ordNumCols
Definition plannodes.h:1274
int frameOptions
Definition plannodes.h:1286
WindowFunc * wfunc
Definition execnodes.h:959
Index winref
Definition primnodes.h:612
WindowAggState * winstate

References ACL_EXECUTE, aclcheck_error(), ACLCHECK_OK, WindowAggState::agg_row_slot, WindowAggState::agg_winobj, WindowAggState::aggcontext, 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(), fb(), WindowAggState::first_part_slot, 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, WindowAggState::numfuncs, object_aclcheck(), OBJECT_FUNCTION, OidIsValid, WindowAggState::ordEqfunction, WindowAgg::ordNumCols, PlanState::outerops, PlanState::outeropsfixed, PlanState::outeropsset, outerPlan, outerPlanState, palloc0_array, WindowAggState::partcontext, WindowAggState::partEqfunction, WindowAggState::partition_spooled, WindowAgg::partNumCols, WindowAggState::peragg, WindowAggState::perfunc, PlanState::plan, WindowAgg::plan, ScanState::ps, PlanState::ps_ExprContext, PlanState::qual, Plan::qual, WindowObjectData::readptr, 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, WindowFuncExprState::wfunc, WindowFuncExprState::wfuncno, WINDOWAGG_RUN, WindowFunc::winfnoid, WindowAgg::winref, WindowFunc::winref, and WindowObjectData::winstate.

Referenced by ExecInitNode().

◆ ExecReScanWindowAgg()

void ExecReScanWindowAgg ( WindowAggState node)
extern

Definition at line 2896 of file nodeWindowAgg.c.

2897{
2899 ExprContext *econtext = node->ss.ps.ps_ExprContext;
2900
2901 node->status = WINDOWAGG_RUN;
2902 node->all_first = true;
2903
2904 /* release tuplestore et al */
2905 release_partition(node);
2906
2907 /* release all temp tuples, but especially first_part_slot */
2913 if (node->framehead_slot)
2915 if (node->frametail_slot)
2917
2918 /* Forget current wfunc values */
2919 MemSet(econtext->ecxt_aggvalues, 0, sizeof(Datum) * node->numfuncs);
2920 MemSet(econtext->ecxt_aggnulls, 0, sizeof(bool) * node->numfuncs);
2921
2922 /*
2923 * if chgParam of subnode is not null then plan will be re-scanned by
2924 * first ExecProcNode.
2925 */
2926 if (outerPlan->chgParam == NULL)
2928}
#define MemSet(start, val, len)
Definition c.h:1107
void ExecReScan(PlanState *node)
Definition execAmi.c:78
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition tuptable.h:476

References WindowAggState::agg_row_slot, WindowAggState::all_first, ExprContext::ecxt_aggnulls, ExprContext::ecxt_aggvalues, ExecClearTuple(), ExecReScan(), fb(), 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().