summaryrefslogtreecommitdiff
path: root/sql/sql_select.cc
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2018-07-24 23:45:55 -0700
committerIgor Babaev <igor@askmonty.org>2018-07-24 23:53:12 -0700
commit1fde449f1d4e8ebe12e989754bfdc84b123cf0b2 (patch)
tree34c15aa81a621c51029cb0145ea31c208d578287 /sql/sql_select.cc
parent57cde8ccd19675dc98e3cbacf0ef5c72cb188e49 (diff)
downloadmariadb-git-1fde449f1d4e8ebe12e989754bfdc84b123cf0b2.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 e3b725ce1f6..460a64e1a7a 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -1212,6 +1212,13 @@ JOIN::optimize_inner()
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);