Commit ae331d61 authored by unknown's avatar unknown

Fixed bug#19225: unchecked error results in server crash

In multi-table delete a table for delete can't be used for selecting in
subselects. Appropriate error was raised but wasn't checked which leads to a
crash at the execution phase.

The mysql_execute_command() now checks for errors before executing select
for multi-delete.


mysql-test/t/multi_update.test:
  Added test case for bug#19225: unchecked error results in server crash
mysql-test/r/multi_update.result:
  Added test case for bug#19225: unchecked error results in server crash
sql/sql_parse.cc:
  Fixed bug#19225: unchecked error results in server crash
  The mysql_execute_command() now checks for errors before executing select for multi-delete.
parent fa6a2687
......@@ -475,3 +475,8 @@ aclid bigint, index idx_acl(aclid)
insert into t2 values(1,null);
delete t2, t1 from t2 left join t1 on (t2.aclid=t1.aclid) where t2.refid='1';
drop table t1, t2;
create table t1(a int);
create table t2(a int);
delete from t1,t2 using t1,t2 where t1.a=(select a from t1);
ERROR HY000: You can't specify target table 't1' for update in FROM clause
drop table t1, t2;
......@@ -448,4 +448,12 @@ insert into t2 values(1,null);
delete t2, t1 from t2 left join t1 on (t2.aclid=t1.aclid) where t2.refid='1';
drop table t1, t2;
#
# Bug#19225: unchecked error leads to server crash
#
create table t1(a int);
create table t2(a int);
--error 1093
delete from t1,t2 using t1,t2 where t1.a=(select a from t1);
drop table t1, t2;
# End of 4.1 tests
......@@ -3047,8 +3047,8 @@ mysql_execute_command(THD *thd)
}
}
if (!thd->is_fatal_error && (result= new multi_delete(thd,aux_tables,
table_count)))
if (!res && !thd->is_fatal_error &&
(result= new multi_delete(thd,aux_tables, table_count)))
{
res= mysql_select(thd, &select_lex->ref_pointer_array,
select_lex->get_table_list(),
......
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