#At file:///home/gluh/MySQL/mysql-5.1/ based on revid:sergey.glukhov@stripped
3646 Sergey Glukhov 2011-04-11
Bug#11765923 58937: MANY VALGRIND ERRORS AFTER GROUPING BY RESULT OF DECIMAL COLUMN FUNCTION
When ROUND evaluates decimal result it uses Item::decimal
value as fraction value for the result. In some cases
Item::decimal is greater than real result fraction value
and uninitialised memory of result(decimal) buffer can be
used in further calculations.
The fix is to use minimum between
decimal_value->frac and Item::decimals.
@ mysql-test/r/func_math.result
test case
@ mysql-test/t/func_math.test
test case
@ sql/item_func.cc
The fix is to use minimum between
decimal_value->frac and Item::decimals.
modified:
mysql-test/r/func_math.result
mysql-test/t/func_math.test
sql/item_func.cc
=== modified file 'mysql-test/r/func_math.result'
--- a/mysql-test/r/func_math.result 2011-03-28 08:35:50 +0000
+++ b/mysql-test/r/func_math.result 2011-04-11 09:22:44 +0000
@@ -518,4 +518,18 @@ CREATE TABLE t1 SELECT CEIL(LINESTRINGFR
DROP TABLE t1;
CREATE TABLE t1 SELECT FLOOR(LINESTRINGFROMWKB(1) DIV NULL);
DROP TABLE t1;
+#
+# Bug#11765923 58937: MANY VALGRIND ERRORS AFTER GROUPING BY RESULT OF DECIMAL COLUMN FUNCTION
+#
+CREATE TABLE t1(f1 DECIMAL(22,1));
+INSERT INTO t1 VALUES (0),(1);
+SELECT ROUND(f1, f1) FROM t1;
+ROUND(f1, f1)
+0.0
+1.0
+SELECT ROUND(f1, f1) FROM t1 GROUP BY 1;
+ROUND(f1, f1)
+0.0
+1.0
+DROP TABLE t1;
End of 5.1 tests
=== modified file 'mysql-test/t/func_math.test'
--- a/mysql-test/t/func_math.test 2011-03-28 08:35:50 +0000
+++ b/mysql-test/t/func_math.test 2011-04-11 09:22:44 +0000
@@ -333,4 +333,14 @@ DROP TABLE t1;
CREATE TABLE t1 SELECT FLOOR(LINESTRINGFROMWKB(1) DIV NULL);
DROP TABLE t1;
+--echo #
+--echo # Bug#11765923 58937: MANY VALGRIND ERRORS AFTER GROUPING BY RESULT OF DECIMAL COLUMN FUNCTION
+--echo #
+
+CREATE TABLE t1(f1 DECIMAL(22,1));
+INSERT INTO t1 VALUES (0),(1);
+SELECT ROUND(f1, f1) FROM t1;
+SELECT ROUND(f1, f1) FROM t1 GROUP BY 1;
+DROP TABLE t1;
+
--echo End of 5.1 tests
=== modified file 'sql/item_func.cc'
--- a/sql/item_func.cc 2011-03-28 13:27:44 +0000
+++ b/sql/item_func.cc 2011-04-11 09:22:44 +0000
@@ -2123,7 +2123,7 @@ my_decimal *Item_func_round::decimal_op(
my_decimal_round(E_DEC_FATAL_ERROR, value, (int) dec,
truncate, decimal_value) > 1)))
{
- decimal_value->frac= decimals;
+ decimal_value->frac= min(decimal_value->frac, decimals);
return decimal_value;
}
return 0;
Attachment: [text/bzr-bundle] bzr/sergey.glukhov@oracle.com-20110411092244-k4punz0qkq82i4ik.bundle
| Thread |
|---|
| • bzr commit into mysql-5.1 branch (sergey.glukhov:3646) Bug#11765923 | Sergey Glukhov | 11 Apr |