Skip to content

[Compatibility]: CAST('x' AS SIGNED) returns error 20203 (MySQL returns 0) #30417

Done

Description

@daviszhen

Proposed consolidated tracking scope: 显式 CAST 的非数字文本回退

This consolidates overlapping explicit-CAST reports. Administrative consolidation does not claim that any defect is fixed. Original report bodies and discussions remain available at the links below.

Included reports

  • #30911 — CAST of non-numeric strings to numeric types errors instead of returning zero

Acceptance checklist

  • Preserve SIGNED, UNSIGNED and DECIMAL reproductions, including empty/whitespace input, numeric prefixes, valid values and warnings.

Existing PR: #30646. Its integer-CAST scope must not be treated as proof of coverage for the DECIMAL cases already consolidated into #30911 (including #30912). Keep those cases explicitly open in this checklist until validated.


Environment

  • MatrixOne: matrixorigin/matrixone:latest arm64, VERSION() = 8.0.30-MatrixOne-v4.2.5
  • Baseline: MySQL 8.0.46

Reproduction

SELECT CAST('x' AS SIGNED);

Actual (MatrixOne)

ERROR 20203 (HY000) (invalid input / conversion error).

Expected (MySQL 8.0.46)

Returns 0 with a warning: Truncated incorrect INTEGER value: 'x'.

Impact

Data-cleaning and legacy-report SQL that relies on MySQL's lenient casting fails outright instead of
yielding 0. Together with the error-code divergence tracked in #26684 (1064 vs 1146), this makes
error-driven fallbacks unreliable during a MySQL→MatrixOne migration.

Activity

  1. added
    kind/compatibility
    on Oct 16, 2026
  2. XuPeng-SH commented on Oct 25, 2026

    @XuPeng-SH
    Contributor

    Fresh-round SQL on the isolated MatrixOne service built from aeaa273daf588a9988ba423915d3ae6b8c82124a (binary SHA-256 450363d5ec5e693bdd7ded44565b3b0ab1addcb807d3f9569c5d5eedeb1486e4) confirms the SIGNED/UNSIGNED integer cases: invalid/empty/whitespace strings return 0 with warning 1292, 42tail returns 42 with a truncation warning, valid 42 and NULL return without warnings, and a filtered row set does not warn for the excluded invalid value. However, the consolidated DECIMAL case still reproduces: SELECT CAST('abc' AS DECIMAL(8,2)) returns Error 20301 (invalid decimal string) instead of a lenient numeric result. Therefore this issue remains open and is not a transfer candidate. Artifacts: round2-30646-cast-integer-sql.sql / round2-aeaa273-30646-cast-integer-sql.log; failing probe round2-30646-cast-decimal-probe.sql / round2-aeaa273-30646-cast-decimal-probe.log.

  3. assigned and unassigned on Oct 27, 2026
  4. slyunnn commented on Oct 27, 2026

    @slyunnn

    Regression and extended verification for #30417 (2026-10-27)

    Verification Environment

    • MatrixOne main: 802376360c574f44aea23db5eef3cfcebf0527fd — perf: adapt bulk user AUTO_INCREMENT prefetch to observed demand (#31410). The freshly built runtime reported git_version() = 8023763.
    • Local topology: 2 CN / 1 TN / 1 LogService / Proxy. Proxy 26833, CN1 27151, and CN2 27152 were reachable.
    • MySQL CLI over TCP using the MySQL wire protocol. The conversion matrix ran through Proxy; the original SIGNED and invalid DECIMAL cases also ran directly on both CNs. A separate MySQL 8.0.46 instance provided the comparison.

    What Was Covered

    • OK CAST('x' AS SIGNED) and CAST('x' AS UNSIGNED) returned 0 with warning 1292. CAST('abc' AS DECIMAL(8,2)) returned 0.00 with warning 1292.
    • OK Empty/whitespace text, numeric-prefix text, valid values, and NULL were checked for the relevant integer and DECIMAL casts against MySQL.
    • OK Under STRICT_TRANS_TABLES, the invalid-decimal INSERT was rejected and inserted no row. INSERT IGNORE and a loose-mode INSERT stored the expected values with warning 1292.
    • OK The original SIGNED and DECIMAL invalid-text queries returned the expected values and warning codes through both CN endpoints.
    • Not covered Binary-protocol prepared statements, the full distributed BVT suite, or engine parallel execution.

    Findings

    The original invalid-text conversion failure and the tested consolidated DECIMAL value/warning behavior are fixed on the pinned main. The merged fixes are PR #30646, commit c3e962df0a7efd7202ab9cbc37ce739f7c8a883a, for integer casts, and PR #31289, commit dfaed071d0fc7941c3544fb57496bf14f1d704cb, for explicit DECIMAL casts.

    Two diagnostic differences observed in the extension tests are tracked separately: #31443 for the numeric-prefix warning's DOUBLE versus INTEGER text, and #31444 for strict-DML error code/SQLSTATE. Their separation does not assert that exact diagnostic parity has already been accepted as the compatibility contract.

    MOTR / BVT Coverage

    No MOTR case was added. The merged implementation PRs include regression coverage; this run used direct SQL and did not rerun the full BVT suite. No engine-parallel or MOTR parallel execution is claimed.

    Final Conclusion

    Fixed for the originally reported invalid-text conversion and the consolidated value/warning-code cases exercised above. The separate diagnostic differences remain open in #31443 and #31444. Large-data regression is not needed for this scalar conversion and diagnostic behavior.

  5. assigned and unassigned on Oct 28, 2026
  6. Ariznawlll commented on Nov 30, 2026

    @Ariznawlll
    Collaborator

    QA 验收通过(最新 main)

    版本与方法

    • 被测及开测时官方 main:c255da6778fac39bc53b5b9defaab3b6f945e4d6;关闭前再次解析仍为该 SHA。
    • 独立双 CN,真实 MySQL 协议;两个 listener 均核对完整 git_version()。
    • 每轮独立数据库,连续 3/3 PASS,并在第二 CN 新连接重复标量矩阵。

    覆盖与结果

    1. CAST 到 SIGNED、UNSIGNED、DECIMAL:非数字文本、空串/空白、数字前缀均返回对应零值或数字前缀;合法 42 精确返回 42/42/42.00,NULL 保持 NULL。
    2. SELECT 诊断逐条核对:非数字、空值及数字前缀各产生 3 条 1292 警告;合法值及 NULL 为 0 条。
    3. STRICT_TRANS_TABLES 下普通 INSERT 非数字值被拒绝,目标表仍为 0 行;INSERT IGNORE 转为警告并写入零值。
    4. 非严格 sql_mode 下 INSERT 同样产生警告并写入零值;精确读出 (0,0,0.00)。
    5. DML 按语句上下文检查 1265/1292/1366 诊断族;本验收不宣称所有 DML 错误文本与 MySQL 逐字一致。

    三轮日志 SHA256:

    • 1cade7d2a34d51121c368790f4a4d4e14b46a9eb5d7153e19f28549f26433644
    • 4dca8c01a8240a63414f390b8442f47ce7a3ea06bfe603607d83411071c9c3e7
    • aaf388a89f6861151e3ba2bde487efbc5e623a5f80a4aafc2232dfd88bd6646d

    MOTR 回归

    已推送到 matrixorigin/motr PR 374,head d7715c5907ac73f967096343b1e394ec8486504f,用例为 issue_30417_lenient_cast.py。评论时新 head 的 CI 均为 pending(queued),daily-42 为 SKIPPED;不以 CI pending 代替上述真实 SQL 验收。

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

Metadata

Metadata

Assignees

Labels

kind/compatibility

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions