mirror of
https://github.com/MariaDB/server.git
synced 2025-04-09 00:35:40 +02:00
MDEV-8282: crash in filesort() with simple ordered delete
Handle the case where the optimizer decides to use handler->delete_all_rows(), but then this call returns HA_ERR_UNSUPPORTED and execution switches to regular row-by-row deletion.
This commit is contained in:
parent
12d9fe14be
commit
f33173d19e
4 changed files with 41 additions and 0 deletions
|
@ -364,3 +364,20 @@ ANALYZE
|
|||
}
|
||||
drop table t2;
|
||||
drop table t0, t1;
|
||||
#
|
||||
# MDEV-8282: crash in filesort() with simple ordered delete
|
||||
#
|
||||
create table t1(a int) engine=innodb;
|
||||
delete from t1 order by a;
|
||||
# EXPLAIN thinks it will use delete_all_rows():
|
||||
explain
|
||||
delete from t1 order by a;
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE NULL NULL NULL NULL NULL NULL 1 Deleting all rows
|
||||
# ANALYZE shows that delete_all_rows() didn't work and we deleted rows
|
||||
# one-by-one:
|
||||
analyze
|
||||
delete from t1 order by a;
|
||||
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 1 0.00 100.00 100.00 Using filesort
|
||||
drop table t1;
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
--source include/have_innodb.inc
|
||||
|
||||
create table t0(a int);
|
||||
insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
|
||||
|
||||
|
@ -91,3 +93,20 @@ select MAX(b) from t2 where mod(a,2)=0 group by c;
|
|||
drop table t2;
|
||||
drop table t0, t1;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-8282: crash in filesort() with simple ordered delete
|
||||
--echo #
|
||||
create table t1(a int) engine=innodb;
|
||||
delete from t1 order by a;
|
||||
|
||||
--echo # EXPLAIN thinks it will use delete_all_rows():
|
||||
explain
|
||||
delete from t1 order by a;
|
||||
|
||||
--echo # ANALYZE shows that delete_all_rows() didn't work and we deleted rows
|
||||
--echo # one-by-one:
|
||||
analyze
|
||||
delete from t1 order by a;
|
||||
|
||||
drop table t1;
|
||||
|
||||
|
|
|
@ -370,6 +370,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
|
|||
goto cleanup;
|
||||
}
|
||||
/* Handler didn't support fast delete; Delete rows one by one */
|
||||
query_plan.cancel_delete_all_rows();
|
||||
}
|
||||
if (conds)
|
||||
{
|
||||
|
|
|
@ -2372,6 +2372,10 @@ public:
|
|||
deleting_all_rows= true;
|
||||
scanned_rows= rows_arg;
|
||||
}
|
||||
void cancel_delete_all_rows()
|
||||
{
|
||||
deleting_all_rows= false;
|
||||
}
|
||||
|
||||
Explain_delete* save_explain_delete_data(MEM_ROOT *mem_root, THD *thd);
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue