Skip to content

[Bug]: TIME and BIT multiplication narrows UINT64 values before Decimal128 evaluation #29469

Closed

Description

@XuPeng-SH

Existing issue check

Searched existing MatrixOne issues before filing.

Branch / commit

main history; reproduced using the clean direct-parent benchmark binary for 1575e70c3db676d3ed00abc080aadc029b0e1435, fresh copy of its data snapshot, Linux amd64, local single CN on NVMe. Discovered while reviewing #29462; these ordinary SQL failures do not require prepared execution.

Actual behavior

create table numeric_domains(t time(0), f time(6), u bigint unsigned, b bit(64), d decimal(5,2));
insert into numeric_domains values('00:00:01','00:00:01.500000',18446744073709551615,18446744073709551615,1.25);
select t*u,u*t,f*u,b*t,b*d from numeric_domains;

Observed: -1, -1, -1.500000, -1, -1.25.
Expected: 18446744073709551615, 18446744073709551615, 27670116110564327422.500000, 18446744073709551615, 23058430092136939518.75.

Root cause / correction

The shared cast table selects Decimal64 for TIME with UINT64/BIT. Decimal64's signed coefficient cannot represent the full unsigned source domain, so conversion loses the value before the Decimal128 multiplication result is produced. MULTI's existing Decimal128-to-Decimal64 fast path separately omits BIT from its unsigned guard.

The correction under review in #29462 selects an adequate implicit multiplication operand domain, shares the UINT64/BIT exclusion with the existing fast path, preserves each operand's scale, and does not cross explicit CAST boundaries. Ordinary columns and the existing binary-prepared TIME arithmetic case pass locally. Other arithmetic operators and explicit CAST policy are outside this multiplication correction. Final PR review/performance acceptance remains pending.

Activity

  1. added
    kind/bug
    on Sep 29, 2026
  2. self-assigned this
    on Sep 29, 2026
  3. added a commit that references this issue on Sep 29, 2026
    a36da7f
  4. Ariznawlll commented on Oct 2, 2026

    @Ariznawlll
    Collaborator

    测试版本

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

    原问题验证

    按 issue 原始语义在上述 commit 重新执行并重复 3 次。UINT64 与 DECIMAL 运算保留完整精度,最大无符号值附近乘积正确。

    Happy Path 覆盖

    覆盖小值和 2^63、UINT64 上界附近值。

    Unhappy Path 覆盖

    覆盖乘积溢出、负 DECIMAL、NULL;不经 FLOAT64 丢精度。

    白盒验证

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

    回归测试

    测试证据

    • 精确测试版本:d50a2d475a406829f67127fef7b2ad4abc1c1d3d
    • 当前结果:UINT64 与 DECIMAL 运算保留完整精度,最大无符号值附近乘积正确。
    • 回归代码与 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

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions