From ffa727a9be04392491cde988eedf72ed47d7643b Mon Sep 17 00:00:00 2001
From: Andres Freund <andres@anarazel.de>
Date: Sat, 3 Aug 2019 12:17:19 -0700
Subject: [PATCH v1 3/4] Remove fmgr.h includes from headers that don't really
 need it.

Most of the fmgr.h includes were obsoleted by 352a24a1f9d6f7d4abb1. A
few others can be obsoleted using the underlying struct type in an
implementation detail.

Author:
Reviewed-By:
Discussion: https://postgr.es/m/
Backpatch:
---
 src/backend/access/common/printsimple.c     | 1 -
 src/backend/nodes/makefuncs.c               | 1 -
 src/backend/replication/logical/logical.c   | 1 +
 src/backend/replication/pgoutput/pgoutput.c | 2 ++
 src/include/access/brin.h                   | 1 -
 src/include/access/gist_private.h           | 1 -
 src/include/access/hash.h                   | 1 -
 src/include/access/spgist.h                 | 1 -
 src/include/commands/async.h                | 2 --
 src/include/executor/executor.h             | 1 +
 src/include/jit/llvmjit_emit.h              | 1 -
 src/include/nodes/execnodes.h               | 1 +
 src/include/nodes/pathnodes.h               | 3 +--
 src/include/pgstat.h                        | 4 ++--
 src/include/replication/origin.h            | 1 -
 src/include/replication/slot.h              | 1 -
 src/include/replication/walreceiver.h       | 1 -
 src/include/replication/walsender.h         | 2 --
 src/include/utils/bytea.h                   | 1 -
 src/include/utils/formatting.h              | 2 --
 src/include/utils/rel.h                     | 3 +--
 src/include/utils/snapmgr.h                 | 1 -
 src/include/utils/tuplesort.h               | 1 -
 23 files changed, 9 insertions(+), 25 deletions(-)

diff --git a/src/backend/access/common/printsimple.c b/src/backend/access/common/printsimple.c
index 3ea188d701c..651ade14dd2 100644
--- a/src/backend/access/common/printsimple.c
+++ b/src/backend/access/common/printsimple.c
@@ -20,7 +20,6 @@
 
 #include "access/printsimple.h"
 #include "catalog/pg_type.h"
-#include "fmgr.h"
 #include "libpq/pqformat.h"
 #include "utils/builtins.h"
 
diff --git a/src/backend/nodes/makefuncs.c b/src/backend/nodes/makefuncs.c
index 5c11b5472e5..18466ac5687 100644
--- a/src/backend/nodes/makefuncs.c
+++ b/src/backend/nodes/makefuncs.c
@@ -17,7 +17,6 @@
 
 #include "catalog/pg_class.h"
 #include "catalog/pg_type.h"
-#include "fmgr.h"
 #include "nodes/makefuncs.h"
 #include "nodes/nodeFuncs.h"
 #include "utils/lsyscache.h"
diff --git a/src/backend/replication/logical/logical.c b/src/backend/replication/logical/logical.c
index 9853be6d1c2..f8b9020081e 100644
--- a/src/backend/replication/logical/logical.c
+++ b/src/backend/replication/logical/logical.c
@@ -28,6 +28,7 @@
 
 #include "postgres.h"
 
+#include "fmgr.h"
 #include "miscadmin.h"
 
 #include "access/xact.h"
diff --git a/src/backend/replication/pgoutput/pgoutput.c b/src/backend/replication/pgoutput/pgoutput.c
index d317fd70063..9c08757fcaf 100644
--- a/src/backend/replication/pgoutput/pgoutput.c
+++ b/src/backend/replication/pgoutput/pgoutput.c
@@ -14,6 +14,8 @@
 
 #include "catalog/pg_publication.h"
 
+#include "fmgr.h"
+
 #include "replication/logical.h"
 #include "replication/logicalproto.h"
 #include "replication/origin.h"
diff --git a/src/include/access/brin.h b/src/include/access/brin.h
index 612721baf3a..fb351b36e03 100644
--- a/src/include/access/brin.h
+++ b/src/include/access/brin.h
@@ -10,7 +10,6 @@
 #ifndef BRIN_H
 #define BRIN_H
 
-#include "fmgr.h"
 #include "nodes/execnodes.h"
 #include "utils/relcache.h"
 
diff --git a/src/include/access/gist_private.h b/src/include/access/gist_private.h
index 664f322df3a..fc1a3115565 100644
--- a/src/include/access/gist_private.h
+++ b/src/include/access/gist_private.h
@@ -17,7 +17,6 @@
 #include "access/amapi.h"
 #include "access/gist.h"
 #include "access/itup.h"
-#include "fmgr.h"
 #include "lib/pairingheap.h"
 #include "storage/bufmgr.h"
 #include "storage/buffile.h"
diff --git a/src/include/access/hash.h b/src/include/access/hash.h
index 107c3d01ae4..85982e0e404 100644
--- a/src/include/access/hash.h
+++ b/src/include/access/hash.h
@@ -20,7 +20,6 @@
 #include "access/amapi.h"
 #include "access/itup.h"
 #include "access/sdir.h"
-#include "fmgr.h"
 #include "lib/stringinfo.h"
 #include "storage/bufmgr.h"
 #include "storage/lockdefs.h"
diff --git a/src/include/access/spgist.h b/src/include/access/spgist.h
index 02c87949cee..d787ab213dc 100644
--- a/src/include/access/spgist.h
+++ b/src/include/access/spgist.h
@@ -16,7 +16,6 @@
 
 #include "access/amapi.h"
 #include "access/xlogreader.h"
-#include "fmgr.h"
 #include "lib/stringinfo.h"
 
 
diff --git a/src/include/commands/async.h b/src/include/commands/async.h
index d132fd59991..c295dc67c64 100644
--- a/src/include/commands/async.h
+++ b/src/include/commands/async.h
@@ -15,8 +15,6 @@
 
 #include <signal.h>
 
-#include "fmgr.h"
-
 /*
  * The number of SLRU page buffers we use for the notification queue.
  */
diff --git a/src/include/executor/executor.h b/src/include/executor/executor.h
index 1fb28b4596b..254db49a3ce 100644
--- a/src/include/executor/executor.h
+++ b/src/include/executor/executor.h
@@ -15,6 +15,7 @@
 #define EXECUTOR_H
 
 #include "executor/execdesc.h"
+#include "fmgr.h"
 #include "nodes/lockoptions.h"
 #include "nodes/parsenodes.h"
 #include "utils/memutils.h"
diff --git a/src/include/jit/llvmjit_emit.h b/src/include/jit/llvmjit_emit.h
index 71a8625efe4..cdfa0dc7214 100644
--- a/src/include/jit/llvmjit_emit.h
+++ b/src/include/jit/llvmjit_emit.h
@@ -17,7 +17,6 @@
 
 #include <llvm-c/Core.h>
 
-#include "fmgr.h"
 #include "jit/llvmjit.h"
 
 
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 4ec78491f6f..c682e86de7d 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -16,6 +16,7 @@
 
 #include "access/tupconvert.h"
 #include "executor/instrument.h"
+#include "fmgr.h"
 #include "lib/pairingheap.h"
 #include "nodes/params.h"
 #include "nodes/plannodes.h"
diff --git a/src/include/nodes/pathnodes.h b/src/include/nodes/pathnodes.h
index e3c579ee443..510f41a4049 100644
--- a/src/include/nodes/pathnodes.h
+++ b/src/include/nodes/pathnodes.h
@@ -15,7 +15,6 @@
 #define PATHNODES_H
 
 #include "access/sdir.h"
-#include "fmgr.h"
 #include "lib/stringinfo.h"
 #include "nodes/params.h"
 #include "nodes/parsenodes.h"
@@ -401,7 +400,7 @@ typedef struct PartitionSchemeData
 	bool	   *parttypbyval;
 
 	/* Cached information about partition comparison functions. */
-	FmgrInfo   *partsupfunc;
+	struct FmgrInfo *partsupfunc;
 }			PartitionSchemeData;
 
 typedef struct PartitionSchemeData *PartitionScheme;
diff --git a/src/include/pgstat.h b/src/include/pgstat.h
index 0a3ad3a1883..fe076d823db 100644
--- a/src/include/pgstat.h
+++ b/src/include/pgstat.h
@@ -12,7 +12,6 @@
 #define PGSTAT_H
 
 #include "datatype/timestamp.h"
-#include "fmgr.h"
 #include "libpq/pqcomm.h"
 #include "port/atomics.h"
 #include "portability/instr_time.h"
@@ -1402,7 +1401,8 @@ extern void pgstat_count_heap_delete(Relation rel);
 extern void pgstat_count_truncate(Relation rel);
 extern void pgstat_update_heap_dead_tuples(Relation rel, int delta);
 
-extern void pgstat_init_function_usage(FunctionCallInfo fcinfo,
+struct FunctionCallInfoBaseData;
+extern void pgstat_init_function_usage(struct FunctionCallInfoBaseData *fcinfo,
 									   PgStat_FunctionCallUsage *fcu);
 extern void pgstat_end_function_usage(PgStat_FunctionCallUsage *fcu,
 									  bool finalize);
diff --git a/src/include/replication/origin.h b/src/include/replication/origin.h
index 7422b26a6d8..dccf48418ff 100644
--- a/src/include/replication/origin.h
+++ b/src/include/replication/origin.h
@@ -10,7 +10,6 @@
 #ifndef PG_ORIGIN_H
 #define PG_ORIGIN_H
 
-#include "fmgr.h"
 #include "access/xlog.h"
 #include "access/xlogdefs.h"
 #include "access/xlogreader.h"
diff --git a/src/include/replication/slot.h b/src/include/replication/slot.h
index 8fbddea78fd..3a5763fb07a 100644
--- a/src/include/replication/slot.h
+++ b/src/include/replication/slot.h
@@ -9,7 +9,6 @@
 #ifndef SLOT_H
 #define SLOT_H
 
-#include "fmgr.h"
 #include "access/xlog.h"
 #include "access/xlogreader.h"
 #include "storage/condition_variable.h"
diff --git a/src/include/replication/walreceiver.h b/src/include/replication/walreceiver.h
index 86a81300517..bc9468b519e 100644
--- a/src/include/replication/walreceiver.h
+++ b/src/include/replication/walreceiver.h
@@ -14,7 +14,6 @@
 
 #include "access/xlog.h"
 #include "access/xlogdefs.h"
-#include "fmgr.h"
 #include "getaddrinfo.h"		/* for NI_MAXHOST */
 #include "replication/logicalproto.h"
 #include "replication/walsender.h"
diff --git a/src/include/replication/walsender.h b/src/include/replication/walsender.h
index 4a60893a3bc..61223aecbc1 100644
--- a/src/include/replication/walsender.h
+++ b/src/include/replication/walsender.h
@@ -14,8 +14,6 @@
 
 #include <signal.h>
 
-#include "fmgr.h"
-
 /*
  * What to do with a snapshot in create replication slot command.
  */
diff --git a/src/include/utils/bytea.h b/src/include/utils/bytea.h
index c96011fae84..72224ca95f3 100644
--- a/src/include/utils/bytea.h
+++ b/src/include/utils/bytea.h
@@ -14,7 +14,6 @@
 #ifndef BYTEA_H
 #define BYTEA_H
 
-#include "fmgr.h"
 
 
 typedef enum
diff --git a/src/include/utils/formatting.h b/src/include/utils/formatting.h
index 741c5f4809f..0117144779e 100644
--- a/src/include/utils/formatting.h
+++ b/src/include/utils/formatting.h
@@ -17,8 +17,6 @@
 #ifndef _FORMATTING_H_
 #define _FORMATTING_H_
 
-#include "fmgr.h"
-
 
 extern char *str_tolower(const char *buff, size_t nbytes, Oid collid);
 extern char *str_toupper(const char *buff, size_t nbytes, Oid collid);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index b0fe19ebc54..302dfff1f3d 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -19,7 +19,6 @@
 #include "catalog/pg_class.h"
 #include "catalog/pg_index.h"
 #include "catalog/pg_publication.h"
-#include "fmgr.h"
 #include "nodes/bitmapset.h"
 #include "rewrite/prs2lock.h"
 #include "storage/block.h"
@@ -159,7 +158,7 @@ typedef struct RelationData
 	Oid		   *rd_opfamily;	/* OIDs of op families for each index col */
 	Oid		   *rd_opcintype;	/* OIDs of opclass declared input data types */
 	RegProcedure *rd_support;	/* OIDs of support procedures */
-	FmgrInfo   *rd_supportinfo; /* lookup info for support procedures */
+	struct FmgrInfo *rd_supportinfo; /* lookup info for support procedures */
 	int16	   *rd_indoption;	/* per-column AM-specific flags */
 	List	   *rd_indexprs;	/* index expression trees, if any */
 	List	   *rd_indpred;		/* index predicate tree, if any */
diff --git a/src/include/utils/snapmgr.h b/src/include/utils/snapmgr.h
index 6641ee510a1..8c070d7f412 100644
--- a/src/include/utils/snapmgr.h
+++ b/src/include/utils/snapmgr.h
@@ -14,7 +14,6 @@
 #define SNAPMGR_H
 
 #include "access/transam.h"
-#include "fmgr.h"
 #include "utils/relcache.h"
 #include "utils/resowner.h"
 #include "utils/snapshot.h"
diff --git a/src/include/utils/tuplesort.h b/src/include/utils/tuplesort.h
index 4521de18e13..d774bc1152f 100644
--- a/src/include/utils/tuplesort.h
+++ b/src/include/utils/tuplesort.h
@@ -23,7 +23,6 @@
 
 #include "access/itup.h"
 #include "executor/tuptable.h"
-#include "fmgr.h"
 #include "storage/dsm.h"
 #include "utils/relcache.h"
 
-- 
2.22.0.545.g9c9b961d7e

