Below is the list of changes that have just been committed into a local
5.0 repository of evgen. When evgen 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
1.2039 06/02/14 16:22:37 evgen@stripped +3 -0
Fixed bug#16272: IF function with decimal args can produce wrong result
The Item_func_if::fix_length_and_dec() function when calculating length of
result doesn't take into account unsigned_flag. But it is taken when
calculating length of temporary field. This result in creating field that
shorter than needed. Due to this, in the reported query 40.0 converted to 9.99.
The function Item_func_if::fix_length_and_dec() now adds 1 to the max_length if
the unsigned_flag isn't set.
mysql-test/t/func_if.test
1.19 06/02/14 15:24:31 evgen@stripped +8 -0
Added test case for bug#16272: IF function with decimal args can produce wrong result
mysql-test/r/func_if.result
1.21 06/02/14 15:24:07 evgen@stripped +7 -0
Added test case for bug#16272: IF function with decimal args can produce wrong result
sql/item_cmpfunc.cc
1.191 06/02/14 15:21:59 evgen@stripped +2 -1
Fixed bug#16272: IF function with decimal args can produce wrong result
The function Item_func_if::fix_length_and_dec() now adds 1 to the max_length if
the unsigned_flag isn't set.
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: evgen
# Host: moonbone.local
# Root: /work/16272-bug-5.0-mysql
--- 1.190/sql/item_cmpfunc.cc 2006-01-14 19:05:31 +03:00
+++ 1.191/sql/item_cmpfunc.cc 2006-02-14 15:21:59 +03:00
@@ -1383,7 +1383,8 @@
max_length=
(cached_result_type == DECIMAL_RESULT || cached_result_type == INT_RESULT) ?
(max(args[1]->max_length - args[1]->decimals,
- args[2]->max_length - args[2]->decimals) + decimals) :
+ args[2]->max_length - args[2]->decimals) + decimals +
+ (unsigned_flag ? 0 : 1) ) :
max(args[1]->max_length, args[2]->max_length);
}
--- 1.20/mysql-test/r/func_if.result 2005-06-14 12:35:48 +04:00
+++ 1.21/mysql-test/r/func_if.result 2006-02-14 15:24:07 +03:00
@@ -121,3 +121,10 @@
NULL NULL
NULL
DROP TABLE t1;
+create table t1 (f1 int, f2 int);
+insert into t1 values(1,1),(0,0);
+select f1, f2, if(f1, 40.0, 5.00) from t1 group by f1 order by f2;
+f1 f2 if(f1, 40.0, 5.00)
+0 0 5.00
+1 1 40.00
+drop table t1;
--- 1.18/mysql-test/t/func_if.test 2005-09-15 23:17:37 +04:00
+++ 1.19/mysql-test/t/func_if.test 2006-02-14 15:24:31 +03:00
@@ -89,3 +89,11 @@
DROP TABLE t1;
# End of 4.1 tests
+
+#
+# Bug #16272 IF function with decimal args can produce wrong result
+#
+create table t1 (f1 int, f2 int);
+insert into t1 values(1,1),(0,0);
+select f1, f2, if(f1, 40.0, 5.00) from t1 group by f1 order by f2;
+drop table t1;
| Thread |
|---|
| • bk commit into 5.0 tree (evgen:1.2039) BUG#16272 | eugene | 14 Feb |