Bug #6813 Stored procedures calculation loses post-decimal digits
Submitted: 24 Nov 2004 19:40 Modified: 13 Jul 2005 11:25
Reporter: Peter Gulutzan Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.2-alpha-debug OS:Linux (SuSE 8.2)
Assigned to: Alexey Botchkov CPU Architecture:Any

[24 Nov 2004 19:40] Peter Gulutzan
Description:
With DECIMAL(5,2) variables I should see two post-decimal digits. 
Usually this works, for example SET decimal_variable = xxx.xx loses no digits. 
However, SET decimal_variable = decimal_variable + decimal_variable loses digits. 
That is: after an arithmetic operation, the last two digits are, incorrectly, ".00". 
 

How to repeat:
mysql> create procedure p80 () begin declare v1,v2 decimal(5,2) default 0.00; set v1 = 
111.01; set v2 = v2 + v1; select v1,v2; end;// 
Query OK, 0 rows affected (0.00 sec) 
 
mysql> call p80()// 
+--------+-----+ 
| v1     | v2  | 
+--------+-----+ 
| 111.01 | 111 | 
+--------+-----+ 
1 row in set (0.00 sec) 
 
Query OK, 0 rows affected (0.00 sec)
[13 Jul 2005 11:25] Alexey Botchkov
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html

Additional info:

Fixed with the previous patch