Skip to content

Commit c8db0df

Browse files
author
Alexander Barkov
committed
Removing "DTCollation Arg_comparator::cmp_collation".
Using a CHARSET_INFO pointer instead.
1 parent 2dc32c0 commit c8db0df

File tree

3 files changed

+25
-17
lines changed

3 files changed

+25
-17
lines changed

sql/item_cmpfunc.cc

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -494,10 +494,13 @@ bool Item_func::setup_args_and_comparator(THD *thd, Arg_comparator *cmp)
494494
DBUG_ASSERT(arg_count >= 2); // Item_func_nullif has arg_count == 3
495495

496496
if (args[0]->cmp_type() == STRING_RESULT &&
497-
args[1]->cmp_type() == STRING_RESULT &&
498-
agg_arg_charsets_for_comparison(cmp->cmp_collation, args, 2))
497+
args[1]->cmp_type() == STRING_RESULT)
498+
{
499+
DTCollation tmp;
500+
if (agg_arg_charsets_for_comparison(tmp, args, 2))
499501
return true;
500-
502+
cmp->m_compare_collation= tmp.collation;
503+
}
501504
// Convert constants when compared to int/year field
502505
DBUG_ASSERT(functype() != LIKE_FUNC);
503506
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)
528531

529532
switch (type) {
530533
case TIME_RESULT:
531-
cmp_collation.collation= &my_charset_numeric;
534+
m_compare_collation= &my_charset_numeric;
532535
break;
533536
case ROW_RESULT:
534537
{
@@ -666,17 +669,19 @@ bool get_mysql_time_from_str(THD *thd, String *str, timestamp_type warn_type,
666669
*/
667670
bool Arg_comparator::agg_arg_charsets_for_comparison()
668671
{
669-
if (cmp_collation.set((*a)->collation, (*b)->collation, MY_COLL_CMP_CONV) ||
670-
cmp_collation.derivation == DERIVATION_NONE)
672+
DTCollation tmp;
673+
if (tmp.set((*a)->collation, (*b)->collation, MY_COLL_CMP_CONV) ||
674+
tmp.derivation == DERIVATION_NONE)
671675
{
672676
my_coll_agg_error((*a)->collation, (*b)->collation, owner->func_name());
673677
return true;
674678
}
675-
if (agg_item_set_converter(cmp_collation, owner->func_name(),
679+
if (agg_item_set_converter(tmp, owner->func_name(),
676680
a, 1, MY_COLL_CMP_CONV, 1) ||
677-
agg_item_set_converter(cmp_collation, owner->func_name(),
681+
agg_item_set_converter(tmp, owner->func_name(),
678682
b, 1, MY_COLL_CMP_CONV, 1))
679683
return true;
684+
m_compare_collation= tmp.collation;
680685
return false;
681686
}
682687

@@ -909,7 +914,7 @@ int Arg_comparator::compare_string()
909914
{
910915
if (set_null)
911916
owner->null_value= 0;
912-
return sortcmp(res1,res2,cmp_collation.collation);
917+
return sortcmp(res1, res2, compare_collation());
913918
}
914919
}
915920
if (set_null)
@@ -930,7 +935,7 @@ int Arg_comparator::compare_e_string()
930935
res2= (*b)->val_str(&value2);
931936
if (!res1 || !res2)
932937
return MY_TEST(res1 == res2);
933-
return MY_TEST(sortcmp(res1, res2, cmp_collation.collation) == 0);
938+
return MY_TEST(sortcmp(res1, res2, compare_collation()) == 0);
934939
}
935940

936941

sql/item_cmpfunc.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class Arg_comparator: public Sql_alloc
4848
{
4949
Item **a, **b;
5050
Item_result m_compare_type;
51+
CHARSET_INFO *m_compare_collation;
5152
arg_cmp_func func;
5253
Item_func_or_sum *owner;
5354
bool set_null; // TRUE <=> set owner->null_value
@@ -65,16 +66,18 @@ class Arg_comparator: public Sql_alloc
6566
int compare_e_temporal(enum_field_types type);
6667

6768
public:
68-
DTCollation cmp_collation;
6969
/* Allow owner function to use string buffers. */
7070
String value1, value2;
7171

7272
Arg_comparator(): m_compare_type(STRING_RESULT),
73+
m_compare_collation(&my_charset_bin),
7374
set_null(TRUE), comparators(0), thd(0),
7475
a_cache(0), b_cache(0) {};
7576
Arg_comparator(Item **a1, Item **a2): a(a1), b(a2),
76-
m_compare_type(STRING_RESULT), set_null(TRUE),
77-
comparators(0), thd(0), a_cache(0), b_cache(0) {};
77+
m_compare_type(STRING_RESULT),
78+
m_compare_collation(&my_charset_bin),
79+
set_null(TRUE), comparators(0), thd(0),
80+
a_cache(0), b_cache(0) {};
7881

7982
public:
8083
inline int set_cmp_func(Item_func_or_sum *owner_arg,
@@ -115,6 +118,7 @@ class Arg_comparator: public Sql_alloc
115118
((Item_func*)owner)->functype() == Item_func::EQUAL_FUNC);
116119
}
117120
Item_result compare_type() const { return m_compare_type; }
121+
CHARSET_INFO *compare_collation() const { return m_compare_collation; }
118122
Arg_comparator *subcomparators() const { return comparators; }
119123
void cleanup()
120124
{
@@ -401,8 +405,7 @@ class Item_bool_rowready_func2 :public Item_bool_func2
401405
{
402406
return cmp.set_cmp_func(this, tmp_arg, tmp_arg + 1, true);
403407
}
404-
CHARSET_INFO *compare_collation() const
405-
{ return cmp.cmp_collation.collation; }
408+
CHARSET_INFO *compare_collation() const { return cmp.compare_collation(); }
406409
Item_result compare_type() const { return cmp.compare_type(); }
407410
Arg_comparator *get_comparator() { return &cmp; }
408411
void cleanup()
@@ -931,7 +934,7 @@ class Item_func_nullif :public Item_func_hybrid_field_type
931934
bool is_null();
932935
Item* propagate_equal_fields(THD *thd, const Context &ctx, COND_EQUAL *cond)
933936
{
934-
Context cmpctx(ANY_SUBST, cmp.compare_type(), cmp.cmp_collation.collation);
937+
Context cmpctx(ANY_SUBST, cmp.compare_type(), cmp.compare_collation());
935938
args[0]->propagate_equal_fields_and_change_item_tree(thd, cmpctx,
936939
cond, &args[0]);
937940
args[1]->propagate_equal_fields_and_change_item_tree(thd, cmpctx,

sql/sql_select.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12766,7 +12766,7 @@ static bool check_row_equality(THD *thd, const Arg_comparator *comparators,
1276612766
is_converted= check_simple_equality(thd,
1276712767
Item::Context(Item::ANY_SUBST,
1276812768
tmp->compare_type(),
12769-
tmp->cmp_collation.collation),
12769+
tmp->compare_collation()),
1277012770
left_item, right_item,
1277112771
cond_equal);
1277212772
}

0 commit comments

Comments
 (0)