Loading mysql-test/r/cast.result +8 −0 Original line number Diff line number Diff line Loading @@ -370,3 +370,11 @@ DROP TABLE t1; select cast(NULL as decimal(6)) as t1; t1 NULL 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; mysql-test/t/cast.test +9 −0 Original line number Diff line number Diff line Loading @@ -165,6 +165,15 @@ select cast(repeat('1',20) as signed); # 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 Loading sql/field.cc +5 −0 Original line number Diff line number Diff line Loading @@ -4240,6 +4240,11 @@ longlong Field_double::val_int(void) 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) rint(j); } Loading Loading
mysql-test/r/cast.result +8 −0 Original line number Diff line number Diff line Loading @@ -370,3 +370,11 @@ DROP TABLE t1; select cast(NULL as decimal(6)) as t1; t1 NULL 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;
mysql-test/t/cast.test +9 −0 Original line number Diff line number Diff line Loading @@ -165,6 +165,15 @@ select cast(repeat('1',20) as signed); # 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 Loading
sql/field.cc +5 −0 Original line number Diff line number Diff line Loading @@ -4240,6 +4240,11 @@ longlong Field_double::val_int(void) 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) rint(j); } Loading