summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <bell@sanja.is.com.ua>2002-11-13 11:59:03 +0200
committerunknown <bell@sanja.is.com.ua>2002-11-13 11:59:03 +0200
commit6ed18d1c9fa444eec6cbb5c5662a13ce7f759e4d (patch)
tree2722c35cc22b1701afca3e2a985b9b2845e1214c
parent0c59356895585b379a599345547c570233c93d50 (diff)
downloadmariadb-git-6ed18d1c9fa444eec6cbb5c5662a13ce7f759e4d.tar.gz
fixed bug of derived table in subselect
fixed bug in error handling mysql-test/r/subselect.result: test of error handling test of derived tables inside subselect mysql-test/t/subselect.test: test of error handling test of derived tables inside subselect sql/sql_class.cc: fixed error handling error sql/sql_lex.h: fifex layout sql/sql_parse.cc: fixed processing of derived tables sql/sql_select.cc: more quick abort on error
-rw-r--r--mysql-test/r/subselect.result8
-rw-r--r--mysql-test/t/subselect.test11
-rw-r--r--sql/sql_class.cc1
-rw-r--r--sql/sql_lex.h2
-rw-r--r--sql/sql_parse.cc25
-rw-r--r--sql/sql_select.cc5
6 files changed, 36 insertions, 16 deletions
diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result
index 77499625bcd..5820c3259be 100644
--- a/mysql-test/r/subselect.result
+++ b/mysql-test/r/subselect.result
@@ -256,4 +256,12 @@ UNIQUE KEY `maxnumrep` (`maxnumrep`)
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);
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 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;
diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test
index 1ee9881c404..cfd22bc48c9 100644
--- a/mysql-test/t/subselect.test
+++ b/mysql-test/t/subselect.test
@@ -152,4 +152,13 @@ CREATE TABLE `forumconthardwarefr7` (
INSERT INTO forumconthardwarefr7 (numeropost,maxnumrep) VALUES (1,0),(2,1);
-- error 1240
select numeropost as a FROM forumconthardwarefr7 GROUP BY (SELECT 1 FROM forumconthardwarefr7 HAVING a=1);
-drop table if exists forumconthardwarefr7; \ No newline at end of file
+-- 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 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;
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 887ee262777..f33d0f2ca28 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -873,7 +873,6 @@ bool select_singleval_subselect::send_data(List<Item> &items)
DBUG_ENTER("select_singleval_subselect::send_data");
Item_singleval_subselect *it= (Item_singleval_subselect *)item;
if (it->assigned()){
- thd->fatal_error= 1;
my_message(ER_SUBSELECT_NO_1_ROW, ER(ER_SUBSELECT_NO_1_ROW), MYF(0));
DBUG_RETURN(1);
}
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index ea944ef34c8..6bafef8a469 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -336,7 +336,7 @@ public:
}
st_select_lex* outer_select();
st_select_lex* next_select() { return (st_select_lex*) next; }
- st_select_lex* next_select_in_list()
+ st_select_lex* next_select_in_list()
{
return (st_select_lex*) link_next;
}
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 52a6c67dda9..60b9cb47946 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -1334,17 +1334,20 @@ mysql_execute_command(THD *thd)
*/
if (lex->derived_tables)
{
- for (TABLE_LIST *cursor= tables;
- cursor;
- cursor= cursor->next)
- if (cursor->derived && (res=mysql_derived(thd, lex,
- (SELECT_LEX_UNIT *)cursor->derived,
- cursor)))
- {
- if (res < 0)
- send_error(thd,thd->killed ? ER_SERVER_SHUTDOWN : 0);
- DBUG_VOID_RETURN;
- }
+ 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->next)
+ if (cursor->derived && (res=mysql_derived(thd, lex,
+ (SELECT_LEX_UNIT *)
+ cursor->derived,
+ cursor)))
+ {
+ if (res < 0)
+ send_error(thd,thd->killed ? ER_SERVER_SHUTDOWN : 0);
+ DBUG_VOID_RETURN;
+ }
}
if ((lex->select_lex.next_select_in_list() &&
lex->unit.create_total_list(thd, lex, &tables)) ||
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 1d1c4656508..5f4bfc5462a 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -994,7 +994,8 @@ JOIN::exec()
}
having=having_list; // Actually a parameter
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;
}
@@ -1078,7 +1079,7 @@ mysql_select(THD *thd, TABLE_LIST *tables, List<Item> &fields, COND *conds,
goto err;
}
- if (free_join && join->global_optimize())
+ if (thd->net.report_error || (free_join && join->global_optimize()))
goto err;
join->exec();