Repository navigation
Description
Consolidated tracking scope: Implicit numeric coercion and numeric operator selection for strings
The existing tracker already owns integer/DOUBLE, literal/column, arithmetic/comparison/JOIN and prepared-IN conversion policy. Add the duplicate well-formed comparison case and the string+string overload-selection branch as independent acceptance paths; no single immediate code fix is assumed.
Administrative consolidation does not mean these defects are fixed. Each distinct path below remains independently required; original bodies and discussions remain preserved.
Included reports
- #31171 — [Bug]: comparing INTEGER with a non-integer string errors ('1 = 1.0' fails; float path works)
- #31169 — [Bug]: '+' on two strings concatenates ('1'+'1'='11') instead of adding (MySQL: 2)
Acceptance checklist
- Retain all existing integer/DOUBLE, literal/column, JOIN, arithmetic, aggregate, mixed IN/NOT IN, prepared execution and NULL controls.
- Cover 1='1.0', 1='1.5', 1='1x', 100='1e2', and int-column/VARCHAR-column JOIN, predicate, ORDER BY k+0 and IN-subquery cases, including a malformed row among valid rows.
- In MySQL-compatible arithmetic, string+string must select numeric addition rather than concatenation: test '1'+'1', '1.5'+'2.5', CHAR/VARCHAR columns and SUM(a+b), with CONCAT as an explicit concatenation control.
- Retain numeric-prefix truncation diagnostics and distinguish SELECT/implicit comparison from explicit CAST and strict/non-strict DML. Earlier summaries that classify every malformed string as zero or as an error are not an acceptance oracle; use the same SQL mode and the retained MySQL results/warnings for each context.
Preserved additional reports
#31171: [Bug]: comparing INTEGER with a non-integer string errors ('1 = 1.0' fails; float path works)
Source: #31171
Original issue body
Description
Comparing an integer with a string raises invalid argument cast to int, bad value ... whenever the string is not a bare integer literal. MySQL coerces the string to a number (taking the numeric prefix, or 0) and compares. The same comparison against a float/decimal works fine, so the integer path is the outlier.
Environment
- MatrixOne dev build (local multi-CN,
main) - MySQL 8.0.45 control
Reproduction
| Expression | MO | MySQL 8.0.45 |
|---|---|---|
SELECT 1 = '1.0' |
ERROR 20203 invalid argument cast to int, bad value 1.0 |
1 |
SELECT 1 = '1.5' |
ERROR 20203 | 0 |
SELECT 1 = '1x' |
ERROR 20203 | 1 |
SELECT 1 = '1e2' |
ERROR 20203 | 0 |
SELECT 100 = '1e2' |
ERROR 20203 | 1 |
SELECT 1.5 = '1.5' |
1 ✓ |
1 |
SELECT CAST(1 AS DECIMAL(5,1)) = '1.0' |
1 ✓ |
1 |
So: int vs string errors out, float/decimal vs string is correct. The problem is specific to the integer comparison path.
Root cause
The integer-vs-string comparison coerces the string operand with a strict integer parse (strconv.ParseInt-style, rejecting ., e, and any trailing characters). MySQL instead applies a lenient numeric prefix parse ('1.5'→1.5, '1x'→1, 'abc'→0) and then compares.
This is the same strictness that also shows up in explicit casts (CAST('1.5' AS SIGNED) errors, MySQL → 1), but the comparison path matters more because it happens implicitly in ordinary WHERE clauses and joins.
Impact
WHERE int_col = ?with a bound string parameter fails. Drivers that send parameters as strings (common with generic ORMs, JDBCsetString, Python%swith a string value, JSON-sourced values) hit this on every integer column comparison:-- app sends '1.0' or '1' as a string parameter SELECT * FROM t WHERE id = '1.0'; -- MO errors, MySQL returns the row
- Mixed-type joins (
ON int_col = varchar_col) error as soon as a single non-bare-integer value appears in the varchar column, so the query fails at plan/exec rather than filtering. - Queries migrated from MySQL that rely on loose comparison (
WHERE id = '0010',WHERE id = ' 10 ') break. - The inconsistency with the float path makes it hard to predict:
1.5 = '1.5'works while1 = '1.0'does not.
Expected behavior
Coerce the string with MySQL's lenient numeric prefix rules and compare:
SELECT 1 = '1.0'; -- 1
SELECT 1 = '1.5'; -- 0
SELECT 1 = '1x'; -- 1
SELECT 100 = '1e2'; -- 1If strictness is intentional for explicit CAST(... AS SIGNED), that is a separate decision — but implicit comparison should follow MySQL's lenient coercion, matching the already-correct float/decimal path.
Original comment by Ariznawlll (2026-10-26T03:20:21Z)
Source: #31171 (comment)
Adding concrete query-level evidence: this is not just a constant-folding edge case — five ordinary query shapes fail on a table whose VARCHAR column contains a non-numeric value.
Setup (identical on both engines):
CREATE TABLE ct_int (id INT PRIMARY KEY, v INT);
CREATE TABLE ct_str (id INT PRIMARY KEY, k VARCHAR(10));
INSERT INTO ct_int VALUES (1,10),(2,20),(3,30);
INSERT INTO ct_str VALUES (1,'10'),(2,'20'),(3,'xx'); -- note the 'xx'| Query | MO | MySQL |
|---|---|---|
SELECT COUNT(*) FROM ct_int a JOIN ct_str b ON a.v = b.k |
ERROR 20203 | 2 |
SELECT COUNT(*) FROM ct_str WHERE k = 10 |
ERROR 20203 | 2 |
SELECT COUNT(*) FROM ct_str WHERE k > 15 |
ERROR 20203 | 2 |
SELECT GROUP_CONCAT(k ORDER BY k+0) FROM ct_str |
ERROR 20203 | 10,20,xx |
SELECT COUNT(*) FROM ct_int WHERE v IN (SELECT k FROM ct_str) |
ERROR 20203 | 2 |
Two things make this worse than a single-bad-value problem:
- One non-numeric cell poisons the whole query.
ct_strhas three rows and only one is'xx'; the presence of that single value makes every mixed int/varchar comparison fail — there is no per-row fallback to 0 like MySQL has. ORDER BY k+0fails, which kills the standard workaround. MySQL users sorting numeric strings numerically (ORDER BY varchar_col + 0) hit the same error, so the documented escape hatch is unavailable.
Note SELECT COUNT(*) FROM ct_int WHERE v = '10' (int column vs string literal) works — so only the direction where the string side is a column breaks. That asymmetry means the failure only appears against real data, never in unit tests with literals.
The fix (lenient numeric prefix parse) should cover all expression contexts — comparison, join keys, IN, and arithmetic on a varchar column — not just literal-to-literal comparison.
#31169: [Bug]: '+' on two strings concatenates ('1'+'1'='11') instead of adding (MySQL: 2)
Source: #31169
Original issue body
Description
The + operator on two string operands performs string concatenation in MatrixOne, where MySQL performs numeric addition. This is a silent wrong-answer bug — no error, no warning, just a different value.
Environment
- MatrixOne dev build (local multi-CN,
main) - MySQL 8.0.45 control
Reproduction
| Expression | MO | MySQL 8.0.45 |
|---|---|---|
SELECT '1' + '1' |
11 |
2 |
SELECT '2' + '3' |
23 |
5 |
SELECT '10' + '5' |
105 |
15 |
SELECT '1.5' + '2.5' |
1.52.5 |
4 |
SELECT CAST('1' AS CHAR) + CAST('1' AS CHAR) |
11 |
2 |
Note the last row: explicitly casting to CHAR and adding still concatenates, so this is not a literal-only path — it applies to real VARCHAR/CHAR columns too.
Scope check
SELECT CONCAT('1','1') + 0 returns 11 on both engines, which confirms the MO result above is CONCAT semantics leaking into the + operator (in MySQL the + result of CONCAT(...) is '11', coerced to 11 numerically).
Impact
- Silent data corruption in aggregates. A column declared
VARCHAR(extremely common for legacy schemas, CSV imports, and JSON-extracted values) summed with+produces a string instead of a number:MySQL would sum numerically.SELECT SUM(a + b) FROM t; -- if a,b are VARCHAR, MO concatenates then sums garbage
- Any monetary/quantity arithmetic over string-typed columns (a very common situation after
LOAD DATAinto a permissive schema, or after JSON extraction) silently yields wrong totals instead of failing. - Because there is no error, this class of bug survives testing and shows up as wrong business numbers.
- Reporting/BI queries written for MySQL that rely on implicit string→number coercion for
+all break silently.
Related but distinct
The reverse direction (numeric operand + non-numeric string) does match MySQL in erroring, e.g. SELECT 'abc' + 1 errors on both. So the divergence is specific to string + string, which MO routes to concatenation.
Expected behavior
+ between two string operands should coerce both to numbers and add, as MySQL does:
SELECT '1' + '1'; -- 2
SELECT '1.5' + '2.5'; -- 4
SELECT 'abc' + 1; -- error (or 1 under non-strict, matching MySQL) — but not concatenationIf MO intends + to concatenate for strings (as some dialects do), that must not be the default for a MySQL-compatible engine — MySQL users' arithmetic would silently change meaning. Either make + numeric (preferred) or reject string + string with a clear error so the divergence cannot pass silently.
Original canonical report (preserved verbatim)
Bug or Feature Request
Bug
Description
In string→DOUBLE implicit conversions, MatrixOne parses a C-strtod-style numeric prefix of the string and silently uses it, instead of MySQL's whole-string validation (junk → 0 with a warning). Combined with an int-vs-double typing split, the same dirty data either hard-errors or silently produces wrong numbers depending on an invisible detail:
| expression | MatrixOne (v3.x @ b24d1b3) | MySQL 8 |
|---|---|---|
'123abc' + 0 (int path) |
ERROR: cast to int, bad value 123abc | 0 (warning) |
'123abc' + 0.0 (double path) |
123 (prefix silently consumed) | 0 (warning) |
'12.7abc' + 0.0 |
12.7 | 0 |
'-5xyz' + 0.0 |
-5 | 0 |
'1e2zz' + 0.0 |
100 | 0 |
'abc' + 0.0 |
0 (correct by luck — empty prefix) | 0 |
' 42 ' + 0 |
42 (whitespace-trim OK) | 42 |
On real dirty data this silently corrupts numeric filters and aggregates:
CREATE TABLE dirty (s VARCHAR(20));
INSERT INTO dirty VALUES ('150abc'), ('50xyz'), ('abc');
SELECT * FROM dirty WHERE s > 100.0; -- returns '150abc' (MySQL: no rows)
SELECT SUM(s + 0.0) FROM dirty; -- 200 (MySQL: 0 with warning)'150abc' slips through a > 100 numeric business filter as if it were a valid 150 reading; the SUM aggregates garbage into the result. No warning is raised anywhere (checked: no SHOW WARNINGS entry on the double path).
The behavioral split makes it worse
s > 100(int literal) → hard error 20203, query dies — at least loud.s > 100.0(double literal) → silently wrong rows.
So whether dirty data crashes the query or silently corrupts results depends solely on whether the comparison literal parses as int or as double — an implementation detail no SQL author reasons about. Both deviate from MySQL (which answers 0-ish for both, with a classic truncation warning), but the double path is the dangerous one because it returns wrong data instead of an error.
Steps to Reproduce
v3.x @ b24d1b3, macOS arm64:
SELECT '123abc' + 0.0; -- 123 (expected 0 + warning per MySQL)
SELECT '12.7abc' + 0.0; -- 12.7
SELECT '-5xyz' + 0.0; -- -5
SELECT '1e2zz' + 0.0; -- 100
-- with a table (see above) the same trick passes WHERE filters and poisons SUM/AVGExpected behavior
Match MySQL's string-to-number rule for the double path too: attempt to parse the entire string (allowing leading/trailing whitespace); if it isn't a valid number, yield 0 and record a truncation warning rather than consuming a prefix. Alternatively, if strict behavior is chosen (hard error like the int path), it must apply uniformly to both paths — today's half-strict/half-lax split is the worst combination.
Versions
- MatrixOne commit
b24d1b3(2026-10-16), v3.x dev, macOS arm64
Additional context
- Data-quality reality: ETL upstreams routinely produce scaffolded/annotated values like '150abc' (unit suffixes) or '12.7µs'. Under MySQL these read as 0 with a visible warning; under MatrixOne they are silently treated as real numbers in comparisons and aggregations — the failure surfaces later as subtly wrong totals, with no trace.
- Related earlier report [Bug]: Comparing a decimal/exponent string with an integer fails with a cast error ('10.0' = 10) #30694 covered the comparison-operator typing split for well-formed strings ('10.0' = 10 errors). This issue is the junk-prefix dimension of the same conversion subsystem: well-formed-but-typed-literal errors, junk silently parses on one path and errors on the other.
Activity
Ariznawlll commentedon Oct 21, 2026
JOIN-condition evidence of the same split (v3.x @ b24d1b3):
CREATE TABLE a (id INT, k INT);
CREATE TABLE b (id INT, k_str VARCHAR(10));
INSERT INTO a VALUES (1,123),(2,456);
INSERT INTO b VALUES (1,'123'),(2,'45x'),(3,'0123');
SELECT * FROM a JOIN b ON a.k = b.k_str;
-- ERROR 20203 (HY000): invalid argument cast to int, bad value 45x <- entire join dies
SELECT * FROM a JOIN b ON a.k = b.k_str + 0.0;
-- 2 rows: (1,123,'123'), (1,123,'0123') <- '45x' silently became 45 (no match), no error
MySQL answers 2 rows for both (with truncation warnings on '45x'/'0123'-style conversions handled uniformly). In MatrixOne the int-typed join key kills the whole query, while coercing the same column through the double path turns garbage into numbers with zero diagnostics — one dirty row in one partition transforms a query from crashing into silently missing/mis-matching rows depending on how the author wrote the join predicate.
[-][Bug]: String-to-number conversion silently consumes junk prefixes on the double path ('150abc' > 100 passes, SUM counts it as 150)[/-][+][Bug]: Implicit string-to-number coercion is inconsistent between integer and DOUBLE paths[/+]XuPeng-SH commentedon Oct 22, 2026
Consolidates the related report from #30694. Both reports expose the same user-visible defect: implicit string-to-number behavior changes with the inferred numeric path. A well-formed decimal/exponent string can fail when compared with an integer literal (
'10.0' = 10,'1e1' = 10), while a junk-prefixed value can be silently consumed as a numeric prefix on the DOUBLE path ('150abc' + 0.0,s > 100.0,SUM(s + 0.0)). The same split also appears in JOIN predicates.Please define and apply one SQL-mode-aware coercion policy across comparison, JOIN, arithmetic, and aggregate paths. It must not depend on whether the other operand happened to infer as integer or DOUBLE, and must never silently treat a valid numeric prefix as the whole input. Preserve diagnostics (warning or error) consistently with the selected SQL mode.
Acceptance coverage should include:
123abcacross=,>, JOIN, arithmetic, and SUM/AVG, with consistent results and diagnostics under relevant SQL modes;Ariznawlll commentedon Oct 22, 2026
Predicate-path variant on today's main build (
3a1e42b430, 2026-10-22), same conversion subsystem:MatrixOne:
MySQL 8.0.45:
Note the MySQL detail: the WHERE comparison converts the column to DOUBLE (not the literal to INT), parses the numeric prefix of the string with a 1292 warning, and still resolves the predicate — rows come back. MatrixOne turns the same dirty literal into a hard statement abort via the int-cast path, so entire reports/ORM queries with a single garbage parameter value die instead of degrading with a warning. This is the predicate form of the int-vs-double split already documented in this issue's table (
WHERE s > 100errors,WHERE s > 100.0misfilters) — adding theint_col = 'junk'row since it's the shape most ORM string-typed inputs hit in practice (e.g. SQLAlchemyfilter(id == '1x')).XuPeng-SH commentedon Oct 23, 2026
Additional reproduction consolidated from #30908
The same implicit string-to-number coercion split also rejects a well-formed decimal string when the other arithmetic operand is inferred as an integer:
The matching DOUBLE-operand controls (
1.0 + '2.5') succeed. This is the well-formed-decimal counterpart to the malformed-prefix and integer-vs-DOUBLE cases already tracked here: inferred operand type changes the coercion path and user-visible result. The original environment, reproduction, and report remain on #30908.Add these cases to the same coercion-policy acceptance matrix: integer and DOUBLE arithmetic operands, both operand orders, decimal/exponent strings, and SQL-mode-appropriate result diagnostics. This is tracker consolidation only; no fix or shared immediate code root is claimed.
XuPeng-SH commentedon Oct 23, 2026
Additional prepared mixed-IN regression consolidated from #25222
Mixed numeric/string
INlists expose the same user-visible coercion contract, including a separate prepared-parameter path. A current nightly reproduced this SQL-prepared regression after the earlier literal-path fix:The literal form
SELECT '9.50' IN (7, '8', 9.5)and several list-order variants had previously passed; this report is specifically evidence that prepared type binding still reaches a failing tuple-cast path. The original report, prior-fix history, nightly evidence, and test references remain on #25222.Add mixed
IN/NOT INlists to the coercion matrix: VARCHAR expressions and bound parameters against integer, decimal, DOUBLE, and string list members; list-order permutations; SQL PREPARE and binaryCOM_STMT_EXECUTE; and NULL three-valued-logic controls. This consolidates the user-visible numeric-coercion contract without asserting that the IN tuple-cast path has the same immediate code root as the arithmetic/comparison cases. No fix is claimed.[-][Bug]: Implicit string-to-number coercion is inconsistent between integer and DOUBLE paths[/-][+][Bug]: Implicit numeric coercion and arithmetic over strings diverge across execution paths[/+]Ariznawlll commentedon Oct 28, 2026
Additional uncovered branches: unary minus/plus,
-/*operators, ABS(), and real-workload impactWhile running the jinpan_001 AP regression workload (the 200 Fact+Dim join queries from
matrixorigin/mo-nightly-regression, cases/jinpan_001) against nightlyb14d67a(2026-10-26 build, arm64 docker), I found that beyond the already-tracked branches above, these paths also diverge from MySQL 8.0. All repros are bare literals — no table involved, so they land directly in the constant/expression evaluation layer.Repro matrix (MO nightly b14d67a vs MySQL 8.0 official image)
SELECT -'915784.68'(unary minus on decimal string)-915784.68invalid argument cast to int, bad value 915784.68SELECT +'915784.68'(unary plus)915784.68SELECT '9.5' - '0.5'9invalid argument operator -, bad value [VARCHAR VARCHAR]SELECT '9.5' * 219invalid argument cast to int, bad value 9.5SELECT ABS('915784.68')915784.68SELECT 0 - '915784.68'-915784.68SELECT 'SJ000' > 200(non-numeric vs int)0(with warning)bad value SJ000SELECT 'PL000000000' + 00(with warning)Notes:
'9.5' / 2works and returns4.75, so the/path (or its result typing) already coerces correctly — divergence between operators suggests per-operator conversion selection, not one shared path.CAST('915784.68' AS SIGNED)returns915784fine, so explicit casts succeed; the failure is in implicit conversion target-type selection (varchar→int instead of varchar→double/decimal).'9.5' + '0.5'returns'9.50.5'— same as tracked [Bug]: '+' on two strings concatenates ('1'+'1'='11') instead of adding (MySQL: 2) #31169 but with decimal (non-integer) strings.Real-workload impact
The workload models SAP FI/SD data where amount columns (
dmbtr,wsl) are stored as varchar (as in the original production-synced data). Two patterns from the original queries fail unconditionally:Of the 200 queries, 59 (29.5%) are blocked by this conversion path with no workaround short of rewriting the queries (e.g. adding explicit
CAST(... AS DOUBLE)), and the workload mirrors real customer-facing regression SQL. Full error breakdown and repro data pipeline: the failures repeat deterministically across j_batch_001–010.Suggested addition to the acceptance checklist
-\'3.14\',+\'9.5\')-and*between string/string and string/int (\'9.5\' - \'0.5\',\'9.5\' * 2,0 - \'9\')\'SJ000\' > 200→ 0), matching[Not-null to 0](https://dev.mysql.com/doc/refman/8.0/en/type-conversion.html)semantics/, which already works (\'9.5\' / 2→ 4.75)Environment:
registry.cn-shanghai.aliyuncs.com/matrixorigin/matrixone:nightly-b14d67a2-arm64, reproduced 2026-10-28.Ariznawlll commentedon Oct 28, 2026
More uncovered lenient-coercion branches (from the same nightly
b14d67asweep)The following string→numeric shapes all error with 20203 on nightly
b14d67awhere MySQL 8.0 (official image, verified) coerces leniently. These are common in ETL/data-sync'd varchar columns (the jinpan_001 workload stores amounts and codes as varchar, mirroring production SAP sync):b14d67aSELECT '1e2' + 0(scientific notation string)100.0SELECT ' 12abc' + 0(leading-space + prefix number)12.0SELECT 'abc' + 0(pure text)0.0SELECT ' +3.5' + 0(signed with space)3.5SELECT '1,234.5' + 0(thousands separator)1.0(stops before comma)SELECT '' + 5(empty string)5.0Also one output-typing diff (value correct, type differs):
b14d67aSELECT '10' % 31.0(decimal)1(int)SELECT '007' + 07.07and a sibling regression re-report: hex-like strings (
'0x10','0b101') are parsed as numeric hex/binary in arithmetic, comparison, CAST and even row-filter predicates — re-opened in #25265 (comment linked there); that's the inverse policy problem (over-lenient where MySQL is strict-zero), likely sharing the same conversion-rooting.Suggested checklist additions:
'12abc'→12,'1e2'→100,' +3.5'→3.5) with warnings, not errors%and other operators return decimal-typed results from string operands (as+already does via the fixed [Bug]: integer + decimal string errors (1 + '2.5' → cast to int, MySQL returns 3.5) #30908 path)