summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorunknown <timour@askmonty.org>2010-10-27 16:28:19 +0300
committerunknown <timour@askmonty.org>2010-10-27 16:28:19 +0300
commit3bdede3c67032345ca5f71dd53ca308377dc2398 (patch)
tree79783890f39bab36e4fbb941cd4472fa29213cb3 /mysql-test
parent3b11e4f8347884c716bdf0b11aba34e8aee1a0c4 (diff)
downloadmariadb-git-3bdede3c67032345ca5f71dd53ca308377dc2398.tar.gz
Fixed LP bug #613009
The set of Ordered keys of a rowid merge engine is dense. Thus when we decide not to create a key for a column that has only NULLs, this column shouldn't be counted. Notice that the caller has already precomputed the correct total number of keys that should be created.
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/subselect_partial_match.result19
-rw-r--r--mysql-test/t/subselect_partial_match.test18
2 files changed, 35 insertions, 2 deletions
diff --git a/mysql-test/r/subselect_partial_match.result b/mysql-test/r/subselect_partial_match.result
index 476ec4d3bc5..5887de2fff2 100644
--- a/mysql-test/r/subselect_partial_match.result
+++ b/mysql-test/r/subselect_partial_match.result
@@ -21,7 +21,8 @@ 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';
+set @save_optimizer_switch=@@optimizer_switch;
+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
@@ -31,3 +32,19 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
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;
+set @@optimizer_switch=@save_optimizer_switch;
+#
+# LP BUG#613009 Crash in Ordered_key::get_field_idx
+#
+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(3) DEFAULT NULL, a2 char(3) DEFAULT NULL);
+insert into t1 values (NULL, 'a21'), (NULL, 'a22');
+explain select * from t1 where (a1, a2) not in (select a1, a2 from t1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where
+2 SUBQUERY t1 ALL NULL NULL NULL NULL 2
+select * from t1 where (a1, a2) not in (select a1, a2 from t1);
+a1 a2
+drop table t1;
+set @@optimizer_switch=@save_optimizer_switch;
diff --git a/mysql-test/t/subselect_partial_match.test b/mysql-test/t/subselect_partial_match.test
index 7e573f9c614..5e48fc7d9f7 100644
--- a/mysql-test/t/subselect_partial_match.test
+++ b/mysql-test/t/subselect_partial_match.test
@@ -32,9 +32,25 @@ 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';
+set @save_optimizer_switch=@@optimizer_switch;
+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;
+set @@optimizer_switch=@save_optimizer_switch;
+
+--echo #
+--echo # LP BUG#613009 Crash in Ordered_key::get_field_idx
+--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(3) DEFAULT NULL, a2 char(3) DEFAULT NULL);
+insert into t1 values (NULL, 'a21'), (NULL, 'a22');
+explain select * from t1 where (a1, a2) not in (select a1, a2 from t1);
+select * from t1 where (a1, a2) not in (select a1, a2 from t1);
+drop table t1;
+set @@optimizer_switch=@save_optimizer_switch;