Skip to content

[Bug]: GROUP_CONCAT reports incorrect truncation row diagnostics across multiple groups #28665

Closed

Description

@Ariznawlll

Description

GROUP_CONCAT emits warning 1260 after truncation, but with multiple GROUP BY groups the reported Row N diagnostics do not identify the same rows as MySQL. The diagnostic numbers are generated in MatrixOne's aggregate-finalization order rather than the input-row order used by MySQL.

Environment

  • Branch: main
  • Commit: e7d46d6dfb27696211ca828c55e245d3bd1b634d
  • Deployment: local standalone, 1 CN / 1 TN / 1 LogService
  • Oracle: MySQL 8.3.0

Steps to reproduce

create database gc_warning_row;
use gc_warning_row;
create table src (g int, id int, v varchar(20), primary key (g, id));
insert into src values
  (3,1,'p'), (3,2,'q'), (3,3,'r'),
  (1,1,'aa'),(1,2,'bbb'),(1,3,'cccc'),
  (2,1,'x'), (2,2,'yy'),(2,3,'zzz');

set session group_concat_max_len = 4;
select g, group_concat(v order by id separator '|') as gc
from src group by g order by g;
show warnings;

Actual behavior

MatrixOne returns the correct aggregate values, but the warning rows are:

Warning  1260  Row 8 was cut by GROUP_CONCAT()
Warning  1260  Row 5 was cut by GROUP_CONCAT()
Warning  1260  Row 3 was cut by GROUP_CONCAT()

The diagnostic set itself is wrong (3,5,8), not merely ordered differently.

Expected behavior

MySQL 8.3.0 returns the same aggregate values and these diagnostics:

Warning  1260  Row 2 was cut by GROUP_CONCAT()
Warning  1260  Row 5 was cut by GROUP_CONCAT()
Warning  1260  Row 8 was cut by GROUP_CONCAT()

MatrixOne should report warning row numbers according to the input-row diagnostic contract, independent of internal group finalization order.

Stability and controls

  • Reproducer: 3/3 on the stated MatrixOne commit; output SHA-256 was identical in all runs.
  • MySQL oracle: 3/3; output SHA-256 was identical in all runs.
  • Control: a single-group truncating aggregate still reports Row 2, and non-truncating aggregates emit no warning.
  • Result values and warning count remain correct; only the row diagnostics are incorrect.

Evidence

  • Reproducer: evidence/group_concat/group_concat_multi_group_warning.sql
  • MatrixOne output SHA-256: 04fb53283c78fee0b46e166f8c7de227f4e6f0ca80762b24653d9755974b16d8
  • MySQL output SHA-256: e4fdbe1e45202a0eeacd4b1cf15053c7525ab56631d375b351d3bd5ca43a06ec

Code analysis

In pkg/sql/colexec/aggexec/concat2.go, FlushWithContext finalizes executor groups and nextWarningRow increments one executor-global counter while each group is being rendered. Consequently, recordTruncation receives a position derived from finalization traversal and the number of entries visited in preceding groups, rather than the source row ordinal that produced the truncation. Internal group order can differ from SQL input order.

Regression coverage

After the fix, add a multi-group case with unequal value lengths and assert the exact SHOW WARNINGS row diagnostics, plus controls for reversed outer ORDER BY, multiple aggregate instances, and a non-truncating query that clears diagnostics.

Related

Activity

  1. added this to the MO-202609 milestone on Sep 11, 2026
  2. added
    kind/bug
    on Sep 11, 2026
  3. added theissue type on Sep 11, 2026
  4. added a commit that references this issue on Sep 12, 2026
    999e07e
  5. Ariznawlll commented on Sep 14, 2026

    @Ariznawlll
    CollaboratorAuthor

    测试版本

    • 分支:main
    • commit:07b25969bfea9d4b76d3bf05d5b0497e4f36eba0
    • 部署:本地独立 1 CN / 1 TN / 1 LogService;每轮均重新启动服务后执行。
    • 执行:每项 SQL 回归连续 3 轮,输出逐轮一致。

    原问题验证

    • GROUP_CONCAT 多分组截断 diagnostics 已报告正确的源行。

    Happy Path 覆盖

    • 覆盖多组正常拼接和每组结果。

    Unhappy Path 覆盖

    • 覆盖多个截断组,SHOW WARNINGS 稳定报告 Row 2、Row 5、Row 8。

    白盒验证

    • 以 MOTR 固定多组 truncation warning 输出。

    回归测试

    测试证据

    • 以上结果均在该 main commit 的独立环境获得;每轮无 stderr,三轮结果一致。

    测试结论

    测试通过。

  6. added 3 commits that reference this issue on Sep 17, 2026
    815023d
    d55ae69
    175cc6e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bug

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions