Skip to content

Commit

Permalink
MDEV-11162 Assertion `num_records == m_idx_array.size()' failed in Fi…
Browse files Browse the repository at this point in the history
…lesort_buffer::alloc_sort_buffer(uint, uint)

When JOIN::destroy() is called for a JOIN object that has
   - join->tmp_join != NULL
   - also has join->table[0]->sort

then the latter was not cleaned up.
This could cause a memory leak and/or asserts in the subsequent queries.

Fixed by adding a cleanup call.
  • Loading branch information
varunraiko committed Dec 7, 2016
1 parent c32d3e1 commit 822fb79
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions mysql-test/r/group_by_innodb.result
Expand Up @@ -123,4 +123,11 @@ id xtext optionen
2 number 22,25
1 select Kabel mit Stecker 5-polig,Kabel ohne Stecker
DROP TABLE t1, t2;
CREATE TABLE t1 (i INT) ENGINE=InnoDB;
SELECT ( SELECT DISTINCT GROUP_CONCAT(SLEEP(0)) FROM t1 GROUP BY i );
( SELECT DISTINCT GROUP_CONCAT(SLEEP(0)) FROM t1 GROUP BY i )
NULL
SELECT i FROM t1 order by i LIMIT 1;
i
DROP TABLE t1;
# End of tests
10 changes: 10 additions & 0 deletions mysql-test/t/group_by_innodb.test
Expand Up @@ -125,4 +125,14 @@ ORDER BY id DESC;

DROP TABLE t1, t2;

--echo #
--echo # MDEV-11162: Assertion `num_records == m_idx_array.size()' failed in Filesort_buffer::alloc_sort_buffer(uint, uint)
--echo #

CREATE TABLE t1 (i INT) ENGINE=InnoDB;
SELECT ( SELECT DISTINCT GROUP_CONCAT(SLEEP(0)) FROM t1 GROUP BY i );
SELECT i FROM t1 order by i LIMIT 1;
DROP TABLE t1;

--echo # End of tests

1 change: 1 addition & 0 deletions sql/sql_select.cc
Expand Up @@ -3144,6 +3144,7 @@ JOIN::destroy()
*/
tmp_table_param.cleanup();
tmp_join->tmp_table_param.copy_field= 0;
cleanup(1);
DBUG_RETURN(tmp_join->destroy());
}
cond_equal= 0;
Expand Down

0 comments on commit 822fb79

Please sign in to comment.