Details
-
Bug
-
Status: Open (View Workflow)
-
Major
-
Resolution: Unresolved
-
11.4.0, 10.4(EOL), 10.5, 10.6, 10.11, 11.0(EOL), 11.1(EOL), 11.2(EOL), 11.3(EOL)
-
None
-
Windows 11 CLI
Description
Description
In theory, sql1 and sql2 should return the same result, however,sql1 return -2025 while sql2 return -20240103
SQL1:
SELECT f1 FROM (SELECT (t0.c0 - ADDDATE('2024-01-01', 1)) AS f1 FROM t0) as t WHERE f1; |
SQL2:
SELECT f1 FROM (SELECT (t0.c0 - ADDDATE('2024-01-01', 1)) AS f1, (t0.c0 - ADDDATE('2024-01-01', 1)) IS TRUE AS flag FROM t0) as t WHERE flag=1; |
How to repeat
DROP DATABASE IF EXISTS database0; |
CREATE DATABASE database0; |
USE database0; |
CREATE TABLE t0(c0 DECIMAL NULL, c1 DECIMAL) ; |
INSERT IGNORE INTO t0(c0, c1) VALUES('-1', 1); |
version |
|
SELECT version();
|
|
+----------------+
|
| version() |
|
+----------------+
|
| 11.4.0-MariaDB |
|
+----------------+
|
1 row in set (0.00 sec)
|
SELECT f1 FROM (SELECT (t0.c0 - ADDDATE('2024-01-01', 1)) AS f1 FROM t0) as t WHERE f1; --sql1 |
|
+-------+ |
| f1 |
|
+-------+ |
| -2025 |
|
+-------+ |
SELECT f1 FROM (SELECT (t0.c0 - ADDDATE('2024-01-01', 1)) AS f1, (t0.c0 - ADDDATE('2024-01-01', 1)) IS TRUE AS flag FROM t0) as t WHERE flag=1; --sql2 |
|
+-----------+ |
| f1 |
|
+-----------+ |
| -20240103 |
|
+-----------+ |