diff --git a/mysql-test/r/type_float.result b/mysql-test/r/type_float.result index f41c2e7688b..f498b6889a5 100644 --- a/mysql-test/r/type_float.result +++ b/mysql-test/r/type_float.result @@ -447,3 +447,21 @@ End of 5.0 tests select format(truncate('1.7976931348623157E+308',-12),1,'fr_BE') as foo; foo 0 +# +# Bug #13500371 63704: CONVERSION OF '1.' TO A NUMBER GIVES ERROR 1265 +# (WARN_DATA_TRUNCATED) +# +CREATE TABLE t1 (f FLOAT); +INSERT INTO t1 VALUES ('1.'); +INSERT INTO t1 VALUES ('2.0.'); +Warnings: +Warning 1265 Data truncated for column 'f' at row 1 +INSERT INTO t1 VALUES ('.'); +Warnings: +Warning 1265 Data truncated for column 'f' at row 1 +SELECT * FROM t1 ORDER BY f; +f +0 +1 +2 +DROP TABLE t1; diff --git a/mysql-test/t/type_float.test b/mysql-test/t/type_float.test index b33c51566a0..96ce1bcbd9e 100644 --- a/mysql-test/t/type_float.test +++ b/mysql-test/t/type_float.test @@ -331,3 +331,15 @@ eval select concat((truncate((-1.7976931348623157E+307),(0x1e))), --echo # select format(truncate('1.7976931348623157E+308',-12),1,'fr_BE') as foo; + +--echo # +--echo # Bug #13500371 63704: CONVERSION OF '1.' TO A NUMBER GIVES ERROR 1265 +--echo # (WARN_DATA_TRUNCATED) +--echo # + +CREATE TABLE t1 (f FLOAT); +INSERT INTO t1 VALUES ('1.'); +INSERT INTO t1 VALUES ('2.0.'); +INSERT INTO t1 VALUES ('.'); +SELECT * FROM t1 ORDER BY f; +DROP TABLE t1; diff --git a/strings/dtoa.c b/strings/dtoa.c index f3498a7bb1e..c3ab347f94c 100644 --- a/strings/dtoa.c +++ b/strings/dtoa.c @@ -1410,7 +1410,7 @@ static double my_strtod_int(const char *s00, char **se, int *error, char *buf, s else if (nd < 16) z= 10*z + c - '0'; nd0= nd; - if (s < end - 1 && c == '.') + if (s < end && c == '.') { ++s; if (!nd)