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

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

Referenced by ExecEndNode().

405 {
406  ExecFreeExprContext(&node->ps);
408 }
void ExecEndNode(PlanState *node)
Definition: execProcnode.c:538
void ExecFreeExprContext(PlanState *planstate)
Definition: execUtils.c:614
#define outerPlanState(node)
Definition: execnodes.h:1034
PlanState ps
Definition: execnodes.h:2350

◆ ExecInitLimit()

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

Definition at line 338 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().

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

◆ ExecReScanLimit()

void ExecReScanLimit ( LimitState node)

Definition at line 412 of file nodeLimit.c.

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

Referenced by ExecReScan().

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