Skip to content

[Compatibility]: Built-in integer arguments omit MySQL warnings for malformed strings #30218

Closed

Description

@Ariznawlll

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Branch Name

main

Commit ID

2ce4e58

Other Environment Information

  • MatrixOne runtime commit: 2ce4e58 (8.0.30-MatrixOne-v1.3.0)
  • MySQL reference: 8.0.46 source implementation; a live MySQL runtime was unavailable for this pass
  • MatrixOne paths checked: scalar arguments across all listed functions; VARCHAR-derived values and SQL PREPARE/EXECUTE for LPAD/RPAD/REPEAT/SPACE

Actual Behavior

For built-in functions that consume integer arguments, MatrixOne silently converts malformed VARCHAR text with an integer prefix and leaves SHOW WARNINGS empty. The omission is reproduced for LPAD, RPAD, REPEAT, SPACE, SUBSTRING/SUBSTR, LEFT, RIGHT, INSERT, ELT, SUBSTRING_INDEX, CHAR, CONV, MAKE_SET, EXPORT_SET, BIT_COUNT, ROUND, and TRUNCATE. Examples: REPEAT('x','3x') returns xxx, SUBSTRING('abcdef','2x') returns bcdef, ELT('2x','a','b','c') returns b, CHAR('65x') returns A, and ROUND(12.345,'2x') returns 12.350. The converted result follows the integer-prefix value, but the conversion diagnostic is missing.

For LPAD/RPAD/REPEAT/SPACE the same omission also reproduces with a VARCHAR-derived value and an SQL prepared-statement parameter. Other listed functions were checked with scalar malformed string arguments.

Expected Behavior

Preserve the current converted values and report MySQL's integer-conversion warning (1292, Truncated incorrect INTEGER value) when malformed string arguments are converted to integer parameters, consistently across the built-ins and execution paths.

Steps to Reproduce

Run each SELECT and inspect SHOW WARNINGS immediately afterward:

SELECT HEX(LPAD('x','3x','0'));
SHOW WARNINGS;
SELECT HEX(RPAD('x','3x','0'));
SHOW WARNINGS;
SELECT HEX(REPEAT('x','3x'));
SHOW WARNINGS;
SELECT HEX(SPACE('3x'));
SHOW WARNINGS;

SELECT HEX(SUBSTRING('abcdef','2x')),
       HEX(LEFT('abcdef','2x')),
       HEX(RIGHT('abcdef','2x')),
       HEX(INSERT('abcdef','2x',1,'X'));
SHOW WARNINGS;
SELECT ELT('2x','a','b','c'), SUBSTRING_INDEX('a,b,c',',','2x');
SHOW WARNINGS;

SELECT HEX(CHAR('65x')), CONV('10','2x','10'), MAKE_SET('2x','a','b','c');
SHOW WARNINGS;
SELECT EXPORT_SET('2x','Y','N',',',3), BIT_COUNT('3x');
SHOW WARNINGS;
SELECT ROUND(12.345,'2x'), TRUNCATE(12.345,'2x');
SHOW WARNINGS;

On MatrixOne, representative results are: HEX outputs 303078, 783030, 787878, 202020; substring-family outputs 6263646566, 6162, 6566, 615863646566; ELT/SUBSTRING_INDEX return b and a,b; CHAR/CONV/MAKE_SET return 41, 2, b; EXPORT_SET/BIT_COUNT return N,Y,N and 2; ROUND/TRUNCATE return 12.350 and 12.340. Each SHOW WARNINGS returns no rows.

MySQL 8.0.46 source: Item_string::val_int() calls longlong_from_string_with_check(), which emits ER_TRUNCATED_WRONG_VALUE when non-space characters remain after parsing. The affected functions obtain these integer parameters through val_int() in item_strfunc.cc and item_func.cc (for example, ROUND/TRUNCATE and BIT_COUNT). Live MySQL execution was unavailable; this expected warning is based on MySQL 8.0.46 source, not claimed as a direct runtime observation.

Additional information

Related warning-diagnostic issues checked: #30211 (division by zero), #30213 (STR_TO_DATE), #30214 (logarithm functions), and #30217 (FORMAT). Their behavior is not listed as a known exception in the mysql-compatibility-contract.

Activity

  1. added this to the MO-202610 milestone on Oct 14, 2026
  2. added theissue type on Oct 14, 2026
  3. changed the title [-][Compatibility]: LPAD/RPAD/REPEAT/SPACE omit warnings for string length conversion[/-] [+][Compatibility]: String arguments to common functions omit MySQL integer-conversion warnings[/+] on Oct 14, 2026
  4. changed the title [-][Compatibility]: String arguments to common functions omit MySQL integer-conversion warnings[/-] [+][Compatibility]: Built-in integer arguments omit MySQL warnings for malformed strings[/+] on Oct 14, 2026
  5. Ariznawlll commented on Oct 14, 2026

    @Ariznawlll
    CollaboratorAuthor

    补充 FIELD() 混合类型路径:在 MatrixOne 固定 runtime 2ce4e58af6f03b943ee288ffad81012766cf830a 与本地 MySQL 8.0.45 上执行 SELECT FIELD('x', 0, 'x'); SHOW WARNINGS;。两边都返回 1;MySQL 报 warning 1292 Truncated incorrect DOUBLE value: 'x',MO 的 SHOW WARNINGS 为空。值语义一致,差异仅是混合字符串/数值比较的转换诊断;归入本 issue 的 warning 丢失范围,不单独重复开单。

  6. XuPeng-SH commented on Oct 17, 2026

    @XuPeng-SH
    Contributor

    合并后独立实测(2026-10-17,冻结 main ba6b31941074cdaaf906ba2ec3883bc3b3eab85f,Linux/amd64、Go 1.27.1、匹配 make cgo 产物):

    独立通过真实 MySQL 协议重跑原 issue 的 9 组 SELECT / SHOW WARNINGS,覆盖 17 个 reported built-ins:返回值保持不变,合计 17 条预期 1292 告警;合法文本/数值/二进制、未选分支及空结果对照无多余告警。#30265/#30271 的显式 CAST 旧复现也通过。

    完整 function、colexec、plan/rule、plan 普通回归通过;plan 中两个现有 HNSW/Interval setup 跳过项不计通过。SQL/binary prepared 复用、列输入/NULL、分支选择、XML/CEIL 常量消费者、生成列及告警容量回归实际执行。

    本 PR 的原始 DML BVT 不全绿:普通/race 均有 4 个新 RETURNING 子场景在宿主机自动 spill cap=1 下失败。保留原断言,仅对测试夹具明确 64 MiB spill 预算的 overlay 对照,普通/race 各 67 个测试/子测试全部通过。该独立的新夹具问题已建 #30480,指派 iamlinjunhong;生产磁盘保护和生产源码未修改。不能把 overlay 对照说成原夹具已修复。

    原 issue 报告的 main 修复范围已验证,按约定转给 @Ariznawlll;新增独立问题继续由其单独 issue 跟踪。

  7. Ariznawlll commented on Oct 17, 2026

    @Ariznawlll
    CollaboratorAuthor

    测试版本

    原问题验证

    对 issue 中涉及的内建函数整数转换逐项执行原始非法字符串输入,3/3 检查九组 SELECT;累计 17 处应有的转换告警均是 1292,返回值与预期一致,不再静默吞告警。

    Happy Path 覆盖

    1. 有效整数参数在相同函数及预处理语句复用时值正确、无告警,3/3。
    2. 四个函数的表列输入与原始字面量输入一致,均报告对应诊断,3/3。

    Unhappy Path 覆盖

    1. 非法整数字符串输入在 17 个受影响调用点均报告 1292,3/3;执行后续有效语句告警状态清空。
    2. 预处理 REPEAT 的非法输入有 1292,改用有效输入后值正确且无旧告警,3/3。

    白盒验证

    确认 #30312 合入提交已进入上述官方 main;未将 #30480 的其他测试夹具问题归为本 issue 产品失败。

    回归测试

    MOTR 成对文件 suites/14_issue_regression/t/issue_30218_builtin_integer_warnings.test / r/issue_30218_builtin_integer_warnings.result 在汇总 PR #247,head f55a4b3813d44412ad6dc776ea51547480a0aee6;定向 3/3 通过。三项 SQL 回归合并定向 9/9 文件次、252/252 语句。完整 suite 尝试未全部通过且有既有无关用例失败;PR 未合入,集成 CI 未验证。

    测试证据

    • MOTR 回归提交
    • 隔离工作树 /private/tmp/mo-30265-qa-adWo0K/qa_cast_warnings.py 三轮逐函数告警和值断言。

    测试结论

    测试通过。

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