diff options
author | Sergey Glukhov <sergey.glukhov@oracle.com> | 2010-12-24 14:05:04 +0300 |
---|---|---|
committer | Sergey Glukhov <sergey.glukhov@oracle.com> | 2010-12-24 14:05:04 +0300 |
commit | bc56dcea9d7047c5561cee08ec2d74077e329f7d (patch) | |
tree | 14518ed65ff8a2be4328cc00d5eb9d6d347e8c37 /sql | |
parent | 8bb96394865ded184fce6b9ba501bed2f7fb9ab5 (diff) | |
download | mariadb-git-bc56dcea9d7047c5561cee08ec2d74077e329f7d.tar.gz |
Bug#57810 case/when/then : Assertion failed: length || !scale
ASSERT happens due to improper calculation of the max_length
in Item_func_div object, if dividend has max_length == 0 then
Item_func_div::max_length is set to 0 under some circumstances.
The fix:
If decimals == NOT_FIXED_DEC then set
Item_func_div::max_length to max possible
DOUBLE length value.
mysql-test/r/func_math.result:
test case
mysql-test/t/func_math.test:
test case
sql/item_func.cc:
The fix:
If decimals == NOT_FIXED_DEC then set
Item_func_div::max_length to max possible
DOUBLE length value.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item_func.cc | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc index 2ba4415dbac..55b81c8c823 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -1329,9 +1329,14 @@ void Item_func_div::fix_length_and_dec() { decimals=max(args[0]->decimals,args[1]->decimals)+prec_increment; set_if_smaller(decimals, NOT_FIXED_DEC); - max_length=args[0]->max_length - args[0]->decimals + decimals; uint tmp=float_length(decimals); - set_if_smaller(max_length,tmp); + if (decimals == NOT_FIXED_DEC) + max_length= tmp; + else + { + max_length=args[0]->max_length - args[0]->decimals + decimals; + set_if_smaller(max_length,tmp); + } break; } case INT_RESULT: |