diff options
author | unknown <sanja@montyprogram.com> | 2012-01-10 23:26:00 +0200 |
---|---|---|
committer | unknown <sanja@montyprogram.com> | 2012-01-10 23:26:00 +0200 |
commit | cf31ccc33c2f5ac5e2ae92c672bd54cc7ce63107 (patch) | |
tree | 5ecc3fc90fc3af76c08e9603dad95e3b735c6ccb /mysql-test/t/subselect.test | |
parent | d21189d7759e8223e06ce28bc75b3a5c87da6db1 (diff) | |
download | mariadb-git-cf31ccc33c2f5ac5e2ae92c672bd54cc7ce63107.tar.gz |
Fix for LP BUG#908269 Wrong result with subquery in select list, EXISTS, constant MyISAM/Aria table.
Problem: When building the condition for JOIN::outer_ref_cond the optimizer forgot to take into account
that this condition could depend on constant tables as well.
Diffstat (limited to 'mysql-test/t/subselect.test')
-rw-r--r-- | mysql-test/t/subselect.test | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index 9d87cbc486c..b92fb6f961c 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -4990,5 +4990,33 @@ SELECT * FROM t1 WHERE a IN (SELECT a AS field1 FROM t1 GROUP BY field1); set @@optimizer_switch=@old_optimizer_switch; drop table t1; +--echo # +--echo # LP BUG#908269 incorrect condition in case of subqueries depending +--echo # on constant tables +--echo # +CREATE TABLE t1 ( a INT ); +INSERT INTO t1 VALUES (1),(5); + +# t2 must be MyISAM or Aria and contain 1 row +CREATE TABLE t2 ( b INT ) ENGINE=MyISAM; +INSERT INTO t2 VALUES (1); + +CREATE TABLE t3 ( c INT ); +INSERT INTO t3 VALUES (4),(5); + +SET optimizer_switch='subquery_cache=off'; + +SELECT ( SELECT b FROM t2 WHERE b = a OR EXISTS ( SELECT c FROM t3 WHERE c = b ) ) FROM t1; + +# This query just for example, it should return the same as above (1 and NULL) +SELECT ( SELECT b FROM t2 WHERE b = a OR b * 0) FROM t1; + +# example with "random" +SELECT ( SELECT b FROM t2 WHERE b = a OR rand() * 0) FROM t1; + + +drop table t1,t2,t3; + + --echo # return optimizer switch changed in the beginning of this test set optimizer_switch=@subselect_tmp; |