Skip to content

[Bug]: '+' on two strings concatenates ('1'+'1'='11') instead of adding (MySQL: 2) #31169

Closed as not planned

Description

@Ariznawlll

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:
    SELECT SUM(a + b) FROM t;   -- if a,b are VARCHAR, MO concatenates then sums garbage
    MySQL would sum numerically.
  • Any monetary/quantity arithmetic over string-typed columns (a very common situation after LOAD DATA into 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 concatenation

If 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.

Activity

  1. added
    kind/bug
    on Oct 26, 2026
  2. added this to the MO-202610 milestone on Oct 26, 2026
  3. added theissue type on Oct 26, 2026
  4. XuPeng-SH commented on Oct 26, 2026

    @XuPeng-SH
    Contributor

    Tracking consolidated into #30730. The canonical issue retains this report’s full reproduction/discussion and independent acceptance requirements. This is administrative consolidation, not a claim that the defect is fixed. Original evidence remains preserved here.

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