Repository navigation
Description
Environment
- MatrixOne:
8.0.30-MatrixOne-v1.3.0, built from2ce4e58af6f03b943ee288ffad81012766cf830a - MySQL:
8.0.46 - Topology: local single CN / TN / LogService
- Verification date: 2026-10-14
The official main commit checked during this run is a53390c57de48ac280249ff0e88831e502e20fb0; the tested DIV resolver/executor source is unchanged there from the pinned test build.
Problem
For DECIMAL operands, MatrixOne's DIV result domain does not match MySQL in both published metadata and mixed signedness behavior.
Result metadata for a narrow DECIMAL dividend
CREATE TABLE div_src(d DECIMAL(10,3), i INT);
INSERT INTO div_src VALUES (5.678, 2), (-5.678, -2);
CREATE TABLE div_ctas AS SELECT d DIV i AS q FROM div_src;
CREATE VIEW div_view AS SELECT d DIV i AS q FROM div_src;
SELECT table_name, column_type
FROM information_schema.columns
WHERE table_schema = DATABASE() AND table_name IN ('div_ctas','div_view');Both CTAS and view metadata are stable but differ:
| Result | MatrixOne | MySQL 8.0.46 |
|---|---|---|
DECIMAL(10,3) DIV INT |
BIGINT |
INT |
The values (2 and 2) match. With a DECIMAL(18,3) dividend, both expose BIGINT, making the mismatch specific to the narrower result domain rather than all DECIMAL DIV expressions.
Negative DECIMAL dividend with an UNSIGNED divisor
SELECT CAST(5.678 AS DECIMAL(10,3)) DIV CAST(2 AS UNSIGNED);
SELECT CAST(-5.678 AS DECIMAL(10,3)) DIV CAST(2 AS UNSIGNED);- Positive control: both return
2. - Negative case: MatrixOne returns
-2; MySQL returnsERROR 1690 (22003): BIGINT UNSIGNED value is out of range. DECIMAL(-5.678) DIV SIGNED(2)returns-2on both engines.- The MySQL error persists with empty
sql_modeandNO_UNSIGNED_SUBTRACTION; MatrixOne returns-2in both modes.
These statements were repeated three times with the same outcomes. This is a result-domain/value-error difference, not a division-by-zero or strict-mode failure.
Existing tracking and contract check
The compatibility contract records signed-integer / behavior, but does not define a DECIMAL DIV exception. Closed #23439 covers earlier Decimal64 sign, overflow, and prepared strict-mode issues; it does not cover a signed DECIMAL dividend with an UNSIGNED integer divisor or the narrow-DECIMAL INT metadata shape. #28580 is specifically for /, not DIV. The broader CTAS metadata tracker is #24436.
Expected behavior
Derive the DIV result type and signed/unsigned result domain compatibly with MySQL for DECIMAL/integer operand combinations, including CTAS and views, while preserving the already-matching signed-operand quotient values.
Activity
Ariznawlll commentedon Oct 14, 2026
补充到 DML/ODKU 交叉路径:
同一操作数形状下,MO 语句成功并将目标行改为
(1,-2);MySQL 报ERROR 1292 (22007): Truncated incorrect DECIMAL value: '-2',已有目标行保持(1,99)。这表明前述 signed DECIMAL / unsigned divisor 差异会进入 ODKU 写路径并改变持久化状态;直接SELECT的 MySQL 错误码为 1690,DML 上下文中的错误文本/错误码不同。XuPeng-SH commentedon Oct 19, 2026
本轮功能复测结果(2026-10-19 UTC):PR #30171 的 DECIMAL DIV 修复在最新 main 上通过真实 MySQL 协议 SQL 回归及 race 测试。分支
main,完整 SHA8e63625c4e9baeb1d28c1095c07732f056c04895;Linux/amd64、Go 1.27.1、隔离嵌入式单 CN + MySQL TCP。执行
TestDecimalIntegerDivPublicContracts,同一实例完整重复两轮(两轮都通过,数据库清理后确认 schema 不存在),覆盖原 issue 的窄/宽 DECIMAL DIV CTAS 与 VIEW 的INT/BIGINT类型域、signed/unsigned 行为,并扩展到 folded/derived/ordered/threshold/null/预备参数重用、uint64 最大值、负非零越界、零与除零 warning 的 sql_mode 对照,以及越界 ODKU 后旧目标行仍保持q=99。两轮均通过,race 命令 exit 0(40.077s)。命令:
原始日志 SHA-256
0a02199bb745ab63881b2520d59333da9545d10eeb3122158b1c01ec975784b7,环境、命令和退出码在continue22/runs/30171-main-race/。该 PR 合入 main,本次仅验证 main,未把无关 4.2-dev 当作必测分支。Ariznawlll commentedon Oct 19, 2026
测试版本
maine0314478159c80b062483c307180b02dc009dbc0(执行前读取的官方 main)873282742714436bff407dfcdbbe879147162bd3;GitHub compare 确认该提交在上述 main 内。原问题验证
在上述完整 SHA 独立运行
MO_TEST_CLUSTER_TCP_ONLY=1 .agents/skills/mo-dev/scripts/mo-cgo-test -race -p 1 -count=3 -run '^TestDecimalIntegerDivPublicContracts$' ./pkg/tests/sqlintegration,exit 0,ok .../pkg/tests/sqlintegration 77.953s。该测试每次运行独立建库/清库两轮,因此原始 SQL 形状累计 6/6:DECIMAL(10,3) DIV INT的 CTAS 与 VIEW 的information_schema.columns.column_type均为int,查询值2;DECIMAL(18,3) DIV INT为bigint、值2,与 issue 的窄/宽对照一致。SELECT不再错误返回-2,而是out of range;正值对照返回2。INSERT ... SELECT d DIV u ... ON DUPLICATE KEY UPDATE被拒绝后,目标旧行q=99保持不变;不会再持久化错误的-2。Happy Path 覆盖
UINT64最大值均有精确类型/值断言;预备语句在 signed/unsigned 参数间复用后,合法结果仍正确。NULL输入与零分母按对应 SQL mode 返回 NULL/警告;测试区分有效 NULL 与错误路径,不将其算作异常失败。Unhappy Path 覆盖
out of range拒绝;失败后同连接合法查询继续成功。99保持不变,验证失败原子性。白盒验证
同 SHA 上述真实协议集成测试以
-race -count=3通过,覆盖表达式类型推断、执行器和持久化消费;不是只运行 planner 单元测试。未观察到 race 报告或 panic。回归测试
int/bigint元数据、正负数、预备语句与 ODKU 失败后的旧值。-race -count=3通过;按用户最新要求,现有 Go 集成测试已覆盖原产品路径与必要边界,不再向 MOTR select without from clause is not supported #247 添加重复用例。测试证据
测试结论
测试通过。