Skip to content

[Compatibility]: INET_NTOA rejects MySQL numeric-convertible values and prepared parameters #28892

Closed

Description

@Ariznawlll

Description

INET_NTOA only exposes native integer, floating-point, and decimal overloads in MatrixOne. Values that MySQL converts through its numeric context—such as fractional numeric strings, Boolean, DATE/TIME, JSON numbers, and untyped prepared parameters—are either rejected during binding or fail with a cast error at execution. A single such row aborts the query instead of producing the per-row IPv4 string or NULL that MySQL returns.

Environment

  • MatrixOne branch: main
  • MatrixOne commit: 0c3a04f390adaf6281fd592a49778ea5b1155e67
  • MatrixOne deployment: local standalone, 1 CN / 1 TN / 1 LogService
  • Reference: local MySQL 8.0.45

Steps to reproduce

SELECT INET_NTOA('1.0'), INET_NTOA('1.6'),
       INET_NTOA('4294967295.9');

SELECT INET_NTOA(TRUE), INET_NTOA(FALSE);
SELECT INET_NTOA(CAST('2024-01-02' AS DATE)),
       INET_NTOA(CAST('00:00:02' AS TIME));
SELECT INET_NTOA(JSON_EXTRACT(CAST('1.6' AS JSON), '$'));

PREPARE p FROM 'SELECT INET_NTOA(?)';
SET @x = 1.6;
EXECUTE p USING @x;
DEALLOCATE PREPARE p;

MatrixOne result

Representative errors are:

ERROR 20203 (HY000): invalid argument cast to int, bad value 1.0
ERROR 20203 (HY000): invalid argument function inet_ntoa, bad value [BOOL]
ERROR 20203 (HY000): invalid argument function inet_ntoa, bad value [DATE]
ERROR 20203 (HY000): invalid argument function inet_ntoa, bad value [JSON]
ERROR 20203 (HY000): invalid argument cast to uint64, bad value 1.6

The final error is from the uncast prepared parameter. INET_NTOA(CAST(? AS DOUBLE)) and INET_NTOA(CAST(? AS DECIMAL(20,6))) are usable workarounds.

MySQL 8.0.45 result

INET_NTOA('1.0')             0.0.0.1
INET_NTOA('1.6')             0.0.0.1
INET_NTOA('4294967295.9')    255.255.255.255
INET_NTOA(TRUE/FALSE)        0.0.0.1 / 0.0.0.0
INET_NTOA(DATE '2024-01-02') 1.52.214.230
INET_NTOA(TIME '00:00:02')   0.0.0.2
INET_NTOA(JSON number 1.6)   0.0.0.2
prepared @x = 1.6            0.0.0.2

Scope and controls

  • Literal, VARCHAR-column, prepared, CTAS, and view execution paths were covered; the results reproduce identically in 3/3 runs.
  • A VARCHAR table containing 0.4, 0.5, 0.6, positive/negative fractions, and values around 4294967295 is processed row-by-row by MySQL but aborts at the first fractional string in MatrixOne.
  • Native DOUBLE, FLOAT, and DECIMAL columns match MySQL, including negative and upper-bound rounding behavior.
  • BIT, ENUM, and SET values also match MySQL through existing casts.
  • MySQL's constant CAST(... AS DOUBLE) path differs from its DOUBLE-column path at exact half values; that MySQL-internal ambiguity is not used as the basis of this report.
  • Negative and out-of-range native integer handling fixed for [Bug]: INET_NTOA wraps out-of-range integers into IPv4 addresses #28215 remains correct.

Code analysis

The INET_NTOA registration in pkg/sql/plan/function/list_builtIn.go contains only integer, FLOAT/DOUBLE, and DECIMAL overloads and uses generic fixed-type matching. VARCHAR is selected through an integer cast, which rejects fractional text instead of applying MySQL's function numeric conversion. BOOL, temporal, and JSON inputs have no admitted conversion. An untyped ? is bound to UINT64, so a later fractional runtime value fails before reaching the real/decimal executor.

Expected behavior

INET_NTOA should accept the same numeric-convertible expression families as MySQL and apply the source type's established numeric conversion before range validation. Prepared parameters should preserve or resolve their runtime numeric domain rather than being fixed to UINT64. The behavior must remain consistent for literals, columns, prepared execution, CTAS, and views.

Activity

  1. added this to the MO-202609 milestone on Sep 15, 2026
  2. added theissue type on Sep 15, 2026
  3. self-assigned this
    on Sep 15, 2026
  4. added a commit that references this issue on Sep 17, 2026
    f6f8c0c
  5. Ariznawlll commented on Sep 17, 2026

    @Ariznawlll
    CollaboratorAuthor

    当前 main 复测未通过,转回 @XuPeng-SH 继续处理。

    验证环境:本地单机 MatrixOne,由远端 main 0370bb4d6b118da29e164c54aa34ee010ed897bc 全新构建;PR #28941 merge commit f6f8c0c885f999cbde3b0d394194b0a4a74176ae 已包含。独立执行 3/3,结果一致。

    核心复现仍失败:INET_NTOA('1.0') 报 ERROR 20203: invalid argument cast to int, bad value 1.0;PREPARE p FROM 'SELECT INET_NTOA(?)' 后以 @x=1.6 执行,报 ERROR 20203: invalid argument cast to uint64, bad value 1.6。

    期望是按 MySQL 的数值上下文完成转换,而不是在绑定/转换阶段拒绝数值可转换的字符串或 prepared 浮点参数。当前验收未通过,issue 保持 Open。

  6. added 2 commits that reference this issue on Sep 17, 2026
    385154b
    fe9c331
  7. added a commit that references this issue on Sep 19, 2026
    aeee7db
  8. Ariznawlll commented on Sep 20, 2026

    @Ariznawlll
    CollaboratorAuthor

    测试版本

    • 分支:main
    • commit:d8ddce92b1c5c172111b50aefe6b6b200b2589cb
    • 日期:2026-09-20

    原问题验证

    验证 INET_NTOA 对字符串数值、浮点字面量和 prepared 参数的转换。'1.0'、1.0 均返回 0.0.0.1,1.6 和 prepared 参数 1.6 均按预期舍入并返回 0.0.0.2。连续执行 3 次通过。

    覆盖范围

    1. 字符串数值输入。
    2. 浮点字面量输入。
    3. prepared statement 运行时浮点参数。

    边界与异常路径

    1. 整数边界附近的浮点舍入结果一致。
    2. 字符串与数值参数走不同转换入口时结果一致。

    自动化回归

    • motr#193 新增 issue_28892_inet_ntoa_prepared.test。
    • MOTR 目标集连续运行 3 轮,共 33/33 成功。

    测试结论

    测试通过。

  9. added a commit that references this issue on Sep 20, 2026
    5e1e93a
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