mirror of
https://github.com/MariaDB/server.git
synced 2026-04-30 12:15:32 +02:00
MDEV-12136 SELECT COUNT(DISTINCT) returns the wrong value when tmp_table_size is limited
Same MDEV, second bug. Merge buffer must fit at least MERGEBUFF2 (that is, 15) key values. Because merge_index() can merge that many buffers, and merge_many_buff() leaves that many buffers unmerged.
This commit is contained in:
parent
e7f51e5d26
commit
27bc13b7a2
3 changed files with 12 additions and 2 deletions
|
|
@ -607,11 +607,15 @@ bool Unique::walk(TABLE *table, tree_walk_action action, void *walk_action_arg)
|
|||
return 1;
|
||||
if (flush_io_cache(&file) || reinit_io_cache(&file, READ_CACHE, 0L, 0, 0))
|
||||
return 1;
|
||||
size_t buff_sz= (max_in_memory_size / full_size + 1) * full_size;
|
||||
/*
|
||||
merge_buffer must fit at least MERGEBUFF2 keys, because
|
||||
merge_index() can merge that many BUFFPEKs at once.
|
||||
*/
|
||||
size_t buff_sz= max(MERGEBUFF2, max_in_memory_size/full_size+1) * full_size;
|
||||
if (!(merge_buffer = (uchar *)my_malloc(buff_sz, MYF(MY_WME))))
|
||||
return 1;
|
||||
if (buff_sz < (ulong) (full_size * (file_ptrs.elements + 1)))
|
||||
res= merge(table, merge_buffer, buff_sz >= full_size * MERGEBUFF2) ;
|
||||
res= merge(table, merge_buffer, true) ;
|
||||
|
||||
if (!res)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue