summaryrefslogtreecommitdiff
path: root/mysys/hash.c
diff options
context:
space:
mode:
authorOleksandr Byelkin <sanja@mariadb.com>2021-09-30 12:45:19 +0200
committerOleksandr Byelkin <sanja@mariadb.com>2021-10-12 10:16:29 +0200
commitcd390af982753fadd83b339536ce4d24ea8e5fd0 (patch)
treea4457bb1687f89ddc8a6709a66ef37ceff8c8a82 /mysys/hash.c
parent3c0f48a4c1094707ead76e9d8f009ebb19e3f307 (diff)
downloadmariadb-git-cd390af982753fadd83b339536ce4d24ea8e5fd0.tar.gz
MDEV-26637: (hash) ASAN: main.metadata and user_variables.basic MTR failures after MDEV-26572
Explicitly devide two function of 0 length in the hash keys comparing.
Diffstat (limited to 'mysys/hash.c')
-rw-r--r--mysys/hash.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/mysys/hash.c b/mysys/hash.c
index abc11b42500..3e0dad18fca 100644
--- a/mysys/hash.c
+++ b/mysys/hash.c
@@ -282,6 +282,8 @@ uchar* my_hash_first_from_hash_value(const HASH *hash,
uint flag= 1;
uint idx= my_hash_mask(hash_value,
hash->blength, hash->records);
+ if (!length)
+ length= hash->key_length; // length for fixed length keys or 0
do
{
pos= dynamic_element(&hash->array,idx,HASH_LINK*);
@@ -316,6 +318,8 @@ uchar* my_hash_next(const HASH *hash, const uchar *key, size_t length,
if (*current_record != NO_RECORD)
{
HASH_LINK *data=dynamic_element(&hash->array,0,HASH_LINK*);
+ if (!length)
+ length= hash->key_length; // length for fixed length keys or 0
for (idx=data[*current_record].next; idx != NO_RECORD ; idx=pos->next)
{
pos=data+idx;
@@ -356,8 +360,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 +375,11 @@ 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;
+ 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);
}