summaryrefslogtreecommitdiff
path: root/src/include/utils
diff options
context:
space:
mode:
authorRobert Haas2017-09-01 02:21:21 +0000
committerRobert Haas2017-09-01 02:21:21 +0000
commit81c5e46c490e2426db243eada186995da5bb0ba7 (patch)
treea6cb745131c45a06fa43746a17a69e1dc9daa44a /src/include/utils
parent2d44c58c79aeef2d376be0141057afbb9ec6b5bc (diff)
Introduce 64-bit hash functions with a 64-bit seed.
This will be useful for hash partitioning, which needs a way to seed the hash functions to avoid problems such as a hash index on a hash partitioned table clumping all values into a small portion of the bucket space; it's also useful for anything that wants a 64-bit hash value rather than a 32-bit hash value. Just in case somebody wants a 64-bit hash value that is compatible with the existing 32-bit hash values, make the low 32-bits of the 64-bit hash value match the 32-bit hash value when the seed is 0. Robert Haas and Amul Sul Discussion: http://postgr.es/m/CA+Tgmoafx2yoJuhCQQOL5CocEi-w_uG4S2xT0EtgiJnPGcHW3g@mail.gmail.com
Diffstat (limited to 'src/include/utils')
-rw-r--r--src/include/utils/jsonb.h2
-rw-r--r--src/include/utils/typcache.h4
2 files changed, 6 insertions, 0 deletions
diff --git a/src/include/utils/jsonb.h b/src/include/utils/jsonb.h
index ea9dd17540d..24f491663bb 100644
--- a/src/include/utils/jsonb.h
+++ b/src/include/utils/jsonb.h
@@ -370,6 +370,8 @@ extern Jsonb *JsonbValueToJsonb(JsonbValue *val);
extern bool JsonbDeepContains(JsonbIterator **val,
JsonbIterator **mContained);
extern void JsonbHashScalarValue(const JsonbValue *scalarVal, uint32 *hash);
+extern void JsonbHashScalarValueExtended(const JsonbValue *scalarVal,
+ uint64 *hash, uint64 seed);
/* jsonb.c support functions */
extern char *JsonbToCString(StringInfo out, JsonbContainer *in,
diff --git a/src/include/utils/typcache.h b/src/include/utils/typcache.h
index c12631dafe2..b4f75921625 100644
--- a/src/include/utils/typcache.h
+++ b/src/include/utils/typcache.h
@@ -56,6 +56,7 @@ typedef struct TypeCacheEntry
Oid gt_opr; /* the greater-than operator */
Oid cmp_proc; /* the btree comparison function */
Oid hash_proc; /* the hash calculation function */
+ Oid hash_extended_proc; /* the extended hash calculation function */
/*
* Pre-set-up fmgr call info for the equality operator, the btree
@@ -67,6 +68,7 @@ typedef struct TypeCacheEntry
FmgrInfo eq_opr_finfo;
FmgrInfo cmp_proc_finfo;
FmgrInfo hash_proc_finfo;
+ FmgrInfo hash_extended_proc_finfo;
/*
* Tuple descriptor if it's a composite type (row type). NULL if not
@@ -120,6 +122,8 @@ typedef struct TypeCacheEntry
#define TYPECACHE_HASH_OPFAMILY 0x0400
#define TYPECACHE_RANGE_INFO 0x0800
#define TYPECACHE_DOMAIN_INFO 0x1000
+#define TYPECACHE_HASH_EXTENDED_PROC 0x2000
+#define TYPECACHE_HASH_EXTENDED_PROC_FINFO 0x4000
/*
* Callers wishing to maintain a long-lived reference to a domain's constraint