Bug #3612 impicite rounding of VARCHARS during aritchmetic operations in SELECT
Submitted: 30 Apr 2004 17:34 Modified: 11 May 2004 14:32
Reporter: Evgenij Golkov
Status: Closed
Category:Server Severity:S2 (Serious)
Version:3.23.47 OS:Microsoft Windows (Win2K SP2)
Assigned to: Sergei Golubchik Target Version:

[30 Apr 2004 17:34] Evgenij Golkov
Description:
Results of arithmetical operations in SELECT statements were be impicitly rounded to one
decimal place if VARCHARS used for those operations. It is a really serious problem
because of wrong results, and the VARCHARS were be often used for storing values using
database systems. 

How to repeat:
It easy to repeat the problem if you use this statement:

CREATE my_table1
SELECT
value1 + value1 * (value2 / 100) AS newvalue 
FROM my_table2

If the my_table1.value1 = 121 and my_table1.value2 = 16 (just an example), you will get
correct result for my_table2.newvalue (=140.36).

But, if you use a VARCHAR for my_table1.value2 ('16' instead of 16), you will get 140.4!
[11 May 2004 14:32] Sergei Golubchik
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 in 4.0.x