Repository navigation
Description
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:
mainat802376360c574f44aea23db5eef3cfcebf0527fd; the freshly built runtime reportedgit_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.46instance. - 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
INSERTreproducer: executed once on each server; both rejected the row and reported count0, 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)))inserted0.00and emitted warning1292on both servers. - Loose mode: after
SET SESSION sql_mode = '', insertingCAST('12.34tail' AS DECIMAL(8,2))stored12.34and emitted warning1292on both servers. UPDATE, otherDECIMALwidths, 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:
- Assert strict non-
IGNOREINSERTrejects the row with the agreed code and SQLSTATE and leaves the table unchanged. - Keep
INSERT IGNOREand loose-mode value/warning controls. - Independently check
UPDATE, other decimal widths, and prepared/binary protocol before extending the compatibility claim.
Related
- [Compatibility]: CAST('x' AS SIGNED) returns error 20203 (MySQL returns 0) #30417 tracks the original
SELECT CAST('abc' AS DECIMAL(...))failure; PR #31289 fixed the lenient explicit-cast path and explicitly recorded this strict-DML error-code difference as pre-existing and outside its scope. - Missing table uses parser error 1064 instead of MySQL error 1146, preventing ODBC SQLSTATE 42S02 #26684 concerned missing-table diagnostics, not decimal conversion.
- [Compatibility]: CAST numeric-prefix text AS SIGNED reports DOUBLE instead of INTEGER in warning #31443 tracks a separate
SIGNEDcast warning-text difference.
Activity