Commit 7b69b6ce authored by Robert Haas's avatar Robert Haas

Fix assorted carelessness about Datum vs. int64 vs. uint64

Bugs introduced by commit 81c5e46c
parent 0d9506d1
...@@ -4084,7 +4084,7 @@ hash_array_extended(PG_FUNCTION_ARGS) ...@@ -4084,7 +4084,7 @@ hash_array_extended(PG_FUNCTION_ARGS)
{ {
/* Apply the hash function */ /* Apply the hash function */
locfcinfo.arg[0] = elt; locfcinfo.arg[0] = elt;
locfcinfo.arg[1] = seed; locfcinfo.arg[1] = Int64GetDatum(seed);
locfcinfo.argnull[0] = false; locfcinfo.argnull[0] = false;
locfcinfo.argnull[1] = false; locfcinfo.argnull[1] = false;
locfcinfo.isnull = false; locfcinfo.isnull = false;
......
...@@ -2223,14 +2223,15 @@ Datum ...@@ -2223,14 +2223,15 @@ Datum
timetz_hash_extended(PG_FUNCTION_ARGS) timetz_hash_extended(PG_FUNCTION_ARGS)
{ {
TimeTzADT *key = PG_GETARG_TIMETZADT_P(0); TimeTzADT *key = PG_GETARG_TIMETZADT_P(0);
uint64 seed = PG_GETARG_DATUM(1); Datum seed = PG_GETARG_DATUM(1);
uint64 thash; uint64 thash;
/* Same approach as timetz_hash */ /* Same approach as timetz_hash */
thash = DatumGetUInt64(DirectFunctionCall2(hashint8extended, thash = DatumGetUInt64(DirectFunctionCall2(hashint8extended,
Int64GetDatumFast(key->time), Int64GetDatumFast(key->time),
seed)); seed));
thash ^= DatumGetUInt64(hash_uint32_extended(key->zone, seed)); thash ^= DatumGetUInt64(hash_uint32_extended(key->zone,
DatumGetInt64(seed)));
PG_RETURN_UINT64(thash); PG_RETURN_UINT64(thash);
} }
......
...@@ -2285,7 +2285,7 @@ hash_numeric_extended(PG_FUNCTION_ARGS) ...@@ -2285,7 +2285,7 @@ hash_numeric_extended(PG_FUNCTION_ARGS)
hash_len * sizeof(NumericDigit), hash_len * sizeof(NumericDigit),
seed); seed);
result = digit_hash ^ weight; result = UInt64GetDatum(DatumGetUInt64(digit_hash) ^ weight);
PG_RETURN_DATUM(result); PG_RETURN_DATUM(result);
} }
......
...@@ -1288,7 +1288,7 @@ Datum ...@@ -1288,7 +1288,7 @@ Datum
hash_range_extended(PG_FUNCTION_ARGS) hash_range_extended(PG_FUNCTION_ARGS)
{ {
RangeType *r = PG_GETARG_RANGE(0); RangeType *r = PG_GETARG_RANGE(0);
uint64 seed = PG_GETARG_INT64(1); Datum seed = PG_GETARG_DATUM(1);
uint64 result; uint64 result;
TypeCacheEntry *typcache; TypeCacheEntry *typcache;
TypeCacheEntry *scache; TypeCacheEntry *scache;
...@@ -1335,7 +1335,8 @@ hash_range_extended(PG_FUNCTION_ARGS) ...@@ -1335,7 +1335,8 @@ hash_range_extended(PG_FUNCTION_ARGS)
upper_hash = 0; upper_hash = 0;
/* Merge hashes of flags and bounds */ /* 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 ^= lower_hash;
result = ROTATE_HIGH_AND_LOW_32BITS(result); result = ROTATE_HIGH_AND_LOW_32BITS(result);
result ^= upper_hash; result ^= upper_hash;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment