Commit 4078d0de authored by unknown's avatar unknown

fixed bug IN subselect with ORDER


mysql-test/r/subselect.result:
  test of IN subselect with ORDER
mysql-test/t/subselect.test:
  test of IN subselect with ORDER
parent 53a81804
......@@ -32,6 +32,9 @@ a
1
SELECT 1 FROM (SELECT (SELECT a));
Unknown column 'a' in 'field list'
SELECT * FROM (SELECT 1 as id) WHERE id IN (SELECT * FROM (SELECT 1 as id) ORDER BY id LIMIT 1);
id
1
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8;
create table t1 (a int);
create table t2 (a int, b int);
......
......@@ -15,6 +15,8 @@ SELECT (SELECT 1), a;
SELECT 1 as a FROM (SELECT 1) HAVING (SELECT a)=1;
-- error 1054
SELECT 1 FROM (SELECT (SELECT a));
SELECT * FROM (SELECT 1 as id) WHERE id IN (SELECT * FROM (SELECT 1 as id) ORDER BY id LIMIT 1);
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8;
create table t1 (a int);
create table t2 (a int, b int);
......
......@@ -300,15 +300,22 @@ void Item_in_subselect::single_value_transformer(st_select_lex *select_lex,
Item *expr= new Item_outer_select_context_saver(left_expr);
if (sl->having || sl->with_sum_func || sl->group_list.first)
if (sl->having || sl->with_sum_func || sl->group_list.first ||
sl->order_list.first)
{
sl->item_list.push_back(item);
item= (*func)(expr, new Item_ref(sl->item_list.head_ref(),
0, (char*)"<result>"));
if (sl->having)
sl->having= new Item_cond_and(sl->having, item);
if (sl->having || sl->with_sum_func || sl->group_list.first)
if (sl->having)
sl->having= new Item_cond_and(sl->having, item);
else
sl->having= item;
else
sl->having= item;
if (sl->where)
sl->where= new Item_cond_and(sl->having, item);
else
sl->where= item;
}
else
{
......
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