You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Compatibility]: TIME functions accept and return values beyond the ±838:59:59 endpoint #28559
CREATETABLEsrc(id INTPRIMARY KEY, t TIME(6));
INSERT INTO src VALUES (1, '838:59:58.999999');
SELECT CAST(ADDTIME(t, '00:00:00.000002') ASCHAR) FROM src;
-- 838:59:59.000001CREATETABLEcopiedASSELECT ADDTIME(t, '00:00:00.000002') AS t FROM src;
-- ERROR 1690: data out of range: data type time, value '838:59:59.000001'
这使查询结果、view/prepared 路径与物化路径使用了不同的值域契约。
代码定位
pkg/sql/plan/function/func_binary.go 的 addTimeToTime 和 subTimeFromTime 使用 types.ValidTime;该检查允许 MatrixOne 内部的约 25.6 亿小时范围,而不是 MySQL TIME 范围。
对应代码是 pkg/sql/plan/function/func_timestamp_pair.go 的 newTimestampPairTimeReader 字符串分支:它直接使用内部宽范围的 types.ParseTime 结果,没有应用 MySQL TIME 输入范围限制。因此 #28559 修复时还需要覆盖双参数 TIMESTAMP(),否则其他 TIME 结果函数修正后仍可从这里绕过范围契约。
changed the title [-][Compatibility]: TIME-producing functions return values beyond the ±838:59:59 endpoint[/-][+][Compatibility]: TIME functions accept and return values beyond the ±838:59:59 endpoint[/+]on Sep 10, 2026
SET SESSION sql_mode ='';
CREATETABLEg(
id INTPRIMARY KEY,
raw VARCHAR(32),
sec BIGINT GENERATED ALWAYS AS (TIME_TO_SEC(raw)) STORED,
INDEX idx_sec(sec)
);
INSERT INTO g(id,raw) VALUES
(1,'838:59:59'),(2,'839:00:00'),(3,'-839:00:00');
SELECT id,raw,sec FROM g ORDER BY id;
SELECT id FROM g WHERE sec=3020400;
执行计划使用 Index Table Scan on g.idx_sec,因此越界解释已经进入持久化生成列和二级索引键。
MySQL 8.0.46 会将两个越界输入限制到正负端点并产生 1292 warning,生成列保存 ±3020399;sec=3020400 不返回行。
以下路径继续保持同一差异:
INSERT INTO g(id,raw) VALUES(1,'839:00:00')
ON DUPLICATE KEY UPDATE raw=VALUES(raw);
ALTERTABLE g ADD COLUMN fmt VARCHAR(64)
GENERATED ALWAYS AS (TIME_FORMAT(raw,'%H:%i:%s.%f')) STORED;
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: C02, C03, C32–C33 in the merged temporal design. The public TIME endpoint is ±838:59:59. Arithmetic ADDTIME/SUBTIME/TIMEDIFF beyond it returns row NULL plus warning 1441; explicit TIME conversion clamps with warning 1292; assignment follows strict/non-strict rules (including 1264/1265). Do not use MySQL arithmetic saturation as the oracle.
Please rerun the original reproducer on main at 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. Retest SELECT, CTAS/view, prepared execution, positive/negative endpoints and one-microsecond overflow. SEC_TO_TIME is a separate API: confirm it publishes no out-of-domain TIME, and keep this issue open if any original path remains inconsistent.
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
Activity
Ariznawlll commentedon Sep 10, 2026
补充同一 TIME 输入边界在双参数
TIMESTAMP()中的传播:MatrixOne latest main
ac660ae56返回:且没有 warning。MySQL 8.0.46 先把第二参数限制到 TIME 上界,返回:
相邻控制
TIMESTAMP('2024-01-01', '838:59:59')两端均返回2024-02-04 22:59:59。对应代码是
pkg/sql/plan/function/func_timestamp_pair.go的newTimestampPairTimeReader字符串分支:它直接使用内部宽范围的types.ParseTime结果,没有应用 MySQL TIME 输入范围限制。因此 #28559 修复时还需要覆盖双参数TIMESTAMP(),否则其他 TIME 结果函数修正后仍可从这里绕过范围契约。[-][Compatibility]: TIME-producing functions return values beyond the ±838:59:59 endpoint[/-][+][Compatibility]: TIME functions accept and return values beyond the ±838:59:59 endpoint[/+]Ariznawlll commentedon Sep 10, 2026
继续扩展后确认,#28559 不只影响“生成 TIME 结果”的函数;多个接收 TIME-like 字符串的函数也绕过相同边界契约。
sql_mode=''与STRICT_TRANS_TABLES下均一致,3/3 重复:MatrixOne latest main
ac660ae56:均无 warning。MySQL 8.0.46 先限制到正负端点:
每个越界参数均产生
Warning 1292。HOUR('839:00:00')两端数值碰巧同为838,但 MatrixOne 同样缺少越界 warning。另外,
MAKETIME(838,59,59.000001)和MAKETIME(839,0,0)已能截到正确端点,但 MatrixOne 没有 MySQL 的1292warning;因此修复范围还应包含“结果已经 clamp、诊断仍丢失”的路径。这些路径与 issue 本文的
ADDTIME/SUBTIME/TIMEDIFF/SEC_TO_TIME共同说明:内部宽范围Time表示被直接暴露给多个 SQL 函数,SQL 层尚未统一应用 MySQL TIME 的输入/输出边界和诊断规则。Ariznawlll commentedon Sep 10, 2026
补充生成列、二级索引、ODKU 和 ALTER 的持久化影响。非严格模式下 3/3 重复:
MatrixOne:
执行计划使用
Index Table Scan on g.idx_sec,因此越界解释已经进入持久化生成列和二级索引键。MySQL 8.0.46 会将两个越界输入限制到正负端点并产生
1292warning,生成列保存±3020399;sec=3020400不返回行。以下路径继续保持同一差异:
MatrixOne 的 ODKU 将
sec更新为3020400;ALTER 回填fmt='839:00:00.000000'。MySQL 分别保存3020399和838:59:59.000000并产生越界 warning。这说明 #28559 不只是临时 SELECT 显示差异;错误值可以通过生成列写入存储、建立索引,并直接改变索引等值查询结果。
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: C02, C03, C32–C33 in the merged temporal design. The public TIME endpoint is ±838:59:59. Arithmetic ADDTIME/SUBTIME/TIMEDIFF beyond it returns row NULL plus warning 1441; explicit TIME conversion clamps with warning 1292; assignment follows strict/non-strict rules (including 1264/1265). Do not use MySQL arithmetic saturation as the oracle.
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. Retest SELECT, CTAS/view, prepared execution, positive/negative endpoints and one-microsecond overflow. SEC_TO_TIME is a separate API: confirm it publishes no out-of-domain TIME, and keep this issue open if any original path remains inconsistent.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 次。SEC_TO_TIME 显式转换按端点 clamp;ADDTIME/SUBTIME/TIMEDIFF 溢出返回 NULL 和 warning 1441。
Happy Path 覆盖
覆盖端点内、恰好端点和正负秒值。
Unhappy Path 覆盖
覆盖端点外、极大值、NULL 及 arithmetic overflow;区分 conversion clamp 与 arithmetic NULL。
白盒验证
关联修复 #28851 已进入当前
main。同时将本 issue 的可公开观察契约固化为独立回归,避免只依赖实现细节或共享测试间接判断。回归测试
suites/14_issue_regression/t/issue_recent_temporal_contracts.test714/714条语句通过。测试证据
d50a2d475a406829f67127fef7b2ad4abc1c1d3d14_issue_regression中观察到的旧 GOROOT/历史 golden/并发锁冲突属于既有无关失败,以上新增用例单独重跑均稳定通过。测试结论
测试通过。