summaryrefslogtreecommitdiff
path: root/mysql-test/r/order_by.result
diff options
context:
space:
mode:
authorunknown <dlenev@brandersnatch.localdomain>2004-08-20 17:53:46 +0400
committerunknown <dlenev@brandersnatch.localdomain>2004-08-20 17:53:46 +0400
commitf9c3cb5f2e764955890c9a4db8d791a47561d130 (patch)
tree65bfed51926a7496b1598c32ff98e04e45df07a7 /mysql-test/r/order_by.result
parente21380034c00f3edb0ed0a7a3cfc196cff3c56d2 (diff)
downloadmariadb-git-f9c3cb5f2e764955890c9a4db8d791a47561d130.tar.gz
Fix for bug#4302 "ambiguos order by when renamed column is identical to another in result"
When in find_item_in_list() we are looking for item we should take into account unaliased names of the fields but only if item with such aliased name is not found. Also we should ignore aliases when looking for fully specified field. mysql-test/r/order_by.result: Fixed wrong (non-standard) test results Added test case for bug #4302 Added tests for other ambiguos and potentially ambigous cases in order by clause mysql-test/t/order_by.test: Fixed wrong (non-standard) test results Added test case for bug #4302 Added tests for other ambiguos and potentially ambigous cases in order by clause sql/sql_select.cc: We should ignore only not_found_item errors when searching for item in find_order_in_list() to be able to catch ambiguities.
Diffstat (limited to 'mysql-test/r/order_by.result')
-rw-r--r--mysql-test/r/order_by.result73
1 files changed, 68 insertions, 5 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;