3749 Norvald H. Ryeng 2012-01-19
Bug#13500371 63704: CONVERSION OF '1.' TO A NUMBER GIVES ERROR 1265
(WARN_DATA_TRUNCATED)
Problem: Converting strings ending with a decimal point (such as '1.')
to floating point numbers causes a truncation warning to be emitted.
Field_float::store() and Field_double::store() calls my_strtod_int()
to convert strings to floating point numbers. Function my_strtod_int()
doesn't consume the decimal point if it is the last character of the
string, and this leads to Field_float::store() and
Field_double::store() reporting unconsumed character as truncated
data.
Fix: Let my_strtod_int() consume the decimal point also if it is the
last character of the string. This behavior is consistent with that of
scanf().
@ mysql-test/r/type_float.result
Test case for bug #13500371.
@ mysql-test/t/type_float.test
Test case for bug #13500371.
@ strings/dtoa.c
Consume decimal point also at end of string.
modified:
mysql-test/r/type_float.result
mysql-test/t/type_float.test
strings/dtoa.c
3748 kevin.lewis@stripped 2012-01-18
Fix a UNIV_DEBUG compile error.
modified:
storage/innobase/dict/dict0boot.cc
=== modified file 'mysql-test/r/type_float.result'
--- a/mysql-test/r/type_float.result 2011-07-18 08:27:05 +0000
+++ b/mysql-test/r/type_float.result 2012-01-19 07:41:28 +0000
@@ -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;
=== modified file 'mysql-test/t/type_float.test'
--- a/mysql-test/t/type_float.test 2011-07-18 08:27:05 +0000
+++ b/mysql-test/t/type_float.test 2012-01-19 07:41:28 +0000
@@ -331,3 +331,15 @@ eval select concat((truncate((-1.7976931
--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;
=== modified file 'strings/dtoa.c'
--- a/strings/dtoa.c 2011-09-26 12:42:12 +0000
+++ b/strings/dtoa.c 2012-01-19 07:41:28 +0000
@@ -1397,7 +1397,7 @@ static double my_strtod_int(const char *
else if (nd < 16)
z= 10*z + c - '0';
nd0= nd;
- if (s < end - 1 && c == '.')
+ if (s < end && c == '.')
{
c= *++s;
if (!nd)
No bundle (reason: useless for push emails).
| Thread |
|---|
| • bzr push into mysql-trunk branch (norvald.ryeng:3748 to 3749) Bug#13500371 | Norvald H. Ryeng | 20 Jan |