]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Don't include storage/lock.h in so many headers
authorÁlvaro Herrera <alvherre@kurilemu.de>
Tue, 24 Mar 2026 16:11:12 +0000 (17:11 +0100)
committerÁlvaro Herrera <alvherre@kurilemu.de>
Tue, 24 Mar 2026 16:11:12 +0000 (17:11 +0100)
Since storage/locktags.h was added by commit 322bab79744d, many headers
can be made leaner by depending on that instead of on storage/lock.h,
which has many other dependencies.

(In fact, some of these changes were possible even before that.)

Author: Álvaro Herrera <alvherre@kurilemu.de>
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Discussion: https://postgr.es/m/abvrRZo52Yx9ZzWQ@ip-10-97-1-34.eu-west-3.compute.internal

34 files changed:
contrib/amcheck/verify_heapam.c
src/backend/access/common/relation.c
src/backend/access/common/reloptions.c
src/backend/access/heap/heapam_handler.c
src/backend/access/index/indexam.c
src/backend/access/nbtree/nbtree.c
src/backend/access/nbtree/nbtutils.c
src/backend/catalog/pg_inherits.c
src/backend/catalog/pg_subscription.c
src/backend/commands/conversioncmds.c
src/backend/commands/discard.c
src/backend/commands/tablespace.c
src/backend/optimizer/util/inherit.c
src/backend/parser/parse_oper.c
src/backend/replication/logical/sequencesync.c
src/backend/utils/activity/wait_event.c
src/backend/utils/cache/relcache.c
src/backend/utils/cache/syscache.c
src/backend/utils/cache/ts_cache.c
src/include/access/reloptions.h
src/include/access/twophase.h
src/include/catalog/namespace.h
src/include/catalog/pg_inherits.h
src/include/catalog/toasting.h
src/include/commands/cluster.h
src/include/commands/tablecmds.h
src/include/commands/vacuum.h
src/include/replication/worker_internal.h
src/include/storage/lmgr.h
src/include/storage/lock.h
src/include/storage/predicate.h
src/include/storage/procarray.h
src/include/storage/sinvaladt.h
src/include/storage/standby.h

index ada782f98f5c13047fa94fd8b8d82d83b692b6b0..20ff58aa782596c0763f332149dad7d45eb3a5cc 100644 (file)
@@ -24,6 +24,7 @@
 #include "funcapi.h"
 #include "miscadmin.h"
 #include "storage/bufmgr.h"
+#include "storage/lwlock.h"
 #include "storage/procarray.h"
 #include "storage/read_stream.h"
 #include "utils/builtins.h"
index 92a6e37d8bdabcbdba467042d713db5a812a4d52..38b356b8239b3ada828d98e3a4fad5db6d4ffccc 100644 (file)
@@ -25,6 +25,7 @@
 #include "catalog/namespace.h"
 #include "pgstat.h"
 #include "storage/lmgr.h"
+#include "storage/lock.h"
 #include "utils/inval.h"
 #include "utils/syscache.h"
 
index 237ab8d0ed9ea38b427a1784638ae954785df7fa..a6002ae9b07241631cf26f09967e505b0b3192c7 100644 (file)
@@ -28,6 +28,7 @@
 #include "commands/defrem.h"
 #include "commands/tablespace.h"
 #include "nodes/makefuncs.h"
+#include "storage/lock.h"
 #include "utils/array.h"
 #include "utils/attoptcache.h"
 #include "utils/builtins.h"
index 253a735b6c1089f5952492c9e5868d62eb94c3b0..d40878928e18cc57b4665fa5d72c90a51964e7bc 100644 (file)
@@ -40,6 +40,7 @@
 #include "storage/bufmgr.h"
 #include "storage/bufpage.h"
 #include "storage/lmgr.h"
+#include "storage/lock.h"
 #include "storage/predicate.h"
 #include "storage/procarray.h"
 #include "storage/smgr.h"
index 5eb7e99ad3ee73be67397403c3809636cf8ff60e..fbfc33159eb5bc387f42baf8124b320119776800 100644 (file)
@@ -53,6 +53,7 @@
 #include "nodes/execnodes.h"
 #include "pgstat.h"
 #include "storage/lmgr.h"
+#include "storage/lock.h"
 #include "storage/predicate.h"
 #include "utils/ruleutils.h"
 #include "utils/snapmgr.h"
index aed74590cf4d4bd6376aab8f3ffc821ba54b4325..6d870e4ebe7fca1dbc64c98d2275d4b6ffd0f670 100644 (file)
@@ -30,6 +30,7 @@
 #include "storage/indexfsm.h"
 #include "storage/ipc.h"
 #include "storage/lmgr.h"
+#include "storage/lwlock.h"
 #include "storage/read_stream.h"
 #include "utils/datum.h"
 #include "utils/fmgrprotos.h"
index 9b091858997f8e1f6d0eb844ce79913360ec92eb..732bc750c9e0e97a44d39cf380dc8edfe5945c6e 100644 (file)
@@ -24,6 +24,7 @@
 #include "common/int.h"
 #include "lib/qunique.h"
 #include "miscadmin.h"
+#include "storage/lwlock.h"
 #include "utils/datum.h"
 #include "utils/lsyscache.h"
 #include "utils/rel.h"
index cef8063315719feeeb691de3586b5e1607457fd5..4b9802aafccc47bef45fb332326441fc00a25dee 100644 (file)
@@ -28,6 +28,7 @@
 #include "storage/lmgr.h"
 #include "utils/builtins.h"
 #include "utils/fmgroids.h"
+#include "utils/hsearch.h"
 #include "utils/snapmgr.h"
 #include "utils/syscache.h"
 
index 3673d4f0bc183198d8d80c647a8b5e87ac890355..1d140c513d02b4b1d813623f1b4ac9fa2e30cdb6 100644 (file)
@@ -26,6 +26,7 @@
 #include "foreign/foreign.h"
 #include "miscadmin.h"
 #include "storage/lmgr.h"
+#include "storage/lock.h"
 #include "utils/acl.h"
 #include "utils/array.h"
 #include "utils/builtins.h"
index 61aa8bb9fd1f556e971661f5011c5911ddcea40a..5f2022d30720345f256b7be30d892efc4d8f815a 100644 (file)
@@ -19,6 +19,7 @@
 #include "catalog/pg_proc.h"
 #include "catalog/pg_type.h"
 #include "commands/conversioncmds.h"
+#include "fmgr.h"
 #include "mb/pg_wchar.h"
 #include "miscadmin.h"
 #include "parser/parse_func.h"
index 7b5520b9abe8e64fc65c89ae98d1cf44e1c919f5..17d172df07692cbd619cbbc34f2477a3ef49ac84 100644 (file)
@@ -19,6 +19,7 @@
 #include "commands/discard.h"
 #include "commands/prepare.h"
 #include "commands/sequence.h"
+#include "storage/lock.h"
 #include "utils/guc.h"
 #include "utils/portal.h"
 
index ed2a93a09dbefdeec3683954dd9c1261157b6f28..d91fcf0facf8bb67cecf994429dbe2235c2b8fc9 100644 (file)
@@ -70,6 +70,7 @@
 #include "miscadmin.h"
 #include "postmaster/bgwriter.h"
 #include "storage/fd.h"
+#include "storage/lwlock.h"
 #include "storage/procsignal.h"
 #include "storage/standby.h"
 #include "utils/acl.h"
index 8d623bf136d9a1f4bc25fba91c8d16cc8dd81438..6a7b9edff3fcee470e555b59a87a674dbd192b82 100644 (file)
@@ -14,6 +14,8 @@
  */
 #include "postgres.h"
 
+#include <limits.h>
+
 #include "access/sysattr.h"
 #include "access/table.h"
 #include "catalog/partition.h"
index a6b402f2d7b742eebfd30ad3f68603d9a7b9e119..2f218c1ab8b9723e165a1c566d9906b0d5fd2572 100644 (file)
@@ -25,6 +25,7 @@
 #include "parser/parse_oper.h"
 #include "parser/parse_type.h"
 #include "utils/builtins.h"
+#include "utils/hsearch.h"
 #include "utils/inval.h"
 #include "utils/lsyscache.h"
 #include "utils/syscache.h"
index 9c92fddd624e7a25d0e264802db50deadca435c2..a4fb6783ba958b78eab89b4073068808b2110e5a 100644 (file)
@@ -60,6 +60,7 @@
 #include "postmaster/interrupt.h"
 #include "replication/logicalworker.h"
 #include "replication/worker_internal.h"
+#include "storage/lwlock.h"
 #include "utils/acl.h"
 #include "utils/builtins.h"
 #include "utils/fmgroids.h"
index aca2c8fc742aabadbe821bf6b55b1be3c49be40a..e5a2289f0b074f790938199d0f2048b3875f529a 100644 (file)
@@ -22,8 +22,9 @@
  */
 #include "postgres.h"
 
-#include "storage/lmgr.h"              /* for GetLockNameFromTagType */
-#include "storage/lwlock.h"            /* for GetLWLockIdentifier */
+#include "storage/lmgr.h"
+#include "storage/lwlock.h"
+#include "storage/shmem.h"
 #include "storage/spin.h"
 #include "utils/wait_event.h"
 
index 3a4f19e8d58519a511a47e16edc09935d73076c8..e19f0d3e51cf33cb99878ad2a7f8d79458851876 100644 (file)
@@ -77,6 +77,7 @@
 #include "rewrite/rowsecurity.h"
 #include "storage/fd.h"
 #include "storage/lmgr.h"
+#include "storage/lock.h"
 #include "storage/smgr.h"
 #include "utils/array.h"
 #include "utils/builtins.h"
index 007a9a15d71bd78c2f29c2fed85727979ec1970b..f4233f9e31a61a43b5e991a22d31a96820b9dbc8 100644 (file)
@@ -32,6 +32,7 @@
 #include "lib/qunique.h"
 #include "miscadmin.h"
 #include "storage/lmgr.h"
+#include "storage/lock.h"
 #include "utils/catcache.h"
 #include "utils/inval.h"
 #include "utils/lsyscache.h"
index 744c8e71d7159cfea38233abb10031d78eeff101..9e29f1386b0252ffd1c20116697d704b259453ac 100644 (file)
@@ -44,6 +44,7 @@
 #include "utils/catcache.h"
 #include "utils/fmgroids.h"
 #include "utils/guc_hooks.h"
+#include "utils/hsearch.h"
 #include "utils/inval.h"
 #include "utils/lsyscache.h"
 #include "utils/memutils.h"
index 0bd17b30ca71adb4e26bf439d93a9af701fc9286..c228147420a94faec6f77af4c0cc2f747d298364 100644 (file)
@@ -23,7 +23,6 @@
 #include "access/htup.h"
 #include "access/tupdesc.h"
 #include "nodes/pg_list.h"
-#include "storage/lock.h"
 
 /* types supported by reloptions */
 typedef enum relopt_type
index e312514ba87dd2f5947ccb4ff0023b164d024623..761d56a5f3df991af9a358c21a38a839a2dde0a1 100644 (file)
 #include "access/xact.h"
 #include "access/xlogdefs.h"
 #include "datatype/timestamp.h"
-#include "storage/lock.h"
+
+/*
+ * forward references in this file
+ */
+typedef struct PGPROC PGPROC;
+typedef struct VirtualTransactionId VirtualTransactionId;
 
 /*
  * GlobalTransactionData is defined in twophase.c; other places have no
index 1a25973685cdb3333faf1fe9676b83aa6120954a..9453a3e49329742feed1f3e153beaf7284eb6dcf 100644 (file)
@@ -15,7 +15,7 @@
 #define NAMESPACE_H
 
 #include "nodes/primnodes.h"
-#include "storage/lock.h"
+#include "storage/lockdefs.h"
 #include "storage/procnumber.h"
 
 
index 7a36241d7b3596bd8ded7df8b292292c99ac6dfb..cc874abaabb5654b9646bb30dedd7872b37155ff 100644 (file)
@@ -22,7 +22,7 @@
 #include "catalog/pg_inherits_d.h"     /* IWYU pragma: export */
 
 #include "nodes/pg_list.h"
-#include "storage/lock.h"
+#include "storage/lockdefs.h"
 
 /* ----------------
  *             pg_inherits definition.  cpp turns this into
index 7e0a9f8e9bf7fb48932d6c5512624fcf3a60f94f..0bc61a8fee986336cd0919918fed7993c56cc124 100644 (file)
@@ -14,7 +14,7 @@
 #ifndef TOASTING_H
 #define TOASTING_H
 
-#include "storage/lock.h"
+#include "storage/lockdefs.h"
 
 /*
  * toasting.c prototypes
index 28741988478a91028bc6a8888d0603b58e4549ff..c79cd2d0e19e5d511dfbe28e98b734a71b9cf410 100644 (file)
@@ -15,7 +15,7 @@
 
 #include "nodes/parsenodes.h"
 #include "parser/parse_node.h"
-#include "storage/lock.h"
+#include "storage/lockdefs.h"
 #include "utils/relcache.h"
 
 
index ed38b311ddffd883867489bdda8e00f54c9ad8d7..c3d8518cb625419f3a1d5d720707bc2ea9c50a59 100644 (file)
@@ -18,7 +18,7 @@
 #include "catalog/dependency.h"
 #include "catalog/objectaddress.h"
 #include "nodes/parsenodes.h"
-#include "storage/lock.h"
+#include "storage/lockdefs.h"
 #include "utils/relcache.h"
 
 typedef struct AlterTableUtilityContext AlterTableUtilityContext;      /* avoid including
index 953a506181eee4821f5984376037d9a9fa1635d3..1f45bca015cf33185f08bade6ca2aa3fe19a2de4 100644 (file)
@@ -23,7 +23,6 @@
 #include "catalog/pg_type.h"
 #include "parser/parse_node.h"
 #include "storage/buf.h"
-#include "storage/lock.h"
 #include "utils/relcache.h"
 
 /*
index 4ecbdcfadac3d24cd2f9894cf9bb5af5a854b173..745b7d9e9696659d0e0c1de5656ea708edf34b4b 100644 (file)
@@ -20,7 +20,6 @@
 #include "replication/walreceiver.h"
 #include "storage/buffile.h"
 #include "storage/fileset.h"
-#include "storage/lock.h"
 #include "storage/shm_mq.h"
 #include "storage/shm_toc.h"
 #include "storage/spin.h"
index 74a398ffc0002154525ffe83c01881d4b02f3325..2a985ce5e154d5b41afca77557d85bbf83de0384 100644 (file)
@@ -16,7 +16,7 @@
 
 #include "lib/stringinfo.h"
 #include "storage/itemptr.h"
-#include "storage/lock.h"
+#include "storage/locktag.h"
 #include "utils/rel.h"
 
 
index 9505701a805a4a9d8a3a57ba59ad278f9a7312f2..fa68e6ecece4ffc7c7d85c083d584a7644cee66b 100644 (file)
@@ -59,7 +59,7 @@ extern PGDLLIMPORT bool Debug_deadlocks;
  * coding errors from trying to use struct assignment with it; instead use
  * GET_VXID_FROM_PGPROC().
  */
-typedef struct
+typedef struct VirtualTransactionId
 {
        ProcNumber      procNumber;             /* proc number of the PGPROC */
        LocalTransactionId localTransactionId;  /* lxid from PGPROC */
index 607d7d84596c6c4ad5aede1b9e7a5c57128a52ee..a5ac55b8f7e43dc705f14072f29f32288b74abf3 100644 (file)
 #ifndef PREDICATE_H
 #define PREDICATE_H
 
+#include "access/transam.h"
 #include "storage/itemptr.h"
-#include "storage/lock.h"
 #include "utils/relcache.h"
 #include "utils/snapshot.h"
 
+/*
+ * forward references in this file
+ */
+typedef struct VirtualTransactionId VirtualTransactionId;
+
 
 /*
  * GUC variables
index c5ab1574fe39a27e46b88d9d8c73e3ff4e97b7bd..abdf021e66e439f459d0c210595ad5706413e462 100644 (file)
@@ -14,7 +14,6 @@
 #ifndef PROCARRAY_H
 #define PROCARRAY_H
 
-#include "storage/lock.h"
 #include "storage/standby.h"
 #include "utils/relcache.h"
 #include "utils/snapshot.h"
index a1694500a8592a49043557a9a7cd7c9189925928..122dbcdf19f420cbc03e73c270a78c5235bf8af0 100644 (file)
@@ -22,7 +22,6 @@
 #ifndef SINVALADT_H
 #define SINVALADT_H
 
-#include "storage/lock.h"
 #include "storage/sinval.h"
 
 /*
index c63a4f2cc6a6647ff429ff089a1bb64c9a0ff91b..6a314c693cde733c263077230a5b12b260507063 100644 (file)
 #define STANDBY_H
 
 #include "datatype/timestamp.h"
-#include "storage/lock.h"
+#include "storage/locktag.h"
 #include "storage/relfilelocator.h"
 #include "storage/standbydefs.h"
 
+typedef struct PGPROC PGPROC;
+typedef struct VirtualTransactionId VirtualTransactionId;
+
 /* User-settable GUC parameters */
 extern PGDLLIMPORT int max_standby_archive_delay;
 extern PGDLLIMPORT int max_standby_streaming_delay;