Commit a247b12f authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-316 lp:1009085 Assertion failed: warn_item, file item_cmpfunc.cc, line 3613

make sure that find_date_time_item() is called before agg_arg_charsets_for_comparison().
optimize Item_func_conv_charset to avoid conversion if no string result is needed
parent 37f56322
set names swe7;
select '' in ('',convert(0,time));
'' in ('',convert(0,time))
1
select case '' when '' then 1 when convert(0,time) then 2 end;
case '' when '' then 1 when convert(0,time) then 2 end
1
#
# MDEV-316 lp:1009085 Assertion failed: warn_item, file item_cmpfunc.cc, line 3613
#
set names swe7;
select '' in ('',convert(0,time));
select case '' when '' then 1 when convert(0,time) then 2 end;
......@@ -3032,6 +3032,11 @@ void Item_func_case::fix_length_and_dec()
nagg++;
if (!(found_types= collect_cmp_types(agg, nagg)))
return;
Item *date_arg= 0;
if (found_types & (1 << TIME_RESULT))
date_arg= find_date_time_item(args, arg_count, 0);
if (found_types & (1 << STRING_RESULT))
{
/*
......@@ -3071,16 +3076,12 @@ void Item_func_case::fix_length_and_dec()
change_item_tree_if_needed(thd, &args[nagg * 2], agg[nagg + 1]);
}
Item *date_arg= 0;
for (i= 0; i <= (uint)TIME_RESULT; i++)
{
if (found_types & (1 << i) && !cmp_items[i])
{
DBUG_ASSERT((Item_result)i != ROW_RESULT);
if ((Item_result)i == TIME_RESULT)
date_arg= find_date_time_item(args, arg_count, 0);
if (!(cmp_items[i]=
cmp_item::get_comparator((Item_result)i, date_arg,
cmp_collation.collation)))
......@@ -4051,15 +4052,15 @@ void Item_func_in::fix_length_and_dec()
}
else
{
if (found_types & (1 << TIME_RESULT))
date_arg= find_date_time_item(args, arg_count, 0);
if (found_types & (1 << STRING_RESULT) &&
agg_arg_charsets_for_comparison(cmp_collation, args, arg_count))
return;
for (i= 0; i <= (uint) TIME_RESULT; i++)
{
if (found_types & (1 << i) && !cmp_items[i])
{
if ((Item_result)i == STRING_RESULT &&
agg_arg_charsets_for_comparison(cmp_collation, args, arg_count))
return;
if ((Item_result)i == TIME_RESULT)
date_arg= find_date_time_item(args, arg_count, 0);
if (!cmp_items[i] && !(cmp_items[i]=
cmp_item::get_comparator((Item_result)i, date_arg,
cmp_collation.collation)))
......
......@@ -854,6 +854,14 @@ class Item_func_conv_charset :public Item_str_func
}
}
String *val_str(String *);
longlong val_int()
{ return args[0]->val_int(); }
double val_real()
{ return args[0]->val_real(); }
my_decimal *val_decimal(my_decimal *d)
{ return args[0]->val_decimal(d); }
bool get_date(MYSQL_TIME *ltime, ulonglong fuzzydate)
{ return args[0]->get_date(ltime, fuzzydate); }
void fix_length_and_dec();
const char *func_name() const { return "convert"; }
virtual void print(String *str, enum_query_type query_type);
......
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