From: Date: December 6 2005 1:54pm Subject: bk commit into 4.1 tree (bar:1.2485) BUG#15098 List-Archive: http://lists.mysql.com/internals/33070 X-Bug: 15098 Message-Id: <200512061254.jB6CsJ1h047129@bar.intranet.mysql.r18.ru> Below is the list of changes that have just been committed into a local 4.1 repository of bar. When bar 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.2485 05/12/06 16:54:13 bar@stripped +3 -0 Bug#15098 CAST(column double TO signed int), wrong result field.cc: Adding longlong range checking to return LONGLONG_MIN or LONGLONG_MAX when out of range. Using (longlong) cast only when range is ok. cast.test: Adding test case. cast.result: Fixing results accordingly. mysql-test/r/cast.result 1.25 05/12/06 16:51:12 bar@stripped +8 -0 Fixing results accordingly. mysql-test/t/cast.test 1.21 05/12/06 16:51:00 bar@stripped +9 -0 Bug#15098 CAST(column double TO signed int), wrong result Adding longlong range checking. sql/field.cc 1.228 05/12/06 16:50:16 bar@stripped +5 -0 Bug#15098 CAST(column double TO signed int), wrong result Adding longlong range checking. # 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: bar # Host: bar.intranet.mysql.r18.ru # Root: /usr/home/bar/mysql-4.1.b15098 --- 1.227/sql/field.cc 2005-10-31 12:24:36 +04:00 +++ 1.228/sql/field.cc 2005-12-06 16:50:16 +04:00 @@ -3385,6 +3385,11 @@ else #endif doubleget(j,ptr); + /* Check whether we fit into longlong range */ + if (j <= (double) LONGLONG_MIN) + return (longlong) LONGLONG_MIN; + if (j >= (double) (ulonglong) LONGLONG_MAX) + return (longlong) LONGLONG_MAX; return ((longlong) j); } --- 1.24/mysql-test/r/cast.result 2005-10-13 01:27:46 +05:00 +++ 1.25/mysql-test/r/cast.result 2005-12-06 16:51:12 +04:00 @@ -267,3 +267,11 @@ select cast(1.0e+300 as signed int); cast(1.0e+300 as signed int) 9223372036854775807 +CREATE TABLE t1 (f1 double); +INSERT INTO t1 SET f1 = -1.0e+30 ; +INSERT INTO t1 SET f1 = +1.0e+30 ; +SELECT f1 AS double_val, CAST(f1 AS SIGNED INT) AS cast_val FROM t1; +double_val cast_val +-1e+30 -9223372036854775808 +1e+30 9223372036854775807 +DROP TABLE t1; --- 1.20/mysql-test/t/cast.test 2005-10-13 01:27:47 +05:00 +++ 1.21/mysql-test/t/cast.test 2005-12-06 16:51:00 +04:00 @@ -152,4 +152,13 @@ # select cast(1.0e+300 as signed int); +# +# Bugs: #15098: CAST(column double TO signed int), wrong result +# +CREATE TABLE t1 (f1 double); +INSERT INTO t1 SET f1 = -1.0e+30 ; +INSERT INTO t1 SET f1 = +1.0e+30 ; +SELECT f1 AS double_val, CAST(f1 AS SIGNED INT) AS cast_val FROM t1; +DROP TABLE t1; + # End of 4.1 tests