Commit c8db0df2 authored by Alexander Barkov's avatar Alexander Barkov

Removing "DTCollation Arg_comparator::cmp_collation".

Using a CHARSET_INFO pointer instead.
parent 2dc32c02
...@@ -494,10 +494,13 @@ bool Item_func::setup_args_and_comparator(THD *thd, Arg_comparator *cmp) ...@@ -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 DBUG_ASSERT(arg_count >= 2); // Item_func_nullif has arg_count == 3
if (args[0]->cmp_type() == STRING_RESULT && if (args[0]->cmp_type() == STRING_RESULT &&
args[1]->cmp_type() == STRING_RESULT && args[1]->cmp_type() == STRING_RESULT)
agg_arg_charsets_for_comparison(cmp->cmp_collation, args, 2)) {
DTCollation tmp;
if (agg_arg_charsets_for_comparison(tmp, args, 2))
return true; return true;
cmp->m_compare_collation= tmp.collation;
}
// Convert constants when compared to int/year field // Convert constants when compared to int/year field
DBUG_ASSERT(functype() != LIKE_FUNC); DBUG_ASSERT(functype() != LIKE_FUNC);
convert_const_compared_to_int_field(thd); 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) ...@@ -528,7 +531,7 @@ int Arg_comparator::set_compare_func(Item_func_or_sum *item, Item_result type)
switch (type) { switch (type) {
case TIME_RESULT: case TIME_RESULT:
cmp_collation.collation= &my_charset_numeric; m_compare_collation= &my_charset_numeric;
break; break;
case ROW_RESULT: case ROW_RESULT:
{ {
...@@ -666,17 +669,19 @@ bool get_mysql_time_from_str(THD *thd, String *str, timestamp_type warn_type, ...@@ -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() bool Arg_comparator::agg_arg_charsets_for_comparison()
{ {
if (cmp_collation.set((*a)->collation, (*b)->collation, MY_COLL_CMP_CONV) || DTCollation tmp;
cmp_collation.derivation == DERIVATION_NONE) 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()); my_coll_agg_error((*a)->collation, (*b)->collation, owner->func_name());
return true; 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) || 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)) b, 1, MY_COLL_CMP_CONV, 1))
return true; return true;
m_compare_collation= tmp.collation;
return false; return false;
} }
...@@ -909,7 +914,7 @@ int Arg_comparator::compare_string() ...@@ -909,7 +914,7 @@ int Arg_comparator::compare_string()
{ {
if (set_null) if (set_null)
owner->null_value= 0; owner->null_value= 0;
return sortcmp(res1,res2,cmp_collation.collation); return sortcmp(res1, res2, compare_collation());
} }
} }
if (set_null) if (set_null)
...@@ -930,7 +935,7 @@ int Arg_comparator::compare_e_string() ...@@ -930,7 +935,7 @@ int Arg_comparator::compare_e_string()
res2= (*b)->val_str(&value2); res2= (*b)->val_str(&value2);
if (!res1 || !res2) if (!res1 || !res2)
return MY_TEST(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);
} }
......
...@@ -48,6 +48,7 @@ class Arg_comparator: public Sql_alloc ...@@ -48,6 +48,7 @@ class Arg_comparator: public Sql_alloc
{ {
Item **a, **b; Item **a, **b;
Item_result m_compare_type; Item_result m_compare_type;
CHARSET_INFO *m_compare_collation;
arg_cmp_func func; arg_cmp_func func;
Item_func_or_sum *owner; Item_func_or_sum *owner;
bool set_null; // TRUE <=> set owner->null_value bool set_null; // TRUE <=> set owner->null_value
...@@ -65,16 +66,18 @@ class Arg_comparator: public Sql_alloc ...@@ -65,16 +66,18 @@ class Arg_comparator: public Sql_alloc
int compare_e_temporal(enum_field_types type); int compare_e_temporal(enum_field_types type);
public: public:
DTCollation cmp_collation;
/* Allow owner function to use string buffers. */ /* Allow owner function to use string buffers. */
String value1, value2; String value1, value2;
Arg_comparator(): m_compare_type(STRING_RESULT), Arg_comparator(): m_compare_type(STRING_RESULT),
m_compare_collation(&my_charset_bin),
set_null(TRUE), comparators(0), thd(0), set_null(TRUE), comparators(0), thd(0),
a_cache(0), b_cache(0) {}; a_cache(0), b_cache(0) {};
Arg_comparator(Item **a1, Item **a2): a(a1), b(a2), Arg_comparator(Item **a1, Item **a2): a(a1), b(a2),
m_compare_type(STRING_RESULT), set_null(TRUE), m_compare_type(STRING_RESULT),
comparators(0), thd(0), a_cache(0), b_cache(0) {}; m_compare_collation(&my_charset_bin),
set_null(TRUE), comparators(0), thd(0),
a_cache(0), b_cache(0) {};
public: public:
inline int set_cmp_func(Item_func_or_sum *owner_arg, inline int set_cmp_func(Item_func_or_sum *owner_arg,
...@@ -115,6 +118,7 @@ class Arg_comparator: public Sql_alloc ...@@ -115,6 +118,7 @@ class Arg_comparator: public Sql_alloc
((Item_func*)owner)->functype() == Item_func::EQUAL_FUNC); ((Item_func*)owner)->functype() == Item_func::EQUAL_FUNC);
} }
Item_result compare_type() const { return m_compare_type; } Item_result compare_type() const { return m_compare_type; }
CHARSET_INFO *compare_collation() const { return m_compare_collation; }
Arg_comparator *subcomparators() const { return comparators; } Arg_comparator *subcomparators() const { return comparators; }
void cleanup() void cleanup()
{ {
...@@ -401,8 +405,7 @@ class Item_bool_rowready_func2 :public Item_bool_func2 ...@@ -401,8 +405,7 @@ class Item_bool_rowready_func2 :public Item_bool_func2
{ {
return cmp.set_cmp_func(this, tmp_arg, tmp_arg + 1, true); return cmp.set_cmp_func(this, tmp_arg, tmp_arg + 1, true);
} }
CHARSET_INFO *compare_collation() const CHARSET_INFO *compare_collation() const { return cmp.compare_collation(); }
{ return cmp.cmp_collation.collation; }
Item_result compare_type() const { return cmp.compare_type(); } Item_result compare_type() const { return cmp.compare_type(); }
Arg_comparator *get_comparator() { return &cmp; } Arg_comparator *get_comparator() { return &cmp; }
void cleanup() void cleanup()
...@@ -931,7 +934,7 @@ class Item_func_nullif :public Item_func_hybrid_field_type ...@@ -931,7 +934,7 @@ class Item_func_nullif :public Item_func_hybrid_field_type
bool is_null(); bool is_null();
Item* propagate_equal_fields(THD *thd, const Context &ctx, COND_EQUAL *cond) 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, args[0]->propagate_equal_fields_and_change_item_tree(thd, cmpctx,
cond, &args[0]); cond, &args[0]);
args[1]->propagate_equal_fields_and_change_item_tree(thd, cmpctx, args[1]->propagate_equal_fields_and_change_item_tree(thd, cmpctx,
......
...@@ -12766,7 +12766,7 @@ static bool check_row_equality(THD *thd, const Arg_comparator *comparators, ...@@ -12766,7 +12766,7 @@ static bool check_row_equality(THD *thd, const Arg_comparator *comparators,
is_converted= check_simple_equality(thd, is_converted= check_simple_equality(thd,
Item::Context(Item::ANY_SUBST, Item::Context(Item::ANY_SUBST,
tmp->compare_type(), tmp->compare_type(),
tmp->cmp_collation.collation), tmp->compare_collation()),
left_item, right_item, left_item, right_item,
cond_equal); cond_equal);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment