1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Fixed bug #52394 / LP bug #623209.

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:
Igor Babaev
2010-09-21 16:41:53 -07:00
parent 61e96a75a6
commit f4503f39ee
3 changed files with 64 additions and 4 deletions

View File

@ -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;