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:523
void ExecFreeExprContext(PlanState *planstate)
Definition: execUtils.c:603
#define outerPlanState(node)
Definition: execnodes.h:896
PlanState ps
Definition: execnodes.h:2101

◆ ExecInitLimit()

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

Definition at line 330 of file nodeLimit.c.

References Assert, EXEC_FLAG_MARK, ExecAssignExprContext(), ExecAssignResultTypeFromTL(), ExecInitExpr(), ExecInitNode(), ExecInitResultTupleSlot(), 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 child expressions
358  */
359  limitstate->limitOffset = ExecInitExpr((Expr *) node->limitOffset,
360  (PlanState *) limitstate);
361  limitstate->limitCount = ExecInitExpr((Expr *) node->limitCount,
362  (PlanState *) limitstate);
363 
364  /*
365  * Tuple table initialization (XXX not actually used...)
366  */
367  ExecInitResultTupleSlot(estate, &limitstate->ps);
368 
369  /*
370  * then initialize outer plan
371  */
372  outerPlan = outerPlan(node);
373  outerPlanState(limitstate) = ExecInitNode(outerPlan, estate, eflags);
374 
375  /*
376  * limit nodes do no projections, so initialize projection info for this
377  * node appropriately
378  */
379  ExecAssignResultTypeFromTL(&limitstate->ps);
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:885
EState * state
Definition: execnodes.h:852
LimitStateCond lstate
Definition: execnodes.h:2107
ExprState * limitCount
Definition: execnodes.h:2103
Node * limitOffset
Definition: plannodes.h:929
void ExecAssignResultTypeFromTL(PlanState *planstate)
Definition: execUtils.c:448
void ExecInitResultTupleSlot(EState *estate, PlanState *planstate)
Definition: execTuples.c:832
Node * limitCount
Definition: plannodes.h:930
#define outerPlanState(node)
Definition: execnodes.h:896
ExprState * limitOffset
Definition: execnodes.h:2102
#define outerPlan(node)
Definition: plannodes.h:174
ExecProcNodeMtd ExecProcNode
Definition: execnodes.h:856
Plan * plan
Definition: execnodes.h:850
#define makeNode(_type_)
Definition: nodes.h:560
#define Assert(condition)
Definition: c.h:670
#define EXEC_FLAG_MARK
Definition: executor.h:61
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Definition: execUtils.c:426
ExprState * ExecInitExpr(Expr *node, PlanState *parent)
Definition: execExpr.c:113
PlanState * ExecInitNode(Plan *node, EState *estate, int eflags)
Definition: execProcnode.c:139
PlanState ps
Definition: execnodes.h:2101

◆ 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:869
Bitmapset * chgParam
Definition: execnodes.h:878
static void recompute_limits(LimitState *node)
Definition: nodeLimit.c:236
PlanState ps
Definition: execnodes.h:2101