diff options
-rw-r--r-- | mysql-test/r/subselect.result | 8 | ||||
-rw-r--r-- | mysql-test/t/subselect.test | 4 | ||||
-rw-r--r-- | sql/item_subselect.cc | 3 | ||||
-rw-r--r-- | sql/sql_lex.cc | 3 |
4 files changed, 17 insertions, 1 deletions
diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index 523c3af91c4..bbf70150ee0 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -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); id 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; create table t1 (a int); create table t2 (a int, b int); diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index 17f3008b62e..c875f8372b3 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -16,6 +16,10 @@ 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); +-- 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; create table t1 (a int); diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 6d55f7399c1..e087664e060 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -92,6 +92,7 @@ bool Item_subselect::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) if (substitution) { (*ref)= substitution; + substitution->name= name; engine->exclude(); return substitution->fix_fields(thd, tables, ref); } @@ -293,7 +294,7 @@ void Item_in_subselect::single_value_transformer(st_select_lex *select_lex, if (sl->item_list.elements > 1) { my_error(ER_CARDINALITY_COL, MYF(0), 1); - item= 0; // Item_asterisk_remover must fail + DBUG_VOID_RETURN; } else item= (Item*) sl->item_list.pop(); diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index c50321ebed7..be0430d4afe 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1071,7 +1071,10 @@ void st_select_lex_unit::exclude_level() sl->link_next->link_prev= sl->link_prev; SELECT_LEX_UNIT **last= 0; for (SELECT_LEX_UNIT *u= sl->first_inner_unit(); u; u= u->next_unit()) + { + u->master= master; last= (SELECT_LEX_UNIT**)&(u->next); + } if (last) { (*units_last)= sl->first_inner_unit(); |