Below is the list of changes that have just been committed into a local
5.0 repository of martin. When martin does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-12-19 11:45:48+01:00, mhansson@stripped +3 -0
Bug#24657: debug assertation fails (string store)
sprintf is used to insert DOUBLE values into VARCHAR columns, but it
was assumed that sprintf would write only 1 byte for a positive number
n < 1. In realtity it needs two, one for leading zero and one for decimal
point. Fixed by making the number 2.
mysql-test/r/type_varchar.result@stripped, 2007-12-19 11:45:44+01:00, mhansson@stripped +13 -0
Bug#24657: Test result
mysql-test/t/type_varchar.test@stripped, 2007-12-19 11:45:44+01:00, mhansson@stripped +17 -0
Bug#24657: Test case
sql/field.cc@stripped, 2007-12-19 11:45:44+01:00, mhansson@stripped +6 -4
Bug#24657: The fix
diff -Nrup a/mysql-test/r/type_varchar.result b/mysql-test/r/type_varchar.result
--- a/mysql-test/r/type_varchar.result 2006-12-04 13:29:30 +01:00
+++ b/mysql-test/r/type_varchar.result 2007-12-19 11:45:44 +01:00
@@ -489,3 +489,16 @@ Warnings:
Warning 1292 Truncated incorrect INTEGER value: '1a'
Warning 1292 Truncated incorrect INTEGER value: 't'
DROP TABLE t1;
+CREATE FUNCTION f1() RETURNS DOUBLE RETURN 0.12345678901234567890;
+CREATE FUNCTION f2() RETURNS DOUBLE RETURN -0.12345678901234567890;
+CREATE FUNCTION f3() RETURNS DOUBLE RETURN 1.12345678901234567890;
+CREATE TABLE t1( a VARCHAR(19) );
+INSERT INTO t1 VALUES ('A');
+INSERT INTO t1 SELECT f1() FROM t1;
+INSERT INTO t1 SELECT f1() FROM t1 LIMIT 1;
+INSERT INTO t1 SELECT f2() FROM t1 LIMIT 1;
+INSERT INTO t1 SELECT f2() FROM t1 LIMIT 1;
+INSERT INTO t1 SELECT f3() FROM t1 LIMIT 1;
+INSERT INTO t1 SELECT f3() FROM t1 LIMIT 1;
+DROP FUNCTION f1;
+DROP TABLE t1;
diff -Nrup a/mysql-test/t/type_varchar.test b/mysql-test/t/type_varchar.test
--- a/mysql-test/t/type_varchar.test 2007-02-23 18:05:31 +01:00
+++ b/mysql-test/t/type_varchar.test 2007-12-19 11:45:44 +01:00
@@ -198,3 +198,20 @@ SELECT a,(a + 0) FROM t1 ORDER BY a;
SELECT a,(a DIV 2) FROM t1 ORDER BY a;
SELECT a,CAST(a AS SIGNED) FROM t1 ORDER BY a;
DROP TABLE t1;
+
+#
+# Bug #24657: debug assertation fails (string store)
+#
+CREATE FUNCTION f1() RETURNS DOUBLE RETURN 0.12345678901234567890;
+CREATE FUNCTION f2() RETURNS DOUBLE RETURN -0.12345678901234567890;
+CREATE FUNCTION f3() RETURNS DOUBLE RETURN 1.12345678901234567890;
+CREATE TABLE t1( a VARCHAR(19) );
+INSERT INTO t1 VALUES ('A');
+INSERT INTO t1 SELECT f1() FROM t1;
+INSERT INTO t1 SELECT f1() FROM t1 LIMIT 1;
+INSERT INTO t1 SELECT f2() FROM t1 LIMIT 1;
+INSERT INTO t1 SELECT f2() FROM t1 LIMIT 1;
+INSERT INTO t1 SELECT f3() FROM t1 LIMIT 1;
+INSERT INTO t1 SELECT f3() FROM t1 LIMIT 1;
+DROP FUNCTION f1;
+DROP TABLE t1;
diff -Nrup a/sql/field.cc b/sql/field.cc
--- a/sql/field.cc 2007-09-29 01:27:18 +02:00
+++ b/sql/field.cc 2007-12-19 11:45:44 +01:00
@@ -5936,14 +5936,16 @@ int Field_str::store(double nr)
local_char_length),
nr));
/*
- +1 below is because "precision" in %g above means the
+ extra below is because "precision" in %g above means the
max. number of significant digits, not the output width.
- Thus the width can be larger than number of significant digits by 1
- (for decimal point)
+ Thus the width can be larger than number of significant digits by
+ - 1 for decimal point and
+ - 1 for leading 0 if nr < 1
the test for local_char_length < 5 is for extreme cases,
like inserting 500.0 in char(1)
*/
- DBUG_ASSERT(local_char_length < 5 || length <= local_char_length+1);
+ uint extra= nr < 1 ? 2 : 1;
+ DBUG_ASSERT(local_char_length < 5 || length <= local_char_length + extra);
return store((const char *) buff, length, charset());
}
| Thread |
|---|
| • bk commit into 5.0 tree (mhansson:1.2546) BUG#24657 | mhansson | 19 Dec |