Don't include storage/lock.h in so many headers

Since storage/locktags.h was added by commit 322bab7974, 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
This commit is contained in:
Álvaro Herrera 2026-03-24 17:11:12 +01:00
parent 5f2350a043
commit 2102ebb195
No known key found for this signature in database
GPG key ID: 1C20ACB9D5C564AE
34 changed files with 45 additions and 17 deletions

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

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

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

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

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

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

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

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

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

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

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

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

View file

@ -14,6 +14,8 @@
*/
#include "postgres.h"
#include <limits.h>
#include "access/sysattr.h"
#include "access/table.h"
#include "catalog/partition.h"

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

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

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

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

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

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

View 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

View file

@ -17,7 +17,12 @@
#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

View file

@ -15,7 +15,7 @@
#define NAMESPACE_H
#include "nodes/primnodes.h"
#include "storage/lock.h"
#include "storage/lockdefs.h"
#include "storage/procnumber.h"

View 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

View file

@ -14,7 +14,7 @@
#ifndef TOASTING_H
#define TOASTING_H
#include "storage/lock.h"
#include "storage/lockdefs.h"
/*
* toasting.c prototypes

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

View 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

View 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"
/*

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

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

View 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 */

View file

@ -14,11 +14,16 @@
#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

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

View file

@ -22,7 +22,6 @@
#ifndef SINVALADT_H
#define SINVALADT_H
#include "storage/lock.h"
#include "storage/sinval.h"
/*

View file

@ -15,10 +15,13 @@
#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;