List:Internals« Previous MessageNext Message »
From:Jim Winstead Date:September 23 2005 12:59am
Subject:bk commit into 4.1 tree (jimw:1.2458) BUG#13344
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of jimw. When jimw 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
  1.2458 05/09/22 15:59:13 jimw@stripped +3 -0
  Fix CAST(1.0e+300 TO SIGNED). (Bug #13344)

  sql/item.h
    1.191 05/09/22 15:59:10 jimw@stripped +8 -0
    Cap Item_real::val_int() to LONGLONG_MIN and LONGLONG_MAX.

  mysql-test/t/cast.test
    1.19 05/09/22 15:59:10 jimw@stripped +5 -0
    Add regression test

  mysql-test/r/cast.result
    1.23 05/09/22 15:59:10 jimw@stripped +3 -0
    Update results

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	jimw
# Host:	rama.(none)
# Root:	/home/jimw/my/mysql-4.1-13344

--- 1.190/sql/item.h	2005-08-29 03:44:43 -07:00
+++ 1.191/sql/item.h	2005-09-22 15:59:10 -07:00
@@ -703,6 +703,14 @@
   longlong val_int()
   {
     DBUG_ASSERT(fixed == 1);
+    if (value <= (double) LONGLONG_MIN)
+    {
+       return LONGLONG_MIN;
+    }
+    else if (value >= (double) (ulonglong) LONGLONG_MAX)
+    {
+      return LONGLONG_MAX;
+    }
     return (longlong) (value+(value > 0 ? 0.5 : -0.5));
   }
   String *val_str(String*);

--- 1.22/mysql-test/r/cast.result	2005-04-29 07:03:15 -07:00
+++ 1.23/mysql-test/r/cast.result	2005-09-22 15:59:10 -07:00
@@ -252,3 +252,6 @@
 -7335632962598440505
 Warnings:
 Warning	1105	Cast to signed converted positive out-of-range integer to it's negative
complement
+select cast(1.0e+300 as signed int);
+cast(1.0e+300 as signed int)
+9223372036854775807

--- 1.18/mysql-test/t/cast.test	2005-09-15 07:17:10 -07:00
+++ 1.19/mysql-test/t/cast.test	2005-09-22 15:59:10 -07:00
@@ -143,4 +143,9 @@
 select cast(repeat('1',20) as unsigned);
 select cast(repeat('1',20) as signed);
 
+#
+# Bug #13344: cast of large decimal to signed int not handled correctly
+#
+select cast(1.0e+300 as signed int);
+
 # End of 4.1 tests
Thread
bk commit into 4.1 tree (jimw:1.2458) BUG#13344Jim Winstead23 Sep