List:Commits« Previous MessageNext Message »
From:Sergey Glukhov Date:December 21 2010 3:31pm
Subject:bzr commit into mysql-5.1-bugteam branch (sergey.glukhov:3534) Bug#57810
View as plain text  
#At file:///home/gluh/MySQL/mysql-5.1-bugteam/ based on revid:sergey.glukhov@stripped

 3534 Sergey Glukhov	2010-12-21
      Bug#57810 case/when/then : Assertion failed: length || !scale
      ASSERT happens due to improper calculation of the max_length
      in Item_func_div object, if dividend has max_length == 0 then
      Item_func_div::max_length is set to 0 under some circumstances.
      The fix:
      If decimals == NOT_FIXED_DEC then set
      Item_func_div::max_length to max possible
      DOUBLE length value.
     @ mysql-test/r/func_math.result
        test case
     @ mysql-test/t/func_math.test
        test case
     @ sql/item_func.cc
        The fix:
        If decimals == NOT_FIXED_DEC then set
        Item_func_div::max_length to max possible
        DOUBLE length value.

    modified:
      mysql-test/r/func_math.result
      mysql-test/t/func_math.test
      sql/item_func.cc
=== modified file 'mysql-test/r/func_math.result'
--- a/mysql-test/r/func_math.result	2010-10-27 14:12:10 +0000
+++ b/mysql-test/r/func_math.result	2010-12-21 15:31:13 +0000
@@ -498,4 +498,10 @@ SELECT -9223372036854775808 MOD -1;
 SELECT -9223372036854775808999 MOD -1;
 -9223372036854775808999 MOD -1
 0
+#
+# Bug#57810 case/when/then : Assertion failed: length || !scale
+#
+SELECT CASE(('')) WHEN (CONVERT(1, CHAR(1))) THEN (('' / 1)) END;
+CASE(('')) WHEN (CONVERT(1, CHAR(1))) THEN (('' / 1)) END
+NULL
 End of 5.1 tests

=== modified file 'mysql-test/t/func_math.test'
--- a/mysql-test/t/func_math.test	2010-10-27 14:12:10 +0000
+++ b/mysql-test/t/func_math.test	2010-12-21 15:31:13 +0000
@@ -315,4 +315,10 @@ SELECT -9223372036854775808 DIV -1;
 SELECT -9223372036854775808 MOD -1;
 SELECT -9223372036854775808999 MOD -1;
 
+--echo #
+--echo # Bug#57810 case/when/then : Assertion failed: length || !scale
+--echo #
+
+SELECT CASE(('')) WHEN (CONVERT(1, CHAR(1))) THEN (('' / 1)) END;
+
 --echo End of 5.1 tests

=== modified file 'sql/item_func.cc'
--- a/sql/item_func.cc	2010-12-16 14:40:52 +0000
+++ b/sql/item_func.cc	2010-12-21 15:31:13 +0000
@@ -1329,9 +1329,14 @@ void Item_func_div::fix_length_and_dec()
   {
     decimals=max(args[0]->decimals,args[1]->decimals)+prec_increment;
     set_if_smaller(decimals, NOT_FIXED_DEC);
-    max_length=args[0]->max_length - args[0]->decimals + decimals;
     uint tmp=float_length(decimals);
-    set_if_smaller(max_length,tmp);
+    if (decimals == NOT_FIXED_DEC)
+      max_length= tmp;
+    else
+    {
+      max_length=args[0]->max_length - args[0]->decimals + decimals;
+      set_if_smaller(max_length,tmp);
+    }
     break;
   }
   case INT_RESULT:


Attachment: [text/bzr-bundle] bzr/sergey.glukhov@oracle.com-20101221153113-gz0i6or7qfy1k2sf.bundle
Thread
bzr commit into mysql-5.1-bugteam branch (sergey.glukhov:3534) Bug#57810Sergey Glukhov21 Dec