Commit cd390af9 authored by Oleksandr Byelkin's avatar Oleksandr Byelkin

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.
parent 3c0f48a4
......@@ -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);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment