Commit 9672ef61 authored by unknown's avatar unknown
Browse files

Bug#16172 DECIMAL data type processed incorrectly

issue an error in case of DECIMAL(M,N) if N > M


mysql-test/r/type_newdecimal.result:
  Bug#16172 DECIMAL data type processed incorrectly
  result fix & test case
mysql-test/t/type_newdecimal.test:
  Bug#16172 DECIMAL data type processed incorrectly
  test fix
parent 1cf56699
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -915,9 +915,13 @@ drop table t1;
select cast('1.00000001335143196001808973960578441619873046875E-10' as decimal(30,15));
cast('1.00000001335143196001808973960578441619873046875E-10' as decimal(30,15))
0.000000000100000
select ln(14000) c1, convert(ln(14000),decimal(2,3)) c2, cast(ln(14000) as decimal(2,3)) c3;
select ln(14000) c1, convert(ln(14000),decimal(5,3)) c2, cast(ln(14000) as decimal(5,3)) c3;
c1	c2	c3
9.5468126085974	9.547	9.547
select convert(ln(14000),decimal(2,3)) c1;
ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column '').
select cast(ln(14000) as decimal(2,3)) c1;
ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column '').
create table t1 (sl decimal(70,30));
ERROR 42000: Too big precision 70 specified for column 'sl'. Maximum is 65.
create table t1 (sl decimal(32,31));
+6 −2
Original line number Diff line number Diff line
@@ -947,7 +947,11 @@ select cast('1.00000001335143196001808973960578441619873046875E-10' as decimal(3
#
# Bug #11708 (conversion to decimal fails in decimal part)
#
select ln(14000) c1, convert(ln(14000),decimal(2,3)) c2, cast(ln(14000) as decimal(2,3)) c3;
select ln(14000) c1, convert(ln(14000),decimal(5,3)) c2, cast(ln(14000) as decimal(5,3)) c3;
--error 1427
select convert(ln(14000),decimal(2,3)) c1;
--error 1427
select cast(ln(14000) as decimal(2,3)) c1;
 
#
# Bug #8449 (Silent column changes)
+8 −1
Original line number Diff line number Diff line
@@ -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 : 
+4 −0
Original line number Diff line number Diff line
@@ -4359,6 +4359,8 @@ simple_expr:
                                 lex->length ? atoi(lex->length) : -1,
                                 lex->dec ? atoi(lex->dec) : 0,
                                 lex->charset);
            if (!$$)
              YYABORT;
	  }
	| CASE_SYM opt_expr WHEN_SYM when_list opt_else END
	  { $$= new Item_func_case(* $4, $2, $5 ); }
@@ -4368,6 +4370,8 @@ simple_expr:
				 Lex->length ? atoi(Lex->length) : -1,
                                 Lex->dec ? atoi(Lex->dec) : 0,
				 Lex->charset);
            if (!$$)
              YYABORT;
	  }
	| CONVERT_SYM '(' expr USING charset_name ')'
	  { $$= new Item_func_conv_charset($3,$5); }