diff options
author | Alexey Kopytov <Alexey.Kopytov@Sun.com> | 2009-12-22 19:23:13 +0300 |
---|---|---|
committer | Alexey Kopytov <Alexey.Kopytov@Sun.com> | 2009-12-22 19:23:13 +0300 |
commit | f02525be8346b7426f1640fb168a7451d38b1641 (patch) | |
tree | 40437c602d2a9ddaa03a54742cec4884f0974253 /mysql-test/t | |
parent | 5bce1e06429c3d58457051f0c439f130609df375 (diff) | |
download | mariadb-git-f02525be8346b7426f1640fb168a7451d38b1641.tar.gz |
Backport of WL #2934: Make/find library for doing float/double
to string conversions and vice versa"
Initial import of the dtoa.c code and custom wrappers around it
to allow its usage from the server code.
Conversion of FLOAT/DOUBLE values to DECIMAL ones or strings
and vice versa has been significantly reworked. As the new
algoritms are more precise than the older ones, results of such
conversions may not always match those obtained from older
server versions. This in turn may break compatibility for some
applications.
This patch also fixes the following bugs:
- bug #12860 "Difference in zero padding of exponent between
Unix and Windows"
- bug #21497 "DOUBLE truncated to unusable value"
- bug #26788 "mysqld (debug) aborts when inserting specific
numbers into char fields"
- bug #24541 "Data truncated..." on decimal type columns
without any good reason"
Diffstat (limited to 'mysql-test/t')
-rw-r--r-- | mysql-test/t/cast.test | 2 | ||||
-rw-r--r-- | mysql-test/t/gis.test | 3 | ||||
-rw-r--r-- | mysql-test/t/insert.test | 6 | ||||
-rw-r--r-- | mysql-test/t/mysqldump.test | 3 | ||||
-rw-r--r-- | mysql-test/t/parser.test | 4 | ||||
-rw-r--r-- | mysql-test/t/type_decimal.test | 12 | ||||
-rw-r--r-- | mysql-test/t/type_float.test | 33 | ||||
-rw-r--r-- | mysql-test/t/type_newdecimal.test | 6 |
8 files changed, 53 insertions, 16 deletions
diff --git a/mysql-test/t/cast.test b/mysql-test/t/cast.test index 8e60d548c2f..f5426f8d631 100644 --- a/mysql-test/t/cast.test +++ b/mysql-test/t/cast.test @@ -177,8 +177,6 @@ select cast(1.0e+300 as signed int); CREATE TABLE t1 (f1 double); INSERT INTO t1 SET f1 = -1.0e+30 ; INSERT INTO t1 SET f1 = +1.0e+30 ; -# Expected result is +-1e+30, but Windows returns +-1e+030. ---replace_result 1e+030 1e+30 SELECT f1 AS double_val, CAST(f1 AS SIGNED INT) AS cast_val FROM t1; DROP TABLE t1; diff --git a/mysql-test/t/gis.test b/mysql-test/t/gis.test index bc0695aaa93..70d73234ea8 100644 --- a/mysql-test/t/gis.test +++ b/mysql-test/t/gis.test @@ -353,6 +353,9 @@ insert into t1 values ('85984',GeomFromText('MULTIPOLYGON(((-115.006363 36.248666,-115.263639 36.247466,-115.263839 36.252766,-115.261439 36.252666,-115.261439 36.247366,-115.247239 36.247066)))')); +# Expected result is 115.31877315203187, but IA64 returns 115.31877315203188 +# due to fused multiply-add instructions. +--replace_result 115.31877315203188 115.31877315203187 select object_id, geometrytype(geo), ISSIMPLE(GEO), ASTEXT(centroid(geo)) from t1 where object_id=85998; diff --git a/mysql-test/t/insert.test b/mysql-test/t/insert.test index 40d1464b86a..4f918504597 100644 --- a/mysql-test/t/insert.test +++ b/mysql-test/t/insert.test @@ -422,9 +422,6 @@ INSERT INTO t1(a,c) VALUES (1.87e-3, 1.87e-3); INSERT INTO t1(a,c) VALUES (-1.87e-2, -1.87e-2); INSERT INTO t1(a,c) VALUES (5000e+0, 5000e+0); INSERT INTO t1(a,c) VALUES (-5000e+0, -5000e+0); -# Expected results are "12.2" and "1.2e+78", but Windows returns "12.3" and -# "1.3e+78" due to different rounding rules ---replace_result 12.3 12.2 1.3e+78 1.2e+78 SELECT * FROM t1; DROP TABLE t1; @@ -459,9 +456,6 @@ INSERT INTO t1(a,c) VALUES (-1.87e-2, -1.87e-2); INSERT INTO t1(a,c) VALUES (5000e+0, 5000e+0); INSERT INTO t1(a,c) VALUES (-5000e+0, -5000e+0); -# Expected results are "12.2" and "1.2e+78", but Windows returns "12.3" and -# "1.3e+78" due to different rounding rules ---replace_result 12.3 12.2 1.3e+78 1.2e+78 SELECT * FROM t1; DROP TABLE t1; diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index 07ab9cecd28..94b209305f6 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -46,9 +46,6 @@ DROP TABLE t1; CREATE TABLE t1 (a double); INSERT INTO t1 VALUES ('-9e999999'); -# The following replaces is here because some systems replaces the above -# double with '-inf' and others with MAX_DOUBLE ---replace_result (-1.79769313486232e+308) (RES) (NULL) (RES) --exec $MYSQL_DUMP --compact test t1 DROP TABLE t1; diff --git a/mysql-test/t/parser.test b/mysql-test/t/parser.test index e579e371184..e6c9c8b423f 100644 --- a/mysql-test/t/parser.test +++ b/mysql-test/t/parser.test @@ -646,6 +646,10 @@ select conv(255 AS p1, 10 AS p2, 16 AS p3); # Native function with a variable number of arguments +# Bug in libm.so on Solaris: +# atan(10) from 32-bit version returns 1.4711276743037347 +# atan(10) from 64-bit version returns 1.4711276743037345 +--replace_result 1.4711276743037345 1.4711276743037347 select atan(10); -- error ER_WRONG_PARAMETERS_TO_NATIVE_FCT select atan(10 AS p1); diff --git a/mysql-test/t/type_decimal.test b/mysql-test/t/type_decimal.test index dfe36ed0905..5d9a2aaa5f4 100644 --- a/mysql-test/t/type_decimal.test +++ b/mysql-test/t/type_decimal.test @@ -410,6 +410,18 @@ SELECT ROUND(qty,3), dps, ROUND(qty,dps) FROM t1; DROP TABLE t1; # +# Bug #24541: "Data truncated..." on decimal type columns without any good reason +# + +create table t1 (c1 decimal(10,6)); +insert into t1 (c1) values (9.99e-4); +insert into t1 (c1) values (9.98e-4); +insert into t1 (c1) values (0.000999); +insert into t1 (c1) values (cast(9.99e-4 as decimal(10,6))); +select * from t1; +drop table t1; + +# # Bug#31019: MOD() function and operator crashes MySQL when # divisor is very long and < 1 # diff --git a/mysql-test/t/type_float.test b/mysql-test/t/type_float.test index 3b7b30db6f8..45cf80aab5c 100644 --- a/mysql-test/t/type_float.test +++ b/mysql-test/t/type_float.test @@ -7,7 +7,7 @@ drop table if exists t1,t2; --enable_warnings SELECT 10,10.0,10.,.1e+2,100.0e-1; -SELECT 6e-05, -6e-05, --6e-05, -6e-05+1.000000; +SELECT 6e-16, -6e-16, --6e-16, -6e-16+1.000000; SELECT 1e1,1.e1,1.0e1,1e+1,1.e+1,1.0e+1,1e-1,1.e-1,1.0e-1; SELECT 0.001e+1,0.001e-1, -0.001e+01,-0.001e-01; SELECT 123.23E+02,-123.23E-02,"123.23E+02"+0.0,"-123.23E-02"+0.0; @@ -252,6 +252,37 @@ insert into t1 values (2e30), (-2e30); select f1 + 0e0 from t1; drop table t1; +# +# Bug #12860 "Difference in zero padding of exponent between Unix and Windows" +# + +create table t1 (c char(6)); +insert into t1 values (2e6),(2e-5); +select * from t1; +drop table t1; + +# +# Bug #21497 "DOUBLE truncated to unusable value" +# + +CREATE TABLE d1 (d DOUBLE); +INSERT INTO d1 VALUES (1.7976931348623157E+308); +SELECT * FROM d1; +--error ER_ILLEGAL_VALUE_FOR_TYPE +INSERT INTO d1 VALUES (1.79769313486232e+308); +SELECT * FROM d1; +DROP TABLE d1; + +# +# Bug #26788 "mysqld (debug) aborts when inserting specific numbers into char +# fields" +# + +create table t1 (a char(20)); +insert into t1 values (1.225e-05); +select a+0 from t1; +drop table t1; + # # Bug #27483: Casting 'scientific notation type' to 'unsigned bigint' fails on # windows. diff --git a/mysql-test/t/type_newdecimal.test b/mysql-test/t/type_newdecimal.test index 2cf7ab8fbdf..8af9d4c263e 100644 --- a/mysql-test/t/type_newdecimal.test +++ b/mysql-test/t/type_newdecimal.test @@ -1054,10 +1054,8 @@ while ($max_power) } SELECT my_float, my_double, my_varchar FROM t1; -# Expected result 0.000000000011754943372854760000 -# On windows we get 0.000000000011754943372854770000 -# use replace_result to correct it ---replace_result 0.000000000011754943372854770000 0.000000000011754943372854760000 +# The following statement produces results with garbage past +# the significant digits. Improving it is a part of the WL#3977. SELECT CAST(my_float AS DECIMAL(65,30)), my_float FROM t1; SELECT CAST(my_double AS DECIMAL(65,30)), my_double FROM t1; SELECT CAST(my_varchar AS DECIMAL(65,30)), my_varchar FROM t1; |