summaryrefslogtreecommitdiff
path: root/sql/sql_lex.cc
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2017-06-22 00:41:44 -0700
committerIgor Babaev <igor@askmonty.org>2017-06-22 22:06:03 -0700
commit9f3622191df074d9f4e512320effe86f06b250fb (patch)
tree16aadc76e982cb17349df79a381af23fec27b2f8 /sql/sql_lex.cc
parenta8131e71f9504a7399bc9a7f312b14ed6700d099 (diff)
downloadmariadb-git-9f3622191df074d9f4e512320effe86f06b250fb.tar.gz
Fixed the bug mdev-12845.
This patch fills in a serious flaw in the code that supports condition pushdown into materialized views / derived tables. If a predicate happened to contain a reference to a mergeable view / derived table and it does not depended directly on the target materialized view / derived table then the predicate was not considered as a subject to pusdown to this view / derived table.
Diffstat (limited to 'sql/sql_lex.cc')
-rw-r--r--sql/sql_lex.cc17
1 files changed, 10 insertions, 7 deletions
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index e3ead45447f..9584f2aba36 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -5006,8 +5006,9 @@ void st_select_lex::collect_grouping_fields(THD *thd)
from cond.
*/
-void st_select_lex::check_cond_extraction_for_grouping_fields(Item *cond,
- Item_processor check_processor)
+void
+st_select_lex::check_cond_extraction_for_grouping_fields(Item *cond,
+ TABLE_LIST *derived)
{
cond->clear_extraction_flag();
if (cond->type() == Item::COND_ITEM)
@@ -5020,7 +5021,7 @@ void st_select_lex::check_cond_extraction_for_grouping_fields(Item *cond,
Item *item;
while ((item=li++))
{
- check_cond_extraction_for_grouping_fields(item, check_processor);
+ check_cond_extraction_for_grouping_fields(item, derived);
if (item->get_extraction_flag() != NO_EXTRACTION_FL)
{
count++;
@@ -5041,10 +5042,12 @@ void st_select_lex::check_cond_extraction_for_grouping_fields(Item *cond,
item->clear_extraction_flag();
}
}
- else
- cond->set_extraction_flag(cond->walk(check_processor,
- 0, (uchar *) this) ?
- NO_EXTRACTION_FL : FULL_EXTRACTION_FL);
+ else
+ {
+ int fl= cond->excl_dep_on_grouping_fields(this) ?
+ FULL_EXTRACTION_FL : NO_EXTRACTION_FL;
+ cond->set_extraction_flag(fl);
+ }
}