Commit af0e0ad1 authored by Oleg Smirnov's avatar Oleg Smirnov

MDEV-30946 Index usage for DATE(datetime_column) = const does not work for DELETE and UPDATE

Add date conditions transformation to the execution paths
of DELETE and UPDATE commands.

Strip excessive prepared statements from the test file
parent 9f9a53be
This diff is collapsed.
This diff is collapsed.
......@@ -464,6 +464,12 @@ bool Sql_cmd_delete::delete_from_single_table(THD *thd)
goto produce_explain_and_leave;
}
}
if (conds && thd->lex->are_date_funcs_used())
{
/* Rewrite datetime comparison conditions into sargable */
conds= conds->top_level_transform(thd, &Item::date_conds_transformer,
(uchar *) 0);
}
#ifdef WITH_PARTITION_STORAGE_ENGINE
if (prune_partitions(thd, table, conds))
......
......@@ -433,6 +433,12 @@ bool Sql_cmd_update::update_single_table(THD *thd)
goto produce_explain_and_leave;
}
}
if (conds && thd->lex->are_date_funcs_used())
{
/* Rewrite datetime comparison conditions into sargable */
conds= conds->top_level_transform(thd, &Item::date_conds_transformer,
(uchar *) 0);
}
// Don't count on usage of 'only index' when calculating which key to use
table->covering_keys.clear_all();
......
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