summaryrefslogtreecommitdiff
path: root/mysql-test/t/subselect4.test
diff options
context:
space:
mode:
authorunknown <timour@askmonty.org>2010-11-22 11:07:45 +0200
committerunknown <timour@askmonty.org>2010-11-22 11:07:45 +0200
commit0a31c4ffc3ce1577c4a76cbc6d755493a6c152ee (patch)
treedc720e7ac8e2d8a7c8cecf6aa9d6d284ed81368a /mysql-test/t/subselect4.test
parentbd5c45dc7a7bda27a5e7a7f6961e79383b4e8a5b (diff)
downloadmariadb-git-0a31c4ffc3ce1577c4a76cbc6d755493a6c152ee.tar.gz
Fixed LP BUG#675981
Cause: The optimize() phase for the subquery selected to use join buffering via setting JOIN_TAB::next_select= sub_select_cache in make_join_readinfo, however, the call to check_join_cache_usage() from make_join_readinfo didn't create the corresponding JOIN_CACHE_BNL object because of the condition: if ((options & SELECT_DESCRIBE) || (((tab->cache= new JOIN_CACHE_BNL(join, tab, prev_cache))) && !tab->cache->init())) Since EXPLAIN for subqueries runs regular execution, the constant predicates that were delayed to be evaluated at the exec() phase, were evaluated during EXPLAIN. As a result the outer JOIN::exec called JOIN::exec for the subquery, while the subquery execution plan was no properly created, which resulted in an failed ASSERT. Fix: The patch blocks evaluation of constant expensive conditions during EXPLAIN. Notice that these conditions are "constant" with respect to the outer query, thus in general they could be arbitrarily expensive, which may result in very slow EXPLAINs.
Diffstat (limited to 'mysql-test/t/subselect4.test')
-rw-r--r--mysql-test/t/subselect4.test21
1 files changed, 21 insertions, 0 deletions
diff --git a/mysql-test/t/subselect4.test b/mysql-test/t/subselect4.test
index 4b77b790a5c..cc58b14db36 100644
--- a/mysql-test/t/subselect4.test
+++ b/mysql-test/t/subselect4.test
@@ -398,6 +398,27 @@ SELECT * FROM t4 LEFT JOIN t2 ON t4.c1 WHERE 's' IN (SELECT c1 FROM t2);
drop table t1, t2, t3, t4;
--echo #
+--echo # LP BUG#675981 Assertion `cache != __null' failed in sub_select_cache()
+--echo # on EXPLAIN
+--echo #
+
+CREATE TABLE t1 (f1 int,f2 int) ;
+INSERT IGNORE INTO t1 VALUES ('2','5'),('2',NULL);
+
+CREATE TABLE t2 (f1 int, f5 int) ;
+INSERT IGNORE INTO t2 VALUES (1,0);
+
+CREATE TABLE t3 (f4 int) ;
+INSERT IGNORE INTO t3 VALUES (0),(0);
+
+set @@optimizer_switch='in_to_exists=on,materialization=off,semijoin=off';
+EXPLAIN
+SELECT * FROM t2
+WHERE f1 IN (SELECT t1.f2 FROM t1 JOIN t3 ON t3.f4);
+
+drop table t1, t2, t3;
+
+--echo #
--echo # BUG#52317: Assertion failing in Field_varstring::store()
--echo # at field.cc:6833
--echo #