diff --git a/src/include/postgres.h b/src/include/postgres.h
index 45c9f6563c..5f6a1e3d5a 100644
--- a/src/include/postgres.h
+++ b/src/include/postgres.h
@@ -884,34 +884,26 @@ extern Datum Float8GetDatum(float8 X);
  * Int64GetDatumFast
  * Float8GetDatumFast
  *
- * These functions are intended to allow writing code that does not depend on
+ * These macros are intended to allow writing code that does not depend on
  * whether int64 and float8 are pass-by-reference types, while not
  * sacrificing performance when they are.  The argument must be a variable
  * that will exist and have the same value for as long as the Datum is needed.
  * In the pass-by-ref case, the address of the variable is taken to use as
- * the Datum.  In the pass-by-val case, these will be the same as the non-Fast
- * functions.
+ * the Datum.  In the pass-by-val case, these are the same as the non-Fast
+ * functions, except for asserting that the variable is of the correct type.
  */
 
-static inline Datum
-Int64GetDatumFast(int64 X)
-{
-#ifdef USE_FLOAT8_BYVAL
-	return Int64GetDatum(X);
-#else
-	return PointerGetDatum(&X);
-#endif
-}
-
-static inline Datum
-Float8GetDatumFast(float8 X)
-{
 #ifdef USE_FLOAT8_BYVAL
-	return Float8GetDatum(X);
+#define Int64GetDatumFast(X) \
+	(AssertVariableIsOfTypeMacro(X, int64), Int64GetDatum(X))
+#define Float8GetDatumFast(X) \
+	(AssertVariableIsOfTypeMacro(X, double), Float8GetDatum(X))
 #else
-	return PointerGetDatum(&X);
+#define Int64GetDatumFast(X) \
+	(AssertVariableIsOfTypeMacro(X, int64), PointerGetDatum(&(X)))
+#define Float8GetDatumFast(X) \
+	(AssertVariableIsOfTypeMacro(X, double), PointerGetDatum(&(X)))
 #endif
-}
 
 
 /* ----------------------------------------------------------------
