You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Compatibility]: bounded conversion functions derive maximum-width types in CTAS #28387
Latest main at f72ca9efbeb3a7c673701e4a135cc6670c33cfde. MySQL control: 8.3.0.
What is different
MatrixOne exposes the bounded results of INET_NTOA, INET6_ATON, and INET6_NTOA as maximum-width VARCHAR(65535)/VARBINARY(65535). MySQL exposes the actual maximum widths. The difference becomes persistent schema when the functions are used in CTAS.
Reproduction
CREATETABLEtASSELECT
INET_NTOA(16909060) AS v4_text,
INET6_ATON('2001:db8::1') AS network_bytes,
INET6_NTOA(UNHEX('20010DB8000000000000000000000001')) AS v6_text;
SHOW CREATE TABLE t;
MatrixOne derives:
`v4_text`varchar(65535) NOT NULL,
`network_bytes` varbinary(65535) DEFAULT NULL,
`v6_text`varchar(65535) DEFAULT NULL
INFORMATION_SCHEMA.COLUMNS.CHARACTER_MAXIMUM_LENGTH reports the same widths. This was reproduced in three independent databases per engine.
Controls
The stored values themselves are correct: 1.2.3.4, 20010DB8000000000000000000000001, and 2001:db8::1.
Ordinary secondary indexes can be created on all three derived columns in both engines, so this is a result metadata/schema derivation problem rather than a value or index-build failure.
INET_ATON correctly derives BIGINT UNSIGNED in both engines and is not included in the affected string/binary width set.
Compatibility contract and root cause
MySQL's network-function reference specifies VARBINARY(16) for IPv6 output, VARBINARY(4) for IPv4 output, and a maximum INET6_NTOA text length of 39; its CTAS example derives VARCHAR(39).
MatrixOne's function registry returns bare T_varbinary/T_varchar without setting a width for INET6_ATON and INET6_NTOA or INET_NTOA. CTAS consequently materializes MatrixOne's default maximum width.
Expected behavior
These functions should expose their bounded result widths so CTAS and client result metadata do not inflate them to 65535. At minimum, INET6_ATON should be VARBINARY(16), INET6_NTOA should be VARCHAR(39), and INET_NTOA should match MySQL's declared result width.
CREATETABLEt_binASSELECT BIN(1) AS v;
CREATETABLEt_convASSELECT CONV('10',10,2) AS v;
CREATETABLEt_hexASSELECT HEX(1) AS v;
CREATETABLEt_unhexASSELECT UNHEX('41') AS v;
SHOW CREATE TABLE 的类型对照:
function MatrixOne MySQL 8.3
BIN VARCHAR(65535) VARCHAR(65)
CONV VARCHAR(65535) VARCHAR(65)
HEX(integer) VARCHAR(65535) VARCHAR(16)
UNHEX BLOB VARBINARY(4)
Latest main (f72ca9efbeb3a7c673701e4a135cc6670c33cfde) shows that the same return-type derivation also affects bounded encryption, compression, and hash functions.
Source table:
CREATETABLEsource(s VARCHAR(12), b VARBINARY(12));
CREATETABLEderivedASSELECT COMPRESS(s) c,
UNCOMPRESS(COMPRESS(s)) u,
UNCOMPRESSED_LENGTH(COMPRESS(s)) n,
AES_ENCRYPT(b,'key') a,
MD5(s) m,
SHA1(s) h1,
SHA2(s,512) h2,
CRC32(s) crc
FROM source;
SHOW CREATE TABLE derived;
MatrixOne derives:
c BLOB
u BLOB
n BIGINT
a BLOB
m VARCHAR(65535)
h1 VARCHAR(65535)
h2 VARCHAR(65535)
crc INT UNSIGNED
MySQL 8.3 derives:
c VARBINARY(66)
u LONGBLOB
n INT
a VARBINARY(16)
m VARCHAR(32)
h1 VARCHAR(40)
h2 VARCHAR(128)
crc INT UNSIGNED
The hash widths are fixed by their algorithms, and the maximum AES_ENCRYPT()/COMPRESS() output sizes are calculable from the input width. MatrixOne instead uses the generic maximum VARCHAR/BLOB return types. CRC32() is a control whose CTAS type already agrees with MySQL.
Value behavior was checked separately: normal hashes match MySQL; current COMPRESS() values are mutually readable by MatrixOne and MySQL; default ECB AES ciphertext is byte-identical and mutually decryptable. The issue here is the schema inferred for persisted expressions rather than the computed value.
Root cause confirmed: the affected built-ins returned bare wide planner types. CTAS persists that expression metadata, so bounded values were materialized as VARCHAR(65535), VARBINARY(65535), or BLOB even though the scalar values were correct.
The fix derives bounded metadata through checked, fail-closed planner arithmetic and preserves text/binary domains:
INET_NTOA: VARCHAR(31)
INET6_NTOA: VARCHAR(39)
BIN/CONV: VARCHAR(65)
HEX numeric: VARCHAR(16)
HEX(string): 2x declared input byte bound
UNHEX: ceil(input byte bound / 2), binary
MD5/SHA1/SHA2: VARCHAR(32/40/128)
AES_ENCRYPT: PKCS#7 padded binary bound
UNCOMPRESSED_LENGTH: INT with int32 executor storage
UNCOMPRESS remains BLOB because output length is not statically bounded
array HEX remains TEXT as a lossless fallback
One important implementation-specific correction came from adversarial validation: MySQL's C-zlib formula gives 66/30 for VARCHAR(12)/VARBINARY(12), but MatrixOne's current Go zlib stream can produce 68/32 for incompressible input. The PR therefore uses the codec-aware 68/32 bounds; a real 48-byte high-entropy valid UTF-8 value produced 68 bytes and CTAS materialized VARBINARY(68) without overflow.
Validation completed:
Targeted function tests passed, including overflow/unknown fallback, NULL propagation, compression bounds, AES, and existing compression behavior.
New distributed BVT func_bounded_result_metadata.test: 15/15 passed.
Rebuilt local server and verified real CTAS values plus information_schema metadata.
Full package execution only hit unrelated environment prerequisites: missing ONNX testdata and the existing WASM test's /test write path.
Please review #28420 for the intentional scope boundaries and the codec-specific compression rationale.
Activity
[-][Compatibility]: network functions derive VARCHAR/VARBINARY(65535) in CTAS[/-][+][Compatibility]: bounded conversion functions derive maximum-width types in CTAS[/+]Ariznawlll commentedon Sep 8, 2026
同一结果类型宽度根因继续扩展到基本进制/二进制转换函数;为避免重复 issue,建议由本 issue 一并覆盖:
SHOW CREATE TABLE的类型对照:LOWER('ABC')和UPPER('abc')的控制表在 MatrixOne 与 MySQL 都能正确派生VARCHAR(3),说明 CTAS 能保留函数返回宽度;差异来自这些转换函数注册的返回类型没有设置宽度,而不是 CTAS 无条件放大字符串列。网络函数与上述转换函数的值计算、NULL 传播和普通索引创建仍正常。问题是函数结果元数据会直接固化成过宽或不同类别的持久列类型。
Ariznawlll commentedon Sep 8, 2026
Latest
main(f72ca9efbeb3a7c673701e4a135cc6670c33cfde) shows that the same return-type derivation also affects bounded encryption, compression, and hash functions.Source table:
MatrixOne derives:
MySQL 8.3 derives:
The hash widths are fixed by their algorithms, and the maximum
AES_ENCRYPT()/COMPRESS()output sizes are calculable from the input width. MatrixOne instead uses the generic maximumVARCHAR/BLOBreturn types.CRC32()is a control whose CTAS type already agrees with MySQL.Value behavior was checked separately: normal hashes match MySQL; current
COMPRESS()values are mutually readable by MatrixOne and MySQL; default ECB AES ciphertext is byte-identical and mutually decryptable. The issue here is the schema inferred for persisted expressions rather than the computed value.XuPeng-SH commentedon Sep 8, 2026
Implemented and submitted as PR #28420: #28420
Root cause confirmed: the affected built-ins returned bare wide planner types. CTAS persists that expression metadata, so bounded values were materialized as VARCHAR(65535), VARBINARY(65535), or BLOB even though the scalar values were correct.
The fix derives bounded metadata through checked, fail-closed planner arithmetic and preserves text/binary domains:
One important implementation-specific correction came from adversarial validation: MySQL's C-zlib formula gives 66/30 for VARCHAR(12)/VARBINARY(12), but MatrixOne's current Go zlib stream can produce 68/32 for incompressible input. The PR therefore uses the codec-aware 68/32 bounds; a real 48-byte high-entropy valid UTF-8 value produced 68 bytes and CTAS materialized VARBINARY(68) without overflow.
Validation completed:
func_bounded_result_metadata.test: 15/15 passed.Please review #28420 for the intentional scope boundaries and the codec-specific compression rationale.
fix(function): preserve bounded conversion result metadata (#28420)
Ariznawlll commentedon Sep 9, 2026
测试版本
maina9d3b8b857c44f1249e682c91d4d62a914eb7d20原问题验证
验证网络相关返回值参与 CTAS 时的推导宽度正确,并可建立索引。
Happy Path 覆盖
Unhappy Path 覆盖
本 issue 的风险为类型宽度推导,非非法网络文本解析;以三种不同最大宽度输出交叉验证,确认不会采用过窄的公共宽度而导致截断。
白盒验证
不适用:以
SHOW COLUMNS、索引创建与查询结果验证外部类型契约。回归测试
suites/14_issue_regression/t/issue_28389_28387_network_return_types.test。--record --repeat 3和非 record--repeat 3均通过;PR 共 21/21 用例、321/321 条语句成功。测试证据
各宽度场景、索引和输出均重复 3 次。
测试结论
测试通过。
fix(function): preserve bounded conversion result metadata (matrixori…
fix(function): preserve bounded conversion result metadata (matrixori…
fix(function): preserve bounded conversion result metadata (matrixori…