Skip to content

[Compatibility]: STRICT mode persists truncated GROUP_CONCAT through write statements #28664

Closed

Description

@Ariznawlll

Description

Under STRICT_TRANS_TABLES, MatrixOne persists a value truncated by GROUP_CONCAT through INSERT ... SELECT and CREATE TABLE ... AS SELECT. MySQL promotes warning 1260 to an error in these data-writing contexts and leaves the target empty or uncreated.

Plain SELECT, non-strict DML, and INSERT IGNORE behavior already match; the gap is the missing strict-mode promotion during materialization.

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_strict_materialization;
create database gc_strict_materialization;
use gc_strict_materialization;

create table src (id int primary key, v varchar(20));
insert into src values (1, 'aa'), (2, 'bbb'), (3, 'cccc');
create table dst_strict (gc varchar(100));

set session group_concat_max_len = 4;
set session sql_mode = 'STRICT_TRANS_TABLES';

select group_concat(v order by id separator '|') from src;
show warnings;

insert into dst_strict
select group_concat(v order by id separator '|') from src;
select count(*), max(hex(gc)) from dst_strict;

create table ctas_strict as
select group_concat(v order by id separator '|') as gc from src;

Controls:

insert ignore into dst_ignore
select group_concat(v order by id separator '|') from src;

set session sql_mode = '';
insert into dst_nonstrict
select group_concat(v order by id separator '|') from src;

Actual behavior

MatrixOne stores the truncated value in both strict paths:

plain_select: aa|b, warning 1260 Row 2 was cut by GROUP_CONCAT()
dst_strict:   count=1, hex=61617C62
ctas_strict:  count=1, hex=61617C62

Expected behavior

With STRICT_TRANS_TABLES, both writing statements should return error 1260. dst_strict should remain empty, and ctas_strict should not be created. MySQL 8.3.0 behaves this way.

INSERT IGNORE and non-strict mode should continue to persist aa|b with warning 1260, which both systems already do.

Stability and controls

  • Reproducer: 3/3 for strict INSERT ... SELECT and CTAS.
  • Plain SELECT control: both systems return aa|b with warning 1260.
  • INSERT IGNORE control: both systems persist one aa|b row with warning 1260.
  • Non-strict control: both systems persist one aa|b row with warning 1260.
  • MySQL 8.3.0 strict oracle: 3/3 error 1260; destination remains empty and CTAS table is absent.
  • MatrixOne post-write check: source rows remain intact; only the unexpected target row/table is created.

Evidence

All three MatrixOne runs are byte-identical, and all three MySQL runs are byte-identical.

MatrixOne STRICT: dst_strict rows=1; ctas_strict rows=1
MySQL STRICT: ERROR 1260; dst_strict rows=0; ctas_strict does not exist
Both INSERT IGNORE/non-strict: one row, hex 61617C62, warning 1260

Code analysis

The aggregate records ER_CUT_VALUE_GROUP_CONCAT through AppendWarningBatch / AppendWarningDiagnostic. The warning transport correctly reaches the session, as shown by SHOW WARNINGS, but the DML/CTAS materialization path does not promote it according to strict SQL mode before commit.

The exact promotion point requires executor/frontend ownership analysis; this report does not assume that the aggregate itself should return an error in ordinary SELECT.

Regression coverage

After the compatibility fix, add SQL coverage for plain SELECT, strict INSERT-SELECT, strict CTAS, INSERT IGNORE, and non-strict mode. Assert target-table atomicity, warning/error 1260, and prepared execution.

Related

Activity

  1. added this to the MO-202609 milestone on Sep 11, 2026
  2. added theissue type on Sep 11, 2026
  3. changed the title [-][Compatibility]: STRICT mode persists truncated GROUP_CONCAT through INSERT-SELECT and CTAS[/-] [+][Compatibility]: STRICT mode persists truncated GROUP_CONCAT through write statements[/+] on Sep 11, 2026
  4. Ariznawlll commented on Sep 11, 2026

    @Ariznawlll
    CollaboratorAuthor

    在最新 main(e7d46d6dfb27696211ca828c55e245d3bd1b634d)继续扩大写入路径后,确认同一 strict-mode warning 提升缺口还覆盖 UPDATE、REPLACE ... SELECT 和 INSERT ... SELECT ... ON DUPLICATE KEY UPDATE,并非只发生在原 issue 的 INSERT-SELECT/CTAS。

    源聚合在 group_concat_max_len=4 下产生 aa|b 和 warning 1260,目标表原值为 sentinel:

    SET SESSION sql_mode='STRICT_TRANS_TABLES';
    
    UPDATE dst
    SET gc=(SELECT GROUP_CONCAT(v ORDER BY id SEPARATOR '|') FROM src)
    WHERE id=1;
    
    REPLACE INTO dst
    SELECT 1, GROUP_CONCAT(v ORDER BY id SEPARATOR '|') FROM src;
    
    INSERT INTO dst
    SELECT 1, GROUP_CONCAT(v ORDER BY id SEPARATOR '|') FROM src
    ON DUPLICATE KEY UPDATE gc=VALUES(gc);

    MatrixOne 三条语句都成功,并把目标值改为 aa|b(hex 61617C62)。MySQL 8.3.0 三条语句都返回 ERROR 1260 Row 2 was cut by GROUP_CONCAT(),目标值保持 sentinel(hex 73656E74696E656C)。

    显式事务中的 UPDATE 后执行 ROLLBACK,两端都恢复/保留 sentinel,说明普通事务回滚本身正常;错误在于 MatrixOne 没有在 strict 写入语句提交前把 aggregate warning 提升为 statement error。

    以上矩阵连续 3 轮一致:

    • MatrixOne 输出 SHA-256:cc33eb3fb986d459e734161d9a72ad6af5b4f082bdb45990f9a4142a7d881b91
    • MySQL 输出 SHA-256:e6cf18ddc437d8a7b37f752e1085b36019b0069a653b6a116866b8f74239948a

    因此修复和回归范围需要覆盖所有把 SELECT aggregate 结果写入表的 statement 类别,而不能只在 INSERT 或 CTAS 的某个入口处理。

  5. added
    severity/s0
    and removed on Sep 11, 2026
  6. XuPeng-SH commented on Sep 11, 2026

    @XuPeng-SH
    Contributor

    Triage decision: promote to severity/s0 and assign to aunjgr.

    Evidence: 3/3 runs show STRICT_TRANS_TABLES incorrectly persists GROUP_CONCAT-truncated values through INSERT-SELECT, CTAS, UPDATE, REPLACE, and INSERT ... ON DUPLICATE KEY UPDATE, while MySQL raises error 1260 and preserves the target state. This is a confirmed data-correctness/statement-atomicity compatibility violation. The fix must be at the warning-to-error materialization boundary and cover all write paths without changing non-strict or INSERT IGNORE behavior.

  7. assigned and unassigned on Sep 14, 2026
  8. Ariznawlll commented on Sep 14, 2026

    @Ariznawlll
    CollaboratorAuthor

    测试版本

    • 分支:main
    • Commit:a72a224ce85fd13aa919fb56dab58b8c60b366dc(2026-09-14 获取的最新 origin/main)
    • 环境:本地单节点 CN/TN/LogService,通过 MySQL 协议执行 SQL。

    原问题验证

    连续 3 轮执行同一组 GROUP_CONCAT 截断场景,输出一致。普通 SELECT GROUP_CONCAT(...) 返回截断值 aa|b,并产生 MySQL warning 1260(Row 2 was cut by GROUP_CONCAT())。在 STRICT_TRANS_TABLES 下,写语句不会再将该 warning 静默带入写入结果。

    Happy Path 覆盖

    • 普通 SELECT 可返回截断结果 aa|b,且可通过 SHOW WARNINGS 获取 1260 告警。
    • INSERT IGNORE 与非严格模式 INSERT 保持 MySQL 兼容行为:写入截断值 aa|b(hex 61617C62),并保留 1260 warning。

    Unhappy Path 覆盖

    在 STRICT_TRANS_TABLES 下逐项验证截断写路径均以 1260 失败,且目标对象保持原子性:

    • INSERT:报错 1260,目标表行数为 0。
    • CTAS:报错 1260,目标表未创建。
    • UPDATE、REPLACE、INSERT ... ON DUPLICATE KEY UPDATE:均报错 1260;预置值 sentinel 未被修改(hex 73656E74696E656C)。
    • Prepared INSERT:执行时报错 1260,目标表无写入。

    白盒验证

    在同一 commit 执行:

    go test -vet=off ./pkg/sql/compile -run '^(TestGroupConcatWarningAttemptOutcomes|TestPreparedGroupConcatFloorFreshAndRetryCompile|TestStrictWriteGroupConcatPromotionPolicy|TestGroupConcatCutMarkerSurvivesDiagnosticRetentionAndRemoteEnvelope|TestStrictWriteGroupConcatCutReturnsMySQLError1260|TestStrictWriteRequiresCompleteWorkerReporting|TestStrictWriteRejectsIncompleteOldWorkerReport)$' -count=1 -v
    

    测试整体 PASS,覆盖截断标记跨 worker 传递、严格写路径提升为 MySQL 1260、预编译/重试编译及不完整 worker 报告拒绝写入的分支。

    回归测试

    已新增 MOTR 回归用例:matrixorigin/motr#173。

    • suites/14_issue_regression/t/issue_28664_group_concat_strict_write.test
    • suites/14_issue_regression/r/issue_28664_group_concat_strict_write.result

    执行 ./motr --repeat 3 14_issue_regression.issue_28664_group_concat_strict_write -v,3/3 轮通过,合计 123/123 条语句通过(每轮 41 条)。现有 test/distributed/cases/function/group_concat_strict_write.sql 也覆盖了该严格写入矩阵。

    测试证据

    测试结论

    测试通过。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/compatibilitykind/bugseverity/s0

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions