[MDEV-6304] Controversial comparison behaviour of decimal literals with scale >30 Created: 2014-06-04  Updated: 2016-05-27

Status: Open
Project: MariaDB Server
Component/s: None
Affects Version/s: 5.3.12, 5.5.37, 10.0.11
Fix Version/s: 10.1

Type: Bug Priority: Minor
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Unresolved Votes: 1
Labels: None

Issue Links:
PartOf
is part of MDEV-10138 Support for decimals up to 38 digits Closed

 Description   

Two decimal literals:
0.1111111111222222222233333333334444444444
and
0.111111111122222222223333333333
are considered as non-equal by "=",
but considered as equal for UNION DISTINCT:

MariaDB [test]> SELECT 0.1111111111222222222233333333334444444444 = 0.111111111122222222223333333333 AS cmp;
+-----+
| cmp |
+-----+
|   0 |
+-----+
1 row in set (0.00 sec)
 
MariaDB [test]> SELECT 0.1111111111222222222233333333334444444444 AS a UNION SELECT 0.111111111122222222223333333333;
+----------------------------------+
| a                                |
+----------------------------------+
| 0.111111111122222222223333333333 |
+----------------------------------+
1 row in set (0.01 sec)

Comparison in "=" and comparison in UNION DISTINCT should use the same rules.

The problem most likely happens because we don't support fields with decimal
scale > 30. UNION uses a temporary table and creates a field,
while '=' does not need a field and compares the two numbers directly.

Literals should probably be fixed not to support more than 30 fractional as well.


Generated at Thu Feb 08 07:10:52 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.