Commit 6ed00c4d authored by Sergey Petrunya's avatar Sergey Petrunya

MDEV-4465: Reproducible crash (mysqld got signal 11) in multi_delete::initialize_tables...

- make multi_delete::initialize_tables() take into account that the JOIN structure may have
  semi-join nests (which are not fully initialized when this function is called, they have 
  tab->table=NULL which caused the crash)
- Also checked multi_update::initialize_tables(): it has a different logic and needed no fixing.
parent 8d75f11a
......@@ -1999,6 +1999,20 @@ b b v v
b b s s
b b y y
DROP TABLE t1,t2;
#
# MDEV-4465: Reproducible crash (mysqld got signal 11) in multi_delete::initialize_tables with semijoin+materialization
#
CREATE TABLE t1 (
id int(11) NOT NULL
);
CREATE TABLE t2 (
id int(11) NOT NULL,
a_id int(11) DEFAULT NULL
);
insert into t1 values (1), (2), (3);
insert into t2 values (1, 1), (2, 1), (3, 1), (4, 2), (5, 3), (6, 3), (7, 3);
delete t2 from t2 where a_id in (select * from (select t1.id from t1 limit 2) as x);
drop table t1,t2;
# This must be at the end:
set optimizer_switch=@subselect_sj_mat_tmp;
set join_cache_level=@save_join_cache_level;
......
......@@ -2039,6 +2039,20 @@ b b v v
b b s s
b b y y
DROP TABLE t1,t2;
#
# MDEV-4465: Reproducible crash (mysqld got signal 11) in multi_delete::initialize_tables with semijoin+materialization
#
CREATE TABLE t1 (
id int(11) NOT NULL
);
CREATE TABLE t2 (
id int(11) NOT NULL,
a_id int(11) DEFAULT NULL
);
insert into t1 values (1), (2), (3);
insert into t2 values (1, 1), (2, 1), (3, 1), (4, 2), (5, 3), (6, 3), (7, 3);
delete t2 from t2 where a_id in (select * from (select t1.id from t1 limit 2) as x);
drop table t1,t2;
# This must be at the end:
set optimizer_switch=@subselect_sj_mat_tmp;
set join_cache_level=@save_join_cache_level;
......@@ -1677,6 +1677,25 @@ SELECT * FROM t1, t2 WHERE b1 IN ( SELECT b2 FROM t2 WHERE b1 > 'o' ) AND ( b1 <
DROP TABLE t1,t2;
--echo #
--echo # MDEV-4465: Reproducible crash (mysqld got signal 11) in multi_delete::initialize_tables with semijoin+materialization
--echo #
CREATE TABLE t1 (
id int(11) NOT NULL
);
CREATE TABLE t2 (
id int(11) NOT NULL,
a_id int(11) DEFAULT NULL
);
insert into t1 values (1), (2), (3);
insert into t2 values (1, 1), (2, 1), (3, 1), (4, 2), (5, 3), (6, 3), (7, 3);
delete t2 from t2 where a_id in (select * from (select t1.id from t1 limit 2) as x);
drop table t1,t2;
--echo # This must be at the end:
set optimizer_switch=@subselect_sj_mat_tmp;
set join_cache_level=@save_join_cache_level;
......
......@@ -677,7 +677,7 @@ multi_delete::initialize_tables(JOIN *join)
tab;
tab= next_linear_tab(join, tab, WITHOUT_BUSH_ROOTS))
{
if (tab->table->map & tables_to_delete_from)
if (!tab->bush_children && tab->table->map & tables_to_delete_from)
{
/* We are going to delete from this table */
TABLE *tbl=walk->table=tab->table;
......
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