From c69474b03af466ef0e5e93dd1ebd69686c6d2016 Mon Sep 17 00:00:00 2001 From: ganyang Date: Thu, 11 Aug 2022 14:41:13 +0800 Subject: [PATCH] add computeHashHook --- src/gausskernel/storage/access/hash/hashfunc.cpp | 3 +++ src/include/access/hash.h | 2 ++ src/include/knl/knl_session.h | 1 + 3 files changed, 6 insertions(+) diff --git a/src/gausskernel/storage/access/hash/hashfunc.cpp b/src/gausskernel/storage/access/hash/hashfunc.cpp index 847f65404..f48a77ea7 100644 --- a/src/gausskernel/storage/access/hash/hashfunc.cpp +++ b/src/gausskernel/storage/access/hash/hashfunc.cpp @@ -708,6 +708,9 @@ Datum compute_hash(Oid type, Datum value, char locator) return DirectFunctionCall1(uuid_hash, value); default: + if (u_sess->hook_cxt.computeHashHook != NULL) { + return ((computeHashFunc)(u_sess->hook_cxt.computeHashHook))(type, value, locator); + } ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), errmsg("Unhandled datatype for modulo or hash distribution\n"))); } diff --git a/src/include/access/hash.h b/src/include/access/hash.h index 081622558..56b0dcdec 100644 --- a/src/include/access/hash.h +++ b/src/include/access/hash.h @@ -440,4 +440,6 @@ extern uint32 hash_multikey(MultiHashKey* mkeys); #define GetBucketID(hashval, hashmapsize) (compute_modulo(abs((int)hashval), hashmapsize)) +typedef Datum (*computeHashFunc)(Oid type, Datum value, char locator); + #endif /* HASH_H */ diff --git a/src/include/knl/knl_session.h b/src/include/knl/knl_session.h index 8363217f0..cde82ff7a 100644 --- a/src/include/knl/knl_session.h +++ b/src/include/knl/knl_session.h @@ -2640,6 +2640,7 @@ typedef struct knl_u_hook_context { void *analyzerRoutineHook; void *transformStmtHook; void *execInitExprHook; + void *computeHashHook; } knl_u_hook_context; typedef struct knl_session_context {