From d09db7eab48cefb0598080b2dc1f44b6e0761d94 Mon Sep 17 00:00:00 2001
From: Andres Freund <andres@anarazel.de>
Date: Tue, 17 Mar 2026 11:00:26 -0400
Subject: [PATCH v2 2/9] wip: Don't include snapmgr.h in bufmgr.h

---
 src/include/access/nbtree.h               | 2 ++
 src/include/storage/bufmgr.h              | 1 -
 src/backend/access/brin/brin.c            | 1 +
 src/backend/access/gin/gininsert.c        | 1 +
 src/backend/access/gin/ginvacuum.c        | 1 +
 src/backend/access/heap/heapam.c          | 1 +
 src/backend/access/heap/heapam_handler.c  | 1 +
 src/backend/access/heap/vacuumlazy.c      | 1 +
 src/backend/access/nbtree/nbtree.c        | 1 +
 src/backend/access/nbtree/nbtvalidate.c   | 1 +
 src/backend/access/table/tableam.c        | 1 +
 src/backend/executor/nodeBitmapHeapscan.c | 1 +
 contrib/amcheck/verify_heapam.c           | 1 +
 13 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/include/access/nbtree.h b/src/include/access/nbtree.h
index da7503c57b6..bf166bf8ac9 100644
--- a/src/include/access/nbtree.h
+++ b/src/include/access/nbtree.h
@@ -17,6 +17,7 @@
 #include "access/amapi.h"
 #include "access/itup.h"
 #include "access/sdir.h"
+#include "access/transam.h"
 #include "catalog/pg_am_d.h"
 #include "catalog/pg_class.h"
 #include "catalog/pg_index.h"
@@ -24,6 +25,7 @@
 #include "storage/bufmgr.h"
 #include "storage/dsm.h"
 #include "storage/shm_toc.h"
+#include "utils/snapmgr.h"
 #include "utils/skipsupport.h"
 
 /* There's room for a 16-bit vacuum cycle ID in BTPageOpaqueData */
diff --git a/src/include/storage/bufmgr.h b/src/include/storage/bufmgr.h
index aa61a39d9e6..c4b48c2aa4c 100644
--- a/src/include/storage/bufmgr.h
+++ b/src/include/storage/bufmgr.h
@@ -21,7 +21,6 @@
 #include "storage/bufpage.h"
 #include "storage/relfilelocator.h"
 #include "utils/relcache.h"
-#include "utils/snapmgr.h"
 
 typedef void *Block;
 
diff --git a/src/backend/access/brin/brin.c b/src/backend/access/brin/brin.c
index 5ec99d44d59..9117dfb09a3 100644
--- a/src/backend/access/brin/brin.c
+++ b/src/backend/access/brin/brin.c
@@ -45,6 +45,7 @@
 #include "utils/index_selfuncs.h"
 #include "utils/memutils.h"
 #include "utils/rel.h"
+#include "utils/snapmgr.h"
 #include "utils/tuplesort.h"
 #include "utils/wait_event.h"
 
diff --git a/src/backend/access/gin/gininsert.c b/src/backend/access/gin/gininsert.c
index 9d83a495775..bdf2335f7f5 100644
--- a/src/backend/access/gin/gininsert.c
+++ b/src/backend/access/gin/gininsert.c
@@ -36,6 +36,7 @@
 #include "utils/memutils.h"
 #include "utils/builtins.h"
 #include "utils/rel.h"
+#include "utils/snapmgr.h"
 #include "utils/tuplesort.h"
 #include "utils/typcache.h"
 #include "utils/wait_event.h"
diff --git a/src/backend/access/gin/ginvacuum.c b/src/backend/access/gin/ginvacuum.c
index 840543eb664..fb7dd6e463f 100644
--- a/src/backend/access/gin/ginvacuum.c
+++ b/src/backend/access/gin/ginvacuum.c
@@ -24,6 +24,7 @@
 #include "storage/predicate.h"
 #include "storage/read_stream.h"
 #include "utils/memutils.h"
+#include "utils/snapmgr.h"
 
 struct GinVacuumState
 {
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c
index 6bff0032db2..8c4fb04af19 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -52,6 +52,7 @@
 #include "utils/datum.h"
 #include "utils/injection_point.h"
 #include "utils/inval.h"
+#include "utils/snapmgr.h"
 #include "utils/spccache.h"
 #include "utils/syscache.h"
 
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index 1be8ea4845a..ad8220cb0f0 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -46,6 +46,7 @@
 #include "storage/smgr.h"
 #include "utils/builtins.h"
 #include "utils/rel.h"
+#include "utils/snapmgr.h"
 #include "utils/tuplesort.h"
 
 static void reform_and_rewrite_tuple(HeapTuple tuple,
diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c
index 88c71cd85b6..0da7ebe59e6 100644
--- a/src/backend/access/heap/vacuumlazy.c
+++ b/src/backend/access/heap/vacuumlazy.c
@@ -154,6 +154,7 @@
 #include "storage/read_stream.h"
 #include "utils/lsyscache.h"
 #include "utils/pg_rusage.h"
+#include "utils/snapmgr.h"
 #include "utils/timestamp.h"
 #include "utils/wait_event.h"
 
diff --git a/src/backend/access/nbtree/nbtree.c b/src/backend/access/nbtree/nbtree.c
index 6d870e4ebe7..d4aac844352 100644
--- a/src/backend/access/nbtree/nbtree.c
+++ b/src/backend/access/nbtree/nbtree.c
@@ -36,6 +36,7 @@
 #include "utils/fmgrprotos.h"
 #include "utils/index_selfuncs.h"
 #include "utils/memutils.h"
+#include "utils/snapmgr.h"
 #include "utils/wait_event.h"
 
 
diff --git a/src/backend/access/nbtree/nbtvalidate.c b/src/backend/access/nbtree/nbtvalidate.c
index b67c015a4e7..f4ee2988f1f 100644
--- a/src/backend/access/nbtree/nbtvalidate.c
+++ b/src/backend/access/nbtree/nbtvalidate.c
@@ -25,6 +25,7 @@
 #include "utils/builtins.h"
 #include "utils/lsyscache.h"
 #include "utils/regproc.h"
+#include "utils/snapmgr.h"
 #include "utils/syscache.h"
 
 
diff --git a/src/backend/access/table/tableam.c b/src/backend/access/table/tableam.c
index 68ff0966f1c..427be8f8f72 100644
--- a/src/backend/access/table/tableam.c
+++ b/src/backend/access/table/tableam.c
@@ -30,6 +30,7 @@
 #include "storage/bufmgr.h"
 #include "storage/shmem.h"
 #include "storage/smgr.h"
+#include "utils/snapmgr.h"
 
 /*
  * Constants to control the behavior of block allocation to parallel workers
diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 73831aed451..8004bb7b29a 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -47,6 +47,7 @@
 #include "storage/condition_variable.h"
 #include "utils/dsa.h"
 #include "utils/rel.h"
+#include "utils/snapmgr.h"
 #include "utils/spccache.h"
 #include "utils/wait_event.h"
 
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index 20ff58aa782..6b2d7fb634f 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -30,6 +30,7 @@
 #include "utils/builtins.h"
 #include "utils/fmgroids.h"
 #include "utils/rel.h"
+#include "utils/snapmgr.h"
 #include "utils/tuplestore.h"
 
 PG_FUNCTION_INFO_V1(verify_heapam);
-- 
2.53.0.1.gb2826b52eb

