Skip to content

[Bug]: CAST to fixed-length CHAR errors instead of truncating like MySQL #25249

Closed

Description

@Ariznawlll

Bug Report

MatrixOne Version

Latest origin/main verified locally at 33e96877604ad4b847ea7d5c55eb09429de1a5b6.

Reproduce Steps

select cast(12345 as char(3)), length(cast(12345 as char(3)));

Expected Behavior

MySQL truncates the character result to the requested length and returns:

123    3

Actual Behavior

MatrixOne returns an error:

ERROR 20101 (HY000): internal error: Can't cast '12345' from BIGINT type to CHAR type. 12345 is larger than Dest length 3

Notes

Found while completing the MySQL-compatible CAST / CONVERT target-type matrix. Passing fixed-length BINARY(4) cast rows were added to BVT; this failing CHAR(3) row was excluded.

Activity

  1. added
    kind/bug
    severity/s1
    on Jun 30, 2026
  2. added this to the MO-202607 milestone on Jul 1, 2026
  3. added theissue type on Jul 1, 2026
  4. added
    ai-easy
    on Jul 1, 2026
  5. added
    ai-light
    and removed
    ai-easy
    on Jul 2, 2026
  6. daviszhen commented on Jul 3, 2026

    @daviszhen
    Contributor

    fixed

  7. Ariznawlll commented on Jul 3, 2026

    @Ariznawlll
    CollaboratorAuthor

    Verified on latest origin/main at 7e70bee (fix cast #25340).

    Result: fixed.

    Validation SQL:

    select cast(12345 as char(3)) as numeric_char,
           length(cast(12345 as char(3))) as numeric_len;
    select cast('abcdef' as char(3)) as string_char,
           length(cast('abcdef' as char(3))) as string_len;

    Observed result:

    numeric_char  numeric_len
    123           3
    
    string_char   string_len
    abc           3
    

    Regression has been added to motr in matrixorigin/motr#39, commit b8f14f4 (issue_25249_cast_char_truncation).

    Motr validation passed together with the related issue regressions:

    SUMMARY | total=6 success=6 failed=0 skipped=0 | stmts=46 ok=46 fail=0
    
  8. Ariznawlll commented on Jul 3, 2026

    @Ariznawlll
    CollaboratorAuthor

    Regression case added in matrixorigin/motr#39.

    Case: 14_issue_regression.issue_25249_cast_char_truncation

    Target branch marker: @target-branch: main

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

ai-lightkind/bugseverity/s1

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions