PostgreSQL Source Code  git master
nodeLimit.h File Reference
#include "nodes/execnodes.h"
Include dependency graph for nodeLimit.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

LimitStateExecInitLimit (Limit *node, EState *estate, int eflags)
 
void ExecEndLimit (LimitState *node)
 
void ExecReScanLimit (LimitState *node)
 

Function Documentation

◆ ExecEndLimit()

void ExecEndLimit ( LimitState node)

Definition at line 402 of file nodeLimit.c.

References ExecEndNode(), ExecFreeExprContext(), outerPlanState, and LimitState::ps.

Referenced by ExecEndNode().

403 {
404  ExecFreeExprContext(&node->ps);
406 }
void ExecEndNode(PlanState *node)
Definition: execProcnode.c:537
void ExecFreeExprContext(PlanState *planstate)
Definition: execUtils.c:614
#define outerPlanState(node)
Definition: execnodes.h:1033
PlanState ps
Definition: execnodes.h:2349

◆ ExecInitLimit()

LimitState* ExecInitLimit ( Limit node,
EState estate,
int  eflags 
)

Definition at line 336 of file nodeLimit.c.

References Assert, EXEC_FLAG_MARK, ExecAssignExprContext(), ExecGetResultSlotOps(), ExecInitExpr(), ExecInitNode(), ExecInitResultTypeTL(), ExecLimit(), PlanState::ExecProcNode, LIMIT_INITIAL, Limit::limitCount, Limit::limitOffset, LimitState::limitOffset, LimitState::lstate, makeNode, outerPlan, outerPlanState, PlanState::plan, LimitState::ps, PlanState::ps_ProjInfo, PlanState::resultops, PlanState::resultopsfixed, PlanState::resultopsset, and PlanState::state.

Referenced by ExecInitNode().

337 {
338  LimitState *limitstate;
339  Plan *outerPlan;
340 
341  /* check for unsupported flags */
342  Assert(!(eflags & EXEC_FLAG_MARK));
343 
344  /*
345  * create state structure
346  */
347  limitstate = makeNode(LimitState);
348  limitstate->ps.plan = (Plan *) node;
349  limitstate->ps.state = estate;
350  limitstate->ps.ExecProcNode = ExecLimit;
351 
352  limitstate->lstate = LIMIT_INITIAL;
353 
354  /*
355  * Miscellaneous initialization
356  *
357  * Limit nodes never call ExecQual or ExecProject, but they need an
358  * exprcontext anyway to evaluate the limit/offset parameters in.
359  */
360  ExecAssignExprContext(estate, &limitstate->ps);
361 
362  /*
363  * initialize outer plan
364  */
365  outerPlan = outerPlan(node);
366  outerPlanState(limitstate) = ExecInitNode(outerPlan, estate, eflags);
367 
368  /*
369  * initialize child expressions
370  */
371  limitstate->limitOffset = ExecInitExpr((Expr *) node->limitOffset,
372  (PlanState *) limitstate);
373  limitstate->limitCount = ExecInitExpr((Expr *) node->limitCount,
374  (PlanState *) limitstate);
375 
376  /*
377  * Initialize result type.
378  */
379  ExecInitResultTypeTL(&limitstate->ps);
380 
381  limitstate->ps.resultopsset = true;
382  limitstate->ps.resultops = ExecGetResultSlotOps(outerPlanState(limitstate),
383  &limitstate->ps.resultopsfixed);
384 
385  /*
386  * limit nodes do no projections, so initialize projection info for this
387  * node appropriately
388  */
389  limitstate->ps.ps_ProjInfo = NULL;
390 
391  return limitstate;
392 }
static TupleTableSlot * ExecLimit(PlanState *pstate)
Definition: nodeLimit.c:41
ProjectionInfo * ps_ProjInfo
Definition: execnodes.h:979
const TupleTableSlotOps * ExecGetResultSlotOps(PlanState *planstate, bool *isfixed)
Definition: execUtils.c:463
EState * state
Definition: execnodes.h:941
LimitStateCond lstate
Definition: execnodes.h:2355
ExprState * limitCount
Definition: execnodes.h:2351
Node * limitOffset
Definition: plannodes.h:968
const TupleTableSlotOps * resultops
Definition: execnodes.h:1014
Node * limitCount
Definition: plannodes.h:969
#define outerPlanState(node)
Definition: execnodes.h:1033
void ExecInitResultTypeTL(PlanState *planstate)
Definition: execTuples.c:1725
ExprState * limitOffset
Definition: execnodes.h:2350
bool resultopsset
Definition: execnodes.h:1022
#define outerPlan(node)
Definition: plannodes.h:170
ExecProcNodeMtd ExecProcNode
Definition: execnodes.h:945
Plan * plan
Definition: execnodes.h:939
#define makeNode(_type_)
Definition: nodes.h:573
#define Assert(condition)
Definition: c.h:739
#define EXEC_FLAG_MARK
Definition: executor.h:59
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Definition: execUtils.c:444
bool resultopsfixed
Definition: execnodes.h:1018
ExprState * ExecInitExpr(Expr *node, PlanState *parent)
Definition: execExpr.c:121
PlanState * ExecInitNode(Plan *node, EState *estate, int eflags)
Definition: execProcnode.c:138
PlanState ps
Definition: execnodes.h:2349

◆ ExecReScanLimit()

void ExecReScanLimit ( LimitState node)

Definition at line 410 of file nodeLimit.c.

References PlanState::chgParam, ExecReScan(), PlanState::lefttree, LimitState::ps, and recompute_limits().

Referenced by ExecReScan().

411 {
412  /*
413  * Recompute limit/offset in case parameters changed, and reset the state
414  * machine. We must do this before rescanning our child node, in case
415  * it's a Sort that we are passing the parameters down to.
416  */
417  recompute_limits(node);
418 
419  /*
420  * if chgParam of subnode is not null then plan will be re-scanned by
421  * first ExecProcNode.
422  */
423  if (node->ps.lefttree->chgParam == NULL)
424  ExecReScan(node->ps.lefttree);
425 }
void ExecReScan(PlanState *node)
Definition: execAmi.c:75
struct PlanState * lefttree
Definition: execnodes.h:961
Bitmapset * chgParam
Definition: execnodes.h:971
static void recompute_limits(LimitState *node)
Definition: nodeLimit.c:242
PlanState ps
Definition: execnodes.h:2349