Commit 8e8678be authored by bell@sanja.is.com.ua's avatar bell@sanja.is.com.ua

fixed bug IN subselect with ORDER

parent 0b8054ac
...@@ -32,6 +32,9 @@ a ...@@ -32,6 +32,9 @@ a
1 1
SELECT 1 FROM (SELECT (SELECT a)); SELECT 1 FROM (SELECT (SELECT a));
Unknown column 'a' in 'field list' 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; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8;
create table t1 (a int); create table t1 (a int);
create table t2 (a int, b int); create table t2 (a int, b int);
......
...@@ -15,6 +15,8 @@ SELECT (SELECT 1), a; ...@@ -15,6 +15,8 @@ SELECT (SELECT 1), a;
SELECT 1 as a FROM (SELECT 1) HAVING (SELECT a)=1; SELECT 1 as a FROM (SELECT 1) HAVING (SELECT a)=1;
-- error 1054 -- error 1054
SELECT 1 FROM (SELECT (SELECT a)); 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; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8;
create table t1 (a int); create table t1 (a int);
create table t2 (a int, b int); create table t2 (a int, b int);
......
...@@ -300,15 +300,22 @@ void Item_in_subselect::single_value_transformer(st_select_lex *select_lex, ...@@ -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); 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); sl->item_list.push_back(item);
item= (*func)(expr, new Item_ref(sl->item_list.head_ref(), item= (*func)(expr, new Item_ref(sl->item_list.head_ref(),
0, (char*)"<result>")); 0, (char*)"<result>"));
if (sl->having || sl->with_sum_func || sl->group_list.first)
if (sl->having) if (sl->having)
sl->having= new Item_cond_and(sl->having, item); sl->having= new Item_cond_and(sl->having, item);
else else
sl->having= item; sl->having= item;
else
if (sl->where)
sl->where= new Item_cond_and(sl->having, item);
else
sl->where= item;
} }
else 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