From 8c4b59b72ce3e3928217aaeb4e758895f62a2a73 Mon Sep 17 00:00:00 2001 From: "Sinisa@sinisa.nasamreza.org" <> Date: Mon, 15 Mar 2004 19:17:18 +0200 Subject: [PATCH 1/2] update.test: a fix for a test with latest change --- mysql-test/t/update.test | 1 - 1 file changed, 1 deletion(-) diff --git a/mysql-test/t/update.test b/mysql-test/t/update.test index a455b308158..2e739dd927d 100644 --- a/mysql-test/t/update.test +++ b/mysql-test/t/update.test @@ -119,7 +119,6 @@ insert into t1 (F1,F2,F3,cnt,groupid) values ('0','0','0',1,6), ('0','1','2',1,5), ('0','2','0',1,3), ('1','0','1',1,2), ('1','2','1',1,1), ('1','2','2',1,1), ('2','0','1',2,4), ('2','2','0',1,7); - delete from t1 using t1 m1,t1 m2 where m1.groupid=m2.groupid and (m1.cnt < m2.cnt or m1.cnt=m2.cnt and m1.F3>m2.F3); select * from t1; drop table t1; From 2eaa07f1993f3719874e65aeb39f37539e19311b Mon Sep 17 00:00:00 2001 From: "Sinisa@sinisa.nasamreza.org" <> Date: Mon, 22 Mar 2004 16:35:15 +0200 Subject: [PATCH 2/2] union.result: A test case for the bug that allowed table names to be used in ORDER BY columns (But #3064) union.test: A test case for the bug that allowed table names to be used in ORDER BY columns (But #3064) sql_union.cc: A fix for a bug that allowed table names to be used in ORDER BY columns (But #3064) --- mysql-test/r/union.result | 2 ++ mysql-test/t/union.test | 2 ++ sql/sql_union.cc | 10 ++++++++++ 3 files changed, 14 insertions(+) diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result index fc5aa1ad0cb..4b9555c334b 100644 --- a/mysql-test/r/union.result +++ b/mysql-test/r/union.result @@ -422,6 +422,8 @@ Wrong usage/placement of 'SQL_CALC_FOUND_ROWS' create temporary table t1 select a from t1 union select a from t2; create table t1 select a from t1 union select a from t2; INSERT TABLE 't1' isn't allowed in FROM table list +select a from t1 union select a from t2 order by t2.a; +Unknown column 't2.a' in 'ORDER BY' drop table t1,t2; select length(version()) > 1 as `*` UNION select 2; * diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test index badfe4b9a3a..c978aef9ce0 100644 --- a/mysql-test/t/union.test +++ b/mysql-test/t/union.test @@ -226,6 +226,8 @@ SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a desc LIMIT 1; create temporary table t1 select a from t1 union select a from t2; --error 1093 create table t1 select a from t1 union select a from t2; +--error 1054 +select a from t1 union select a from t2 order by t2.a; drop table t1,t2; # diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 34acd79f18b..8088737c0de 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -100,6 +100,7 @@ int mysql_union(THD *thd, LEX *lex,select_result *result) else { Item *item; + ORDER *orr; List_iterator it(lex->select_lex.item_list); TABLE_LIST *first_table= (TABLE_LIST*) lex->select_lex.table_list.first; @@ -110,6 +111,15 @@ int mysql_union(THD *thd, LEX *lex,select_result *result) if (setup_tables(first_table) || setup_fields(thd,first_table,item_list,0,0,1)) DBUG_RETURN(-1); + for (orr=order;orr;orr=orr->next) + { + item=*orr->item; + if (((item->type() == Item::FIELD_ITEM) && ((class Item_field*)item)->table_name)) + { + my_error(ER_BAD_FIELD_ERROR,MYF(0),item->full_name(),"ORDER BY"); + DBUG_RETURN(-1); + } + } } bzero((char*) &tmp_table_param,sizeof(tmp_table_param));