diff options
author | unknown <timour@askmonty.org> | 2011-12-12 12:36:46 +0200 |
---|---|---|
committer | unknown <timour@askmonty.org> | 2011-12-12 12:36:46 +0200 |
commit | 6404504d0c10d58ad5861bdb72edd54508f1364c (patch) | |
tree | 630cebe7a3b3f2c3c6a48ca310f1e408f69bc2c0 /mysql-test/t/group_min_max.test | |
parent | 314c377422dd13c86591a4de32162467eb540c33 (diff) | |
download | mariadb-git-6404504d0c10d58ad5861bdb72edd54508f1364c.tar.gz |
Fixed bug lp:900375
The range optimizer incorrectly chose a loose scan for group by
when there is a correlated WHERE condition. This range access
method cannot be executed for correlated conditions also with the
"range checked for each record" because generally the range access
method can change for each outer record. Loose scan destructively
changes the query plan and removes the GROUP operation, which will
result in wrong query plans if another range access is chosen
dynamically.
Diffstat (limited to 'mysql-test/t/group_min_max.test')
-rw-r--r-- | mysql-test/t/group_min_max.test | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/mysql-test/t/group_min_max.test b/mysql-test/t/group_min_max.test index bd2cbd8a9f0..7c9c2b05eda 100644 --- a/mysql-test/t/group_min_max.test +++ b/mysql-test/t/group_min_max.test @@ -1114,4 +1114,27 @@ select (select t2.a from t2 where t2.a >= t1.a group by t2.a) from t1; drop table t1, t2; +--echo # +--echo # LP BUG#900375 Wrong result with derived_merge=ON, DISTINCT or GROUP BY, EXISTS +--echo # + +CREATE TABLE t1 ( a INT, b INT, KEY (b) ); +INSERT INTO t1 VALUES +(100,10),(101,11),(102,12),(103,13),(104,14), +(105,15),(106,16),(107,17),(108,18),(109,19); + +EXPLAIN +SELECT alias1.* FROM t1, (SELECT * FROM t1) AS alias1 +WHERE EXISTS ( SELECT DISTINCT b FROM t1 WHERE b <= alias1.a ) ; +SELECT alias1.* FROM t1, (SELECT * FROM t1) AS alias1 +WHERE EXISTS ( SELECT DISTINCT b FROM t1 WHERE b <= alias1.a ) ; + +EXPLAIN +SELECT alias1.* FROM t1, t1 AS alias1 +WHERE EXISTS ( SELECT DISTINCT b FROM t1 WHERE b <= alias1.a ) ; +SELECT alias1.* FROM t1, t1 AS alias1 +WHERE EXISTS ( SELECT DISTINCT b FROM t1 WHERE b <= alias1.a ) ; + +drop table t1; + --echo End of 5.1 tests |