3471 Norvald H. Ryeng 2011-10-03
Bug #12330344 CRASH AND/OR VALGRIND ERRORS IN FREE_IO_CACHE WITH JOIN,
VIEW, PARTITIONED TABLE
Problem: Server crashes when executing query using a TEMPTABLE view
with a subselect using a partitioned table.
In prune_partitions(), the memory root is substituted for a memory
root with a life span as long as the prune_partions() call. During
optimization of functions, subselects may allocate memory that is
expected to have the same life span as the subselect. Due to the new
memory root, this memory is freed at the end of prune_partitions() and
still referred to by the subselect and attempted used during query
execution.
Fix: Switch memory root back to the normal root before calling
Item_func::select_optimize().
@ mysql-test/r/partition.result
Add test case for bug#12330344
@ mysql-test/t/partition.test
Add test case for bug#12330344
@ sql/opt_range.cc
Switch memory root before calling Item_func::select_optimize()
modified:
mysql-test/r/partition.result
mysql-test/t/partition.test
sql/opt_range.cc
3470 Andrei Elkin 2011-10-03
fixing bug@11747416 post-push few tests non-deterministic tests/results. Few print-outs are removed until a new Bug@13055685 has provided a necessary too.
modified:
mysql-test/suite/rpl/r/rpl_manual_change_index_file.result
mysql-test/suite/rpl/r/rpl_packet.result
mysql-test/suite/rpl/r/rpl_row_event_max_size.result
mysql-test/suite/rpl/t/rpl_manual_change_index_file.test
mysql-test/suite/rpl/t/rpl_packet.test
mysql-test/suite/rpl/t/rpl_row_event_max_size.test
=== modified file 'mysql-test/r/partition.result'
--- a/mysql-test/r/partition.result 2011-07-19 15:11:15 +0000
+++ b/mysql-test/r/partition.result 2011-10-03 12:22:21 +0000
@@ -2422,3 +2422,10 @@ alter table t1 add column j int;
unlock tables;
drop table t1;
# End of 5.5 tests
+CREATE TABLE t1(a INT PRIMARY KEY) PARTITION BY LINEAR KEY (a);
+CREATE ALGORITHM=TEMPTABLE VIEW vtmp AS
+SELECT 1 FROM t1 AS t1_0 JOIN t1 ON t1_0.a LIKE (SELECT 1 FROM t1);
+SELECT * FROM vtmp;
+1
+DROP VIEW vtmp;
+DROP TABLE t1;
=== modified file 'mysql-test/t/partition.test'
--- a/mysql-test/t/partition.test 2011-06-13 10:55:58 +0000
+++ b/mysql-test/t/partition.test 2011-10-03 12:22:21 +0000
@@ -2421,3 +2421,15 @@ unlock tables;
drop table t1;
--echo # End of 5.5 tests
+
+#
+# Bug #12330344 Crash and/or valgrind errors in free_io_cache with join, view,
+# partitioned table
+#
+
+CREATE TABLE t1(a INT PRIMARY KEY) PARTITION BY LINEAR KEY (a);
+CREATE ALGORITHM=TEMPTABLE VIEW vtmp AS
+SELECT 1 FROM t1 AS t1_0 JOIN t1 ON t1_0.a LIKE (SELECT 1 FROM t1);
+SELECT * FROM vtmp;
+DROP VIEW vtmp;
+DROP TABLE t1;
=== modified file 'sql/opt_range.cc'
--- a/sql/opt_range.cc 2011-09-28 07:42:55 +0000
+++ b/sql/opt_range.cc 2011-10-03 12:22:21 +0000
@@ -6088,8 +6088,21 @@ static SEL_TREE *get_mm_tree(RANGE_OPT_P
if (cond_func->functype() == Item_func::BETWEEN ||
cond_func->functype() == Item_func::IN_FUNC)
inv= ((Item_func_opt_neg *) cond_func)->negated;
- else if (cond_func->select_optimize() == Item_func::OPTIMIZE_NONE)
- DBUG_RETURN(0);
+ else
+ {
+ /*
+ During the cond_func->select_optimize() evaluation we can come across a
+ subselect item which may allocate memory on the thd->mem_root and assumes
+ all the memory allocated has the same life span as the subselect item
+ itself. So we have to restore the thread's mem_root here.
+ */
+ MEM_ROOT *tmp_root= param->mem_root;
+ param->thd->mem_root= param->old_root;
+ Item_func::optimize_type opt_type= cond_func->select_optimize();
+ param->thd->mem_root= tmp_root;
+ if (opt_type == Item_func::OPTIMIZE_NONE)
+ DBUG_RETURN(NULL);
+ }
param->cond= cond;
No bundle (reason: useless for push emails).
| Thread |
|---|
| • bzr push into mysql-trunk branch (norvald.ryeng:3470 to 3471) Bug#12330344 | Norvald H. Ryeng | 3 Oct |