Repository navigation
Description
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 around4294967295is 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
fix: preserve expression result metadata and coercion contracts (#28941)
Ariznawlll commentedon Sep 17, 2026
当前 main 复测未通过,转回 @XuPeng-SH 继续处理。
验证环境:本地单机 MatrixOne,由远端 main
0370bb4d6b118da29e164c54aa34ee010ed897bc全新构建;PR #28941 merge commitf6f8c0c885f999cbde3b0d394194b0a4a74176ae已包含。独立执行 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。
fix: preserve expression result metadata and coercion contracts (matr…
fix: preserve expression result metadata and coercion contracts (matr…
fix: close expression result contract regressions (#29075)
Ariznawlll commentedon Sep 20, 2026
测试版本
maind8ddce92b1c5c172111b50aefe6b6b200b2589cb原问题验证
验证
INET_NTOA对字符串数值、浮点字面量和 prepared 参数的转换。'1.0'、1.0均返回0.0.0.1,1.6和 prepared 参数1.6均按预期舍入并返回0.0.0.2。连续执行 3 次通过。覆盖范围
边界与异常路径
自动化回归
issue_28892_inet_ntoa_prepared.test。33/33成功。测试结论
测试通过。
fix(spatial): support geodetic discrete distance units (#28830)