Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
12.3.2
-
None
-
Windows 11 Home 64-bit
Database Server: MariaDB 12.3.2-MariaDB
Server Comment: MariaDB Server
-
Not for Release Notes
-
XOR could incorrectly treat non-integer string operands as FALSE, causing rows to be omitted from WHERE results.
Description
-
-
- Summary
-
MariaDB evaluates the non-integer string `'0.7'` as TRUE in IS TRUE, AND, and OR expressions, but evaluates it as FALSE when it is used as the left operand of XOR.
This can cause rows to be incorrectly filtered out by a WHERE clause.
-
-
- Steps to reproduce
-
Run the following query:
```sql
SELECT
'0.7' IS TRUE AS is_true,
'0.7' AND TRUE AS and_true,
'0.7' OR FALSE AS or_false,
'0.7' XOR FALSE AS xor_false,
'0.7' XOR TRUE AS xor_true;
-
-
- Expected result
According to the logical XOR semantics, a non-zero operand is TRUE.
Therefore:
'0.7' IS TRUE -> 1
'0.7' AND TRUE -> 1
'0.7' OR FALSE -> 1
'0.7' XOR FALSE -> 1
'0.7' XOR TRUE -> 0
The filtering query should return one row:
-------value -------
0.7 -------
- Expected result
-
-
-
- Actual result on MariaDB 12.3.2
-------------------------------------------is_true and_true or_false xor_false xor_true --------
-----------------------------------1 1 1 0 1 --------
-----------------------------------
The filtering query returns:Empty set
Thus, MariaDB treats '0.7' as TRUE for IS TRUE, AND, and OR, but as FALSE for XOR.
- Actual result on MariaDB 12.3.2
-
MySQL 8.0.46 and MySQL 8.4.7 return:
-------------------------------------------
| is_true | and_true | or_false | xor_false | xor_true |
-------------------------------------------
| 1 | 1 | 1 | 1 | 0 |
-------------------------------------------
The filtering query also returns one row on both MySQL versions.
Attachments
Issue Links
- duplicates
-
MDEV-39363 Logical Bug in `NOT ( ... XOR ... )` Evaluation with Implicit Type Conversion
-
- Closed
-