Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Duplicate
-
12.3.2
-
None
-
Not for Release Notes
Description
Description
MariaDB Server 12.3.2 returns different binary strings for an unchanged correlated STDDEV expression when DISTINCT is added to the left operand of UNION ALL. The right operand is empty but contributes a BIT column to result type inference. DISTINCT changes the output from `0.9809292541051465` to `0.980929`.
The left operand contains distinct id values, so no rows are duplicates. Adding DISTINCT should preserve every projected value. This is a server-side result/formatting inconsistency, rather than a client numeric-tolerance failure.
How to repeat
CREATE TEMPORARY TABLE precision_float (x FLOAT(8,2)); |
INSERT INTO precision_float VALUES (1.1),(2.2),(3.5); |
CREATE TEMPORARY TABLE precision_bit (k BIT(8)); |
INSERT INTO precision_bit VALUES (b'01001101'); |
|
|
SELECT DISTINCT o.id,
|
(SELECT STDDEV(x) FROM precision_float WHERE o.id > 0) AS s |
FROM (SELECT 1 AS id UNION ALL SELECT 2) AS o |
UNION ALL SELECT 3,k FROM precision_bit WHERE FALSE; |
|
|
SELECT o.id,
|
(SELECT STDDEV(x) FROM precision_float WHERE o.id > 0) AS s |
FROM (SELECT 1 AS id UNION ALL SELECT 2) AS o |
UNION ALL SELECT 3,k FROM precision_bit WHERE FALSE; |
|
Expected result
Both statements return the same two rows, including identical binary strings in `s`. The id values are unique and the UNION right operand is empty. DISTINCT can remove duplicate rows; it should not change the values in retained rows or the precision of their conversion to strings.
Actual result
| Statement | Rows `(id, s)` |
|
| --- | --- |
|
| With DISTINCT | `(1, b'0.980929')`, `(2, b'0.980929')` | |
| Without DISTINCT | `(1, b'0.9809292541051465')`, `(2, b'0.9809292541051465')` | |
|
Attachments
Issue Links
- duplicates
-
MDEV-40569 Redundant DISTINCT in a UNION branch changes the returned floating-point value
-
- Open
-