Repository navigation
Description
Description
GROUP_CONCAT returns an internal error when one non-NULL LONGTEXT or LONGBLOB input value is 65,536 bytes or larger, even when group_concat_max_len is large enough for the result.
The failure is tied to the size of one input row, not to the aggregate result size: a 65,535-byte value succeeds, and three 40,000-byte values concatenate to a 120,000-byte result.
Environment
- Branch:
main - Commit:
e7d46d6dfb27696211ca828c55e245d3bd1b634d - Deployment: local standalone (
1 CN / 1 TN / 1 LogService) - Oracle: MySQL 8.3.0, isolated local instance
Steps to reproduce
drop database if exists gc_single_value_boundary;
create database gc_single_value_boundary;
use gc_single_value_boundary;
create table src (id int primary key, txt longtext, bin longblob);
insert into src values
(1, repeat('x', 65535), unhex(repeat('61', 65535))),
(2, repeat('y', 65536), unhex(repeat('62', 65536))),
(3, repeat('z', 70000), unhex(repeat('63', 70000)));
set session group_concat_max_len = 300000;
select id, length(txt), length(bin) from src order by id;
select length(group_concat(txt order by id separator '')) from src where id = 1;
select length(group_concat(txt order by id separator '')) from src where id = 2;
select length(group_concat(txt order by id separator '')) from src where id = 3;
select length(group_concat(bin order by id separator '')) from src where id = 2;Actual behavior
The source values are stored at the requested lengths, and the 65,535-byte aggregate succeeds. Each 65,536-byte or 70,000-byte text/binary probe returns:
ERROR 20101 (HY000): internal error: group_concat: the length of the value is too long
Expected behavior
With group_concat_max_len = 300000, these one-row aggregates should return lengths 65,536 and 70,000. MySQL 8.3.0 returns the full values for the same SQL.
Stability and controls
- Reproducer: 3/3 for both
LONGTEXTandLONGBLOBat 65,536 and 70,000 bytes. - Lower-bound control: a 65,535-byte single value returns length 65,535.
- Aggregate-size control: three 40,000-byte values return one 120,000-byte result.
- Source-data control: direct
LENGTH(txt)andLENGTH(bin)return 65,535, 65,536, and 70,000. - MySQL 8.3.0 oracle: all text and binary probes return the requested lengths in 3/3 runs.
- Failure atomicity: read-only aggregate failures do not modify the source rows.
Evidence
MatrixOne (same output in runs 1-3):
control_plain_lengths 1 65535 65535
control_plain_lengths 2 65536 65536
control_plain_lengths 3 70000 70000
text_65535 65535
text_65536 ERROR 20101 ... length of the value is too long
text_70000 ERROR 20101 ... length of the value is too long
binary_65535 65535
binary_65536 ERROR 20101 ... length of the value is too long
binary_70000 ERROR 20101 ... length of the value is too long
many_small_values 120000
MySQL 8.3.0 (same output in runs 1-3):
text_65535 65535
text_65536 65536
text_70000 70000
binary_65535 65535
binary_65536 65536
binary_70000 70000
many_small_values 120000
Code analysis
pkg/sql/colexec/aggexec/agg_payload.go calls isValidGroupConcatUnit for string, binary, array, and JSON payload fields. pkg/sql/colexec/aggexec/concat2.go rejects any such field whose encoded byte length exceeds math.MaxUint16.
That guard is inconsistent with the current payload format: appendPayloadField stores field lengths as uint32, and the aggregate already supports results larger than 65,535 bytes. Removing or widening the obsolete per-field guard should be evaluated together with spill serialization and memory accounting.
Regression coverage
After the fix, add focused aggregate-executor coverage at 65,535/65,536 bytes and SQL regression coverage for LONGTEXT/LONGBLOB, ordered aggregation, and a forced-spill run with a value larger than 64 KiB.
Related
- fix(sql): report group concat truncation warnings #28504 / [Compatibility]: GROUP_CONCAT truncation does not emit MySQL warning 1260 #28252 cover truncation warnings, not per-row input rejection.
- [Bug]: GROUP_CONCAT fails for DECIMAL256, YEAR, UUID, GEOMETRY and GEOMETRY32 #27589 covers supported payload types, not values larger than 64 KiB.
- [Bug]: MD5(LONGBLOB) hashes only the first 65535 bytes #27798 and [Bug]: SHA2 truncates LONGTEXT input to 65,535 bytes #28103 were similar 65,535-byte boundaries in hash functions, but do not cover
GROUP_CONCAT.
Activity
[-][Bug]: GROUP_CONCAT rejects a single LONGTEXT or LONGBLOB value above 65,535 bytes[/-][+][Bug]: GROUP_CONCAT rejects a single string-like value above an internal uint16 limit[/+]Ariznawlll commentedon Sep 11, 2026
补充影响范围:该 65,535-byte 限制并非只影响表中的
LONGTEXT/LONGBLOB,由表达式生成的长字符串、二进制值和 JSON 也会触发同一个内部错误。当前 main
e7d46d6dfb27696211ca828c55e245d3bd1b634d:三个语句都直接报:
MySQL 8.3.0 分别返回
70000、70000和70009。JSON 还有额外问题:限制施加在 MatrixOne 的内部二进制 JSON 编码,而不是最终输出字节数。
repeat长度为65511时,JSON 的最终文本为65520bytes,可以聚合;只增加一个字符到65512,最终文本仅65521bytes,却因内部编码超过uint16上限而失败。因此,即使最终文本尚未达到 65,535 bytes,也可能报错。字符串、二进制和 JSON 三种表达式均连续 3 次复现;小于内部边界的 JSON 作为对照可正常返回。实现中的
isValidGroupConcatUnit对VARCHAR/TEXT/BLOB/VARBINARY/BINARY/JSON/ARRAY共用math.MaxUint16检查,说明这些类型都在同一问题范围内。Ariznawlll commentedon Sep 11, 2026
最新
main065a67528608c475d0219e0be6b7d454a58f7b1a复核:group_concat(repeat('x',70000))连续 3 次均报group_concat: the length of the value is too long;同一group_concat_max_len=1000000下 MySQL 8.3.0 返回 70000 bytes。内部 uint16 单值限制仍存在。fix: allow group_concat fields above 64 KiB (#28702)
test(function): cover GROUP_CONCAT spill and consolidate lock BVT (#2…
aunjgr commentedon Sep 13, 2026
Verified fixed by merged PR #28702 on main
4d18bee954400592c8b96546febcc7b987d448a3.The SQL regression passes for text and binary expressions of 65,535, 65,536, and 70,000 bytes with a sufficient
group_concat_max_len. The large JSON expression also succeeds and returns 70,009 output bytes. Existing payload and ordered-spill regressions pass, including large text, JSON, and float32-vector cases.The obsolete uint16 per-field restriction is removed; the existing payload format and output-length limit remain intact. Closing this issue as completed. The separate result-metadata issue #28663 and temporal/strict-write issues #28657/#28664 are not covered by this closure.
Ariznawlll commentedon Sep 14, 2026
测试版本
mainbb358ea76aeb44a6eed5079616e7e75ba35e75b9原问题验证
在
group_concat_max_len=100000下分别聚合 65,535、65,536、70,000 bytes 的单个文本值,以及含 70,000 bytes 字段的 JSON 值。连续 3 轮结果分别为65535/65536/70000/70009,不再触发原 uint16 单字段限制。Happy Path 覆盖
Unhappy Path 覆盖
group_concat_max_len降至 10 后,70,000 bytes 输入返回长度 10 并产生Warning 1260;这是配置输出上限的预期截断,不是单字段大小限制。白盒验证
修复 PR matrixone#28702 已合入当前 main;本轮从 SQL 聚合入口覆盖实际 payload 与输出上限路径。
回归测试
已加入 motr#169:
suites/14_issue_regression/t/issue_28579_28593_28595_28653_28657_28669_compatibility.test。定向用例连续 3/3 通过,共 150/150 statements。测试证据
6817c73d112d012ae784cbb9c0fc9b515a313e4fd1b1057f0abd7ea15125b9f6(3 轮一致)。测试结论
测试通过。
fix: allow group_concat fields above 64 KiB (matrixorigin#28702)
test(function): cover GROUP_CONCAT spill and consolidate lock BVT (ma…
fix: allow group_concat fields above 64 KiB (matrixorigin#28702)
test(function): cover GROUP_CONCAT spill and consolidate lock BVT (ma…
fix: allow group_concat fields above 64 KiB (matrixorigin#28702)
test(function): cover GROUP_CONCAT spill and consolidate lock BVT (ma…