From ba3dec8480aae835e458fdc35fff67e13dfb611e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=81lvaro=20Herrera?= <alvherre@kurilemu.de>
Date: Thu, 26 Feb 2026 18:29:49 +0100
Subject: [PATCH] Avoid including proc.h in shm_mq.h

This prevents proliferation of proc.h to tons of other places.
---
 src/backend/access/brin/brin.c                        | 1 +
 src/backend/access/gin/gininsert.c                    | 1 +
 src/backend/access/heap/heapam.c                      | 1 +
 src/backend/access/heap/vacuumlazy.c                  | 1 +
 src/backend/access/nbtree/nbtsort.c                   | 1 +
 src/backend/access/transam/parallel.c                 | 1 +
 src/backend/catalog/namespace.c                       | 1 +
 src/backend/commands/async.c                          | 1 +
 src/backend/commands/vacuumparallel.c                 | 1 +
 src/backend/executor/execParallel.c                   | 1 +
 src/backend/executor/nodeAppend.c                     | 1 +
 src/backend/executor/nodeGather.c                     | 1 +
 src/backend/libpq/pqmq.c                              | 1 +
 src/backend/optimizer/plan/createplan.c               | 1 +
 src/backend/replication/logical/applyparallelworker.c | 2 ++
 src/backend/replication/logical/tablesync.c           | 1 +
 src/backend/replication/logical/worker.c              | 1 +
 src/backend/storage/ipc/procsignal.c                  | 1 +
 src/backend/storage/ipc/shm_mq.c                      | 1 +
 src/backend/utils/activity/backend_progress.c         | 1 +
 src/backend/utils/misc/guc_tables.c                   | 1 +
 src/include/access/parallel.h                         | 2 ++
 src/include/libpq/pqmq.h                              | 1 +
 src/include/storage/shm_mq.h                          | 4 +++-
 src/test/modules/test_shm_mq/setup.c                  | 1 +
 src/test/modules/test_shm_mq/test.c                   | 1 +
 src/test/modules/test_shm_mq/worker.c                 | 2 ++
 27 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/src/backend/access/brin/brin.c b/src/backend/access/brin/brin.c
index 6887e421442..9cd563fd0c3 100644
--- a/src/backend/access/brin/brin.c
+++ b/src/backend/access/brin/brin.c
@@ -33,6 +33,7 @@
 #include "postmaster/autovacuum.h"
 #include "storage/bufmgr.h"
 #include "storage/freespace.h"
+#include "storage/proc.h"
 #include "tcop/tcopprot.h"
 #include "utils/acl.h"
 #include "utils/datum.h"
diff --git a/src/backend/access/gin/gininsert.c b/src/backend/access/gin/gininsert.c
index 0d63fb4ba27..ee9b6106922 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/proc.h"
 #include "storage/predicate.h"
 #include "tcop/tcopprot.h"
 #include "utils/datum.h"
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c
index 98d53caeea8..d534258e547 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -47,6 +47,7 @@
 #include "port/pg_bitutils.h"
 #include "storage/lmgr.h"
 #include "storage/predicate.h"
+#include "storage/proc.h"
 #include "storage/procarray.h"
 #include "utils/datum.h"
 #include "utils/injection_point.h"
diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c
index 4be267ff657..1f11d8c1567 100644
--- a/src/backend/access/heap/vacuumlazy.c
+++ b/src/backend/access/heap/vacuumlazy.c
@@ -149,6 +149,7 @@
 #include "postmaster/autovacuum.h"
 #include "storage/bufmgr.h"
 #include "storage/freespace.h"
+#include "storage/latch.h"
 #include "storage/lmgr.h"
 #include "storage/read_stream.h"
 #include "utils/lsyscache.h"
diff --git a/src/backend/access/nbtree/nbtsort.c b/src/backend/access/nbtree/nbtsort.c
index 3a45508f62e..fd9d4087b5a 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/proc.h"
 #include "tcop/tcopprot.h"
 #include "utils/rel.h"
 #include "utils/sortsupport.h"
diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 44786dc131f..e69c4b74248 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -36,6 +36,7 @@
 #include "pgstat.h"
 #include "storage/ipc.h"
 #include "storage/predicate.h"
+#include "storage/proc.h"
 #include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
diff --git a/src/backend/catalog/namespace.c b/src/backend/catalog/namespace.c
index 4b0f4ba115d..56b87d878e8 100644
--- a/src/backend/catalog/namespace.c
+++ b/src/backend/catalog/namespace.c
@@ -48,6 +48,7 @@
 #include "nodes/makefuncs.h"
 #include "storage/ipc.h"
 #include "storage/lmgr.h"
+#include "storage/proc.h"
 #include "storage/procarray.h"
 #include "utils/acl.h"
 #include "utils/builtins.h"
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index 657c591618d..0b6d119dad0 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -176,6 +176,7 @@
 #include "miscadmin.h"
 #include "storage/dsm_registry.h"
 #include "storage/ipc.h"
+#include "storage/latch.h"
 #include "storage/lmgr.h"
 #include "storage/procsignal.h"
 #include "tcop/tcopprot.h"
diff --git a/src/backend/commands/vacuumparallel.c b/src/backend/commands/vacuumparallel.c
index c3b3c9ea21a..279108ca89f 100644
--- a/src/backend/commands/vacuumparallel.c
+++ b/src/backend/commands/vacuumparallel.c
@@ -35,6 +35,7 @@
 #include "optimizer/paths.h"
 #include "pgstat.h"
 #include "storage/bufmgr.h"
+#include "storage/proc.h"
 #include "tcop/tcopprot.h"
 #include "utils/lsyscache.h"
 #include "utils/rel.h"
diff --git a/src/backend/executor/execParallel.c b/src/backend/executor/execParallel.c
index f87978c137e..ac84af294c9 100644
--- a/src/backend/executor/execParallel.c
+++ b/src/backend/executor/execParallel.c
@@ -45,6 +45,7 @@
 #include "jit/jit.h"
 #include "nodes/nodeFuncs.h"
 #include "pgstat.h"
+#include "storage/proc.h"
 #include "tcop/tcopprot.h"
 #include "utils/datum.h"
 #include "utils/dsa.h"
diff --git a/src/backend/executor/nodeAppend.c b/src/backend/executor/nodeAppend.c
index 7138dc692c6..39d9442c121 100644
--- a/src/backend/executor/nodeAppend.c
+++ b/src/backend/executor/nodeAppend.c
@@ -64,6 +64,7 @@
 #include "miscadmin.h"
 #include "pgstat.h"
 #include "storage/latch.h"
+#include "storage/lwlock.h"
 
 /* Shared state for parallel-aware Append. */
 struct ParallelAppendState
diff --git a/src/backend/executor/nodeGather.c b/src/backend/executor/nodeGather.c
index 4105f1d1968..114693abb32 100644
--- a/src/backend/executor/nodeGather.c
+++ b/src/backend/executor/nodeGather.c
@@ -36,6 +36,7 @@
 #include "executor/tqueue.h"
 #include "miscadmin.h"
 #include "optimizer/optimizer.h"
+#include "storage/latch.h"
 #include "utils/wait_event.h"
 
 
diff --git a/src/backend/libpq/pqmq.c b/src/backend/libpq/pqmq.c
index 6e4bbfb5aa1..7e4a725b796 100644
--- a/src/backend/libpq/pqmq.c
+++ b/src/backend/libpq/pqmq.c
@@ -20,6 +20,7 @@
 #include "miscadmin.h"
 #include "pgstat.h"
 #include "replication/logicalworker.h"
+#include "storage/latch.h"
 #include "tcop/tcopprot.h"
 #include "utils/builtins.h"
 
diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c
index 21f1988cf22..50b0e10308b 100644
--- a/src/backend/optimizer/plan/createplan.c
+++ b/src/backend/optimizer/plan/createplan.c
@@ -17,6 +17,7 @@
 #include "postgres.h"
 
 #include "access/sysattr.h"
+#include "access/transam.h"
 #include "catalog/pg_class.h"
 #include "foreign/fdwapi.h"
 #include "miscadmin.h"
diff --git a/src/backend/replication/logical/applyparallelworker.c b/src/backend/replication/logical/applyparallelworker.c
index 1730ace5490..7cd6e912a9c 100644
--- a/src/backend/replication/logical/applyparallelworker.c
+++ b/src/backend/replication/logical/applyparallelworker.c
@@ -166,7 +166,9 @@
 #include "replication/origin.h"
 #include "replication/worker_internal.h"
 #include "storage/ipc.h"
+#include "storage/latch.h"
 #include "storage/lmgr.h"
+#include "storage/proc.h"
 #include "tcop/tcopprot.h"
 #include "utils/inval.h"
 #include "utils/memutils.h"
diff --git a/src/backend/replication/logical/tablesync.c b/src/backend/replication/logical/tablesync.c
index 2f2f0121ecf..bccbf61bf39 100644
--- a/src/backend/replication/logical/tablesync.c
+++ b/src/backend/replication/logical/tablesync.c
@@ -112,6 +112,7 @@
 #include "replication/walreceiver.h"
 #include "replication/worker_internal.h"
 #include "storage/ipc.h"
+#include "storage/latch.h"
 #include "storage/lmgr.h"
 #include "utils/acl.h"
 #include "utils/array.h"
diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c
index bae8c011390..f9c4b484754 100644
--- a/src/backend/replication/logical/worker.c
+++ b/src/backend/replication/logical/worker.c
@@ -281,6 +281,7 @@
 #include "rewrite/rewriteHandler.h"
 #include "storage/buffile.h"
 #include "storage/ipc.h"
+#include "storage/latch.h"
 #include "storage/lmgr.h"
 #include "storage/procarray.h"
 #include "tcop/tcopprot.h"
diff --git a/src/backend/storage/ipc/procsignal.c b/src/backend/storage/ipc/procsignal.c
index 7505c9d3a37..d47d180a32f 100644
--- a/src/backend/storage/ipc/procsignal.c
+++ b/src/backend/storage/ipc/procsignal.c
@@ -28,6 +28,7 @@
 #include "storage/condition_variable.h"
 #include "storage/ipc.h"
 #include "storage/latch.h"
+#include "storage/proc.h"
 #include "storage/shmem.h"
 #include "storage/sinval.h"
 #include "storage/smgr.h"
diff --git a/src/backend/storage/ipc/shm_mq.c b/src/backend/storage/ipc/shm_mq.c
index 3ce6068ac54..7e9fbc00705 100644
--- a/src/backend/storage/ipc/shm_mq.c
+++ b/src/backend/storage/ipc/shm_mq.c
@@ -22,6 +22,7 @@
 #include "pgstat.h"
 #include "port/pg_bitutils.h"
 #include "postmaster/bgworker.h"
+#include "storage/proc.h"
 #include "storage/shm_mq.h"
 #include "storage/spin.h"
 #include "utils/memutils.h"
diff --git a/src/backend/utils/activity/backend_progress.c b/src/backend/utils/activity/backend_progress.c
index 5addb2d004f..b0359771de5 100644
--- a/src/backend/utils/activity/backend_progress.c
+++ b/src/backend/utils/activity/backend_progress.c
@@ -12,6 +12,7 @@
 
 #include "access/parallel.h"
 #include "libpq/pqformat.h"
+#include "storage/proc.h"
 #include "utils/backend_progress.h"
 #include "utils/backend_status.h"
 
diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c
index 741fce8dede..38aaf82f120 100644
--- a/src/backend/utils/misc/guc_tables.c
+++ b/src/backend/utils/misc/guc_tables.c
@@ -85,6 +85,7 @@
 #include "storage/large_object.h"
 #include "storage/pg_shmem.h"
 #include "storage/predicate.h"
+#include "storage/proc.h"
 #include "storage/procnumber.h"
 #include "storage/standby.h"
 #include "tcop/backend_startup.h"
diff --git a/src/include/access/parallel.h b/src/include/access/parallel.h
index 01bdf2bec1f..60f857675e0 100644
--- a/src/include/access/parallel.h
+++ b/src/include/access/parallel.h
@@ -14,6 +14,8 @@
 #ifndef PARALLEL_H
 #define PARALLEL_H
 
+#include <signal.h>
+
 #include "access/xlogdefs.h"
 #include "lib/ilist.h"
 #include "postmaster/bgworker.h"
diff --git a/src/include/libpq/pqmq.h b/src/include/libpq/pqmq.h
index c62fffb5998..36780c0816e 100644
--- a/src/include/libpq/pqmq.h
+++ b/src/include/libpq/pqmq.h
@@ -14,6 +14,7 @@
 #define PQMQ_H
 
 #include "lib/stringinfo.h"
+#include "storage/procnumber.h"
 #include "storage/shm_mq.h"
 
 extern void pq_redirect_to_shm_mq(dsm_segment *seg, shm_mq_handle *mqh);
diff --git a/src/include/storage/shm_mq.h b/src/include/storage/shm_mq.h
index aa5676f6a12..6f78f4a3acb 100644
--- a/src/include/storage/shm_mq.h
+++ b/src/include/storage/shm_mq.h
@@ -15,7 +15,9 @@
 
 #include "postmaster/bgworker.h"
 #include "storage/dsm.h"
-#include "storage/proc.h"
+
+/* avoid including storage/proc.h */
+typedef struct PGPROC PGPROC;
 
 /* The queue itself, in shared memory. */
 struct shm_mq;
diff --git a/src/test/modules/test_shm_mq/setup.c b/src/test/modules/test_shm_mq/setup.c
index 579e5933d28..36bb255922c 100644
--- a/src/test/modules/test_shm_mq/setup.c
+++ b/src/test/modules/test_shm_mq/setup.c
@@ -18,6 +18,7 @@
 #include "miscadmin.h"
 #include "pgstat.h"
 #include "postmaster/bgworker.h"
+#include "storage/proc.h"
 #include "storage/shm_toc.h"
 #include "test_shm_mq.h"
 #include "utils/memutils.h"
diff --git a/src/test/modules/test_shm_mq/test.c b/src/test/modules/test_shm_mq/test.c
index fe1794c6077..ce97e6e1aa4 100644
--- a/src/test/modules/test_shm_mq/test.c
+++ b/src/test/modules/test_shm_mq/test.c
@@ -16,6 +16,7 @@
 #include "fmgr.h"
 #include "miscadmin.h"
 #include "pgstat.h"
+#include "storage/proc.h"
 #include "varatt.h"
 
 #include "test_shm_mq.h"
diff --git a/src/test/modules/test_shm_mq/worker.c b/src/test/modules/test_shm_mq/worker.c
index 6a4147554bb..e13c05ae5c7 100644
--- a/src/test/modules/test_shm_mq/worker.c
+++ b/src/test/modules/test_shm_mq/worker.c
@@ -21,6 +21,8 @@
 
 #include "miscadmin.h"
 #include "storage/ipc.h"
+#include "storage/latch.h"
+#include "storage/proc.h"
 #include "storage/procarray.h"
 #include "storage/shm_mq.h"
 #include "storage/shm_toc.h"
-- 
2.47.3

