Skip to content

[Compatibility]: strict INSERT with invalid DECIMAL cast returns 20301/HY000 instead of MySQL 1292/22007 #31444

Open

Description

@slyunnn

Description

Under STRICT_TRANS_TABLES, an INSERT containing an explicit invalid-text-to-DECIMAL cast is rejected by both MatrixOne and MySQL, and neither inserts the row. The error code and SQLSTATE differ:

  • MatrixOne: 20301 / HY000.
  • MySQL 8.0.46: 1292 / 22007.

The observed difference is diagnostic classification; strict rejection and the tested statement's atomicity match.

Environment

  • MatrixOne: main at 802376360c574f44aea23db5eef3cfcebf0527fd; the freshly built runtime reported git_version() = 8023763.
  • Deployment: isolated local 2 CN / 1 TN / 1 LogService / Proxy.
  • Client: MySQL CLI over the MySQL TCP protocol; DML was executed through Proxy.
  • Comparison: an isolated MySQL 8.0.46 instance.
  • Verification date: 2026-10-27.

Steps to reproduce

Run the following in one session on each server. After the expected INSERT error, continue in the same session to check the row count.

CREATE DATABASE cast_decimal_diag;
USE cast_decimal_diag;
CREATE TABLE t (id INT PRIMARY KEY, v DECIMAL(8,2));
SET SESSION sql_mode = 'STRICT_TRANS_TABLES';

INSERT INTO t VALUES (1, CAST('abc' AS DECIMAL(8,2)));
SELECT COUNT(*) FROM t;

Actual behavior

MatrixOne rejects the INSERT with:

ERROR 20301 (HY000): invalid input: "abc" is invalid decimal string

The subsequent SELECT COUNT(*) returned 0.

Expected behavior

MySQL 8.0.46 rejects the same INSERT with:

ERROR 1292 (22007): Truncated incorrect DECIMAL value: 'abc'

The subsequent SELECT COUNT(*) also returned 0.

Please confirm the intended MySQL compatibility contract for native error code and SQLSTATE. If exact parity is required, the statement should expose 1292 / 22007 while retaining strict rejection and atomicity.

Stability and controls

  • Strict INSERT reproducer: executed once on each server; both rejected the row and reported count 0, with different diagnostics. Repeated-run stability has not been established.
  • Strict INSERT IGNORE: INSERT IGNORE INTO t VALUES (2, CAST('abc' AS DECIMAL(8,2))) inserted 0.00 and emitted warning 1292 on both servers.
  • Loose mode: after SET SESSION sql_mode = '', inserting CAST('12.34tail' AS DECIMAL(8,2)) stored 12.34 and emitted warning 1292 on both servers.
  • UPDATE, other DECIMAL widths, and prepared/binary-protocol DML have not been independently tested.

Evidence

MatrixOne: ERROR 20301 (HY000) ... invalid decimal string; row count 0
MySQL:     ERROR 1292 (22007) ... Truncated incorrect DECIMAL value; row count 0

The original regression record is in #30417's regression comment.

Code analysis

At the tested commit, explicitCastMustErrorOnStrictDML detects strict non-IGNORE DML. The explicit DECIMAL64 lexical-error path in func_cast.go skips the lenient warning fallback under that condition and returns the parsing error.

This static inspection is consistent with the observed 20301; it does not establish which diagnostic mapping the compatibility contract requires. The DECIMAL128/256 runtime paths were not tested here.

Regression coverage

If error-code/SQLSTATE parity is confirmed as in scope:

  1. Assert strict non-IGNORE INSERT rejects the row with the agreed code and SQLSTATE and leaves the table unchanged.
  2. Keep INSERT IGNORE and loose-mode value/warning controls.
  3. Independently check UPDATE, other decimal widths, and prepared/binary protocol before extending the compatibility claim.

Related

Activity

  1. added
    kind/compatibility
    kind/bug
    and removed
    kind/compatibility
    on Oct 27, 2026
  2. added this to the MO-202610 milestone on Oct 27, 2026
  3. added theissue type on Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bugneeds-triage

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions