Hi,

On 2026-03-13 14:05:24 +0100, Álvaro Herrera wrote:
> execnodes.h is a very large source of other headers for no very good
> reasons anymore.  Fortunately there's a few of the files it includes
> that we can remove very easily with just a small number of additional
> typedefs.  Some proposed patches attached; it's all very
> straightforward, just add typedefs for structs
>   Tuplesortstate
>   Tuplestorestate
>   TupleConversionMap
>   TupleTableSlot
>   TupleTableSlotOps
>   TIDBitmap
> This also requires to add some headers to a bunch of .c files, which is
> a good indicator that we're making progress.
> 
> It's especially nice when the new #include line we have to add in some
> .c file is not the one that was removed from the .h file -- for instance
> in 0001 we have to add pg_type_d.h when removing tuplestore.h/
> tuplesort.h, and if you look at the chart here
> https://doxygen.postgresql.org/tuplesort_8h.html it becomes very clear
> we're saving quite a lot of useless indirect inclusions.  (This is also
> seen in 0004: we remove tuptable.h and have to add sysattr.h to three .c
> files).

Nice.


> From 47d5e30b00ce8c0c37c8b905223f1b70a5020bfa Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?=C3=81lvaro=20Herrera?= <[email protected]>
> Date: Thu, 5 Mar 2026 18:00:54 +0100
> Subject: [PATCH 1/6] remove tuplestore.h and tuplesort.h from execnodes.h

> diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
> index 31e19fbc697..ada782f98f5 100644
> --- a/contrib/amcheck/verify_heapam.c
> +++ b/contrib/amcheck/verify_heapam.c
> @@ -29,6 +29,7 @@
>  #include "utils/builtins.h"
>  #include "utils/fmgroids.h"
>  #include "utils/rel.h"
> +#include "utils/tuplestore.h"
>  
>  PG_FUNCTION_INFO_V1(verify_heapam);
>  

Kinda wonder if funcapi.h should export tuplestore.h. That'd avoid needing
adding the dedicated tuplestore.h in so many places, and as the use of
tuplestore is basically required for funcapi.h users, it seems like it'd be
fine semantically?

But it also doesn't really matter.


If we could go back in time I'd wrap the tuplestore_puttuple() for the SRF use
case into an SRF specific wrapper, but my time travel capabilities have not
developed, despite no lack of trying.



> Subject: [PATCH 2/6] remove tupconvert.h from execnodes.h

> diff --git a/src/include/catalog/index.h b/src/include/catalog/index.h
> index b259c4141ed..e475e278aa8 100644
> --- a/src/include/catalog/index.h
> +++ b/src/include/catalog/index.h
> @@ -14,6 +14,7 @@
>  #ifndef INDEX_H
>  #define INDEX_H
>  
> +#include "access/attmap.h"
>  #include "catalog/objectaddress.h"
>  #include "nodes/execnodes.h"

A bit sad to include attmap.h here. Looks like it'd not be hard to instead
forward declare AttrMap instead?

I've attached a version of your patches that does so in a followup commit.


> diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
> index 41ac0259b32..8c03498180f 100644
> --- a/src/include/nodes/execnodes.h
> +++ b/src/include/nodes/execnodes.h
> @@ -30,9 +30,9 @@
>  #define EXECNODES_H
>  
>  #include "access/skey.h"
> -#include "access/tupconvert.h"
>  #include "executor/instrument.h"
>  #include "executor/instrument_node.h"
> +#include "executor/tuptable.h"
>  #include "fmgr.h"
>  #include "lib/ilist.h"
>  #include "lib/pairingheap.h"
> @@ -58,6 +58,7 @@ typedef struct ExprState ExprState;
>  typedef struct ExprContext ExprContext;
>  typedef struct Tuplesortstate Tuplesortstate;
>  typedef struct Tuplestorestate Tuplestorestate;
> +typedef struct TupleConversionMap TupleConversionMap;

I was about to complain about growing that tuptable.h include, but I see
that's transient...

LGTM.


> Subject: [PATCH 3/6] don't include sharedtuplestore.h in execnodes.h

LGTM, certainly the missing fd.h includes seem like structurally better.


> Subject: [PATCH 4/6] don't include tuptable.h in execnodes.h

LGTM.  Smaller after the patch to not include attmap.h that I added above, as
that also triggered needing to add those sysattr.h includes.


> Subject: [PATCH 5/6] don't include tidbitmap.h in execnodes.h


> diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
> index 82bd5dcb683..652cc316067 100644
> --- a/src/include/nodes/execnodes.h
> +++ b/src/include/nodes/execnodes.h
> @@ -39,10 +39,10 @@
>  #include "nodes/miscnodes.h"
>  #include "nodes/params.h"
>  #include "nodes/plannodes.h"
> -#include "nodes/tidbitmap.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"
> @@ -56,6 +56,7 @@ typedef struct PlanState PlanState;
>  typedef struct ExecRowMark ExecRowMark;
>  typedef struct ExprState ExprState;
>  typedef struct ExprContext ExprContext;
> +typedef struct TIDBitmap TIDBitmap;
>  typedef struct Tuplesortstate Tuplesortstate;
>  typedef struct Tuplestorestate Tuplestorestate;
>  typedef struct TupleConversionMap TupleConversionMap;
> -- 
> 2.47.3

Sad to add dsa.h this widely. But I don't immediately see a better way, at
least not as part of this commit.

LGTM.


The need for dsa.h and condition_variable.h just is from
ParallelBitmapHeapState - which isn't actually an executor node and never
needed outside of nodeBitmapHeapscan.c - so it seems better to move it there?

Added a commit for that.




Your patch numbering says 5/6, but there's only 5 attached, I assume that was
intentional?


I couldn't help myself to slim down execnodes.h further. Not sure if all of
them are quite worth it.

With all the commits combined very little low-level stuff is still
included. The worst is probably instr_time.h.

Greetings,

Andres Freund
>From 873c22fadf8c93e2d4fdaf4e3e6c3feb1e77774b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=81lvaro=20Herrera?= <[email protected]>
Date: Thu, 5 Mar 2026 18:00:54 +0100
Subject: [PATCH v2 01/17] remove tuplestore.h and tuplesort.h from execnodes.h

---
 src/include/executor/executor.h                      | 1 +
 src/include/nodes/execnodes.h                        | 4 ++--
 src/backend/access/gin/gininsert.c                   | 1 +
 src/backend/access/heap/heapam_handler.c             | 1 +
 src/backend/access/transam/xlogprefetcher.c          | 1 +
 src/backend/backup/walsummaryfuncs.c                 | 1 +
 src/backend/commands/event_trigger.c                 | 1 +
 src/backend/commands/explain.c                       | 1 +
 src/backend/commands/extension.c                     | 1 +
 src/backend/commands/prepare.c                       | 1 +
 src/backend/commands/wait.c                          | 1 +
 src/backend/executor/execExprInterp.c                | 1 +
 src/backend/executor/execSRF.c                       | 1 +
 src/backend/executor/functions.c                     | 1 +
 src/backend/executor/nodeCtescan.c                   | 1 +
 src/backend/executor/nodeFunctionscan.c              | 1 +
 src/backend/executor/nodeMaterial.c                  | 1 +
 src/backend/executor/nodeNamedtuplestorescan.c       | 1 +
 src/backend/executor/nodeRecursiveunion.c            | 1 +
 src/backend/executor/nodeTableFuncscan.c             | 1 +
 src/backend/executor/nodeWindowAgg.c                 | 1 +
 src/backend/executor/nodeWorktablescan.c             | 1 +
 src/backend/executor/spi.c                           | 1 +
 src/backend/foreign/foreign.c                        | 1 +
 src/backend/optimizer/prep/preptlist.c               | 1 +
 src/backend/storage/ipc/dsm_registry.c               | 1 +
 src/backend/storage/ipc/shmem.c                      | 1 +
 src/backend/utils/activity/wait_event_funcs.c        | 1 +
 src/backend/utils/adt/arraysubs.c                    | 1 +
 src/backend/utils/adt/datetime.c                     | 1 +
 src/backend/utils/adt/hbafuncs.c                     | 1 +
 src/backend/utils/adt/jsonbsubs.c                    | 1 +
 src/backend/utils/adt/jsonfuncs.c                    | 1 +
 src/backend/utils/adt/mcxtfuncs.c                    | 2 ++
 src/backend/utils/adt/misc.c                         | 1 +
 src/backend/utils/adt/pgstatfuncs.c                  | 1 +
 src/backend/utils/adt/rangetypes.c                   | 1 +
 src/backend/utils/adt/varlena.c                      | 2 ++
 src/backend/utils/misc/guc_funcs.c                   | 2 ++
 src/backend/utils/misc/pg_config.c                   | 1 +
 src/backend/utils/mmgr/portalmem.c                   | 1 +
 src/pl/plperl/plperl.c                               | 1 +
 contrib/amcheck/verify_heapam.c                      | 1 +
 contrib/dblink/dblink.c                              | 1 +
 contrib/hstore/hstore_subs.c                         | 1 +
 contrib/pageinspect/brinfuncs.c                      | 1 +
 contrib/pageinspect/gistfuncs.c                      | 1 +
 contrib/pg_buffercache/pg_buffercache_pages.c        | 1 +
 contrib/pg_stat_statements/pg_stat_statements.c      | 1 +
 contrib/pg_walinspect/pg_walinspect.c                | 1 +
 contrib/pgrowlocks/pgrowlocks.c                      | 1 +
 contrib/postgres_fdw/connection.c                    | 1 +
 contrib/tablefunc/tablefunc.c                        | 1 +
 contrib/xml2/xpath.c                                 | 1 +
 src/test/modules/injection_points/injection_points.c | 1 +
 src/test/modules/test_ddl_deparse/test_ddl_deparse.c | 1 +
 src/test/modules/test_regex/test_regex.c             | 1 +
 57 files changed, 61 insertions(+), 2 deletions(-)

diff --git a/src/include/executor/executor.h b/src/include/executor/executor.h
index 82c442d23f8..b9f8f896969 100644
--- a/src/include/executor/executor.h
+++ b/src/include/executor/executor.h
@@ -14,6 +14,7 @@
 #ifndef EXECUTOR_H
 #define EXECUTOR_H
 
+#include "access/xlogdefs.h"
 #include "datatype/timestamp.h"
 #include "executor/execdesc.h"
 #include "fmgr.h"
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 63c067d5aae..41ac0259b32 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -48,8 +48,6 @@
 #include "utils/sharedtuplestore.h"
 #include "utils/snapshot.h"
 #include "utils/sortsupport.h"
-#include "utils/tuplesort.h"
-#include "utils/tuplestore.h"
 
 /*
  * forward references in this file
@@ -58,6 +56,8 @@ typedef struct PlanState PlanState;
 typedef struct ExecRowMark ExecRowMark;
 typedef struct ExprState ExprState;
 typedef struct ExprContext ExprContext;
+typedef struct Tuplesortstate Tuplesortstate;
+typedef struct Tuplestorestate Tuplestorestate;
 
 
 /* ----------------
diff --git a/src/backend/access/gin/gininsert.c b/src/backend/access/gin/gininsert.c
index 97cea5f7d4e..923bfa3fcb4 100644
--- a/src/backend/access/gin/gininsert.c
+++ b/src/backend/access/gin/gininsert.c
@@ -34,6 +34,7 @@
 #include "utils/memutils.h"
 #include "utils/builtins.h"
 #include "utils/rel.h"
+#include "utils/tuplesort.h"
 #include "utils/typcache.h"
 #include "utils/wait_event.h"
 
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index 5137d2510ea..ffa14afd992 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -45,6 +45,7 @@
 #include "storage/smgr.h"
 #include "utils/builtins.h"
 #include "utils/rel.h"
+#include "utils/tuplesort.h"
 
 static void reform_and_rewrite_tuple(HeapTuple tuple,
 									 Relation OldHeap, Relation NewHeap,
diff --git a/src/backend/access/transam/xlogprefetcher.c b/src/backend/access/transam/xlogprefetcher.c
index 24cfa96d737..2c1eb217713 100644
--- a/src/backend/access/transam/xlogprefetcher.c
+++ b/src/backend/access/transam/xlogprefetcher.c
@@ -42,6 +42,7 @@
 #include "utils/guc_hooks.h"
 #include "utils/hsearch.h"
 #include "utils/timestamp.h"
+#include "utils/tuplestore.h"
 
 /*
  * Every time we process this much WAL, we'll update the values in
diff --git a/src/backend/backup/walsummaryfuncs.c b/src/backend/backup/walsummaryfuncs.c
index eb26596cf0a..f83c1604263 100644
--- a/src/backend/backup/walsummaryfuncs.c
+++ b/src/backend/backup/walsummaryfuncs.c
@@ -20,6 +20,7 @@
 #include "postmaster/walsummarizer.h"
 #include "utils/fmgrprotos.h"
 #include "utils/pg_lsn.h"
+#include "utils/tuplestore.h"
 
 #define NUM_WS_ATTS			3
 #define NUM_SUMMARY_ATTS	6
diff --git a/src/backend/commands/event_trigger.c b/src/backend/commands/event_trigger.c
index 2898967fa67..27333fd2e27 100644
--- a/src/backend/commands/event_trigger.c
+++ b/src/backend/commands/event_trigger.c
@@ -57,6 +57,7 @@
 #include "utils/rel.h"
 #include "utils/snapmgr.h"
 #include "utils/syscache.h"
+#include "utils/tuplestore.h"
 
 typedef struct EventTriggerQueryState
 {
diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c
index 93918a223b8..25ca7d1df31 100644
--- a/src/backend/commands/explain.c
+++ b/src/backend/commands/explain.c
@@ -42,6 +42,7 @@
 #include "utils/ruleutils.h"
 #include "utils/snapmgr.h"
 #include "utils/tuplesort.h"
+#include "utils/tuplestore.h"
 #include "utils/typcache.h"
 #include "utils/xml.h"
 
diff --git a/src/backend/commands/extension.c b/src/backend/commands/extension.c
index 963618a64c4..b98801d08f2 100644
--- a/src/backend/commands/extension.c
+++ b/src/backend/commands/extension.c
@@ -69,6 +69,7 @@
 #include "utils/rel.h"
 #include "utils/snapmgr.h"
 #include "utils/syscache.h"
+#include "utils/tuplestore.h"
 #include "utils/varlena.h"
 
 
diff --git a/src/backend/commands/prepare.c b/src/backend/commands/prepare.c
index 5b86a727587..ac0c40612b2 100644
--- a/src/backend/commands/prepare.c
+++ b/src/backend/commands/prepare.c
@@ -36,6 +36,7 @@
 #include "utils/builtins.h"
 #include "utils/snapmgr.h"
 #include "utils/timestamp.h"
+#include "utils/tuplestore.h"
 
 
 /*
diff --git a/src/backend/commands/wait.c b/src/backend/commands/wait.c
index 1290df10c6f..720c95056ab 100644
--- a/src/backend/commands/wait.c
+++ b/src/backend/commands/wait.c
@@ -18,6 +18,7 @@
 #include "access/xlog.h"
 #include "access/xlogrecovery.h"
 #include "access/xlogwait.h"
+#include "catalog/pg_type_d.h"
 #include "commands/defrem.h"
 #include "commands/wait.h"
 #include "executor/executor.h"
diff --git a/src/backend/executor/execExprInterp.c b/src/backend/executor/execExprInterp.c
index 61ff5ddc74c..c9c30450234 100644
--- a/src/backend/executor/execExprInterp.c
+++ b/src/backend/executor/execExprInterp.c
@@ -77,6 +77,7 @@
 #include "utils/lsyscache.h"
 #include "utils/memutils.h"
 #include "utils/timestamp.h"
+#include "utils/tuplesort.h"
 #include "utils/typcache.h"
 #include "utils/xml.h"
 
diff --git a/src/backend/executor/execSRF.c b/src/backend/executor/execSRF.c
index a0b111dc0e4..dbeec2a423b 100644
--- a/src/backend/executor/execSRF.c
+++ b/src/backend/executor/execSRF.c
@@ -30,6 +30,7 @@
 #include "utils/builtins.h"
 #include "utils/lsyscache.h"
 #include "utils/memutils.h"
+#include "utils/tuplestore.h"
 #include "utils/typcache.h"
 
 
diff --git a/src/backend/executor/functions.c b/src/backend/executor/functions.c
index 4ca342a43ef..88109348817 100644
--- a/src/backend/executor/functions.c
+++ b/src/backend/executor/functions.c
@@ -37,6 +37,7 @@
 #include "utils/plancache.h"
 #include "utils/snapmgr.h"
 #include "utils/syscache.h"
+#include "utils/tuplestore.h"
 
 
 /*
diff --git a/src/backend/executor/nodeCtescan.c b/src/backend/executor/nodeCtescan.c
index e6e476388e5..509317bf139 100644
--- a/src/backend/executor/nodeCtescan.c
+++ b/src/backend/executor/nodeCtescan.c
@@ -18,6 +18,7 @@
 #include "executor/executor.h"
 #include "executor/nodeCtescan.h"
 #include "miscadmin.h"
+#include "utils/tuplestore.h"
 
 static TupleTableSlot *CteScanNext(CteScanState *node);
 
diff --git a/src/backend/executor/nodeFunctionscan.c b/src/backend/executor/nodeFunctionscan.c
index 63e605e1f81..cf094507e80 100644
--- a/src/backend/executor/nodeFunctionscan.c
+++ b/src/backend/executor/nodeFunctionscan.c
@@ -27,6 +27,7 @@
 #include "funcapi.h"
 #include "nodes/nodeFuncs.h"
 #include "utils/memutils.h"
+#include "utils/tuplestore.h"
 
 
 /*
diff --git a/src/backend/executor/nodeMaterial.c b/src/backend/executor/nodeMaterial.c
index 764032df6c6..e5f387612bc 100644
--- a/src/backend/executor/nodeMaterial.c
+++ b/src/backend/executor/nodeMaterial.c
@@ -24,6 +24,7 @@
 #include "executor/executor.h"
 #include "executor/nodeMaterial.h"
 #include "miscadmin.h"
+#include "utils/tuplestore.h"
 
 /* ----------------------------------------------------------------
  *		ExecMaterial
diff --git a/src/backend/executor/nodeNamedtuplestorescan.c b/src/backend/executor/nodeNamedtuplestorescan.c
index fdfccc8169f..e6aec6174fd 100644
--- a/src/backend/executor/nodeNamedtuplestorescan.c
+++ b/src/backend/executor/nodeNamedtuplestorescan.c
@@ -18,6 +18,7 @@
 #include "executor/executor.h"
 #include "executor/nodeNamedtuplestorescan.h"
 #include "utils/queryenvironment.h"
+#include "utils/tuplestore.h"
 
 static TupleTableSlot *NamedTuplestoreScanNext(NamedTuplestoreScanState *node);
 
diff --git a/src/backend/executor/nodeRecursiveunion.c b/src/backend/executor/nodeRecursiveunion.c
index 5098ddeabb6..7166397e59b 100644
--- a/src/backend/executor/nodeRecursiveunion.c
+++ b/src/backend/executor/nodeRecursiveunion.c
@@ -22,6 +22,7 @@
 #include "executor/nodeRecursiveunion.h"
 #include "miscadmin.h"
 #include "utils/memutils.h"
+#include "utils/tuplestore.h"
 
 
 
diff --git a/src/backend/executor/nodeTableFuncscan.c b/src/backend/executor/nodeTableFuncscan.c
index 52070d147a4..70c7b26570e 100644
--- a/src/backend/executor/nodeTableFuncscan.c
+++ b/src/backend/executor/nodeTableFuncscan.c
@@ -31,6 +31,7 @@
 #include "utils/jsonpath.h"
 #include "utils/lsyscache.h"
 #include "utils/memutils.h"
+#include "utils/tuplestore.h"
 #include "utils/xml.h"
 
 static TupleTableSlot *TableFuncNext(TableFuncScanState *node);
diff --git a/src/backend/executor/nodeWindowAgg.c b/src/backend/executor/nodeWindowAgg.c
index d9b64b0f465..11f69c152bc 100644
--- a/src/backend/executor/nodeWindowAgg.c
+++ b/src/backend/executor/nodeWindowAgg.c
@@ -53,6 +53,7 @@
 #include "utils/memutils.h"
 #include "utils/regproc.h"
 #include "utils/syscache.h"
+#include "utils/tuplestore.h"
 #include "windowapi.h"
 
 /*
diff --git a/src/backend/executor/nodeWorktablescan.c b/src/backend/executor/nodeWorktablescan.c
index 210cc44f911..a0aeeae9e0b 100644
--- a/src/backend/executor/nodeWorktablescan.c
+++ b/src/backend/executor/nodeWorktablescan.c
@@ -17,6 +17,7 @@
 
 #include "executor/executor.h"
 #include "executor/nodeWorktablescan.h"
+#include "utils/tuplestore.h"
 
 static TupleTableSlot *WorkTableScanNext(WorkTableScanState *node);
 
diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c
index 3019a3b2b97..52f3b11301c 100644
--- a/src/backend/executor/spi.c
+++ b/src/backend/executor/spi.c
@@ -32,6 +32,7 @@
 #include "utils/rel.h"
 #include "utils/snapmgr.h"
 #include "utils/syscache.h"
+#include "utils/tuplestore.h"
 #include "utils/typcache.h"
 
 
diff --git a/src/backend/foreign/foreign.c b/src/backend/foreign/foreign.c
index 9ea93b35e86..30000be1d22 100644
--- a/src/backend/foreign/foreign.c
+++ b/src/backend/foreign/foreign.c
@@ -28,6 +28,7 @@
 #include "utils/memutils.h"
 #include "utils/rel.h"
 #include "utils/syscache.h"
+#include "utils/tuplestore.h"
 #include "utils/varlena.h"
 
 
diff --git a/src/backend/optimizer/prep/preptlist.c b/src/backend/optimizer/prep/preptlist.c
index ff9c7c4fb96..bd16d197d4f 100644
--- a/src/backend/optimizer/prep/preptlist.c
+++ b/src/backend/optimizer/prep/preptlist.c
@@ -37,6 +37,7 @@
 #include "postgres.h"
 
 #include "access/table.h"
+#include "catalog/pg_type_d.h"
 #include "nodes/makefuncs.h"
 #include "optimizer/appendinfo.h"
 #include "optimizer/optimizer.h"
diff --git a/src/backend/storage/ipc/dsm_registry.c b/src/backend/storage/ipc/dsm_registry.c
index 068c1577b12..9bfcd616827 100644
--- a/src/backend/storage/ipc/dsm_registry.c
+++ b/src/backend/storage/ipc/dsm_registry.c
@@ -47,6 +47,7 @@
 #include "storage/shmem.h"
 #include "utils/builtins.h"
 #include "utils/memutils.h"
+#include "utils/tuplestore.h"
 
 typedef struct DSMRegistryCtxStruct
 {
diff --git a/src/backend/storage/ipc/shmem.c b/src/backend/storage/ipc/shmem.c
index 55e4a5421de..d3e5d3c8e1f 100644
--- a/src/backend/storage/ipc/shmem.c
+++ b/src/backend/storage/ipc/shmem.c
@@ -75,6 +75,7 @@
 #include "storage/shmem.h"
 #include "storage/spin.h"
 #include "utils/builtins.h"
+#include "utils/tuplestore.h"
 
 /*
  * This is the first data structure stored in the shared memory segment, at
diff --git a/src/backend/utils/activity/wait_event_funcs.c b/src/backend/utils/activity/wait_event_funcs.c
index fa10a80b088..ff683ae8c5d 100644
--- a/src/backend/utils/activity/wait_event_funcs.c
+++ b/src/backend/utils/activity/wait_event_funcs.c
@@ -16,6 +16,7 @@
 
 #include "funcapi.h"
 #include "utils/builtins.h"
+#include "utils/tuplestore.h"
 #include "utils/wait_event.h"
 
 /*
diff --git a/src/backend/utils/adt/arraysubs.c b/src/backend/utils/adt/arraysubs.c
index 63c78ed12cd..2bf9e9509fb 100644
--- a/src/backend/utils/adt/arraysubs.c
+++ b/src/backend/utils/adt/arraysubs.c
@@ -14,6 +14,7 @@
  */
 #include "postgres.h"
 
+#include "catalog/pg_type_d.h"
 #include "executor/execExpr.h"
 #include "nodes/makefuncs.h"
 #include "nodes/nodeFuncs.h"
diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c
index 90946db72ff..8f25c15fcfc 100644
--- a/src/backend/utils/adt/datetime.c
+++ b/src/backend/utils/adt/datetime.c
@@ -30,6 +30,7 @@
 #include "utils/date.h"
 #include "utils/datetime.h"
 #include "utils/guc.h"
+#include "utils/tuplestore.h"
 #include "utils/tzparser.h"
 
 static int	DecodeNumber(int flen, char *str, bool haveTextMonth,
diff --git a/src/backend/utils/adt/hbafuncs.c b/src/backend/utils/adt/hbafuncs.c
index e7432c447e7..fdce3ed7927 100644
--- a/src/backend/utils/adt/hbafuncs.c
+++ b/src/backend/utils/adt/hbafuncs.c
@@ -22,6 +22,7 @@
 #include "utils/array.h"
 #include "utils/builtins.h"
 #include "utils/guc.h"
+#include "utils/tuplestore.h"
 
 
 static ArrayType *get_hba_options(HbaLine *hba);
diff --git a/src/backend/utils/adt/jsonbsubs.c b/src/backend/utils/adt/jsonbsubs.c
index 6bf55f19d6a..f2745b29a3f 100644
--- a/src/backend/utils/adt/jsonbsubs.c
+++ b/src/backend/utils/adt/jsonbsubs.c
@@ -14,6 +14,7 @@
  */
 #include "postgres.h"
 
+#include "catalog/pg_type_d.h"
 #include "executor/execExpr.h"
 #include "nodes/nodeFuncs.h"
 #include "nodes/subscripting.h"
diff --git a/src/backend/utils/adt/jsonfuncs.c b/src/backend/utils/adt/jsonfuncs.c
index d5b64d7fca5..efdf60ca5a5 100644
--- a/src/backend/utils/adt/jsonfuncs.c
+++ b/src/backend/utils/adt/jsonfuncs.c
@@ -38,6 +38,7 @@
 #include "utils/lsyscache.h"
 #include "utils/memutils.h"
 #include "utils/syscache.h"
+#include "utils/tuplestore.h"
 #include "utils/typcache.h"
 
 /* Operations available for setPath */
diff --git a/src/backend/utils/adt/mcxtfuncs.c b/src/backend/utils/adt/mcxtfuncs.c
index c7f7b8bc2dd..1a4dbbeb8db 100644
--- a/src/backend/utils/adt/mcxtfuncs.c
+++ b/src/backend/utils/adt/mcxtfuncs.c
@@ -15,6 +15,7 @@
 
 #include "postgres.h"
 
+#include "catalog/pg_type_d.h"
 #include "funcapi.h"
 #include "mb/pg_wchar.h"
 #include "storage/proc.h"
@@ -23,6 +24,7 @@
 #include "utils/array.h"
 #include "utils/builtins.h"
 #include "utils/hsearch.h"
+#include "utils/tuplestore.h"
 
 /* ----------
  * The max bytes for showing identifiers of MemoryContext.
diff --git a/src/backend/utils/adt/misc.c b/src/backend/utils/adt/misc.c
index 864032c32bf..29ef800d992 100644
--- a/src/backend/utils/adt/misc.c
+++ b/src/backend/utils/adt/misc.c
@@ -46,6 +46,7 @@
 #include "utils/ruleutils.h"
 #include "utils/syscache.h"
 #include "utils/timestamp.h"
+#include "utils/tuplestore.h"
 #include "utils/wait_event.h"
 
 
diff --git a/src/backend/utils/adt/pgstatfuncs.c b/src/backend/utils/adt/pgstatfuncs.c
index 5ac022274a7..38c72a66e64 100644
--- a/src/backend/utils/adt/pgstatfuncs.c
+++ b/src/backend/utils/adt/pgstatfuncs.c
@@ -31,6 +31,7 @@
 #include "utils/acl.h"
 #include "utils/builtins.h"
 #include "utils/timestamp.h"
+#include "utils/tuplestore.h"
 #include "utils/wait_event.h"
 
 #define UINT32_ACCESS_ONCE(var)		 ((uint32)(*((volatile uint32 *)&(var))))
diff --git a/src/backend/utils/adt/rangetypes.c b/src/backend/utils/adt/rangetypes.c
index 06cc3af4f4a..809c0cb44a3 100644
--- a/src/backend/utils/adt/rangetypes.c
+++ b/src/backend/utils/adt/rangetypes.c
@@ -30,6 +30,7 @@
  */
 #include "postgres.h"
 
+#include "access/tupmacs.h"
 #include "common/hashfn.h"
 #include "funcapi.h"
 #include "libpq/pqformat.h"
diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c
index 7caf700fd61..7b1ee61bde6 100644
--- a/src/backend/utils/adt/varlena.c
+++ b/src/backend/utils/adt/varlena.c
@@ -19,6 +19,7 @@
 
 #include "access/detoast.h"
 #include "access/toast_compression.h"
+#include "access/tupmacs.h"
 #include "catalog/pg_collation.h"
 #include "catalog/pg_type.h"
 #include "common/hashfn.h"
@@ -40,6 +41,7 @@
 #include "utils/memutils.h"
 #include "utils/pg_locale.h"
 #include "utils/sortsupport.h"
+#include "utils/tuplestore.h"
 #include "utils/varlena.h"
 
 typedef varlena VarString;
diff --git a/src/backend/utils/misc/guc_funcs.c b/src/backend/utils/misc/guc_funcs.c
index 8524dd3a981..81f60af37f5 100644
--- a/src/backend/utils/misc/guc_funcs.c
+++ b/src/backend/utils/misc/guc_funcs.c
@@ -22,6 +22,7 @@
 #include "catalog/objectaccess.h"
 #include "catalog/pg_authid.h"
 #include "catalog/pg_parameter_acl.h"
+#include "catalog/pg_type_d.h"
 #include "funcapi.h"
 #include "guc_internal.h"
 #include "miscadmin.h"
@@ -30,6 +31,7 @@
 #include "utils/builtins.h"
 #include "utils/guc_tables.h"
 #include "utils/snapmgr.h"
+#include "utils/tuplestore.h"
 
 static char *flatten_set_variable_args(const char *name, List *args);
 static void ShowGUCConfigOption(const char *name, DestReceiver *dest);
diff --git a/src/backend/utils/misc/pg_config.c b/src/backend/utils/misc/pg_config.c
index 210e3a50ff9..1d9d7985cf1 100644
--- a/src/backend/utils/misc/pg_config.c
+++ b/src/backend/utils/misc/pg_config.c
@@ -18,6 +18,7 @@
 #include "funcapi.h"
 #include "miscadmin.h"
 #include "utils/builtins.h"
+#include "utils/tuplestore.h"
 
 Datum
 pg_config(PG_FUNCTION_ARGS)
diff --git a/src/backend/utils/mmgr/portalmem.c b/src/backend/utils/mmgr/portalmem.c
index c1a53e658cb..79c8db2c60f 100644
--- a/src/backend/utils/mmgr/portalmem.c
+++ b/src/backend/utils/mmgr/portalmem.c
@@ -27,6 +27,7 @@
 #include "utils/memutils.h"
 #include "utils/snapmgr.h"
 #include "utils/timestamp.h"
+#include "utils/tuplestore.h"
 
 /*
  * Estimate of the maximum number of open portals a user would have,
diff --git a/src/pl/plperl/plperl.c b/src/pl/plperl/plperl.c
index 02eced3b2c5..c5f11b874c7 100644
--- a/src/pl/plperl/plperl.c
+++ b/src/pl/plperl/plperl.c
@@ -35,6 +35,7 @@
 #include "utils/memutils.h"
 #include "utils/rel.h"
 #include "utils/syscache.h"
+#include "utils/tuplestore.h"
 #include "utils/typcache.h"
 
 /* define our text domain for translations */
diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c
index 31e19fbc697..ada782f98f5 100644
--- a/contrib/amcheck/verify_heapam.c
+++ b/contrib/amcheck/verify_heapam.c
@@ -29,6 +29,7 @@
 #include "utils/builtins.h"
 #include "utils/fmgroids.h"
 #include "utils/rel.h"
+#include "utils/tuplestore.h"
 
 PG_FUNCTION_INFO_V1(verify_heapam);
 
diff --git a/contrib/dblink/dblink.c b/contrib/dblink/dblink.c
index 2498d80c8e7..114883a28b5 100644
--- a/contrib/dblink/dblink.c
+++ b/contrib/dblink/dblink.c
@@ -62,6 +62,7 @@
 #include "utils/lsyscache.h"
 #include "utils/memutils.h"
 #include "utils/rel.h"
+#include "utils/tuplestore.h"
 #include "utils/varlena.h"
 #include "utils/wait_event.h"
 
diff --git a/contrib/hstore/hstore_subs.c b/contrib/hstore/hstore_subs.c
index 45b8c962038..56e0858c1a6 100644
--- a/contrib/hstore/hstore_subs.c
+++ b/contrib/hstore/hstore_subs.c
@@ -23,6 +23,7 @@
  */
 #include "postgres.h"
 
+#include "catalog/pg_type_d.h"
 #include "executor/execExpr.h"
 #include "hstore.h"
 #include "nodes/nodeFuncs.h"
diff --git a/contrib/pageinspect/brinfuncs.c b/contrib/pageinspect/brinfuncs.c
index 26cf78252ed..309b9522f90 100644
--- a/contrib/pageinspect/brinfuncs.c
+++ b/contrib/pageinspect/brinfuncs.c
@@ -22,6 +22,7 @@
 #include "utils/builtins.h"
 #include "utils/lsyscache.h"
 #include "utils/rel.h"
+#include "utils/tuplestore.h"
 
 PG_FUNCTION_INFO_V1(brin_page_type);
 PG_FUNCTION_INFO_V1(brin_page_items);
diff --git a/contrib/pageinspect/gistfuncs.c b/contrib/pageinspect/gistfuncs.c
index a205cb8a334..e56c7d8a601 100644
--- a/contrib/pageinspect/gistfuncs.c
+++ b/contrib/pageinspect/gistfuncs.c
@@ -25,6 +25,7 @@
 #include "utils/pg_lsn.h"
 #include "utils/rel.h"
 #include "utils/ruleutils.h"
+#include "utils/tuplestore.h"
 
 PG_FUNCTION_INFO_V1(gist_page_opaque_info);
 PG_FUNCTION_INFO_V1(gist_page_items);
diff --git a/contrib/pg_buffercache/pg_buffercache_pages.c b/contrib/pg_buffercache/pg_buffercache_pages.c
index 89b86855243..b055eb31794 100644
--- a/contrib/pg_buffercache/pg_buffercache_pages.c
+++ b/contrib/pg_buffercache/pg_buffercache_pages.c
@@ -16,6 +16,7 @@
 #include "storage/buf_internals.h"
 #include "storage/bufmgr.h"
 #include "utils/rel.h"
+#include "utils/tuplestore.h"
 
 
 #define NUM_BUFFERCACHE_PAGES_MIN_ELEM	8
diff --git a/contrib/pg_stat_statements/pg_stat_statements.c b/contrib/pg_stat_statements/pg_stat_statements.c
index 4a427533bd8..6cb14824ec3 100644
--- a/contrib/pg_stat_statements/pg_stat_statements.c
+++ b/contrib/pg_stat_statements/pg_stat_statements.c
@@ -71,6 +71,7 @@
 #include "utils/builtins.h"
 #include "utils/memutils.h"
 #include "utils/timestamp.h"
+#include "utils/tuplestore.h"
 
 PG_MODULE_MAGIC_EXT(
 					.name = "pg_stat_statements",
diff --git a/contrib/pg_walinspect/pg_walinspect.c b/contrib/pg_walinspect/pg_walinspect.c
index 716a0922c6b..0b830b2d567 100644
--- a/contrib/pg_walinspect/pg_walinspect.c
+++ b/contrib/pg_walinspect/pg_walinspect.c
@@ -24,6 +24,7 @@
 #include "utils/array.h"
 #include "utils/builtins.h"
 #include "utils/pg_lsn.h"
+#include "utils/tuplestore.h"
 
 /*
  * NOTE: For any code change or issue fix here, it is highly recommended to
diff --git a/contrib/pgrowlocks/pgrowlocks.c b/contrib/pgrowlocks/pgrowlocks.c
index f88269332b6..ff3692c87c4 100644
--- a/contrib/pgrowlocks/pgrowlocks.c
+++ b/contrib/pgrowlocks/pgrowlocks.c
@@ -40,6 +40,7 @@
 #include "utils/fmgrprotos.h"
 #include "utils/rel.h"
 #include "utils/snapmgr.h"
+#include "utils/tuplestore.h"
 #include "utils/varlena.h"
 
 PG_MODULE_MAGIC_EXT(
diff --git a/contrib/postgres_fdw/connection.c b/contrib/postgres_fdw/connection.c
index 7e2b822d161..192f8011160 100644
--- a/contrib/postgres_fdw/connection.c
+++ b/contrib/postgres_fdw/connection.c
@@ -33,6 +33,7 @@
 #include "utils/hsearch.h"
 #include "utils/inval.h"
 #include "utils/syscache.h"
+#include "utils/tuplestore.h"
 
 /*
  * Connection cache hash table entry
diff --git a/contrib/tablefunc/tablefunc.c b/contrib/tablefunc/tablefunc.c
index ca2434c6e19..c01a01c5fe7 100644
--- a/contrib/tablefunc/tablefunc.c
+++ b/contrib/tablefunc/tablefunc.c
@@ -43,6 +43,7 @@
 #include "lib/stringinfo.h"
 #include "miscadmin.h"
 #include "utils/builtins.h"
+#include "utils/tuplestore.h"
 
 PG_MODULE_MAGIC_EXT(
 					.name = "tablefunc",
diff --git a/contrib/xml2/xpath.c b/contrib/xml2/xpath.c
index 662d7d02f27..14b9e014d74 100644
--- a/contrib/xml2/xpath.c
+++ b/contrib/xml2/xpath.c
@@ -12,6 +12,7 @@
 #include "funcapi.h"
 #include "lib/stringinfo.h"
 #include "utils/builtins.h"
+#include "utils/tuplestore.h"
 #include "utils/xml.h"
 
 /* libxml includes */
diff --git a/src/test/modules/injection_points/injection_points.c b/src/test/modules/injection_points/injection_points.c
index 3de0491e0ec..d59c5ad0582 100644
--- a/src/test/modules/injection_points/injection_points.c
+++ b/src/test/modules/injection_points/injection_points.c
@@ -31,6 +31,7 @@
 #include "utils/guc.h"
 #include "utils/injection_point.h"
 #include "utils/memutils.h"
+#include "utils/tuplestore.h"
 #include "utils/wait_event.h"
 
 PG_MODULE_MAGIC;
diff --git a/src/test/modules/test_ddl_deparse/test_ddl_deparse.c b/src/test/modules/test_ddl_deparse/test_ddl_deparse.c
index 380b3e754b7..64a1dfa9f79 100644
--- a/src/test/modules/test_ddl_deparse/test_ddl_deparse.c
+++ b/src/test/modules/test_ddl_deparse/test_ddl_deparse.c
@@ -15,6 +15,7 @@
 #include "tcop/deparse_utility.h"
 #include "tcop/utility.h"
 #include "utils/builtins.h"
+#include "utils/tuplestore.h"
 
 PG_MODULE_MAGIC;
 
diff --git a/src/test/modules/test_regex/test_regex.c b/src/test/modules/test_regex/test_regex.c
index 4e97cde65a6..cfe569aa060 100644
--- a/src/test/modules/test_regex/test_regex.c
+++ b/src/test/modules/test_regex/test_regex.c
@@ -14,6 +14,7 @@
 
 #include "postgres.h"
 
+#include "catalog/pg_type_d.h"
 #include "funcapi.h"
 #include "regex/regex.h"
 #include "utils/array.h"
-- 
2.53.0.1.gb2826b52eb

>From b2ed453d5230cf2e6f21763c89067ccd32c2b434 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=81lvaro=20Herrera?= <[email protected]>
Date: Fri, 6 Mar 2026 12:52:03 +0100
Subject: [PATCH v2 02/17] remove tupconvert.h from execnodes.h

---
 src/include/catalog/index.h              | 1 +
 src/include/nodes/execnodes.h            | 3 ++-
 src/backend/commands/copyfrom.c          | 1 +
 src/backend/commands/copyto.c            | 1 +
 src/backend/commands/tablecmds.c         | 1 +
 src/backend/commands/trigger.c           | 1 +
 src/backend/executor/execExprInterp.c    | 1 +
 src/backend/executor/execMain.c          | 1 +
 src/backend/executor/execPartition.c     | 1 +
 src/backend/executor/execUtils.c         | 1 +
 src/backend/executor/nodeModifyTable.c   | 1 +
 src/backend/replication/logical/worker.c | 1 +
 src/backend/rewrite/rewriteManip.c       | 1 +
 src/backend/utils/sort/tuplestore.c      | 1 +
 src/pl/tcl/pltcl.c                       | 1 +
 15 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/include/catalog/index.h b/src/include/catalog/index.h
index b259c4141ed..e475e278aa8 100644
--- a/src/include/catalog/index.h
+++ b/src/include/catalog/index.h
@@ -14,6 +14,7 @@
 #ifndef INDEX_H
 #define INDEX_H
 
+#include "access/attmap.h"
 #include "catalog/objectaddress.h"
 #include "nodes/execnodes.h"
 
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 41ac0259b32..8c03498180f 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -30,9 +30,9 @@
 #define EXECNODES_H
 
 #include "access/skey.h"
-#include "access/tupconvert.h"
 #include "executor/instrument.h"
 #include "executor/instrument_node.h"
+#include "executor/tuptable.h"
 #include "fmgr.h"
 #include "lib/ilist.h"
 #include "lib/pairingheap.h"
@@ -58,6 +58,7 @@ typedef struct ExprState ExprState;
 typedef struct ExprContext ExprContext;
 typedef struct Tuplesortstate Tuplesortstate;
 typedef struct Tuplestorestate Tuplestorestate;
+typedef struct TupleConversionMap TupleConversionMap;
 
 
 /* ----------------
diff --git a/src/backend/commands/copyfrom.c b/src/backend/commands/copyfrom.c
index 0ece40557c8..89eff31dc65 100644
--- a/src/backend/commands/copyfrom.c
+++ b/src/backend/commands/copyfrom.c
@@ -26,6 +26,7 @@
 
 #include "access/heapam.h"
 #include "access/tableam.h"
+#include "access/tupconvert.h"
 #include "access/xact.h"
 #include "catalog/namespace.h"
 #include "commands/copyapi.h"
diff --git a/src/backend/commands/copyto.c b/src/backend/commands/copyto.c
index d6ef7275a64..499ce9ad3db 100644
--- a/src/backend/commands/copyto.c
+++ b/src/backend/commands/copyto.c
@@ -20,6 +20,7 @@
 
 #include "access/table.h"
 #include "access/tableam.h"
+#include "access/tupconvert.h"
 #include "catalog/pg_inherits.h"
 #include "commands/copyapi.h"
 #include "commands/progress.h"
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index cd6d720386f..4738f820b80 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -25,6 +25,7 @@
 #include "access/sysattr.h"
 #include "access/tableam.h"
 #include "access/toast_compression.h"
+#include "access/tupconvert.h"
 #include "access/xact.h"
 #include "access/xlog.h"
 #include "access/xloginsert.h"
diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c
index 98d402c0a3b..8b90ca9a3ab 100644
--- a/src/backend/commands/trigger.c
+++ b/src/backend/commands/trigger.c
@@ -19,6 +19,7 @@
 #include "access/sysattr.h"
 #include "access/table.h"
 #include "access/tableam.h"
+#include "access/tupconvert.h"
 #include "access/xact.h"
 #include "catalog/catalog.h"
 #include "catalog/dependency.h"
diff --git a/src/backend/executor/execExprInterp.c b/src/backend/executor/execExprInterp.c
index c9c30450234..98689649680 100644
--- a/src/backend/executor/execExprInterp.c
+++ b/src/backend/executor/execExprInterp.c
@@ -57,6 +57,7 @@
 #include "postgres.h"
 
 #include "access/heaptoast.h"
+#include "access/tupconvert.h"
 #include "catalog/pg_type.h"
 #include "commands/sequence.h"
 #include "executor/execExpr.h"
diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c
index bfd3ebc601e..00c261f9b49 100644
--- a/src/backend/executor/execMain.c
+++ b/src/backend/executor/execMain.c
@@ -40,6 +40,7 @@
 #include "access/sysattr.h"
 #include "access/table.h"
 #include "access/tableam.h"
+#include "access/tupconvert.h"
 #include "access/xact.h"
 #include "catalog/namespace.h"
 #include "catalog/partition.h"
diff --git a/src/backend/executor/execPartition.c b/src/backend/executor/execPartition.c
index bab294f5e91..d96d4f9947b 100644
--- a/src/backend/executor/execPartition.c
+++ b/src/backend/executor/execPartition.c
@@ -15,6 +15,7 @@
 
 #include "access/table.h"
 #include "access/tableam.h"
+#include "access/tupconvert.h"
 #include "catalog/index.h"
 #include "catalog/partition.h"
 #include "executor/execPartition.h"
diff --git a/src/backend/executor/execUtils.c b/src/backend/executor/execUtils.c
index a7955e476f9..62c6373f9de 100644
--- a/src/backend/executor/execUtils.c
+++ b/src/backend/executor/execUtils.c
@@ -48,6 +48,7 @@
 #include "access/parallel.h"
 #include "access/table.h"
 #include "access/tableam.h"
+#include "access/tupconvert.h"
 #include "executor/executor.h"
 #include "executor/nodeModifyTable.h"
 #include "jit/jit.h"
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index 327c27abff9..4d897ebc059 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -54,6 +54,7 @@
 
 #include "access/htup_details.h"
 #include "access/tableam.h"
+#include "access/tupconvert.h"
 #include "access/xact.h"
 #include "commands/trigger.h"
 #include "executor/execPartition.h"
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index 033858752d9..2beacaa4bd9 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -250,6 +250,7 @@
 #include "access/commit_ts.h"
 #include "access/table.h"
 #include "access/tableam.h"
+#include "access/tupconvert.h"
 #include "access/twophase.h"
 #include "access/xact.h"
 #include "catalog/indexing.h"
diff --git a/src/backend/rewrite/rewriteManip.c b/src/backend/rewrite/rewriteManip.c
index 6fa174412f2..fe89754a73c 100644
--- a/src/backend/rewrite/rewriteManip.c
+++ b/src/backend/rewrite/rewriteManip.c
@@ -13,6 +13,7 @@
  */
 #include "postgres.h"
 
+#include "access/attmap.h"
 #include "catalog/pg_type.h"
 #include "nodes/makefuncs.h"
 #include "nodes/nodeFuncs.h"
diff --git a/src/backend/utils/sort/tuplestore.c b/src/backend/utils/sort/tuplestore.c
index afba82f28a2..273a4c9b02f 100644
--- a/src/backend/utils/sort/tuplestore.c
+++ b/src/backend/utils/sort/tuplestore.c
@@ -63,6 +63,7 @@
 #include "storage/buffile.h"
 #include "utils/memutils.h"
 #include "utils/resowner.h"
+#include "utils/tuplestore.h"
 
 
 /*
diff --git a/src/pl/tcl/pltcl.c b/src/pl/tcl/pltcl.c
index b7318f7261e..44491de669a 100644
--- a/src/pl/tcl/pltcl.c
+++ b/src/pl/tcl/pltcl.c
@@ -36,6 +36,7 @@
 #include "utils/regproc.h"
 #include "utils/rel.h"
 #include "utils/syscache.h"
+#include "utils/tuplestore.h"
 #include "utils/typcache.h"
 
 
-- 
2.53.0.1.gb2826b52eb

>From 500d8884e6e408b7f781e908826639cb8aaf134c Mon Sep 17 00:00:00 2001
From: Andres Freund <[email protected]>
Date: Fri, 13 Mar 2026 10:14:53 -0400
Subject: [PATCH v2 03/17] remove attmap.h from index.h

---
 src/include/catalog/index.h             | 7 ++++++-
 src/backend/catalog/index.c             | 1 +
 src/backend/commands/indexcmds.c        | 1 +
 src/backend/optimizer/plan/initsplan.c  | 1 +
 src/backend/optimizer/prep/preptlist.c  | 1 +
 src/backend/optimizer/util/appendinfo.c | 1 +
 src/backend/parser/parse_utilcmd.c      | 1 +
 7 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/include/catalog/index.h b/src/include/catalog/index.h
index e475e278aa8..36b70689254 100644
--- a/src/include/catalog/index.h
+++ b/src/include/catalog/index.h
@@ -14,11 +14,16 @@
 #ifndef INDEX_H
 #define INDEX_H
 
-#include "access/attmap.h"
 #include "catalog/objectaddress.h"
 #include "nodes/execnodes.h"
 
 
+/*
+ * forward references in this file
+ */
+typedef struct AttrMap AttrMap;
+
+
 #define DEFAULT_INDEX_TYPE	"btree"
 
 /* Action code for index_set_state_flags */
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index 5ee6389d39c..836d76ae474 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -24,6 +24,7 @@
 #include <unistd.h>
 
 #include "access/amapi.h"
+#include "access/attmap.h"
 #include "access/heapam.h"
 #include "access/multixact.h"
 #include "access/relscan.h"
diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c
index 635679cc1f2..cbd76066f74 100644
--- a/src/backend/commands/indexcmds.c
+++ b/src/backend/commands/indexcmds.c
@@ -16,6 +16,7 @@
 #include "postgres.h"
 
 #include "access/amapi.h"
+#include "access/attmap.h"
 #include "access/gist.h"
 #include "access/heapam.h"
 #include "access/htup_details.h"
diff --git a/src/backend/optimizer/plan/initsplan.c b/src/backend/optimizer/plan/initsplan.c
index 9aaf1c4e5ca..c20e7e49780 100644
--- a/src/backend/optimizer/plan/initsplan.c
+++ b/src/backend/optimizer/plan/initsplan.c
@@ -15,6 +15,7 @@
 #include "postgres.h"
 
 #include "access/nbtree.h"
+#include "access/sysattr.h"
 #include "catalog/pg_constraint.h"
 #include "catalog/pg_type.h"
 #include "nodes/makefuncs.h"
diff --git a/src/backend/optimizer/prep/preptlist.c b/src/backend/optimizer/prep/preptlist.c
index bd16d197d4f..1647066a13d 100644
--- a/src/backend/optimizer/prep/preptlist.c
+++ b/src/backend/optimizer/prep/preptlist.c
@@ -36,6 +36,7 @@
 
 #include "postgres.h"
 
+#include "access/sysattr.h"
 #include "access/table.h"
 #include "catalog/pg_type_d.h"
 #include "nodes/makefuncs.h"
diff --git a/src/backend/optimizer/util/appendinfo.c b/src/backend/optimizer/util/appendinfo.c
index eadecd0bb92..778e4662f6e 100644
--- a/src/backend/optimizer/util/appendinfo.c
+++ b/src/backend/optimizer/util/appendinfo.c
@@ -15,6 +15,7 @@
 #include "postgres.h"
 
 #include "access/htup_details.h"
+#include "access/sysattr.h"
 #include "access/table.h"
 #include "foreign/fdwapi.h"
 #include "nodes/makefuncs.h"
diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c
index cc244c49e9e..9a918e14aa7 100644
--- a/src/backend/parser/parse_utilcmd.c
+++ b/src/backend/parser/parse_utilcmd.c
@@ -23,6 +23,7 @@
 #include "postgres.h"
 
 #include "access/amapi.h"
+#include "access/attmap.h"
 #include "access/htup_details.h"
 #include "access/relation.h"
 #include "access/reloptions.h"
-- 
2.53.0.1.gb2826b52eb

>From d3d59c901a269568f9537849b3a138cc019432f9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=81lvaro=20Herrera?= <[email protected]>
Date: Fri, 6 Mar 2026 13:05:35 +0100
Subject: [PATCH v2 04/17] don't include sharedtuplestore.h in execnodes.h

---
 src/include/executor/hashjoin.h                            | 1 +
 src/include/nodes/execnodes.h                              | 1 -
 src/backend/access/transam/xlogprefetcher.c                | 1 +
 src/backend/bootstrap/bootstrap.c                          | 1 +
 src/backend/jit/jit.c                                      | 1 +
 src/backend/postmaster/autovacuum.c                        | 1 +
 src/backend/tcop/postgres.c                                | 1 +
 src/backend/utils/cache/relcache.c                         | 1 +
 src/test/modules/test_custom_stats/test_custom_var_stats.c | 1 +
 9 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/include/executor/hashjoin.h b/src/include/executor/hashjoin.h
index 781ba266a8b..67bcc781119 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/sharedtuplestore.h"
 
 /* ----------------------------------------------------------------
  *				hash-join hash table structures
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 8c03498180f..b0c65172a2c 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -45,7 +45,6 @@
 #include "utils/hsearch.h"
 #include "utils/queryenvironment.h"
 #include "utils/reltrigger.h"
-#include "utils/sharedtuplestore.h"
 #include "utils/snapshot.h"
 #include "utils/sortsupport.h"
 
diff --git a/src/backend/access/transam/xlogprefetcher.c b/src/backend/access/transam/xlogprefetcher.c
index 2c1eb217713..c235eca7c51 100644
--- a/src/backend/access/transam/xlogprefetcher.c
+++ b/src/backend/access/transam/xlogprefetcher.c
@@ -36,6 +36,7 @@
 #include "miscadmin.h"
 #include "port/atomics.h"
 #include "storage/bufmgr.h"
+#include "storage/fd.h"
 #include "storage/shmem.h"
 #include "storage/smgr.h"
 #include "utils/fmgrprotos.h"
diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c
index 17118f2fe76..68a42de0889 100644
--- a/src/backend/bootstrap/bootstrap.c
+++ b/src/backend/bootstrap/bootstrap.c
@@ -35,6 +35,7 @@
 #include "pg_getopt.h"
 #include "postmaster/postmaster.h"
 #include "storage/bufpage.h"
+#include "storage/fd.h"
 #include "storage/ipc.h"
 #include "storage/proc.h"
 #include "utils/builtins.h"
diff --git a/src/backend/jit/jit.c b/src/backend/jit/jit.c
index e92be36932b..fd930bdca3a 100644
--- a/src/backend/jit/jit.c
+++ b/src/backend/jit/jit.c
@@ -26,6 +26,7 @@
 #include "miscadmin.h"
 #include "nodes/execnodes.h"
 #include "portability/instr_time.h"
+#include "storage/fd.h"
 #include "utils/fmgrprotos.h"
 
 /* GUCs */
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c
index 695e187ba11..219673db930 100644
--- a/src/backend/postmaster/autovacuum.c
+++ b/src/backend/postmaster/autovacuum.c
@@ -90,6 +90,7 @@
 #include "storage/aio_subsys.h"
 #include "storage/bufmgr.h"
 #include "storage/ipc.h"
+#include "storage/fd.h"
 #include "storage/latch.h"
 #include "storage/lmgr.h"
 #include "storage/pmsignal.h"
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index d01a09dd0c4..b3563113219 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -63,6 +63,7 @@
 #include "rewrite/rewriteHandler.h"
 #include "storage/bufmgr.h"
 #include "storage/ipc.h"
+#include "storage/fd.h"
 #include "storage/pmsignal.h"
 #include "storage/proc.h"
 #include "storage/procsignal.h"
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index a1c88c6b1b6..a51a017c9a3 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -75,6 +75,7 @@
 #include "pgstat.h"
 #include "rewrite/rewriteDefine.h"
 #include "rewrite/rowsecurity.h"
+#include "storage/fd.h"
 #include "storage/lmgr.h"
 #include "storage/smgr.h"
 #include "utils/array.h"
diff --git a/src/test/modules/test_custom_stats/test_custom_var_stats.c b/src/test/modules/test_custom_stats/test_custom_var_stats.c
index da28afbd929..2ef0e903745 100644
--- a/src/test/modules/test_custom_stats/test_custom_var_stats.c
+++ b/src/test/modules/test_custom_stats/test_custom_var_stats.c
@@ -16,6 +16,7 @@
 #include "common/hashfn.h"
 #include "funcapi.h"
 #include "storage/dsm_registry.h"
+#include "storage/fd.h"
 #include "utils/builtins.h"
 #include "utils/pgstat_internal.h"
 
-- 
2.53.0.1.gb2826b52eb

>From d7d12ecb0976aa67b2997bf16c36bd9d8e2c0c8b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=81lvaro=20Herrera?= <[email protected]>
Date: Fri, 6 Mar 2026 13:18:26 +0100
Subject: [PATCH v2 05/17] don't include tuptable.h in execnodes.h

---
 src/include/nodes/execnodes.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index b0c65172a2c..82bd5dcb683 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -29,10 +29,10 @@
 #ifndef EXECNODES_H
 #define EXECNODES_H
 
+#include "access/htup.h"
 #include "access/skey.h"
 #include "executor/instrument.h"
 #include "executor/instrument_node.h"
-#include "executor/tuptable.h"
 #include "fmgr.h"
 #include "lib/ilist.h"
 #include "lib/pairingheap.h"
@@ -41,6 +41,7 @@
 #include "nodes/plannodes.h"
 #include "nodes/tidbitmap.h"
 #include "partitioning/partdefs.h"
+#include "storage/buf.h"
 #include "storage/condition_variable.h"
 #include "utils/hsearch.h"
 #include "utils/queryenvironment.h"
@@ -58,6 +59,8 @@ typedef struct ExprContext ExprContext;
 typedef struct Tuplesortstate Tuplesortstate;
 typedef struct Tuplestorestate Tuplestorestate;
 typedef struct TupleConversionMap TupleConversionMap;
+typedef struct TupleTableSlot TupleTableSlot;
+typedef struct TupleTableSlotOps TupleTableSlotOps;
 
 
 /* ----------------
-- 
2.53.0.1.gb2826b52eb

>From a6d2a9ddda0f2a6fe0a1bee9f7020ad22959a4ef Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=81lvaro=20Herrera?= <[email protected]>
Date: Fri, 6 Mar 2026 13:33:06 +0100
Subject: [PATCH v2 06/17] don't include tidbitmap.h in execnodes.h

---
 src/include/nodes/execnodes.h        | 3 ++-
 src/backend/executor/nodeBitmapAnd.c | 1 +
 src/backend/executor/nodeBitmapOr.c  | 1 +
 3 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 82bd5dcb683..652cc316067 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -39,10 +39,10 @@
 #include "nodes/miscnodes.h"
 #include "nodes/params.h"
 #include "nodes/plannodes.h"
-#include "nodes/tidbitmap.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"
@@ -56,6 +56,7 @@ typedef struct PlanState PlanState;
 typedef struct ExecRowMark ExecRowMark;
 typedef struct ExprState ExprState;
 typedef struct ExprContext ExprContext;
+typedef struct TIDBitmap TIDBitmap;
 typedef struct Tuplesortstate Tuplesortstate;
 typedef struct Tuplestorestate Tuplestorestate;
 typedef struct TupleConversionMap TupleConversionMap;
diff --git a/src/backend/executor/nodeBitmapAnd.c b/src/backend/executor/nodeBitmapAnd.c
index e6406c8f92b..75cbb4b8e91 100644
--- a/src/backend/executor/nodeBitmapAnd.c
+++ b/src/backend/executor/nodeBitmapAnd.c
@@ -30,6 +30,7 @@
 
 #include "executor/executor.h"
 #include "executor/nodeBitmapAnd.h"
+#include "nodes/tidbitmap.h"
 
 
 /* ----------------------------------------------------------------
diff --git a/src/backend/executor/nodeBitmapOr.c b/src/backend/executor/nodeBitmapOr.c
index dcd7ceb2972..a856f3c8e29 100644
--- a/src/backend/executor/nodeBitmapOr.c
+++ b/src/backend/executor/nodeBitmapOr.c
@@ -30,6 +30,7 @@
 
 #include "executor/executor.h"
 #include "executor/nodeBitmapOr.h"
+#include "nodes/tidbitmap.h"
 #include "miscadmin.h"
 
 
-- 
2.53.0.1.gb2826b52eb

>From c0a8b444c19cd005588c70e56471967e2402aa9b Mon Sep 17 00:00:00 2001
From: Andres Freund <[email protected]>
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

>From 2a538641d03e99aa6c9019d5c2d438cba2cc9891 Mon Sep 17 00:00:00 2001
From: Andres Freund <[email protected]>
Date: Fri, 13 Mar 2026 10:39:39 -0400
Subject: [PATCH v2 08/17] don't include hsearch.h in execnodes.h

---
 src/include/nodes/execnodes.h         | 2 +-
 src/backend/commands/prepare.c        | 1 +
 src/backend/optimizer/util/predtest.c | 1 +
 src/backend/utils/adt/json.c          | 1 +
 src/backend/utils/fmgr/fmgr.c         | 1 +
 src/backend/utils/mmgr/portalmem.c    | 1 +
 6 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index e58a005c33d..365fa24ea56 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -41,7 +41,6 @@
 #include "nodes/plannodes.h"
 #include "partitioning/partdefs.h"
 #include "storage/buf.h"
-#include "utils/hsearch.h"
 #include "utils/queryenvironment.h"
 #include "utils/reltrigger.h"
 #include "utils/snapshot.h"
@@ -54,6 +53,7 @@ typedef struct PlanState PlanState;
 typedef struct ExecRowMark ExecRowMark;
 typedef struct ExprState ExprState;
 typedef struct ExprContext ExprContext;
+typedef struct HTAB HTAB;
 typedef struct TIDBitmap TIDBitmap;
 typedef struct Tuplesortstate Tuplesortstate;
 typedef struct Tuplestorestate Tuplestorestate;
diff --git a/src/backend/commands/prepare.c b/src/backend/commands/prepare.c
index ac0c40612b2..876aad2100a 100644
--- a/src/backend/commands/prepare.c
+++ b/src/backend/commands/prepare.c
@@ -34,6 +34,7 @@
 #include "tcop/pquery.h"
 #include "tcop/utility.h"
 #include "utils/builtins.h"
+#include "utils/hsearch.h"
 #include "utils/snapmgr.h"
 #include "utils/timestamp.h"
 #include "utils/tuplestore.h"
diff --git a/src/backend/optimizer/util/predtest.c b/src/backend/optimizer/util/predtest.c
index fe15881af4e..690a23d619a 100644
--- a/src/backend/optimizer/util/predtest.c
+++ b/src/backend/optimizer/util/predtest.c
@@ -25,6 +25,7 @@
 #include "nodes/pathnodes.h"
 #include "optimizer/optimizer.h"
 #include "utils/array.h"
+#include "utils/hsearch.h"
 #include "utils/inval.h"
 #include "utils/lsyscache.h"
 #include "utils/syscache.h"
diff --git a/src/backend/utils/adt/json.c b/src/backend/utils/adt/json.c
index 0b161398465..ab38ddb9079 100644
--- a/src/backend/utils/adt/json.c
+++ b/src/backend/utils/adt/json.c
@@ -26,6 +26,7 @@
 #include "utils/date.h"
 #include "utils/datetime.h"
 #include "utils/fmgroids.h"
+#include "utils/hsearch.h"
 #include "utils/json.h"
 #include "utils/jsonfuncs.h"
 #include "utils/lsyscache.h"
diff --git a/src/backend/utils/fmgr/fmgr.c b/src/backend/utils/fmgr/fmgr.c
index 4e26df7c63a..bfeceb7a92f 100644
--- a/src/backend/utils/fmgr/fmgr.c
+++ b/src/backend/utils/fmgr/fmgr.c
@@ -31,6 +31,7 @@
 #include "utils/builtins.h"
 #include "utils/fmgrtab.h"
 #include "utils/guc.h"
+#include "utils/hsearch.h"
 #include "utils/lsyscache.h"
 #include "utils/syscache.h"
 
diff --git a/src/backend/utils/mmgr/portalmem.c b/src/backend/utils/mmgr/portalmem.c
index 79c8db2c60f..493f9b0ee19 100644
--- a/src/backend/utils/mmgr/portalmem.c
+++ b/src/backend/utils/mmgr/portalmem.c
@@ -24,6 +24,7 @@
 #include "miscadmin.h"
 #include "storage/ipc.h"
 #include "utils/builtins.h"
+#include "utils/hsearch.h"
 #include "utils/memutils.h"
 #include "utils/snapmgr.h"
 #include "utils/timestamp.h"
-- 
2.53.0.1.gb2826b52eb

>From 835ca580da8b923c37a55c722c74c789f8151827 Mon Sep 17 00:00:00 2001
From: Andres Freund <[email protected]>
Date: Fri, 13 Mar 2026 10:45:59 -0400
Subject: [PATCH v2 09/17] don't include skey.h in execnodes.h

---
 src/include/nodes/execnodes.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 365fa24ea56..e63a8fbec09 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -30,7 +30,6 @@
 #define EXECNODES_H
 
 #include "access/htup.h"
-#include "access/skey.h"
 #include "executor/instrument.h"
 #include "executor/instrument_node.h"
 #include "fmgr.h"
@@ -54,6 +53,7 @@ typedef struct ExecRowMark ExecRowMark;
 typedef struct ExprState ExprState;
 typedef struct ExprContext ExprContext;
 typedef struct HTAB HTAB;
+typedef struct ScanKeyData ScanKeyData;
 typedef struct TIDBitmap TIDBitmap;
 typedef struct Tuplesortstate Tuplesortstate;
 typedef struct Tuplestorestate Tuplestorestate;
-- 
2.53.0.1.gb2826b52eb

>From 51b14f679e31f0471f844cf887c55c8b35607ab9 Mon Sep 17 00:00:00 2001
From: Andres Freund <[email protected]>
Date: Fri, 13 Mar 2026 10:47:46 -0400
Subject: [PATCH v2 10/17] don't include queryenvironment.h in execnodes.h

---
 src/include/nodes/execnodes.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index e63a8fbec09..fef8a3f843f 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -40,7 +40,6 @@
 #include "nodes/plannodes.h"
 #include "partitioning/partdefs.h"
 #include "storage/buf.h"
-#include "utils/queryenvironment.h"
 #include "utils/reltrigger.h"
 #include "utils/snapshot.h"
 #include "utils/sortsupport.h"
@@ -53,6 +52,7 @@ typedef struct ExecRowMark ExecRowMark;
 typedef struct ExprState ExprState;
 typedef struct ExprContext ExprContext;
 typedef struct HTAB HTAB;
+typedef struct QueryEnvironment QueryEnvironment;
 typedef struct ScanKeyData ScanKeyData;
 typedef struct TIDBitmap TIDBitmap;
 typedef struct Tuplesortstate Tuplesortstate;
-- 
2.53.0.1.gb2826b52eb

>From 9d0e312e4dfa54807ebdb2bd368400f3456d047f Mon Sep 17 00:00:00 2001
From: Andres Freund <[email protected]>
Date: Fri, 13 Mar 2026 11:07:07 -0400
Subject: [PATCH v2 11/17] don't include sortsupport.h in execnodes.h

---
 src/include/bootstrap/bootstrap.h      | 1 +
 src/include/nodes/execnodes.h          | 5 ++++-
 src/backend/executor/nodeGatherMerge.c | 1 +
 src/backend/executor/nodeIndexscan.c   | 1 +
 src/backend/executor/nodeMergeAppend.c | 1 +
 src/backend/executor/nodeMergejoin.c   | 1 +
 src/backend/executor/nodeSetOp.c       | 1 +
 7 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/include/bootstrap/bootstrap.h b/src/include/bootstrap/bootstrap.h
index e967b2b1885..c0bba03a5ee 100644
--- a/src/include/bootstrap/bootstrap.h
+++ b/src/include/bootstrap/bootstrap.h
@@ -14,6 +14,7 @@
 #ifndef BOOTSTRAP_H
 #define BOOTSTRAP_H
 
+#include "catalog/pg_attribute.h"
 #include "nodes/execnodes.h"
 #include "nodes/parsenodes.h"
 
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index fef8a3f843f..355f72ea306 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -42,7 +42,6 @@
 #include "storage/buf.h"
 #include "utils/reltrigger.h"
 #include "utils/snapshot.h"
-#include "utils/sortsupport.h"
 
 /*
  * forward references in this file
@@ -53,11 +52,15 @@ typedef struct ExprState ExprState;
 typedef struct ExprContext ExprContext;
 typedef struct HTAB HTAB;
 typedef struct QueryEnvironment QueryEnvironment;
+typedef struct RelationData *Relation;
+typedef Relation *RelationPtr;
 typedef struct ScanKeyData ScanKeyData;
+typedef struct SortSupportData *SortSupport;
 typedef struct TIDBitmap TIDBitmap;
 typedef struct Tuplesortstate Tuplesortstate;
 typedef struct Tuplestorestate Tuplestorestate;
 typedef struct TupleConversionMap TupleConversionMap;
+typedef struct TupleDescData *TupleDesc;
 typedef struct TupleTableSlot TupleTableSlot;
 typedef struct TupleTableSlotOps TupleTableSlotOps;
 
diff --git a/src/backend/executor/nodeGatherMerge.c b/src/backend/executor/nodeGatherMerge.c
index ae212194182..c2ac5e0792c 100644
--- a/src/backend/executor/nodeGatherMerge.c
+++ b/src/backend/executor/nodeGatherMerge.c
@@ -22,6 +22,7 @@
 #include "lib/binaryheap.h"
 #include "miscadmin.h"
 #include "optimizer/optimizer.h"
+#include "utils/sortsupport.h"
 
 /*
  * When we read tuples from workers, it's a good idea to read several at once
diff --git a/src/backend/executor/nodeIndexscan.c b/src/backend/executor/nodeIndexscan.c
index a616abff04c..ff1c6d50626 100644
--- a/src/backend/executor/nodeIndexscan.c
+++ b/src/backend/executor/nodeIndexscan.c
@@ -42,6 +42,7 @@
 #include "utils/datum.h"
 #include "utils/lsyscache.h"
 #include "utils/rel.h"
+#include "utils/sortsupport.h"
 
 /*
  * When an ordering operator is used, tuples fetched from the index that
diff --git a/src/backend/executor/nodeMergeAppend.c b/src/backend/executor/nodeMergeAppend.c
index 30bfeaf7c13..72eebd50bdf 100644
--- a/src/backend/executor/nodeMergeAppend.c
+++ b/src/backend/executor/nodeMergeAppend.c
@@ -43,6 +43,7 @@
 #include "executor/nodeMergeAppend.h"
 #include "lib/binaryheap.h"
 #include "miscadmin.h"
+#include "utils/sortsupport.h"
 
 /*
  * We have one slot for each item in the heap array.  We use SlotNumber
diff --git a/src/backend/executor/nodeMergejoin.c b/src/backend/executor/nodeMergejoin.c
index cbcae4c70b8..24061698282 100644
--- a/src/backend/executor/nodeMergejoin.c
+++ b/src/backend/executor/nodeMergejoin.c
@@ -97,6 +97,7 @@
 #include "executor/nodeMergejoin.h"
 #include "miscadmin.h"
 #include "utils/lsyscache.h"
+#include "utils/sortsupport.h"
 
 
 /*
diff --git a/src/backend/executor/nodeSetOp.c b/src/backend/executor/nodeSetOp.c
index 24cd713b12c..24709778384 100644
--- a/src/backend/executor/nodeSetOp.c
+++ b/src/backend/executor/nodeSetOp.c
@@ -50,6 +50,7 @@
 #include "executor/nodeSetOp.h"
 #include "miscadmin.h"
 #include "utils/memutils.h"
+#include "utils/sortsupport.h"
 
 
 /*
-- 
2.53.0.1.gb2826b52eb

>From edaae0f83035c4ed3063e8ec155b3f1a54f755d5 Mon Sep 17 00:00:00 2001
From: Andres Freund <[email protected]>
Date: Fri, 13 Mar 2026 11:19:02 -0400
Subject: [PATCH v2 12/17] don't include snapshot.h in execnodes.h

---
 src/include/nodes/execnodes.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 355f72ea306..83c3c797446 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -41,7 +41,6 @@
 #include "partitioning/partdefs.h"
 #include "storage/buf.h"
 #include "utils/reltrigger.h"
-#include "utils/snapshot.h"
 
 /*
  * forward references in this file
@@ -55,6 +54,7 @@ typedef struct QueryEnvironment QueryEnvironment;
 typedef struct RelationData *Relation;
 typedef Relation *RelationPtr;
 typedef struct ScanKeyData ScanKeyData;
+typedef struct SnapshotData *Snapshot;
 typedef struct SortSupportData *SortSupport;
 typedef struct TIDBitmap TIDBitmap;
 typedef struct Tuplesortstate Tuplesortstate;
-- 
2.53.0.1.gb2826b52eb

>From 92dceb46ecdd923a10ee25c589483178c4725bab Mon Sep 17 00:00:00 2001
From: Andres Freund <[email protected]>
Date: Fri, 13 Mar 2026 11:19:34 -0400
Subject: [PATCH v2 13/17] don't include pairingheap.h in execnodes.h

---
 src/include/nodes/execnodes.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 83c3c797446..3dc616c1aeb 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -34,7 +34,6 @@
 #include "executor/instrument_node.h"
 #include "fmgr.h"
 #include "lib/ilist.h"
-#include "lib/pairingheap.h"
 #include "nodes/miscnodes.h"
 #include "nodes/params.h"
 #include "nodes/plannodes.h"
@@ -50,6 +49,7 @@ typedef struct ExecRowMark ExecRowMark;
 typedef struct ExprState ExprState;
 typedef struct ExprContext ExprContext;
 typedef struct HTAB HTAB;
+typedef struct pairingheap pairingheap;
 typedef struct QueryEnvironment QueryEnvironment;
 typedef struct RelationData *Relation;
 typedef Relation *RelationPtr;
-- 
2.53.0.1.gb2826b52eb

>From 73ed675152df45b145f051b86fb650e07527665b Mon Sep 17 00:00:00 2001
From: Andres Freund <[email protected]>
Date: Fri, 13 Mar 2026 10:53:05 -0400
Subject: [PATCH v2 14/17] don't include pg_bitutils.h in simplehash.h when
 just declaring

This is mainly interesting to get an indirect include of pg_bitutils.h out of
execnodes.h. Which in turn is interesting because on windows it includes
intrin.h, which is fairly large.
---
 src/include/commands/explain_state.h     | 1 +
 src/include/lib/simplehash.h             | 3 ++-
 src/backend/executor/execUtils.c         | 1 +
 src/backend/executor/nodeAgg.c           | 1 +
 src/backend/optimizer/prep/prepunion.c   | 1 +
 src/backend/replication/logical/worker.c | 1 +
 src/backend/utils/adt/acl.c              | 1 +
 src/backend/utils/adt/rangetypes.c       | 1 +
 src/backend/utils/init/postinit.c        | 1 +
 contrib/pg_walinspect/pg_walinspect.c    | 1 +
 10 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/include/commands/explain_state.h b/src/include/commands/explain_state.h
index 0b695f7d812..5a48bc6fbb1 100644
--- a/src/include/commands/explain_state.h
+++ b/src/include/commands/explain_state.h
@@ -16,6 +16,7 @@
 #include "nodes/parsenodes.h"
 #include "nodes/plannodes.h"
 #include "parser/parse_node.h"
+#include "port/pg_bitutils.h"
 
 typedef enum ExplainSerializeOption
 {
diff --git a/src/include/lib/simplehash.h b/src/include/lib/simplehash.h
index 848719232a4..15af488abfb 100644
--- a/src/include/lib/simplehash.h
+++ b/src/include/lib/simplehash.h
@@ -93,7 +93,6 @@
  * src/include/lib/simplehash.h
  */
 
-#include "port/pg_bitutils.h"
 
 /* helpers */
 #define SH_MAKE_PREFIX(a) CppConcat(a,_)
@@ -255,6 +254,8 @@ SH_SCOPE void SH_STAT(SH_TYPE * tb);
 /* generate implementation of the hash table */
 #ifdef SH_DEFINE
 
+#include "port/pg_bitutils.h"
+
 #ifndef SH_RAW_ALLOCATOR
 #include "utils/memutils.h"
 #endif
diff --git a/src/backend/executor/execUtils.c b/src/backend/executor/execUtils.c
index 62c6373f9de..01cfe010209 100644
--- a/src/backend/executor/execUtils.c
+++ b/src/backend/executor/execUtils.c
@@ -56,6 +56,7 @@
 #include "miscadmin.h"
 #include "parser/parse_relation.h"
 #include "partitioning/partdesc.h"
+#include "port/pg_bitutils.h"
 #include "storage/lmgr.h"
 #include "utils/builtins.h"
 #include "utils/memutils.h"
diff --git a/src/backend/executor/nodeAgg.c b/src/backend/executor/nodeAgg.c
index 7d487a165fa..8666780c369 100644
--- a/src/backend/executor/nodeAgg.c
+++ b/src/backend/executor/nodeAgg.c
@@ -264,6 +264,7 @@
 #include "optimizer/optimizer.h"
 #include "parser/parse_agg.h"
 #include "parser/parse_coerce.h"
+#include "port/pg_bitutils.h"
 #include "utils/acl.h"
 #include "utils/builtins.h"
 #include "utils/datum.h"
diff --git a/src/backend/optimizer/prep/prepunion.c b/src/backend/optimizer/prep/prepunion.c
index f50c296e3d9..583cb0b7a25 100644
--- a/src/backend/optimizer/prep/prepunion.c
+++ b/src/backend/optimizer/prep/prepunion.c
@@ -37,6 +37,7 @@
 #include "optimizer/prep.h"
 #include "optimizer/tlist.h"
 #include "parser/parse_coerce.h"
+#include "port/pg_bitutils.h"
 #include "utils/selfuncs.h"
 
 
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index 2beacaa4bd9..2d7708805a6 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -267,6 +267,7 @@
 #include "optimizer/optimizer.h"
 #include "parser/parse_relation.h"
 #include "pgstat.h"
+#include "port/pg_bitutils.h"
 #include "postmaster/bgworker.h"
 #include "postmaster/interrupt.h"
 #include "postmaster/walwriter.h"
diff --git a/src/backend/utils/adt/acl.c b/src/backend/utils/adt/acl.c
index 071e3f2c49e..722e424b9bb 100644
--- a/src/backend/utils/adt/acl.c
+++ b/src/backend/utils/adt/acl.c
@@ -40,6 +40,7 @@
 #include "lib/bloomfilter.h"
 #include "lib/qunique.h"
 #include "miscadmin.h"
+#include "port/pg_bitutils.h"
 #include "storage/large_object.h"
 #include "utils/acl.h"
 #include "utils/array.h"
diff --git a/src/backend/utils/adt/rangetypes.c b/src/backend/utils/adt/rangetypes.c
index 809c0cb44a3..92dacd73dec 100644
--- a/src/backend/utils/adt/rangetypes.c
+++ b/src/backend/utils/adt/rangetypes.c
@@ -41,6 +41,7 @@
 #include "optimizer/clauses.h"
 #include "optimizer/cost.h"
 #include "optimizer/optimizer.h"
+#include "port/pg_bitutils.h"
 #include "utils/builtins.h"
 #include "utils/date.h"
 #include "utils/lsyscache.h"
diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c
index b59e08605cc..26118661f07 100644
--- a/src/backend/utils/init/postinit.c
+++ b/src/backend/utils/init/postinit.c
@@ -38,6 +38,7 @@
 #include "mb/pg_wchar.h"
 #include "miscadmin.h"
 #include "pgstat.h"
+#include "port/pg_bitutils.h"
 #include "postmaster/autovacuum.h"
 #include "postmaster/postmaster.h"
 #include "replication/slot.h"
diff --git a/contrib/pg_walinspect/pg_walinspect.c b/contrib/pg_walinspect/pg_walinspect.c
index 0b830b2d567..f6f5f0792d2 100644
--- a/contrib/pg_walinspect/pg_walinspect.c
+++ b/contrib/pg_walinspect/pg_walinspect.c
@@ -21,6 +21,7 @@
 #include "access/xlogutils.h"
 #include "funcapi.h"
 #include "miscadmin.h"
+#include "port/pg_bitutils.h"
 #include "utils/array.h"
 #include "utils/builtins.h"
 #include "utils/pg_lsn.h"
-- 
2.53.0.1.gb2826b52eb

>From 26ca8f186afad71677684a72bceb757c34eeab6c Mon Sep 17 00:00:00 2001
From: Andres Freund <[email protected]>
Date: Fri, 13 Mar 2026 11:12:45 -0400
Subject: [PATCH v2 15/17] don't include relpath.h in plannodes.h

This is nice because it avoids the indirect include of catversion.h, which in
turn is often the trigger for rebuilding large portions of the tree.
---
 src/include/nodes/plannodes.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/include/nodes/plannodes.h b/src/include/nodes/plannodes.h
index 8c9321aab8c..2d4e4632d73 100644
--- a/src/include/nodes/plannodes.h
+++ b/src/include/nodes/plannodes.h
@@ -16,7 +16,6 @@
 
 #include "access/sdir.h"
 #include "access/stratnum.h"
-#include "common/relpath.h"
 #include "lib/stringinfo.h"
 #include "nodes/bitmapset.h"
 #include "nodes/lockoptions.h"
-- 
2.53.0.1.gb2826b52eb

>From c5a7e0bce45d056f9382b8f1a243fcdceb8ed22f Mon Sep 17 00:00:00 2001
From: Andres Freund <[email protected]>
Date: Fri, 13 Mar 2026 11:15:24 -0400
Subject: [PATCH v2 16/17] don't include stringinfo.h in plannodes.h

Hasn't been required since a05dc4d7fd5. Seems nice to include less lib/ stuff
in nodes/, even if it isn't a huge dependency.
---
 src/include/nodes/plannodes.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/include/nodes/plannodes.h b/src/include/nodes/plannodes.h
index 2d4e4632d73..b6185825fcb 100644
--- a/src/include/nodes/plannodes.h
+++ b/src/include/nodes/plannodes.h
@@ -16,7 +16,6 @@
 
 #include "access/sdir.h"
 #include "access/stratnum.h"
-#include "lib/stringinfo.h"
 #include "nodes/bitmapset.h"
 #include "nodes/lockoptions.h"
 #include "nodes/primnodes.h"
-- 
2.53.0.1.gb2826b52eb

>From 9c227d8bffcde6c3c402ebe020f698e41c0fcd9f Mon Sep 17 00:00:00 2001
From: Andres Freund <[email protected]>
Date: Fri, 13 Mar 2026 11:44:04 -0400
Subject: [PATCH v2 17/17] don't include bitmapset.h in most nodes/*nodes.h
 headers

Not entirely sure this is worth it and, if so, whether we should rely on the
forward declaration in nodes.h.
---
 src/include/nodes/execnodes.h  | 1 +
 src/include/nodes/parsenodes.h | 6 +++++-
 src/include/nodes/plannodes.h  | 6 +++++-
 src/include/nodes/primnodes.h  | 6 +++++-
 4 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 3dc616c1aeb..aadab6ab687 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -45,6 +45,7 @@
  * forward references in this file
  */
 typedef struct PlanState PlanState;
+typedef struct Bitmapset Bitmapset;
 typedef struct ExecRowMark ExecRowMark;
 typedef struct ExprState ExprState;
 typedef struct ExprContext ExprContext;
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index f3d32ef0188..50345cf8715 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -23,12 +23,16 @@
 #define PARSENODES_H
 
 #include "common/relpath.h"
-#include "nodes/bitmapset.h"
 #include "nodes/lockoptions.h"
 #include "nodes/primnodes.h"
 #include "nodes/value.h"
 #include "partitioning/partdefs.h"
 
+/*
+ * forward references in this file
+ */
+typedef struct Bitmapset Bitmapset;
+
 
 /* Possible sources of a Query */
 typedef enum QuerySource
diff --git a/src/include/nodes/plannodes.h b/src/include/nodes/plannodes.h
index b6185825fcb..905d1a5e3df 100644
--- a/src/include/nodes/plannodes.h
+++ b/src/include/nodes/plannodes.h
@@ -16,10 +16,14 @@
 
 #include "access/sdir.h"
 #include "access/stratnum.h"
-#include "nodes/bitmapset.h"
 #include "nodes/lockoptions.h"
 #include "nodes/primnodes.h"
 
+/*
+ * forward references in this file
+ */
+typedef struct Bitmapset Bitmapset;
+
 
 /* ----------------------------------------------------------------
  *						node definitions
diff --git a/src/include/nodes/primnodes.h b/src/include/nodes/primnodes.h
index 384df50c80a..26c2518a242 100644
--- a/src/include/nodes/primnodes.h
+++ b/src/include/nodes/primnodes.h
@@ -19,10 +19,14 @@
 
 #include "access/attnum.h"
 #include "access/cmptype.h"
-#include "nodes/bitmapset.h"
 #include "nodes/lockoptions.h"
 #include "nodes/pg_list.h"
 
+/*
+ * forward references in this file
+ */
+typedef struct Bitmapset Bitmapset;
+
 
 typedef enum OverridingKind
 {
-- 
2.53.0.1.gb2826b52eb

Reply via email to