1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Bug#16172 DECIMAL data type processed incorrectly

issue an error in case of DECIMAL(M,N) if N > M
This commit is contained in:
gluh@mysql.com/gluh.(none)
2006-08-08 14:40:07 +05:00
parent e9b87a1a7f
commit 1be93531ee
4 changed files with 23 additions and 4 deletions

View File

@ -450,6 +450,7 @@ Item *create_func_cast(Item *a, Cast_target cast_type, int len, int dec,
CHARSET_INFO *cs)
{
Item *res;
int tmp_len;
LINT_INIT(res);
switch (cast_type) {
@ -460,7 +461,13 @@ Item *create_func_cast(Item *a, Cast_target cast_type, int len, int dec,
case ITEM_CAST_TIME: res= new Item_time_typecast(a); break;
case ITEM_CAST_DATETIME: res= new Item_datetime_typecast(a); break;
case ITEM_CAST_DECIMAL:
res= new Item_decimal_typecast(a, (len>0) ? len : 10, dec ? dec : 2);
tmp_len= (len>0) ? len : 10;
if (tmp_len < dec)
{
my_error(ER_M_BIGGER_THAN_D, MYF(0), "");
return 0;
}
res= new Item_decimal_typecast(a, tmp_len, dec ? dec : 2);
break;
case ITEM_CAST_CHAR:
res= new Item_char_typecast(a, len, cs ? cs :