Bug #79505 "if(1,1,1.234)" return 1 while the "Decimals" is 3

Submitted: 3 Dec 2015 10:57 Modified: 3 Dec 2015 12:07
Reporter: Su Dylan Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: DML Severity:S3 (Non-critical)
Version:5.7.8, 5.5.48, 5.6.29, 5.7.9 OS:Any
Assigned to: CPU Architecture:Any

[3 Dec 2015 10:57] Su Dylan
Description:
Output:
=======
mysql> select if(1,1,1.234);
Field   1:  `if(1,1,1.234)`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       NEWDECIMAL
Collation:  binary (63)
Length:     6
Max_length: 1
Decimals:   3
Flags:      NOT_NULL BINARY

+---------------+
| if(1,1,1.234) |
+---------------+
|             1 |
+---------------+
1 row in set (0.00 sec)

Problem:
========
The displayed "Decimals" is 3, while the result gives "1", with no decimal appended.

How to repeat:
select if(1,1,1.234);

Suggested fix:
"if(1,1,1.234)" is expected to return 1.000.
[3 Dec 2015 12:01] Peter Laursen
MySQL 5.6 also returns  "1" whilst MariaDB 10.1 returns "1.000".

-- Peter
-- not a MySQL/Oracle or MariaDB person
[3 Dec 2015 12:07] MySQL Verification Team
Hello Su Dylan,

Thank you for the report.

Thanks,
Umesh

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.050 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.