diff options
author | dlenev@brandersnatch.localdomain <> | 2004-08-20 19:30:45 +0400 |
---|---|---|
committer | dlenev@brandersnatch.localdomain <> | 2004-08-20 19:30:45 +0400 |
commit | b4105df897f5653358dda59b4c81fc4a0c8103f7 (patch) | |
tree | ef5a56fdd09959b03ed0bd03c6e5ce93ba678d14 /mysql-test | |
parent | a71f1894d0fa6716eb34262b2c7f026c5c1248da (diff) | |
parent | c8882165f37b196067296eb45dcba098e669a174 (diff) | |
download | mariadb-git-b4105df897f5653358dda59b4c81fc4a0c8103f7.tar.gz |
Merge bk-internal.mysql.com:/home/bk/mysql-4.1
into brandersnatch.localdomain:/home/dlenev/src/mysql-4.1-bg4302
Diffstat (limited to 'mysql-test')
-rw-r--r-- | mysql-test/r/order_by.result | 73 | ||||
-rw-r--r-- | mysql-test/t/order_by.test | 45 |
2 files changed, 111 insertions, 7 deletions
diff --git a/mysql-test/r/order_by.result b/mysql-test/r/order_by.result index 694dc26bcde..b3bc4a18a40 100644 --- a/mysql-test/r/order_by.result +++ b/mysql-test/r/order_by.result @@ -116,7 +116,7 @@ col1 2 3 2 -select col1 as id from t1 order by t1.id; +select col1 as id from t1 order by id; id 1 1 @@ -126,16 +126,16 @@ id 2 2 3 -select concat(col1) as id from t1 order by t1.id; +select concat(col1) as id from t1 order by id; id -2 -2 1 1 1 2 -3 2 +2 +2 +3 drop table t1; CREATE TABLE t1 (id int auto_increment primary key,aika varchar(40),aikakentta timestamp); insert into t1 (aika) values ('Keskiviikko'); @@ -660,3 +660,66 @@ a b c d 1 1 12 -1 1 1 2 0 drop table t1, t2; +create table t1 (col1 int, col int); +create table t2 (col2 int, col int); +insert into t1 values (1,1),(2,2),(3,3); +insert into t2 values (1,3),(2,2),(3,1); +select t1.* , t2.col as t2_col from t1 left join t2 on (t1.col1=t2.col2) +order by col; +col1 col t2_col +1 1 3 +2 2 2 +3 3 1 +select col1 as col, col from t1 order by col; +ERROR 23000: Column 'col' in order clause is ambiguous +select t1.col as c1, t2.col as c2 from t1, t2 where t1.col1=t2.col2 +order by col; +ERROR 23000: Column 'col' in order clause is ambiguous +select t1.col as c1, t2.col as c2 from t1, t2 where t1.col1=t2.col2 +order by col; +ERROR 23000: Column 'col' in order clause is ambiguous +select col1 from t1, t2 where t1.col1=t2.col2 order by col; +ERROR 23000: Column 'col' in order clause is ambiguous +select t1.col as t1_col, t2.col from t1, t2 where t1.col1=t2.col2 +order by col; +t1_col col +3 1 +2 2 +1 3 +select col2 as c, col as c from t2 order by col; +c c +3 1 +2 2 +1 3 +select col2 as col, col as col2 from t2 order by col; +col col2 +1 3 +2 2 +3 1 +select t1.col as t1_col, t2.col2 from t1, t2 where t1.col1=t2.col2 +order by col; +t1_col col2 +1 1 +2 2 +3 3 +select t2.col2, t2.col, t2.col from t2 order by col; +col2 col col +3 1 1 +2 2 2 +1 3 3 +select t2.col2 as col from t2 order by t2.col; +col +3 +2 +1 +select t2.col2 as col, t2.col from t2 order by t2.col; +col col +3 1 +2 2 +1 3 +select t2.col2, t2.col, t2.col from t2 order by t2.col; +col2 col col +3 1 1 +2 2 2 +1 3 3 +drop table t1, t2; diff --git a/mysql-test/t/order_by.test b/mysql-test/t/order_by.test index 465920deaed..5131bb8c8b8 100644 --- a/mysql-test/t/order_by.test +++ b/mysql-test/t/order_by.test @@ -97,8 +97,8 @@ create table t1 (id int not null,col1 int not null,col2 int not null,index(col1) insert into t1 values(1,2,2),(2,2,1),(3,1,2),(4,1,1),(5,1,4),(6,2,3),(7,3,1),(8,2,4); select * from t1 order by col1,col2; select col1 from t1 order by id; -select col1 as id from t1 order by t1.id; -select concat(col1) as id from t1 order by t1.id; +select col1 as id from t1 order by id; +select concat(col1) as id from t1 order by id; drop table t1; # @@ -445,3 +445,44 @@ insert into t1 select 1, b, c + (@row:=@row - 1) * 10, d - @row from t2 limit 10 select * from t1 where a=1 and b in (1) order by c, b, a; select * from t1 where a=1 and b in (1); drop table t1, t2; + +# +# Bug #4302 +# Ambiguos order by when renamed column is identical to another in result. +# Should not fail and prefer column from t1 for sorting. +# +create table t1 (col1 int, col int); +create table t2 (col2 int, col int); +insert into t1 values (1,1),(2,2),(3,3); +insert into t2 values (1,3),(2,2),(3,1); +select t1.* , t2.col as t2_col from t1 left join t2 on (t1.col1=t2.col2) + order by col; + +# +# Let us also test various ambiguos and potentially ambiguos cases +# related to aliases +# +--error 1052 +select col1 as col, col from t1 order by col; +--error 1052 +select t1.col as c1, t2.col as c2 from t1, t2 where t1.col1=t2.col2 + order by col; +--error 1052 +select t1.col as c1, t2.col as c2 from t1, t2 where t1.col1=t2.col2 + order by col; +--error 1052 +select col1 from t1, t2 where t1.col1=t2.col2 order by col; + +select t1.col as t1_col, t2.col from t1, t2 where t1.col1=t2.col2 + order by col; +select col2 as c, col as c from t2 order by col; +select col2 as col, col as col2 from t2 order by col; +select t1.col as t1_col, t2.col2 from t1, t2 where t1.col1=t2.col2 + order by col; +select t2.col2, t2.col, t2.col from t2 order by col; + +select t2.col2 as col from t2 order by t2.col; +select t2.col2 as col, t2.col from t2 order by t2.col; +select t2.col2, t2.col, t2.col from t2 order by t2.col; + +drop table t1, t2; |