diff options
author | Melanie Plageman <melanieplageman@gmail.com> | 2025-01-16 18:42:39 -0500 |
---|---|---|
committer | Melanie Plageman <melanieplageman@gmail.com> | 2025-01-16 18:42:39 -0500 |
commit | f7a8fc10ccb882249f8624b937f2c3b467d07bd6 (patch) | |
tree | 12853f752004fb0283206e30caa9cce4f970eb6c /src/backend/access/heap/heapam_handler.c | |
parent | 7b6468cc9523d7d923487d212281af51f7f3dae2 (diff) | |
download | postgresql-f7a8fc10ccb882249f8624b937f2c3b467d07bd6.tar.gz postgresql-f7a8fc10ccb882249f8624b937f2c3b467d07bd6.zip |
Add and use BitmapHeapScanDescData struct
Move the several members of HeapScanDescData which are specific to
Bitmap Heap Scans into a new struct, BitmapHeapScanDescData, which
inherits from HeapScanDescData.
This reduces the size of the HeapScanDescData for other types of scans
and will allow us to add additional bitmap heap scan-specific members in
the future without fear of bloating the HeapScanDescData.
Reviewed-by: Tomas Vondra
Discussion: https://postgr.es/m/c736f6aa-8b35-4e20-9621-62c7c82e2168%40vondra.me
Diffstat (limited to 'src/backend/access/heap/heapam_handler.c')
-rw-r--r-- | src/backend/access/heap/heapam_handler.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c index e817f8f8f84..a4003cf59e1 100644 --- a/src/backend/access/heap/heapam_handler.c +++ b/src/backend/access/heap/heapam_handler.c @@ -2118,13 +2118,16 @@ heapam_scan_bitmap_next_block(TableScanDesc scan, BlockNumber *blockno, bool *recheck, uint64 *lossy_pages, uint64 *exact_pages) { - HeapScanDesc hscan = (HeapScanDesc) scan; + BitmapHeapScanDesc bscan = (BitmapHeapScanDesc) scan; + HeapScanDesc hscan = (HeapScanDesc) bscan; BlockNumber block; Buffer buffer; Snapshot snapshot; int ntup; TBMIterateResult *tbmres; + Assert(scan->rs_flags & SO_TYPE_BITMAPSCAN); + hscan->rs_cindex = 0; hscan->rs_ntuples = 0; @@ -2162,13 +2165,13 @@ heapam_scan_bitmap_next_block(TableScanDesc scan, */ if (!(scan->rs_flags & SO_NEED_TUPLES) && !tbmres->recheck && - VM_ALL_VISIBLE(scan->rs_rd, tbmres->blockno, &hscan->rs_vmbuffer)) + VM_ALL_VISIBLE(scan->rs_rd, tbmres->blockno, &bscan->rs_vmbuffer)) { /* can't be lossy in the skip_fetch case */ Assert(tbmres->ntuples >= 0); - Assert(hscan->rs_empty_tuples_pending >= 0); + Assert(bscan->rs_empty_tuples_pending >= 0); - hscan->rs_empty_tuples_pending += tbmres->ntuples; + bscan->rs_empty_tuples_pending += tbmres->ntuples; return true; } @@ -2282,18 +2285,19 @@ static bool heapam_scan_bitmap_next_tuple(TableScanDesc scan, TupleTableSlot *slot) { - HeapScanDesc hscan = (HeapScanDesc) scan; + BitmapHeapScanDesc bscan = (BitmapHeapScanDesc) scan; + HeapScanDesc hscan = (HeapScanDesc) bscan; OffsetNumber targoffset; Page page; ItemId lp; - if (hscan->rs_empty_tuples_pending > 0) + if (bscan->rs_empty_tuples_pending > 0) { /* * If we don't have to fetch the tuple, just return nulls. */ ExecStoreAllNullTuple(slot); - hscan->rs_empty_tuples_pending--; + bscan->rs_empty_tuples_pending--; return true; } |