Details
-
Bug
-
Status: Open (View Workflow)
-
Major
-
Resolution: Unresolved
-
11.4, 11.8, 12.3
-
None
Description
CREATE TABLE t ( |
id INT AUTO_INCREMENT PRIMARY KEY, |
ts DATETIME NOT NULL, |
INDEX idx_ts (ts) |
);
|
|
|
INSERT INTO t (ts) VALUES |
('2024-01-15 10:00:00'), |
('2024-06-30 12:34:56'), |
('2024-12-31 23:59:59'); |
|
|
# Control: should return 3 |
SELECT COUNT(*) AS count_year_2024 FROM t WHERE YEAR(ts) = 2024; |
|
|
# Bug trigger: 4294969320 = 2024 + 2^32; YEAR() can never return this |
# value, so 0 rows is correct. Due to the truncation bug, the optimizer |
# rewrites this to a range scan and returns 3 rows. |
SELECT COUNT(*) AS count_year_overflow FROM t WHERE YEAR(ts) = 4294969320; |
10.11 returns 0
11.4+ returns 3
Reported by: Yuelin Wang
Attachments
Issue Links
- is caused by
-
MDEV-8320 Allow index usage for DATE(datetime_column) = const
-
- Closed
-
- relates to
-
MDEV-40255 Wrong result with UNION through VIEW/CTE and outer YEAR() predicate
-
- Confirmed
-