Repository navigation
Description
Description
With zero-date SQL modes disabled, MatrixOne returns NULL from STR_TO_DATE() for MySQL incomplete-date values. MySQL preserves the zero month/day components. This also changes values from date-part functions and formatting applied to the parsed result.
Environment
- MatrixOne local service:
8.0.30-MatrixOne-v1.3.0 - MySQL reference:
8.0.45 - Verification: 3 repeated runs on each engine
- Session SQL mode: explicitly set per case
Reproduction
SET SESSION sql_mode = '';
SELECT STR_TO_DATE('2024-00-00', '%Y-%m-%d');
SELECT STR_TO_DATE('2024-00-01', '%Y-%m-%d');
SELECT STR_TO_DATE('2024-01-00', '%Y-%m-%d');
SELECT STR_TO_DATE('0000-00-00', '%Y-%m-%d');
SELECT
YEAR(STR_TO_DATE('2024-00-00', '%Y-%m-%d')),
MONTH(STR_TO_DATE('2024-00-00', '%Y-%m-%d')),
DAYOFMONTH(STR_TO_DATE('2024-00-00', '%Y-%m-%d')),
DATE_FORMAT(STR_TO_DATE('2024-00-00', '%Y-%m-%d'), '%Y-%m-%d');
SELECT STR_TO_DATE('2024-02-29', '%Y-%m-%d'); -- valid controlObserved behavior
| Input / expression | MySQL 8.0.45 | MatrixOne |
|---|---|---|
2024-00-00 |
2024-00-00 |
NULL |
2024-00-01 |
2024-00-01 |
NULL |
2024-01-00 |
2024-01-00 |
NULL |
0000-00-00 |
0000-00-00 |
NULL |
YEAR/MONTH/DAYOFMONTH/DATE_FORMAT of 2024-00-00 |
2024 / 0 / 0 / 2024-00-00 |
NULL / NULL / NULL / NULL |
Valid 2024-02-29 control |
2024-02-29 |
2024-02-29 |
MySQL emits no warnings for these incomplete dates with sql_mode=''. The result difference reproduced identically in 3/3 runs per engine.
The mode distinction also differs: with sql_mode='NO_ZERO_IN_DATE', MySQL rejects 2024-00-00 with warning 1411 but still returns 0000-00-00; MatrixOne returns NULL for both. Warning parity is separately tracked by #30213.
Expected behavior
Match MySQL's incomplete-date parsing in STR_TO_DATE() when the active SQL mode permits zero date parts, and honor the distinction between NO_ZERO_IN_DATE and NO_ZERO_DATE.
MySQL documentation states that zero dates or zero date parts are permitted by STR_TO_DATE() unless the relevant SQL mode disallows them: https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_str-to-date
Related issues checked
- [Bug]: date/time functions error on zero or invalid date strings instead of MySQL NULL/0 semantics #25306 is closed and covered other temporal functions; it does not cover
STR_TO_DATE()return values for incomplete dates. - [Compatibility]: STR_TO_DATE omits MySQL warnings for invalid or truncated input #30213 tracks missing MySQL warnings from
STR_TO_DATE(), not this returned-value mismatch. - [Compatibility]: ALLOW_INVALID_DATES is accepted but DATE and DATETIME remain strictly validated #28602 tracks
ALLOW_INVALID_DATESand calendar-invalid dates such as February 30, not zero month/day acceptance. - [Compatibility] Common MySQL zero DATETIME literals block application schema loading #29207 tracks zero-DATETIME schema/data loading, not this scalar function result.
Activity
Ariznawlll commentedon Oct 14, 2026
补充同一差异在表列和 SQL PREPARE 路径的观察(MatrixOne 服务源码 commit
2ce4e58af6f03b943ee288ffad81012766cf830a,MySQL 8.0.45;每条路径各重复 3 轮):2024-00-00和有效控制2024-02-29;MO 对前者返回NULL,有效控制相同。2024-00-00;MO 返回NULL。因此该结果差异不仅出现在字面量表达式,也稳定存在于行输入和 SQL PREPARE 参数路径。