summaryrefslogtreecommitdiff
path: root/src/backend/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/utils')
-rw-r--r--src/backend/utils/adt/arrayfuncs.c6
-rw-r--r--src/backend/utils/adt/int8.c75
-rw-r--r--src/backend/utils/adt/mac.c27
-rw-r--r--src/backend/utils/adt/network.c54
-rw-r--r--src/backend/utils/adt/numeric.c191
-rw-r--r--src/backend/utils/adt/orderedsetaggs.c2
-rw-r--r--src/backend/utils/adt/rangetypes_typanalyze.c2
-rw-r--r--src/backend/utils/adt/timestamp.c21
-rw-r--r--src/backend/utils/adt/uuid.c6
-rw-r--r--src/backend/utils/adt/varlena.c27
-rw-r--r--src/backend/utils/fmgr/fmgr.c35
-rw-r--r--src/backend/utils/resowner/resowner.c7
-rw-r--r--src/backend/utils/sort/tuplesort.c8
13 files changed, 83 insertions, 378 deletions
diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c
index c8f53c6fbe7..c833e7df1fd 100644
--- a/src/backend/utils/adt/arrayfuncs.c
+++ b/src/backend/utils/adt/arrayfuncs.c
@@ -3406,7 +3406,7 @@ construct_array_builtin(Datum *elems, int nelems, Oid elmtype)
case FLOAT8OID:
elmlen = sizeof(float8);
- elmbyval = FLOAT8PASSBYVAL;
+ elmbyval = true;
elmalign = TYPALIGN_DOUBLE;
break;
@@ -3424,7 +3424,7 @@ construct_array_builtin(Datum *elems, int nelems, Oid elmtype)
case INT8OID:
elmlen = sizeof(int64);
- elmbyval = FLOAT8PASSBYVAL;
+ elmbyval = true;
elmalign = TYPALIGN_DOUBLE;
break;
@@ -3718,7 +3718,7 @@ deconstruct_array_builtin(ArrayType *array,
case FLOAT8OID:
elmlen = sizeof(float8);
- elmbyval = FLOAT8PASSBYVAL;
+ elmbyval = true;
elmalign = TYPALIGN_DOUBLE;
break;
diff --git a/src/backend/utils/adt/int8.c b/src/backend/utils/adt/int8.c
index 9dd5889f34c..bdea490202a 100644
--- a/src/backend/utils/adt/int8.c
+++ b/src/backend/utils/adt/int8.c
@@ -718,76 +718,29 @@ int8lcm(PG_FUNCTION_ARGS)
Datum
int8inc(PG_FUNCTION_ARGS)
{
- /*
- * When int8 is pass-by-reference, we provide this special case to avoid
- * 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.)
- */
-#ifndef USE_FLOAT8_BYVAL /* controls int8 too */
- if (AggCheckCallContext(fcinfo, NULL))
- {
- int64 *arg = (int64 *) PG_GETARG_POINTER(0);
-
- if (unlikely(pg_add_s64_overflow(*arg, 1, arg)))
- ereport(ERROR,
- (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
- errmsg("bigint out of range")));
-
- PG_RETURN_POINTER(arg);
- }
- else
-#endif
- {
- /* Not called as an aggregate, so just do it the dumb way */
- int64 arg = PG_GETARG_INT64(0);
- int64 result;
+ int64 arg = PG_GETARG_INT64(0);
+ int64 result;
- if (unlikely(pg_add_s64_overflow(arg, 1, &result)))
- ereport(ERROR,
- (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
- errmsg("bigint out of range")));
+ if (unlikely(pg_add_s64_overflow(arg, 1, &result)))
+ ereport(ERROR,
+ (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
+ errmsg("bigint out of range")));
- PG_RETURN_INT64(result);
- }
+ PG_RETURN_INT64(result);
}
Datum
int8dec(PG_FUNCTION_ARGS)
{
- /*
- * When int8 is pass-by-reference, we provide this special case to avoid
- * 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.)
- */
-#ifndef USE_FLOAT8_BYVAL /* controls int8 too */
- if (AggCheckCallContext(fcinfo, NULL))
- {
- int64 *arg = (int64 *) PG_GETARG_POINTER(0);
-
- if (unlikely(pg_sub_s64_overflow(*arg, 1, arg)))
- ereport(ERROR,
- (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
- errmsg("bigint out of range")));
- PG_RETURN_POINTER(arg);
- }
- else
-#endif
- {
- /* Not called as an aggregate, so just do it the dumb way */
- int64 arg = PG_GETARG_INT64(0);
- int64 result;
+ int64 arg = PG_GETARG_INT64(0);
+ int64 result;
- if (unlikely(pg_sub_s64_overflow(arg, 1, &result)))
- ereport(ERROR,
- (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
- errmsg("bigint out of range")));
+ if (unlikely(pg_sub_s64_overflow(arg, 1, &result)))
+ ereport(ERROR,
+ (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
+ errmsg("bigint out of range")));
- PG_RETURN_INT64(result);
- }
+ PG_RETURN_INT64(result);
}
diff --git a/src/backend/utils/adt/mac.c b/src/backend/utils/adt/mac.c
index 3644e9735f5..bb38ef2f5e4 100644
--- a/src/backend/utils/adt/mac.c
+++ b/src/backend/utils/adt/mac.c
@@ -481,33 +481,26 @@ macaddr_abbrev_convert(Datum original, SortSupport ssup)
Datum res;
/*
- * On a 64-bit machine, zero out the 8-byte datum and copy the 6 bytes of
- * the MAC address in. There will be two bytes of zero padding on the end
- * of the least significant bits.
+ * Zero out the 8-byte Datum and copy in the 6 bytes of the MAC address.
+ * There will be two bytes of zero padding on the end of the least
+ * significant bits.
*/
-#if SIZEOF_DATUM == 8
- memset(&res, 0, SIZEOF_DATUM);
+ StaticAssertStmt(sizeof(res) >= sizeof(macaddr),
+ "Datum is too small for macaddr");
+ memset(&res, 0, sizeof(res));
memcpy(&res, authoritative, sizeof(macaddr));
-#else /* SIZEOF_DATUM != 8 */
- memcpy(&res, authoritative, SIZEOF_DATUM);
-#endif
uss->input_count += 1;
/*
- * Cardinality estimation. The estimate uses uint32, so on a 64-bit
- * architecture, XOR the two 32-bit halves together to produce slightly
- * more entropy. The two zeroed bytes won't have any practical impact on
- * this operation.
+ * Cardinality estimation. The estimate uses uint32, so XOR the two 32-bit
+ * halves together to produce slightly more entropy. The two zeroed bytes
+ * won't have any practical impact on this operation.
*/
if (uss->estimating)
{
uint32 tmp;
-#if SIZEOF_DATUM == 8
- tmp = (uint32) res ^ (uint32) ((uint64) res >> 32);
-#else /* SIZEOF_DATUM != 8 */
- tmp = (uint32) res;
-#endif
+ tmp = DatumGetUInt32(res) ^ (uint32) (DatumGetUInt64(res) >> 32);
addHyperLogLog(&uss->abbr_card, DatumGetUInt32(hash_uint32(tmp)));
}
diff --git a/src/backend/utils/adt/network.c b/src/backend/utils/adt/network.c
index 9fd211b2d45..3cb0ab6829a 100644
--- a/src/backend/utils/adt/network.c
+++ b/src/backend/utils/adt/network.c
@@ -567,24 +567,11 @@ network_abbrev_abort(int memtupcount, SortSupport ssup)
*
* When generating abbreviated keys for SortSupport, we pack as much as we can
* into a datum while ensuring that when comparing those keys as integers,
- * these rules will be respected. Exact contents depend on IP family and datum
- * size.
+ * these rules will be respected. Exact contents depend on IP family:
*
* IPv4
* ----
*
- * 4 byte datums:
- *
- * Start with 1 bit for the IP family (IPv4 or IPv6; this bit is present in
- * every case below) followed by all but 1 of the netmasked bits.
- *
- * +----------+---------------------+
- * | 1 bit IP | 31 bits network | (1 bit network
- * | family | (truncated) | omitted)
- * +----------+---------------------+
- *
- * 8 byte datums:
- *
* We have space to store all netmasked bits, followed by the netmask size,
* followed by 25 bits of the subnet (25 bits is usually more than enough in
* practice). cidr datums always have all-zero subnet bits.
@@ -597,15 +584,6 @@ network_abbrev_abort(int memtupcount, SortSupport ssup)
* IPv6
* ----
*
- * 4 byte datums:
- *
- * +----------+---------------------+
- * | 1 bit IP | 31 bits network | (up to 97 bits
- * | family | (truncated) | network omitted)
- * +----------+---------------------+
- *
- * 8 byte datums:
- *
* +----------+---------------------------------+
* | 1 bit IP | 63 bits network | (up to 65 bits
* | family | (truncated) | network omitted)
@@ -628,8 +606,7 @@ network_abbrev_convert(Datum original, SortSupport ssup)
/*
* Get an unsigned integer representation of the IP address by taking its
* first 4 or 8 bytes. Always take all 4 bytes of an IPv4 address. Take
- * the first 8 bytes of an IPv6 address with an 8 byte datum and 4 bytes
- * otherwise.
+ * the first 8 bytes of an IPv6 address.
*
* We're consuming an array of unsigned char, so byteswap on little endian
* systems (an inet's ipaddr field stores the most significant byte
@@ -659,7 +636,7 @@ network_abbrev_convert(Datum original, SortSupport ssup)
ipaddr_datum = DatumBigEndianToNative(ipaddr_datum);
/* Initialize result with ipfamily (most significant) bit set */
- res = ((Datum) 1) << (SIZEOF_DATUM * BITS_PER_BYTE - 1);
+ res = ((Datum) 1) << (sizeof(Datum) * BITS_PER_BYTE - 1);
}
/*
@@ -668,8 +645,7 @@ network_abbrev_convert(Datum original, SortSupport ssup)
* while low order bits go in "subnet" component when there is space for
* one. This is often accomplished by generating a temp datum subnet
* bitmask, which we may reuse later when generating the subnet bits
- * themselves. (Note that subnet bits are only used with IPv4 datums on
- * platforms where datum is 8 bytes.)
+ * themselves.
*
* The number of bits in subnet is used to generate a datum subnet
* bitmask. For example, with a /24 IPv4 datum there are 8 subnet bits
@@ -681,14 +657,14 @@ network_abbrev_convert(Datum original, SortSupport ssup)
subnet_size = ip_maxbits(authoritative) - ip_bits(authoritative);
Assert(subnet_size >= 0);
/* subnet size must work with prefix ipaddr cases */
- subnet_size %= SIZEOF_DATUM * BITS_PER_BYTE;
+ subnet_size %= sizeof(Datum) * BITS_PER_BYTE;
if (ip_bits(authoritative) == 0)
{
/* Fit as many ipaddr bits as possible into subnet */
subnet_bitmask = ((Datum) 0) - 1;
network = 0;
}
- else if (ip_bits(authoritative) < SIZEOF_DATUM * BITS_PER_BYTE)
+ else if (ip_bits(authoritative) < sizeof(Datum) * BITS_PER_BYTE)
{
/* Split ipaddr bits between network and subnet */
subnet_bitmask = (((Datum) 1) << subnet_size) - 1;
@@ -701,12 +677,11 @@ network_abbrev_convert(Datum original, SortSupport ssup)
network = ipaddr_datum;
}
-#if SIZEOF_DATUM == 8
if (ip_family(authoritative) == PGSQL_AF_INET)
{
/*
- * IPv4 with 8 byte datums: keep all 32 netmasked bits, netmask size,
- * and most significant 25 subnet bits
+ * IPv4: keep all 32 netmasked bits, netmask size, and most
+ * significant 25 subnet bits
*/
Datum netmask_size = (Datum) ip_bits(authoritative);
Datum subnet;
@@ -750,12 +725,11 @@ network_abbrev_convert(Datum original, SortSupport ssup)
res |= network | netmask_size | subnet;
}
else
-#endif
{
/*
- * 4 byte datums, or IPv6 with 8 byte datums: Use as many of the
- * netmasked bits as will fit in final abbreviated key. Avoid
- * clobbering the ipfamily bit that was set earlier.
+ * IPv6: Use as many of the netmasked bits as will fit in final
+ * abbreviated key. Avoid clobbering the ipfamily bit that was set
+ * earlier.
*/
res |= network >> 1;
}
@@ -767,11 +741,7 @@ network_abbrev_convert(Datum original, SortSupport ssup)
{
uint32 tmp;
-#if SIZEOF_DATUM == 8
- tmp = (uint32) res ^ (uint32) ((uint64) res >> 32);
-#else /* SIZEOF_DATUM != 8 */
- tmp = (uint32) res;
-#endif
+ tmp = DatumGetUInt32(res) ^ (uint32) (DatumGetUInt64(res) >> 32);
addHyperLogLog(&uss->abbr_card, DatumGetUInt32(hash_uint32(tmp)));
}
diff --git a/src/backend/utils/adt/numeric.c b/src/backend/utils/adt/numeric.c
index 122f2efab8b..b6287f5d973 100644
--- a/src/backend/utils/adt/numeric.c
+++ b/src/backend/utils/adt/numeric.c
@@ -392,30 +392,21 @@ 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. The type of abbreviation we use is based only on
- * the size of a datum, not the argument-passing convention for float8.
+ * representations, just to have a notational indication that that's
+ * what we're doing. Now that sizeof(Datum) is always 8, we can rely
+ * on fitting an int64 into Datum.
*
- * The range of abbreviations for finite values is from +PG_INT64/32_MAX
- * to -PG_INT64/32_MAX. NaN has the abbreviation PG_INT64/32_MIN, and we
+ * The range of abbreviations for finite values is from +PG_INT64_MAX
+ * to -PG_INT64_MAX. NaN has the abbreviation PG_INT64_MIN, and we
* define the sort ordering to make that work out properly (see further
* comments below). PINF and NINF share the abbreviations of the largest
* and smallest finite abbreviation classes.
*/
-#define NUMERIC_ABBREV_BITS (SIZEOF_DATUM * BITS_PER_BYTE)
-#if SIZEOF_DATUM == 8
-#define NumericAbbrevGetDatum(X) ((Datum) (X))
-#define DatumGetNumericAbbrev(X) ((int64) (X))
+#define NumericAbbrevGetDatum(X) Int64GetDatum(X)
+#define DatumGetNumericAbbrev(X) DatumGetInt64(X)
#define NUMERIC_ABBREV_NAN NumericAbbrevGetDatum(PG_INT64_MIN)
#define NUMERIC_ABBREV_PINF NumericAbbrevGetDatum(-PG_INT64_MAX)
#define NUMERIC_ABBREV_NINF NumericAbbrevGetDatum(PG_INT64_MAX)
-#else
-#define NumericAbbrevGetDatum(X) ((Datum) (X))
-#define DatumGetNumericAbbrev(X) ((int32) (X))
-#define NUMERIC_ABBREV_NAN NumericAbbrevGetDatum(PG_INT32_MIN)
-#define NUMERIC_ABBREV_PINF NumericAbbrevGetDatum(-PG_INT32_MAX)
-#define NUMERIC_ABBREV_NINF NumericAbbrevGetDatum(PG_INT32_MAX)
-#endif
/* ----------
@@ -2096,12 +2087,11 @@ compute_bucket(Numeric operand, Numeric bound1, Numeric bound2,
* while this could be worked on itself, the abbreviation strategy gives more
* speedup in many common cases.
*
- * Two different representations are used for the abbreviated form, one in
- * int32 and one in int64, whichever fits into a by-value Datum. In both cases
- * the representation is negated relative to the original value, because we use
- * the largest negative value for NaN, which sorts higher than other values. We
- * convert the absolute value of the numeric to a 31-bit or 63-bit positive
- * value, and then negate it if the original number was positive.
+ * The abbreviated format is an int64. The representation is negated relative
+ * to the original value, because we use the largest negative value for NaN,
+ * which sorts higher than other values. We convert the absolute value of the
+ * numeric to a 63-bit positive value, and then negate it if the original
+ * number was positive.
*
* We abort the abbreviation process if the abbreviation cardinality is below
* 0.01% of the row count (1 per 10k non-null rows). The actual break-even
@@ -2328,7 +2318,7 @@ numeric_cmp_abbrev(Datum x, Datum y, SortSupport ssup)
}
/*
- * Abbreviate a NumericVar according to the available bit size.
+ * Abbreviate a NumericVar into the 64-bit sortsupport size.
*
* The 31-bit value is constructed as:
*
@@ -2372,9 +2362,6 @@ numeric_cmp_abbrev(Datum x, Datum y, SortSupport ssup)
* with all bits zero. This allows simple comparisons to work on the composite
* value.
*/
-
-#if NUMERIC_ABBREV_BITS == 64
-
static Datum
numeric_abbrev_convert_var(const NumericVar *var, NumericSortSupport *nss)
{
@@ -2426,84 +2413,6 @@ numeric_abbrev_convert_var(const NumericVar *var, NumericSortSupport *nss)
return NumericAbbrevGetDatum(result);
}
-#endif /* NUMERIC_ABBREV_BITS == 64 */
-
-#if NUMERIC_ABBREV_BITS == 32
-
-static Datum
-numeric_abbrev_convert_var(const NumericVar *var, NumericSortSupport *nss)
-{
- int ndigits = var->ndigits;
- int weight = var->weight;
- int32 result;
-
- if (ndigits == 0 || weight < -11)
- {
- result = 0;
- }
- else if (weight > 20)
- {
- result = PG_INT32_MAX;
- }
- else
- {
- NumericDigit nxt1 = (ndigits > 1) ? var->digits[1] : 0;
-
- weight = (weight + 11) * 4;
-
- result = var->digits[0];
-
- /*
- * "result" now has 1 to 4 nonzero decimal digits. We pack in more
- * digits to make 7 in total (largest we can fit in 24 bits)
- */
-
- if (result > 999)
- {
- /* already have 4 digits, add 3 more */
- result = (result * 1000) + (nxt1 / 10);
- weight += 3;
- }
- else if (result > 99)
- {
- /* already have 3 digits, add 4 more */
- result = (result * 10000) + nxt1;
- weight += 2;
- }
- else if (result > 9)
- {
- NumericDigit nxt2 = (ndigits > 2) ? var->digits[2] : 0;
-
- /* already have 2 digits, add 5 more */
- result = (result * 100000) + (nxt1 * 10) + (nxt2 / 1000);
- weight += 1;
- }
- else
- {
- NumericDigit nxt2 = (ndigits > 2) ? var->digits[2] : 0;
-
- /* already have 1 digit, add 6 more */
- result = (result * 1000000) + (nxt1 * 100) + (nxt2 / 100);
- }
-
- result = result | (weight << 24);
- }
-
- /* the abbrev is negated relative to the original */
- if (var->sign == NUMERIC_POS)
- result = -result;
-
- if (nss->estimating)
- {
- uint32 tmp = (uint32) result;
-
- addHyperLogLog(&nss->abbr_card, DatumGetUInt32(hash_uint32(tmp)));
- }
-
- return NumericAbbrevGetDatum(result);
-}
-
-#endif /* NUMERIC_ABBREV_BITS == 32 */
/*
* Ordinary (non-sortsupport) comparisons follow.
@@ -6453,6 +6362,7 @@ numeric_poly_stddev_pop(PG_FUNCTION_ARGS)
Datum
int2_sum(PG_FUNCTION_ARGS)
{
+ int64 oldsum;
int64 newval;
if (PG_ARGISNULL(0))
@@ -6465,43 +6375,22 @@ int2_sum(PG_FUNCTION_ARGS)
PG_RETURN_INT64(newval);
}
- /*
- * 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.)
- */
-#ifndef USE_FLOAT8_BYVAL /* controls int8 too */
- if (AggCheckCallContext(fcinfo, NULL))
- {
- int64 *oldsum = (int64 *) PG_GETARG_POINTER(0);
-
- /* Leave the running sum unchanged in the new input is null */
- if (!PG_ARGISNULL(1))
- *oldsum = *oldsum + (int64) PG_GETARG_INT16(1);
+ oldsum = PG_GETARG_INT64(0);
- PG_RETURN_POINTER(oldsum);
- }
- else
-#endif
- {
- int64 oldsum = PG_GETARG_INT64(0);
-
- /* Leave sum unchanged if new input is null. */
- if (PG_ARGISNULL(1))
- PG_RETURN_INT64(oldsum);
+ /* Leave sum unchanged if new input is null. */
+ if (PG_ARGISNULL(1))
+ PG_RETURN_INT64(oldsum);
- /* OK to do the addition. */
- newval = oldsum + (int64) PG_GETARG_INT16(1);
+ /* OK to do the addition. */
+ newval = oldsum + (int64) PG_GETARG_INT16(1);
- PG_RETURN_INT64(newval);
- }
+ PG_RETURN_INT64(newval);
}
Datum
int4_sum(PG_FUNCTION_ARGS)
{
+ int64 oldsum;
int64 newval;
if (PG_ARGISNULL(0))
@@ -6514,38 +6403,16 @@ int4_sum(PG_FUNCTION_ARGS)
PG_RETURN_INT64(newval);
}
- /*
- * 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.)
- */
-#ifndef USE_FLOAT8_BYVAL /* controls int8 too */
- if (AggCheckCallContext(fcinfo, NULL))
- {
- int64 *oldsum = (int64 *) PG_GETARG_POINTER(0);
+ oldsum = PG_GETARG_INT64(0);
- /* Leave the running sum unchanged in the new input is null */
- if (!PG_ARGISNULL(1))
- *oldsum = *oldsum + (int64) PG_GETARG_INT32(1);
-
- PG_RETURN_POINTER(oldsum);
- }
- else
-#endif
- {
- int64 oldsum = PG_GETARG_INT64(0);
-
- /* Leave sum unchanged if new input is null. */
- if (PG_ARGISNULL(1))
- PG_RETURN_INT64(oldsum);
+ /* Leave sum unchanged if new input is null. */
+ if (PG_ARGISNULL(1))
+ PG_RETURN_INT64(oldsum);
- /* OK to do the addition. */
- newval = oldsum + (int64) PG_GETARG_INT32(1);
+ /* OK to do the addition. */
+ newval = oldsum + (int64) PG_GETARG_INT32(1);
- PG_RETURN_INT64(newval);
- }
+ PG_RETURN_INT64(newval);
}
/*
diff --git a/src/backend/utils/adt/orderedsetaggs.c b/src/backend/utils/adt/orderedsetaggs.c
index 9457d239715..c41b191be62 100644
--- a/src/backend/utils/adt/orderedsetaggs.c
+++ b/src/backend/utils/adt/orderedsetaggs.c
@@ -1007,7 +1007,7 @@ percentile_cont_float8_multi_final(PG_FUNCTION_ARGS)
FLOAT8OID,
/* hard-wired info on type float8 */
sizeof(float8),
- FLOAT8PASSBYVAL,
+ true,
TYPALIGN_DOUBLE,
float8_lerp);
}
diff --git a/src/backend/utils/adt/rangetypes_typanalyze.c b/src/backend/utils/adt/rangetypes_typanalyze.c
index a18196d8a34..36e885af2dd 100644
--- a/src/backend/utils/adt/rangetypes_typanalyze.c
+++ b/src/backend/utils/adt/rangetypes_typanalyze.c
@@ -397,7 +397,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);
- stats->statypbyval[slot_idx] = FLOAT8PASSBYVAL;
+ stats->statypbyval[slot_idx] = true;
stats->statypalign[slot_idx] = 'd';
/* Store the fraction of empty ranges */
diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c
index e640b48205b..3e5f9dc1458 100644
--- a/src/backend/utils/adt/timestamp.c
+++ b/src/backend/utils/adt/timestamp.c
@@ -2275,33 +2275,12 @@ timestamp_cmp(PG_FUNCTION_ARGS)
PG_RETURN_INT32(timestamp_cmp_internal(dt1, dt2));
}
-#if SIZEOF_DATUM < 8
-/* note: this is used for timestamptz also */
-static int
-timestamp_fastcmp(Datum x, Datum y, SortSupport ssup)
-{
- Timestamp a = DatumGetTimestamp(x);
- Timestamp b = DatumGetTimestamp(y);
-
- return timestamp_cmp_internal(a, b);
-}
-#endif
-
Datum
timestamp_sortsupport(PG_FUNCTION_ARGS)
{
SortSupport ssup = (SortSupport) PG_GETARG_POINTER(0);
-#if SIZEOF_DATUM >= 8
-
- /*
- * If this build has pass-by-value timestamps, then we can use a standard
- * comparator function.
- */
ssup->comparator = ssup_datum_signed_cmp;
-#else
- ssup->comparator = timestamp_fastcmp;
-#endif
PG_RETURN_VOID();
}
diff --git a/src/backend/utils/adt/uuid.c b/src/backend/utils/adt/uuid.c
index bce7309c183..7413239f7af 100644
--- a/src/backend/utils/adt/uuid.c
+++ b/src/backend/utils/adt/uuid.c
@@ -398,11 +398,7 @@ uuid_abbrev_convert(Datum original, SortSupport ssup)
{
uint32 tmp;
-#if SIZEOF_DATUM == 8
- tmp = (uint32) res ^ (uint32) ((uint64) res >> 32);
-#else /* SIZEOF_DATUM != 8 */
- tmp = (uint32) res;
-#endif
+ tmp = DatumGetUInt32(res) ^ (uint32) (DatumGetUInt64(res) >> 32);
addHyperLogLog(&uss->abbr_card, DatumGetUInt32(hash_uint32(tmp)));
}
diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c
index 11b442a5941..2c398cd9e5c 100644
--- a/src/backend/utils/adt/varlena.c
+++ b/src/backend/utils/adt/varlena.c
@@ -1671,14 +1671,13 @@ varstr_sortsupport(SortSupport ssup, Oid typid, Oid collid)
*
* Even apart from the risk of broken locales, it's possible that
* there are platforms where the use of abbreviated keys should be
- * disabled at compile time. Having only 4 byte datums could make
- * worst-case performance drastically more likely, for example.
- * Moreover, macOS's strxfrm() implementation is known to not
- * effectively concentrate a significant amount of entropy from the
- * original string in earlier transformed blobs. It's possible that
- * other supported platforms are similarly encumbered. So, if we ever
- * get past disabling this categorically, we may still want or need to
- * disable it for particular platforms.
+ * disabled at compile time. For example, macOS's strxfrm()
+ * implementation is known to not effectively concentrate a
+ * significant amount of entropy from the original string in earlier
+ * transformed blobs. It's possible that other supported platforms
+ * are similarly encumbered. So, if we ever get past disabling this
+ * categorically, we may still want or need to disable it for
+ * particular platforms.
*/
if (!pg_strxfrm_enabled(locale))
abbreviate = false;
@@ -2132,18 +2131,12 @@ varstr_abbrev_convert(Datum original, SortSupport ssup)
addHyperLogLog(&sss->full_card, hash);
/* Hash abbreviated key */
-#if SIZEOF_DATUM == 8
{
- uint32 lohalf,
- hihalf;
+ uint32 tmp;
- lohalf = (uint32) res;
- hihalf = (uint32) (res >> 32);
- hash = DatumGetUInt32(hash_uint32(lohalf ^ hihalf));
+ tmp = DatumGetUInt32(res) ^ (uint32) (DatumGetUInt64(res) >> 32);
+ hash = DatumGetUInt32(hash_uint32(tmp));
}
-#else /* SIZEOF_DATUM != 8 */
- hash = DatumGetUInt32(hash_uint32((uint32) res));
-#endif
addHyperLogLog(&sss->abbr_card, hash);
diff --git a/src/backend/utils/fmgr/fmgr.c b/src/backend/utils/fmgr/fmgr.c
index 782291d9998..5543440a33e 100644
--- a/src/backend/utils/fmgr/fmgr.c
+++ b/src/backend/utils/fmgr/fmgr.c
@@ -1789,41 +1789,6 @@ OidSendFunctionCall(Oid functionId, Datum val)
/*-------------------------------------------------------------------------
- * Support routines for standard maybe-pass-by-reference datatypes
- *
- * int8 and float8 can be passed by value if Datum is wide enough.
- * (For backwards-compatibility reasons, we allow pass-by-ref to be chosen
- * at compile time even if pass-by-val is possible.)
- *
- * Note: there is only one switch controlling the pass-by-value option for
- * both int8 and float8; this is to avoid making things unduly complicated
- * for the timestamp types, which might have either representation.
- *-------------------------------------------------------------------------
- */
-
-#ifndef USE_FLOAT8_BYVAL /* controls int8 too */
-
-Datum
-Int64GetDatum(int64 X)
-{
- int64 *retval = (int64 *) palloc(sizeof(int64));
-
- *retval = X;
- return PointerGetDatum(retval);
-}
-
-Datum
-Float8GetDatum(float8 X)
-{
- float8 *retval = (float8 *) palloc(sizeof(float8));
-
- *retval = X;
- return PointerGetDatum(retval);
-}
-#endif /* USE_FLOAT8_BYVAL */
-
-
-/*-------------------------------------------------------------------------
* Support routines for toastable datatypes
*-------------------------------------------------------------------------
*/
diff --git a/src/backend/utils/resowner/resowner.c b/src/backend/utils/resowner/resowner.c
index d39f3e1b655..fca84ded6dd 100644
--- a/src/backend/utils/resowner/resowner.c
+++ b/src/backend/utils/resowner/resowner.c
@@ -231,11 +231,8 @@ hash_resource_elem(Datum value, const ResourceOwnerDesc *kind)
* 'kind' into the hash. Just add it with hash_combine(), it perturbs the
* result enough for our purposes.
*/
-#if SIZEOF_DATUM == 8
- return hash_combine64(murmurhash64((uint64) value), (uint64) kind);
-#else
- return hash_combine(murmurhash32((uint32) value), (uint32) kind);
-#endif
+ return hash_combine64(murmurhash64((uint64) value),
+ (uint64) (uintptr_t) kind);
}
/*
diff --git a/src/backend/utils/sort/tuplesort.c b/src/backend/utils/sort/tuplesort.c
index 65ab83fff8b..5d4411dc33f 100644
--- a/src/backend/utils/sort/tuplesort.c
+++ b/src/backend/utils/sort/tuplesort.c
@@ -512,7 +512,6 @@ qsort_tuple_unsigned_compare(SortTuple *a, SortTuple *b, Tuplesortstate *state)
return state->base.comparetup_tiebreak(a, b, state);
}
-#if SIZEOF_DATUM >= 8
/* Used if first key's comparator is ssup_datum_signed_cmp */
static pg_attribute_always_inline int
qsort_tuple_signed_compare(SortTuple *a, SortTuple *b, Tuplesortstate *state)
@@ -535,7 +534,6 @@ qsort_tuple_signed_compare(SortTuple *a, SortTuple *b, Tuplesortstate *state)
return state->base.comparetup_tiebreak(a, b, state);
}
-#endif
/* Used if first key's comparator is ssup_datum_int32_cmp */
static pg_attribute_always_inline int
@@ -578,7 +576,6 @@ qsort_tuple_int32_compare(SortTuple *a, SortTuple *b, Tuplesortstate *state)
#define ST_DEFINE
#include "lib/sort_template.h"
-#if SIZEOF_DATUM >= 8
#define ST_SORT qsort_tuple_signed
#define ST_ELEMENT_TYPE SortTuple
#define ST_COMPARE(a, b, state) qsort_tuple_signed_compare(a, b, state)
@@ -587,7 +584,6 @@ qsort_tuple_int32_compare(SortTuple *a, SortTuple *b, Tuplesortstate *state)
#define ST_SCOPE static
#define ST_DEFINE
#include "lib/sort_template.h"
-#endif
#define ST_SORT qsort_tuple_int32
#define ST_ELEMENT_TYPE SortTuple
@@ -2692,7 +2688,6 @@ tuplesort_sort_memtuples(Tuplesortstate *state)
state);
return;
}
-#if SIZEOF_DATUM >= 8
else if (state->base.sortKeys[0].comparator == ssup_datum_signed_cmp)
{
qsort_tuple_signed(state->memtuples,
@@ -2700,7 +2695,6 @@ tuplesort_sort_memtuples(Tuplesortstate *state)
state);
return;
}
-#endif
else if (state->base.sortKeys[0].comparator == ssup_datum_int32_cmp)
{
qsort_tuple_int32(state->memtuples,
@@ -3146,7 +3140,6 @@ ssup_datum_unsigned_cmp(Datum x, Datum y, SortSupport ssup)
return 0;
}
-#if SIZEOF_DATUM >= 8
int
ssup_datum_signed_cmp(Datum x, Datum y, SortSupport ssup)
{
@@ -3160,7 +3153,6 @@ ssup_datum_signed_cmp(Datum x, Datum y, SortSupport ssup)
else
return 0;
}
-#endif
int
ssup_datum_int32_cmp(Datum x, Datum y, SortSupport ssup)