Skip to content

[Compatibility]: IGNORE skips constraint violations without populating MySQL warnings #28254

Closed

Description

@Ariznawlll

Problem

MatrixOne correctly skips rows rejected by primary/unique keys and CHECK constraints under INSERT IGNORE or UPDATE IGNORE, but it leaves the statement warning area empty.

MySQL records one warning for each ignored row, preserving the original condition code. Without these warnings, a client sees only the reduced affected-row count and cannot determine which integrity rule caused data to be omitted.

This issue is limited to warning reporting for rows that are already skipped correctly; it is separate from value-conversion behavior under non-strict SQL modes.

Version

  • MatrixOne main: e7bb0572235ec4bac81eb098eb0ad8900f0065ab
  • MySQL: 8.3.0

Primary and unique key example

create database codex_ignore_warning;
use codex_ignore_warning;
create table uq(id int primary key, v int unique);
insert into uq values(1,10);

insert ignore into uq values(1,11),(2,10),(3,30);
show warnings;
select * from uq order by id;

Both databases retain the same rows:

1  10
3  30

MatrixOne returns no warnings. MySQL returns:

Warning  1062  Duplicate entry '1' for key 'uq.PRIMARY'
Warning  1062  Duplicate entry '10' for key 'uq.v'

CHECK examples

create table ck(
  id int primary key,
  v int,
  constraint ck_pos check(v > 0)
);

insert ignore into ck values(1,-1),(2,2),(3,-3);
show warnings;

update ignore ck set v=-v;
show warnings;
select * from ck order by id;

Both databases keep only (2,2). MatrixOne returns no warnings after either DML statement. MySQL returns two warning 3819 rows after the insert and one warning 3819 row after the update:

Warning  3819  Check constraint 'ck_pos' is violated.

Expected behavior

For every row skipped because IGNORE downgraded an integrity error, MatrixOne should populate the warning area with the original error code and a useful message, matching MySQL's observable warning semantics.

Activity

  1. added this to the MO-202609 milestone on Sep 5, 2026
  2. added
    kind/bug
    on Sep 5, 2026
  3. added theissue type on Sep 5, 2026
  4. self-assigned this
    on Sep 5, 2026
  5. XuPeng-SH commented on Sep 9, 2026

    @XuPeng-SH
    Contributor

    Summary

    Fixes #28254.

    INSERT IGNORE and UPDATE IGNORE now expose warnings for rows skipped by
    primary-key, unique-key, and CHECK constraint violations. The warning count is
    one per skipped row, while SHOW WARNINGS retains the existing bounded
    diagnostic set.

    Design

    • Use one bounded warning accumulator per execution boundary. It preserves the
      exact total count and at most 64 rendered diagnostics, then sends one batch
      to the owning session.
    • Cover all production duplicate paths: hash-build deduplication,
      dedup-join probing, and the multi-primary/unique-key PreInsertUnique
      arbiter used by ordinary multi-key INSERT IGNORE.
    • Carry logical unique-key names and types in PreInsertUkCtx, so serialized
      composite/index keys are rendered as user-visible values instead of
      internal encodings.
    • Run CHECK assertions in IGNORE mode as a barrier filter: rejected rows are
      removed, but the assertion records ER_CHECK_CONSTRAINT_VIOLATED warnings.

    Correctness and unhappy paths

    • Diagnostics are flushed only after the operator/function completes
      successfully; cancellation, encoding failure, or another statement error
      cannot leak partial warnings into a later statement.
    • A row that conflicts with multiple constraints produces one duplicate
      warning for the first constraint selected by the existing arbitration order.
    • After the 64-record retention limit, key rendering stops but the exact total
      count continues to be accumulated, avoiding unbounded memory and formatting
      work.
    • Diagnostic rendering is best-effort and cannot turn an already-ignored row
      into a statement failure. Legacy/cached plans without the new metadata use a
      safe fallback name.
    • Internal dedup operations are not changed unless they belong to a statement
      carrying IGNORE semantics.

    Validation

    • go test -count=1 ./pkg/vm/process ./pkg/sql/colexec/preinsertunique ./pkg/sql/colexec/hashbuild ./pkg/sql/colexec/dedupjoin ./pkg/sql/plan ./pkg/sql/plan/function ./pkg/sql/compile
    • go test -race -count=1 ./pkg/vm/process ./pkg/sql/colexec/preinsertunique
    • Local MatrixOne BVT for issue_28254_ignore_warnings.test: 30/30 checks
      passed in each of 3 runs, covering existing and same-batch PK/unique
      duplicates, ordinary single-PK deduplication, UPDATE IGNORE, and CHECK
      violations. The mo-tester wrapper exits non-zero afterward because its
      report-move step cannot find report/*.txt; the three execution summaries
      are all 100% with zero failed or abnormal cases.
    • git diff --check

    The full repository CI has not been waited on locally.

  6. added a commit that references this issue on Sep 11, 2026
    065a675
  7. Ariznawlll commented on Sep 11, 2026

    @Ariznawlll
    CollaboratorAuthor

    测试版本

    • 分支:main;官方 main 基线:4a7bfac4f91fe3e4519e25ed82654556e38d670a。
    • 实际运行构建:7013fbbd6e152ba31da2d3dbba7012ac7f8b8462,本地 2 CN、1 TN、1 Log 拓扑;修复提交 065a67528608c475d0219e0be6b7d454a58f7b1a 已包含,且为上述官方 main 基线祖先。
    • 验证日期:2026-09-11。

    原问题验证

    围绕 INSERT IGNORE 与 UPDATE IGNORE 的约束违规路径复测,确认被跳过的行会保留 MySQL 兼容警告,且不会写入或改写非法数据。

    Happy Path 覆盖

    1. 预置合法行 (1,10) 后,批量 INSERT IGNORE 中的合法行 (3,30) 成功写入。
    2. 查询最终数据仅为 (1,10)、(3,30),证明合法行和被跳过行的行为可区分。

    Unhappy Path 覆盖

    1. 同一批插入覆盖主键重复和 CHECK 约束违反:SHOW WARNINGS 分别返回 1062 与 3819,非法行不落库。
    2. UPDATE IGNORE 将值改为负数时返回 3819,原行 (1,10) 保持不变。
    3. 上述场景连续执行 3 轮,结果一致。

    白盒验证

    本 issue 为 SQL 兼容性行为,使用可观察的 SHOW WARNINGS、最终行集与错误码进行黑盒验收;无额外内部状态断言。

    回归测试

    测试证据

    • 定向 3 轮:9/9 用例成功,102/102 SQL 结果匹配。
    • 全量 14_issue_regression 运行中,本用例通过;其余 6 个既有用例的预期差异与本改动无关,未修改其基线。

    测试结论

    测试通过。

  8. added 3 commits that reference this issue on Sep 17, 2026
    15befcf
    86b5812
    8c49836
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