summaryrefslogtreecommitdiff
path: root/sql/sql_select.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r--sql/sql_select.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 9b9d93d182e..12d4eb2cd79 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -2257,6 +2257,8 @@ JOIN::optimize_inner()
}
transform_in_predicates_into_equalities(thd);
+ if (thd->lex->are_date_funcs_used())
+ transform_date_conds_into_sargable();
conds= optimize_cond(this, conds, join_list, ignore_on_expr,
&cond_value, &cond_equal, OPT_LINK_EQUAL_FIELDS);
@@ -31095,6 +31097,20 @@ bool JOIN::transform_in_predicates_into_equalities(THD *thd)
/**
@brief
+ Rewrite datetime comparison conditions into sargable.
+ See details in the description for class Date_cmp_func_rewriter
+*/
+
+bool JOIN::transform_date_conds_into_sargable()
+{
+ DBUG_ENTER("JOIN::transform_date_conds_into_sargable");
+ DBUG_RETURN(transform_all_conds_and_on_exprs(
+ thd, &Item::date_conds_transformer));
+}
+
+
+/**
+ @brief
Transform all items in WHERE and ON expressions using a given transformer
@param thd The context of the statement