PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
nodeWorktablescan.h File Reference
#include "nodes/execnodes.h"
Include dependency graph for nodeWorktablescan.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

WorkTableScanStateExecInitWorkTableScan (WorkTableScan *node, EState *estate, int eflags)
 
TupleTableSlotExecWorkTableScan (WorkTableScanState *node)
 
void ExecEndWorkTableScan (WorkTableScanState *node)
 
void ExecReScanWorkTableScan (WorkTableScanState *node)
 

Function Documentation

void ExecEndWorkTableScan ( WorkTableScanState node)

Definition at line 183 of file nodeWorktablescan.c.

References ExecClearTuple(), ExecFreeExprContext(), ScanState::ps, PlanState::ps_ResultTupleSlot, WorkTableScanState::ss, and ScanState::ss_ScanTupleSlot.

Referenced by ExecEndNode().

184 {
185  /*
186  * Free exprcontext
187  */
188  ExecFreeExprContext(&node->ss.ps);
189 
190  /*
191  * clean out the tuple table
192  */
195 }
TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: execTuples.c:439
TupleTableSlot * ss_ScanTupleSlot
Definition: execnodes.h:1050
void ExecFreeExprContext(PlanState *planstate)
Definition: execUtils.c:516
PlanState ps
Definition: execnodes.h:1047
TupleTableSlot * ps_ResultTupleSlot
Definition: execnodes.h:832
WorkTableScanState* ExecInitWorkTableScan ( WorkTableScan node,
EState estate,
int  eflags 
)

Definition at line 128 of file nodeWorktablescan.c.

References Assert, EXEC_FLAG_BACKWARD, EXEC_FLAG_MARK, ExecAssignExprContext(), ExecAssignResultTypeFromTL(), ExecInitQual(), ExecInitResultTupleSlot(), ExecInitScanTupleSlot(), innerPlan, makeNode, NULL, outerPlan, Scan::plan, PlanState::plan, ScanState::ps, Plan::qual, PlanState::qual, WorkTableScanState::rustate, WorkTableScan::scan, WorkTableScanState::ss, and PlanState::state.

Referenced by ExecInitNode().

129 {
130  WorkTableScanState *scanstate;
131 
132  /* check for unsupported flags */
133  Assert(!(eflags & (EXEC_FLAG_BACKWARD | EXEC_FLAG_MARK)));
134 
135  /*
136  * WorkTableScan should not have any children.
137  */
138  Assert(outerPlan(node) == NULL);
139  Assert(innerPlan(node) == NULL);
140 
141  /*
142  * create new WorkTableScanState for node
143  */
144  scanstate = makeNode(WorkTableScanState);
145  scanstate->ss.ps.plan = (Plan *) node;
146  scanstate->ss.ps.state = estate;
147  scanstate->rustate = NULL; /* we'll set this later */
148 
149  /*
150  * Miscellaneous initialization
151  *
152  * create expression context for node
153  */
154  ExecAssignExprContext(estate, &scanstate->ss.ps);
155 
156  /*
157  * initialize child expressions
158  */
159  scanstate->ss.ps.qual =
160  ExecInitQual(node->scan.plan.qual, (PlanState *) scanstate);
161 
162  /*
163  * tuple table initialization
164  */
165  ExecInitResultTupleSlot(estate, &scanstate->ss.ps);
166  ExecInitScanTupleSlot(estate, &scanstate->ss);
167 
168  /*
169  * Initialize result tuple type, but not yet projection info.
170  */
171  ExecAssignResultTypeFromTL(&scanstate->ss.ps);
172 
173  return scanstate;
174 }
List * qual
Definition: plannodes.h:135
Plan plan
Definition: plannodes.h:317
void ExecInitScanTupleSlot(EState *estate, ScanState *scanstate)
Definition: execTuples.c:842
EState * state
Definition: execnodes.h:805
ExprState * ExecInitQual(List *qual, PlanState *parent)
Definition: execExpr.c:160
void ExecAssignResultTypeFromTL(PlanState *planstate)
Definition: execUtils.c:440
PlanState ps
Definition: execnodes.h:1047
void ExecInitResultTupleSlot(EState *estate, PlanState *planstate)
Definition: execTuples.c:832
#define EXEC_FLAG_BACKWARD
Definition: executor.h:60
#define innerPlan(node)
Definition: plannodes.h:163
#define outerPlan(node)
Definition: plannodes.h:164
RecursiveUnionState * rustate
Definition: execnodes.h:1480
Plan * plan
Definition: execnodes.h:803
#define makeNode(_type_)
Definition: nodes.h:557
#define NULL
Definition: c.h:229
#define Assert(condition)
Definition: c.h:675
#define EXEC_FLAG_MARK
Definition: executor.h:61
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Definition: execUtils.c:418
ExprState * qual
Definition: execnodes.h:817
void ExecReScanWorkTableScan ( WorkTableScanState node)

Definition at line 204 of file nodeWorktablescan.c.

References ExecClearTuple(), ExecScanReScan(), ScanState::ps, PlanState::ps_ResultTupleSlot, WorkTableScanState::rustate, WorkTableScanState::ss, tuplestore_rescan(), and RecursiveUnionState::working_table.

Referenced by ExecReScan().

205 {
207 
208  ExecScanReScan(&node->ss);
209 
210  /* No need (or way) to rescan if ExecWorkTableScan not called yet */
211  if (node->rustate)
213 }
void tuplestore_rescan(Tuplestorestate *state)
Definition: tuplestore.c:1233
TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: execTuples.c:439
PlanState ps
Definition: execnodes.h:1047
TupleTableSlot * ps_ResultTupleSlot
Definition: execnodes.h:832
Tuplestorestate * working_table
Definition: execnodes.h:994
RecursiveUnionState * rustate
Definition: execnodes.h:1480
void ExecScanReScan(ScanState *node)
Definition: execScan.c:327
TupleTableSlot* ExecWorkTableScan ( WorkTableScanState node)

Definition at line 81 of file nodeWorktablescan.c.

References Assert, castNode, DatumGetPointer, ExecAssignScanProjectionInfo(), ExecAssignScanType(), ExecGetResultType(), ExecScan(), NULL, PlanState::plan, RecursiveUnionState::ps, ScanState::ps, WorkTableScanState::rustate, WorkTableScanState::ss, PlanState::state, WorkTableScanNext(), WorkTableScanRecheck(), and WorkTableScan::wtParam.

Referenced by ExecProcNode().

82 {
83  /*
84  * On the first call, find the ancestor RecursiveUnion's state via the
85  * Param slot reserved for it. (We can't do this during node init because
86  * there are corner cases where we'll get the init call before the
87  * RecursiveUnion does.)
88  */
89  if (node->rustate == NULL)
90  {
91  WorkTableScan *plan = (WorkTableScan *) node->ss.ps.plan;
92  EState *estate = node->ss.ps.state;
93  ParamExecData *param;
94 
95  param = &(estate->es_param_exec_vals[plan->wtParam]);
96  Assert(param->execPlan == NULL);
97  Assert(!param->isnull);
98  node->rustate = castNode(RecursiveUnionState, DatumGetPointer(param->value));
99  Assert(node->rustate);
100 
101  /*
102  * The scan tuple type (ie, the rowtype we expect to find in the work
103  * table) is the same as the result rowtype of the ancestor
104  * RecursiveUnion node. Note this depends on the assumption that
105  * RecursiveUnion doesn't allow projection.
106  */
107  ExecAssignScanType(&node->ss,
108  ExecGetResultType(&node->rustate->ps));
109 
110  /*
111  * Now we can initialize the projection info. This must be completed
112  * before we can call ExecScan().
113  */
115  }
116 
117  return ExecScan(&node->ss,
120 }
static TupleTableSlot * WorkTableScanNext(WorkTableScanState *node)
#define castNode(_type_, nodeptr)
Definition: nodes.h:578
TupleTableSlot * ExecScan(ScanState *node, ExecScanAccessMtd accessMtd, ExecScanRecheckMtd recheckMtd)
Definition: execScan.c:121
EState * state
Definition: execnodes.h:805
TupleTableSlot *(* ExecScanAccessMtd)(ScanState *node)
Definition: executor.h:388
PlanState ps
Definition: execnodes.h:1047
bool(* ExecScanRecheckMtd)(ScanState *node, TupleTableSlot *slot)
Definition: executor.h:389
void ExecAssignScanProjectionInfo(ScanState *node)
Definition: execScan.c:235
RecursiveUnionState * rustate
Definition: execnodes.h:1480
Plan * plan
Definition: execnodes.h:803
#define NULL
Definition: c.h:229
#define Assert(condition)
Definition: c.h:675
static bool WorkTableScanRecheck(WorkTableScanState *node, TupleTableSlot *slot)
TupleDesc ExecGetResultType(PlanState *planstate)
Definition: execUtils.c:469
#define DatumGetPointer(X)
Definition: postgres.h:555
void ExecAssignScanType(ScanState *scanstate, TupleDesc tupDesc)
Definition: execUtils.c:540