]> granicus.if.org Git - postgresql/commitdiff
Fix assorted carelessness about Datum vs. int64 vs. uint64
authorRobert Haas <rhaas@postgresql.org>
Fri, 1 Sep 2017 04:13:25 +0000 (00:13 -0400)
committerRobert Haas <rhaas@postgresql.org>
Fri, 1 Sep 2017 04:14:54 +0000 (00:14 -0400)
Bugs introduced by commit 81c5e46c490e2426db243eada186995da5bb0ba7

src/backend/utils/adt/arrayfuncs.c
src/backend/utils/adt/date.c
src/backend/utils/adt/numeric.c
src/backend/utils/adt/rangetypes.c

index 522af7affc6e301bc7c594c6fd1b1db37ea45a5f..2a4de41bbc0b303bb3177827687d7c2eab1ca65f 100644 (file)
@@ -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;
index 34c0b52d5834d1b929c9b3540d0d64e2b6b87ff2..0992bb3fdd024a093374ad923e2151fc05446550 100644 (file)
@@ -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);
 }
 
index 22d5898927cec5dc8700d9a76ae72df45b1a8e62..bc01f3c284640d37f289021bad1e9d8016755059 100644 (file)
@@ -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);
 }
index d7ba271317a19d8b8a2e420d084e174817a0007c..dae505159ee76dd5af39c3d3cf61b69af3719a23 100644 (file)
@@ -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;