Details
-
Bug
-
Status: Open (View Workflow)
-
Major
-
Resolution: Unresolved
-
12.2.2
-
None
-
None
-
None
-
Ubuntu 24.04
Description
Summary
There appears to be a logical bug where `NOT (expr1 XOR expr2)` is not the boolean complement of `(expr1 XOR expr2)` under implicit type conversion (numeric/text values).
This violates core boolean consistency: rows can satisfy both `P` and `NOT P`, or satisfy neither, for the same predicate `P`.
Environment
- Deployment: Docker container (`mariadb:12.2.2`)
- Connection used: `mysql -h 127.0.0.1 -P 23306 -u root -proot`
- `sql_mode`:
- `STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION`
Reproducibility
- Reproduced consistently in the environment above.
- Also observed in others independent generated workloads (same bug pattern):
- `3 vs 4`
- `21 vs 0`
- `4 vs 1`
- `1 vs 0`
Minimal Reproducer (Constants)
```sql
SELECT
0.1 XOR 2 AS p,
NOT (0.1 XOR 2) AS not_p,
(0.1 XOR 2) IS NULL AS p_is_null;
```
Expected
- `p = 1`
- `not_p = 0`
- `p_is_null = 0`
Actual
- `p = 1`
- `not_p = 1`
- `p_is_null = 0`
`NOT p` is not complementing `p`.
Logical Consistency Reproducer (Row Count Mismatch)
DROP DATABASE IF EXISTS bug_logic_xor; |
CREATE DATABASE bug_logic_xor; |
USE bug_logic_xor; |
|
|
CREATE TABLE t(v DOUBLE); |
INSERT INTO t VALUES (0.1), (2), (NULL); |
|
|
-- Baseline row count
|
SELECT COUNT(*) AS baseline FROM t; |
|
|
-- Logical decomposition by P / NOT P / P IS NULL
|
SELECT COUNT(*) AS decomposed_cardinality |
FROM ( |
SELECT v FROM t WHERE (v XOR 2) |
UNION ALL |
SELECT v FROM t WHERE NOT (v XOR 2) |
UNION ALL |
SELECT v FROM t WHERE (v XOR 2) IS NULL |
) q;
|
|
|
-- Row-level evidence
|
SELECT
|
v,
|
(v XOR 2) AS p, |
NOT (v XOR 2) AS not_p, |
((v XOR 2) IS NULL) AS p_is_null |
FROM t; |
Expected
- `baseline = decomposed_cardinality = 3`
- For each non-NULL row, exactly one of `p` or `not_p` is true.
Actual
- `baseline = 3`
- `decomposed_cardinality = 4`
- Row-level output includes `p=1` and `not_p=1` for `v=0.1` (overlap).