Skip to content

[Bug]: integer + decimal string errors (1 + '2.5' → cast to int, MySQL returns 3.5) #30908

Closed as not planned

Description

@Ariznawlll

Description

Arithmetic with an integer left operand and a decimal-literal string right operand fails: 1 + '2.5' raises ERROR 20203: invalid argument cast to int, bad value 2.5, whereas MySQL evaluates it as 3.5. The string '2.5' is coerced to an integer type when the other operand is an integer, instead of promoting to DOUBLE/DECIMAL as MySQL does.

Environment

  • MatrixOne dev build 3a1e42b430, server reports 8.0.30-MatrixOne-v1.3.0
  • MySQL comparison: 8.0.45 (localhost)

Reproduction

SELECT 1 + '2.5';     -- MatrixOne: ERROR 20203 (HY000) invalid argument cast to int, bad value 2.5
                      -- MySQL: 3.5

SELECT 1 - '0.5';     -- MatrixOne: ERROR 20203 ... bad value 0.5 ;  MySQL: 0.5
SELECT '2.5' + 1;     -- MatrixOne: ERROR 20203 ... bad value 2.5 ;  MySQL: 3.5

-- Controls that do work on MatrixOne (shows the bug is integer-operand-specific):
SELECT 1.0 + '2.5';   -- 3.5  (double operand → correct)
SELECT 1 + '2';        -- 3    (integer string → correct)

Root cause

When one operand of a binary arithmetic operator is an integer and the other is a string, MatrixOne infers the string's type as integer too (rather than double), so a decimal string such as '2.5' is fed into an int cast and rejected. MySQL's numeric-type coercion treats the string as a numeric (DOUBLE) here, matching the value's actual decimal form.

Impact

  • Legitimate arithmetic over string-typed values (common when columns are VARCHAR holding numbers, e.g. int_col + varchar_col with fractional values) errors out instead of computing.
  • Breaks expressions like SELECT qty + '1.5' used in ETL/BI over loosely-typed schemas, which MySQL handles transparently.

Expected behavior

1 + '2.5' should return 3.5 (promote to DOUBLE), consistent with MySQL and with 1.0 + '2.5'.

Activity

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

    @XuPeng-SH
    Contributor

    This reproduction is now tracked under #30730, which covers implicit string-to-number coercion changing with inferred integer versus DOUBLE paths. Its acceptance criteria now include the well-formed decimal-string arithmetic cases from this report (1 + '2.5', 1 - '0.5', and '2.5' + 1) alongside the existing malformed-string cases.

    Closing this issue records tracking consolidation only. The reproduction and environment above remain available here; no fix is claimed.

  5. Ariznawlll commented on Oct 23, 2026

    @Ariznawlll
    CollaboratorAuthor

    Same root cause also affects comparison operators, not just arithmetic — worth covering in the fix:

    SELECT 1 < '2.5';   -- ERROR 20203 cast to int, bad value 2.5 ;  MySQL: 1
    SELECT 1 > '0.5';   -- ERROR 20203 ;  MySQL: 1
    SELECT 2 < '2.1';   -- ERROR 20203 ;  MySQL: 1

    So the integer-operand + decimal-string coercion bug spans +, -, *, <, >, <=, >= — any operator whose binder locks the string to int when the other side is an integer. (The = case is tracked in #30694.)

  6. added theissue type on Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

duplicatekind/bugneeds-triage

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions