Commit d209cf70 authored by bar@bar.mysql.r18.ru's avatar bar@bar.mysql.r18.ru

More code was reused

parent 3fbc765b
......@@ -32,18 +32,6 @@ static void my_coll_agg_error(DTCollation &c1, DTCollation &c2, const char *fnam
fname);
}
static void my_coll_agg3_error(DTCollation &c1,
DTCollation &c2,
DTCollation &c3,
const char *fname)
{
my_error(ER_CANT_AGGREGATE_3COLLATIONS,MYF(0),
c1.collation->name,c1.derivation_name(),
c2.collation->name,c2.derivation_name(),
c3.collation->name,c3.derivation_name(),
fname);
}
Item_bool_func2* Item_bool_func2::eq_creator(Item *a, Item *b)
{
return new Item_func_eq(a, b);
......@@ -572,18 +560,9 @@ void Item_func_between::fix_length_and_dec()
item_cmp_type(args[1]->result_type(),
args[2]->result_type()));
if (cmp_type == STRING_RESULT)
{
cmp_collation.set(args[0]->collation);
if (!cmp_collation.aggregate(args[1]->collation))
cmp_collation.aggregate(args[2]->collation);
if (cmp_collation.derivation == DERIVATION_NONE)
{
my_coll_agg3_error(args[0]->collation, args[1]->collation,
args[2]->collation, func_name());
return;
}
}
if (cmp_type == STRING_RESULT &&
agg_arg_collations_for_comparison(cmp_collation, args, 3))
return;
/*
Make a special case of compare with date/time and longlong fields.
......@@ -691,8 +670,8 @@ Item_func_ifnull::fix_length_and_dec()
args[1]->result_type())) !=
REAL_RESULT)
decimals= 0;
if (collation.set(args[0]->collation,args[1]->collation))
my_coll_agg_error(args[0]->collation, args[1]->collation, func_name());
if (cached_result_type == STRING_RESULT)
agg_arg_collations(collation, args, arg_count);
}
......@@ -768,11 +747,8 @@ Item_func_if::fix_length_and_dec()
else if (arg1_type == STRING_RESULT || arg2_type == STRING_RESULT)
{
cached_result_type = STRING_RESULT;
if (collation.set(args[1]->collation, args[2]->collation))
{
my_coll_agg_error(args[0]->collation, args[1]->collation, func_name());
if (agg_arg_collations(collation, args+1, 2))
return;
}
}
else
{
......@@ -1972,11 +1948,8 @@ Item_func_regex::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref)
max_length= 1;
decimals= 0;
if (cmp_collation.set(args[0]->collation, args[1]->collation))
{
my_coll_agg_error(args[0]->collation, args[1]->collation, func_name());
if (agg_arg_collations(cmp_collation, args, 2))
return 1;
}
used_tables_cache=args[0]->used_tables() | args[1]->used_tables();
const_item_cache=args[0]->const_item() && args[1]->const_item();
......
......@@ -921,14 +921,9 @@ void Item_func_min_max::fix_length_and_dec()
if (!args[i]->maybe_null)
maybe_null=0;
cmp_type=item_cmp_type(cmp_type,args[i]->result_type());
if (i==0)
collation.set(args[0]->collation);
if (collation.aggregate(args[i]->collation))
{
my_coll_agg_error(collation, args[i]->collation, func_name());
break;
}
}
if (cmp_type == STRING_RESULT)
agg_arg_collations_for_comparison(collation, args, arg_count);
}
......@@ -1103,8 +1098,7 @@ longlong Item_func_coercibility::val_int()
void Item_func_locate::fix_length_and_dec()
{
maybe_null=0; max_length=11;
if (cmp_collation.set(args[0]->collation, args[1]->collation))
my_coll_agg_error(args[0]->collation, args[1]->collation, func_name());
agg_arg_collations_for_comparison(cmp_collation, args, 2);
}
longlong Item_func_locate::val_int()
......@@ -1310,8 +1304,7 @@ void Item_func_find_in_set::fix_length_and_dec()
}
}
}
if (cmp_collation.set(args[0]->collation, args[1]->collation))
my_coll_agg_error(args[0]->collation, args[1]->collation, func_name());
agg_arg_collations_for_comparison(cmp_collation, args, 2);
}
static const char separator=',';
......
......@@ -1317,7 +1317,8 @@ void Item_func_trim::fix_length_and_dec()
remove.set_ascii(" ",1);
}
else
if (collation.set(args[1]->collation, args[0]->collation))
if (collation.set(args[1]->collation, args[0]->collation) ||
collation.derivation == DERIVATION_NONE)
{
my_coll_agg_error(args[1]->collation, args[0]->collation, func_name());
}
......
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