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

Better arguments format to allow reuse more code

parent de9ba384
......@@ -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;
......
......@@ -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);
};
......
......@@ -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;
}
......
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