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

fixed error handling bug

fixed naming bug
fixed bug of subselect excluding
parent e1cb8679
...@@ -35,6 +35,14 @@ Unknown column 'a' in 'field list' ...@@ -35,6 +35,14 @@ 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); SELECT * FROM (SELECT 1 as id) WHERE id IN (SELECT * FROM (SELECT 1 as id) ORDER BY id LIMIT 1);
id id
1 1
SELECT * FROM (SELECT 1) WHERE 1 IN (SELECT 1,1);
Cardinality error (more/less than 1 columns)
SELECT 1 IN (SELECT 1);
1 IN (SELECT 1)
1
SELECT 1 FROM (SELECT 1 as a) WHERE 1 IN (SELECT (SELECT a));
1
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);
......
...@@ -16,6 +16,10 @@ SELECT 1 as a FROM (SELECT 1) HAVING (SELECT a)=1; ...@@ -16,6 +16,10 @@ 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); SELECT * FROM (SELECT 1 as id) WHERE id IN (SELECT * FROM (SELECT 1 as id) ORDER BY id LIMIT 1);
-- error 1239
SELECT * FROM (SELECT 1) WHERE 1 IN (SELECT 1,1);
SELECT 1 IN (SELECT 1);
SELECT 1 FROM (SELECT 1 as a) WHERE 1 IN (SELECT (SELECT a));
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);
......
...@@ -92,6 +92,7 @@ bool Item_subselect::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) ...@@ -92,6 +92,7 @@ bool Item_subselect::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
if (substitution) if (substitution)
{ {
(*ref)= substitution; (*ref)= substitution;
substitution->name= name;
engine->exclude(); engine->exclude();
return substitution->fix_fields(thd, tables, ref); return substitution->fix_fields(thd, tables, ref);
} }
...@@ -293,7 +294,7 @@ void Item_in_subselect::single_value_transformer(st_select_lex *select_lex, ...@@ -293,7 +294,7 @@ void Item_in_subselect::single_value_transformer(st_select_lex *select_lex,
if (sl->item_list.elements > 1) if (sl->item_list.elements > 1)
{ {
my_error(ER_CARDINALITY_COL, MYF(0), 1); my_error(ER_CARDINALITY_COL, MYF(0), 1);
item= 0; // Item_asterisk_remover must fail DBUG_VOID_RETURN;
} }
else else
item= (Item*) sl->item_list.pop(); item= (Item*) sl->item_list.pop();
......
...@@ -1071,7 +1071,10 @@ void st_select_lex_unit::exclude_level() ...@@ -1071,7 +1071,10 @@ void st_select_lex_unit::exclude_level()
sl->link_next->link_prev= sl->link_prev; sl->link_next->link_prev= sl->link_prev;
SELECT_LEX_UNIT **last= 0; SELECT_LEX_UNIT **last= 0;
for (SELECT_LEX_UNIT *u= sl->first_inner_unit(); u; u= u->next_unit()) for (SELECT_LEX_UNIT *u= sl->first_inner_unit(); u; u= u->next_unit())
{
u->master= master;
last= (SELECT_LEX_UNIT**)&(u->next); last= (SELECT_LEX_UNIT**)&(u->next);
}
if (last) if (last)
{ {
(*units_last)= sl->first_inner_unit(); (*units_last)= sl->first_inner_unit();
......
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