Commit 5e02635e authored by Sergey Petrunya's avatar Sergey Petrunya

MDEV-4974: memory leak in 5.5.32-MariaDB-1~wheezy-log

- When a JOIN has both "optimization tabs" (JOIN_TABs used to 
  read the base tables and do the join operation) and also
  has "execution tabs" (a JOIN_TAB that is to produce result set 
  that is sent to the client), do not forget to call JOIN_TAB::cleanup()
  for the execution JOIN_TAB.
parent b0aaf5c6
......@@ -2026,4 +2026,28 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index NULL PRIMARY 4 NULL 8 Using index
1 SIMPLE t2 ref i_a i_a 5 test.t1.a 2 Using index
DROP TABLE t1,t2;
#
# MDEV-4974 memory leak in 5.5.32-MariaDB-1~wheezy-log
#
set sort_buffer_size=default;
set max_sort_length=default;
create table t1(a int);
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table t2 (b int,
col1 varchar(255),
col2 varchar(255)
) character set utf8;
insert into t2 select
A.a+10*B.a,
concat('wow-wow-col1-value-', A.a+10*B.a+100*C.a),
concat('wow-wow-col2-value-', A.a+10*B.a+100*C.a)
from
t1 A, t1 B, t1 C where C.a < 8;
create table t3 as
select distinct A.col1 as XX, B.col1 as YY
from
t2 A, t2 B
where A.b = B.b
order by A.col2, B.col2 limit 10, 1000000;
drop table t1,t2,t3;
End of 5.5 tests
......@@ -1717,6 +1717,35 @@ SELECT t1.a FROM t1 LEFT JOIN t2 ON t1.a=t2.a ORDER BY t1.a LIMIT 100;
DROP TABLE t1,t2;
--echo #
--echo # MDEV-4974 memory leak in 5.5.32-MariaDB-1~wheezy-log
--echo #
set sort_buffer_size=default;
set max_sort_length=default;
create table t1(a int);
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table t2 (b int,
col1 varchar(255),
col2 varchar(255)
) character set utf8;
insert into t2 select
A.a+10*B.a,
concat('wow-wow-col1-value-', A.a+10*B.a+100*C.a),
concat('wow-wow-col2-value-', A.a+10*B.a+100*C.a)
from
t1 A, t1 B, t1 C where C.a < 8;
create table t3 as
select distinct A.col1 as XX, B.col1 as YY
from
t2 A, t2 B
where A.b = B.b
order by A.col2, B.col2 limit 10, 1000000;
drop table t1,t2,t3;
--echo End of 5.5 tests
......@@ -10819,6 +10819,16 @@ void JOIN::cleanup(bool full)
{
tab->cleanup();
}
if (tabs_kind == WALK_OPTIMIZATION_TABS &&
first_breadth_first_tab(this, WALK_OPTIMIZATION_TABS) !=
first_breadth_first_tab(this, WALK_EXECUTION_TABS))
{
JOIN_TAB *jt= first_breadth_first_tab(this, WALK_EXECUTION_TABS);
/* We've walked optimization tabs. do execution ones too */
if (jt)
jt->cleanup();
}
}
cleaned= true;
......
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