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 382 of file nodeLockRows.c.

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

Referenced by ExecEndNode().

383 {
386 }
EPQState lr_epqstate
Definition: execnodes.h:2321
void ExecEndNode(PlanState *node)
Definition: execProcnode.c:537
void EvalPlanQualEnd(EPQState *epqstate)
Definition: execMain.c:2944
#define outerPlanState(node)
Definition: execnodes.h:1033

◆ ExecInitLockRows()

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

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

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

◆ ExecReScanLockRows()

void ExecReScanLockRows ( LockRowsState node)

Definition at line 390 of file nodeLockRows.c.

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

Referenced by ExecReScan().

391 {
392  /*
393  * if chgParam of subnode is not null then plan will be re-scanned by
394  * first ExecProcNode.
395  */
396  if (node->ps.lefttree->chgParam == NULL)
397  ExecReScan(node->ps.lefttree);
398 }
void ExecReScan(PlanState *node)
Definition: execAmi.c:75
struct PlanState * lefttree
Definition: execnodes.h:961
PlanState ps
Definition: execnodes.h:2319
Bitmapset * chgParam
Definition: execnodes.h:971