Commit b56bc04c authored by bar@mysql.com's avatar bar@mysql.com

Merge mysql.com:/usr/home/bar/mysql-5.0

into  mysql.com:/usr/home/bar/mysql-5.1-new
parents 15ecaa18 fc86e304
...@@ -337,6 +337,14 @@ Warning 1105 Cast to signed converted positive out-of-range integer to it's nega ...@@ -337,6 +337,14 @@ Warning 1105 Cast to signed converted positive out-of-range integer to it's nega
select cast(1.0e+300 as signed int); select cast(1.0e+300 as signed int);
cast(1.0e+300 as signed int) cast(1.0e+300 as signed int)
9223372036854775807 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;
select cast('1.2' as decimal(3,2)); select cast('1.2' as decimal(3,2));
cast('1.2' as decimal(3,2)) cast('1.2' as decimal(3,2))
1.20 1.20
......
...@@ -165,6 +165,15 @@ select cast(repeat('1',20) as signed); ...@@ -165,6 +165,15 @@ select cast(repeat('1',20) as signed);
# #
select cast(1.0e+300 as signed int); 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 # End of 4.1 tests
......
...@@ -4245,6 +4245,11 @@ longlong Field_double::val_int(void) ...@@ -4245,6 +4245,11 @@ longlong Field_double::val_int(void)
else else
#endif #endif
doubleget(j,ptr); 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) rint(j); return (longlong) rint(j);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment