summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Petrunya <psergey@askmonty.org>2014-01-21 17:27:36 +0400
committerSergey Petrunya <psergey@askmonty.org>2014-01-21 17:27:36 +0400
commit5e02635eb846214b462ed4ab45b2142a08dc5a91 (patch)
treeeb26c4d974369dbbc46a391f45073bf517f7e724
parentb0aaf5c6f56d98c86c98c2a079e5915ad482eec9 (diff)
downloadmariadb-git-5e02635eb846214b462ed4ab45b2142a08dc5a91.tar.gz
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.
-rw-r--r--mysql-test/r/order_by.result24
-rw-r--r--mysql-test/t/order_by.test29
-rw-r--r--sql/sql_select.cc10
3 files changed, 63 insertions, 0 deletions
diff --git a/mysql-test/r/order_by.result b/mysql-test/r/order_by.result
index 0487f9222e0..6ce12651dba 100644
--- a/mysql-test/r/order_by.result
+++ b/mysql-test/r/order_by.result
@@ -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
diff --git a/mysql-test/t/order_by.test b/mysql-test/t/order_by.test
index 35f1a7f744b..2ebf8ba5af1 100644
--- a/mysql-test/t/order_by.test
+++ b/mysql-test/t/order_by.test
@@ -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
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index d4cf72ede42..dfbf5e144e5 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -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;