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

Go to the source code of this file.

Functions

SeqScanStateExecInitSeqScan (SeqScan *node, EState *estate, int eflags)
 
TupleTableSlotExecSeqScan (SeqScanState *node)
 
void ExecEndSeqScan (SeqScanState *node)
 
void ExecReScanSeqScan (SeqScanState *node)
 
void ExecSeqScanEstimate (SeqScanState *node, ParallelContext *pcxt)
 
void ExecSeqScanInitializeDSM (SeqScanState *node, ParallelContext *pcxt)
 
void ExecSeqScanInitializeWorker (SeqScanState *node, shm_toc *toc)
 

Function Documentation

void ExecEndSeqScan ( SeqScanState node)

Definition at line 225 of file nodeSeqscan.c.

References ExecClearTuple(), ExecCloseScanRelation(), ExecFreeExprContext(), heap_endscan(), NULL, ScanState::ps, PlanState::ps_ResultTupleSlot, SeqScanState::ss, ScanState::ss_currentRelation, ScanState::ss_currentScanDesc, and ScanState::ss_ScanTupleSlot.

Referenced by ExecEndNode().

226 {
227  Relation relation;
228  HeapScanDesc scanDesc;
229 
230  /*
231  * get information from node
232  */
233  relation = node->ss.ss_currentRelation;
234  scanDesc = node->ss.ss_currentScanDesc;
235 
236  /*
237  * Free the exprcontext
238  */
239  ExecFreeExprContext(&node->ss.ps);
240 
241  /*
242  * clean out the tuple table
243  */
246 
247  /*
248  * close heap scan
249  */
250  if (scanDesc != NULL)
251  heap_endscan(scanDesc);
252 
253  /*
254  * close the heap relation.
255  */
256  ExecCloseScanRelation(relation);
257 }
void heap_endscan(HeapScanDesc scan)
Definition: heapam.c:1581
TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: execTuples.c:439
ScanState ss
Definition: execnodes.h:1300
TupleTableSlot * ss_ScanTupleSlot
Definition: execnodes.h:1291
Relation ss_currentRelation
Definition: execnodes.h:1289
void ExecFreeExprContext(PlanState *planstate)
Definition: execUtils.c:685
PlanState ps
Definition: execnodes.h:1288
TupleTableSlot * ps_ResultTupleSlot
Definition: execnodes.h:1077
#define NULL
Definition: c.h:226
void ExecCloseScanRelation(Relation scanrel)
Definition: execUtils.c:830
HeapScanDesc ss_currentScanDesc
Definition: execnodes.h:1290
SeqScanState* ExecInitSeqScan ( SeqScan node,
EState estate,
int  eflags 
)

Definition at line 163 of file nodeSeqscan.c.

References Assert, ExecAssignExprContext(), ExecAssignResultTypeFromTL(), ExecAssignScanProjectionInfo(), ExecInitExpr(), ExecInitResultTupleSlot(), ExecInitScanTupleSlot(), InitScanRelation(), innerPlan, makeNode, NULL, outerPlan, Scan::plan, PlanState::plan, ScanState::ps, Plan::qual, PlanState::qual, SeqScanState::ss, PlanState::state, Plan::targetlist, and PlanState::targetlist.

Referenced by ExecInitNode().

164 {
165  SeqScanState *scanstate;
166 
167  /*
168  * Once upon a time it was possible to have an outerPlan of a SeqScan, but
169  * not any more.
170  */
171  Assert(outerPlan(node) == NULL);
172  Assert(innerPlan(node) == NULL);
173 
174  /*
175  * create state structure
176  */
177  scanstate = makeNode(SeqScanState);
178  scanstate->ss.ps.plan = (Plan *) node;
179  scanstate->ss.ps.state = estate;
180 
181  /*
182  * Miscellaneous initialization
183  *
184  * create expression context for node
185  */
186  ExecAssignExprContext(estate, &scanstate->ss.ps);
187 
188  /*
189  * initialize child expressions
190  */
191  scanstate->ss.ps.targetlist = (List *)
192  ExecInitExpr((Expr *) node->plan.targetlist,
193  (PlanState *) scanstate);
194  scanstate->ss.ps.qual = (List *)
195  ExecInitExpr((Expr *) node->plan.qual,
196  (PlanState *) scanstate);
197 
198  /*
199  * tuple table initialization
200  */
201  ExecInitResultTupleSlot(estate, &scanstate->ss.ps);
202  ExecInitScanTupleSlot(estate, &scanstate->ss);
203 
204  /*
205  * initialize scan relation
206  */
207  InitScanRelation(scanstate, estate, eflags);
208 
209  /*
210  * Initialize result tuple type and projection info.
211  */
212  ExecAssignResultTypeFromTL(&scanstate->ss.ps);
213  ExecAssignScanProjectionInfo(&scanstate->ss);
214 
215  return scanstate;
216 }
List * qual
Definition: plannodes.h:130
Plan plan
Definition: plannodes.h:305
void ExecInitScanTupleSlot(EState *estate, ScanState *scanstate)
Definition: execTuples.c:842
List * qual
Definition: execnodes.h:1062
static void InitScanRelation(SeqScanState *node, EState *estate, int eflags)
Definition: nodeSeqscan.c:139
List * targetlist
Definition: execnodes.h:1061
ScanState ss
Definition: execnodes.h:1300
EState * state
Definition: execnodes.h:1049
void ExecAssignResultTypeFromTL(PlanState *planstate)
Definition: execUtils.c:430
PlanState ps
Definition: execnodes.h:1288
ExprState * ExecInitExpr(Expr *node, PlanState *parent)
Definition: execQual.c:4266
void ExecAssignScanProjectionInfo(ScanState *node)
Definition: execScan.c:235
void ExecInitResultTupleSlot(EState *estate, PlanState *planstate)
Definition: execTuples.c:832
#define innerPlan(node)
Definition: plannodes.h:158
#define outerPlan(node)
Definition: plannodes.h:159
Plan * plan
Definition: execnodes.h:1047
#define makeNode(_type_)
Definition: nodes.h:557
#define NULL
Definition: c.h:226
#define Assert(condition)
Definition: c.h:671
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Definition: execUtils.c:408
List * targetlist
Definition: plannodes.h:129
Definition: pg_list.h:45
void ExecReScanSeqScan ( SeqScanState node)

Definition at line 271 of file nodeSeqscan.c.

References ExecScanReScan(), heap_rescan(), NULL, SeqScanState::ss, and ScanState::ss_currentScanDesc.

Referenced by ExecReScan().

272 {
273  HeapScanDesc scan;
274 
275  scan = node->ss.ss_currentScanDesc;
276 
277  if (scan != NULL)
278  heap_rescan(scan, /* scan desc */
279  NULL); /* new scan keys */
280 
281  ExecScanReScan((ScanState *) node);
282 }
ScanState ss
Definition: execnodes.h:1300
void heap_rescan(HeapScanDesc scan, ScanKey key)
Definition: heapam.c:1518
#define NULL
Definition: c.h:226
HeapScanDesc ss_currentScanDesc
Definition: execnodes.h:1290
void ExecScanReScan(ScanState *node)
Definition: execScan.c:327
TupleTableSlot* ExecSeqScan ( SeqScanState node)

Definition at line 125 of file nodeSeqscan.c.

References ExecScan(), SeqNext(), and SeqRecheck().

Referenced by ExecProcNode().

126 {
127  return ExecScan((ScanState *) node,
130 }
TupleTableSlot * ExecScan(ScanState *node, ExecScanAccessMtd accessMtd, ExecScanRecheckMtd recheckMtd)
Definition: execScan.c:121
static TupleTableSlot * SeqNext(SeqScanState *node)
Definition: nodeSeqscan.c:49
TupleTableSlot *(* ExecScanAccessMtd)(ScanState *node)
Definition: executor.h:271
bool(* ExecScanRecheckMtd)(ScanState *node, TupleTableSlot *slot)
Definition: executor.h:272
static bool SeqRecheck(SeqScanState *node, TupleTableSlot *slot)
Definition: nodeSeqscan.c:106
void ExecSeqScanEstimate ( SeqScanState node,
ParallelContext pcxt 
)

Definition at line 296 of file nodeSeqscan.c.

References EState::es_snapshot, ParallelContext::estimator, heap_parallelscan_estimate(), ScanState::ps, SeqScanState::pscan_len, shm_toc_estimate_chunk, shm_toc_estimate_keys, SeqScanState::ss, and PlanState::state.

Referenced by ExecParallelEstimate().

298 {
299  EState *estate = node->ss.ps.state;
300 
303  shm_toc_estimate_keys(&pcxt->estimator, 1);
304 }
shm_toc_estimator estimator
Definition: parallel.h:42
Snapshot es_snapshot
Definition: execnodes.h:370
ScanState ss
Definition: execnodes.h:1300
EState * state
Definition: execnodes.h:1049
#define shm_toc_estimate_chunk(e, sz)
Definition: shm_toc.h:49
Size pscan_len
Definition: execnodes.h:1301
PlanState ps
Definition: execnodes.h:1288
#define shm_toc_estimate_keys(e, cnt)
Definition: shm_toc.h:52
Size heap_parallelscan_estimate(Snapshot snapshot)
Definition: heapam.c:1616
void ExecSeqScanInitializeDSM ( SeqScanState node,
ParallelContext pcxt 
)

Definition at line 313 of file nodeSeqscan.c.

References EState::es_snapshot, heap_beginscan_parallel(), heap_parallelscan_initialize(), PlanState::plan, Plan::plan_node_id, ScanState::ps, SeqScanState::pscan_len, shm_toc_allocate(), shm_toc_insert(), SeqScanState::ss, ScanState::ss_currentRelation, ScanState::ss_currentScanDesc, PlanState::state, and ParallelContext::toc.

Referenced by ExecParallelInitializeDSM().

315 {
316  EState *estate = node->ss.ps.state;
317  ParallelHeapScanDesc pscan;
318 
319  pscan = shm_toc_allocate(pcxt->toc, node->pscan_len);
321  node->ss.ss_currentRelation,
322  estate->es_snapshot);
323  shm_toc_insert(pcxt->toc, node->ss.ps.plan->plan_node_id, pscan);
324  node->ss.ss_currentScanDesc =
326 }
int plan_node_id
Definition: plannodes.h:128
Snapshot es_snapshot
Definition: execnodes.h:370
ScanState ss
Definition: execnodes.h:1300
Relation ss_currentRelation
Definition: execnodes.h:1289
EState * state
Definition: execnodes.h:1049
Size pscan_len
Definition: execnodes.h:1301
PlanState ps
Definition: execnodes.h:1288
void heap_parallelscan_initialize(ParallelHeapScanDesc target, Relation relation, Snapshot snapshot)
Definition: heapam.c:1631
Plan * plan
Definition: execnodes.h:1047
void * shm_toc_allocate(shm_toc *toc, Size nbytes)
Definition: shm_toc.c:83
HeapScanDesc ss_currentScanDesc
Definition: execnodes.h:1290
void shm_toc_insert(shm_toc *toc, uint64 key, void *address)
Definition: shm_toc.c:161
HeapScanDesc heap_beginscan_parallel(Relation relation, ParallelHeapScanDesc parallel_scan)
Definition: heapam.c:1653
shm_toc * toc
Definition: parallel.h:45
void ExecSeqScanInitializeWorker ( SeqScanState node,
shm_toc toc 
)

Definition at line 335 of file nodeSeqscan.c.

References heap_beginscan_parallel(), PlanState::plan, Plan::plan_node_id, ScanState::ps, shm_toc_lookup(), SeqScanState::ss, ScanState::ss_currentRelation, and ScanState::ss_currentScanDesc.

Referenced by ExecParallelInitializeWorker().

336 {
337  ParallelHeapScanDesc pscan;
338 
339  pscan = shm_toc_lookup(toc, node->ss.ps.plan->plan_node_id);
340  node->ss.ss_currentScanDesc =
342 }
int plan_node_id
Definition: plannodes.h:128
ScanState ss
Definition: execnodes.h:1300
Relation ss_currentRelation
Definition: execnodes.h:1289
PlanState ps
Definition: execnodes.h:1288
void * shm_toc_lookup(shm_toc *toc, uint64 key)
Definition: shm_toc.c:218
Plan * plan
Definition: execnodes.h:1047
HeapScanDesc ss_currentScanDesc
Definition: execnodes.h:1290
HeapScanDesc heap_beginscan_parallel(Relation relation, ParallelHeapScanDesc parallel_scan)
Definition: heapam.c:1653