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

Go to the source code of this file.

Functions

UniqueStateExecInitUnique (Unique *node, EState *estate, int eflags)
 
void ExecEndUnique (UniqueState *node)
 
void ExecReScanUnique (UniqueState *node)
 

Function Documentation

◆ ExecEndUnique()

void ExecEndUnique ( UniqueState node)

Definition at line 168 of file nodeUnique.c.

References ExecClearTuple(), ExecEndNode(), ExecFreeExprContext(), outerPlanState, UniqueState::ps, and PlanState::ps_ResultTupleSlot.

Referenced by ExecEndNode().

169 {
170  /* clean up tuple table */
172 
173  ExecFreeExprContext(&node->ps);
174 
176 }
void ExecEndNode(PlanState *node)
Definition: execProcnode.c:538
TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: execTuples.c:475
void ExecFreeExprContext(PlanState *planstate)
Definition: execUtils.c:566
TupleTableSlot * ps_ResultTupleSlot
Definition: execnodes.h:946
#define outerPlanState(node)
Definition: execnodes.h:966
PlanState ps
Definition: execnodes.h:2040

◆ ExecInitUnique()

UniqueState* ExecInitUnique ( Unique node,
EState estate,
int  eflags 
)

Definition at line 115 of file nodeUnique.c.

References Assert, UniqueState::eqfunction, EXEC_FLAG_BACKWARD, EXEC_FLAG_MARK, ExecAssignExprContext(), ExecGetResultType(), ExecInitNode(), ExecInitResultTupleSlotTL(), PlanState::ExecProcNode, execTuplesMatchPrepare(), ExecUnique(), makeNode, Unique::numCols, outerPlan, outerPlanState, PlanState::plan, UniqueState::ps, PlanState::ps_ProjInfo, PlanState::state, Unique::uniqColIdx, and Unique::uniqOperators.

Referenced by ExecInitNode().

116 {
117  UniqueState *uniquestate;
118 
119  /* check for unsupported flags */
120  Assert(!(eflags & (EXEC_FLAG_BACKWARD | EXEC_FLAG_MARK)));
121 
122  /*
123  * create state structure
124  */
125  uniquestate = makeNode(UniqueState);
126  uniquestate->ps.plan = (Plan *) node;
127  uniquestate->ps.state = estate;
128  uniquestate->ps.ExecProcNode = ExecUnique;
129 
130  /*
131  * create expression context
132  */
133  ExecAssignExprContext(estate, &uniquestate->ps);
134 
135  /*
136  * then initialize outer plan
137  */
138  outerPlanState(uniquestate) = ExecInitNode(outerPlan(node), estate, eflags);
139 
140  /*
141  * Initialize result slot and type. Unique nodes do no projections, so
142  * initialize projection info for this node appropriately.
143  */
144  ExecInitResultTupleSlotTL(estate, &uniquestate->ps);
145  uniquestate->ps.ps_ProjInfo = NULL;
146 
147  /*
148  * Precompute fmgr lookup data for inner loop
149  */
150  uniquestate->eqfunction =
152  node->numCols,
153  node->uniqColIdx,
154  node->uniqOperators,
155  &uniquestate->ps);
156 
157  return uniquestate;
158 }
int numCols
Definition: plannodes.h:841
ProjectionInfo * ps_ProjInfo
Definition: execnodes.h:948
EState * state
Definition: execnodes.h:914
Oid * uniqOperators
Definition: plannodes.h:843
ExprState * eqfunction
Definition: execnodes.h:2041
#define EXEC_FLAG_BACKWARD
Definition: executor.h:60
#define outerPlanState(node)
Definition: execnodes.h:966
PlanState ps
Definition: execnodes.h:2040
#define outerPlan(node)
Definition: plannodes.h:177
AttrNumber * uniqColIdx
Definition: plannodes.h:842
ExecProcNodeMtd ExecProcNode
Definition: execnodes.h:918
void ExecInitResultTupleSlotTL(EState *estate, PlanState *planstate)
Definition: execTuples.c:890
Plan * plan
Definition: execnodes.h:912
ExprState * execTuplesMatchPrepare(TupleDesc desc, int numCols, AttrNumber *keyColIdx, Oid *eqOperators, PlanState *parent)
Definition: execGrouping.c:60
#define makeNode(_type_)
Definition: nodes.h:564
#define Assert(condition)
Definition: c.h:699
#define EXEC_FLAG_MARK
Definition: executor.h:61
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Definition: execUtils.c:428
TupleDesc ExecGetResultType(PlanState *planstate)
Definition: execUtils.c:438
static TupleTableSlot * ExecUnique(PlanState *pstate)
Definition: nodeUnique.c:47
PlanState * ExecInitNode(Plan *node, EState *estate, int eflags)
Definition: execProcnode.c:139

◆ ExecReScanUnique()

void ExecReScanUnique ( UniqueState node)

Definition at line 180 of file nodeUnique.c.

References PlanState::chgParam, ExecClearTuple(), ExecReScan(), PlanState::lefttree, UniqueState::ps, and PlanState::ps_ResultTupleSlot.

Referenced by ExecReScan().

181 {
182  /* must clear result tuple so first input tuple is returned */
184 
185  /*
186  * if chgParam of subnode is not null then plan will be re-scanned by
187  * first ExecProcNode.
188  */
189  if (node->ps.lefttree->chgParam == NULL)
190  ExecReScan(node->ps.lefttree);
191 }
void ExecReScan(PlanState *node)
Definition: execAmi.c:76
TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: execTuples.c:475
struct PlanState * lefttree
Definition: execnodes.h:931
TupleTableSlot * ps_ResultTupleSlot
Definition: execnodes.h:946
PlanState ps
Definition: execnodes.h:2040
Bitmapset * chgParam
Definition: execnodes.h:941