#At file:///home/gluh/MySQL/mysql-5.0-bug-43833/ based on revid:chad@stripped
2726 Sergey Glukhov 2009-04-03
Bug#43833 Simple INSERT crashes the server
The crash happens due to wrong 'digits' variable value(0),
'digits' can not be 0, so the fix is use 1 as min allowed value.
@ mysql-test/r/insert.result
test case
@ mysql-test/t/insert.test
test case
@ sql/field.cc
Bug#43833 Simple INSERT crashes the server
The crash happens due to wrong 'digits' variable value(0),
'digits' can not be 0, so the fix is use 1 as min allowed value.
modified:
mysql-test/r/insert.result
mysql-test/t/insert.test
sql/field.cc
=== modified file 'mysql-test/r/insert.result'
--- a/mysql-test/r/insert.result 2007-12-01 12:37:25 +0000
+++ b/mysql-test/r/insert.result 2009-04-03 11:07:04 +0000
@@ -595,4 +595,9 @@ SELECT * FROM t2;
c1
15449237462
DROP TABLE t1, t2;
+CREATE TABLE t1(f1 FLOAT);
+INSERT INTO t1 VALUES (1.23);
+CREATE TABLE t2(f1 CHAR(1));
+INSERT INTO t2 SELECT f1 FROM t1;
+DROP TABLE t1, t2;
End of 5.0 tests.
=== modified file 'mysql-test/t/insert.test'
--- a/mysql-test/t/insert.test 2007-12-02 11:11:36 +0000
+++ b/mysql-test/t/insert.test 2009-04-03 11:07:04 +0000
@@ -454,5 +454,14 @@ SELECT * FROM t2;
DROP TABLE t1, t2;
+#
+# Bug#43833 Simple INSERT crashes the server
+#
+CREATE TABLE t1(f1 FLOAT);
+INSERT INTO t1 VALUES (1.23);
+CREATE TABLE t2(f1 CHAR(1));
+INSERT INTO t2 SELECT f1 FROM t1;
+DROP TABLE t1, t2;
+
--echo End of 5.0 tests.
=== modified file 'sql/field.cc'
--- a/sql/field.cc 2009-03-27 10:12:50 +0000
+++ b/sql/field.cc 2009-04-03 11:07:04 +0000
@@ -5987,13 +5987,13 @@ int Field_str::store(double nr)
calculate the maximum number of significant digits if the 'f'-format
would be used (+1 for decimal point if the number has a fractional part).
*/
- digits= max(0, (int) max_length - fractional);
+ digits= max(1, (int) max_length - fractional);
/*
If the exponent is negative, decrease digits by the number of leading zeros
after the decimal point that do not count as significant digits.
*/
if (exp < 0)
- digits= max(0, (int) digits + exp);
+ digits= max(1, (int) digits + exp);
/*
'e'-format is used only if the exponent is less than -4 or greater than or
equal to the precision. In this case we need to adjust the number of
@@ -6001,7 +6001,7 @@ int Field_str::store(double nr)
We also have to reserve one additional character if abs(exp) >= 100.
*/
if (exp >= (int) digits || exp < -4)
- digits= max(0, (int) (max_length - 5 - (exp >= 100 || exp <= -100)));
+ digits= max(1, (int) (max_length - 5 - (exp >= 100 || exp <= -100)));
/* Limit precision to DBL_DIG to avoid garbage past significant digits */
set_if_smaller(digits, DBL_DIG);
Attachment: [text/bzr-bundle] bzr/sergey.glukhov@sun.com-20090403110704-hz0wm45wj2pf2ym7.bundle
| Thread |
|---|
| • bzr commit into mysql-5.0-bugteam branch (Sergey.Glukhov:2726)Bug#43833 | Sergey Glukhov | 3 Apr |