From 3fbc765b048a3802a3c3f997071b567447db6c04 Mon Sep 17 00:00:00 2001 From: "bar@bar.mysql.r18.ru" <> Date: Fri, 4 Jul 2003 19:56:32 +0500 Subject: [PATCH] Better arguments format to allow reuse more code --- sql/item_func.cc | 20 ++++++++++---------- sql/item_func.h | 4 ++-- sql/item_strfunc.cc | 12 ++++++------ 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/sql/item_func.cc b/sql/item_func.cc index df1bce37581..0080a2bcff1 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -64,15 +64,15 @@ static void my_coll_agg_error(Item** args, uint ac, const char *fname) my_error(ER_CANT_AGGREGATE_NCOLLATIONS,MYF(0),fname); } -bool Item_func::agg_arg_collations(DTCollation &c, uint from, uint argc) +bool Item_func::agg_arg_collations(DTCollation &c, Item **av, uint ac) { uint i; - c.set(args[from]->collation); - for (i= from+1; i < argc; i++) + c.set(av[0]->collation); + for (i= 1; i < ac; i++) { - if (c.aggregate(args[i]->collation)) + if (c.aggregate(av[i]->collation)) { - my_coll_agg_error(args+from, argc-from, func_name()); + my_coll_agg_error(av, ac, func_name()); return TRUE; } } @@ -80,14 +80,14 @@ bool Item_func::agg_arg_collations(DTCollation &c, uint from, uint argc) } bool Item_func::agg_arg_collations_for_comparison(DTCollation &c, - uint from, uint argc) + Item **av, uint ac) { - if (agg_arg_collations(c, from, argc)) - return FALSE; - + if (agg_arg_collations(c, av, ac)) + return TRUE; + if (c.derivation == DERIVATION_NONE) { - my_coll_agg_error(args+from, argc-from, func_name()); + my_coll_agg_error(av, ac, func_name()); return TRUE; } return FALSE; diff --git a/sql/item_func.h b/sql/item_func.h index c7f227051f3..a5575a35851 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -136,8 +136,8 @@ public: void set_outer_resolving(); Item *get_tmp_table_item(THD *thd); - bool agg_arg_collations(DTCollation &c, uint from, uint argc); - bool agg_arg_collations_for_comparison(DTCollation &c, uint from, uint argc); + bool agg_arg_collations(DTCollation &c, Item **items, uint nitems); + bool agg_arg_collations_for_comparison(DTCollation &c, Item **items, uint nitems); }; diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 8c3784a5d4e..f46959e5365 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -324,7 +324,7 @@ void Item_func_concat::fix_length_and_dec() bool first_coll= 1; max_length=0; - if (agg_arg_collations(collation, 0, arg_count)) + if (agg_arg_collations(collation, args, arg_count)) return; for (uint i=0 ; i < arg_count ; i++) @@ -823,7 +823,7 @@ void Item_func_replace::fix_length_and_dec() maybe_null=1; } - if (agg_arg_collations_for_comparison(collation, 0, 3)) + if (agg_arg_collations_for_comparison(collation, args, 3)) return; } @@ -1029,7 +1029,7 @@ void Item_func_substr_index::fix_length_and_dec() { max_length= args[0]->max_length; - if (agg_arg_collations_for_comparison(collation, 0, 2)) + if (agg_arg_collations_for_comparison(collation, args, 2)) return; } @@ -1658,7 +1658,7 @@ void Item_func_elt::fix_length_and_dec() max_length=0; decimals=0; - if (agg_arg_collations(collation, 0, arg_count)) + if (agg_arg_collations(collation, args, arg_count)) return; for (uint i=0 ; i < arg_count ; i++) @@ -1758,7 +1758,7 @@ void Item_func_make_set::fix_length_and_dec() { max_length=arg_count-1; - if (agg_arg_collations(collation, 0, arg_count)) + if (agg_arg_collations(collation, args, arg_count)) return; for (uint i=0 ; i < arg_count ; i++) @@ -2431,7 +2431,7 @@ void Item_func_export_set::fix_length_and_dec() uint sep_length=(arg_count > 3 ? args[3]->max_length : 1); max_length=length*64+sep_length*63; - if (agg_arg_collations(collation,1, min(4,arg_count))) + if (agg_arg_collations(collation, args+1, min(4,arg_count)-1)) return; }