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

fixed bug of derived table in subselect

fixed bug in error handling
parent e3d78f0b
...@@ -256,4 +256,12 @@ UNIQUE KEY `maxnumrep` (`maxnumrep`) ...@@ -256,4 +256,12 @@ UNIQUE KEY `maxnumrep` (`maxnumrep`)
INSERT INTO forumconthardwarefr7 (numeropost,maxnumrep) VALUES (1,0),(2,1); INSERT INTO forumconthardwarefr7 (numeropost,maxnumrep) VALUES (1,0),(2,1);
select numeropost as a FROM forumconthardwarefr7 GROUP BY (SELECT 1 FROM forumconthardwarefr7 HAVING a=1); select numeropost as a FROM forumconthardwarefr7 GROUP BY (SELECT 1 FROM forumconthardwarefr7 HAVING a=1);
Subselect returns more than 1 record Subselect returns more than 1 record
select numeropost as a FROM forumconthardwarefr7 ORDER BY (SELECT 1 FROM forumconthardwarefr7 HAVING a=1);
Subselect returns more than 1 record
drop table if exists forumconthardwarefr7; drop table if exists forumconthardwarefr7;
drop table if exists iftest;
CREATE TABLE iftest (field char(1) NOT NULL DEFAULT 'b');
INSERT INTO iftest VALUES ();
SELECT field FROM iftest WHERE 1=(SELECT 1 UNION ALL SELECT 1 FROM (SELECT 1) HAVING field='b');
Subselect returns more than 1 record
drop table iftest;
...@@ -152,4 +152,13 @@ CREATE TABLE `forumconthardwarefr7` ( ...@@ -152,4 +152,13 @@ CREATE TABLE `forumconthardwarefr7` (
INSERT INTO forumconthardwarefr7 (numeropost,maxnumrep) VALUES (1,0),(2,1); INSERT INTO forumconthardwarefr7 (numeropost,maxnumrep) VALUES (1,0),(2,1);
-- error 1240 -- error 1240
select numeropost as a FROM forumconthardwarefr7 GROUP BY (SELECT 1 FROM forumconthardwarefr7 HAVING a=1); select numeropost as a FROM forumconthardwarefr7 GROUP BY (SELECT 1 FROM forumconthardwarefr7 HAVING a=1);
-- error 1240
select numeropost as a FROM forumconthardwarefr7 ORDER BY (SELECT 1 FROM forumconthardwarefr7 HAVING a=1);
drop table if exists forumconthardwarefr7; drop table if exists forumconthardwarefr7;
drop table if exists iftest;
CREATE TABLE iftest (field char(1) NOT NULL DEFAULT 'b');
INSERT INTO iftest VALUES ();
-- error 1240
SELECT field FROM iftest WHERE 1=(SELECT 1 UNION ALL SELECT 1 FROM (SELECT 1) HAVING field='b');
drop table iftest;
...@@ -873,7 +873,6 @@ bool select_singleval_subselect::send_data(List<Item> &items) ...@@ -873,7 +873,6 @@ bool select_singleval_subselect::send_data(List<Item> &items)
DBUG_ENTER("select_singleval_subselect::send_data"); DBUG_ENTER("select_singleval_subselect::send_data");
Item_singleval_subselect *it= (Item_singleval_subselect *)item; Item_singleval_subselect *it= (Item_singleval_subselect *)item;
if (it->assigned()){ if (it->assigned()){
thd->fatal_error= 1;
my_message(ER_SUBSELECT_NO_1_ROW, ER(ER_SUBSELECT_NO_1_ROW), MYF(0)); my_message(ER_SUBSELECT_NO_1_ROW, ER(ER_SUBSELECT_NO_1_ROW), MYF(0));
DBUG_RETURN(1); DBUG_RETURN(1);
} }
......
...@@ -1334,11 +1334,14 @@ mysql_execute_command(THD *thd) ...@@ -1334,11 +1334,14 @@ mysql_execute_command(THD *thd)
*/ */
if (lex->derived_tables) if (lex->derived_tables)
{ {
for (TABLE_LIST *cursor= tables; for (SELECT_LEX *sl= &lex->select_lex; sl; sl= sl->next_select_in_list())
if (sl->linkage != DERIVED_TABLE_TYPE)
for (TABLE_LIST *cursor= sl->get_table_list();
cursor; cursor;
cursor= cursor->next) cursor= cursor->next)
if (cursor->derived && (res=mysql_derived(thd, lex, if (cursor->derived && (res=mysql_derived(thd, lex,
(SELECT_LEX_UNIT *)cursor->derived, (SELECT_LEX_UNIT *)
cursor->derived,
cursor))) cursor)))
{ {
if (res < 0) if (res < 0)
......
...@@ -994,7 +994,8 @@ JOIN::exec() ...@@ -994,7 +994,8 @@ JOIN::exec()
} }
having=having_list; // Actually a parameter having=having_list; // Actually a parameter
thd->proc_info="Sending data"; thd->proc_info="Sending data";
error=do_select(this, &fields_list, NULL, procedure); error= thd->net.report_error ||
do_select(this, &fields_list, NULL, procedure);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
...@@ -1078,7 +1079,7 @@ mysql_select(THD *thd, TABLE_LIST *tables, List<Item> &fields, COND *conds, ...@@ -1078,7 +1079,7 @@ mysql_select(THD *thd, TABLE_LIST *tables, List<Item> &fields, COND *conds,
goto err; goto err;
} }
if (free_join && join->global_optimize()) if (thd->net.report_error || (free_join && join->global_optimize()))
goto err; goto err;
join->exec(); join->exec();
......
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