MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Alexey Kopytov Date:October 15 2007 6:34am
Subject:bk commit into 5.0 tree (kaa:1.2528) BUG#30453
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of kaa. When kaa does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2007-10-15 10:34:34+04:00, kaa@polly.(none) +3 -0
  Fix for bug #30453: String not cast to int correctly.
  
  Problem:
  
  my_strntoull10rnd_8bit() handled incorrectly cases when the input
  string contains a decimal point and is long enough to overrun the
  'unsigned long long' type. The position of the decimal point was not
  taken into account which resulted in miscalculated numbers and
  truncation to appropriate SQL data type limits.
  
  Solution:
  
  Fix my_strntoull10rnd_8bit() to take the position of a decimal point
  into account in such cases.

  mysql-test/r/insert.result@stripped, 2007-10-15 10:34:29+04:00, kaa@polly.(none) +14 -0
    Added a test case for bug #30453.

  mysql-test/t/insert.test@stripped, 2007-10-15 10:34:29+04:00, kaa@polly.(none) +15 -0
    Added a test case for bug #30453.

  strings/ctype-simple.c@stripped, 2007-10-15 10:34:29+04:00, kaa@polly.(none) +9 -5
    In cases when the 'unsigned long long' type is overrun by the input
    string and a decimal point has occurred, adjust the 'shift' according to
    the position of the decimal point and skip all subsequent digits.

diff -Nrup a/mysql-test/r/insert.result b/mysql-test/r/insert.result
--- a/mysql-test/r/insert.result	2007-05-30 16:04:02 +04:00
+++ b/mysql-test/r/insert.result	2007-10-15 10:34:29 +04:00
@@ -461,4 +461,18 @@ i
 2
 2
 DROP TABLE t1, t2;
+CREATE TABLE t1 (c1 INT NOT NULL);
+INSERT INTO t1 VALUES(4188.32999999999992724042385816574096679687500),
+('4188.32999999999992724042385816574096679687500'), (4188);
+SELECT * FROM t1;
+c1
+4188
+4188
+4188
+CREATE TABLE t2 (c1 BIGINT);
+INSERT INTO t2 VALUES('15449237462.0000000000');
+SELECT * FROM t2;
+c1
+15449237462
+DROP TABLE t1, t2;
 End of 5.0 tests.
diff -Nrup a/mysql-test/t/insert.test b/mysql-test/t/insert.test
--- a/mysql-test/t/insert.test	2007-05-16 09:51:03 +04:00
+++ b/mysql-test/t/insert.test	2007-10-15 10:34:29 +04:00
@@ -353,5 +353,20 @@ SELECT * FROM t2;
 
 DROP TABLE t1, t2;
 
+#
+# Bug #30453: String not cast to int correctly
+#
+
+CREATE TABLE t1 (c1 INT NOT NULL);
+INSERT INTO t1 VALUES(4188.32999999999992724042385816574096679687500),
+('4188.32999999999992724042385816574096679687500'), (4188);
+SELECT * FROM t1;
+
+CREATE TABLE t2 (c1 BIGINT);
+INSERT INTO t2 VALUES('15449237462.0000000000');
+SELECT * FROM t2;
+
+DROP TABLE t1, t2;
+
 --echo End of 5.0 tests.
 
diff -Nrup a/strings/ctype-simple.c b/strings/ctype-simple.c
--- a/strings/ctype-simple.c	2007-07-09 01:21:39 +04:00
+++ b/strings/ctype-simple.c	2007-10-15 10:34:29 +04:00
@@ -1538,14 +1538,18 @@ my_strntoull10rnd_8bit(CHARSET_INFO *cs 
       }
       else
         addon= (*str >= '5');
-      for ( ; str < end && (ch= (unsigned char) (*str - '0')) < 10; str++)
+      if (!dot)
       {
-        if (!dot)
-          shift++;
+        for ( ; str < end && (ch= (unsigned char) (*str - '0')) < 10; shift++, str++);
+        if (str < end && *str == '.')
+        {
+          str++;
+          for ( ; str < end && (ch= (unsigned char) (*str - '0')) < 10; str++);
+        }
       }
-      if (str < end && *str == '.' && !dot)
+      else
       {
-        str++;
+        shift= dot - str;
         for ( ; str < end && (ch= (unsigned char) (*str - '0')) < 10; str++);
       }
       goto exp;
Thread
bk commit into 5.0 tree (kaa:1.2528) BUG#30453Alexey Kopytov15 Oct