Skip to content

[Compatibility]: CONV and BIN reject strings with trailing text instead of using numeric prefixes #28392

Closed

Description

@Ariznawlll

MatrixOne version

Latest main at f72ca9efbeb3a7c673701e4a135cc6670c33cfde. MySQL control: 8.3.0.

What is different

CONV() and BIN() reject character inputs containing trailing nonnumeric text. MySQL consumes the valid leading digit sequence, and returns zero when no valid leading digit exists. This is especially inconsistent because MySQL defines BIN(N) as equivalent to CONV(N, 10, 2).

Reproduction

SELECT
  CONV('123xyz', 10, 16),
  CONV('xyz123', 10, 16),
  CONV('  +15tail', 10, 16),
  CONV('  -15tail', 10, -16);

SELECT
  BIN('7x'),
  BIN('-2tail'),
  BIN('abc'),
  BIN('');

MatrixOne aborts with:

invalid input: invalid conv input "123xyz" for base 10
invalid argument cast to int, bad value 7x

MySQL 8.3 returns:

CONV: 7B, 0, F, -F
BIN:  111,
      1111111111111111111111111111111111111111111111111111111111111110,
      0,
      NULL

The constant matrix reproduces identically in three runs per engine. A six-row VARCHAR column containing the same valid-prefix, invalid-prefix, signed, and empty inputs shows the same difference.

Controls

  • Complete valid inputs across bases 2, 10, 16, and 36 match MySQL.
  • Signed output bases, BIGINT saturation boundaries, invalid base values, NULL, and ordinary integer/floating inputs match.
  • HEX/UNHEX, including odd-length hex input and invalid digits, also match.
  • MatrixOne's BIT_COUNT('7x'), BIT_COUNT('-2tail'), and BIT_COUNT('abc') already use the MySQL-compatible prefix rule, returning 3, 63, and 0.

Root cause

CONV uses parseConvStrictString, which validates every character after the optional sign and raises an error as soon as a digit is invalid for the source base (source). BIN has only numeric overloads (registry), so string input reaches the ordinary strict string-to-integer cast instead of the prefix conversion used by MySQL.

Expected behavior

CONV should stop at the first invalid digit for the selected source base and use the parsed prefix, or zero if no digit is usable. BIN should apply the equivalent base-10 prefix conversion, matching MySQL.

Activity

  1. added this to the MO-202609 milestone on Sep 8, 2026
  2. added theissue type on Sep 8, 2026
  3. self-assigned this
    on Sep 8, 2026
  4. added a commit that references this issue on Sep 9, 2026
    cfcfa7a
  5. XuPeng-SH commented on Sep 11, 2026

    @XuPeng-SH
    Contributor

    Implemented in #28650. CONV/BIN now consume MySQL-compatible numeric prefixes for character and binary operands, including signs, leading whitespace, invalid-prefix zero, and empty-string NULL behavior. Added constant/column/binary regression coverage and MySQL 8.4 black-box validation.

  6. added a commit that references this issue on Sep 11, 2026
    92fafca
  7. Ariznawlll commented on Sep 12, 2026

    @Ariznawlll
    CollaboratorAuthor

    已在最新官方 main efb2c5084957ac90273a3f625668fc6a784562c4 验证。

    • 原始场景:CONV(123xyz,10,16) 返回 7B,BIN(7x) 返回 111,不再因尾随文本拒绝。\n- Happy path:有效数字前缀正确转换。\n- 边界控制:无有效前缀 xyz123/abc 返回 0,不会误解析;会话后续查询正常。\n- 自动化:已加入 MOTR PR (aoe)[daily-update]: correct the memory node size #165,issue_28210_28211_28392_28454_28456_28460_28461_functions;TestIssue28392ConvBinNumericPrefixes 当前 main 定向通过,MOTR 三轮复跑 12/12 case、252/252 statements 一致通过。\n\n测试通过。
  8. added 6 commits that reference this issue on Sep 17, 2026
    bdc66d9
    37b8fda
    1dd14d4
    09e73cc
    362eb86
    2dee94f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/compatibilitykind/bug

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions