Commit fb2501e2 authored by Sergey Petrunya's avatar Sergey Petrunya

MDEV-4277: Crash inside mi_killed_in_mariadb() with myisammrg

- Set MI_INFO::external_ref for MyISAM tables that are parts of myisamMRG table.
parent 8f607aae
......@@ -2369,3 +2369,133 @@ ERROR HY000: Can't reopen table: 'm1'
UNLOCK TABLES;
DROP TABLE t1, t2, t3, m1;
End of 5.1 tests
#
# MDEV-4277: Crash inside mi_killed_in_mariadb() with myisammrg
#
create table t1 (a int);
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table t2 ( i int ) engine=myisam;
insert into t2 values (1),(2);
create table t3 (a int, b int, filler char(100), key(a), key(b)) engine=myisam;
create table t4 like t3;
insert into t3
select A.a+10*B.a+100*C.a,
A.a+10*B.a+100*C.a,
'filler-data-FILLER-DATA-qqq'
from t1 A, t1 B, t1 C where C.a < 5;
insert into t4
select A.a+10*B.a+100*C.a,
A.a+10*B.a+100*C.a,
'filler-data-FILLER-DATA-qqq'
from t1 A, t1 B, t1 C where C.a >= 5;
create table t5 like t3;
alter table t5 engine=merge;
alter table t5 union(t3, t4);
update t5 set b=999, a=999 where b>950;
explain
select * from t2, t5 where t5.a=999 and t5.b=999;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 2
1 SIMPLE t5 index_merge a,b a,b 5,5 NULL 6 Using intersect(a,b); Using where; Using join buffer (flat, BNL join)
select * from t2, t5 where t5.a=999 and t5.b=999;
i a b filler
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
1 999 999 filler-data-FILLER-DATA-qqq
2 999 999 filler-data-FILLER-DATA-qqq
drop table t5;
drop table t1,t2,t3,t4;
......@@ -1865,6 +1865,41 @@ DROP TABLE t1, t2, t3, m1;
--echo End of 5.1 tests
--echo #
--echo # MDEV-4277: Crash inside mi_killed_in_mariadb() with myisammrg
--echo #
create table t1 (a int);
insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table t2 ( i int ) engine=myisam;
insert into t2 values (1),(2);
create table t3 (a int, b int, filler char(100), key(a), key(b)) engine=myisam;
create table t4 like t3;
insert into t3
select A.a+10*B.a+100*C.a,
A.a+10*B.a+100*C.a,
'filler-data-FILLER-DATA-qqq'
from t1 A, t1 B, t1 C where C.a < 5;
insert into t4
select A.a+10*B.a+100*C.a,
A.a+10*B.a+100*C.a,
'filler-data-FILLER-DATA-qqq'
from t1 A, t1 B, t1 C where C.a >= 5;
create table t5 like t3;
alter table t5 engine=merge;
alter table t5 union(t3, t4);
update t5 set b=999, a=999 where b>950;
explain
select * from t2, t5 where t5.a=999 and t5.b=999;
select * from t2, t5 where t5.a=999 and t5.b=999;
drop table t5;
drop table t1,t2,t3,t4;
--disable_result_log
--disable_query_log
eval set global storage_engine=$default;
......
......@@ -422,6 +422,19 @@ static MI_INFO *myisammrg_attach_children_callback(void *callback_param)
DBUG_RETURN(my_errno ? NULL : myisam);
}
/*
Set external_ref for the child MyISAM tables. They need this to be set in
order to check for killed status.
*/
static void myrg_set_external_ref(MYRG_INFO *m_info, void *ext_ref_arg)
{
int i;
for (i= 0; i < (int)m_info->tables; i++)
{
m_info->open_tables[i].table->external_ref= ext_ref_arg;
}
}
/**
@brief Open a MERGE parent table, not its children.
......@@ -467,6 +480,7 @@ int ha_myisammrg::open(const char *name, int mode __attribute__((unused)),
}
file->children_attached= TRUE;
myrg_set_external_ref(file, (void*)table);
info(HA_STATUS_NO_LOCK | HA_STATUS_VARIABLE | HA_STATUS_CONST);
}
......
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