Bug #49089 Make rounding in expressions more precise
Submitted: 25 Nov 2009 8:18
Reporter: Georgi Kodinov Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Data Types Severity:S4 (Feature request)
Version:5.0+ OS:Any
Assigned to: CPU Architecture:Any

[25 Nov 2009 8:18] Georgi Kodinov
Description:
This is a spin-off from bug #45261.

The server uses arbitrary precision when doing expression calculation. But it needs to truncate when storing expressions into columns. However the truncation is done in several places sometimes using the length/precision of the data in the Item instead of the declared length/precision of the item itself. This affects how conversion from an expression to a column is handled (both in temporary tables and in CREATE .. SELECT).
There's also discrepancy between the declared length in Item and the actual length/precision of the numeric constants.

How to repeat:
For test case and examples see #45261.

Suggested fix:
Clean up all the truncations and do them in a single place (when converting to column). Make sure the truncation in expressions follows the rules described in our docs.