Skip to content

[Bug]: PERIOD_ADD/PERIOD_DIFF invalid month handling differs from MySQL #25307

Closed

Description

@Ariznawlll

Bug Report

MatrixOne Version

Latest origin/main verified locally at 200bfa7e0efb.

Reproduce Steps

set session sql_mode = '';

select period_add(202413, 1) as add_bad_month,
       period_diff(202413, 202312) as diff_bad_month;

Expected Behavior

MySQL rejects invalid period months:

ERROR 1210 (HY000): Incorrect arguments to period_add

Actual Behavior

MatrixOne returns NULL values instead of raising the MySQL-compatible error:

add_bad_month  diff_bad_month
NULL           NULL

Notes

Found during MySQL compatibility Module 5 exploration. Existing #24504 is a broad old feature request for unsupported datetime functions on 3.0-dev; on latest main PERIOD_ADD / PERIOD_DIFF exist, so this is now a behavior compatibility bug for invalid period arguments.

Activity

  1. added
    kind/bug
    severity/s1
    on Jul 1, 2026
  2. added
    severity/s0
    and removed
    severity/s1
    on Jul 2, 2026
  3. added this to the MO-202607 milestone on Jul 2, 2026
  4. added theissue type on Jul 2, 2026
  5. added and removed
    severity/s0
    on Jul 2, 2026
  6. XuPeng-SH commented on Sep 27, 2026

    @XuPeng-SH
    Contributor

    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: C28 in the merged temporal design. PERIOD_ADD/PERIOD_DIFF are strict numeric year-month APIs: month must be 1..12, zero is invalid, and bad/negative/unrepresentable periods must raise the same error across literal/column/marker paths rather than silently return NULL.

    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. Rerun month13 and zero periods, NULL propagation, valid two-digit-year window, antisymmetric PERIOD_DIFF, inactive CASE and real prepared execution.

    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

  7. Ariznawlll commented on Oct 2, 2026

    @Ariznawlll
    CollaboratorAuthor

    测试版本

    • 分支:main
    • Commit:d50a2d475a406829f67127fef7b2ad4abc1c1d3d
    • 部署方式:本地全新单 CN mo-service,独立数据目录;MySQL 文本协议与 server-side PREPARE
    • 测试日期:2026-10-02

    原问题验证

    按 issue 原始语义在上述 commit 重新执行并重复 3 次。PERIOD_ADD/PERIOD_DIFF 对无效月份稳定返回 ERROR 1210,不再静默给出错误结果。

    Happy Path 覆盖

    覆盖合法 YYYYMM/YYMM 的加法和差值,并校验跨年边界。

    Unhappy Path 覆盖

    覆盖月份 0、13、负数及不可表示 period;literal/column/prepared 路径保持同一错误类别。

    白盒验证

    关联修复 #28851 已进入当前 main。同时将本 issue 的可公开观察契约固化为独立回归,避免只依赖实现细节或共享测试间接判断。

    回归测试

    测试证据

    • 精确测试版本:d50a2d475a406829f67127fef7b2ad4abc1c1d3d
    • 当前结果:PERIOD_ADD/PERIOD_DIFF 对无效月份稳定返回 ERROR 1210,不再静默给出错误结果。
    • 回归代码与 golden result 已提交到 MOTR #209;本地全量 14_issue_regression 中观察到的旧 GOROOT/历史 golden/并发锁冲突属于既有无关失败,以上新增用例单独重跑均稳定通过。

    测试结论

    测试通过。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bug

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions