#At file:///home/gluh/MySQL/mysql-5.1/ based on revid:sergey.glukhov@stripped
3675 Sergey Glukhov 2011-04-29
Bug#12392636 ASSERTION FAILED: SCALE >= 0 && PRECISION > 0 && SCALE <= PRECISION
Assertion fires due to missing NULL value check in
Item_func_round::fix_length_and_dec() function.
The fix: added NULL value check for second parameter.
@ mysql-test/r/func_math.result
test case
@ mysql-test/t/func_math.test
test case
@ sql/item_func.cc
added NULL value check for second parameter.
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-04-20 07:39:20 +0000
+++ b/mysql-test/r/func_math.result 2011-04-29 07:18:09 +0000
@@ -540,4 +540,10 @@ ROUND(LEAST(15, -4939092, 0.2704), STDDE
-4939092.0000
Warnings:
Warning 1292 Truncated incorrect DOUBLE value: 'a'
+#
+# Bug#12392636 ASSERTION FAILED: SCALE >= 0 && PRECISION > 0 && SCALE <= PRECISION
+#
+SELECT SUM(DISTINCT (TRUNCATE((.1), NULL)));
+SUM(DISTINCT (TRUNCATE((.1), NULL)))
+NULL
End of 5.1 tests
=== modified file 'mysql-test/t/func_math.test'
--- a/mysql-test/t/func_math.test 2011-04-20 07:39:20 +0000
+++ b/mysql-test/t/func_math.test 2011-04-29 07:18:09 +0000
@@ -349,4 +349,10 @@ DROP TABLE t1;
SELECT ROUND(LEAST(15, -4939092, 0.2704), STDDEV('a'));
+--echo #
+--echo # Bug#12392636 ASSERTION FAILED: SCALE >= 0 && PRECISION > 0 && SCALE <= PRECISION
+--echo #
+
+SELECT SUM(DISTINCT (TRUNCATE((.1), NULL)));
+
--echo End of 5.1 tests
=== modified file 'sql/item_func.cc'
--- a/sql/item_func.cc 2011-04-20 07:39:20 +0000
+++ b/sql/item_func.cc 2011-04-29 07:18:09 +0000
@@ -1973,6 +1973,12 @@ void Item_func_round::fix_length_and_dec
}
val1= args[1]->val_int();
+ if (args[1]->is_null())
+ {
+ null_value= TRUE;
+ return;
+ }
+
val1_unsigned= args[1]->unsigned_flag;
if (val1 < 0)
decimals_to_set= val1_unsigned ? INT_MAX : 0;
Attachment: [text/bzr-bundle] bzr/sergey.glukhov@oracle.com-20110429071809-2s0i8m9edb4yv5hs.bundle
| Thread |
|---|
| • bzr commit into mysql-5.1 branch (sergey.glukhov:3675) Bug#12392636 | Sergey Glukhov | 29 Apr |