From c0a8b444c19cd005588c70e56471967e2402aa9b Mon Sep 17 00:00:00 2001 From: Andres Freund Date: Fri, 13 Mar 2026 10:30:34 -0400 Subject: [PATCH v2 07/17] Move ParallelBitmapHeapState to nodeBitmapHeapscan.c --- src/include/executor/hashjoin.h | 1 + src/include/nodes/execnodes.h | 41 +++-------------------- src/backend/access/brin/brin.c | 1 + src/backend/access/gin/gininsert.c | 1 + src/backend/access/nbtree/nbtsort.c | 1 + src/backend/executor/nodeBitmapHeapscan.c | 39 +++++++++++++++++++++ 6 files changed, 47 insertions(+), 37 deletions(-) diff --git a/src/include/executor/hashjoin.h b/src/include/executor/hashjoin.h index 67bcc781119..9cc82cdea4b 100644 --- a/src/include/executor/hashjoin.h +++ b/src/include/executor/hashjoin.h @@ -19,6 +19,7 @@ #include "storage/barrier.h" #include "storage/buffile.h" #include "storage/lwlock.h" +#include "utils/dsa.h" #include "utils/sharedtuplestore.h" /* ---------------------------------------------------------------- diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h index 652cc316067..e58a005c33d 100644 --- a/src/include/nodes/execnodes.h +++ b/src/include/nodes/execnodes.h @@ -41,8 +41,6 @@ #include "nodes/plannodes.h" #include "partitioning/partdefs.h" #include "storage/buf.h" -#include "storage/condition_variable.h" -#include "utils/dsa.h" #include "utils/hsearch.h" #include "utils/queryenvironment.h" #include "utils/reltrigger.h" @@ -1823,41 +1821,6 @@ typedef struct BitmapIndexScanState SharedIndexScanInstrumentation *biss_SharedInfo; } BitmapIndexScanState; -/* ---------------- - * SharedBitmapState information - * - * BM_INITIAL TIDBitmap creation is not yet started, so first worker - * to see this state will set the state to BM_INPROGRESS - * and that process will be responsible for creating - * TIDBitmap. - * BM_INPROGRESS TIDBitmap creation is in progress; workers need to - * sleep until it's finished. - * BM_FINISHED TIDBitmap creation is done, so now all workers can - * proceed to iterate over TIDBitmap. - * ---------------- - */ -typedef enum -{ - BM_INITIAL, - BM_INPROGRESS, - BM_FINISHED, -} SharedBitmapState; - -/* ---------------- - * ParallelBitmapHeapState information - * tbmiterator iterator for scanning current pages - * mutex mutual exclusion for state - * state current state of the TIDBitmap - * cv conditional wait variable - * ---------------- - */ -typedef struct ParallelBitmapHeapState -{ - dsa_pointer tbmiterator; - slock_t mutex; - SharedBitmapState state; - ConditionVariable cv; -} ParallelBitmapHeapState; /* ---------------- * BitmapHeapScanState information @@ -1871,6 +1834,10 @@ typedef struct ParallelBitmapHeapState * recheck do current page's tuples need recheck * ---------------- */ + +/* this struct is defined in nodeBitmapHeapscan.c */ +typedef struct ParallelBitmapHeapState ParallelBitmapHeapState; + typedef struct BitmapHeapScanState { ScanState ss; /* its first field is NodeTag */ diff --git a/src/backend/access/brin/brin.c b/src/backend/access/brin/brin.c index 1909c3254b5..4f493312750 100644 --- a/src/backend/access/brin/brin.c +++ b/src/backend/access/brin/brin.c @@ -32,6 +32,7 @@ #include "pgstat.h" #include "postmaster/autovacuum.h" #include "storage/bufmgr.h" +#include "storage/condition_variable.h" #include "storage/freespace.h" #include "storage/proc.h" #include "tcop/tcopprot.h" diff --git a/src/backend/access/gin/gininsert.c b/src/backend/access/gin/gininsert.c index 923bfa3fcb4..cfb1adff544 100644 --- a/src/backend/access/gin/gininsert.c +++ b/src/backend/access/gin/gininsert.c @@ -27,6 +27,7 @@ #include "nodes/execnodes.h" #include "pgstat.h" #include "storage/bufmgr.h" +#include "storage/condition_variable.h" #include "storage/proc.h" #include "storage/predicate.h" #include "tcop/tcopprot.h" diff --git a/src/backend/access/nbtree/nbtsort.c b/src/backend/access/nbtree/nbtsort.c index 69ef1527e06..47a9bda30c9 100644 --- a/src/backend/access/nbtree/nbtsort.c +++ b/src/backend/access/nbtree/nbtsort.c @@ -52,6 +52,7 @@ #include "miscadmin.h" #include "pgstat.h" #include "storage/bulk_write.h" +#include "storage/condition_variable.h" #include "storage/proc.h" #include "tcop/tcopprot.h" #include "utils/rel.h" diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c index e0b6df64767..6888f0a8798 100644 --- a/src/backend/executor/nodeBitmapHeapscan.c +++ b/src/backend/executor/nodeBitmapHeapscan.c @@ -43,6 +43,8 @@ #include "miscadmin.h" #include "pgstat.h" #include "storage/bufmgr.h" +#include "storage/condition_variable.h" +#include "utils/dsa.h" #include "utils/rel.h" #include "utils/spccache.h" #include "utils/wait_event.h" @@ -53,6 +55,43 @@ static inline void BitmapDoneInitializingSharedState(ParallelBitmapHeapState *ps static bool BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate); +/* ---------------- + * SharedBitmapState information + * + * BM_INITIAL TIDBitmap creation is not yet started, so first worker + * to see this state will set the state to BM_INPROGRESS + * and that process will be responsible for creating + * TIDBitmap. + * BM_INPROGRESS TIDBitmap creation is in progress; workers need to + * sleep until it's finished. + * BM_FINISHED TIDBitmap creation is done, so now all workers can + * proceed to iterate over TIDBitmap. + * ---------------- + */ +typedef enum +{ + BM_INITIAL, + BM_INPROGRESS, + BM_FINISHED, +} SharedBitmapState; + +/* ---------------- + * ParallelBitmapHeapState information + * tbmiterator iterator for scanning current pages + * mutex mutual exclusion for state + * state current state of the TIDBitmap + * cv conditional wait variable + * ---------------- + */ +typedef struct ParallelBitmapHeapState +{ + dsa_pointer tbmiterator; + slock_t mutex; + SharedBitmapState state; + ConditionVariable cv; +} ParallelBitmapHeapState; + + /* * Do the underlying index scan, build the bitmap, set up the parallel state * needed for parallel workers to iterate through the bitmap, and set up the -- 2.53.0.1.gb2826b52eb