summaryrefslogtreecommitdiff
path: root/sql/sql_select.cc
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2018-07-24 20:00:28 -0700
committerIgor Babaev <igor@askmonty.org>2018-07-24 20:00:28 -0700
commitd567f1611e27a17427380e9aae67939792f68ad1 (patch)
tree96821ecf4292951ce29d26a246e467b958287fec /sql/sql_select.cc
parent9cea4ccf12cb6e8746b9b440d9c62408a9ef04af (diff)
downloadmariadb-git-d567f1611e27a17427380e9aae67939792f68ad1.tar.gz
MDEV-16820 Lost 'Impossible where' from query with inexpensive subquery
This patch fixes another problem introduced by the patch for mdev-4817. The latter changed Item_cond::fix_fields() in such a way that it could call the virtual method is_expensive(). With the first its call the method saves the result in Item::is_expensive_cache. For all next calls the method returns the result from this cache. So if the item once was determined as expensive the method always returns true. For subqueries it's not good, because non-optimized subqueries always is considered as expensive. It means that the cache should be invalidated after the call of optimize_constant_subqueries().
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r--sql/sql_select.cc7
1 files changed, 7 insertions, 0 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 6a64a0e9952..5228dd4f439 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -1098,6 +1098,13 @@ JOIN::optimize()
if (optimize_constant_subqueries())
DBUG_RETURN(1);
+ if (conds && conds->has_subquery())
+ (void) conds->walk(&Item::cleanup_is_expensive_cache_processor,
+ 0, (uchar*)0);
+ if (having && having->has_subquery())
+ (void) having->walk(&Item::cleanup_is_expensive_cache_processor,
+ 0, (uchar*)0);
+
if (setup_jtbm_semi_joins(this, join_list, &conds))
DBUG_RETURN(1);