Details
- 
    Bug 
- 
    Status: Closed (View Workflow)
- 
    Major 
- 
    Resolution: Fixed
- 
    5.6.1, 6.1.1
- 
    None
Description
The code in TreeNode::getIntVal() performs DECIMAL-to-INT conversion using pow(), so the calculation is done in double format. This leads to precision loss and therefore to MariaDB incompatible results.
| DROP TABLE IF EXISTS t1; | 
| CREATE TABLE t1 (a DECIMAL(18,0)) ENGINE=ColumnStore; | 
| INSERT INTO t1 VALUES (9999999999999999); | 
| INSERT INTO t1 VALUES (99999999999999998); | 
| INSERT INTO t1 VALUES (999999999999999997); | 
| SELECT RAND(a) FROM t1; | 
| +-----------------------+ | 
| | RAND(a)               | | 
| +-----------------------+ | 
| |   0.13983957482486925 | | 
| | 0.0014118393896257872 | | 
| |    0.6171344999383525 | | 
| +-----------------------+
 | 
The above result is wrong. The expected result is:
| DROP TABLE IF EXISTS t1; | 
| CREATE TABLE t1 (a DECIMAL(18,0)) ENGINE=InnoDB; | 
| INSERT INTO t1 VALUES (9999999999999999); | 
| INSERT INTO t1 VALUES (99999999999999998); | 
| INSERT INTO t1 VALUES (999999999999999997); | 
| SELECT RAND(a) FROM t1; | 
| +--------------------+ | 
| | RAND(a)            | | 
| +--------------------+ | 
| | 0.8896564653978277 | | 
| | 0.5010456205355428 | | 
| |  0.866585171657228 | | 
| +--------------------+
 | 
Attachments
Issue Links
- blocks
- 
                    MCOL-4361 Replace pow(10.0, (double)scale) expressions with a static dictionary lookup. -         
- Closed
 
-         
- relates to
- 
                    MCOL-4609 TreeNode::getIntVal() does not round: implicit DECIMAL->INT cast is not MariaDB compatible -         
- Closed
 
-         
- 
                    MCOL-4610 TreeNode::getUintVal() looses precision for narrow decimal -         
- Closed
 
-         
- 
                    MCOL-4619 TreeNode::getUintVal() does not round: Implicit DECIMAL->UINT conversion is not like in InnoDB -         
- Closed
 
-