PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
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

void ExecEndLimit ( LimitState node)

Definition at line 431 of file nodeLimit.c.

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

Referenced by ExecEndNode().

432 {
433  ExecFreeExprContext(&node->ps);
435 }
void ExecEndNode(PlanState *node)
Definition: execProcnode.c:523
void ExecFreeExprContext(PlanState *planstate)
Definition: execUtils.c:521
#define outerPlanState(node)
Definition: execnodes.h:893
PlanState ps
Definition: execnodes.h:2034
LimitState* ExecInitLimit ( Limit node,
EState estate,
int  eflags 
)

Definition at line 368 of file nodeLimit.c.

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

Referenced by ExecInitNode().

369 {
370  LimitState *limitstate;
371  Plan *outerPlan;
372 
373  /* check for unsupported flags */
374  Assert(!(eflags & EXEC_FLAG_MARK));
375 
376  /*
377  * create state structure
378  */
379  limitstate = makeNode(LimitState);
380  limitstate->ps.plan = (Plan *) node;
381  limitstate->ps.state = estate;
382  limitstate->ps.ExecProcNode = ExecLimit;
383 
384  limitstate->lstate = LIMIT_INITIAL;
385 
386  /*
387  * Miscellaneous initialization
388  *
389  * Limit nodes never call ExecQual or ExecProject, but they need an
390  * exprcontext anyway to evaluate the limit/offset parameters in.
391  */
392  ExecAssignExprContext(estate, &limitstate->ps);
393 
394  /*
395  * initialize child expressions
396  */
397  limitstate->limitOffset = ExecInitExpr((Expr *) node->limitOffset,
398  (PlanState *) limitstate);
399  limitstate->limitCount = ExecInitExpr((Expr *) node->limitCount,
400  (PlanState *) limitstate);
401 
402  /*
403  * Tuple table initialization (XXX not actually used...)
404  */
405  ExecInitResultTupleSlot(estate, &limitstate->ps);
406 
407  /*
408  * then initialize outer plan
409  */
410  outerPlan = outerPlan(node);
411  outerPlanState(limitstate) = ExecInitNode(outerPlan, estate, eflags);
412 
413  /*
414  * limit nodes do no projections, so initialize projection info for this
415  * node appropriately
416  */
417  ExecAssignResultTypeFromTL(&limitstate->ps);
418  limitstate->ps.ps_ProjInfo = NULL;
419 
420  return limitstate;
421 }
static TupleTableSlot * ExecLimit(PlanState *pstate)
Definition: nodeLimit.c:41
ProjectionInfo * ps_ProjInfo
Definition: execnodes.h:882
EState * state
Definition: execnodes.h:849
LimitStateCond lstate
Definition: execnodes.h:2040
ExprState * limitCount
Definition: execnodes.h:2036
Node * limitOffset
Definition: plannodes.h:915
void ExecAssignResultTypeFromTL(PlanState *planstate)
Definition: execUtils.c:445
void ExecInitResultTupleSlot(EState *estate, PlanState *planstate)
Definition: execTuples.c:832
Node * limitCount
Definition: plannodes.h:916
#define outerPlanState(node)
Definition: execnodes.h:893
ExprState * limitOffset
Definition: execnodes.h:2035
#define outerPlan(node)
Definition: plannodes.h:174
ExecProcNodeMtd ExecProcNode
Definition: execnodes.h:853
Plan * plan
Definition: execnodes.h:847
#define makeNode(_type_)
Definition: nodes.h:557
#define NULL
Definition: c.h:229
#define Assert(condition)
Definition: c.h:676
#define EXEC_FLAG_MARK
Definition: executor.h:61
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Definition: execUtils.c:423
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:2034
void ExecReScanLimit ( LimitState node)

Definition at line 439 of file nodeLimit.c.

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

Referenced by ExecReScan().

440 {
441  /*
442  * Recompute limit/offset in case parameters changed, and reset the state
443  * machine. We must do this before rescanning our child node, in case
444  * it's a Sort that we are passing the parameters down to.
445  */
446  recompute_limits(node);
447 
448  /*
449  * if chgParam of subnode is not null then plan will be re-scanned by
450  * first ExecProcNode.
451  */
452  if (node->ps.lefttree->chgParam == NULL)
453  ExecReScan(node->ps.lefttree);
454 }
void ExecReScan(PlanState *node)
Definition: execAmi.c:76
struct PlanState * lefttree
Definition: execnodes.h:866
Bitmapset * chgParam
Definition: execnodes.h:875
#define NULL
Definition: c.h:229
static void recompute_limits(LimitState *node)
Definition: nodeLimit.c:236
PlanState ps
Definition: execnodes.h:2034