diff options
author | Sergei Golubchik <sergii@pisem.net> | 2013-03-27 23:41:02 +0100 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2013-03-27 23:41:02 +0100 |
commit | 993ea79f2df42292eceeee394e8ece9f4a3f6cf2 (patch) | |
tree | d105c8288a89a25d412e9006b740c756db6326d6 /sql/item_cmpfunc.h | |
parent | 1827d9591e24ee469527021771088d842ab18374 (diff) | |
parent | 6599fd3e9c23a8957a63146cbe6a0ffc4c292a3d (diff) | |
download | mariadb-git-993ea79f2df42292eceeee394e8ece9f4a3f6cf2.tar.gz |
5.5 merge
Diffstat (limited to 'sql/item_cmpfunc.h')
-rw-r--r-- | sql/item_cmpfunc.h | 81 |
1 files changed, 68 insertions, 13 deletions
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 5a5f9ad60fd..4ca31e01df9 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -1578,6 +1578,11 @@ public: DBUG_ASSERT(nlist->elements); list.prepand(nlist); } + void add_at_end(List<Item> *nlist) + { + DBUG_ASSERT(nlist->elements); + list.concat(nlist); + } bool fix_fields(THD *, Item **ref); void fix_after_pullout(st_select_lex *new_parent, Item **ref); @@ -1603,6 +1608,7 @@ public: bool eval_not_null_tables(uchar *opt_arg); }; +template <template<class> class LI, class T> class Item_equal_iterator; /* The class Item_equal is used to represent conjunctions of equality @@ -1730,7 +1736,11 @@ class Item_equal: public Item_bool_func used in the original equality. */ Item_field *context_field; + public: + + COND_EQUAL *upper_levels; /* multiple equalities of upper and levels */ + inline Item_equal() : Item_bool_func(), with_const(FALSE), eval_item(0), cond_false(0), context_field(NULL) @@ -1747,6 +1757,8 @@ public: /** Get number of field items / references to field items in this object */ uint n_field_items() { return equal_items.elements-test(with_const); } void merge(Item_equal *item); + bool merge_with_check(Item_equal *equal_item); + void merge_into_list(List<Item_equal> *list); void update_const(); enum Functype functype() const { return MULT_EQUAL_FUNC; } longlong val_int(); @@ -1762,7 +1774,8 @@ public: CHARSET_INFO *compare_collation(); void set_context_field(Item_field *ctx_field) { context_field= ctx_field; } - friend class Item_equal_fields_iterator; + friend class Item_equal_iterator<List_iterator_fast,Item>; + friend class Item_equal_iterator<List_iterator,Item>; friend Item *eliminate_item_equal(COND *cond, COND_EQUAL *upper_levels, Item_equal *item_equal); friend bool setup_sj_materialization_part1(struct st_join_table *tab); @@ -1781,43 +1794,55 @@ public: { upper_levels= 0; } + void copy(COND_EQUAL &cond_equal) + { + max_members= cond_equal.max_members; + upper_levels= cond_equal.upper_levels; + if (cond_equal.current_level.is_empty()) + current_level.empty(); + else + current_level= cond_equal.current_level; + } }; /* - The class Item_equal_fields_iterator is used to iterate over references - to table/view columns from a list of equal items. + The template Item_equal_iterator is used to define classes + Item_equal_fields_iterator and Item_equal_fields_iterator_slow. + These are helper classes for the class Item equal + Both classes are used to iterate over references to table/view columns + from the list of equal items that included in an Item_equal object. + The second class supports the operation of removal of the current member + from the list when performing an iteration. */ -class Item_equal_fields_iterator : public List_iterator_fast<Item> +template <template<class> class LI, typename T> class Item_equal_iterator + : public LI<T> { +protected: Item_equal *item_equal; Item *curr_item; public: - Item_equal_fields_iterator(Item_equal &item_eq) - :List_iterator_fast<Item> (item_eq.equal_items) + Item_equal_iterator<LI,T>(Item_equal &item_eq) + :LI<T> (item_eq.equal_items) { curr_item= NULL; item_equal= &item_eq; if (item_eq.with_const) { - List_iterator_fast<Item> *list_it= this; + LI<T> *list_it= this; curr_item= (*list_it)++; } } Item* operator++(int) { - List_iterator_fast<Item> *list_it= this; + LI<T> *list_it= this; curr_item= (*list_it)++; return curr_item; } - Item ** ref() - { - return List_iterator_fast<Item>::ref(); - } void rewind(void) { - List_iterator_fast<Item> *list_it= this; + LI<T> *list_it= this; list_it->rewind(); if (item_equal->with_const) curr_item= (*list_it)++; @@ -1829,6 +1854,36 @@ public: } }; +typedef Item_equal_iterator<List_iterator_fast,Item > Item_equal_iterator_fast; + +class Item_equal_fields_iterator + :public Item_equal_iterator_fast +{ +public: + Item_equal_fields_iterator(Item_equal &item_eq) + :Item_equal_iterator_fast(item_eq) + { } + Item ** ref() + { + return List_iterator_fast<Item>::ref(); + } +}; + +typedef Item_equal_iterator<List_iterator,Item > Item_equal_iterator_iterator_slow; + +class Item_equal_fields_iterator_slow + :public Item_equal_iterator_iterator_slow +{ +public: + Item_equal_fields_iterator_slow(Item_equal &item_eq) + :Item_equal_iterator_iterator_slow(item_eq) + { } + void remove() + { + List_iterator<Item>::remove(); + } +}; + class Item_cond_and :public Item_cond { |