aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2017-09-01 00:13:25 -0400
committerRobert Haas <rhaas@postgresql.org>2017-09-01 00:14:54 -0400
commit7b69b6ceb8047979ddf82af12ec1de143da62263 (patch)
tree34b9d49cd1acd5abcfe9357a0b3451866ad921b5
parent0d9506d125beef18247a5e38a219d3b23e2d312e (diff)
downloadpostgresql-7b69b6ceb8047979ddf82af12ec1de143da62263.tar.gz
postgresql-7b69b6ceb8047979ddf82af12ec1de143da62263.zip
Fix assorted carelessness about Datum vs. int64 vs. uint64
Bugs introduced by commit 81c5e46c490e2426db243eada186995da5bb0ba7
-rw-r--r--src/backend/utils/adt/arrayfuncs.c2
-rw-r--r--src/backend/utils/adt/date.c5
-rw-r--r--src/backend/utils/adt/numeric.c2
-rw-r--r--src/backend/utils/adt/rangetypes.c5
4 files changed, 8 insertions, 6 deletions
diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c
index 522af7affc6..2a4de41bbc0 100644
--- a/src/backend/utils/adt/arrayfuncs.c
+++ b/src/backend/utils/adt/arrayfuncs.c
@@ -4084,7 +4084,7 @@ hash_array_extended(PG_FUNCTION_ARGS)
{
/* Apply the hash function */
locfcinfo.arg[0] = elt;
- locfcinfo.arg[1] = seed;
+ locfcinfo.arg[1] = Int64GetDatum(seed);
locfcinfo.argnull[0] = false;
locfcinfo.argnull[1] = false;
locfcinfo.isnull = false;
diff --git a/src/backend/utils/adt/date.c b/src/backend/utils/adt/date.c
index 34c0b52d583..0992bb3fdd0 100644
--- a/src/backend/utils/adt/date.c
+++ b/src/backend/utils/adt/date.c
@@ -2223,14 +2223,15 @@ Datum
timetz_hash_extended(PG_FUNCTION_ARGS)
{
TimeTzADT *key = PG_GETARG_TIMETZADT_P(0);
- uint64 seed = PG_GETARG_DATUM(1);
+ Datum seed = PG_GETARG_DATUM(1);
uint64 thash;
/* Same approach as timetz_hash */
thash = DatumGetUInt64(DirectFunctionCall2(hashint8extended,
Int64GetDatumFast(key->time),
seed));
- thash ^= DatumGetUInt64(hash_uint32_extended(key->zone, seed));
+ thash ^= DatumGetUInt64(hash_uint32_extended(key->zone,
+ DatumGetInt64(seed)));
PG_RETURN_UINT64(thash);
}
diff --git a/src/backend/utils/adt/numeric.c b/src/backend/utils/adt/numeric.c
index 22d5898927c..bc01f3c2846 100644
--- a/src/backend/utils/adt/numeric.c
+++ b/src/backend/utils/adt/numeric.c
@@ -2285,7 +2285,7 @@ hash_numeric_extended(PG_FUNCTION_ARGS)
hash_len * sizeof(NumericDigit),
seed);
- result = digit_hash ^ weight;
+ result = UInt64GetDatum(DatumGetUInt64(digit_hash) ^ weight);
PG_RETURN_DATUM(result);
}
diff --git a/src/backend/utils/adt/rangetypes.c b/src/backend/utils/adt/rangetypes.c
index d7ba271317a..dae505159ee 100644
--- a/src/backend/utils/adt/rangetypes.c
+++ b/src/backend/utils/adt/rangetypes.c
@@ -1288,7 +1288,7 @@ Datum
hash_range_extended(PG_FUNCTION_ARGS)
{
RangeType *r = PG_GETARG_RANGE(0);
- uint64 seed = PG_GETARG_INT64(1);
+ Datum seed = PG_GETARG_DATUM(1);
uint64 result;
TypeCacheEntry *typcache;
TypeCacheEntry *scache;
@@ -1335,7 +1335,8 @@ hash_range_extended(PG_FUNCTION_ARGS)
upper_hash = 0;
/* Merge hashes of flags and bounds */
- result = hash_uint32_extended((uint32) flags, seed);
+ result = DatumGetUInt64(hash_uint32_extended((uint32) flags,
+ DatumGetInt64(seed)));
result ^= lower_hash;
result = ROTATE_HIGH_AND_LOW_32BITS(result);
result ^= upper_hash;