Skip to content

[Bug]: Strict Decimal256 LOAD silently accepts malformed tails after 76 retained digits #29922

Closed

Description

@XuPeng-SH

Is there an existing issue for the same bug?

  • I searched open and closed reports for Decimal256 / malformed decimal / invalid suffix / trailing tail. No matching report was found.

Branch Name

main

Commit ID

41ac6242b7620aa069db91492db1d41584319b05

Fresh service built from this main snapshot, with the build's commit ID verified. Local Linux/amd64, Go 1.27.1; owned LogService/TN/two-CN cluster. Both CNs reproduce. This is a correctness report, not a claim that the latest commits introduced the defect.

Actual Behavior

With sql_mode='STRICT_ALL_TABLES', CSV and JSONLINE LOAD into DECIMAL(39,2) or DECIMAL(65,2) silently accept malformed text after the Decimal256 parser's retained-digit boundary:

Input Observed
0. + 76 × 1 + z rejected
0. + 77 × 1 + z accepted, stores 0.11, no warnings
0. + 80 × 1 + z accepted, stores 0.11, no warnings
0. + 77 × 1 + .1 accepted, stores 0.11, no warnings
Same long fraction followed by e+ rejected

The corresponding Decimal128 target DECIMAL(38,2) rejects the malformed z / second-decimal-point tails. Valid long fractions, with and without a valid exponent, still load successfully.

Expected Behavior

Strict import should validate the entire numeric token and reject malformed trailing characters consistently, regardless of the number of preceding valid digits. Precision truncation/rounding must not turn invalid numeric text into a valid stored value.

Steps to Reproduce

Create the fixtures on the machine visible to the service:

import json
from pathlib import Path

for n in (76, 77):
    value = "0." + "1" * n + "z"
    Path(f"/tmp/mo_decimal_tail_{n}.csv").write_text(
        "1," + value + "\n"
    )
Path("/tmp/mo_decimal_tail_77.jsonl").write_text(
    json.dumps({"id": 1, "d": "0." + "1" * 77 + "z"}) + "\n"
)
SET sql_mode='STRICT_ALL_TABLES';
CREATE DATABASE qa_decimal_tail;
USE qa_decimal_tail;
CREATE TABLE t(id INT, d DECIMAL(65,2));

-- Control: rejected with invalid Decimal256 input.
LOAD DATA INFILE '/tmp/mo_decimal_tail_76.csv'
INTO TABLE t FIELDS TERMINATED BY ',';

-- Counterexample: succeeds although the token ends in z.
LOAD DATA INFILE '/tmp/mo_decimal_tail_77.csv'
INTO TABLE t FIELDS TERMINATED BY ',';
SHOW WARNINGS;
SELECT id, CAST(d AS VARCHAR) FROM t;
-- no warnings; (1, '0.11')

TRUNCATE t;
LOAD DATA INFILE {
  'filepath'='/tmp/mo_decimal_tail_77.jsonl',
  'format'='jsonline',
  'jsondata'='object'
} INTO TABLE t;
SHOW WARNINGS;
SELECT id, CAST(d AS VARCHAR) FROM t;
-- same result

DROP DATABASE qa_decimal_tail;

White-box location and validation

parse256 dropped-tail handling: when width == 76, it skips remaining digit characters, continues if the next character is e/E, and otherwise breaks. A remaining z or . is not validated before the caller applies the final column scale.

The fresh-main public matrix covered 180 combinations: two CNs × CSV/JSONLINE × precisions 38/39/65 × 76/77/80 fractional digits × tails z, .1, e+, e1, and empty. All 32 malformed-tail Decimal256 acceptance combinations reproduced without warnings.

A parser-source control immediately before #29884 also reproduces this acceptance. That control is not a full old-service test, and this report does not classify the defect as a new regression from #29884.

Activity

  1. added
    kind/bug
    on Oct 11, 2026
  2. XuPeng-SH commented on Oct 12, 2026

    @XuPeng-SH
    ContributorAuthor

    追加 main 复验:已将独立 LogService/TN/两个 CN 全部升级到 2c9399d3831be92c53431788c60a00bdde84af3c,验证服务构建 commit ID,重新执行完整 180 组 CSV/JSONLINE + STRICT_ALL_TABLES 对照。32 组非法尾部 Decimal256 输入仍被接受,均存为 0.11,SHOW WARNINGS 为空;76 位尾部、Decimal128 及非法指数控制保持拒绝。该版本运行二进制 SHA256:b961c4ed9efa87a8cc87c400492360214b2621ffe6fcca6e04c53eb76d638f8f。此处明确记录实际测试快照,不把后续未执行的 main 提交算作已验证。

  3. added
    ai-easy
    on Oct 12, 2026
  4. Ariznawlll commented on Oct 13, 2026

    @Ariznawlll
    Collaborator

    测试版本

    • 分支:main;commit:175a645a85994f2c95992d3aa8d6dacb6d9e167f;2026-10-13。
    • 环境:本地隔离 MatrixOne 服务;按用例使用真实 SQL、MySQL 二进制协议或异步索引。

    原问题验证

    CSV 与 JSONLine 严格导入分别覆盖 DECIMAL(38/39/65)、76/77/80 位尾部及 z、.1、e+ 非法后缀;非法输入均报错,目标表仍为 0 行。 对应定向用例在 MOTR 入口重复执行 3 次均通过(每次脚本内再执行 3 轮)。

    Happy Path 覆盖

    同格式有效长小数导入成功且与原值相等。

    Unhappy Path 覆盖

    非法尾部不再静默截断为 0.11;每个失败后再次查询目标表和连接,未残留部分数据。

    白盒验证

    本次以真实 SQL/协议行为直接判定;没有把仅凭源码推断当作运行结果。

    回归测试

    MOTR PR #234 中的 issue_29922_decimal256_tail.py 已提交;离线 CI 通过,仍待正常 review/merge。该缺陷由确定性语义/类型/协议边界触发,不需要另加 big-data 或 chaos 才能验收。

    测试证据

    PR 验证记录及 CI 运行。

    测试结论

    测试通过。

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

Metadata

Metadata

Assignees

Labels

ai-easykind/bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions