From 1c20d0217f0fb88a286a61532340b0c07d1a013a Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Thu, 31 Oct 2019 09:21:38 +0100 Subject: [PATCH 2/3] Replace USE_FLOAT8_BYVAL by FLOAT8PASSBYVAL It's enough to have one macro for the same thing. --- contrib/btree_gist/btree_time.c | 2 +- contrib/btree_gist/btree_ts.c | 2 +- src/backend/access/heap/heapam_handler.c | 2 +- src/backend/access/index/indexam.c | 2 +- src/backend/utils/adt/int8.c | 4 ++-- src/backend/utils/adt/numeric.c | 6 +++--- src/backend/utils/adt/rangetypes_typanalyze.c | 6 +----- src/backend/utils/fmgr/fmgr.c | 2 +- src/include/c.h | 2 -- src/include/postgres.h | 14 +++++++------- 10 files changed, 18 insertions(+), 24 deletions(-) diff --git a/contrib/btree_gist/btree_time.c b/contrib/btree_gist/btree_time.c index 90cf6554ea..884ae21ff6 100644 --- a/contrib/btree_gist/btree_time.c +++ b/contrib/btree_gist/btree_time.c @@ -30,7 +30,7 @@ PG_FUNCTION_INFO_V1(gbt_time_penalty); PG_FUNCTION_INFO_V1(gbt_time_same); -#ifdef USE_FLOAT8_BYVAL +#if FLOAT8PASSBYVAL #define TimeADTGetDatumFast(X) TimeADTGetDatum(X) #else #define TimeADTGetDatumFast(X) PointerGetDatum(&(X)) diff --git a/contrib/btree_gist/btree_ts.c b/contrib/btree_gist/btree_ts.c index 49d1849d88..30864465d2 100644 --- a/contrib/btree_gist/btree_ts.c +++ b/contrib/btree_gist/btree_ts.c @@ -33,7 +33,7 @@ PG_FUNCTION_INFO_V1(gbt_ts_penalty); PG_FUNCTION_INFO_V1(gbt_ts_same); -#ifdef USE_FLOAT8_BYVAL +#if FLOAT8PASSBYVAL #define TimestampGetDatumFast(X) TimestampGetDatum(X) #else #define TimestampGetDatumFast(X) PointerGetDatum(&(X)) diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c index 2dd8821fac..1ae4258670 100644 --- a/src/backend/access/heap/heapam_handler.c +++ b/src/backend/access/heap/heapam_handler.c @@ -1858,7 +1858,7 @@ heapam_index_validate_scan(Relation heapRelation, indexcursor = &decoded; /* If int8 is pass-by-ref, free (encoded) TID Datum memory */ -#ifndef USE_FLOAT8_BYVAL +#if !FLOAT8PASSBYVAL pfree(DatumGetPointer(ts_val)); #endif } diff --git a/src/backend/access/index/indexam.c b/src/backend/access/index/indexam.c index 4af418287d..6a4a1f935c 100644 --- a/src/backend/access/index/indexam.c +++ b/src/backend/access/index/indexam.c @@ -860,7 +860,7 @@ index_store_float8_orderby_distances(IndexScanDesc scan, Oid *orderByTypes, { if (orderByTypes[i] == FLOAT8OID) { -#ifndef USE_FLOAT8_BYVAL +#if !FLOAT8PASSBYVAL /* must free any old value to avoid memory leakage */ if (!scan->xs_orderbynulls[i]) pfree(DatumGetPointer(scan->xs_orderbyvals[i])); diff --git a/src/backend/utils/adt/int8.c b/src/backend/utils/adt/int8.c index 0ff9394a2f..165be75da8 100644 --- a/src/backend/utils/adt/int8.c +++ b/src/backend/utils/adt/int8.c @@ -679,7 +679,7 @@ int8inc(PG_FUNCTION_ARGS) * (If int8 is pass-by-value, then of course this is useless as well as * incorrect, so just ifdef it out.) */ -#ifndef USE_FLOAT8_BYVAL /* controls int8 too */ +#if !FLOAT8PASSBYVAL /* controls int8 too */ if (AggCheckCallContext(fcinfo, NULL)) { int64 *arg = (int64 *) PG_GETARG_POINTER(0); @@ -717,7 +717,7 @@ int8dec(PG_FUNCTION_ARGS) * (If int8 is pass-by-value, then of course this is useless as well as * incorrect, so just ifdef it out.) */ -#ifndef USE_FLOAT8_BYVAL /* controls int8 too */ +#if !FLOAT8PASSBYVAL /* controls int8 too */ if (AggCheckCallContext(fcinfo, NULL)) { int64 *arg = (int64 *) PG_GETARG_POINTER(0); diff --git a/src/backend/utils/adt/numeric.c b/src/backend/utils/adt/numeric.c index 21cc9a8109..318c6a5494 100644 --- a/src/backend/utils/adt/numeric.c +++ b/src/backend/utils/adt/numeric.c @@ -351,7 +351,7 @@ typedef struct NumericSumAccum /* * We define our own macros for packing and unpacking abbreviated-key * representations for numeric values in order to avoid depending on - * USE_FLOAT8_BYVAL, which was previously build-time configurable. The type + * FLOAT8PASSBYVAL, which was previously build-time configurable. The type * of abbreviation we use is based only on the size of a datum, not the * argument-passing convention for float8. */ @@ -5301,7 +5301,7 @@ int2_sum(PG_FUNCTION_ARGS) * then of course this is useless as well as incorrect, so just ifdef it * out.) */ -#ifndef USE_FLOAT8_BYVAL /* controls int8 too */ +#if !FLOAT8PASSBYVAL /* controls int8 too */ if (AggCheckCallContext(fcinfo, NULL)) { int64 *oldsum = (int64 *) PG_GETARG_POINTER(0); @@ -5350,7 +5350,7 @@ int4_sum(PG_FUNCTION_ARGS) * then of course this is useless as well as incorrect, so just ifdef it * out.) */ -#ifndef USE_FLOAT8_BYVAL /* controls int8 too */ +#if !FLOAT8PASSBYVAL /* controls int8 too */ if (AggCheckCallContext(fcinfo, NULL)) { int64 *oldsum = (int64 *) PG_GETARG_POINTER(0); diff --git a/src/backend/utils/adt/rangetypes_typanalyze.c b/src/backend/utils/adt/rangetypes_typanalyze.c index d01d3032cc..b438625951 100644 --- a/src/backend/utils/adt/rangetypes_typanalyze.c +++ b/src/backend/utils/adt/rangetypes_typanalyze.c @@ -325,11 +325,7 @@ compute_range_stats(VacAttrStats *stats, AnalyzeAttrFetchFunc fetchfunc, stats->numvalues[slot_idx] = num_hist; stats->statypid[slot_idx] = FLOAT8OID; stats->statyplen[slot_idx] = sizeof(float8); -#ifdef USE_FLOAT8_BYVAL - stats->statypbyval[slot_idx] = true; -#else - stats->statypbyval[slot_idx] = false; -#endif + stats->statypbyval[slot_idx] = FLOAT8PASSBYVAL; stats->statypalign[slot_idx] = 'd'; /* Store the fraction of empty ranges */ diff --git a/src/backend/utils/fmgr/fmgr.c b/src/backend/utils/fmgr/fmgr.c index c2eaa6178d..d73fe59a26 100644 --- a/src/backend/utils/fmgr/fmgr.c +++ b/src/backend/utils/fmgr/fmgr.c @@ -1687,7 +1687,7 @@ OidSendFunctionCall(Oid functionId, Datum val) *------------------------------------------------------------------------- */ -#ifndef USE_FLOAT8_BYVAL /* controls int8 too */ +#if !FLOAT8PASSBYVAL /* controls int8 too */ Datum Int64GetDatum(int64 X) diff --git a/src/include/c.h b/src/include/c.h index ab9cb73a4c..26d50495e6 100644 --- a/src/include/c.h +++ b/src/include/c.h @@ -499,10 +499,8 @@ typedef double float8; */ #if SIZEOF_VOID_P >= 8 #define FLOAT8PASSBYVAL true -#define USE_FLOAT8_BYVAL 1 #else #define FLOAT8PASSBYVAL false -#undef USE_FLOAT8_BYVAL #endif /* diff --git a/src/include/postgres.h b/src/include/postgres.h index f5b7c52f8a..bf4b6223f3 100644 --- a/src/include/postgres.h +++ b/src/include/postgres.h @@ -601,7 +601,7 @@ typedef struct NullableDatum * Note: this macro hides whether int64 is pass by value or by reference. */ -#ifdef USE_FLOAT8_BYVAL +#if FLOAT8PASSBYVAL #define DatumGetInt64(X) ((int64) (X)) #else #define DatumGetInt64(X) (* ((int64 *) DatumGetPointer(X))) @@ -615,7 +615,7 @@ typedef struct NullableDatum * to palloc'd space. */ -#ifdef USE_FLOAT8_BYVAL +#if FLOAT8PASSBYVAL #define Int64GetDatum(X) ((Datum) (X)) #else extern Datum Int64GetDatum(int64 X); @@ -628,7 +628,7 @@ extern Datum Int64GetDatum(int64 X); * Note: this macro hides whether int64 is pass by value or by reference. */ -#ifdef USE_FLOAT8_BYVAL +#if FLOAT8PASSBYVAL #define DatumGetUInt64(X) ((uint64) (X)) #else #define DatumGetUInt64(X) (* ((uint64 *) DatumGetPointer(X))) @@ -642,7 +642,7 @@ extern Datum Int64GetDatum(int64 X); * to palloc'd space. */ -#ifdef USE_FLOAT8_BYVAL +#if FLOAT8PASSBYVAL #define UInt64GetDatum(X) ((Datum) (X)) #else #define UInt64GetDatum(X) Int64GetDatum((int64) (X)) @@ -697,7 +697,7 @@ Float4GetDatum(float4 X) * Note: this macro hides whether float8 is pass by value or by reference. */ -#ifdef USE_FLOAT8_BYVAL +#if FLOAT8PASSBYVAL static inline float8 DatumGetFloat8(Datum X) { @@ -722,7 +722,7 @@ DatumGetFloat8(Datum X) * to palloc'd space. */ -#ifdef USE_FLOAT8_BYVAL +#if FLOAT8PASSBYVAL static inline Datum Float8GetDatum(float8 X) { @@ -753,7 +753,7 @@ extern Datum Float8GetDatum(float8 X); * macros. */ -#ifdef USE_FLOAT8_BYVAL +#if FLOAT8PASSBYVAL #define Int64GetDatumFast(X) Int64GetDatum(X) #define Float8GetDatumFast(X) Float8GetDatum(X) #else -- 2.23.0