Commit 29c7aff7 authored by Vicențiu Ciorbaru's avatar Vicențiu Ciorbaru Committed by Vicentiu Ciorbaru

MDEV-8063: Unconditional ANALYZE DELETE does not delete rows

When detecting a statement that can make use of ha_delete_all_rows(),
we refrained from running the statement when being presented
with the analyze or explain prefix.
parent 20c23048
......@@ -315,3 +315,20 @@ id select_type table type possible_keys key key_len ref rows r_rows filtered r_f
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10.00 100.00 100.00 Using where
1 SIMPLE t2 ref a a 5 test.t1.a 2 0.20 100.00 100.00 Using index
drop table t1,t2;
#
# MDEV-8063: Unconditional ANALYZE DELETE does not delete rows
#
create table t1 (i int);
insert into t1 values (1),(2);
analyze delete from t1;
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL 2 NULL NULL NULL Deleting all rows
select * from t1;
i
insert into t1 values (1),(2);
explain delete from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL 2 Deleting all rows
select * from t1;
i
drop table t1;
......@@ -258,3 +258,18 @@ insert into t2 values (0),(1);
analyze select * from t1 straight_join t2 force index(a) where t2.a=t1.a;
drop table t1,t2;
--echo #
--echo # MDEV-8063: Unconditional ANALYZE DELETE does not delete rows
--echo #
create table t1 (i int);
insert into t1 values (1),(2);
analyze delete from t1;
select * from t1;
insert into t1 values (1),(2);
explain delete from t1;
select * from t1;
drop table t1;
......@@ -347,8 +347,6 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
DBUG_PRINT("debug", ("Trying to use delete_all_rows()"));
query_plan.set_delete_all_rows(maybe_deleted);
if (thd->lex->describe || thd->lex->analyze_stmt)
goto produce_explain_and_leave;
if (!(error=table->file->ha_delete_all_rows()))
{
......@@ -359,6 +357,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
query_type= THD::STMT_QUERY_TYPE;
error= -1;
deleted= maybe_deleted;
query_plan.save_explain_delete_data(thd->mem_root, thd);
goto cleanup;
}
if (error != HA_ERR_WRONG_COMMAND)
......@@ -698,9 +697,8 @@ cleanup:
if (error < 0 ||
(thd->lex->ignore && !thd->is_error() && !thd->is_fatal_error))
{
if (thd->lex->analyze_stmt)
if (thd->lex->describe || thd->lex->analyze_stmt)
{
error= 0;
goto send_nothing_and_leave;
}
......
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