Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 7b69b6c

Browse files
committed
Fix assorted carelessness about Datum vs. int64 vs. uint64
Bugs introduced by commit 81c5e46
1 parent 0d9506d commit 7b69b6c

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

src/backend/utils/adt/arrayfuncs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4084,7 +4084,7 @@ hash_array_extended(PG_FUNCTION_ARGS)
40844084
{
40854085
/* Apply the hash function */
40864086
locfcinfo.arg[0] = elt;
4087-
locfcinfo.arg[1] = seed;
4087+
locfcinfo.arg[1] = Int64GetDatum(seed);
40884088
locfcinfo.argnull[0] = false;
40894089
locfcinfo.argnull[1] = false;
40904090
locfcinfo.isnull = false;

src/backend/utils/adt/date.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2223,14 +2223,15 @@ Datum
22232223
timetz_hash_extended(PG_FUNCTION_ARGS)
22242224
{
22252225
TimeTzADT *key = PG_GETARG_TIMETZADT_P(0);
2226-
uint64 seed = PG_GETARG_DATUM(1);
2226+
Datum seed = PG_GETARG_DATUM(1);
22272227
uint64 thash;
22282228

22292229
/* Same approach as timetz_hash */
22302230
thash = DatumGetUInt64(DirectFunctionCall2(hashint8extended,
22312231
Int64GetDatumFast(key->time),
22322232
seed));
2233-
thash ^= DatumGetUInt64(hash_uint32_extended(key->zone, seed));
2233+
thash ^= DatumGetUInt64(hash_uint32_extended(key->zone,
2234+
DatumGetInt64(seed)));
22342235
PG_RETURN_UINT64(thash);
22352236
}
22362237

src/backend/utils/adt/numeric.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2285,7 +2285,7 @@ hash_numeric_extended(PG_FUNCTION_ARGS)
22852285
hash_len * sizeof(NumericDigit),
22862286
seed);
22872287

2288-
result = digit_hash ^ weight;
2288+
result = UInt64GetDatum(DatumGetUInt64(digit_hash) ^ weight);
22892289

22902290
PG_RETURN_DATUM(result);
22912291
}

src/backend/utils/adt/rangetypes.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,7 +1288,7 @@ Datum
12881288
hash_range_extended(PG_FUNCTION_ARGS)
12891289
{
12901290
RangeType *r = PG_GETARG_RANGE(0);
1291-
uint64 seed = PG_GETARG_INT64(1);
1291+
Datum seed = PG_GETARG_DATUM(1);
12921292
uint64 result;
12931293
TypeCacheEntry *typcache;
12941294
TypeCacheEntry *scache;
@@ -1335,7 +1335,8 @@ hash_range_extended(PG_FUNCTION_ARGS)
13351335
upper_hash = 0;
13361336

13371337
/* Merge hashes of flags and bounds */
1338-
result = hash_uint32_extended((uint32) flags, seed);
1338+
result = DatumGetUInt64(hash_uint32_extended((uint32) flags,
1339+
DatumGetInt64(seed)));
13391340
result ^= lower_hash;
13401341
result = ROTATE_HIGH_AND_LOW_32BITS(result);
13411342
result ^= upper_hash;

0 commit comments

Comments
 (0)