Details
-
Bug
-
Status: Confirmed (View Workflow)
-
Minor
-
Resolution: Unresolved
-
12.3, 13.1, 12.3.3
-
None
-
Linux x86_64
Description
When TO_DATE() evaluates a format stored in a column, a NULL format affects the following row: the next valid format returns NULL in the same scan, although it returns the correct date when queried alone.
This occurs when TO_DATE() evaluates a row-varying format expression across a valid/NULL/valid sequence.
The behavior was recorded on MariaDB 12.3.3. This equivalent reproducer demonstrates the same valid/NULL/valid sequence:
CREATE DATABASE dates_test; |
USE dates_test; |
CREATE TABLE formats (id INT PRIMARY KEY, f VARCHAR(20)); |
INSERT INTO formats VALUES (1,'YYYY-MM-DD'),(2,NULL),(3,'YYYY-MM-DD'); |
SELECT id, TO_DATE('2024-06-15',f) AS actual, IF(f IS NULL,NULL,CAST('2024-06-15' AS DATETIME)) AS expected FROM formats FORCE INDEX(PRIMARY) ORDER BY id; |
SELECT id, TO_DATE('2024-06-15',f) AS actual FROM formats WHERE id=3; |
The recorded scan returned:
id actual expected
|
1 2024-06-15 00:00:00.000000 2024-06-15 00:00:00
|
2 NULL NULL
|
3 NULL 2024-06-15 00:00:00
|
The recorded query selecting row 3 alone returned:
id actual
|
3 2024-06-15 00:00:00.000000
|
Rows 1 and 3 contain the same valid format, so both should return the parsed date. Row 2 should return NULL. The isolated query confirms that row 3's input is valid; its result should not depend on whether a preceding row supplied a NULL format.
Attachments
Issue Links
- relates to
-
MDEV-19683 Add support for Oracle TO_DATE()
-
- Closed
-