Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Not a Bug
-
5.5.33a, 5.3.13, 5.5(EOL), 10.0(EOL)
-
None
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)
|
Attachments
Issue Links
- is duplicated by
-
MDEV-22362 Number of digits wrong for round if round is within an if or case construct
-
- Closed
-
The problem was introduced in 5.3 tree (and further in 5.5.33 and 10.0.5) with the following revision:
revno: 3689
revision-id: bar@mnogosearch.org-20130909113225-k56ivrazr3wq1up4
parent: igor@askmonty.org-20130906165532-5v2ybq2t8f0o9pke
committer: Alexander Barkov <bar@mnogosearch.org>
branch nick: maria-5.3.b4863
timestamp: Mon 2013-09-09 15:32:25 +0400
message:
MDEV-4863 COALESCE(time_or_datetime) returns wrong results in numeric context