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 2813 of file nodeWindowAgg.c.

2814{
2816 int i;
2817
2818 if (node->buffer != NULL)
2819 {
2820 tuplestore_end(node->buffer);
2821
2822 /* nullify so that release_partition skips the tuplestore_clear() */
2823 node->buffer = NULL;
2824 }
2825
2826 release_partition(node);
2827
2828 for (i = 0; i < node->numaggs; i++)
2829 {
2830 if (node->peragg[i].aggcontext != node->aggcontext)
2832 }
2835
2836 pfree(node->perfunc);
2837 pfree(node->peragg);
2838
2839 outerPlan = outerPlanState(node);
2841}
void ExecEndNode(PlanState *node)
#define outerPlanState(node)
Definition execnodes.h:1273
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:265
static int fb(int x)
MemoryContext aggcontext
Definition execnodes.h:2559
WindowStatePerAgg peragg
Definition execnodes.h:2509
MemoryContext partcontext
Definition execnodes.h:2558
Tuplestorestate * buffer
Definition execnodes.h:2512
WindowStatePerFunc perfunc
Definition execnodes.h:2508
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 2500 of file nodeWindowAgg.c.

2501{
2502 WindowAggState *winstate;
2503 Plan *outerPlan;
2504 ExprContext *econtext;
2505 ExprContext *tmpcontext;
2506 WindowStatePerFunc perfunc;
2507 WindowStatePerAgg peragg;
2508 int frameOptions = node->frameOptions;
2509 int numfuncs,
2510 wfuncno,
2511 numaggs,
2512 aggno;
2514 ListCell *l;
2515
2516 /* check for unsupported flags */
2517 Assert(!(eflags & (EXEC_FLAG_BACKWARD | EXEC_FLAG_MARK)));
2518
2519 /*
2520 * create state structure
2521 */
2522 winstate = makeNode(WindowAggState);
2523 winstate->ss.ps.plan = (Plan *) node;
2524 winstate->ss.ps.state = estate;
2525 winstate->ss.ps.ExecProcNode = ExecWindowAgg;
2526
2527 /* copy frame options to state node for easy access */
2528 winstate->frameOptions = frameOptions;
2529
2530 /*
2531 * Create expression contexts. We need two, one for per-input-tuple
2532 * processing and one for per-output-tuple processing. We cheat a little
2533 * by using ExecAssignExprContext() to build both.
2534 */
2535 ExecAssignExprContext(estate, &winstate->ss.ps);
2536 tmpcontext = winstate->ss.ps.ps_ExprContext;
2537 winstate->tmpcontext = tmpcontext;
2538 ExecAssignExprContext(estate, &winstate->ss.ps);
2539
2540 /* Create long-lived context for storage of partition-local memory etc */
2541 winstate->partcontext =
2543 "WindowAgg Partition",
2545
2546 /*
2547 * Create mid-lived context for aggregate trans values etc.
2548 *
2549 * Note that moving aggregates each use their own private context, not
2550 * this one.
2551 */
2552 winstate->aggcontext =
2554 "WindowAgg Aggregates",
2556
2557 /* Only the top-level WindowAgg may have a qual */
2558 Assert(node->plan.qual == NIL || node->topWindow);
2559
2560 /* Initialize the qual */
2561 winstate->ss.ps.qual = ExecInitQual(node->plan.qual,
2562 (PlanState *) winstate);
2563
2564 /*
2565 * Setup the run condition, if we received one from the query planner.
2566 * When set, this may allow us to move into pass-through mode so that we
2567 * don't have to perform any further evaluation of WindowFuncs in the
2568 * current partition or possibly stop returning tuples altogether when all
2569 * tuples are in the same partition.
2570 */
2571 winstate->runcondition = ExecInitQual(node->runCondition,
2572 (PlanState *) winstate);
2573
2574 /*
2575 * When we're not the top-level WindowAgg node or we are but have a
2576 * PARTITION BY clause we must move into one of the WINDOWAGG_PASSTHROUGH*
2577 * modes when the runCondition becomes false.
2578 */
2579 winstate->use_pass_through = !node->topWindow || node->partNumCols > 0;
2580
2581 /* remember if we're the top-window or we are below the top-window */
2582 winstate->top_window = node->topWindow;
2583
2584 /*
2585 * initialize child nodes
2586 */
2587 outerPlan = outerPlan(node);
2588 outerPlanState(winstate) = ExecInitNode(outerPlan, estate, eflags);
2589
2590 /*
2591 * initialize source tuple type (which is also the tuple type that we'll
2592 * store in the tuplestore and use in all our working slots).
2593 */
2596
2597 /* the outer tuple isn't the child's tuple, but always a minimal tuple */
2598 winstate->ss.ps.outeropsset = true;
2599 winstate->ss.ps.outerops = &TTSOpsMinimalTuple;
2600 winstate->ss.ps.outeropsfixed = true;
2601
2602 /*
2603 * tuple table initialization
2604 */
2607 winstate->agg_row_slot = ExecInitExtraTupleSlot(estate, scanDesc,
2609 winstate->temp_slot_1 = ExecInitExtraTupleSlot(estate, scanDesc,
2611 winstate->temp_slot_2 = ExecInitExtraTupleSlot(estate, scanDesc,
2613
2614 /*
2615 * create frame head and tail slots only if needed (must create slots in
2616 * exactly the same cases that update_frameheadpos and update_frametailpos
2617 * need them)
2618 */
2619 winstate->framehead_slot = winstate->frametail_slot = NULL;
2620
2621 if (frameOptions & (FRAMEOPTION_RANGE | FRAMEOPTION_GROUPS))
2622 {
2623 if (((frameOptions & FRAMEOPTION_START_CURRENT_ROW) &&
2624 node->ordNumCols != 0) ||
2625 (frameOptions & FRAMEOPTION_START_OFFSET))
2628 if (((frameOptions & FRAMEOPTION_END_CURRENT_ROW) &&
2629 node->ordNumCols != 0) ||
2630 (frameOptions & FRAMEOPTION_END_OFFSET))
2633 }
2634
2635 /*
2636 * Initialize result slot, type and projection.
2637 */
2639 ExecAssignProjectionInfo(&winstate->ss.ps, NULL);
2640
2641 /* Set up data for comparing tuples */
2642 if (node->partNumCols > 0)
2643 winstate->partEqfunction =
2645 node->partNumCols,
2646 node->partColIdx,
2647 node->partOperators,
2648 node->partCollations,
2649 &winstate->ss.ps);
2650
2651 if (node->ordNumCols > 0)
2652 winstate->ordEqfunction =
2654 node->ordNumCols,
2655 node->ordColIdx,
2656 node->ordOperators,
2657 node->ordCollations,
2658 &winstate->ss.ps);
2659
2660 /*
2661 * WindowAgg nodes use aggvalues and aggnulls as well as Agg nodes.
2662 */
2663 numfuncs = winstate->numfuncs;
2664 numaggs = winstate->numaggs;
2665 econtext = winstate->ss.ps.ps_ExprContext;
2666 econtext->ecxt_aggvalues = palloc0_array(Datum, numfuncs);
2667 econtext->ecxt_aggnulls = palloc0_array(bool, numfuncs);
2668
2669 /*
2670 * allocate per-wfunc/per-agg state information.
2671 */
2672 perfunc = palloc0_array(WindowStatePerFuncData, numfuncs);
2673 peragg = palloc0_array(WindowStatePerAggData, numaggs);
2674 winstate->perfunc = perfunc;
2675 winstate->peragg = peragg;
2676
2677 wfuncno = -1;
2678 aggno = -1;
2679 foreach(l, winstate->funcs)
2680 {
2681 WindowFuncExprState *wfuncstate = (WindowFuncExprState *) lfirst(l);
2682 WindowFunc *wfunc = wfuncstate->wfunc;
2685 int i;
2686
2687 if (wfunc->winref != node->winref) /* planner screwed up? */
2688 elog(ERROR, "WindowFunc with winref %u assigned to WindowAgg with winref %u",
2689 wfunc->winref, node->winref);
2690
2691 /*
2692 * Look for a previous duplicate window function, which needs the same
2693 * ignore_nulls value
2694 */
2695 for (i = 0; i <= wfuncno; i++)
2696 {
2697 if (equal(wfunc, perfunc[i].wfunc) &&
2698 !contain_volatile_functions((Node *) wfunc))
2699 break;
2700 }
2701 if (i <= wfuncno && wfunc->ignore_nulls == perfunc[i].ignore_nulls)
2702 {
2703 /* Found a match to an existing entry, so just mark it */
2704 wfuncstate->wfuncno = i;
2705 continue;
2706 }
2707
2708 /* Nope, so assign a new PerAgg record */
2709 perfuncstate = &perfunc[++wfuncno];
2710
2711 /* Mark WindowFunc state node with assigned index in the result array */
2712 wfuncstate->wfuncno = wfuncno;
2713
2714 /* Check permission to call window function */
2716 ACL_EXECUTE);
2717 if (aclresult != ACLCHECK_OK)
2719 get_func_name(wfunc->winfnoid));
2720 InvokeFunctionExecuteHook(wfunc->winfnoid);
2721
2722 /* Fill in the perfuncstate data */
2723 perfuncstate->wfuncstate = wfuncstate;
2724 perfuncstate->wfunc = wfunc;
2725 perfuncstate->numArguments = list_length(wfuncstate->args);
2726 perfuncstate->winCollation = wfunc->inputcollid;
2727
2728 get_typlenbyval(wfunc->wintype,
2729 &perfuncstate->resulttypeLen,
2730 &perfuncstate->resulttypeByVal);
2731
2732 /*
2733 * If it's really just a plain aggregate function, we'll emulate the
2734 * Agg environment for it.
2735 */
2736 perfuncstate->plain_agg = wfunc->winagg;
2737 if (wfunc->winagg)
2738 {
2740
2741 perfuncstate->aggno = ++aggno;
2742 peraggstate = &winstate->peragg[aggno];
2743 initialize_peragg(winstate, wfunc, peraggstate);
2744 peraggstate->wfuncno = wfuncno;
2745 }
2746 else
2747 {
2749
2750 winobj->winstate = winstate;
2751 winobj->argstates = wfuncstate->args;
2752 winobj->localmem = NULL;
2753 perfuncstate->winobj = winobj;
2754 winobj->ignore_nulls = wfunc->ignore_nulls;
2756
2757 /* It's a real window function, so set up to call it. */
2758 fmgr_info_cxt(wfunc->winfnoid, &perfuncstate->flinfo,
2759 econtext->ecxt_per_query_memory);
2760 fmgr_info_set_expr((Node *) wfunc, &perfuncstate->flinfo);
2761 }
2762 }
2763
2764 /* Update numfuncs, numaggs to match number of unique functions found */
2765 winstate->numfuncs = wfuncno + 1;
2766 winstate->numaggs = aggno + 1;
2767
2768 /* Set up WindowObject for aggregates, if needed */
2769 if (winstate->numaggs > 0)
2770 {
2772
2773 agg_winobj->winstate = winstate;
2774 agg_winobj->argstates = NIL;
2775 agg_winobj->localmem = NULL;
2776 /* make sure markptr = -1 to invalidate. It may not get used */
2777 agg_winobj->markptr = -1;
2778 agg_winobj->readptr = -1;
2779 winstate->agg_winobj = agg_winobj;
2780 }
2781
2782 /* Set the status to running */
2783 winstate->status = WINDOWAGG_RUN;
2784
2785 /* initialize frame bound offset expressions */
2786 winstate->startOffset = ExecInitExpr((Expr *) node->startOffset,
2787 (PlanState *) winstate);
2788 winstate->endOffset = ExecInitExpr((Expr *) node->endOffset,
2789 (PlanState *) winstate);
2790
2791 /* Lookup in_range support functions if needed */
2792 if (OidIsValid(node->startInRangeFunc))
2793 fmgr_info(node->startInRangeFunc, &winstate->startInRangeFunc);
2794 if (OidIsValid(node->endInRangeFunc))
2795 fmgr_info(node->endInRangeFunc, &winstate->endInRangeFunc);
2796 winstate->inRangeColl = node->inRangeColl;
2797 winstate->inRangeAsc = node->inRangeAsc;
2798 winstate->inRangeNullsFirst = node->inRangeNullsFirst;
2799
2800 winstate->all_first = true;
2801 winstate->partition_spooled = false;
2802 winstate->more_partitions = false;
2803 winstate->next_partition = true;
2804
2805 return winstate;
2806}
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:945
#define OidIsValid(objectId)
Definition c.h:860
bool contain_volatile_functions(Node *clause)
Definition clauses.c:549
#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: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:2493
#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: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
#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:303
bool * ecxt_aggnulls
Definition execnodes.h:305
MemoryContext ecxt_per_query_memory
Definition execnodes.h:291
Definition nodes.h:135
bool outeropsset
Definition execnodes.h:1260
const TupleTableSlotOps * outerops
Definition execnodes.h:1252
ExprState * qual
Definition execnodes.h:1198
Plan * plan
Definition execnodes.h:1177
bool outeropsfixed
Definition execnodes.h:1256
EState * state
Definition execnodes.h:1179
ExprContext * ps_ExprContext
Definition execnodes.h:1216
ExecProcNodeMtd ExecProcNode
Definition execnodes.h:1183
List * qual
Definition plannodes.h:235
TupleTableSlot * ss_ScanTupleSlot
Definition execnodes.h:1636
PlanState ps
Definition execnodes.h:1633
TupleDesc tts_tupleDescriptor
Definition tuptable.h:129
ExprState * endOffset
Definition execnodes.h:2529
ScanState ss
Definition execnodes.h:2501
FmgrInfo endInRangeFunc
Definition execnodes.h:2535
TupleTableSlot * framehead_slot
Definition execnodes.h:2578
bool partition_spooled
Definition execnodes.h:2564
FmgrInfo startInRangeFunc
Definition execnodes.h:2534
TupleTableSlot * frametail_slot
Definition execnodes.h:2579
ExprState * ordEqfunction
Definition execnodes.h:2511
ExprState * runcondition
Definition execnodes.h:2546
TupleTableSlot * temp_slot_2
Definition execnodes.h:2584
WindowAggStatus status
Definition execnodes.h:2525
TupleTableSlot * agg_row_slot
Definition execnodes.h:2582
struct WindowObjectData * agg_winobj
Definition execnodes.h:2522
bool inRangeNullsFirst
Definition execnodes.h:2538
ExprState * partEqfunction
Definition execnodes.h:2510
ExprState * startOffset
Definition execnodes.h:2528
TupleTableSlot * first_part_slot
Definition execnodes.h:2576
ExprContext * tmpcontext
Definition execnodes.h:2561
TupleTableSlot * temp_slot_1
Definition execnodes.h:2583
bool use_pass_through
Definition execnodes.h:2541
int partNumCols
Definition plannodes.h:1258
Oid endInRangeFunc
Definition plannodes.h:1302
Node * endOffset
Definition plannodes.h:1288
bool topWindow
Definition plannodes.h:1317
Oid inRangeColl
Definition plannodes.h:1305
Node * startOffset
Definition plannodes.h:1285
List * runCondition
Definition plannodes.h:1291
Oid startInRangeFunc
Definition plannodes.h:1299
bool inRangeAsc
Definition plannodes.h:1308
Index winref
Definition plannodes.h:1255
bool inRangeNullsFirst
Definition plannodes.h:1311
int ordNumCols
Definition plannodes.h:1270
int frameOptions
Definition plannodes.h:1282
WindowFunc * wfunc
Definition execnodes.h:935
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 2848 of file nodeWindowAgg.c.

2849{
2851 ExprContext *econtext = node->ss.ps.ps_ExprContext;
2852
2853 node->status = WINDOWAGG_RUN;
2854 node->all_first = true;
2855
2856 /* release tuplestore et al */
2857 release_partition(node);
2858
2859 /* release all temp tuples, but especially first_part_slot */
2865 if (node->framehead_slot)
2867 if (node->frametail_slot)
2869
2870 /* Forget current wfunc values */
2871 MemSet(econtext->ecxt_aggvalues, 0, sizeof(Datum) * node->numfuncs);
2872 MemSet(econtext->ecxt_aggnulls, 0, sizeof(bool) * node->numfuncs);
2873
2874 /*
2875 * if chgParam of subnode is not null then plan will be re-scanned by
2876 * first ExecProcNode.
2877 */
2878 if (outerPlan->chgParam == NULL)
2880}
#define MemSet(start, val, len)
Definition c.h:1109
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().