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

Go to the source code of this file.

Functions

BitmapHeapScanStateExecInitBitmapHeapScan (BitmapHeapScan *node, EState *estate, int eflags)
 
TupleTableSlotExecBitmapHeapScan (BitmapHeapScanState *node)
 
void ExecEndBitmapHeapScan (BitmapHeapScanState *node)
 
void ExecReScanBitmapHeapScan (BitmapHeapScanState *node)
 

Function Documentation

TupleTableSlot* ExecBitmapHeapScan ( BitmapHeapScanState node)

Definition at line 440 of file nodeBitmapHeapscan.c.

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

Referenced by ExecProcNode().

441 {
442  return ExecScan(&node->ss,
445 }
TupleTableSlot * ExecScan(ScanState *node, ExecScanAccessMtd accessMtd, ExecScanRecheckMtd recheckMtd)
Definition: execScan.c:121
TupleTableSlot *(* ExecScanAccessMtd)(ScanState *node)
Definition: executor.h:271
bool(* ExecScanRecheckMtd)(ScanState *node, TupleTableSlot *slot)
Definition: executor.h:272
static TupleTableSlot * BitmapHeapNext(BitmapHeapScanState *node)
static bool BitmapHeapRecheck(BitmapHeapScanState *node, TupleTableSlot *slot)
void ExecEndBitmapHeapScan ( BitmapHeapScanState node)

Definition at line 485 of file nodeBitmapHeapscan.c.

References ExecClearTuple(), ExecCloseScanRelation(), ExecEndNode(), ExecFreeExprContext(), heap_endscan(), outerPlanState, BitmapHeapScanState::prefetch_iterator, ScanState::ps, PlanState::ps_ResultTupleSlot, BitmapHeapScanState::ss, ScanState::ss_currentRelation, ScanState::ss_currentScanDesc, ScanState::ss_ScanTupleSlot, BitmapHeapScanState::tbm, tbm_end_iterate(), tbm_free(), and BitmapHeapScanState::tbmiterator.

Referenced by ExecEndNode().

486 {
487  Relation relation;
488  HeapScanDesc scanDesc;
489 
490  /*
491  * extract information from the node
492  */
493  relation = node->ss.ss_currentRelation;
494  scanDesc = node->ss.ss_currentScanDesc;
495 
496  /*
497  * Free the exprcontext
498  */
499  ExecFreeExprContext(&node->ss.ps);
500 
501  /*
502  * clear out tuple table slots
503  */
506 
507  /*
508  * close down subplans
509  */
511 
512  /*
513  * release bitmap if any
514  */
515  if (node->tbmiterator)
517  if (node->prefetch_iterator)
519  if (node->tbm)
520  tbm_free(node->tbm);
521 
522  /*
523  * close heap scan
524  */
525  heap_endscan(scanDesc);
526 
527  /*
528  * close the heap relation.
529  */
530  ExecCloseScanRelation(relation);
531 }
void tbm_end_iterate(TBMIterator *iterator)
Definition: tidbitmap.c:787
void heap_endscan(HeapScanDesc scan)
Definition: heapam.c:1581
void ExecEndNode(PlanState *node)
Definition: execProcnode.c:624
TIDBitmap * tbm
Definition: execnodes.h:1486
TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
Definition: execTuples.c:439
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 outerPlanState(node)
Definition: execnodes.h:1090
void tbm_free(TIDBitmap *tbm)
Definition: tidbitmap.c:272
void ExecCloseScanRelation(Relation scanrel)
Definition: execUtils.c:830
TBMIterator * tbmiterator
Definition: execnodes.h:1487
HeapScanDesc ss_currentScanDesc
Definition: execnodes.h:1290
TBMIterator * prefetch_iterator
Definition: execnodes.h:1491
BitmapHeapScanState* ExecInitBitmapHeapScan ( BitmapHeapScan node,
EState estate,
int  eflags 
)

Definition at line 540 of file nodeBitmapHeapscan.c.

References Assert, BitmapHeapScan::bitmapqualorig, BitmapHeapScanState::bitmapqualorig, ComputeIoConcurrency(), effective_io_concurrency, EState::es_snapshot, BitmapHeapScanState::exact_pages, EXEC_FLAG_BACKWARD, EXEC_FLAG_MARK, ExecAssignExprContext(), ExecAssignResultTypeFromTL(), ExecAssignScanProjectionInfo(), ExecAssignScanType(), ExecInitExpr(), ExecInitNode(), ExecInitResultTupleSlot(), ExecInitScanTupleSlot(), ExecOpenScanRelation(), get_tablespace_io_concurrency(), heap_beginscan_bm(), IsMVCCSnapshot, BitmapHeapScanState::lossy_pages, makeNode, NULL, outerPlan, outerPlanState, Scan::plan, PlanState::plan, BitmapHeapScanState::prefetch_iterator, BitmapHeapScanState::prefetch_maximum, BitmapHeapScanState::prefetch_pages, BitmapHeapScanState::prefetch_target, ScanState::ps, Plan::qual, PlanState::qual, RelationData::rd_rel, RelationGetDescr, rint(), BitmapHeapScan::scan, Scan::scanrelid, BitmapHeapScanState::ss, ScanState::ss_currentRelation, ScanState::ss_currentScanDesc, PlanState::state, target_prefetch_pages, Plan::targetlist, PlanState::targetlist, BitmapHeapScanState::tbm, BitmapHeapScanState::tbmiterator, and BitmapHeapScanState::tbmres.

Referenced by ExecInitNode().

541 {
542  BitmapHeapScanState *scanstate;
543  Relation currentRelation;
544  int io_concurrency;
545 
546  /* check for unsupported flags */
547  Assert(!(eflags & (EXEC_FLAG_BACKWARD | EXEC_FLAG_MARK)));
548 
549  /*
550  * Assert caller didn't ask for an unsafe snapshot --- see comments at
551  * head of file.
552  */
554 
555  /*
556  * create state structure
557  */
558  scanstate = makeNode(BitmapHeapScanState);
559  scanstate->ss.ps.plan = (Plan *) node;
560  scanstate->ss.ps.state = estate;
561 
562  scanstate->tbm = NULL;
563  scanstate->tbmiterator = NULL;
564  scanstate->tbmres = NULL;
565  scanstate->exact_pages = 0;
566  scanstate->lossy_pages = 0;
567  scanstate->prefetch_iterator = NULL;
568  scanstate->prefetch_pages = 0;
569  scanstate->prefetch_target = 0;
570  /* may be updated below */
572 
573  /*
574  * Miscellaneous initialization
575  *
576  * create expression context for node
577  */
578  ExecAssignExprContext(estate, &scanstate->ss.ps);
579 
580  /*
581  * initialize child expressions
582  */
583  scanstate->ss.ps.targetlist = (List *)
585  (PlanState *) scanstate);
586  scanstate->ss.ps.qual = (List *)
587  ExecInitExpr((Expr *) node->scan.plan.qual,
588  (PlanState *) scanstate);
589  scanstate->bitmapqualorig = (List *)
590  ExecInitExpr((Expr *) node->bitmapqualorig,
591  (PlanState *) scanstate);
592 
593  /*
594  * tuple table initialization
595  */
596  ExecInitResultTupleSlot(estate, &scanstate->ss.ps);
597  ExecInitScanTupleSlot(estate, &scanstate->ss);
598 
599  /*
600  * open the base relation and acquire appropriate lock on it.
601  */
602  currentRelation = ExecOpenScanRelation(estate, node->scan.scanrelid, eflags);
603 
604  /*
605  * Determine the maximum for prefetch_target. If the tablespace has a
606  * specific IO concurrency set, use that to compute the corresponding
607  * maximum value; otherwise, we already initialized to the value computed
608  * by the GUC machinery.
609  */
610  io_concurrency =
611  get_tablespace_io_concurrency(currentRelation->rd_rel->reltablespace);
612  if (io_concurrency != effective_io_concurrency)
613  {
614  double maximum;
615 
616  if (ComputeIoConcurrency(io_concurrency, &maximum))
617  scanstate->prefetch_maximum = rint(maximum);
618  }
619 
620  scanstate->ss.ss_currentRelation = currentRelation;
621 
622  /*
623  * Even though we aren't going to do a conventional seqscan, it is useful
624  * to create a HeapScanDesc --- most of the fields in it are usable.
625  */
626  scanstate->ss.ss_currentScanDesc = heap_beginscan_bm(currentRelation,
627  estate->es_snapshot,
628  0,
629  NULL);
630 
631  /*
632  * get the scan type from the relation descriptor.
633  */
634  ExecAssignScanType(&scanstate->ss, RelationGetDescr(currentRelation));
635 
636  /*
637  * Initialize result tuple type and projection info.
638  */
639  ExecAssignResultTypeFromTL(&scanstate->ss.ps);
640  ExecAssignScanProjectionInfo(&scanstate->ss);
641 
642  /*
643  * initialize child nodes
644  *
645  * We do this last because the child nodes will open indexscans on our
646  * relation's indexes, and we want to be sure we have acquired a lock on
647  * the relation first.
648  */
649  outerPlanState(scanstate) = ExecInitNode(outerPlan(node), estate, eflags);
650 
651  /*
652  * all done.
653  */
654  return scanstate;
655 }
List * qual
Definition: plannodes.h:130
int target_prefetch_pages
Definition: bufmgr.c:129
Plan plan
Definition: plannodes.h:305
void ExecInitScanTupleSlot(EState *estate, ScanState *scanstate)
Definition: execTuples.c:842
Index scanrelid
Definition: plannodes.h:306
#define RelationGetDescr(relation)
Definition: rel.h:425
TIDBitmap * tbm
Definition: execnodes.h:1486
List * qual
Definition: execnodes.h:1062
int get_tablespace_io_concurrency(Oid spcid)
Definition: spccache.c:204
List * targetlist
Definition: execnodes.h:1061
Snapshot es_snapshot
Definition: execnodes.h:370
Relation ss_currentRelation
Definition: execnodes.h:1289
EState * state
Definition: execnodes.h:1049
Form_pg_class rd_rel
Definition: rel.h:113
int effective_io_concurrency
Definition: bufmgr.c:112
void ExecAssignResultTypeFromTL(PlanState *planstate)
Definition: execUtils.c:430
bool ComputeIoConcurrency(int io_concurrency, double *target)
Definition: bufmgr.c:467
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
Relation ExecOpenScanRelation(EState *estate, Index scanrelid, int eflags)
Definition: execUtils.c:772
#define EXEC_FLAG_BACKWARD
Definition: executor.h:60
#define outerPlanState(node)
Definition: execnodes.h:1090
double rint(double x)
Definition: rint.c:22
List * bitmapqualorig
Definition: plannodes.h:439
TBMIterateResult * tbmres
Definition: execnodes.h:1488
#define outerPlan(node)
Definition: plannodes.h:159
HeapScanDesc heap_beginscan_bm(Relation relation, Snapshot snapshot, int nkeys, ScanKey key)
Definition: heapam.c:1422
Plan * plan
Definition: execnodes.h:1047
#define makeNode(_type_)
Definition: nodes.h:556
#define NULL
Definition: c.h:226
#define Assert(condition)
Definition: c.h:671
#define IsMVCCSnapshot(snapshot)
Definition: tqual.h:31
#define EXEC_FLAG_MARK
Definition: executor.h:61
void ExecAssignExprContext(EState *estate, PlanState *planstate)
Definition: execUtils.c:408
TBMIterator * tbmiterator
Definition: execnodes.h:1487
List * targetlist
Definition: plannodes.h:129
HeapScanDesc ss_currentScanDesc
Definition: execnodes.h:1290
TBMIterator * prefetch_iterator
Definition: execnodes.h:1491
void ExecAssignScanType(ScanState *scanstate, TupleDesc tupDesc)
Definition: execUtils.c:709
PlanState * ExecInitNode(Plan *node, EState *estate, int eflags)
Definition: execProcnode.c:137
Definition: pg_list.h:45
void ExecReScanBitmapHeapScan ( BitmapHeapScanState node)

Definition at line 452 of file nodeBitmapHeapscan.c.

References PlanState::chgParam, ExecReScan(), ExecScanReScan(), heap_rescan(), NULL, outerPlan, outerPlanState, BitmapHeapScanState::prefetch_iterator, BitmapHeapScanState::ss, ScanState::ss_currentScanDesc, BitmapHeapScanState::tbm, tbm_end_iterate(), tbm_free(), BitmapHeapScanState::tbmiterator, and BitmapHeapScanState::tbmres.

Referenced by ExecReScan().

453 {
455 
456  /* rescan to release any page pin */
458 
459  if (node->tbmiterator)
461  if (node->prefetch_iterator)
463  if (node->tbm)
464  tbm_free(node->tbm);
465  node->tbm = NULL;
466  node->tbmiterator = NULL;
467  node->tbmres = NULL;
468  node->prefetch_iterator = NULL;
469 
470  ExecScanReScan(&node->ss);
471 
472  /*
473  * if chgParam of subnode is not null then plan will be re-scanned by
474  * first ExecProcNode.
475  */
476  if (outerPlan->chgParam == NULL)
477  ExecReScan(outerPlan);
478 }
void tbm_end_iterate(TBMIterator *iterator)
Definition: tidbitmap.c:787
TIDBitmap * tbm
Definition: execnodes.h:1486
void ExecReScan(PlanState *node)
Definition: execAmi.c:73
#define outerPlanState(node)
Definition: execnodes.h:1090
void tbm_free(TIDBitmap *tbm)
Definition: tidbitmap.c:272
void heap_rescan(HeapScanDesc scan, ScanKey key)
Definition: heapam.c:1518
TBMIterateResult * tbmres
Definition: execnodes.h:1488
Bitmapset * chgParam
Definition: execnodes.h:1072
#define outerPlan(node)
Definition: plannodes.h:159
#define NULL
Definition: c.h:226
TBMIterator * tbmiterator
Definition: execnodes.h:1487
HeapScanDesc ss_currentScanDesc
Definition: execnodes.h:1290
TBMIterator * prefetch_iterator
Definition: execnodes.h:1491
void ExecScanReScan(ScanState *node)
Definition: execScan.c:327