Repository navigation
Description
Problem
With sql_mode='', MatrixOne treats malformed or trailing-content VARCHAR to TIME conversions as statement errors. MySQL 8.3 applies its non-strict conversion semantics instead: it keeps a valid time prefix when present, returns NULL/zero-time where appropriate, and emits a warning.
This is a shared conversion-path difference rather than a TIME_TO_SEC-specific problem. It affects direct casts, functions that implicitly request a time value, table scans, prepared statements, assignments, and CTAS.
Tested on MatrixOne main commit f0c31cd4b830be32442cf329e0a3fb08aa9c16c3 and MySQL 8.3.0. Each MatrixOne reproduction was repeated three times.
Minimal reproduction
SET SESSION sql_mode='';
SELECT CAST('01:02:03.456789tail' AS TIME(6));
SELECT CAST('tail' AS TIME(6));
SELECT TIME_TO_SEC('01:02:03tail');MatrixOne returns error 20301 (invalid time value ...) for all three statements.
MySQL returns:
01:02:03.456789 -- warning 1292
NULL -- warning 1292
3723 -- warning 1292
Row and persistence scenarios
CREATE TABLE src(id INT, s VARCHAR(64));
INSERT INTO src VALUES
(1, '01:02:03.456789'),
(2, '01:02:03.456789tail'),
(3, 'tail'),
(4, ''),
(5, NULL);
SELECT id, CAST(s AS TIME(6)) FROM src ORDER BY id;
CREATE TABLE copied AS
SELECT id, CAST(s AS TIME(6)) AS t FROM src;
CREATE TABLE assigned(id INT, t TIME(6));
INSERT INTO assigned VALUES (1, '01:02:03.456789tail');
INSERT INTO assigned VALUES (2, 'tail');MatrixOne aborts the mixed-row SELECT and CTAS on the first trailing value. The two non-strict INSERT statements also return error 20301 and persist no rows.
MySQL completes the SELECT/CTAS with the valid prefix preserved and malformed values converted to NULL, emitting warnings. Its assignment path stores 01:02:03.456789 for the trailing input and 00:00:00.000000 for the invalid input, with warning 1265.
The same difference is present when the input is supplied through a prepared-statement parameter.
Controls
- Valid
TIME(6)strings preserve microseconds in both systems. NULLremainsNULLin both systems.- Filtering the table to the valid row allows MatrixOne to complete the cast correctly.
- MatrixOne remains healthy after each error.
Code analysis
pkg/sql/plan/function/func_cast.go, strToTime, calls types.ParseTime. When parsing fails, only assignment-mode compact-time and out-of-range cases enter a MySQL-compatible fallback. Other malformed/trailing strings return the parse error directly; expression casts have no non-strict warning/nullification path.
The conversion layer therefore does not implement the session's non-strict semantics consistently across expression and assignment modes.
Expected behavior
When strict SQL mode is disabled, string-to-TIME conversion should use consistent non-strict coercion semantics across direct casts, implicit function conversion, prepared statements, INSERT, and CTAS, with warnings rather than aborting the statement. Strict mode can continue to reject invalid assignment values where required.
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: C32–C35, C36–C37 in the merged temporal design. Explicit TIME conversion, TIME() grammar and assignment have distinct mode policies. Permissive CAST text-prefix conversion may retain a valid prefix with warning 1292, while malformed strict conversion remains an error; assignment uses its 1264/1265 diagnostics. Released empty ordinary payload→NULL and IGNORE empty→zero+1265 are deliberate exceptions.
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. Rerun the original SELECT, mixed-row CTAS, INSERT and real prepared statements under strict/non-strict modes; assert exact rows, NULLs, metadata and warning counts. Keep open if implicit TIME_TO_SEC or any original path remains wrong.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 次。VARCHAR→TIME 的合法前缀按模式转换,非法尾部产生 warning 1292;未再丢失非严格模式诊断。
Happy Path 覆盖
覆盖完整 TIME、合法文本前缀、显式 CAST 与 TIME()。
Unhappy Path 覆盖
覆盖空串、malformed、越界和 strict/non-strict;返回值与 1292/1264/1265 诊断按入口区分。
白盒验证
关联修复 #28851 已进入当前
main。同时将本 issue 的可公开观察契约固化为独立回归,避免只依赖实现细节或共享测试间接判断。回归测试
suites/14_issue_regression/t/issue_recent_temporal_contracts.test714/714条语句通过。测试证据
d50a2d475a406829f67127fef7b2ad4abc1c1d3d14_issue_regression中观察到的旧 GOROOT/历史 golden/并发锁冲突属于既有无关失败,以上新增用例单独重跑均稳定通过。测试结论
测试通过。