mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 12:32:27 +01:00
IF() and LEAST() now honors coercibility
This commit is contained in:
parent
a0e2d75aa0
commit
ce17ac5af2
2 changed files with 15 additions and 5 deletions
|
@ -723,8 +723,12 @@ Item_func_if::fix_length_and_dec()
|
||||||
else if (arg1_type == STRING_RESULT || arg2_type == STRING_RESULT)
|
else if (arg1_type == STRING_RESULT || arg2_type == STRING_RESULT)
|
||||||
{
|
{
|
||||||
cached_result_type = STRING_RESULT;
|
cached_result_type = STRING_RESULT;
|
||||||
set_charset((args[1]->binary() || args[2]->binary()) ?
|
if (set_charset(args[1]->charset(), args[1]->coercibility,
|
||||||
&my_charset_bin : args[1]->charset());
|
args[2]->charset(), args[2]->coercibility))
|
||||||
|
{
|
||||||
|
my_error(ER_WRONG_ARGUMENTS,MYF(0),func_name());
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -760,6 +764,7 @@ Item_func_if::val_str(String *str)
|
||||||
{
|
{
|
||||||
Item *arg= args[0]->val_int() ? args[1] : args[2];
|
Item *arg= args[0]->val_int() ? args[1] : args[2];
|
||||||
String *res=arg->val_str(str);
|
String *res=arg->val_str(str);
|
||||||
|
res->set_charset(charset());
|
||||||
null_value=arg->null_value;
|
null_value=arg->null_value;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
@ -855,9 +855,13 @@ void Item_func_min_max::fix_length_and_dec()
|
||||||
maybe_null=0;
|
maybe_null=0;
|
||||||
cmp_type=item_cmp_type(cmp_type,args[i]->result_type());
|
cmp_type=item_cmp_type(cmp_type,args[i]->result_type());
|
||||||
if (i==0)
|
if (i==0)
|
||||||
set_charset(args[i]->charset());
|
set_charset(args[i]->charset(), args[i]->coercibility);
|
||||||
else if (args[i]->charset() == &my_charset_bin)
|
else if (set_charset(charset(), coercibility,
|
||||||
set_charset(&my_charset_bin);
|
args[i]->charset(), args[i]->coercibility))
|
||||||
|
{
|
||||||
|
my_error(ER_WRONG_ARGUMENTS,MYF(0),func_name());
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -909,6 +913,7 @@ String *Item_func_min_max::val_str(String *str)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
res->set_charset(charset());
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
case ROW_RESULT:
|
case ROW_RESULT:
|
||||||
|
|
Loading…
Reference in a new issue