Details
Description
In MariaDB, it seems that the 3rd argument of the IF() function is consulted to determine how a DECIMAL result is zero-padded when sent back to the client. The behavior is different in MySQL. For example:
In MySQL:
mysql 5.6.21-log (root) [test]> SELECT IF (1=1, ROUND(0.123451, 3), ROUND(0.123451, 5)) as result; -------------- SELECT IF (1=1, ROUND(0.123451, 3), ROUND(0.123451, 5)) as result -------------- Field 1: `result` Catalog: `def` Database: `` Table: `` Org_table: `` Type: NEWDECIMAL Collation: binary (63) Length: 9 Max_length: 5 Decimals: 5 Flags: NOT_NULL BINARY NUM +--------+ | result | +--------+ | 0.123 | +--------+ 1 row in set (0.00 sec)
And in MariaDB:
mysql 10.0.13-MariaDB-log (root) [test]> SELECT IF (1=1, ROUND(0.123451, 3), ROUND(0.123451, 5)) as result; -------------- SELECT IF (1=1, ROUND(0.123451, 3), ROUND(0.123451, 5)) as result -------------- Field 1: `result` Catalog: `def` Database: `` Table: `` Org_table: `` Type: NEWDECIMAL Collation: binary (63) Length: 9 Max_length: 7 Decimals: 5 Flags: NOT_NULL BINARY NUM +---------+ | result | +---------+ | 0.12300 | +---------+ 1 row in set (0.00 sec)
Gliffy Diagrams
Attachments
Activity
- All
- Comments
- Work Log
- History
- Activity
- Transitions
The problem was introduced in 5.3 tree (and further in 5.5.33 and 10.0.5) with the following revision: