diff options
author | Oleksandr Byelkin <sanja@mariadb.com> | 2021-09-30 12:45:19 +0200 |
---|---|---|
committer | Oleksandr Byelkin <sanja@mariadb.com> | 2021-09-30 12:50:53 +0200 |
commit | f64531a17b5b0828d04e226fd47ed5f7f36840fc (patch) | |
tree | 3548dbacd5559ebce5f8889b946a1b182eec3411 | |
parent | 4a3834e249769778ed81eab2bb97b7792fa4a039 (diff) | |
download | mariadb-git-bb-10.7-MDEV-26637.tar.gz |
MDEV-26637: (hash) ASAN: main.metadata and user_variables.basic MTR failures after MDEV-26572bb-10.7-MDEV-26637
Explicitly devide two function of 0 length in the hash keys comparing.
-rw-r--r-- | mysys/hash.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/mysys/hash.c b/mysys/hash.c index abc11b42500..6f298cea45d 100644 --- a/mysys/hash.c +++ b/mysys/hash.c @@ -356,8 +356,11 @@ static void movelink(HASH_LINK *array,uint find,uint next_link,uint newlink) length length of key NOTES: - If length is 0, comparison is done using the length of the - record being compared against. + length equal 0 can mean 2 things: + 1) it is fixed key length hash (HASH::key_length != 0) and + default length should be taken in this case + 2) it is really 0 length key for variable key length hash + (HASH::key_length == 0) RETURN = 0 key of record == key @@ -368,10 +371,13 @@ static int hashcmp(const HASH *hash, HASH_LINK *pos, const uchar *key, size_t length) { size_t rec_keylength; - uchar *rec_key= (uchar*) my_hash_key(hash, pos->data, &rec_keylength, 1); - return ((length && length != rec_keylength) || + uchar *rec_key; + if (!length) + length= hash->key_length; // length for fixed length keys or 0 + rec_key= (uchar*) my_hash_key(hash, pos->data, &rec_keylength, 1); + return (length != rec_keylength) || my_strnncoll(hash->charset, (uchar*) rec_key, rec_keylength, - (uchar*) key, rec_keylength)); + (uchar*) key, rec_keylength); } |