Commit b8153269 authored by Sergei Golubchik's avatar Sergei Golubchik

fix an overly agressive optimization in Item_func_conv_charset

parent 6cf8672f
......@@ -5,3 +5,18 @@ select '' in ('',convert(0,time));
select case '' when '' then 1 when convert(0,time) then 2 end;
case '' when '' then 1 when convert(0,time) then 2 end
1
select convert(0x0030 using ucs2) div 1, concat(convert(0x0030 using ucs2)) div 1;
convert(0x0030 using ucs2) div 1 concat(convert(0x0030 using ucs2)) div 1
0 0
select cast(convert(0x0030 using ucs2) as double), cast(concat(convert(0x0030 using ucs2)) as double);
cast(convert(0x0030 using ucs2) as double) cast(concat(convert(0x0030 using ucs2)) as double)
0 0
select cast(convert(0x0030 using ucs2) as decimal(5.2)), cast(concat(convert(0x0030 using ucs2)) as decimal(5.2));
cast(convert(0x0030 using ucs2) as decimal(5.2)) cast(concat(convert(0x0030 using ucs2)) as decimal(5.2))
0 0
select cast(convert(_ucs2 0x0030 using latin1) as date), cast(concat(convert(_ucs2 0x0030 using latin1)) as date);
cast(convert(_ucs2 0x0030 using latin1) as date) cast(concat(convert(_ucs2 0x0030 using latin1)) as date)
NULL NULL
Warnings:
Warning 1292 Incorrect datetime value: '0'
Warning 1292 Incorrect datetime value: '0'
......@@ -4,3 +4,11 @@
set names swe7;
select '' in ('',convert(0,time));
select case '' when '' then 1 when convert(0,time) then 2 end;
#
# Excessive optimization of Item_func_conv_charset:
#
select convert(0x0030 using ucs2) div 1, concat(convert(0x0030 using ucs2)) div 1;
select cast(convert(0x0030 using ucs2) as double), cast(concat(convert(0x0030 using ucs2)) as double);
select cast(convert(0x0030 using ucs2) as decimal(5.2)), cast(concat(convert(0x0030 using ucs2)) as decimal(5.2));
select cast(convert(_ucs2 0x0030 using latin1) as date), cast(concat(convert(_ucs2 0x0030 using latin1)) as date);
......@@ -855,13 +855,29 @@ public:
}
String *val_str(String *);
longlong val_int()
{ return args[0]->val_int(); }
{
if (args[0]->result_type() == STRING_RESULT)
return Item_str_func::val_int();
return args[0]->val_int();
}
double val_real()
{ return args[0]->val_real(); }
{
if (args[0]->result_type() == STRING_RESULT)
return Item_str_func::val_real();
return args[0]->val_real();
}
my_decimal *val_decimal(my_decimal *d)
{ return args[0]->val_decimal(d); }
{
if (args[0]->result_type() == STRING_RESULT)
return Item_str_func::val_decimal(d);
return args[0]->val_decimal(d);
}
bool get_date(MYSQL_TIME *ltime, ulonglong fuzzydate)
{ return args[0]->get_date(ltime, fuzzydate); }
{
if (args[0]->result_type() == STRING_RESULT)
return Item_str_func::get_date(ltime, 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