mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
When an incremental join cache is used to join a table whose fields are not referenced anywhere in the query the association pointer to the last record in the such cache can be the same as the pointer to the end of the buffer. The function JOIN_CACHE_BKA::get_next_key must take into consideration this when iterating over the keys of the records from the join buffer. The assertion in JOIN_TAB_SCAN_MRR::next also must take this into consideration. Borrowed a slightly changed test case from a patch attached to the bug #52394.
This commit is contained in:
@ -3391,8 +3391,12 @@ int JOIN_TAB_SCAN_MRR::next()
|
||||
uint rc= join_tab->table->file->multi_range_read_next(ptr) ? -1 : 0;
|
||||
if (!rc)
|
||||
{
|
||||
/*
|
||||
If a record in in an incremental cache contains no fields then the
|
||||
association for the last record in cache will be equal to cache->end_pos
|
||||
*/
|
||||
DBUG_ASSERT(cache->buff <= (uchar *) (*ptr) &&
|
||||
(uchar *) (*ptr) < cache->end_pos);
|
||||
(uchar *) (*ptr) <= cache->end_pos);
|
||||
update_virtual_fields(join_tab->table);
|
||||
}
|
||||
return rc;
|
||||
@ -3728,12 +3732,12 @@ uint JOIN_CACHE_BKA::get_next_key(uchar ** key)
|
||||
uchar *init_pos;
|
||||
JOIN_CACHE *cache;
|
||||
|
||||
if (pos > last_rec_pos || !records)
|
||||
return 0;
|
||||
|
||||
/* Any record in a BKA cache is prepended with its length */
|
||||
DBUG_ASSERT(with_length);
|
||||
|
||||
if ((pos+size_of_rec_len) > last_rec_pos || !records)
|
||||
return 0;
|
||||
|
||||
/* Read the length of the record */
|
||||
rec_len= get_rec_length(pos);
|
||||
pos+= size_of_rec_len;
|
||||
|
Reference in New Issue
Block a user