Repository navigation
Description
Description
STR_TO_DATE() returns NULL for multiple format directives that MySQL 8.0 accepts and converts to a date. The affected set includes ordinal day, day-of-year, weekday names, and week/year directives.
Environment
- Branch:
main - Commit:
95b1d2bfd9d756d08320569858080cb16f230fff - Deployment: local standalone MatrixOne
- Reference: MySQL 8.0.45
- Date: 2026-09-24
Steps to reproduce
SET sql_mode='';
SELECT STR_TO_DATE('29th February 2024','%D %M %Y');
SELECT STR_TO_DATE('2024 060','%Y %j');
SELECT STR_TO_DATE('2024-02-29 Thursday','%Y-%m-%d %W');
SELECT STR_TO_DATE('2024-02-29 Thu','%Y-%m-%d %a');
SELECT STR_TO_DATE('2024-09-1','%x-%v-%w');
SELECT STR_TO_DATE('2024-09-1','%X-%V-%w');
SELECT STR_TO_DATE('2024-09-1','%Y-%u-%w');
SELECT STR_TO_DATE('2024-09-1','%Y-%U-%w');Actual behavior
MatrixOne returns NULL for all eight expressions.
The complete directive matrix shows the same gap for:
%D: day of month with English suffix;%j: day of year;%a/%W: abbreviated/full weekday name;%U/%u/%V/%v: week number modes;%w: weekday number when used to construct a week date;%X/%x: week-based year.
Expected behavior
Match MySQL 8.0.45:
29th February 2024 / %D %M %Y -> 2024-02-29
2024 060 / %Y %j -> 2024-02-29
2024-02-29 Thursday / ...%W -> 2024-02-29
2024-02-29 Thu / ...%a -> 2024-02-29
2024-09-1 / %x-%v-%w -> 2024-02-26
2024-09-1 / %X-%V-%w -> 2024-03-04
2024-09-1 / %Y-%u-%w -> 2024-02-26
2024-09-1 / %Y-%U-%w -> 2024-03-04
Stability and controls
- Reproducer: identical results in 3/3 complete runs.
- Passing controls: numeric year/month/day, abbreviated and full month names, 12/24-hour time, compound
%r/%T, microseconds, two-digit years, leading whitespace and trailing input all match MySQL. - NULL operands remain NULL and the session stays usable after every query.
- The same failures occur as literals and from table rows; they are independent of data volume.
Code analysis
pkg/sql/plan/function/generalTime.go leaves %a, %D, %U, %u, %V, %v, %W, %w, %X, and %x commented out in dateFormatParserTable. %j is tokenized and stored in the parse context, but checkMysqlTime() does not convert the parsed day-of-year into month/day fields, so the final date validation returns NULL.
Regression coverage
After implementation, add a stable SQL regression covering every directive above, leap/non-leap day-of-year boundaries, week 00/53 and invalid combinations. This is scalar compatibility coverage; big-data, stability and Chaos are not required.
Related
- [Feature Request]: 3.0-dev Unsupported datetime functions #24504 tracked the older broad datetime-function inventory but was closed after its remaining listed items were split; it does not track these
STR_TO_DATEdirective semantics. - [Compatibility]: STR_TO_DATE rejects a prepared format-string parameter #28129 tracks prepared format markers, not the literal directive behavior here.
- [Compatibility]: temporal formatting functions reject row-dependent format expressions #28566 tracks row-dependent format expressions, not missing directive parsing.
Activity
fix: parse STR_TO_DATE day and week directives (#29365)
Ariznawlll commentedon Sep 27, 2026
测试版本
main5be6cd90b501da225be591ffffe6000bf01f515e原问题验证
在上述最新 main 上按 issue 原始复现步骤执行,并独立重复 3 次;3/3 均满足修复后的预期。当前 main 已包含修复提交
bff570f0f7048c0c778bf7a6fb852f23ac9d1532。Happy Path 覆盖
Unhappy Path 覆盖
白盒验证
确认修复提交
bff570f0f7048c0c778bf7a6fb852f23ac9d1532是当前 main 的祖先,并核对对应 MatrixOne BVT/实现路径;本次另以公开 SQL 协议执行黑盒验收。回归测试
已加入 MOTR PR #204 的
issue_29323_29325_29327_29328_29329_29330_29331_sql_contracts.test,MOTR 提交2b4462f2;本地基线比对连续 3 次通过。测试证据
5be6cd90b501da225be591ffffe6000bf01f515e测试结论
测试通过。