v22b-0015-Add-scan_in_progress-to-BitmapHeapScanState.patch
text/x-patch
Filename: v22b-0015-Add-scan_in_progress-to-BitmapHeapScanState.patch
Type: text/x-patch
Part: 14
Patch
Format: format-patch
Series: patch 0015
Subject: Add scan_in_progress to BitmapHeapScanState
| File | + | − |
|---|---|---|
| src/backend/executor/nodeBitmapHeapscan.c | 4 | 1 |
| src/include/nodes/execnodes.h | 2 | 0 |
From c8a9b5a0db622323a7a928376e8f5ef528991522 Mon Sep 17 00:00:00 2001
From: Melanie Plageman <melanieplageman@gmail.com>
Date: Thu, 13 Jun 2024 13:38:46 -0400
Subject: [PATCH v22b 15/29] Add scan_in_progress to BitmapHeapScanState
Instead of checking that the scan descriptor hasn't been allocated yet,
use a dedicated variable, scan_in_progress. This feels cleaner and also
allows us to more easily extract the per scan setup into a separate
function.
---
src/backend/executor/nodeBitmapHeapscan.c | 5 ++++-
src/include/nodes/execnodes.h | 2 ++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index fd58b202c5d..d9c6f252138 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -141,7 +141,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
* If this is the first scan of the underlying table, create the table
* scan descriptor and begin the scan.
*/
- if (!scan)
+ if (!node->scan_in_progress)
{
bool need_tuples = false;
@@ -163,8 +163,10 @@ BitmapHeapNext(BitmapHeapScanState *node)
need_tuples);
node->scandesc = scan;
+ node->scan_in_progress = true;
}
+ Assert(scan);
tbm_begin_iterate(&scan->tbmiterator, node->tbm, dsa,
pstate ?
pstate->tbmiterator :
@@ -659,6 +661,7 @@ ExecInitBitmapHeapScan(BitmapHeapScan *node, EState *estate, int eflags)
scanstate->prefetch_pages = 0;
scanstate->prefetch_target = -1;
scanstate->initialized = false;
+ scanstate->scan_in_progress = false;
scanstate->pstate = NULL;
scanstate->recheck = true;
scanstate->blockno = InvalidBlockNumber;
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index c8cc9f4295e..4c0c5c14f64 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1804,6 +1804,7 @@ typedef struct ParallelBitmapHeapState
* prefetch_target current target prefetch distance
* prefetch_maximum maximum value for prefetch_target
* initialized is node is ready to iterate
+ * scan_in_progress is this a rescan
* pstate shared state for parallel bitmap scan
* recheck do current page's tuples need recheck
* blockno used to validate pf and current block in sync
@@ -1823,6 +1824,7 @@ typedef struct BitmapHeapScanState
int prefetch_target;
int prefetch_maximum;
bool initialized;
+ bool scan_in_progress;
/* XXX probably should be kept in the order per comment */
TBMIterator prefetch_iterator;
ParallelBitmapHeapState *pstate;
--
2.45.2