List:Commits« Previous MessageNext Message »
From:Sergey Glukhov Date:March 23 2011 12:21pm
Subject:bzr commit into mysql-5.1 branch (sergey.glukhov:3620) Bug#11764994
View as plain text  
#At file:///home/gluh/MySQL/mysql-5.1/ based on revid:sergey.glukhov@stripped

 3620 Sergey Glukhov	2011-03-23
      Bug#11764994  57900: CREATE TABLE .. SELECT ASSERTS SCALE >= 0 && PRECISION > 0 && SCALE <= PR
      Assert fails due to overflow which happens in
      Item_func_int_val::fix_num_length_and_dec() as
      geometry functions have max_length value equal to
      max_field_size(4294967295U). The fix is to skip
      max_length calculation for some boundary cases.
     @ mysql-test/r/func_math.result
        test case
     @ mysql-test/t/func_math.test
        test case
     @ sql/item_func.cc
        skip max_length calculation
        if argument max_length is near max_field_size.

    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-12-24 11:05:04 +0000
+++ b/mysql-test/r/func_math.result	2011-03-23 12:21:52 +0000
@@ -511,4 +511,11 @@ t1	CREATE TABLE `t1` (
   `C` varchar(23) DEFAULT NULL
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
 DROP TABLE t1;
+#
+# Bug#11764994  57900: CREATE TABLE .. SELECT ASSERTS SCALE >= 0 && PRECISION > 0 && SCALE <= PR
+#
+CREATE TABLE t1 SELECT CEIL(LINESTRINGFROMWKB(1) DIV NULL);
+DROP TABLE t1;
+CREATE TABLE t1 SELECT FLOOR(LINESTRINGFROMWKB(1) DIV NULL);
+DROP TABLE t1;
 End of 5.1 tests

=== modified file 'mysql-test/t/func_math.test'
--- a/mysql-test/t/func_math.test	2010-12-24 11:05:04 +0000
+++ b/mysql-test/t/func_math.test	2011-03-23 12:21:52 +0000
@@ -324,4 +324,13 @@ CREATE TABLE t1 SELECT CAST((CASE(('')) 
 SHOW CREATE TABLE t1;
 DROP TABLE t1;
 
+--echo #
+--echo # Bug#11764994  57900: CREATE TABLE .. SELECT ASSERTS SCALE >= 0 && PRECISION > 0 && SCALE <= PR
+--echo #
+
+CREATE TABLE t1 SELECT CEIL(LINESTRINGFROMWKB(1) DIV NULL);
+DROP TABLE t1;
+CREATE TABLE t1 SELECT FLOOR(LINESTRINGFROMWKB(1) DIV NULL);
+DROP TABLE t1;
+
 --echo End of 5.1 tests

=== modified file 'sql/item_func.cc'
--- a/sql/item_func.cc	2011-03-03 12:04:04 +0000
+++ b/sql/item_func.cc	2011-03-23 12:21:52 +0000
@@ -1803,9 +1803,17 @@ void Item_func_integer::fix_length_and_d
 
 void Item_func_int_val::fix_num_length_and_dec()
 {
-  max_length= args[0]->max_length - (args[0]->decimals ?
-                                     args[0]->decimals + 1 :
-                                     0) + 2;
+  /*
+    avoid overflow for Geometry functions which
+    have max_length = max_field_size.
+  */
+  if (max_field_size - args[0]->max_length > 2)
+    max_length= args[0]->max_length - (args[0]->decimals ?
+                                       args[0]->decimals + 1 :
+                                       0) + 2;
+  else
+    max_length= args[0]->max_length;
+
   uint tmp= float_length(decimals);
   set_if_smaller(max_length,tmp);
   decimals= 0;


Attachment: [text/bzr-bundle] bzr/sergey.glukhov@oracle.com-20110323122152-i7bbu1en4ncfpkf8.bundle
Thread
bzr commit into mysql-5.1 branch (sergey.glukhov:3620) Bug#11764994Sergey Glukhov23 Mar