PostgreSQL Source Code git master
Loading...
Searching...
No Matches
nodeBitmapHeapscan.c File Reference
#include "postgres.h"
#include "access/relscan.h"
#include "access/tableam.h"
#include "access/visibilitymap.h"
#include "executor/executor.h"
#include "executor/nodeBitmapHeapscan.h"
#include "miscadmin.h"
#include "pgstat.h"
#include "storage/bufmgr.h"
#include "utils/rel.h"
#include "utils/spccache.h"
#include "utils/wait_event.h"
Include dependency graph for nodeBitmapHeapscan.c:

Go to the source code of this file.

Functions

static void BitmapTableScanSetup (BitmapHeapScanState *node)
 
static TupleTableSlotBitmapHeapNext (BitmapHeapScanState *node)
 
static void BitmapDoneInitializingSharedState (ParallelBitmapHeapState *pstate)
 
static bool BitmapShouldInitializeSharedState (ParallelBitmapHeapState *pstate)
 
static bool BitmapHeapRecheck (BitmapHeapScanState *node, TupleTableSlot *slot)
 
static TupleTableSlotExecBitmapHeapScan (PlanState *pstate)
 
void ExecReScanBitmapHeapScan (BitmapHeapScanState *node)
 
void ExecEndBitmapHeapScan (BitmapHeapScanState *node)
 
BitmapHeapScanStateExecInitBitmapHeapScan (BitmapHeapScan *node, EState *estate, int eflags)
 
void ExecBitmapHeapEstimate (BitmapHeapScanState *node, ParallelContext *pcxt)
 
void ExecBitmapHeapInitializeDSM (BitmapHeapScanState *node, ParallelContext *pcxt)
 
void ExecBitmapHeapReInitializeDSM (BitmapHeapScanState *node, ParallelContext *pcxt)
 
void ExecBitmapHeapInitializeWorker (BitmapHeapScanState *node, ParallelWorkerContext *pwcxt)
 
void ExecBitmapHeapRetrieveInstrumentation (BitmapHeapScanState *node)
 

Function Documentation

◆ BitmapDoneInitializingSharedState()

static void BitmapDoneInitializingSharedState ( ParallelBitmapHeapState pstate)
inlinestatic

Definition at line 180 of file nodeBitmapHeapscan.c.

181{
182 SpinLockAcquire(&pstate->mutex);
183 pstate->state = BM_FINISHED;
184 SpinLockRelease(&pstate->mutex);
186}
void ConditionVariableBroadcast(ConditionVariable *cv)
@ BM_FINISHED
Definition execnodes.h:1839
static void SpinLockRelease(volatile slock_t *lock)
Definition spin.h:62
static void SpinLockAcquire(volatile slock_t *lock)
Definition spin.h:56
SharedBitmapState state
Definition execnodes.h:1854
ConditionVariable cv
Definition execnodes.h:1855

References BM_FINISHED, ConditionVariableBroadcast(), ParallelBitmapHeapState::cv, ParallelBitmapHeapState::mutex, SpinLockAcquire(), SpinLockRelease(), and ParallelBitmapHeapState::state.

Referenced by BitmapTableScanSetup().

◆ BitmapHeapNext()

static TupleTableSlot * BitmapHeapNext ( BitmapHeapScanState node)
static

Definition at line 125 of file nodeBitmapHeapscan.c.

126{
127 ExprContext *econtext = node->ss.ps.ps_ExprContext;
128 TupleTableSlot *slot = node->ss.ss_ScanTupleSlot;
129
130 /*
131 * If we haven't yet performed the underlying index scan, do it, and begin
132 * the iteration over the bitmap.
133 */
134 if (!node->initialized)
136
138 slot, &node->recheck,
139 &node->stats.lossy_pages,
140 &node->stats.exact_pages))
141 {
142 /*
143 * Continuing in previously obtained page.
144 */
146
147 /*
148 * If we are using lossy info, we have to recheck the qual conditions
149 * at every tuple.
150 */
151 if (node->recheck)
152 {
153 econtext->ecxt_scantuple = slot;
154 if (!ExecQualAndReset(node->bitmapqualorig, econtext))
155 {
156 /* Fails recheck, so drop it and loop back for another */
157 InstrCountFiltered2(node, 1);
158 ExecClearTuple(slot);
159 continue;
160 }
161 }
162
163 /* OK to return this tuple */
164 return slot;
165 }
166
167 /*
168 * if we get here it means we are at the end of the scan..
169 */
170 return ExecClearTuple(slot);
171}
#define InstrCountFiltered2(node, delta)
Definition execnodes.h:1277
static bool ExecQualAndReset(ExprState *state, ExprContext *econtext)
Definition executor.h:548
#define CHECK_FOR_INTERRUPTS()
Definition miscadmin.h:123
static void BitmapTableScanSetup(BitmapHeapScanState *node)
ExprState * bitmapqualorig
Definition execnodes.h:1873
BitmapHeapScanInstrumentation stats
Definition execnodes.h:1875
TupleTableSlot * ecxt_scantuple
Definition execnodes.h:275
ExprContext * ps_ExprContext
Definition execnodes.h:1207
TupleTableSlot * ss_ScanTupleSlot
Definition execnodes.h:1627
PlanState ps
Definition execnodes.h:1624
struct TableScanDescData * ss_currentScanDesc
Definition execnodes.h:1626
static bool table_scan_bitmap_next_tuple(TableScanDesc scan, TupleTableSlot *slot, bool *recheck, uint64 *lossy_pages, uint64 *exact_pages)
Definition tableam.h:1955
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition tuptable.h:460

References BitmapHeapScanState::bitmapqualorig, BitmapTableScanSetup(), CHECK_FOR_INTERRUPTS, ExprContext::ecxt_scantuple, BitmapHeapScanInstrumentation::exact_pages, ExecClearTuple(), ExecQualAndReset(), BitmapHeapScanState::initialized, InstrCountFiltered2, BitmapHeapScanInstrumentation::lossy_pages, ScanState::ps, PlanState::ps_ExprContext, BitmapHeapScanState::recheck, BitmapHeapScanState::ss, ScanState::ss_currentScanDesc, ScanState::ss_ScanTupleSlot, BitmapHeapScanState::stats, and table_scan_bitmap_next_tuple().

Referenced by ExecBitmapHeapScan().

◆ BitmapHeapRecheck()

static bool BitmapHeapRecheck ( BitmapHeapScanState node,
TupleTableSlot slot 
)
static

Definition at line 192 of file nodeBitmapHeapscan.c.

193{
194 ExprContext *econtext;
195
196 /*
197 * extract necessary information from index scan node
198 */
199 econtext = node->ss.ps.ps_ExprContext;
200
201 /* Does the tuple meet the original qual conditions? */
202 econtext->ecxt_scantuple = slot;
203 return ExecQualAndReset(node->bitmapqualorig, econtext);
204}

References BitmapHeapScanState::bitmapqualorig, ExprContext::ecxt_scantuple, ExecQualAndReset(), ScanState::ps, PlanState::ps_ExprContext, and BitmapHeapScanState::ss.

Referenced by ExecBitmapHeapScan().

◆ BitmapShouldInitializeSharedState()

static bool BitmapShouldInitializeSharedState ( ParallelBitmapHeapState pstate)
static

Definition at line 419 of file nodeBitmapHeapscan.c.

420{
422
423 while (1)
424 {
425 SpinLockAcquire(&pstate->mutex);
426 state = pstate->state;
427 if (pstate->state == BM_INITIAL)
428 pstate->state = BM_INPROGRESS;
429 SpinLockRelease(&pstate->mutex);
430
431 /* Exit if bitmap is done, or if we're the leader. */
432 if (state != BM_INPROGRESS)
433 break;
434
435 /* Wait for the leader to wake us up. */
437 }
438
440
441 return (state == BM_INITIAL);
442}
bool ConditionVariableCancelSleep(void)
void ConditionVariableSleep(ConditionVariable *cv, uint32 wait_event_info)
SharedBitmapState
Definition execnodes.h:1836
@ BM_INITIAL
Definition execnodes.h:1837
@ BM_INPROGRESS
Definition execnodes.h:1838
static int fb(int x)

References BM_INITIAL, BM_INPROGRESS, ConditionVariableCancelSleep(), ConditionVariableSleep(), ParallelBitmapHeapState::cv, fb(), ParallelBitmapHeapState::mutex, SpinLockAcquire(), SpinLockRelease(), and ParallelBitmapHeapState::state.

Referenced by BitmapTableScanSetup().

◆ BitmapTableScanSetup()

static void BitmapTableScanSetup ( BitmapHeapScanState node)
static

Definition at line 62 of file nodeBitmapHeapscan.c.

63{
64 TBMIterator tbmiterator = {0};
65 ParallelBitmapHeapState *pstate = node->pstate;
66 dsa_area *dsa = node->ss.ps.state->es_query_dsa;
67
68 if (!pstate)
69 {
71
72 if (!node->tbm || !IsA(node->tbm, TIDBitmap))
73 elog(ERROR, "unrecognized result from subplan");
74 }
75 else if (BitmapShouldInitializeSharedState(pstate))
76 {
77 /*
78 * The leader will immediately come out of the function, but others
79 * will be blocked until leader populates the TBM and wakes them up.
80 */
82 if (!node->tbm || !IsA(node->tbm, TIDBitmap))
83 elog(ERROR, "unrecognized result from subplan");
84
85 /*
86 * Prepare to iterate over the TBM. This will return the dsa_pointer
87 * of the iterator state which will be used by multiple processes to
88 * iterate jointly.
89 */
91
92 /* We have initialized the shared state so wake up others. */
94 }
95
96 tbmiterator = tbm_begin_iterate(node->tbm, dsa,
97 pstate ?
98 pstate->tbmiterator :
100
101 /*
102 * If this is the first scan of the underlying table, create the table
103 * scan descriptor and begin the scan.
104 */
105 if (!node->ss.ss_currentScanDesc)
106 {
107 node->ss.ss_currentScanDesc =
109 node->ss.ps.state->es_snapshot,
110 0,
111 NULL);
112 }
113
114 node->ss.ss_currentScanDesc->st.rs_tbmiterator = tbmiterator;
115 node->initialized = true;
116}
#define InvalidDsaPointer
Definition dsa.h:78
#define ERROR
Definition elog.h:39
#define elog(elevel,...)
Definition elog.h:226
Node * MultiExecProcNode(PlanState *node)
#define outerPlanState(node)
Definition execnodes.h:1264
static bool BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
static void BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
#define IsA(nodeptr, _type_)
Definition nodes.h:164
ParallelBitmapHeapState * pstate
Definition execnodes.h:1877
struct dsa_area * es_query_dsa
Definition execnodes.h:755
Snapshot es_snapshot
Definition execnodes.h:663
EState * state
Definition execnodes.h:1170
Relation ss_currentRelation
Definition execnodes.h:1625
TBMIterator rs_tbmiterator
Definition relscan.h:46
union TableScanDescData::@52 st
static TableScanDesc table_beginscan_bm(Relation rel, Snapshot snapshot, int nkeys, ScanKeyData *key)
Definition tableam.h:941
dsa_pointer tbm_prepare_shared_iterate(TIDBitmap *tbm)
Definition tidbitmap.c:752
TBMIterator tbm_begin_iterate(TIDBitmap *tbm, dsa_area *dsa, dsa_pointer dsp)
Definition tidbitmap.c:1571

References BitmapDoneInitializingSharedState(), BitmapShouldInitializeSharedState(), elog, ERROR, EState::es_query_dsa, EState::es_snapshot, fb(), BitmapHeapScanState::initialized, InvalidDsaPointer, IsA, MultiExecProcNode(), outerPlanState, ScanState::ps, BitmapHeapScanState::pstate, TableScanDescData::rs_tbmiterator, BitmapHeapScanState::ss, ScanState::ss_currentRelation, ScanState::ss_currentScanDesc, TableScanDescData::st, PlanState::state, table_beginscan_bm(), BitmapHeapScanState::tbm, tbm_begin_iterate(), tbm_prepare_shared_iterate(), and ParallelBitmapHeapState::tbmiterator.

Referenced by BitmapHeapNext().

◆ ExecBitmapHeapEstimate()

void ExecBitmapHeapEstimate ( BitmapHeapScanState node,
ParallelContext pcxt 
)

Definition at line 452 of file nodeBitmapHeapscan.c.

454{
455 Size size;
456
457 size = MAXALIGN(sizeof(ParallelBitmapHeapState));
458
459 /* account for instrumentation, if required */
460 if (node->ss.ps.instrument && pcxt->nworkers > 0)
461 {
462 size = add_size(size, offsetof(SharedBitmapHeapInstrumentation, sinstrument));
463 size = add_size(size, mul_size(pcxt->nworkers, sizeof(BitmapHeapScanInstrumentation)));
464 }
465
466 shm_toc_estimate_chunk(&pcxt->estimator, size);
468}
#define MAXALIGN(LEN)
Definition c.h:880
size_t Size
Definition c.h:673
#define shm_toc_estimate_chunk(e, sz)
Definition shm_toc.h:51
#define shm_toc_estimate_keys(e, cnt)
Definition shm_toc.h:53
Size add_size(Size s1, Size s2)
Definition shmem.c:482
Size mul_size(Size s1, Size s2)
Definition shmem.c:497
shm_toc_estimator estimator
Definition parallel.h:43
Instrumentation * instrument
Definition execnodes.h:1178

References add_size(), ParallelContext::estimator, fb(), PlanState::instrument, MAXALIGN, mul_size(), ParallelContext::nworkers, ScanState::ps, shm_toc_estimate_chunk, shm_toc_estimate_keys, and BitmapHeapScanState::ss.

Referenced by ExecParallelEstimate().

◆ ExecBitmapHeapInitializeDSM()

void ExecBitmapHeapInitializeDSM ( BitmapHeapScanState node,
ParallelContext pcxt 
)

Definition at line 477 of file nodeBitmapHeapscan.c.

479{
482 dsa_area *dsa = node->ss.ps.state->es_query_dsa;
483 char *ptr;
484 Size size;
485
486 /* If there's no DSA, there are no workers; initialize nothing. */
487 if (dsa == NULL)
488 return;
489
490 size = MAXALIGN(sizeof(ParallelBitmapHeapState));
491 if (node->ss.ps.instrument && pcxt->nworkers > 0)
492 {
493 size = add_size(size, offsetof(SharedBitmapHeapInstrumentation, sinstrument));
494 size = add_size(size, mul_size(pcxt->nworkers, sizeof(BitmapHeapScanInstrumentation)));
495 }
496
497 ptr = shm_toc_allocate(pcxt->toc, size);
498 pstate = (ParallelBitmapHeapState *) ptr;
499 ptr += MAXALIGN(sizeof(ParallelBitmapHeapState));
500 if (node->ss.ps.instrument && pcxt->nworkers > 0)
501 sinstrument = (SharedBitmapHeapInstrumentation *) ptr;
502
503 pstate->tbmiterator = 0;
504
505 /* Initialize the mutex */
506 SpinLockInit(&pstate->mutex);
507 pstate->state = BM_INITIAL;
508
509 ConditionVariableInit(&pstate->cv);
510
511 if (sinstrument)
512 {
513 sinstrument->num_workers = pcxt->nworkers;
514
515 /* ensure any unfilled slots will contain zeroes */
516 memset(sinstrument->sinstrument, 0,
518 }
519
520 shm_toc_insert(pcxt->toc, node->ss.ps.plan->plan_node_id, pstate);
521 node->pstate = pstate;
522 node->sinstrument = sinstrument;
523}
void ConditionVariableInit(ConditionVariable *cv)
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
static void SpinLockInit(volatile slock_t *lock)
Definition spin.h:50
SharedBitmapHeapInstrumentation * sinstrument
Definition execnodes.h:1878
shm_toc * toc
Definition parallel.h:46
Plan * plan
Definition execnodes.h:1168
int plan_node_id
Definition plannodes.h:233
BitmapHeapScanInstrumentation sinstrument[FLEXIBLE_ARRAY_MEMBER]

References add_size(), BM_INITIAL, ConditionVariableInit(), ParallelBitmapHeapState::cv, EState::es_query_dsa, fb(), PlanState::instrument, MAXALIGN, mul_size(), ParallelBitmapHeapState::mutex, SharedBitmapHeapInstrumentation::num_workers, ParallelContext::nworkers, PlanState::plan, Plan::plan_node_id, ScanState::ps, BitmapHeapScanState::pstate, shm_toc_allocate(), shm_toc_insert(), SharedBitmapHeapInstrumentation::sinstrument, BitmapHeapScanState::sinstrument, SpinLockInit(), BitmapHeapScanState::ss, PlanState::state, ParallelBitmapHeapState::state, ParallelBitmapHeapState::tbmiterator, and ParallelContext::toc.

Referenced by ExecParallelInitializeDSM().

◆ ExecBitmapHeapInitializeWorker()

void ExecBitmapHeapInitializeWorker ( BitmapHeapScanState node,
ParallelWorkerContext pwcxt 
)

Definition at line 557 of file nodeBitmapHeapscan.c.

559{
560 char *ptr;
561
562 Assert(node->ss.ps.state->es_query_dsa != NULL);
563
564 ptr = shm_toc_lookup(pwcxt->toc, node->ss.ps.plan->plan_node_id, false);
565
566 node->pstate = (ParallelBitmapHeapState *) ptr;
567 ptr += MAXALIGN(sizeof(ParallelBitmapHeapState));
568
569 if (node->ss.ps.instrument)
571}
#define Assert(condition)
Definition c.h:927
void * shm_toc_lookup(shm_toc *toc, uint64 key, bool noError)
Definition shm_toc.c:232

References Assert, EState::es_query_dsa, fb(), PlanState::instrument, MAXALIGN, PlanState::plan, Plan::plan_node_id, ScanState::ps, BitmapHeapScanState::pstate, shm_toc_lookup(), BitmapHeapScanState::sinstrument, BitmapHeapScanState::ss, and PlanState::state.

Referenced by ExecParallelInitializeWorker().

◆ ExecBitmapHeapReInitializeDSM()

void ExecBitmapHeapReInitializeDSM ( BitmapHeapScanState node,
ParallelContext pcxt 
)

Definition at line 532 of file nodeBitmapHeapscan.c.

534{
535 ParallelBitmapHeapState *pstate = node->pstate;
536 dsa_area *dsa = node->ss.ps.state->es_query_dsa;
537
538 /* If there's no DSA, there are no workers; do nothing. */
539 if (dsa == NULL)
540 return;
541
542 pstate->state = BM_INITIAL;
543
544 if (DsaPointerIsValid(pstate->tbmiterator))
545 tbm_free_shared_area(dsa, pstate->tbmiterator);
546
548}
#define DsaPointerIsValid(x)
Definition dsa.h:106
void tbm_free_shared_area(dsa_area *dsa, dsa_pointer dp)
Definition tidbitmap.c:331

References BM_INITIAL, DsaPointerIsValid, EState::es_query_dsa, fb(), InvalidDsaPointer, ScanState::ps, BitmapHeapScanState::pstate, BitmapHeapScanState::ss, PlanState::state, ParallelBitmapHeapState::state, tbm_free_shared_area(), and ParallelBitmapHeapState::tbmiterator.

Referenced by ExecParallelReInitializeDSM().

◆ ExecBitmapHeapRetrieveInstrumentation()

void ExecBitmapHeapRetrieveInstrumentation ( BitmapHeapScanState node)

Definition at line 580 of file nodeBitmapHeapscan.c.

581{
582 SharedBitmapHeapInstrumentation *sinstrument = node->sinstrument;
583 Size size;
584
585 if (sinstrument == NULL)
586 return;
587
588 size = offsetof(SharedBitmapHeapInstrumentation, sinstrument)
589 + sinstrument->num_workers * sizeof(BitmapHeapScanInstrumentation);
590
591 node->sinstrument = palloc(size);
592 memcpy(node->sinstrument, sinstrument, size);
593}
void * palloc(Size size)
Definition mcxt.c:1387

References fb(), SharedBitmapHeapInstrumentation::num_workers, palloc(), and BitmapHeapScanState::sinstrument.

Referenced by ExecParallelRetrieveInstrumentation().

◆ ExecBitmapHeapScan()

static TupleTableSlot * ExecBitmapHeapScan ( PlanState pstate)
static

Definition at line 211 of file nodeBitmapHeapscan.c.

212{
214
215 return ExecScan(&node->ss,
218}
TupleTableSlot * ExecScan(ScanState *node, ExecScanAccessMtd accessMtd, ExecScanRecheckMtd recheckMtd)
Definition execScan.c:47
bool(* ExecScanRecheckMtd)(ScanState *node, TupleTableSlot *slot)
Definition executor.h:582
TupleTableSlot *(* ExecScanAccessMtd)(ScanState *node)
Definition executor.h:581
static TupleTableSlot * BitmapHeapNext(BitmapHeapScanState *node)
static bool BitmapHeapRecheck(BitmapHeapScanState *node, TupleTableSlot *slot)
#define castNode(_type_, nodeptr)
Definition nodes.h:182

References BitmapHeapNext(), BitmapHeapRecheck(), castNode, ExecScan(), and BitmapHeapScanState::ss.

Referenced by ExecInitBitmapHeapScan().

◆ ExecEndBitmapHeapScan()

void ExecEndBitmapHeapScan ( BitmapHeapScanState node)

Definition at line 266 of file nodeBitmapHeapscan.c.

267{
269
270 /*
271 * When ending a parallel worker, copy the statistics gathered by the
272 * worker back into shared memory so that it can be picked up by the main
273 * process to report in EXPLAIN ANALYZE.
274 */
275 if (node->sinstrument != NULL && IsParallelWorker())
276 {
278
279 Assert(ParallelWorkerNumber < node->sinstrument->num_workers);
281
282 /*
283 * Here we accumulate the stats rather than performing memcpy on
284 * node->stats into si. When a Gather/GatherMerge node finishes it
285 * will perform planner shutdown on the workers. On rescan it will
286 * spin up new workers which will have a new BitmapHeapScanState and
287 * zeroed stats.
288 */
290 si->lossy_pages += node->stats.lossy_pages;
291 }
292
293 /*
294 * extract information from the node
295 */
297
298 /*
299 * close down subplans
300 */
302
303 if (scanDesc)
304 {
305 /*
306 * End iteration on iterators saved in scan descriptor if they have
307 * not already been cleaned up.
308 */
309 if (!tbm_exhausted(&scanDesc->st.rs_tbmiterator))
310 tbm_end_iterate(&scanDesc->st.rs_tbmiterator);
311
312 /*
313 * close table scan
314 */
316 }
317
318 /*
319 * release bitmaps and buffers if any
320 */
321 if (node->tbm)
322 tbm_free(node->tbm);
323}
int ParallelWorkerNumber
Definition parallel.c:117
void ExecEndNode(PlanState *node)
#define IsParallelWorker()
Definition parallel.h:62
static void table_endscan(TableScanDesc scan)
Definition tableam.h:1004
void tbm_free(TIDBitmap *tbm)
Definition tidbitmap.c:312
void tbm_end_iterate(TBMIterator *iterator)
Definition tidbitmap.c:1594
static bool tbm_exhausted(TBMIterator *iterator)
Definition tidbitmap.h:118

References Assert, BitmapHeapScanInstrumentation::exact_pages, ExecEndNode(), fb(), IsParallelWorker, BitmapHeapScanInstrumentation::lossy_pages, outerPlanState, ParallelWorkerNumber, SharedBitmapHeapInstrumentation::sinstrument, BitmapHeapScanState::sinstrument, BitmapHeapScanState::ss, ScanState::ss_currentScanDesc, BitmapHeapScanState::stats, table_endscan(), BitmapHeapScanState::tbm, tbm_end_iterate(), tbm_exhausted(), and tbm_free().

Referenced by ExecEndNode().

◆ ExecInitBitmapHeapScan()

BitmapHeapScanState * ExecInitBitmapHeapScan ( BitmapHeapScan node,
EState estate,
int  eflags 
)

Definition at line 332 of file nodeBitmapHeapscan.c.

333{
336
337 /* check for unsupported flags */
339
340 /*
341 * Assert caller didn't ask for an unsafe snapshot --- see comments at
342 * head of file.
343 */
345
346 /*
347 * create state structure
348 */
350 scanstate->ss.ps.plan = (Plan *) node;
351 scanstate->ss.ps.state = estate;
352 scanstate->ss.ps.ExecProcNode = ExecBitmapHeapScan;
353
354 scanstate->tbm = NULL;
355
356 /* Zero the statistics counters */
358
359 scanstate->initialized = false;
360 scanstate->pstate = NULL;
361 scanstate->recheck = true;
362
363 /*
364 * Miscellaneous initialization
365 *
366 * create expression context for node
367 */
368 ExecAssignExprContext(estate, &scanstate->ss.ps);
369
370 /*
371 * open the scan relation
372 */
373 currentRelation = ExecOpenScanRelation(estate, node->scan.scanrelid, eflags);
374
375 /*
376 * initialize child nodes
377 */
378 outerPlanState(scanstate) = ExecInitNode(outerPlan(node), estate, eflags);
379
380 /*
381 * get the scan type from the relation descriptor.
382 */
383 ExecInitScanTupleSlot(estate, &scanstate->ss,
386
387 /*
388 * Initialize result type and projection.
389 */
392
393 /*
394 * initialize child expressions
395 */
396 scanstate->ss.ps.qual =
397 ExecInitQual(node->scan.plan.qual, (PlanState *) scanstate);
398 scanstate->bitmapqualorig =
400
401 scanstate->ss.ss_currentRelation = currentRelation;
402
403 /*
404 * all done.
405 */
406 return scanstate;
407}
ExprState * ExecInitQual(List *qual, PlanState *parent)
Definition execExpr.c:250
PlanState * ExecInitNode(Plan *node, EState *estate, int eflags)
void ExecAssignScanProjectionInfo(ScanState *node)
Definition execScan.c:81
void ExecInitScanTupleSlot(EState *estate, ScanState *scanstate, TupleDesc tupledesc, const TupleTableSlotOps *tts_ops)
void ExecInitResultTypeTL(PlanState *planstate)
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Definition execUtils.c:485
Relation ExecOpenScanRelation(EState *estate, Index scanrelid, int eflags)
Definition execUtils.c:742
#define EXEC_FLAG_BACKWARD
Definition executor.h:69
#define EXEC_FLAG_MARK
Definition executor.h:70
static TupleTableSlot * ExecBitmapHeapScan(PlanState *pstate)
#define makeNode(_type_)
Definition nodes.h:161
#define outerPlan(node)
Definition plannodes.h:267
#define RelationGetDescr(relation)
Definition rel.h:540
#define IsMVCCSnapshot(snapshot)
Definition snapmgr.h:59
List * bitmapqualorig
Definition plannodes.h:712
Index scanrelid
Definition plannodes.h:542
const TupleTableSlotOps * table_slot_callbacks(Relation relation)
Definition tableam.c:59

References Assert, BitmapHeapScan::bitmapqualorig, EState::es_snapshot, EXEC_FLAG_BACKWARD, EXEC_FLAG_MARK, ExecAssignExprContext(), ExecAssignScanProjectionInfo(), ExecBitmapHeapScan(), ExecInitNode(), ExecInitQual(), ExecInitResultTypeTL(), ExecInitScanTupleSlot(), ExecOpenScanRelation(), fb(), IsMVCCSnapshot, makeNode, outerPlan, outerPlanState, RelationGetDescr, BitmapHeapScan::scan, Scan::scanrelid, and table_slot_callbacks().

Referenced by ExecInitNode().

◆ ExecReScanBitmapHeapScan()

void ExecReScanBitmapHeapScan ( BitmapHeapScanState node)

Definition at line 225 of file nodeBitmapHeapscan.c.

226{
228
230
231 if (scan)
232 {
233 /*
234 * End iteration on iterators saved in scan descriptor if they have
235 * not already been cleaned up.
236 */
237 if (!tbm_exhausted(&scan->st.rs_tbmiterator))
239
240 /* rescan to release any page pin */
242 }
243
244 /* release bitmaps and buffers if any */
245 if (node->tbm)
246 tbm_free(node->tbm);
247 node->tbm = NULL;
248 node->initialized = false;
249 node->recheck = true;
250
251 ExecScanReScan(&node->ss);
252
253 /*
254 * if chgParam of subnode is not null then plan will be re-scanned by
255 * first ExecProcNode.
256 */
257 if (outerPlan->chgParam == NULL)
259}
void ExecReScan(PlanState *node)
Definition execAmi.c:77
void ExecScanReScan(ScanState *node)
Definition execScan.c:108
static void table_rescan(TableScanDesc scan, ScanKeyData *key)
Definition tableam.h:1013

References ExecReScan(), ExecScanReScan(), fb(), BitmapHeapScanState::initialized, outerPlan, outerPlanState, BitmapHeapScanState::recheck, TableScanDescData::rs_tbmiterator, BitmapHeapScanState::ss, ScanState::ss_currentScanDesc, TableScanDescData::st, table_rescan(), BitmapHeapScanState::tbm, tbm_end_iterate(), tbm_exhausted(), and tbm_free().

Referenced by ExecReScan().