aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands
diff options
context:
space:
mode:
authorPeter Eisentraut <peter@eisentraut.org>2024-03-04 12:00:11 +0100
committerPeter Eisentraut <peter@eisentraut.org>2024-03-04 12:02:20 +0100
commitdbbca2cf299b81299112ca6ada671a36235ec008 (patch)
treeaac5368f0983f682c6a31b6bc6140cd89b50fe3c /src/backend/commands
parent24eebc65c26cfcc0ea5b8a95b61fa2fda6118e68 (diff)
downloadpostgresql-dbbca2cf299b81299112ca6ada671a36235ec008.tar.gz
postgresql-dbbca2cf299b81299112ca6ada671a36235ec008.zip
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
Diffstat (limited to 'src/backend/commands')
-rw-r--r--src/backend/commands/aggregatecmds.c6
-rw-r--r--src/backend/commands/alter.c7
-rw-r--r--src/backend/commands/analyze.c10
-rw-r--r--src/backend/commands/async.c3
-rw-r--r--src/backend/commands/cluster.c3
-rw-r--r--src/backend/commands/collationcmds.c2
-rw-r--r--src/backend/commands/constraint.c4
-rw-r--r--src/backend/commands/conversioncmds.c7
-rw-r--r--src/backend/commands/copy.c2
-rw-r--r--src/backend/commands/copyfrom.c5
-rw-r--r--src/backend/commands/copyfromparse.c1
-rw-r--r--src/backend/commands/copyto.c7
-rw-r--r--src/backend/commands/createas.c5
-rw-r--r--src/backend/commands/dbcommands.c1
-rw-r--r--src/backend/commands/define.c3
-rw-r--r--src/backend/commands/dropcmds.c5
-rw-r--r--src/backend/commands/event_trigger.c3
-rw-r--r--src/backend/commands/explain.c1
-rw-r--r--src/backend/commands/extension.c2
-rw-r--r--src/backend/commands/functioncmds.c6
-rw-r--r--src/backend/commands/indexcmds.c2
-rw-r--r--src/backend/commands/lockcmds.c1
-rw-r--r--src/backend/commands/matview.c5
-rw-r--r--src/backend/commands/opclasscmds.c3
-rw-r--r--src/backend/commands/operatorcmds.c3
-rw-r--r--src/backend/commands/policy.c3
-rw-r--r--src/backend/commands/prepare.c3
-rw-r--r--src/backend/commands/proclang.c2
-rw-r--r--src/backend/commands/publicationcmds.c7
-rw-r--r--src/backend/commands/statscmds.c5
-rw-r--r--src/backend/commands/tablecmds.c3
-rw-r--r--src/backend/commands/tablespace.c6
-rw-r--r--src/backend/commands/trigger.c7
-rw-r--r--src/backend/commands/tsearchcmds.c4
-rw-r--r--src/backend/commands/typecmds.c4
-rw-r--r--src/backend/commands/user.c1
-rw-r--r--src/backend/commands/vacuum.c2
-rw-r--r--src/backend/commands/vacuumparallel.c2
-rw-r--r--src/backend/commands/variable.c2
-rw-r--r--src/backend/commands/view.c5
40 files changed, 15 insertions, 138 deletions
diff --git a/src/backend/commands/aggregatecmds.c b/src/backend/commands/aggregatecmds.c
index 623c699cae9..fde5a2a0e04 100644
--- a/src/backend/commands/aggregatecmds.c
+++ b/src/backend/commands/aggregatecmds.c
@@ -22,21 +22,17 @@
*/
#include "postgres.h"
-#include "access/htup_details.h"
-#include "catalog/dependency.h"
+#include "catalog/namespace.h"
#include "catalog/pg_aggregate.h"
#include "catalog/pg_namespace.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_type.h"
-#include "commands/alter.h"
#include "commands/defrem.h"
#include "miscadmin.h"
-#include "parser/parse_func.h"
#include "parser/parse_type.h"
#include "utils/acl.h"
#include "utils/builtins.h"
#include "utils/lsyscache.h"
-#include "utils/syscache.h"
static char extractModify(DefElem *defel);
diff --git a/src/backend/commands/alter.c b/src/backend/commands/alter.c
index b2e4260aef7..cd740140fd7 100644
--- a/src/backend/commands/alter.c
+++ b/src/backend/commands/alter.c
@@ -16,7 +16,6 @@
#include "access/htup_details.h"
#include "access/relation.h"
-#include "access/sysattr.h"
#include "access/table.h"
#include "catalog/dependency.h"
#include "catalog/indexing.h"
@@ -43,13 +42,11 @@
#include "catalog/pg_ts_template.h"
#include "commands/alter.h"
#include "commands/collationcmds.h"
-#include "commands/conversioncmds.h"
#include "commands/dbcommands.h"
#include "commands/defrem.h"
#include "commands/event_trigger.h"
#include "commands/extension.h"
#include "commands/policy.h"
-#include "commands/proclang.h"
#include "commands/publicationcmds.h"
#include "commands/schemacmds.h"
#include "commands/subscriptioncmds.h"
@@ -59,12 +56,10 @@
#include "commands/typecmds.h"
#include "commands/user.h"
#include "miscadmin.h"
-#include "parser/parse_func.h"
#include "replication/logicalworker.h"
#include "rewrite/rewriteDefine.h"
-#include "tcop/utility.h"
+#include "utils/acl.h"
#include "utils/builtins.h"
-#include "utils/fmgroids.h"
#include "utils/lsyscache.h"
#include "utils/rel.h"
#include "utils/syscache.h"
diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c
index d105d2fad7b..4aee1098cf6 100644
--- a/src/backend/commands/analyze.c
+++ b/src/backend/commands/analyze.c
@@ -20,20 +20,15 @@
#include "access/genam.h"
#include "access/multixact.h"
#include "access/relation.h"
-#include "access/sysattr.h"
#include "access/table.h"
#include "access/tableam.h"
#include "access/transam.h"
#include "access/tupconvert.h"
#include "access/visibilitymap.h"
#include "access/xact.h"
-#include "catalog/catalog.h"
#include "catalog/index.h"
#include "catalog/indexing.h"
-#include "catalog/pg_collation.h"
#include "catalog/pg_inherits.h"
-#include "catalog/pg_namespace.h"
-#include "catalog/pg_statistic_ext.h"
#include "commands/dbcommands.h"
#include "commands/progress.h"
#include "commands/tablecmds.h"
@@ -50,14 +45,9 @@
#include "statistics/extended_stats_internal.h"
#include "statistics/statistics.h"
#include "storage/bufmgr.h"
-#include "storage/lmgr.h"
-#include "storage/proc.h"
#include "storage/procarray.h"
-#include "utils/acl.h"
#include "utils/attoptcache.h"
-#include "utils/builtins.h"
#include "utils/datum.h"
-#include "utils/fmgroids.h"
#include "utils/guc.h"
#include "utils/lsyscache.h"
#include "utils/memutils.h"
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index bbea5abd27a..d0891e3f0e0 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -142,10 +142,7 @@
#include "miscadmin.h"
#include "storage/ipc.h"
#include "storage/lmgr.h"
-#include "storage/proc.h"
-#include "storage/procarray.h"
#include "storage/procsignal.h"
-#include "storage/sinval.h"
#include "tcop/tcopprot.h"
#include "utils/builtins.h"
#include "utils/guc_hooks.h"
diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c
index e2c48ec560d..661fdef9b33 100644
--- a/src/backend/commands/cluster.c
+++ b/src/backend/commands/cluster.c
@@ -25,14 +25,12 @@
#include "access/toast_internals.h"
#include "access/transam.h"
#include "access/xact.h"
-#include "access/xlog.h"
#include "catalog/catalog.h"
#include "catalog/dependency.h"
#include "catalog/heap.h"
#include "catalog/index.h"
#include "catalog/namespace.h"
#include "catalog/objectaccess.h"
-#include "catalog/partition.h"
#include "catalog/pg_am.h"
#include "catalog/pg_database.h"
#include "catalog/pg_inherits.h"
@@ -58,7 +56,6 @@
#include "utils/relmapper.h"
#include "utils/snapmgr.h"
#include "utils/syscache.h"
-#include "utils/tuplesort.h"
/*
* This struct is used to pass around the information on tables to be
diff --git a/src/backend/commands/collationcmds.c b/src/backend/commands/collationcmds.c
index 58c059fdb7e..106e696da8d 100644
--- a/src/backend/commands/collationcmds.c
+++ b/src/backend/commands/collationcmds.c
@@ -17,14 +17,12 @@
#include "access/htup_details.h"
#include "access/table.h"
#include "access/xact.h"
-#include "catalog/dependency.h"
#include "catalog/indexing.h"
#include "catalog/namespace.h"
#include "catalog/objectaccess.h"
#include "catalog/pg_collation.h"
#include "catalog/pg_database.h"
#include "catalog/pg_namespace.h"
-#include "commands/alter.h"
#include "commands/collationcmds.h"
#include "commands/comment.h"
#include "commands/dbcommands.h"
diff --git a/src/backend/commands/constraint.c b/src/backend/commands/constraint.c
index c8a3f0a11fc..94d491b7541 100644
--- a/src/backend/commands/constraint.c
+++ b/src/backend/commands/constraint.c
@@ -14,13 +14,11 @@
#include "postgres.h"
#include "access/genam.h"
-#include "access/heapam.h"
#include "access/tableam.h"
#include "catalog/index.h"
#include "commands/trigger.h"
#include "executor/executor.h"
-#include "utils/builtins.h"
-#include "utils/rel.h"
+#include "utils/fmgrprotos.h"
#include "utils/snapmgr.h"
diff --git a/src/backend/commands/conversioncmds.c b/src/backend/commands/conversioncmds.c
index 4e811a32749..ddd5d1d1c54 100644
--- a/src/backend/commands/conversioncmds.c
+++ b/src/backend/commands/conversioncmds.c
@@ -14,23 +14,16 @@
*/
#include "postgres.h"
-#include "access/htup_details.h"
-#include "catalog/dependency.h"
-#include "catalog/indexing.h"
#include "catalog/pg_conversion.h"
#include "catalog/pg_namespace.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_type.h"
-#include "commands/alter.h"
#include "commands/conversioncmds.h"
#include "mb/pg_wchar.h"
#include "miscadmin.h"
#include "parser/parse_func.h"
#include "utils/acl.h"
-#include "utils/builtins.h"
#include "utils/lsyscache.h"
-#include "utils/rel.h"
-#include "utils/syscache.h"
/*
* CREATE CONVERSION
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c
index cc0786c6f4a..056b6733c8e 100644
--- a/src/backend/commands/copy.c
+++ b/src/backend/commands/copy.c
@@ -33,11 +33,9 @@
#include "parser/parse_collate.h"
#include "parser/parse_expr.h"
#include "parser/parse_relation.h"
-#include "rewrite/rewriteHandler.h"
#include "utils/acl.h"
#include "utils/builtins.h"
#include "utils/lsyscache.h"
-#include "utils/memutils.h"
#include "utils/rel.h"
#include "utils/rls.h"
diff --git a/src/backend/commands/copyfrom.c b/src/backend/commands/copyfrom.c
index c3bc897028a..8908a440e19 100644
--- a/src/backend/commands/copyfrom.c
+++ b/src/backend/commands/copyfrom.c
@@ -25,10 +25,8 @@
#include <sys/stat.h>
#include "access/heapam.h"
-#include "access/htup_details.h"
#include "access/tableam.h"
#include "access/xact.h"
-#include "access/xlog.h"
#include "catalog/namespace.h"
#include "commands/copy.h"
#include "commands/copyfrom_internal.h"
@@ -39,8 +37,7 @@
#include "executor/nodeModifyTable.h"
#include "executor/tuptable.h"
#include "foreign/fdwapi.h"
-#include "libpq/libpq.h"
-#include "libpq/pqformat.h"
+#include "mb/pg_wchar.h"
#include "miscadmin.h"
#include "nodes/miscnodes.h"
#include "optimizer/optimizer.h"
diff --git a/src/backend/commands/copyfromparse.c b/src/backend/commands/copyfromparse.c
index 7cacd0b752c..5682d5d054b 100644
--- a/src/backend/commands/copyfromparse.c
+++ b/src/backend/commands/copyfromparse.c
@@ -74,7 +74,6 @@
#include "pgstat.h"
#include "port/pg_bswap.h"
#include "utils/builtins.h"
-#include "utils/memutils.h"
#include "utils/rel.h"
#define ISOCTAL(c) (((c) >= '0') && ((c) <= '7'))
diff --git a/src/backend/commands/copyto.c b/src/backend/commands/copyto.c
index 20ffc90363d..a6962e0cb77 100644
--- a/src/backend/commands/copyto.c
+++ b/src/backend/commands/copyto.c
@@ -18,11 +18,7 @@
#include <unistd.h>
#include <sys/stat.h>
-#include "access/heapam.h"
-#include "access/htup_details.h"
#include "access/tableam.h"
-#include "access/xact.h"
-#include "access/xlog.h"
#include "commands/copy.h"
#include "commands/progress.h"
#include "executor/execdesc.h"
@@ -32,14 +28,11 @@
#include "libpq/pqformat.h"
#include "mb/pg_wchar.h"
#include "miscadmin.h"
-#include "optimizer/optimizer.h"
#include "pgstat.h"
-#include "rewrite/rewriteHandler.h"
#include "storage/fd.h"
#include "tcop/tcopprot.h"
#include "utils/lsyscache.h"
#include "utils/memutils.h"
-#include "utils/partcache.h"
#include "utils/rel.h"
#include "utils/snapmgr.h"
diff --git a/src/backend/commands/createas.c b/src/backend/commands/createas.c
index 16a2fe65e68..62050f4dc59 100644
--- a/src/backend/commands/createas.c
+++ b/src/backend/commands/createas.c
@@ -25,12 +25,9 @@
#include "postgres.h"
#include "access/heapam.h"
-#include "access/htup_details.h"
#include "access/reloptions.h"
-#include "access/sysattr.h"
#include "access/tableam.h"
#include "access/xact.h"
-#include "access/xlog.h"
#include "catalog/namespace.h"
#include "catalog/toasting.h"
#include "commands/createas.h"
@@ -41,9 +38,7 @@
#include "miscadmin.h"
#include "nodes/makefuncs.h"
#include "nodes/nodeFuncs.h"
-#include "parser/parse_clause.h"
#include "rewrite/rewriteHandler.h"
-#include "storage/smgr.h"
#include "tcop/tcopprot.h"
#include "utils/builtins.h"
#include "utils/lsyscache.h"
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c
index 78a158c3da4..b256d6d0f7d 100644
--- a/src/backend/commands/dbcommands.c
+++ b/src/backend/commands/dbcommands.c
@@ -64,7 +64,6 @@
#include "utils/acl.h"
#include "utils/builtins.h"
#include "utils/fmgroids.h"
-#include "utils/guc.h"
#include "utils/pg_locale.h"
#include "utils/relmapper.h"
#include "utils/snapmgr.h"
diff --git a/src/backend/commands/define.c b/src/backend/commands/define.c
index 0bb7bce6868..43f50066ea0 100644
--- a/src/backend/commands/define.c
+++ b/src/backend/commands/define.c
@@ -39,8 +39,7 @@
#include "commands/defrem.h"
#include "nodes/makefuncs.h"
#include "parser/parse_type.h"
-#include "parser/scansup.h"
-#include "utils/builtins.h"
+#include "utils/fmgrprotos.h"
/*
* Extract a string value (otherwise uninterpreted) from a DefElem.
diff --git a/src/backend/commands/dropcmds.c b/src/backend/commands/dropcmds.c
index 87a2db4e0f5..85eec7e3947 100644
--- a/src/backend/commands/dropcmds.c
+++ b/src/backend/commands/dropcmds.c
@@ -14,23 +14,18 @@
*/
#include "postgres.h"
-#include "access/htup_details.h"
#include "access/table.h"
#include "access/xact.h"
#include "catalog/dependency.h"
#include "catalog/namespace.h"
#include "catalog/objectaddress.h"
-#include "catalog/pg_class.h"
#include "catalog/pg_namespace.h"
#include "catalog/pg_proc.h"
#include "commands/defrem.h"
#include "miscadmin.h"
-#include "nodes/makefuncs.h"
#include "parser/parse_type.h"
#include "utils/acl.h"
-#include "utils/builtins.h"
#include "utils/lsyscache.h"
-#include "utils/syscache.h"
static void does_not_exist_skipping(ObjectType objtype,
diff --git a/src/backend/commands/event_trigger.c b/src/backend/commands/event_trigger.c
index c8b662131c3..ab11ab500b2 100644
--- a/src/backend/commands/event_trigger.c
+++ b/src/backend/commands/event_trigger.c
@@ -30,7 +30,6 @@
#include "catalog/pg_trigger.h"
#include "catalog/pg_ts_config.h"
#include "catalog/pg_type.h"
-#include "commands/dbcommands.h"
#include "commands/event_trigger.h"
#include "commands/extension.h"
#include "commands/trigger.h"
@@ -46,7 +45,7 @@
#include "utils/builtins.h"
#include "utils/evtcache.h"
#include "utils/fmgroids.h"
-#include "utils/inval.h"
+#include "utils/fmgrprotos.h"
#include "utils/lsyscache.h"
#include "utils/memutils.h"
#include "utils/rel.h"
diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c
index 83d00a46638..78754bc6ba0 100644
--- a/src/backend/commands/explain.c
+++ b/src/backend/commands/explain.c
@@ -18,7 +18,6 @@
#include "commands/createas.h"
#include "commands/defrem.h"
#include "commands/prepare.h"
-#include "executor/nodeHash.h"
#include "foreign/fdwapi.h"
#include "jit/jit.h"
#include "nodes/extensible.h"
diff --git a/src/backend/commands/extension.c b/src/backend/commands/extension.c
index 226f85d0e34..af600d7c9ac 100644
--- a/src/backend/commands/extension.c
+++ b/src/backend/commands/extension.c
@@ -32,7 +32,6 @@
#include "access/genam.h"
#include "access/htup_details.h"
#include "access/relation.h"
-#include "access/sysattr.h"
#include "access/table.h"
#include "access/xact.h"
#include "catalog/catalog.h"
@@ -55,7 +54,6 @@
#include "funcapi.h"
#include "mb/pg_wchar.h"
#include "miscadmin.h"
-#include "nodes/makefuncs.h"
#include "storage/fd.h"
#include "tcop/utility.h"
#include "utils/acl.h"
diff --git a/src/backend/commands/functioncmds.c b/src/backend/commands/functioncmds.c
index 63f4f499ecf..9cf3fe8275e 100644
--- a/src/backend/commands/functioncmds.c
+++ b/src/backend/commands/functioncmds.c
@@ -32,9 +32,7 @@
*/
#include "postgres.h"
-#include "access/genam.h"
#include "access/htup_details.h"
-#include "access/sysattr.h"
#include "access/table.h"
#include "catalog/catalog.h"
#include "catalog/dependency.h"
@@ -47,11 +45,9 @@
#include "catalog/pg_proc.h"
#include "catalog/pg_transform.h"
#include "catalog/pg_type.h"
-#include "commands/alter.h"
#include "commands/defrem.h"
#include "commands/extension.h"
#include "commands/proclang.h"
-#include "executor/execdesc.h"
#include "executor/executor.h"
#include "executor/functions.h"
#include "funcapi.h"
@@ -68,10 +64,8 @@
#include "tcop/utility.h"
#include "utils/acl.h"
#include "utils/builtins.h"
-#include "utils/fmgroids.h"
#include "utils/guc.h"
#include "utils/lsyscache.h"
-#include "utils/memutils.h"
#include "utils/rel.h"
#include "utils/snapmgr.h"
#include "utils/syscache.h"
diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c
index 06f90ff7522..cde1ee7432d 100644
--- a/src/backend/commands/indexcmds.c
+++ b/src/backend/commands/indexcmds.c
@@ -26,6 +26,7 @@
#include "catalog/catalog.h"
#include "catalog/index.h"
#include "catalog/indexing.h"
+#include "catalog/namespace.h"
#include "catalog/pg_am.h"
#include "catalog/pg_constraint.h"
#include "catalog/pg_database.h"
@@ -48,7 +49,6 @@
#include "nodes/nodeFuncs.h"
#include "optimizer/optimizer.h"
#include "parser/parse_coerce.h"
-#include "parser/parse_func.h"
#include "parser/parse_oper.h"
#include "partitioning/partdesc.h"
#include "pgstat.h"
diff --git a/src/backend/commands/lockcmds.c b/src/backend/commands/lockcmds.c
index 29e9953bf45..09ae09cf5cc 100644
--- a/src/backend/commands/lockcmds.c
+++ b/src/backend/commands/lockcmds.c
@@ -21,7 +21,6 @@
#include "commands/lockcmds.h"
#include "miscadmin.h"
#include "nodes/nodeFuncs.h"
-#include "parser/parse_clause.h"
#include "rewrite/rewriteHandler.h"
#include "storage/lmgr.h"
#include "utils/acl.h"
diff --git a/src/backend/commands/matview.c b/src/backend/commands/matview.c
index 59920ced838..2f1d897cf1d 100644
--- a/src/backend/commands/matview.c
+++ b/src/backend/commands/matview.c
@@ -20,13 +20,10 @@
#include "access/multixact.h"
#include "access/tableam.h"
#include "access/xact.h"
-#include "access/xlog.h"
-#include "catalog/catalog.h"
#include "catalog/indexing.h"
#include "catalog/namespace.h"
#include "catalog/pg_am.h"
#include "catalog/pg_opclass.h"
-#include "catalog/pg_operator.h"
#include "commands/cluster.h"
#include "commands/matview.h"
#include "commands/tablecmds.h"
@@ -34,11 +31,9 @@
#include "executor/executor.h"
#include "executor/spi.h"
#include "miscadmin.h"
-#include "parser/parse_relation.h"
#include "pgstat.h"
#include "rewrite/rewriteHandler.h"
#include "storage/lmgr.h"
-#include "storage/smgr.h"
#include "tcop/tcopprot.h"
#include "utils/builtins.h"
#include "utils/lsyscache.h"
diff --git a/src/backend/commands/opclasscmds.c b/src/backend/commands/opclasscmds.c
index 7c2108832d4..b8b5c147c5d 100644
--- a/src/backend/commands/opclasscmds.c
+++ b/src/backend/commands/opclasscmds.c
@@ -21,7 +21,6 @@
#include "access/hash.h"
#include "access/htup_details.h"
#include "access/nbtree.h"
-#include "access/sysattr.h"
#include "access/table.h"
#include "catalog/catalog.h"
#include "catalog/dependency.h"
@@ -36,13 +35,13 @@
#include "catalog/pg_opfamily.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_type.h"
-#include "commands/alter.h"
#include "commands/defrem.h"
#include "commands/event_trigger.h"
#include "miscadmin.h"
#include "parser/parse_func.h"
#include "parser/parse_oper.h"
#include "parser/parse_type.h"
+#include "utils/acl.h"
#include "utils/builtins.h"
#include "utils/fmgroids.h"
#include "utils/lsyscache.h"
diff --git a/src/backend/commands/operatorcmds.c b/src/backend/commands/operatorcmds.c
index 64140860914..5872a3e1922 100644
--- a/src/backend/commands/operatorcmds.c
+++ b/src/backend/commands/operatorcmds.c
@@ -33,21 +33,18 @@
#include "access/htup_details.h"
#include "access/table.h"
-#include "catalog/dependency.h"
#include "catalog/indexing.h"
#include "catalog/objectaccess.h"
#include "catalog/pg_namespace.h"
#include "catalog/pg_operator.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_type.h"
-#include "commands/alter.h"
#include "commands/defrem.h"
#include "miscadmin.h"
#include "parser/parse_func.h"
#include "parser/parse_oper.h"
#include "parser/parse_type.h"
#include "utils/acl.h"
-#include "utils/builtins.h"
#include "utils/lsyscache.h"
#include "utils/rel.h"
#include "utils/syscache.h"
diff --git a/src/backend/commands/policy.c b/src/backend/commands/policy.c
index 596326e5ec0..6ff3eba8249 100644
--- a/src/backend/commands/policy.c
+++ b/src/backend/commands/policy.c
@@ -16,7 +16,6 @@
#include "access/htup.h"
#include "access/htup_details.h"
#include "access/relation.h"
-#include "access/sysattr.h"
#include "access/table.h"
#include "access/xact.h"
#include "catalog/catalog.h"
@@ -29,7 +28,6 @@
#include "catalog/pg_type.h"
#include "commands/policy.h"
#include "miscadmin.h"
-#include "nodes/makefuncs.h"
#include "nodes/pg_list.h"
#include "parser/parse_clause.h"
#include "parser/parse_collate.h"
@@ -37,7 +35,6 @@
#include "parser/parse_relation.h"
#include "rewrite/rewriteManip.h"
#include "rewrite/rowsecurity.h"
-#include "storage/lock.h"
#include "utils/acl.h"
#include "utils/array.h"
#include "utils/builtins.h"
diff --git a/src/backend/commands/prepare.c b/src/backend/commands/prepare.c
index bf1579d36d7..5e85585e9dd 100644
--- a/src/backend/commands/prepare.c
+++ b/src/backend/commands/prepare.c
@@ -23,14 +23,11 @@
#include "commands/createas.h"
#include "commands/prepare.h"
#include "funcapi.h"
-#include "miscadmin.h"
#include "nodes/nodeFuncs.h"
-#include "parser/analyze.h"
#include "parser/parse_coerce.h"
#include "parser/parse_collate.h"
#include "parser/parse_expr.h"
#include "parser/parse_type.h"
-#include "rewrite/rewriteHandler.h"
#include "tcop/pquery.h"
#include "tcop/utility.h"
#include "utils/builtins.h"
diff --git a/src/backend/commands/proclang.c b/src/backend/commands/proclang.c
index c849d65e623..881f90017ef 100644
--- a/src/backend/commands/proclang.c
+++ b/src/backend/commands/proclang.c
@@ -19,10 +19,8 @@
#include "catalog/indexing.h"
#include "catalog/objectaccess.h"
#include "catalog/pg_language.h"
-#include "catalog/pg_namespace.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_type.h"
-#include "commands/defrem.h"
#include "commands/proclang.h"
#include "miscadmin.h"
#include "parser/parse_func.h"
diff --git a/src/backend/commands/publicationcmds.c b/src/backend/commands/publicationcmds.c
index 88db8258d71..9bcc22fdd7e 100644
--- a/src/backend/commands/publicationcmds.c
+++ b/src/backend/commands/publicationcmds.c
@@ -14,7 +14,6 @@
#include "postgres.h"
-#include "access/genam.h"
#include "access/htup_details.h"
#include "access/table.h"
#include "access/xact.h"
@@ -23,7 +22,6 @@
#include "catalog/namespace.h"
#include "catalog/objectaccess.h"
#include "catalog/objectaddress.h"
-#include "catalog/partition.h"
#include "catalog/pg_database.h"
#include "catalog/pg_inherits.h"
#include "catalog/pg_namespace.h"
@@ -31,12 +29,10 @@
#include "catalog/pg_publication.h"
#include "catalog/pg_publication_namespace.h"
#include "catalog/pg_publication_rel.h"
-#include "catalog/pg_type.h"
#include "commands/dbcommands.h"
#include "commands/defrem.h"
#include "commands/event_trigger.h"
#include "commands/publicationcmds.h"
-#include "funcapi.h"
#include "miscadmin.h"
#include "nodes/nodeFuncs.h"
#include "parser/parse_clause.h"
@@ -44,10 +40,7 @@
#include "parser/parse_relation.h"
#include "storage/lmgr.h"
#include "utils/acl.h"
-#include "utils/array.h"
#include "utils/builtins.h"
-#include "utils/catcache.h"
-#include "utils/fmgroids.h"
#include "utils/inval.h"
#include "utils/lsyscache.h"
#include "utils/rel.h"
diff --git a/src/backend/commands/statscmds.c b/src/backend/commands/statscmds.c
index b1a9c74bd63..6fa840fada8 100644
--- a/src/backend/commands/statscmds.c
+++ b/src/backend/commands/statscmds.c
@@ -14,9 +14,7 @@
*/
#include "postgres.h"
-#include "access/heapam.h"
#include "access/relation.h"
-#include "access/relscan.h"
#include "access/table.h"
#include "catalog/catalog.h"
#include "catalog/dependency.h"
@@ -32,11 +30,10 @@
#include "nodes/nodeFuncs.h"
#include "optimizer/optimizer.h"
#include "statistics/statistics.h"
+#include "utils/acl.h"
#include "utils/builtins.h"
#include "utils/lsyscache.h"
-#include "utils/fmgroids.h"
#include "utils/inval.h"
-#include "utils/memutils.h"
#include "utils/rel.h"
#include "utils/syscache.h"
#include "utils/typcache.h"
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index f7987945563..764478c950c 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -54,7 +54,6 @@
#include "commands/comment.h"
#include "commands/defrem.h"
#include "commands/event_trigger.h"
-#include "commands/policy.h"
#include "commands/sequence.h"
#include "commands/tablecmds.h"
#include "commands/tablespace.h"
@@ -70,11 +69,9 @@
#include "nodes/nodeFuncs.h"
#include "nodes/parsenodes.h"
#include "optimizer/optimizer.h"
-#include "parser/parse_clause.h"
#include "parser/parse_coerce.h"
#include "parser/parse_collate.h"
#include "parser/parse_expr.h"
-#include "parser/parse_oper.h"
#include "parser/parse_relation.h"
#include "parser/parse_type.h"
#include "parser/parse_utilcmd.h"
diff --git a/src/backend/commands/tablespace.c b/src/backend/commands/tablespace.c
index 76ad66e51f9..113b4807315 100644
--- a/src/backend/commands/tablespace.c
+++ b/src/backend/commands/tablespace.c
@@ -53,7 +53,6 @@
#include "access/heapam.h"
#include "access/htup_details.h"
#include "access/reloptions.h"
-#include "access/sysattr.h"
#include "access/tableam.h"
#include "access/xact.h"
#include "access/xloginsert.h"
@@ -62,25 +61,20 @@
#include "catalog/catalog.h"
#include "catalog/dependency.h"
#include "catalog/indexing.h"
-#include "catalog/namespace.h"
#include "catalog/objectaccess.h"
-#include "catalog/pg_namespace.h"
#include "catalog/pg_tablespace.h"
#include "commands/comment.h"
#include "commands/seclabel.h"
-#include "commands/tablecmds.h"
#include "commands/tablespace.h"
#include "common/file_perm.h"
#include "miscadmin.h"
#include "postmaster/bgwriter.h"
#include "storage/fd.h"
-#include "storage/lmgr.h"
#include "storage/standby.h"
#include "utils/acl.h"
#include "utils/builtins.h"
#include "utils/fmgroids.h"
#include "utils/guc_hooks.h"
-#include "utils/lsyscache.h"
#include "utils/memutils.h"
#include "utils/rel.h"
#include "utils/varlena.h"
diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c
index c344ff09442..3d35b64a57d 100644
--- a/src/backend/commands/trigger.c
+++ b/src/backend/commands/trigger.c
@@ -22,7 +22,6 @@
#include "access/xact.h"
#include "catalog/catalog.h"
#include "catalog/dependency.h"
-#include "catalog/index.h"
#include "catalog/indexing.h"
#include "catalog/objectaccess.h"
#include "catalog/partition.h"
@@ -32,10 +31,8 @@
#include "catalog/pg_trigger.h"
#include "catalog/pg_type.h"
#include "commands/dbcommands.h"
-#include "commands/defrem.h"
#include "commands/trigger.h"
#include "executor/executor.h"
-#include "executor/execPartition.h"
#include "miscadmin.h"
#include "nodes/bitmapset.h"
#include "nodes/makefuncs.h"
@@ -44,16 +41,12 @@
#include "parser/parse_collate.h"
#include "parser/parse_func.h"
#include "parser/parse_relation.h"
-#include "parser/parsetree.h"
#include "partitioning/partdesc.h"
#include "pgstat.h"
#include "rewrite/rewriteManip.h"
-#include "storage/bufmgr.h"
#include "storage/lmgr.h"
-#include "tcop/utility.h"
#include "utils/acl.h"
#include "utils/builtins.h"
-#include "utils/bytea.h"
#include "utils/fmgroids.h"
#include "utils/guc_hooks.h"
#include "utils/inval.h"
diff --git a/src/backend/commands/tsearchcmds.c b/src/backend/commands/tsearchcmds.c
index 3c2587db89b..b7b5019f1e0 100644
--- a/src/backend/commands/tsearchcmds.c
+++ b/src/backend/commands/tsearchcmds.c
@@ -33,7 +33,6 @@
#include "catalog/pg_ts_parser.h"
#include "catalog/pg_ts_template.h"
#include "catalog/pg_type.h"
-#include "commands/alter.h"
#include "commands/defrem.h"
#include "commands/event_trigger.h"
#include "common/string.h"
@@ -41,7 +40,8 @@
#include "nodes/makefuncs.h"
#include "parser/parse_func.h"
#include "tsearch/ts_cache.h"
-#include "tsearch/ts_utils.h"
+#include "tsearch/ts_public.h"
+#include "utils/acl.h"
#include "utils/builtins.h"
#include "utils/fmgroids.h"
#include "utils/lsyscache.h"
diff --git a/src/backend/commands/typecmds.c b/src/backend/commands/typecmds.c
index e0275e5fe9c..d3b6c1089e7 100644
--- a/src/backend/commands/typecmds.c
+++ b/src/backend/commands/typecmds.c
@@ -32,8 +32,9 @@
#include "postgres.h"
#include "access/genam.h"
-#include "access/heapam.h"
#include "access/htup_details.h"
+#include "access/relation.h"
+#include "access/table.h"
#include "access/tableam.h"
#include "access/xact.h"
#include "catalog/binary_upgrade.h"
@@ -68,7 +69,6 @@
#include "utils/fmgroids.h"
#include "utils/inval.h"
#include "utils/lsyscache.h"
-#include "utils/memutils.h"
#include "utils/rel.h"
#include "utils/ruleutils.h"
#include "utils/snapmgr.h"
diff --git a/src/backend/commands/user.c b/src/backend/commands/user.c
index 6839d44a2f5..c75cde2e8e1 100644
--- a/src/backend/commands/user.c
+++ b/src/backend/commands/user.c
@@ -38,7 +38,6 @@
#include "utils/catcache.h"
#include "utils/fmgroids.h"
#include "utils/syscache.h"
-#include "utils/timestamp.h"
#include "utils/varlena.h"
/*
diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c
index e40cef6566e..bd2309967e0 100644
--- a/src/backend/commands/vacuum.c
+++ b/src/backend/commands/vacuum.c
@@ -38,7 +38,6 @@
#include "catalog/index.h"
#include "catalog/pg_database.h"
#include "catalog/pg_inherits.h"
-#include "catalog/pg_namespace.h"
#include "commands/cluster.h"
#include "commands/defrem.h"
#include "commands/vacuum.h"
@@ -58,7 +57,6 @@
#include "utils/guc.h"
#include "utils/guc_hooks.h"
#include "utils/memutils.h"
-#include "utils/pg_rusage.h"
#include "utils/snapmgr.h"
#include "utils/syscache.h"
diff --git a/src/backend/commands/vacuumparallel.c b/src/backend/commands/vacuumparallel.c
index e087dfd72eb..befda1c1050 100644
--- a/src/backend/commands/vacuumparallel.c
+++ b/src/backend/commands/vacuumparallel.c
@@ -29,9 +29,9 @@
#include "access/amapi.h"
#include "access/table.h"
#include "access/xact.h"
-#include "catalog/index.h"
#include "commands/progress.h"
#include "commands/vacuum.h"
+#include "executor/instrument.h"
#include "optimizer/paths.h"
#include "pgstat.h"
#include "storage/bufmgr.h"
diff --git a/src/backend/commands/variable.c b/src/backend/commands/variable.c
index 30efcd554ae..01151ca2b5a 100644
--- a/src/backend/commands/variable.c
+++ b/src/backend/commands/variable.c
@@ -32,8 +32,8 @@
#include "storage/bufmgr.h"
#include "utils/acl.h"
#include "utils/backend_status.h"
-#include "utils/builtins.h"
#include "utils/datetime.h"
+#include "utils/fmgrprotos.h"
#include "utils/guc_hooks.h"
#include "utils/snapmgr.h"
#include "utils/syscache.h"
diff --git a/src/backend/commands/view.c b/src/backend/commands/view.c
index dce898c751c..becc1fb4583 100644
--- a/src/backend/commands/view.c
+++ b/src/backend/commands/view.c
@@ -17,23 +17,18 @@
#include "access/relation.h"
#include "access/xact.h"
#include "catalog/namespace.h"
-#include "commands/defrem.h"
#include "commands/tablecmds.h"
#include "commands/view.h"
-#include "miscadmin.h"
#include "nodes/makefuncs.h"
#include "nodes/nodeFuncs.h"
#include "parser/analyze.h"
#include "parser/parse_relation.h"
#include "rewrite/rewriteDefine.h"
#include "rewrite/rewriteHandler.h"
-#include "rewrite/rewriteManip.h"
#include "rewrite/rewriteSupport.h"
-#include "utils/acl.h"
#include "utils/builtins.h"
#include "utils/lsyscache.h"
#include "utils/rel.h"
-#include "utils/syscache.h"
static void checkViewTupleDesc(TupleDesc newdesc, TupleDesc olddesc);