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

535{
537}
void ExecEndNode(PlanState *node)
Definition: execProcnode.c:562
#define outerPlanState(node)
Definition: execnodes.h:1237

References ExecEndNode(), and outerPlanState.

Referenced by ExecEndNode().

◆ ExecInitLimit()

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

Definition at line 447 of file nodeLimit.c.

448{
449 LimitState *limitstate;
451
452 /* check for unsupported flags */
453 Assert(!(eflags & EXEC_FLAG_MARK));
454
455 /*
456 * create state structure
457 */
458 limitstate = makeNode(LimitState);
459 limitstate->ps.plan = (Plan *) node;
460 limitstate->ps.state = estate;
461 limitstate->ps.ExecProcNode = ExecLimit;
462
463 limitstate->lstate = LIMIT_INITIAL;
464
465 /*
466 * Miscellaneous initialization
467 *
468 * Limit nodes never call ExecQual or ExecProject, but they need an
469 * exprcontext anyway to evaluate the limit/offset parameters in.
470 */
471 ExecAssignExprContext(estate, &limitstate->ps);
472
473 /*
474 * initialize outer plan
475 */
476 outerPlan = outerPlan(node);
477 outerPlanState(limitstate) = ExecInitNode(outerPlan, estate, eflags);
478
479 /*
480 * initialize child expressions
481 */
482 limitstate->limitOffset = ExecInitExpr((Expr *) node->limitOffset,
483 (PlanState *) limitstate);
484 limitstate->limitCount = ExecInitExpr((Expr *) node->limitCount,
485 (PlanState *) limitstate);
486 limitstate->limitOption = node->limitOption;
487
488 /*
489 * Initialize result type.
490 */
491 ExecInitResultTypeTL(&limitstate->ps);
492
493 limitstate->ps.resultopsset = true;
494 limitstate->ps.resultops = ExecGetResultSlotOps(outerPlanState(limitstate),
495 &limitstate->ps.resultopsfixed);
496
497 /*
498 * limit nodes do no projections, so initialize projection info for this
499 * node appropriately
500 */
501 limitstate->ps.ps_ProjInfo = NULL;
502
503 /*
504 * Initialize the equality evaluation, to detect ties.
505 */
507 {
508 TupleDesc desc;
509 const TupleTableSlotOps *ops;
510
511 desc = ExecGetResultType(outerPlanState(limitstate));
512 ops = ExecGetResultSlotOps(outerPlanState(limitstate), NULL);
513
514 limitstate->last_slot = ExecInitExtraTupleSlot(estate, desc, ops);
515 limitstate->eqfunction = execTuplesMatchPrepare(desc,
516 node->uniqNumCols,
517 node->uniqColIdx,
518 node->uniqOperators,
519 node->uniqCollations,
520 &limitstate->ps);
521 }
522
523 return limitstate;
524}
#define Assert(condition)
Definition: c.h:815
ExprState * ExecInitExpr(Expr *node, PlanState *parent)
Definition: execExpr.c:143
ExprState * execTuplesMatchPrepare(TupleDesc desc, int numCols, const AttrNumber *keyColIdx, const Oid *eqOperators, const Oid *collations, PlanState *parent)
Definition: execGrouping.c:58
PlanState * ExecInitNode(Plan *node, EState *estate, int eflags)
Definition: execProcnode.c:142
void ExecInitResultTypeTL(PlanState *planstate)
Definition: execTuples.c:1942
TupleTableSlot * ExecInitExtraTupleSlot(EState *estate, TupleDesc tupledesc, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:2018
TupleDesc ExecGetResultType(PlanState *planstate)
Definition: execUtils.c:495
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Definition: execUtils.c:485
const TupleTableSlotOps * ExecGetResultSlotOps(PlanState *planstate, bool *isfixed)
Definition: execUtils.c:504
@ LIMIT_INITIAL
Definition: execnodes.h:2882
#define EXEC_FLAG_MARK
Definition: executor.h:69
static TupleTableSlot * ExecLimit(PlanState *pstate)
Definition: nodeLimit.c:40
@ LIMIT_OPTION_WITH_TIES
Definition: nodes.h:432
#define makeNode(_type_)
Definition: nodes.h:155
#define outerPlan(node)
Definition: plannodes.h:183
PlanState ps
Definition: execnodes.h:2894
ExprState * limitOffset
Definition: execnodes.h:2895
ExprState * limitCount
Definition: execnodes.h:2896
LimitOption limitOption
Definition: execnodes.h:2897
TupleTableSlot * last_slot
Definition: execnodes.h:2906
ExprState * eqfunction
Definition: execnodes.h:2904
LimitStateCond lstate
Definition: execnodes.h:2901
LimitOption limitOption
Definition: plannodes.h:1281
Node * limitCount
Definition: plannodes.h:1278
int uniqNumCols
Definition: plannodes.h:1284
Node * limitOffset
Definition: plannodes.h:1275
const TupleTableSlotOps * resultops
Definition: execnodes.h:1218
bool resultopsset
Definition: execnodes.h:1226
Plan * plan
Definition: execnodes.h:1141
EState * state
Definition: execnodes.h:1143
ProjectionInfo * ps_ProjInfo
Definition: execnodes.h:1181
bool resultopsfixed
Definition: execnodes.h:1222
ExecProcNodeMtd ExecProcNode
Definition: execnodes.h:1147

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

Referenced by ExecInitNode().

◆ ExecReScanLimit()

void ExecReScanLimit ( LimitState node)

Definition at line 541 of file nodeLimit.c.

542{
544
545 /*
546 * Recompute limit/offset in case parameters changed, and reset the state
547 * machine. We must do this before rescanning our child node, in case
548 * it's a Sort that we are passing the parameters down to.
549 */
550 recompute_limits(node);
551
552 /*
553 * if chgParam of subnode is not null then plan will be re-scanned by
554 * first ExecProcNode.
555 */
556 if (outerPlan->chgParam == NULL)
558}
void ExecReScan(PlanState *node)
Definition: execAmi.c:76
static void recompute_limits(LimitState *node)
Definition: nodeLimit.c:353

References ExecReScan(), outerPlan, outerPlanState, and recompute_limits().

Referenced by ExecReScan().