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 393 of file nodeLimit.c.

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

Referenced by ExecEndNode().

394 {
395  ExecFreeExprContext(&node->ps);
397 }
void ExecEndNode(PlanState *node)
Definition: execProcnode.c:538
void ExecFreeExprContext(PlanState *planstate)
Definition: execUtils.c:566
#define outerPlanState(node)
Definition: execnodes.h:966
PlanState ps
Definition: execnodes.h:2210

◆ ExecInitLimit()

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

Definition at line 330 of file nodeLimit.c.

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

Referenced by ExecInitNode().

331 {
332  LimitState *limitstate;
333  Plan *outerPlan;
334 
335  /* check for unsupported flags */
336  Assert(!(eflags & EXEC_FLAG_MARK));
337 
338  /*
339  * create state structure
340  */
341  limitstate = makeNode(LimitState);
342  limitstate->ps.plan = (Plan *) node;
343  limitstate->ps.state = estate;
344  limitstate->ps.ExecProcNode = ExecLimit;
345 
346  limitstate->lstate = LIMIT_INITIAL;
347 
348  /*
349  * Miscellaneous initialization
350  *
351  * Limit nodes never call ExecQual or ExecProject, but they need an
352  * exprcontext anyway to evaluate the limit/offset parameters in.
353  */
354  ExecAssignExprContext(estate, &limitstate->ps);
355 
356  /*
357  * initialize outer plan
358  */
359  outerPlan = outerPlan(node);
360  outerPlanState(limitstate) = ExecInitNode(outerPlan, estate, eflags);
361 
362  /*
363  * initialize child expressions
364  */
365  limitstate->limitOffset = ExecInitExpr((Expr *) node->limitOffset,
366  (PlanState *) limitstate);
367  limitstate->limitCount = ExecInitExpr((Expr *) node->limitCount,
368  (PlanState *) limitstate);
369 
370  /*
371  * Initialize result slot and type. (XXX not actually used, but upper
372  * nodes access it to get this node's result tupledesc...)
373  */
374  ExecInitResultTupleSlotTL(estate, &limitstate->ps);
375 
376  /*
377  * limit nodes do no projections, so initialize projection info for this
378  * node appropriately
379  */
380  limitstate->ps.ps_ProjInfo = NULL;
381 
382  return limitstate;
383 }
static TupleTableSlot * ExecLimit(PlanState *pstate)
Definition: nodeLimit.c:41
ProjectionInfo * ps_ProjInfo
Definition: execnodes.h:948
EState * state
Definition: execnodes.h:914
LimitStateCond lstate
Definition: execnodes.h:2216
ExprState * limitCount
Definition: execnodes.h:2212
Node * limitOffset
Definition: plannodes.h:949
Node * limitCount
Definition: plannodes.h:950
#define outerPlanState(node)
Definition: execnodes.h:966
ExprState * limitOffset
Definition: execnodes.h:2211
#define outerPlan(node)
Definition: plannodes.h:177
ExecProcNodeMtd ExecProcNode
Definition: execnodes.h:918
void ExecInitResultTupleSlotTL(EState *estate, PlanState *planstate)
Definition: execTuples.c:890
Plan * plan
Definition: execnodes.h:912
#define makeNode(_type_)
Definition: nodes.h:564
#define Assert(condition)
Definition: c.h:699
#define EXEC_FLAG_MARK
Definition: executor.h:61
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Definition: execUtils.c:428
ExprState * ExecInitExpr(Expr *node, PlanState *parent)
Definition: execExpr.c:119
PlanState * ExecInitNode(Plan *node, EState *estate, int eflags)
Definition: execProcnode.c:139
PlanState ps
Definition: execnodes.h:2210

◆ ExecReScanLimit()

void ExecReScanLimit ( LimitState node)

Definition at line 401 of file nodeLimit.c.

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

Referenced by ExecReScan().

402 {
403  /*
404  * Recompute limit/offset in case parameters changed, and reset the state
405  * machine. We must do this before rescanning our child node, in case
406  * it's a Sort that we are passing the parameters down to.
407  */
408  recompute_limits(node);
409 
410  /*
411  * if chgParam of subnode is not null then plan will be re-scanned by
412  * first ExecProcNode.
413  */
414  if (node->ps.lefttree->chgParam == NULL)
415  ExecReScan(node->ps.lefttree);
416 }
void ExecReScan(PlanState *node)
Definition: execAmi.c:76
struct PlanState * lefttree
Definition: execnodes.h:931
Bitmapset * chgParam
Definition: execnodes.h:941
static void recompute_limits(LimitState *node)
Definition: nodeLimit.c:236
PlanState ps
Definition: execnodes.h:2210