Details
-
Bug
-
Status: Open (View Workflow)
-
Minor
-
Resolution: Unresolved
-
5.3.12, 5.5.37, 10.0.11
-
None
-
None
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.
Attachments
Issue Links
- is part of
-
MDEV-10138 Support for decimals up to 38 digits
-
- Closed
-
Activity
Field | Original Value | New Value |
---|---|---|
Summary | Controverial comparison behaviour of decimal literals with scale >30 | Controversial comparison behaviour of decimal literals with scale >30 |
Description |
Two decimal literals: 0.1111111111222222222233333333334444444444 and 0.111111111122222222223333333333 are considered as non-equal by "=", but considered as equal for UNION DISTINCT: {noformat} 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) {noformat} 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 create 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. |
Two decimal literals: 0.1111111111222222222233333333334444444444 and 0.111111111122222222223333333333 are considered as non-equal by "=", but considered as equal for UNION DISTINCT: {noformat} 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) {noformat} 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. |
Fix Version/s | 10.0.13 [ 16000 ] | |
Fix Version/s | 5.5.39 [ 15800 ] |
Workflow | defaullt [ 42100 ] | MariaDB v2 [ 44335 ] |
Fix Version/s | 5.5 [ 15800 ] |
Assignee | Alexander Barkov [ bar ] | Sergei Golubchik [ serg ] |
Assignee | Sergei Golubchik [ serg ] | Alexander Barkov [ bar ] |
Fix Version/s | 10.1 [ 16100 ] | |
Fix Version/s | 10.0 [ 16000 ] |
Priority | Major [ 3 ] | Minor [ 4 ] |
Workflow | MariaDB v2 [ 44335 ] | MariaDB v3 [ 66878 ] |
Link |
This issue is part of |
Workflow | MariaDB v3 [ 66878 ] | MariaDB v4 [ 139657 ] |