From 18c7d6760aadd033f84e799bb6ac8c94edbf2435 Mon Sep 17 00:00:00 2001
From: Andres Freund <andres@anarazel.de>
Date: Sat, 3 Aug 2019 12:21:27 -0700
Subject: [PATCH v1 4/4] Remove fmgr.h includes from headers that have macro
 only dependencies.

These headers all just include fmgr.h because they define macros that
in turn use fmgr.h macros, like PG_GETARG_DATUM. Most include sites
for these headers however just want to reference the type defined in
the respective header. Where needed fmgr.h can be included.

Author:
Reviewed-By:
Discussion: https://postgr.es/m/
Backpatch:
---
 contrib/earthdistance/earthdistance.c | 2 ++
 src/include/utils/cash.h              | 2 --
 src/include/utils/date.h              | 1 -
 src/include/utils/expandedrecord.h    | 1 -
 src/include/utils/geo_decls.h         | 2 --
 src/include/utils/inet.h              | 2 --
 src/include/utils/jsonpath.h          | 1 -
 src/include/utils/numeric.h           | 2 --
 src/include/utils/pg_lsn.h            | 1 -
 src/include/utils/timestamp.h         | 1 -
 src/include/utils/varbit.h            | 2 --
 src/include/utils/xml.h               | 1 -
 12 files changed, 2 insertions(+), 16 deletions(-)

diff --git a/contrib/earthdistance/earthdistance.c b/contrib/earthdistance/earthdistance.c
index e6ebfd11ad4..d6825a83721 100644
--- a/contrib/earthdistance/earthdistance.c
+++ b/contrib/earthdistance/earthdistance.c
@@ -4,6 +4,8 @@
 
 #include <math.h>
 
+#include "fmgr.h"
+
 #include "utils/geo_decls.h"	/* for Point */
 
 #ifndef M_PI
diff --git a/src/include/utils/cash.h b/src/include/utils/cash.h
index 2e332d83b1c..ae158e2dcd0 100644
--- a/src/include/utils/cash.h
+++ b/src/include/utils/cash.h
@@ -12,8 +12,6 @@
 #ifndef CASH_H
 #define CASH_H
 
-#include "fmgr.h"
-
 typedef int64 Cash;
 
 /* Cash is pass-by-reference if and only if int64 is */
diff --git a/src/include/utils/date.h b/src/include/utils/date.h
index bec129aff1c..df6af8dc660 100644
--- a/src/include/utils/date.h
+++ b/src/include/utils/date.h
@@ -16,7 +16,6 @@
 
 #include <math.h>
 
-#include "fmgr.h"
 #include "pgtime.h"
 #include "datatype/timestamp.h"
 
diff --git a/src/include/utils/expandedrecord.h b/src/include/utils/expandedrecord.h
index 84e6aae23fe..ff97effc2f9 100644
--- a/src/include/utils/expandedrecord.h
+++ b/src/include/utils/expandedrecord.h
@@ -15,7 +15,6 @@
 
 #include "access/htup.h"
 #include "access/tupdesc.h"
-#include "fmgr.h"
 #include "utils/expandeddatum.h"
 
 
diff --git a/src/include/utils/geo_decls.h b/src/include/utils/geo_decls.h
index 4b0353cf0f2..cdb350527ba 100644
--- a/src/include/utils/geo_decls.h
+++ b/src/include/utils/geo_decls.h
@@ -18,8 +18,6 @@
 #ifndef GEO_DECLS_H
 #define GEO_DECLS_H
 
-#include "fmgr.h"
-
 /*--------------------------------------------------------------------
  * Useful floating point utilities and constants.
  *-------------------------------------------------------------------
diff --git a/src/include/utils/inet.h b/src/include/utils/inet.h
index 998593e956f..231fb423448 100644
--- a/src/include/utils/inet.h
+++ b/src/include/utils/inet.h
@@ -14,8 +14,6 @@
 #ifndef INET_H
 #define INET_H
 
-#include "fmgr.h"
-
 /*
  *	This is the internal storage format for IP addresses
  *	(both INET and CIDR datatypes):
diff --git a/src/include/utils/jsonpath.h b/src/include/utils/jsonpath.h
index 40ad5fda928..3e7497182e3 100644
--- a/src/include/utils/jsonpath.h
+++ b/src/include/utils/jsonpath.h
@@ -14,7 +14,6 @@
 #ifndef JSONPATH_H
 #define JSONPATH_H
 
-#include "fmgr.h"
 #include "utils/jsonb.h"
 #include "nodes/pg_list.h"
 
diff --git a/src/include/utils/numeric.h b/src/include/utils/numeric.h
index 7cc597d7b09..7bb56f12916 100644
--- a/src/include/utils/numeric.h
+++ b/src/include/utils/numeric.h
@@ -14,8 +14,6 @@
 #ifndef _PG_NUMERIC_H_
 #define _PG_NUMERIC_H_
 
-#include "fmgr.h"
-
 /*
  * Limit on the precision (and hence scale) specifiable in a NUMERIC typmod.
  * Note that the implementation limit on the length of a numeric value is
diff --git a/src/include/utils/pg_lsn.h b/src/include/utils/pg_lsn.h
index 70d8640ef3e..77eff0c15f1 100644
--- a/src/include/utils/pg_lsn.h
+++ b/src/include/utils/pg_lsn.h
@@ -15,7 +15,6 @@
 #ifndef PG_LSN_H
 #define PG_LSN_H
 
-#include "fmgr.h"
 #include "access/xlogdefs.h"
 
 #define DatumGetLSN(X) ((XLogRecPtr) DatumGetInt64(X))
diff --git a/src/include/utils/timestamp.h b/src/include/utils/timestamp.h
index ea16190ec3d..e6489180675 100644
--- a/src/include/utils/timestamp.h
+++ b/src/include/utils/timestamp.h
@@ -14,7 +14,6 @@
 #define TIMESTAMP_H
 
 #include "datatype/timestamp.h"
-#include "fmgr.h"
 #include "pgtime.h"
 
 
diff --git a/src/include/utils/varbit.h b/src/include/utils/varbit.h
index 641731c4177..0db45b8f95a 100644
--- a/src/include/utils/varbit.h
+++ b/src/include/utils/varbit.h
@@ -17,8 +17,6 @@
 
 #include <limits.h>
 
-#include "fmgr.h"
-
 /*
  * Modeled on struct varlena from postgres.h, but data type is bits8.
  */
diff --git a/src/include/utils/xml.h b/src/include/utils/xml.h
index 90d08b1fcf2..5f96364bc21 100644
--- a/src/include/utils/xml.h
+++ b/src/include/utils/xml.h
@@ -15,7 +15,6 @@
 #ifndef XML_H
 #define XML_H
 
-#include "fmgr.h"
 #include "nodes/execnodes.h"
 #include "nodes/primnodes.h"
 #include "executor/tablefunc.h"
-- 
2.22.0.545.g9c9b961d7e

