Commit bb9584fd authored by unknown's avatar unknown

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)


sql/sql_union.cc:
  A fix for a bug that allowed table names to be used in ORDER BY columns (But #3064)
mysql-test/t/union.test:
  A test case for the bug  that allowed table names to be used in ORDER BY columns (But #3064)
mysql-test/r/union.result:
   A test case for the bug  that allowed table names to be used in ORDER BY columns (But #3064)
parent 1f115bc2
...@@ -422,6 +422,8 @@ Wrong usage/placement of 'SQL_CALC_FOUND_ROWS' ...@@ -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 temporary table t1 select a from t1 union select a from t2;
create 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 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; drop table t1,t2;
select length(version()) > 1 as `*` UNION select 2; select length(version()) > 1 as `*` UNION select 2;
* *
......
...@@ -226,6 +226,8 @@ SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a desc LIMIT 1; ...@@ -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; create temporary table t1 select a from t1 union select a from t2;
--error 1093 --error 1093
create table t1 select a from t1 union select a from t2; 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; drop table t1,t2;
# #
......
...@@ -100,6 +100,7 @@ int mysql_union(THD *thd, LEX *lex,select_result *result) ...@@ -100,6 +100,7 @@ int mysql_union(THD *thd, LEX *lex,select_result *result)
else else
{ {
Item *item; Item *item;
ORDER *orr;
List_iterator<Item> it(lex->select_lex.item_list); List_iterator<Item> it(lex->select_lex.item_list);
TABLE_LIST *first_table= (TABLE_LIST*) lex->select_lex.table_list.first; 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) ...@@ -110,6 +111,15 @@ int mysql_union(THD *thd, LEX *lex,select_result *result)
if (setup_tables(first_table) || if (setup_tables(first_table) ||
setup_fields(thd,first_table,item_list,0,0,1)) setup_fields(thd,first_table,item_list,0,0,1))
DBUG_RETURN(-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)); bzero((char*) &tmp_table_param,sizeof(tmp_table_param));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment