PostgreSQL Source Code git master
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)
 
void ExecEndSeqScan (SeqScanState *node)
 
void ExecReScanSeqScan (SeqScanState *node)
 
void ExecSeqScanEstimate (SeqScanState *node, ParallelContext *pcxt)
 
void ExecSeqScanInitializeDSM (SeqScanState *node, ParallelContext *pcxt)
 
void ExecSeqScanReInitializeDSM (SeqScanState *node, ParallelContext *pcxt)
 
void ExecSeqScanInitializeWorker (SeqScanState *node, ParallelWorkerContext *pwcxt)
 

Function Documentation

◆ ExecEndSeqScan()

void ExecEndSeqScan ( SeqScanState node)

Definition at line 293 of file nodeSeqscan.c.

294{
295 TableScanDesc scanDesc;
296
297 /*
298 * get information from node
299 */
300 scanDesc = node->ss.ss_currentScanDesc;
301
302 /*
303 * close heap scan
304 */
305 if (scanDesc != NULL)
306 table_endscan(scanDesc);
307}
struct TableScanDescData * ss_currentScanDesc
Definition: execnodes.h:1623
ScanState ss
Definition: execnodes.h:1633
static void table_endscan(TableScanDesc scan)
Definition: tableam.h:985

References SeqScanState::ss, ScanState::ss_currentScanDesc, and table_endscan().

Referenced by ExecEndNode().

◆ ExecInitSeqScan()

SeqScanState * ExecInitSeqScan ( SeqScan node,
EState estate,
int  eflags 
)

Definition at line 211 of file nodeSeqscan.c.

212{
213 SeqScanState *scanstate;
214
215 /*
216 * Once upon a time it was possible to have an outerPlan of a SeqScan, but
217 * not any more.
218 */
219 Assert(outerPlan(node) == NULL);
220 Assert(innerPlan(node) == NULL);
221
222 /*
223 * create state structure
224 */
225 scanstate = makeNode(SeqScanState);
226 scanstate->ss.ps.plan = (Plan *) node;
227 scanstate->ss.ps.state = estate;
228
229 /*
230 * Miscellaneous initialization
231 *
232 * create expression context for node
233 */
234 ExecAssignExprContext(estate, &scanstate->ss.ps);
235
236 /*
237 * open the scan relation
238 */
239 scanstate->ss.ss_currentRelation =
241 node->scan.scanrelid,
242 eflags);
243
244 /* and create slot with the appropriate rowtype */
245 ExecInitScanTupleSlot(estate, &scanstate->ss,
248
249 /*
250 * Initialize result type and projection.
251 */
252 ExecInitResultTypeTL(&scanstate->ss.ps);
253 ExecAssignScanProjectionInfo(&scanstate->ss);
254
255 /*
256 * initialize child expressions
257 */
258 scanstate->ss.ps.qual =
259 ExecInitQual(node->scan.plan.qual, (PlanState *) scanstate);
260
261 /*
262 * When EvalPlanQual() is not in use, assign ExecProcNode for this node
263 * based on the presence of qual and projection. Each ExecSeqScan*()
264 * variant is optimized for the specific combination of these conditions.
265 */
266 if (scanstate->ss.ps.state->es_epq_active != NULL)
267 scanstate->ss.ps.ExecProcNode = ExecSeqScanEPQ;
268 else if (scanstate->ss.ps.qual == NULL)
269 {
270 if (scanstate->ss.ps.ps_ProjInfo == NULL)
271 scanstate->ss.ps.ExecProcNode = ExecSeqScan;
272 else
274 }
275 else
276 {
277 if (scanstate->ss.ps.ps_ProjInfo == NULL)
279 else
281 }
282
283 return scanstate;
284}
ExprState * ExecInitQual(List *qual, PlanState *parent)
Definition: execExpr.c:229
void ExecAssignScanProjectionInfo(ScanState *node)
Definition: execScan.c:81
void ExecInitScanTupleSlot(EState *estate, ScanState *scanstate, TupleDesc tupledesc, const TupleTableSlotOps *tts_ops)
Definition: execTuples.c:2000
void ExecInitResultTypeTL(PlanState *planstate)
Definition: execTuples.c:1944
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Definition: execUtils.c:485
Relation ExecOpenScanRelation(EState *estate, Index scanrelid, int eflags)
Definition: execUtils.c:742
Assert(PointerIsAligned(start, uint64))
static TupleTableSlot * ExecSeqScanWithQual(PlanState *pstate)
Definition: nodeSeqscan.c:130
static TupleTableSlot * ExecSeqScanWithQualProject(PlanState *pstate)
Definition: nodeSeqscan.c:175
static TupleTableSlot * ExecSeqScan(PlanState *pstate)
Definition: nodeSeqscan.c:110
static TupleTableSlot * ExecSeqScanEPQ(PlanState *pstate)
Definition: nodeSeqscan.c:197
static TupleTableSlot * ExecSeqScanWithProject(PlanState *pstate)
Definition: nodeSeqscan.c:154
#define makeNode(_type_)
Definition: nodes.h:161
#define innerPlan(node)
Definition: plannodes.h:260
#define outerPlan(node)
Definition: plannodes.h:261
#define RelationGetDescr(relation)
Definition: rel.h:541
struct EPQState * es_epq_active
Definition: execnodes.h:742
ExprState * qual
Definition: execnodes.h:1186
Plan * plan
Definition: execnodes.h:1165
EState * state
Definition: execnodes.h:1167
ProjectionInfo * ps_ProjInfo
Definition: execnodes.h:1205
ExecProcNodeMtd ExecProcNode
Definition: execnodes.h:1171
Relation ss_currentRelation
Definition: execnodes.h:1622
PlanState ps
Definition: execnodes.h:1621
Index scanrelid
Definition: plannodes.h:523
Scan scan
Definition: plannodes.h:532
const TupleTableSlotOps * table_slot_callbacks(Relation relation)
Definition: tableam.c:59

References Assert(), EState::es_epq_active, ExecAssignExprContext(), ExecAssignScanProjectionInfo(), ExecInitQual(), ExecInitResultTypeTL(), ExecInitScanTupleSlot(), ExecOpenScanRelation(), PlanState::ExecProcNode, ExecSeqScan(), ExecSeqScanEPQ(), ExecSeqScanWithProject(), ExecSeqScanWithQual(), ExecSeqScanWithQualProject(), innerPlan, makeNode, outerPlan, PlanState::plan, ScanState::ps, PlanState::ps_ProjInfo, PlanState::qual, RelationGetDescr, SeqScan::scan, Scan::scanrelid, SeqScanState::ss, ScanState::ss_currentRelation, PlanState::state, and table_slot_callbacks().

Referenced by ExecInitNode().

◆ ExecReScanSeqScan()

void ExecReScanSeqScan ( SeqScanState node)

Definition at line 321 of file nodeSeqscan.c.

322{
323 TableScanDesc scan;
324
325 scan = node->ss.ss_currentScanDesc;
326
327 if (scan != NULL)
328 table_rescan(scan, /* scan desc */
329 NULL); /* new scan keys */
330
331 ExecScanReScan((ScanState *) node);
332}
void ExecScanReScan(ScanState *node)
Definition: execScan.c:108
static void table_rescan(TableScanDesc scan, ScanKeyData *key)
Definition: tableam.h:994

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

Referenced by ExecReScan().

◆ ExecSeqScanEstimate()

void ExecSeqScanEstimate ( SeqScanState node,
ParallelContext pcxt 
)

Definition at line 347 of file nodeSeqscan.c.

349{
350 EState *estate = node->ss.ps.state;
351
353 estate->es_snapshot);
356}
#define shm_toc_estimate_chunk(e, sz)
Definition: shm_toc.h:51
#define shm_toc_estimate_keys(e, cnt)
Definition: shm_toc.h:53
Snapshot es_snapshot
Definition: execnodes.h:660
shm_toc_estimator estimator
Definition: parallel.h:41
Size pscan_len
Definition: execnodes.h:1634
Size table_parallelscan_estimate(Relation rel, Snapshot snapshot)
Definition: tableam.c:131

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

Referenced by ExecParallelEstimate().

◆ ExecSeqScanInitializeDSM()

void ExecSeqScanInitializeDSM ( SeqScanState node,
ParallelContext pcxt 
)

Definition at line 365 of file nodeSeqscan.c.

367{
368 EState *estate = node->ss.ps.state;
370
371 pscan = shm_toc_allocate(pcxt->toc, node->pscan_len);
373 pscan,
374 estate->es_snapshot);
375 shm_toc_insert(pcxt->toc, node->ss.ps.plan->plan_node_id, pscan);
376 node->ss.ss_currentScanDesc =
378}
void * shm_toc_allocate(shm_toc *toc, Size nbytes)
Definition: shm_toc.c:88
void shm_toc_insert(shm_toc *toc, uint64 key, void *address)
Definition: shm_toc.c:171
shm_toc * toc
Definition: parallel.h:44
int plan_node_id
Definition: plannodes.h:227
TableScanDesc table_beginscan_parallel(Relation relation, ParallelTableScanDesc pscan)
Definition: tableam.c:166
void table_parallelscan_initialize(Relation rel, ParallelTableScanDesc pscan, Snapshot snapshot)
Definition: tableam.c:146

References EState::es_snapshot, 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, table_beginscan_parallel(), table_parallelscan_initialize(), and ParallelContext::toc.

Referenced by ExecParallelInitializeDSM().

◆ ExecSeqScanInitializeWorker()

void ExecSeqScanInitializeWorker ( SeqScanState node,
ParallelWorkerContext pwcxt 
)

Definition at line 403 of file nodeSeqscan.c.

405{
407
408 pscan = shm_toc_lookup(pwcxt->toc, node->ss.ps.plan->plan_node_id, false);
409 node->ss.ss_currentScanDesc =
411}
void * shm_toc_lookup(shm_toc *toc, uint64 key, bool noError)
Definition: shm_toc.c:232

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

Referenced by ExecParallelInitializeWorker().

◆ ExecSeqScanReInitializeDSM()

void ExecSeqScanReInitializeDSM ( SeqScanState node,
ParallelContext pcxt 
)

Definition at line 387 of file nodeSeqscan.c.

389{
391
392 pscan = node->ss.ss_currentScanDesc->rs_parallel;
394}
struct ParallelTableScanDescData * rs_parallel
Definition: relscan.h:66
static void table_parallelscan_reinitialize(Relation rel, ParallelTableScanDesc pscan)
Definition: tableam.h:1149

References TableScanDescData::rs_parallel, SeqScanState::ss, ScanState::ss_currentRelation, ScanState::ss_currentScanDesc, and table_parallelscan_reinitialize().

Referenced by ExecParallelReInitializeDSM().