diff options
| author | Oleg Smirnov <olernov@gmail.com> | 2023-04-11 11:18:42 +0700 |
|---|---|---|
| committer | Oleg Smirnov <olernov@gmail.com> | 2023-04-25 20:21:36 +0700 |
| commit | af0e0ad18d5295d57696e3d26d5a7b13dca4e420 (patch) | |
| tree | 3daf3e392ea6d311beefffe4d92967542e714f78 /sql | |
| parent | 9f9a53be4057a1c65478dfd04cd11fe9c079ce59 (diff) | |
| download | mariadb-git-preview-11.1-mdev-8320.tar.gz | |
MDEV-30946 Index usage for DATE(datetime_column) = const does not work for DELETE and UPDATEpreview-11.1-mdev-8320
Add date conditions transformation to the execution paths
of DELETE and UPDATE commands.
Strip excessive prepared statements from the test file
Diffstat (limited to 'sql')
| -rw-r--r-- | sql/sql_delete.cc | 6 | ||||
| -rw-r--r-- | sql/sql_update.cc | 6 |
2 files changed, 12 insertions, 0 deletions
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 93ec11ca063..dcf61e9b085 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -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)) diff --git a/sql/sql_update.cc b/sql/sql_update.cc index ff1d70e7f8e..2be2a85b889 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -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(); |
