PostgreSQL Source Code  git master
nodeLockRows.h File Reference
#include "nodes/execnodes.h"
Include dependency graph for nodeLockRows.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

LockRowsStateExecInitLockRows (LockRows *node, EState *estate, int eflags)
 
void ExecEndLockRows (LockRowsState *node)
 
void ExecReScanLockRows (LockRowsState *node)
 

Function Documentation

◆ ExecEndLockRows()

void ExecEndLockRows ( LockRowsState node)

Definition at line 386 of file nodeLockRows.c.

References EvalPlanQualEnd(), ExecEndNode(), LockRowsState::lr_epqstate, and outerPlanState.

Referenced by ExecEndNode().

387 {
388  /* We may have shut down EPQ already, but no harm in another call */
391 }
EPQState lr_epqstate
Definition: execnodes.h:2599
void ExecEndNode(PlanState *node)
Definition: execProcnode.c:556
void EvalPlanQualEnd(EPQState *epqstate)
Definition: execMain.c:2834
#define outerPlanState(node)
Definition: execnodes.h:1062

◆ ExecInitLockRows()

LockRowsState* ExecInitLockRows ( LockRows node,
EState estate,
int  eflags 
)

Definition at line 292 of file nodeLockRows.c.

References Assert, LockRows::epqParam, EvalPlanQualInit(), EXEC_FLAG_MARK, ExecBuildAuxRowMark(), ExecFindRowMark(), ExecGetResultSlotOps(), ExecInitNode(), ExecInitResultTypeTL(), ExecLockRows(), PlanState::ExecProcNode, PlanRowMark::isParent, lappend(), lfirst_node, LockRowsState::lr_arowMarks, LockRowsState::lr_epqstate, makeNode, ExecRowMark::markType, NIL, outerPlan, outerPlanState, PlanState::plan, LockRowsState::ps, PlanState::ps_ProjInfo, PlanState::resultops, PlanState::resultopsfixed, PlanState::resultopsset, RowMarkRequiresRowShareLock, LockRows::rowMarks, PlanRowMark::rti, PlanState::state, and Plan::targetlist.

Referenced by ExecInitNode().

293 {
294  LockRowsState *lrstate;
295  Plan *outerPlan = outerPlan(node);
296  List *epq_arowmarks;
297  ListCell *lc;
298 
299  /* check for unsupported flags */
300  Assert(!(eflags & EXEC_FLAG_MARK));
301 
302  /*
303  * create state structure
304  */
305  lrstate = makeNode(LockRowsState);
306  lrstate->ps.plan = (Plan *) node;
307  lrstate->ps.state = estate;
308  lrstate->ps.ExecProcNode = ExecLockRows;
309 
310  /*
311  * Miscellaneous initialization
312  *
313  * LockRows nodes never call ExecQual or ExecProject, therefore no
314  * ExprContext is needed.
315  */
316 
317  /*
318  * Initialize result type.
319  */
320  ExecInitResultTypeTL(&lrstate->ps);
321 
322  /*
323  * then initialize outer plan
324  */
325  outerPlanState(lrstate) = ExecInitNode(outerPlan, estate, eflags);
326 
327  /* node returns unmodified slots from the outer plan */
328  lrstate->ps.resultopsset = true;
329  lrstate->ps.resultops = ExecGetResultSlotOps(outerPlanState(lrstate),
330  &lrstate->ps.resultopsfixed);
331 
332  /*
333  * LockRows nodes do no projections, so initialize projection info for
334  * this node appropriately
335  */
336  lrstate->ps.ps_ProjInfo = NULL;
337 
338  /*
339  * Locate the ExecRowMark(s) that this node is responsible for, and
340  * construct ExecAuxRowMarks for them. (InitPlan should already have
341  * built the global list of ExecRowMarks.)
342  */
343  lrstate->lr_arowMarks = NIL;
344  epq_arowmarks = NIL;
345  foreach(lc, node->rowMarks)
346  {
348  ExecRowMark *erm;
349  ExecAuxRowMark *aerm;
350 
351  /* ignore "parent" rowmarks; they are irrelevant at runtime */
352  if (rc->isParent)
353  continue;
354 
355  /* find ExecRowMark and build ExecAuxRowMark */
356  erm = ExecFindRowMark(estate, rc->rti, false);
357  aerm = ExecBuildAuxRowMark(erm, outerPlan->targetlist);
358 
359  /*
360  * Only locking rowmarks go into our own list. Non-locking marks are
361  * passed off to the EvalPlanQual machinery. This is because we don't
362  * want to bother fetching non-locked rows unless we actually have to
363  * do an EPQ recheck.
364  */
366  lrstate->lr_arowMarks = lappend(lrstate->lr_arowMarks, aerm);
367  else
368  epq_arowmarks = lappend(epq_arowmarks, aerm);
369  }
370 
371  /* Now we have the info needed to set up EPQ state */
372  EvalPlanQualInit(&lrstate->lr_epqstate, estate,
373  outerPlan, epq_arowmarks, node->epqParam);
374 
375  return lrstate;
376 }
#define NIL
Definition: pg_list.h:65
ProjectionInfo * ps_ProjInfo
Definition: execnodes.h:1006
const TupleTableSlotOps * ExecGetResultSlotOps(PlanState *planstate, bool *isfixed)
Definition: execUtils.c:499
EPQState lr_epqstate
Definition: execnodes.h:2599
static TupleTableSlot * ExecLockRows(PlanState *pstate)
Definition: nodeLockRows.c:38
int epqParam
Definition: plannodes.h:1014
EState * state
Definition: execnodes.h:968
#define RowMarkRequiresRowShareLock(marktype)
Definition: plannodes.h:1077
const TupleTableSlotOps * resultops
Definition: execnodes.h:1043
#define lfirst_node(type, lc)
Definition: pg_list.h:172
#define outerPlanState(node)
Definition: execnodes.h:1062
PlanState ps
Definition: execnodes.h:2597
void ExecInitResultTypeTL(PlanState *planstate)
Definition: execTuples.c:1755
bool resultopsset
Definition: execnodes.h:1051
#define outerPlan(node)
Definition: plannodes.h:171
List * lappend(List *list, void *datum)
Definition: list.c:336
void EvalPlanQualInit(EPQState *epqstate, EState *parentestate, Plan *subplan, List *auxrowmarks, int epqParam)
Definition: execMain.c:2413
ExecProcNodeMtd ExecProcNode
Definition: execnodes.h:972
Plan * plan
Definition: execnodes.h:966
#define makeNode(_type_)
Definition: nodes.h:584
#define Assert(condition)
Definition: c.h:804
#define EXEC_FLAG_MARK
Definition: executor.h:59
List * rowMarks
Definition: plannodes.h:1013
RowMarkType markType
Definition: execnodes.h:677
List * targetlist
Definition: plannodes.h:141
bool resultopsfixed
Definition: execnodes.h:1047
List * lr_arowMarks
Definition: execnodes.h:2598
bool isParent
Definition: plannodes.h:1127
PlanState * ExecInitNode(Plan *node, EState *estate, int eflags)
Definition: execProcnode.c:141
Definition: pg_list.h:50
ExecAuxRowMark * ExecBuildAuxRowMark(ExecRowMark *erm, List *targetlist)
Definition: execMain.c:2289
ExecRowMark * ExecFindRowMark(EState *estate, Index rti, bool missing_ok)
Definition: execMain.c:2266

◆ ExecReScanLockRows()

void ExecReScanLockRows ( LockRowsState node)

Definition at line 395 of file nodeLockRows.c.

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

Referenced by ExecReScan().

396 {
397  /*
398  * if chgParam of subnode is not null then plan will be re-scanned by
399  * first ExecProcNode.
400  */
401  if (node->ps.lefttree->chgParam == NULL)
402  ExecReScan(node->ps.lefttree);
403 }
void ExecReScan(PlanState *node)
Definition: execAmi.c:78
struct PlanState * lefttree
Definition: execnodes.h:988
PlanState ps
Definition: execnodes.h:2597
Bitmapset * chgParam
Definition: execnodes.h:998