diff options
author | Igor Babaev <igor@askmonty.org> | 2016-11-26 21:22:49 -0800 |
---|---|---|
committer | Igor Babaev <igor@askmonty.org> | 2016-11-26 21:23:39 -0800 |
commit | 1d0f17415a7b0907498fbdf7b499862bed790edd (patch) | |
tree | 893ec1c027e76ea5e32a371bdb4a0b10b87c9575 /sql | |
parent | b5b68b6bb809624b7cee6464eabb4b633443add0 (diff) | |
download | mariadb-git-1d0f17415a7b0907498fbdf7b499862bed790edd.tar.gz |
Fixed bug mdev-11313.
The fix for bug 11072 was not complete though it also fixed
the bug mdev-10800.
This patch resolves the problems of all three bugs.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item.h | 18 | ||||
-rw-r--r-- | sql/sql_derived.cc | 10 |
2 files changed, 18 insertions, 10 deletions
diff --git a/sql/item.h b/sql/item.h index 7844b6766d1..1641c6d17bb 100644 --- a/sql/item.h +++ b/sql/item.h @@ -1560,7 +1560,7 @@ public: { return 0; } virtual bool exclusive_dependence_on_grouping_fields_processor(void *arg) { return 0; } - virtual bool cleanup_excluding_outer_fields_processor(void *arg) + virtual bool cleanup_excluding_const_fields_processor(void *arg) { return cleanup_processor(arg); } virtual Item *get_copy(THD *thd, MEM_ROOT *mem_root)=0; @@ -2664,9 +2664,9 @@ public: virtual void print(String *str, enum_query_type query_type); bool exclusive_dependence_on_table_processor(void *map); bool exclusive_dependence_on_grouping_fields_processor(void *arg); - bool cleanup_excluding_outer_fields_processor(void *arg) - { return depended_from ? 0 : cleanup_processor(arg); } - + bool cleanup_excluding_const_fields_processor(void *arg) + { return field && const_item() ? 0 : cleanup_processor(arg); } + Item *get_copy(THD *thd, MEM_ROOT *mem_root) { return get_item_copy<Item_field>(thd, mem_root, this); } bool is_outer_field() const @@ -4282,7 +4282,15 @@ public: { return depended_from != NULL; } bool exclusive_dependence_on_grouping_fields_processor(void *arg) { return depended_from != NULL; } - }; + bool cleanup_excluding_const_fields_processor(void *arg) + { + Item *item= real_item(); + if (item && item->type() == FIELD_ITEM && + ((Item_field *) item)->field && item->const_item()) + return 0; + return cleanup_processor(arg); + } +}; /* diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index 9732c82646b..1156b3b8305 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -1195,9 +1195,9 @@ bool pushdown_cond_for_derived(THD *thd, Item *cond, TABLE_LIST *derived) (uchar*) sl); if (extracted_cond_copy) { - extracted_cond_copy->walk( - &Item::cleanup_excluding_outer_fields_processor, 0, 0); - sl->cond_pushed_into_where= extracted_cond_copy; + extracted_cond_copy->walk( + &Item::cleanup_excluding_const_fields_processor, 0, 0); + sl->cond_pushed_into_where= extracted_cond_copy; } continue; @@ -1230,9 +1230,9 @@ bool pushdown_cond_for_derived(THD *thd, Item *cond, TABLE_LIST *derived) has been pushed into the where clause of sl */ extracted_cond_copy= remove_pushed_top_conjuncts(thd, extracted_cond_copy); - + cond_over_grouping_fields->walk( - &Item::cleanup_excluding_outer_fields_processor, 0, 0); + &Item::cleanup_excluding_const_fields_processor, 0, 0); sl->cond_pushed_into_where= cond_over_grouping_fields; if (!extracted_cond_copy) |