PostgreSQL Source Code git master
Functions
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)
 
 
 

Function Documentation

ExecEndWindowAgg()

void ExecEndWindowAgg ( WindowAggStatenode )

Definition at line 2794 of file nodeWindowAgg.c.

2795{
2797 int i;
2798
2799 if (node->buffer != NULL)
2800 {
2801 tuplestore_end(node->buffer);
2802
2803 /* nullify so that release_partition skips the tuplestore_clear() */
2804 node->buffer = NULL;
2805 }
2806
2807 release_partition(node);
2808
2809 for (i = 0; i < node->numaggs; i++)
2810 {
2811 if (node->peragg[i].aggcontext != node->aggcontext)
2813 }
2816
2817 pfree(node->perfunc);
2818 pfree(node->peragg);
2819
2820 outerPlan = outerPlanState(node);
2822}
void ExecEndNode(PlanState *node)
Definition: execProcnode.c:562
#define outerPlanState(node)
Definition: execnodes.h:1255
i
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:252
MemoryContext aggcontext
Definition: execnodes.h:2682
WindowStatePerAgg peragg
Definition: execnodes.h:2632
MemoryContext partcontext
Definition: execnodes.h:2681
Tuplestorestate * buffer
Definition: execnodes.h:2635
WindowStatePerFunc perfunc
Definition: execnodes.h:2631
MemoryContext aggcontext
Definition: nodeWindowAgg.c:159
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 ( WindowAggnode,
EStateestate,
int  eflags 
)

Definition at line 2481 of file nodeWindowAgg.c.

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

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 ( WindowAggStatenode )

Definition at line 2829 of file nodeWindowAgg.c.

2830{
2832 ExprContext *econtext = node->ss.ps.ps_ExprContext;
2833
2834 node->status = WINDOWAGG_RUN;
2835 node->all_first = true;
2836
2837 /* release tuplestore et al */
2838 release_partition(node);
2839
2840 /* release all temp tuples, but especially first_part_slot */
2846 if (node->framehead_slot)
2848 if (node->frametail_slot)
2850
2851 /* Forget current wfunc values */
2852 MemSet(econtext->ecxt_aggvalues, 0, sizeof(Datum) * node->numfuncs);
2853 MemSet(econtext->ecxt_aggnulls, 0, sizeof(bool) * node->numfuncs);
2854
2855 /*
2856 * if chgParam of subnode is not null then plan will be re-scanned by
2857 * first ExecProcNode.
2858 */
2859 if (outerPlan->chgParam == NULL)
2861}
#define MemSet(start, val, len)
Definition: c.h:1019
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().

AltStyle によって変換されたページ (->オリジナル) /