Hello,

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).


-- 
Álvaro Herrera         PostgreSQL Developer  —  https://www.EnterpriseDB.com/
"You don't solve a bad join with SELECT DISTINCT" #CupsOfFail
https://twitter.com/connor_mc_d/status/1431240081726115845
>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

---
 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/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/include/executor/executor.h                      | 1 +
 src/include/nodes/execnodes.h                        | 4 ++--
 src/pl/plperl/plperl.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/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/backend/access/gin/gininsert.c b/src/backend/access/gin/gininsert.c
index c7e38dbe193..8f7966cc8f7 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/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/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/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.47.3

>From 1d759cbfdb86e1a07f2a9dfe40c7e2851f5bc37e 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 2/6] remove tupconvert.h from execnodes.h

---
 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/include/catalog/index.h              | 1 +
 src/include/nodes/execnodes.h            | 3 ++-
 src/pl/tcl/pltcl.c                       | 1 +
 15 files changed, 16 insertions(+), 1 deletion(-)

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/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/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.47.3

>From 435d66c3abff11c3e59373d782c91ff76c38eea9 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 3/6] don't include sharedtuplestore.h in execnodes.h

---
 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/include/executor/hashjoin.h                            | 1 +
 src/include/nodes/execnodes.h                              | 1 -
 src/test/modules/test_custom_stats/test_custom_var_stats.c | 1 +
 9 files changed, 8 insertions(+), 1 deletion(-)

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/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/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.47.3

>From 264560b908cea9c974d3d13f76c0059b89c634aa 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 4/6] don't include tuptable.h in execnodes.h

---
 src/backend/optimizer/plan/initsplan.c  | 1 +
 src/backend/optimizer/prep/preptlist.c  | 1 +
 src/backend/optimizer/util/appendinfo.c | 1 +
 src/include/nodes/execnodes.h           | 5 ++++-
 4 files changed, 7 insertions(+), 1 deletion(-)

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/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.47.3

>From 10b51486b9b036ce1bcbe45c32801c847755c446 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 5/6] don't include tidbitmap.h in execnodes.h

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

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"
 
 
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

Reply via email to