diff options
author | Alexander Barkov <bar@mariadb.org> | 2015-09-21 16:18:20 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.org> | 2015-09-21 16:18:20 +0400 |
commit | c8db0df2daa807044d980e5aaa13084ae2b1efe6 (patch) | |
tree | 69de4ababd41a4bf7fd89d8bbf5edf6782f66b13 | |
parent | 2dc32c02ab687683ef8d29115d3f89a660231c51 (diff) | |
download | mariadb-git-c8db0df2daa807044d980e5aaa13084ae2b1efe6.tar.gz |
Removing "DTCollation Arg_comparator::cmp_collation".
Using a CHARSET_INFO pointer instead.
-rw-r--r-- | sql/item_cmpfunc.cc | 25 | ||||
-rw-r--r-- | sql/item_cmpfunc.h | 15 | ||||
-rw-r--r-- | sql/sql_select.cc | 2 |
3 files changed, 25 insertions, 17 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 46b6eac1997..e79e73dc015 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -494,10 +494,13 @@ bool Item_func::setup_args_and_comparator(THD *thd, Arg_comparator *cmp) DBUG_ASSERT(arg_count >= 2); // Item_func_nullif has arg_count == 3 if (args[0]->cmp_type() == STRING_RESULT && - args[1]->cmp_type() == STRING_RESULT && - agg_arg_charsets_for_comparison(cmp->cmp_collation, args, 2)) + args[1]->cmp_type() == STRING_RESULT) + { + DTCollation tmp; + if (agg_arg_charsets_for_comparison(tmp, args, 2)) return true; - + cmp->m_compare_collation= tmp.collation; + } // Convert constants when compared to int/year field DBUG_ASSERT(functype() != LIKE_FUNC); convert_const_compared_to_int_field(thd); @@ -528,7 +531,7 @@ int Arg_comparator::set_compare_func(Item_func_or_sum *item, Item_result type) switch (type) { case TIME_RESULT: - cmp_collation.collation= &my_charset_numeric; + m_compare_collation= &my_charset_numeric; break; case ROW_RESULT: { @@ -666,17 +669,19 @@ bool get_mysql_time_from_str(THD *thd, String *str, timestamp_type warn_type, */ bool Arg_comparator::agg_arg_charsets_for_comparison() { - if (cmp_collation.set((*a)->collation, (*b)->collation, MY_COLL_CMP_CONV) || - cmp_collation.derivation == DERIVATION_NONE) + DTCollation tmp; + if (tmp.set((*a)->collation, (*b)->collation, MY_COLL_CMP_CONV) || + tmp.derivation == DERIVATION_NONE) { my_coll_agg_error((*a)->collation, (*b)->collation, owner->func_name()); return true; } - if (agg_item_set_converter(cmp_collation, owner->func_name(), + if (agg_item_set_converter(tmp, owner->func_name(), a, 1, MY_COLL_CMP_CONV, 1) || - agg_item_set_converter(cmp_collation, owner->func_name(), + agg_item_set_converter(tmp, owner->func_name(), b, 1, MY_COLL_CMP_CONV, 1)) return true; + m_compare_collation= tmp.collation; return false; } @@ -909,7 +914,7 @@ int Arg_comparator::compare_string() { if (set_null) owner->null_value= 0; - return sortcmp(res1,res2,cmp_collation.collation); + return sortcmp(res1, res2, compare_collation()); } } if (set_null) @@ -930,7 +935,7 @@ int Arg_comparator::compare_e_string() res2= (*b)->val_str(&value2); if (!res1 || !res2) return MY_TEST(res1 == res2); - return MY_TEST(sortcmp(res1, res2, cmp_collation.collation) == 0); + return MY_TEST(sortcmp(res1, res2, compare_collation()) == 0); } diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 3d15cf0cf7d..350d9d07565 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -48,6 +48,7 @@ class Arg_comparator: public Sql_alloc { Item **a, **b; Item_result m_compare_type; + CHARSET_INFO *m_compare_collation; arg_cmp_func func; Item_func_or_sum *owner; bool set_null; // TRUE <=> set owner->null_value @@ -65,16 +66,18 @@ class Arg_comparator: public Sql_alloc int compare_e_temporal(enum_field_types type); public: - DTCollation cmp_collation; /* Allow owner function to use string buffers. */ String value1, value2; Arg_comparator(): m_compare_type(STRING_RESULT), + m_compare_collation(&my_charset_bin), set_null(TRUE), comparators(0), thd(0), a_cache(0), b_cache(0) {}; Arg_comparator(Item **a1, Item **a2): a(a1), b(a2), - m_compare_type(STRING_RESULT), set_null(TRUE), - comparators(0), thd(0), a_cache(0), b_cache(0) {}; + m_compare_type(STRING_RESULT), + m_compare_collation(&my_charset_bin), + set_null(TRUE), comparators(0), thd(0), + a_cache(0), b_cache(0) {}; public: inline int set_cmp_func(Item_func_or_sum *owner_arg, @@ -115,6 +118,7 @@ public: ((Item_func*)owner)->functype() == Item_func::EQUAL_FUNC); } Item_result compare_type() const { return m_compare_type; } + CHARSET_INFO *compare_collation() const { return m_compare_collation; } Arg_comparator *subcomparators() const { return comparators; } void cleanup() { @@ -401,8 +405,7 @@ public: { return cmp.set_cmp_func(this, tmp_arg, tmp_arg + 1, true); } - CHARSET_INFO *compare_collation() const - { return cmp.cmp_collation.collation; } + CHARSET_INFO *compare_collation() const { return cmp.compare_collation(); } Item_result compare_type() const { return cmp.compare_type(); } Arg_comparator *get_comparator() { return &cmp; } void cleanup() @@ -931,7 +934,7 @@ public: bool is_null(); Item* propagate_equal_fields(THD *thd, const Context &ctx, COND_EQUAL *cond) { - Context cmpctx(ANY_SUBST, cmp.compare_type(), cmp.cmp_collation.collation); + Context cmpctx(ANY_SUBST, cmp.compare_type(), cmp.compare_collation()); args[0]->propagate_equal_fields_and_change_item_tree(thd, cmpctx, cond, &args[0]); args[1]->propagate_equal_fields_and_change_item_tree(thd, cmpctx, diff --git a/sql/sql_select.cc b/sql/sql_select.cc index a9bebecfa52..0a9890a7c96 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -12766,7 +12766,7 @@ static bool check_row_equality(THD *thd, const Arg_comparator *comparators, is_converted= check_simple_equality(thd, Item::Context(Item::ANY_SUBST, tmp->compare_type(), - tmp->cmp_collation.collation), + tmp->compare_collation()), left_item, right_item, cond_equal); } |