summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <bar@bar.mysql.r18.ru>2003-07-04 20:19:07 +0500
committerunknown <bar@bar.mysql.r18.ru>2003-07-04 20:19:07 +0500
commit0333deefd229929abda46f94148e34c36973a93b (patch)
treed020bda4212193202065c0bcd34c3ae3174bbb83
parenta371a6e6ca04090999c69359da55f772154d9b97 (diff)
downloadmariadb-git-0333deefd229929abda46f94148e34c36973a93b.tar.gz
More code was reused
-rw-r--r--sql/item_cmpfunc.cc41
-rw-r--r--sql/item_func.cc15
-rw-r--r--sql/item_strfunc.cc3
3 files changed, 13 insertions, 46 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 11a6e6604bf..326138d798d 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -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();
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 0080a2bcff1..ad2bebf9efb 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -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=',';
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index f46959e5365..2d29f76c2d7 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -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());
}