Hello,

Here's another simple piece that I noticed while fooling around with the 
doxygen report -- genam.h was including tidbitmap.h and relcache.h for the sake 
of one typedefs each, and this was bleeding in other places in a rather random 
fashion, particularly through amapi.h.  I propose the following to fix it.  The 
changes to inet.h and varbit.h are surprising, but required.  (It's possible 
that we should be including varatt.h in more datatype headers than just those 
two, but at least these are the ones that complained.  So another option would 
be to include varatt.h in the files that include those headers. However, that 
seems to me to be the wrong direction).


-- 
Álvaro Herrera
From 32ad7228b3073e296f87670d6e4d8a0dbfdd100a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=81lvaro=20Herrera?= <[email protected]>
Date: Sun, 28 Sep 2025 11:15:51 +0200
Subject: [PATCH] Remove genam.h's dependency on relcache.h and tidbitmap.h

---
 src/include/access/amapi.h  | 2 ++
 src/include/access/genam.h  | 6 ++++--
 src/include/access/nbtree.h | 1 +
 src/include/utils/inet.h    | 1 +
 src/include/utils/varbit.h  | 1 +
 5 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/include/access/amapi.h b/src/include/access/amapi.h
index 2b4482dc1e6..63dd41c1f21 100644
--- a/src/include/access/amapi.h
+++ b/src/include/access/amapi.h
@@ -15,6 +15,8 @@
 #include "access/cmptype.h"
 #include "access/genam.h"
 #include "access/stratnum.h"
+#include "nodes/nodes.h"
+#include "nodes/pg_list.h"
 
 /*
  * We don't wish to include planner header files here, since most of an index
diff --git a/src/include/access/genam.h b/src/include/access/genam.h
index ac62f6a6abd..e23eb04650b 100644
--- a/src/include/access/genam.h
+++ b/src/include/access/genam.h
@@ -17,15 +17,17 @@
 #include "access/htup.h"
 #include "access/sdir.h"
 #include "access/skey.h"
-#include "nodes/tidbitmap.h"
 #include "storage/buf.h"
 #include "storage/lockdefs.h"
-#include "utils/relcache.h"
 #include "utils/snapshot.h"
 
 /* We don't want this file to depend on execnodes.h. */
 typedef struct IndexInfo IndexInfo;
 typedef struct TupleTableSlot TupleTableSlot;
+/* or tidbitmap.h */
+typedef struct TIDBitmap TIDBitmap;
+/* or relcache.h */
+typedef struct RelationData *Relation;
 
 
 /*
diff --git a/src/include/access/nbtree.h b/src/include/access/nbtree.h
index 9ab467cb8fd..db1345f54c8 100644
--- a/src/include/access/nbtree.h
+++ b/src/include/access/nbtree.h
@@ -22,6 +22,7 @@
 #include "catalog/pg_index.h"
 #include "lib/stringinfo.h"
 #include "storage/bufmgr.h"
+#include "storage/dsm.h"
 #include "storage/shm_toc.h"
 #include "utils/skipsupport.h"
 
diff --git a/src/include/utils/inet.h b/src/include/utils/inet.h
index ace8957f220..f08cf2abc95 100644
--- a/src/include/utils/inet.h
+++ b/src/include/utils/inet.h
@@ -15,6 +15,7 @@
 #define INET_H
 
 #include "fmgr.h"
+#include "varatt.h"
 
 /*
  *	This is the internal storage format for IP addresses
diff --git a/src/include/utils/varbit.h b/src/include/utils/varbit.h
index 7b81e8e6bbc..f633e232502 100644
--- a/src/include/utils/varbit.h
+++ b/src/include/utils/varbit.h
@@ -18,6 +18,7 @@
 #include <limits.h>
 
 #include "fmgr.h"
+#include "varatt.h"
 
 /*
  * Modeled on struct varlena from c.h, but data type is bits8.
-- 
2.47.3

Reply via email to