Repository navigation
Description
Summary
STR_TO_DATE rejects a parameter marker in its format-string position during prepared-statement creation. The input value may be parameterized, and the related DATE_FORMAT/TIME_FORMAT functions accept parameterized format strings, so applications cannot reuse a STR_TO_DATE plan when its parsing format is runtime data.
Environment
- MatrixOne official
main:99ed717b769e261b842c2f17345bd65865fc1470 - Clean local single-CN build and isolated data directory
- Reproduced identically in 3/3 runs through both server-side text PREPARE and the MySQL binary prepared-statement protocol
Reproduction
SELECT STR_TO_DATE('2024-01-02 01:02:03.654321', '%Y-%m-%d %H:%i:%s.%f');
-- 2024-01-02 01:02:03.654321
PREPARE p_value FROM
'SELECT STR_TO_DATE(?, ''%Y-%m-%d %H:%i:%s.%f'')';
SET @value = '2024-01-02 01:02:03.654321';
EXECUTE p_value USING @value;
-- 2024-01-02 01:02:03.654321
PREPARE p_format FROM
'SELECT STR_TO_DATE(''2024-01-02 01:02:03.654321'', ?)';Actual result for p_format:
ERROR 20203 (HY000): invalid argument str_to_date function have invalid input args length, bad value 2
Parameterizing both positions fails for the same reason.
Scope control
PREPARE date_format FROM
'SELECT DATE_FORMAT(''2024-01-02 01:02:03.654321'', ?)';
SET @fmt = '%Y-%m-%d %H:%i:%s.%f';
EXECUTE date_format USING @fmt;
-- 2024-01-02 01:02:03.654321
PREPARE time_format FROM
'SELECT TIME_FORMAT(''01:02:03.654321'', ?)';
EXECUTE time_format USING @fmt;
-- 01:02:03.654321Expected behavior
The format string is a value expression and should be bindable in a prepared statement. STR_TO_DATE(literal, ?) and STR_TO_DATE(?, ?) should prepare and execute with each supplied format.
Preliminary code observation
The binder derives STR_TO_DATE's return type from the format and appends an internal third type marker. For an unknown format parameter it appends a DATETIME marker, but the prepared binding flow appears to validate the rewritten three-argument form as if it were the original public two-argument call. This is a diagnosis hypothesis, not a proposed fix.
Suggested regression coverage
Cover server-side and binary prepared STR_TO_DATE with parameterized value, parameterized format, and both; include date-only, datetime(6), and time-only format outputs. Keep DATE_FORMAT/TIME_FORMAT dynamic-format cases as controls.
Activity
fix: align date compatibility semantics (#28851)
XuPeng-SH commentedon Sep 27, 2026
QA handoff after merged PR #28851 (merge
a99db843c7b4630a86883addc9424433d93fc2d2). This issue was a non-closing related report; the merge and shared BVT counts are not an independent PASS for this reproducer.Latest MatrixOne contract: C23, C36–C38 in the merged temporal design. STR_TO_DATE accepts a runtime format marker. A dynamic format binds DATETIME(6); a static format binds DATE/TIME/DATETIME from its directives. A time-only dynamic row without a calendar is NULL.
Please rerun the original reproducer on
mainat or after the merge and record the exact SHA, deployment, SQL mode/time zone, client path, observed rows/types/NULLs and active warnings or errors. Use a real server-side prepared handle across changing format values and NULL/invalid inputs; check field metadata, NULL bitmap and reuse.Keep the issue open until the issue-specific acceptance is demonstrated with happy and unhappy controls. If any part still fails, post the exact observed-versus-expected result and return it to development; if it passes, record evidence and close the issue. @Ariznawlll
Ariznawlll commentedon Oct 2, 2026
测试版本
maind50a2d475a406829f67127fef7b2ad4abc1c1d3dmo-service,独立数据目录;MySQL 文本协议与 server-side PREPARE原问题验证
按 issue 原始语义在上述 commit 重新执行并重复 3 次。STR_TO_DATE 的 value 与 format 均可由 prepared marker 提供,重复绑定返回正确 DATE/DATETIME。
Happy Path 覆盖
覆盖静态/动态 format、DATE 与 DATETIME 指令组合及多次重绑。
Unhappy Path 覆盖
覆盖不匹配格式、time-only 动态行与 NULL 参数;返回受控 NULL,不污染后续执行。
白盒验证
关联修复 #28851、#29365 已进入当前
main。同时将本 issue 的可公开观察契约固化为独立回归,避免只依赖实现细节或共享测试间接判断。回归测试
suites/14_issue_regression/t/issue_recent_temporal_contracts.test714/714条语句通过。测试证据
d50a2d475a406829f67127fef7b2ad4abc1c1d3d14_issue_regression中观察到的旧 GOROOT/历史 golden/并发锁冲突属于既有无关失败,以上新增用例单独重跑均稳定通过。测试结论
测试通过。