diff options
author | unknown <timour@askmonty.org> | 2011-07-07 17:22:28 +0300 |
---|---|---|
committer | unknown <timour@askmonty.org> | 2011-07-07 17:22:28 +0300 |
commit | 0f36ab3a52472b9769da43d61c2d664bb4333c4c (patch) | |
tree | 6ec0d6c01e2e880625b47c775838323e0241a0fd | |
parent | 5f5cbf76844da25d547bcd0235bcf345cdfa4a0a (diff) | |
download | mariadb-git-0f36ab3a52472b9769da43d61c2d664bb4333c4c.tar.gz |
Test for bug lp:612543
The bug itself has been fixed by MWL#89.
-rw-r--r-- | mysql-test/r/subselect4.result | 57 | ||||
-rw-r--r-- | mysql-test/t/subselect4.test | 36 |
2 files changed, 93 insertions, 0 deletions
diff --git a/mysql-test/r/subselect4.result b/mysql-test/r/subselect4.result index 3c5db147e4a..19fa10eb4ed 100644 --- a/mysql-test/r/subselect4.result +++ b/mysql-test/r/subselect4.result @@ -1883,4 +1883,61 @@ WHERE SUBQUERY2_t2.col_varchar_nokey IN col_int_key drop table t1, t2; set @@optimizer_switch = @old_optimizer_switch; +# +# LP BUG#612543 Crash in Item_field::used_tables() with view + subquery + prepared statements +# +CREATE TABLE t1 ( f1 int(11), f2 varchar(1)); +CREATE TABLE t2 ( f3 varchar(1)); +insert into t1 values (2,'x'), (5,'y'); +insert into t2 values ('x'), ('z'); +CREATE VIEW v2 AS SELECT * FROM t2; +set @old_optimizer_switch = @@optimizer_switch; +set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=off,subquery_cache=off'; +EXPLAIN SELECT * FROM t1 JOIN v2 ON t1.f2 > 'a' WHERE v2.f3 IN ( SELECT f2 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 +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) +2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 +PREPARE st1 FROM "SELECT * FROM t1 JOIN v2 ON t1.f2 > 'a' WHERE v2.f3 IN ( SELECT f2 FROM t1 )"; +EXECUTE st1; +f1 f2 f3 +2 x x +5 y x +EXECUTE st1; +f1 f2 f3 +2 x x +5 y x +set @@optimizer_switch='materialization=off,in_to_exists=on,semijoin=off,subquery_cache=off'; +EXPLAIN SELECT * FROM t1 JOIN v2 ON t1.f2 > 'a' WHERE v2.f3 IN ( SELECT f2 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 +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) +2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where +PREPARE st2 FROM "SELECT * FROM t1 JOIN v2 ON t1.f2 > 'a' WHERE v2.f3 IN ( SELECT f2 FROM t1 )"; +EXECUTE st2; +f1 f2 f3 +2 x x +5 y x +EXECUTE st2; +f1 f2 f3 +2 x x +5 y x +set @@optimizer_switch='materialization=on,in_to_exists=on,semijoin=off,subquery_cache=off'; +EXPLAIN SELECT * FROM t1 JOIN v2 ON t1.f2 > 'a' WHERE v2.f3 IN ( SELECT f2 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 +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) +2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 +PREPARE st3 FROM "SELECT * FROM t1 JOIN v2 ON t1.f2 > 'a' WHERE v2.f3 IN ( SELECT f2 FROM t1 )"; +EXECUTE st3; +f1 f2 f3 +2 x x +5 y x +EXECUTE st3; +f1 f2 f3 +2 x x +5 y x +set @@optimizer_switch = @old_optimizer_switch; +drop table t1, t2; +drop view v2; set optimizer_switch=@subselect4_tmp; diff --git a/mysql-test/t/subselect4.test b/mysql-test/t/subselect4.test index 3b55bd78c09..22ed5e4b278 100644 --- a/mysql-test/t/subselect4.test +++ b/mysql-test/t/subselect4.test @@ -1558,4 +1558,40 @@ drop table t1, t2; set @@optimizer_switch = @old_optimizer_switch; + +--echo # +--echo # LP BUG#612543 Crash in Item_field::used_tables() with view + subquery + prepared statements +--echo # + +CREATE TABLE t1 ( f1 int(11), f2 varchar(1)); +CREATE TABLE t2 ( f3 varchar(1)); +insert into t1 values (2,'x'), (5,'y'); +insert into t2 values ('x'), ('z'); +CREATE VIEW v2 AS SELECT * FROM t2; + +set @old_optimizer_switch = @@optimizer_switch; + +set @@optimizer_switch='materialization=on,in_to_exists=off,semijoin=off,subquery_cache=off'; +EXPLAIN SELECT * FROM t1 JOIN v2 ON t1.f2 > 'a' WHERE v2.f3 IN ( SELECT f2 FROM t1 ); +PREPARE st1 FROM "SELECT * FROM t1 JOIN v2 ON t1.f2 > 'a' WHERE v2.f3 IN ( SELECT f2 FROM t1 )"; +EXECUTE st1; +EXECUTE st1; + +set @@optimizer_switch='materialization=off,in_to_exists=on,semijoin=off,subquery_cache=off'; +EXPLAIN SELECT * FROM t1 JOIN v2 ON t1.f2 > 'a' WHERE v2.f3 IN ( SELECT f2 FROM t1 ); +PREPARE st2 FROM "SELECT * FROM t1 JOIN v2 ON t1.f2 > 'a' WHERE v2.f3 IN ( SELECT f2 FROM t1 )"; +EXECUTE st2; +EXECUTE st2; + +set @@optimizer_switch='materialization=on,in_to_exists=on,semijoin=off,subquery_cache=off'; +EXPLAIN SELECT * FROM t1 JOIN v2 ON t1.f2 > 'a' WHERE v2.f3 IN ( SELECT f2 FROM t1 ); +PREPARE st3 FROM "SELECT * FROM t1 JOIN v2 ON t1.f2 > 'a' WHERE v2.f3 IN ( SELECT f2 FROM t1 )"; +EXECUTE st3; +EXECUTE st3; + +set @@optimizer_switch = @old_optimizer_switch; + +drop table t1, t2; +drop view v2; + set optimizer_switch=@subselect4_tmp; |