diff options
Diffstat (limited to 'mysql-test/t/group_by.test')
-rw-r--r-- | mysql-test/t/group_by.test | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test index bc01577c249..98b1ee238b1 100644 --- a/mysql-test/t/group_by.test +++ b/mysql-test/t/group_by.test @@ -36,8 +36,10 @@ INSERT INTO t2 VALUES (2,'name','pass','mail','Y','v','n','adr','1','1','1'); INSERT INTO t2 VALUES (3,'name','pass','mail','Y','v','n','adr','1','1','1'); SELECT t2.userid, MIN(t1.score) FROM t1, t2 WHERE t1.userID=t2.userID GROUP BY t2.userid; +SELECT t2.userid, MIN(t1.score) FROM t1, t2 WHERE t1.userID=t2.userID GROUP BY t2.userid ORDER BY NULL; SELECT t2.userid, MIN(t1.score) FROM t1, t2 WHERE t1.userID=t2.userID AND t1.spID=2 GROUP BY t2.userid; SELECT t2.userid, MIN(t1.score+0.0) FROM t1, t2 WHERE t1.userID=t2.userID AND t1.spID=2 GROUP BY t2.userid; +SELECT t2.userid, MIN(t1.score+0.0) FROM t1, t2 WHERE t1.userID=t2.userID AND t1.spID=2 GROUP BY t2.userid ORDER BY NULL; drop table test.t1,test.t2; # @@ -100,6 +102,7 @@ INSERT INTO t2 VALUES (91,2); INSERT INTO t2 VALUES (92,2); SELECT cid, CONCAT(firstname, ' ', surname), COUNT(call_id) FROM t1 LEFT JOIN t2 ON cid=contact_id WHERE firstname like '%foo%' GROUP BY cid; +SELECT cid, CONCAT(firstname, ' ', surname), COUNT(call_id) FROM t1 LEFT JOIN t2 ON cid=contact_id WHERE firstname like '%foo%' GROUP BY cid ORDER BY NULL; SELECT HIGH_PRIORITY cid, CONCAT(firstname, ' ', surname), COUNT(call_id) FROM t1 LEFT JOIN t2 ON cid=contact_id WHERE firstname like '%foo%' GROUP BY cid ORDER BY surname, firstname; drop table t1,t2; @@ -234,16 +237,20 @@ CREATE TABLE t1 ( INSERT INTO t1 VALUES (1,1,1),(2,2,2),(2,1,1),(3,3,3),(4,3,3),(5,3,3); explain select userid,count(*) from t1 group by userid desc; +explain select userid,count(*) from t1 group by userid desc order by null; select userid,count(*) from t1 group by userid desc; select userid,count(*) from t1 group by userid desc having (count(*)+1) IN (4,3); select userid,count(*) from t1 group by userid desc having 3 IN (1,COUNT(*)); explain select spid,count(*) from t1 where spid between 1 and 2 group by spid desc; explain select spid,count(*) from t1 where spid between 1 and 2 group by spid; +explain select spid,count(*) from t1 where spid between 1 and 2 group by spid order by null; select spid,count(*) from t1 where spid between 1 and 2 group by spid; select spid,count(*) from t1 where spid between 1 and 2 group by spid desc; explain select sql_big_result spid,sum(userid) from t1 group by spid desc; +explain select sql_big_result spid,sum(userid) from t1 group by spid desc order by null; select sql_big_result spid,sum(userid) from t1 group by spid desc; explain select sql_big_result score,count(*) from t1 group by score desc; +explain select sql_big_result score,count(*) from t1 group by score desc order by null; select sql_big_result score,count(*) from t1 group by score desc; drop table t1; @@ -365,3 +372,17 @@ select a,count(*) from t1 group by a; set option sql_big_tables=1; select a,count(*) from t1 group by a; drop table t1; + +# +# Test of GROUP BY ... ORDER BY NULL optimization +# + +create table t1 (a int not null, b int not null); +insert into t1 values (1,1),(1,2),(3,1),(3,2),(2,2),(2,1); +create table t2 (a int not null, b int not null, key(a)); +insert into t2 values (1,3),(3,1),(2,2),(1,1); +select t1.a,t2.b from t1,t2 where t1.a=t2.a group by t1.a,t2.b; +select t1.a,t2.b from t1,t2 where t1.a=t2.a group by t1.a,t2.b ORDER BY NULL; +explain select t1.a,t2.b from t1,t2 where t1.a=t2.a group by t1.a,t2.b; +explain select t1.a,t2.b from t1,t2 where t1.a=t2.a group by t1.a,t2.b ORDER BY NULL; +drop table t1,t2; |