Repository navigation
Description
Observed failure
Fixed by PR #29618, merged into main. The PR body references this issue with Fixes #29610.
Systematic QA for #29249 found two reachable Decimal256 modulo defects. Both reproduce through the actual SQL parser, planner and expression executor with valid DECIMAL(65,0) operands and a three-row scan (1, 2, NULL), preventing constant folding from bypassing the batch owner.
Tested branch: 76f2cd1617d823dc929e1c3fc1a72426a24f10a6, including main 21f711a7b8. The four affected owner bodies (Decimal128.Mod128, d256ModViaD128, d128ModOne, d128ModDiffScaleYPow10) are byte-identical to that main commit. This is separate from #29607's scale-difference-above-38 defect: these witnesses use equal scales.
Minimal SQL shape
CREATE TABLE mod_boundary_probe(i INT);
INSERT INTO mod_boundary_probe VALUES (1), (2), (NULL);
SELECT (CAST('-170141183460469231731687303715884105728' AS DECIMAL(65,0))
+ CAST(i - 1 AS DECIMAL(65,0)))
% CAST('18446744073709551616' AS DECIMAL(65,0))
FROM mod_boundary_probe;
-- expected: 0, -18446744073709551615, NULL
-- first evaluated row actually returns -170141183460469231731687303715884105728
SELECT CAST(i AS DECIMAL(65,0))
% CAST('-18446744073709551616' AS DECIMAL(65,0))
FROM mod_boundary_probe;
-- expected: 1, 2, NULL
-- actual executor panic: runtime error: integer divide by zero
DROP TABLE mod_boundary_probe;The executed reproduction binds the equivalent expressions to the existing mock optimizer's nation.n_nationkey scan, supplies actual int32 vectors and evaluates real expression executors. These are executed parser/planner/executor failures, not yet a live-service BVT claim. Independent literal coefficient and NULL assertions are used.
Root causes and ownership
Decimal128.Mod128is used for absolute magnitudes by signed modulo owners, but its wide-divisor comparisons call signedLess. The magnitude of the minimum signed coefficient is2^127; treating that bit pattern as negative skips reduction. D128's own SQL precision limit does not make this unreachable: legal D256 operands narrow to the same carrier.d256ModViaD128independently admits divisors using an OR reduction ofB64_127 + 1. It accepts-2^64, whose low limb is zero and whose absolute magnitude does not fit uint64. The resulting narrowed divisor is zero atbits.Div64. The existing canonicald128AbsFits64predicate already excludes exactly this boundary; the D256 path duplicates an incomplete rule.
Required closure
Restore absolute-magnitude comparison at the existing remainder owner, and reuse the existing divisor-domain predicate across narrowing consumers. Preserve signed results, factor/fallback contracts, NULL/mask ordering and strict/permissive zero behavior. Verify nearest positive/negative boundaries, broadcasting and late wide divisors; avoid adding a separate execution path or full-batch allocation. Validate actual public SQL/BVT and common-path cost before publication.
Baseline private probes: two raw and two public children fail for the intended wrong result/panic; command exits 1. No production source was changed for reproduction. Refs #29249 and #29608.
Activity
XuPeng-SH commentedon Oct 6, 2026
Fixed by #29618 (merged into main). The regression tests cover both minimum D128 magnitude remainder and the negative 2^64 divisor panic witness.
Ariznawlll commentedon Oct 8, 2026
main服务级复核结果测试版本:
bab4b3286a0dd5683a9b291763817722233e586c,包含修复 PR #29618 的 merge commit856e9ddbdd69b52d18f727c763ecd963e66644de。使用该提交重新编译的本地单 CN/TN 服务执行原 issue 的两组DECIMAL(65,0)SQL。连续 3 轮结果一致:
负
2^64除数不再触发integer divide by zeropanic;每轮之后连接保持可用,测试表仍可正常读取。当前main已覆盖原 issue 的错误余数、负宽除数和 NULL 路径,#29610 描述的问题已由 #29618 修复。Ariznawlll commentedon Oct 8, 2026
测试版本
MatrixOne 最新 main
1a0088790c8823bd3fe824ad9ff2ef1ce130eb31;本地独立数据目录、单 CN/TN 服务;MOTR PR #218 已推送,Python 3.10/3.12/3.13 与 Go 离线检查均通过。原问题验证
原
(-2^127+(i-1)) % 2^64在 i=1/2 分别为 0、-18446744073709551615,不再错算。正常场景覆盖
DECIMAL(65,0)宽除数% (-2^64)在 i=1/2 返回 1、2。边界与异常场景覆盖
NULL 行保持 NULL;负宽除数不触发 divide-by-zero panic,后续 SQL 正常。
白盒验证
修复 PR #29618 的底层 modulo 测试已在 main;本轮补真实 SQL 的双边界行验证。
回归测试
MOTR
14_issue_regression.issue_29607_29610_29615_decimal256_boundaries,3/3 通过。测试证据
MOTR PR #218 中同名 SQL/golden;两条 modulo 路径及会话存活均有断言。
测试结论
测试通过。