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
[Bug]: CAST AS CHAR without a length silently truncates large strings #32336
CAST(expr AS CHAR) without an explicit length silently truncates a 100,000-byte string to 65,535 bytes. The input itself is not truncated. This can corrupt or invalidate large application payloads read through a cast.
Minimal SQL reproduction
SELECT
LENGTH(CONCAT(REPEAT('a', 50000), REPEAT('b', 50000))) AS input_bytes,
LENGTH(CAST(CONCAT(REPEAT('a', 50000), REPEAT('b', 50000)) ASCHAR)) AS cast_bytes;
Server
input_bytes
cast_bytes
MatrixOne 8.0.30-MatrixOne-v4.2.1
100000
65535
MySQL 8.0.46
100000
100000
The MatrixOne instance used image matrixorigin/matrixone@sha256:c95d1b468e3fc5f4f2b377da14f4601e7efefa6eb143758636d60114a5bbb436. Both queries were executed over the MySQL protocol. The same truncation was also observed when reading a 100,000-byte stored LONGTEXT column.
Expected behavior
Without a specified length, preserve the complete string, as the MySQL control does. MySQL's CAST documentation describes length inference and widening for large strings.
Impact and workaround
An Astra Edge dispatch result can be larger than 64 KiB. Casting its LONGTEXT result column to CHAR truncates the result before the client reads it. Reading the LONGTEXT column directly preserves the complete value and avoids the extra cast.
Related: #28103 recorded the same 65,535-byte behavior for CAST(... AS CHAR) as a control while diagnosing SHA2; this issue isolates the CAST compatibility problem itself.
Administrative consolidation of #32374 into this issue. This is not a fix claim.
Additional acceptance coverage retained from #32374:
JSON CAST(... AS CHAR) must preserve values larger than 65,535 bytes. A 100,000-byte input must remain complete and valid JSON, or produce an explicit error if a limit applies; silent truncation is not acceptable.
The existing LONGTEXT and large-string acceptance cases remain in scope.
Activity
MatrixAdventurer commentedon Nov 7, 2026
分级建议:s1/P1。理由:无长度 CAST 静默截断,与 MySQL 权威语义背离,属正确性缺陷,可能损坏上层读取的载荷;正文有最小 SQL 对照,非崩溃类。
模块/目录:pkg/sql 表达式层 CAST→CHAR 的长度推断(建议在类型系统/表达式求值侧修复)。
疑似重复:未发现独立跟踪单(正文引用的 #28103 记录同一 65535 现象,仅作对照组)。
建议负责人:尚无 assignee;正文作者 XuPeng-SH 已完成对照,建议交内核类型/表达式方向评审。
本操作由LW授权的MOI智能体提交
Ariznawlll commentedon Nov 9, 2026
结论
测试不通过。当前 main 的无长度 CHAR CAST 仍会在 CONCAT 输入上静默截断 100000 字节字符串。
关键证据
main@c99234dcf4c94d1ff9d372917cd35041f1a3a682,隔离本地 CN,运行时git_version()为c99234dcf4。CAST(CONCAT(REPEAT('a',50000),REPEAT('b',50000)) AS CHAR),输入长度均为 100000,结果长度均为 65535;相邻控制CAST(REPEAT('a',100000) AS CHAR)返回 100000。待解决点
test(plan): align omitted-length CHAR cast UTs with unbounded TEXT ta…
fix(sql): keep REVERSE and LEAST/GREATEST intact for TEXT cast results
test(function): align greatest JSON+date TEXT peer with its VARCHAR r…
fix(sql): keep string/numeric, temporal and EXTRACT paths for TEXT casts
fix(sql): keep timestampdiff string temporal paths for TEXT casts
fix(sql): keep operator rewrites and date-extraction string paths for…
fix(sql): keep signed INT64 coercion, DATE parsing and HEX encoding f…
test(dtype): align BIN/SPACE TEXT-column expectations with signed INT…
fix(sql): keep FLOAT64 domain of composed CEIL/FLOOR over omitted-len…
fix(sql): keep base numeric domains for all CEIL/FLOOR render composi…
fix(sql): keep SUBSTRING_INDEX base FLOAT64 route for TEXT counts
fix(sql): keep omitted-CHAR CEIL/FLOOR numeric contract across query …
fix(sql): keep omitted-CHAR numeric contracts across set operations
fix(sql): keep ENUM order-key rewrite firing for untagged bind scopes
XuPeng-SH commentedon Nov 20, 2026
Administrative consolidation of #32374 into this issue. This is not a fix claim.
Additional acceptance coverage retained from #32374:
CAST(... AS CHAR)must preserve values larger than 65,535 bytes. A 100,000-byte input must remain complete and valid JSON, or produce an explicit error if a limit applies; silent truncation is not acceptable.Assignee retained:
matrix-meow.