diff options
author | holyfoot/hf@mysql.com/deer.(none) <> | 2006-11-16 23:16:44 +0400 |
---|---|---|
committer | holyfoot/hf@mysql.com/deer.(none) <> | 2006-11-16 23:16:44 +0400 |
commit | 497ccd6b87b9978fadac6c48d4ae6bd2f689feb7 (patch) | |
tree | 5400912843b70b171dc06c8cdc96a6f3329a25db /mysql-test/t/order_by.test | |
parent | 4e9ef283efa621ad3acafce39978bc8f29b97931 (diff) | |
parent | e7cde7265138dcb6ded0a1309e331a52baaf44e5 (diff) | |
download | mariadb-git-497ccd6b87b9978fadac6c48d4ae6bd2f689feb7.tar.gz |
Merge mysql.com:/home/hf/work/mysql-4.1-mrg
into mysql.com:/home/hf/work/mysql-5.0-mrg
Diffstat (limited to 'mysql-test/t/order_by.test')
-rw-r--r-- | mysql-test/t/order_by.test | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/mysql-test/t/order_by.test b/mysql-test/t/order_by.test index 1104c859ab8..ff75186f64e 100644 --- a/mysql-test/t/order_by.test +++ b/mysql-test/t/order_by.test @@ -514,6 +514,81 @@ set max_sort_length=20; select a from t1 order by a; drop table t1; +# +# Bug #7331 +# + +create table t1 ( + `sid` decimal(8,0) default null, + `wnid` varchar(11) not null default '', + key `wnid14` (`wnid`(4)), + key `wnid` (`wnid`) +) engine=myisam default charset=latin1; + +insert into t1 (`sid`, `wnid`) values +('10100','01019000000'),('37986','01019000000'),('37987','01019010000'), +('39560','01019090000'),('37989','01019000000'),('37990','01019011000'), +('37991','01019011000'),('37992','01019019000'),('37993','01019030000'), +('37994','01019090000'),('475','02070000000'),('25253','02071100000'), +('25255','02071100000'),('25256','02071110000'),('25258','02071130000'), +('25259','02071190000'),('25260','02071200000'),('25261','02071210000'), +('25262','02071290000'),('25263','02071300000'),('25264','02071310000'), +('25265','02071310000'),('25266','02071320000'),('25267','02071320000'), +('25269','02071330000'),('25270','02071340000'),('25271','02071350000'), +('25272','02071360000'),('25273','02071370000'),('25281','02071391000'), +('25282','02071391000'),('25283','02071399000'),('25284','02071400000'), +('25285','02071410000'),('25286','02071410000'),('25287','02071420000'), +('25288','02071420000'),('25291','02071430000'),('25290','02071440000'), +('25292','02071450000'),('25293','02071460000'),('25294','02071470000'), +('25295','02071491000'),('25296','02071491000'),('25297','02071499000'); + +explain select * from t1 where wnid like '0101%' order by wnid; + +select * from t1 where wnid like '0101%' order by wnid; + +drop table t1; + +# +# Bug #7672 - a wrong result for a select query in braces followed by order by +# + +CREATE TABLE t1 (a int); +INSERT INTO t1 VALUES (2), (1), (1), (2), (1); +SELECT a FROM t1 ORDER BY a; +(SELECT a FROM t1) ORDER BY a; +DROP TABLE t1; + +# +# Bug #18767: global ORDER BY applied to a SELECT with ORDER BY either was +# ignored or 'concatened' to the latter. + +CREATE TABLE t1 (a int, b int); +INSERT INTO t1 VALUES (1,30), (2,20), (1,10), (2,30), (1,20), (2,10); + +(SELECT b,a FROM t1 ORDER BY a,b) ORDER BY b,a; +(SELECT b FROM t1 ORDER BY b DESC) ORDER BY b ASC; +(SELECT b,a FROM t1 ORDER BY b,a) ORDER BY a,b; +(SELECT b,a FROM t1 ORDER by b,a LIMIT 3) ORDER by a,b; + +DROP TABLE t1; + +# +# Bug #22457: Column alias in ORDER BY works, but not if in an expression +# + +CREATE TABLE t1 (a INT); INSERT INTO t1 VALUES (1),(2); +SELECT a + 1 AS num FROM t1 ORDER BY 30 - num; +SELECT CONCAT('test', a) AS str FROM t1 ORDER BY UPPER(str); +SELECT a + 1 AS num FROM t1 GROUP BY 30 - num; +SELECT a + 1 AS num FROM t1 HAVING 30 - num; +--error 1054 +SELECT a + 1 AS num, num + 1 FROM t1; +SELECT a + 1 AS num, (select num + 2 FROM t1 LIMIT 1) FROM t1; +--error 1054 +SELECT a.a + 1 AS num FROM t1 a JOIN t1 b ON num = b.a; +DROP TABLE t1; + +# End of 4.1 tests create table t1 (a int not null, b int not null, c int not null); insert t1 values (1,1,1),(1,1,2),(1,2,1); select a, b from t1 group by a, b order by sum(c); |