summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <timour@askmonty.org>2010-10-26 14:55:42 +0300
committerunknown <timour@askmonty.org>2010-10-26 14:55:42 +0300
commitb4d5f30a869857d532af0200fdb2204213c51f58 (patch)
treecddb89ae274394d3ce9fc8ea6685c3f493193f73
parentdb4738a18a141955465b7a7e139fe25c832d6c44 (diff)
downloadmariadb-git-b4d5f30a869857d532af0200fdb2204213c51f58.tar.gz
Fixed LP bug #601156
The cause for this bug is that MariaDB 5.3 still processes derived tables (subqueries in the FROM clause) by fully executing them during the parse phase. This will be remedied by MWL#106 once merged into the main 5.3. The assert statement is triggered when MATERIALIZATION is ON for EXPLAIN EXTENDED for derived tables with an IN subquery as follows: - mysql_parse calls JOIN::exec for the derived table as if it is regular execution (not explain). - When materialization is ON, this call goes all the way to subselect_hash_sj_engine::exec, which creates a partial match engine because of NULL presence. - In order to proceed with normal execution, the hash_sj engine substitutes itself with the created partial match engine. - After the parse phase it turns out that this execution was part of EXPLAIN EXTENDED, which in turn calls Item_cond::print -> ... -> Item_subselect::print, which calls engine->print(). Since subselect_hash_sj_engine::exec substituted the current Item_subselect engine with a partial match engine, eventually we call its ::print() method. However the partial match engines are designed only for execution, hence there is no implementation of this print() method. The fix temporarily removes the assert, until this code is merged with MWL#106.
-rw-r--r--mysql-test/r/subselect_partial_match.result23
-rw-r--r--mysql-test/t/subselect_partial_match.test25
-rw-r--r--sql/item_subselect.cc2
3 files changed, 45 insertions, 5 deletions
diff --git a/mysql-test/r/subselect_partial_match.result b/mysql-test/r/subselect_partial_match.result
index 7d4a3d750e1..476ec4d3bc5 100644
--- a/mysql-test/r/subselect_partial_match.result
+++ b/mysql-test/r/subselect_partial_match.result
@@ -1,5 +1,7 @@
drop table if exists t1, t2;
-#launchpad BUG#608744
+#
+# LP BUG#608744
+#
set @save_optimizer_switch=@@optimizer_switch;
set @@optimizer_switch="materialization=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=off";
create table t1 (a1 char(1), a2 char(1));
@@ -10,3 +12,22 @@ select * from t1 where (a1, a2) NOT IN (select b1, b2 from t2);
a1 a2
drop table t1,t2;
set @@optimizer_switch=@save_optimizer_switch;
+#
+# LP BUG#601156
+#
+CREATE TABLE t1 (a1 int DEFAULT NULL, a2 int DEFAULT NULL);
+INSERT INTO t1 VALUES (NULL,2);
+INSERT INTO t1 VALUES (4,NULL);
+CREATE TABLE t2 (b1 int DEFAULT NULL, b2 int DEFAULT NULL);
+INSERT INTO t2 VALUES (6,NULL);
+INSERT INTO t2 VALUES (NULL,0);
+SET @@optimizer_switch='materialization=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on';
+EXPLAIN EXTENDED
+SELECT * FROM (SELECT * FROM t1 WHERE a1 NOT IN (SELECT b2 FROM t2)) table1;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY <derived2> system NULL NULL NULL NULL 0 0.00 const row not found
+2 DERIVED t1 ALL NULL NULL NULL NULL 2 100.00 Using where
+3 SUBQUERY t2 ALL NULL NULL NULL NULL 2 100.00
+Warnings:
+Note 1003 select NULL AS `a1`,NULL AS `a2` from (select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where (not(<expr_cache><`test`.`t1`.`a1`>(<in_optimizer>(`test`.`t1`.`a1`,`test`.`t1`.`a1` in ()))))) `table1`
+DROP TABLE t1, t2;
diff --git a/mysql-test/t/subselect_partial_match.test b/mysql-test/t/subselect_partial_match.test
index 0b6af684003..7e573f9c614 100644
--- a/mysql-test/t/subselect_partial_match.test
+++ b/mysql-test/t/subselect_partial_match.test
@@ -7,9 +7,9 @@
drop table if exists t1, t2;
--enable_warnings
-#
---echo #launchpad BUG#608744
-#
+--echo #
+--echo # LP BUG#608744
+--echo #
set @save_optimizer_switch=@@optimizer_switch;
set @@optimizer_switch="materialization=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=off";
create table t1 (a1 char(1), a2 char(1));
@@ -19,3 +19,22 @@ insert into t2 values ('a','b'), ('c', 'd');
select * from t1 where (a1, a2) NOT IN (select b1, b2 from t2);
drop table t1,t2;
set @@optimizer_switch=@save_optimizer_switch;
+
+
+--echo #
+--echo # LP BUG#601156
+--echo #
+
+CREATE TABLE t1 (a1 int DEFAULT NULL, a2 int DEFAULT NULL);
+INSERT INTO t1 VALUES (NULL,2);
+INSERT INTO t1 VALUES (4,NULL);
+CREATE TABLE t2 (b1 int DEFAULT NULL, b2 int DEFAULT NULL);
+INSERT INTO t2 VALUES (6,NULL);
+INSERT INTO t2 VALUES (NULL,0);
+
+SET @@optimizer_switch='materialization=on,semijoin=off,partial_match_rowid_merge=on,partial_match_table_scan=on';
+
+EXPLAIN EXTENDED
+SELECT * FROM (SELECT * FROM t1 WHERE a1 NOT IN (SELECT b2 FROM t2)) table1;
+
+DROP TABLE t1, t2;
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc
index 2cc7ccfceaa..de8430cc8eb 100644
--- a/sql/item_subselect.cc
+++ b/sql/item_subselect.cc
@@ -4722,8 +4722,8 @@ void subselect_partial_match_engine::print(String *str,
/*
Should never be called as the actual engine cannot be known at query
optimization time.
+ DBUG_ASSERT(FALSE);
*/
- DBUG_ASSERT(FALSE);
}