From dbbca2cf299b81299112ca6ada671a36235ec008 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Mon, 4 Mar 2024 12:00:11 +0100 Subject: Remove unused #include's from backend .c files as determined by include-what-you-use (IWYU) While IWYU also suggests to *add* a bunch of #include's (which is its main purpose), this patch does not do that. In some cases, a more specific #include replaces another less specific one. Some manual adjustments of the automatic result: - IWYU currently doesn't know about includes that provide global variable declarations (like -Wmissing-variable-declarations), so those includes are being kept manually. - All includes for port(ability) headers are being kept for now, to play it safe. - No changes of catalog/pg_foo.h to catalog/pg_foo_d.h, to keep the patch from exploding in size. Note that this patch touches just *.c files, so nothing declared in header files changes in hidden ways. As a small example, in src/backend/access/transam/rmgr.c, some IWYU pragma annotations are added to handle a special case there. Discussion: https://www.postgresql.org/message-id/flat/af837490-6b2f-46df-ba05-37ea6a6653fc%40eisentraut.org --- src/backend/access/transam/rmgr.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src/backend/access/transam/rmgr.c') diff --git a/src/backend/access/transam/rmgr.c b/src/backend/access/transam/rmgr.c index 7d67eda5f79..3e2f1d4a237 100644 --- a/src/backend/access/transam/rmgr.c +++ b/src/backend/access/transam/rmgr.c @@ -7,6 +7,18 @@ */ #include "postgres.h" +#include "access/rmgr.h" +#include "access/xlog_internal.h" +#include "fmgr.h" +#include "funcapi.h" +#include "miscadmin.h" +#include "nodes/execnodes.h" +#include "utils/builtins.h" +#include "utils/fmgrprotos.h" +#include "utils/tuplestore.h" + +/* includes needed for "access/rmgrlist.h" */ +/* IWYU pragma: begin_keep */ #include "access/brin_xlog.h" #include "access/clog.h" #include "access/commit_ts.h" @@ -19,20 +31,17 @@ #include "access/nbtxlog.h" #include "access/spgxlog.h" #include "access/xact.h" -#include "access/xlog_internal.h" #include "catalog/storage_xlog.h" #include "commands/dbcommands_xlog.h" #include "commands/sequence.h" #include "commands/tablespace.h" -#include "fmgr.h" -#include "funcapi.h" -#include "miscadmin.h" #include "replication/decode.h" #include "replication/message.h" #include "replication/origin.h" #include "storage/standby.h" -#include "utils/builtins.h" #include "utils/relmapper.h" +/* IWYU pragma: end_keep */ + /* must be kept in sync with RmgrData definition in xlog_internal.h */ #define PG_RMGR(symname,name,redo,desc,identify,startup,cleanup,mask,decode) \ -- cgit v1.2.3