summaryrefslogtreecommitdiff
path: root/sql/item_cmpfunc.cc
diff options
context:
space:
mode:
authorevgen@moonbone.local <>2006-02-14 16:22:37 +0300
committerevgen@moonbone.local <>2006-02-14 16:22:37 +0300
commit8f904e9cabdaa3f1941ecafc16c375e975f299a4 (patch)
treee6ac903dd104e65ccb3459c20d17158e9a4b8ca9 /sql/item_cmpfunc.cc
parentf9a23667b2037caeb4da7cd2672d53bcce496e1e (diff)
downloadmariadb-git-8f904e9cabdaa3f1941ecafc16c375e975f299a4.tar.gz
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.
Diffstat (limited to 'sql/item_cmpfunc.cc')
-rw-r--r--sql/item_cmpfunc.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index bb3f6e8b231..d812ce913c5 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -1383,7 +1383,8 @@ Item_func_if::fix_length_and_dec()
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);
}