0003-Convert-some-if-calls-to-compiler-if-s.patch

text/plain

Filename: 0003-Convert-some-if-calls-to-compiler-if-s.patch
Type: text/plain
Part: 2
Message: Remove configure --disable-float4-byval and --disable-float8-byval

Patch

Format: format-patch
Series: patch 0003
Subject: Convert some #if calls to compiler if()s
File+
src/backend/access/heap/heapam_handler.c 2 3
src/backend/access/index/indexam.c 6 5
src/backend/utils/adt/int8.c 4 8
src/backend/utils/adt/numeric.c 4 10
From 9c38db227b7f2154b5a06c4ff42a43f8835b9929 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Thu, 31 Oct 2019 09:21:38 +0100
Subject: [PATCH 3/3] Convert some #if calls to compiler if()s

This ensures that the contained code is looked at by the compiler and
does not bit rot.  This is especially interesting as the affected code
is for the lesser-used 32-bit builds.
---
 src/backend/access/heap/heapam_handler.c |  5 ++---
 src/backend/access/index/indexam.c       | 11 ++++++-----
 src/backend/utils/adt/int8.c             | 12 ++++--------
 src/backend/utils/adt/numeric.c          | 14 ++++----------
 4 files changed, 16 insertions(+), 26 deletions(-)

diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index 1ae4258670..a002916a73 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -1858,9 +1858,8 @@ heapam_index_validate_scan(Relation heapRelation,
 				indexcursor = &decoded;
 
 				/* If int8 is pass-by-ref, free (encoded) TID Datum memory */
-#if !FLOAT8PASSBYVAL
-				pfree(DatumGetPointer(ts_val));
-#endif
+				if (!FLOAT8PASSBYVAL)
+					pfree(DatumGetPointer(ts_val));
 			}
 			else
 			{
diff --git a/src/backend/access/index/indexam.c b/src/backend/access/index/indexam.c
index 6a4a1f935c..934c41c1be 100644
--- a/src/backend/access/index/indexam.c
+++ b/src/backend/access/index/indexam.c
@@ -860,11 +860,12 @@ index_store_float8_orderby_distances(IndexScanDesc scan, Oid *orderByTypes,
 	{
 		if (orderByTypes[i] == FLOAT8OID)
 		{
-#if !FLOAT8PASSBYVAL
-			/* must free any old value to avoid memory leakage */
-			if (!scan->xs_orderbynulls[i])
-				pfree(DatumGetPointer(scan->xs_orderbyvals[i]));
-#endif
+			if (!FLOAT8PASSBYVAL)
+			{
+				/* must free any old value to avoid memory leakage */
+				if (!scan->xs_orderbynulls[i])
+					pfree(DatumGetPointer(scan->xs_orderbyvals[i]));
+			}
 			if (distances && !distances[i].isnull)
 			{
 				scan->xs_orderbyvals[i] = Float8GetDatum(distances[i].value);
diff --git a/src/backend/utils/adt/int8.c b/src/backend/utils/adt/int8.c
index 165be75da8..3f25ff6b64 100644
--- a/src/backend/utils/adt/int8.c
+++ b/src/backend/utils/adt/int8.c
@@ -677,10 +677,9 @@ int8inc(PG_FUNCTION_ARGS)
 	 * palloc overhead for COUNT(): when called as an aggregate, we know that
 	 * the argument is modifiable local storage, so just update it in-place.
 	 * (If int8 is pass-by-value, then of course this is useless as well as
-	 * incorrect, so just ifdef it out.)
+	 * incorrect.)
 	 */
-#if !FLOAT8PASSBYVAL		/* controls int8 too */
-	if (AggCheckCallContext(fcinfo, NULL))
+	if (!FLOAT8PASSBYVAL && AggCheckCallContext(fcinfo, NULL))
 	{
 		int64	   *arg = (int64 *) PG_GETARG_POINTER(0);
 
@@ -692,7 +691,6 @@ int8inc(PG_FUNCTION_ARGS)
 		PG_RETURN_POINTER(arg);
 	}
 	else
-#endif
 	{
 		/* Not called as an aggregate, so just do it the dumb way */
 		int64		arg = PG_GETARG_INT64(0);
@@ -715,10 +713,9 @@ int8dec(PG_FUNCTION_ARGS)
 	 * palloc overhead for COUNT(): when called as an aggregate, we know that
 	 * the argument is modifiable local storage, so just update it in-place.
 	 * (If int8 is pass-by-value, then of course this is useless as well as
-	 * incorrect, so just ifdef it out.)
+	 * incorrect.)
 	 */
-#if !FLOAT8PASSBYVAL		/* controls int8 too */
-	if (AggCheckCallContext(fcinfo, NULL))
+	if (!FLOAT8PASSBYVAL && AggCheckCallContext(fcinfo, NULL))
 	{
 		int64	   *arg = (int64 *) PG_GETARG_POINTER(0);
 
@@ -729,7 +726,6 @@ int8dec(PG_FUNCTION_ARGS)
 		PG_RETURN_POINTER(arg);
 	}
 	else
-#endif
 	{
 		/* Not called as an aggregate, so just do it the dumb way */
 		int64		arg = PG_GETARG_INT64(0);
diff --git a/src/backend/utils/adt/numeric.c b/src/backend/utils/adt/numeric.c
index 318c6a5494..d6eae74a35 100644
--- a/src/backend/utils/adt/numeric.c
+++ b/src/backend/utils/adt/numeric.c
@@ -5298,11 +5298,9 @@ int2_sum(PG_FUNCTION_ARGS)
 	 * If we're invoked as an aggregate, we can cheat and modify our first
 	 * parameter in-place to avoid palloc overhead. If not, we need to return
 	 * the new value of the transition variable. (If int8 is pass-by-value,
-	 * then of course this is useless as well as incorrect, so just ifdef it
-	 * out.)
+	 * then of course this is useless as well as incorrect.)
 	 */
-#if !FLOAT8PASSBYVAL		/* controls int8 too */
-	if (AggCheckCallContext(fcinfo, NULL))
+	if (!FLOAT8PASSBYVAL && AggCheckCallContext(fcinfo, NULL))
 	{
 		int64	   *oldsum = (int64 *) PG_GETARG_POINTER(0);
 
@@ -5313,7 +5311,6 @@ int2_sum(PG_FUNCTION_ARGS)
 		PG_RETURN_POINTER(oldsum);
 	}
 	else
-#endif
 	{
 		int64		oldsum = PG_GETARG_INT64(0);
 
@@ -5347,11 +5344,9 @@ int4_sum(PG_FUNCTION_ARGS)
 	 * If we're invoked as an aggregate, we can cheat and modify our first
 	 * parameter in-place to avoid palloc overhead. If not, we need to return
 	 * the new value of the transition variable. (If int8 is pass-by-value,
-	 * then of course this is useless as well as incorrect, so just ifdef it
-	 * out.)
+	 * then of course this is useless as well as incorrect.)
 	 */
-#if !FLOAT8PASSBYVAL		/* controls int8 too */
-	if (AggCheckCallContext(fcinfo, NULL))
+	if (!FLOAT8PASSBYVAL && AggCheckCallContext(fcinfo, NULL))
 	{
 		int64	   *oldsum = (int64 *) PG_GETARG_POINTER(0);
 
@@ -5362,7 +5357,6 @@ int4_sum(PG_FUNCTION_ARGS)
 		PG_RETURN_POINTER(oldsum);
 	}
 	else
-#endif
 	{
 		int64		oldsum = PG_GETARG_INT64(0);
 
-- 
2.23.0