Repository navigation
Description
Is there an existing issue for the same bug?
- I have checked the existing issues, including closed issues.
This is an FK-specific residual related to closed #28254. That issue and its fix explicitly cover PK/UK/CHECK warnings for rows already skipped correctly; they do not cover the FK-only case below. #30715 concerns LOAD DATA IGNORE, whose warning-producing path is different. Open #33478 concerns UPDATE/DELETE IGNORE statement failure and sibling loss, not a successful plain INSERT with a missing diagnostic.
Branch Name
main
Commit ID
Other Environment Information
- Test date: 2026-11-30
- Deployment: local standalone
mo-service, 1 CN / 1 TN / 1 LogService, MySQL text protocol - Runtime identity checked with
git_version()='98b20975'andSELECT 42 - Comparator: MySQL 8.0.46, InnoDB
Description
Plain INSERT IGNORE correctly skips a child row whose foreign key references no parent, but MatrixOne leaves the warning area empty. MySQL exposes warning 1452 for the skipped orphan row.
The final stored rows are correct on both engines. This issue is limited to diagnostic compatibility, not persisted-data integrity.
Steps to Reproduce
This discriminator deliberately includes no duplicate-key input, so duplicate arbitration cannot hide or replace the FK warning:
CREATE TABLE p(id INT PRIMARY KEY);
INSERT INTO p VALUES(1);
CREATE TABLE c(
id INT PRIMARY KEY,
pid INT NOT NULL,
CONSTRAINT fk_c_pid FOREIGN KEY(pid) REFERENCES p(id)
);
INSERT IGNORE INTO c VALUES(1,999),(2,1);
SHOW WARNINGS;
SELECT * FROM c ORDER BY id;Actual Behavior
| Observable | MatrixOne | MySQL 8.0.46 |
|---|---|---|
| Statement result | Success, 1 affected row | Success, 1 affected row |
SHOW WARNINGS |
Empty | Warning 1452 for (1,999) |
| Fresh-connection rows | (2,1) |
(2,1) |
An orphan-only statement likewise affects zero rows on both engines, but only MySQL exposes warning 1452. In a mixed duplicate/orphan/valid batch, both engines retain the same valid rows; MySQL reports warnings 1062 and 1452, whereas MatrixOne reports only 1062.
Expected Behavior
When INSERT IGNORE skips a row because of an FK violation, SHOW WARNINGS should expose the corresponding warning 1452 (and the statement warning count should include it), while continuing to skip only the offending row.
Stability and Controls
- Reproduced in two independent MatrixOne databases and two independent MySQL databases.
- Covered orphan-only, orphan+valid, duplicate+orphan+valid, non-IGNORE, and fully valid controls.
- Non-IGNORE orphan input returns error 1452 and stores no rows on both engines.
- Fully valid
INSERT IGNOREstores both rows with no warnings on both engines. - Every final readback used a fresh connection, and post-probe
SELECT 42succeeded.
Likely Mechanism from Read-only Source Inspection
Plain INSERT IGNORE reaches buildInsertIgnoreFkFilter: bind_insert.go.
Only the LOAD path (loadWarnings=true) wraps the FK predicate in _load_fk_ignore_check; ordinary INSERT IGNORE installs the raw FK-OK predicates as a FILTER. Rows are therefore removed correctly, but no warning-producing function is called: bind_insert.go.
A regression should include the no-duplicate discriminator above so that the FK diagnostic is tested independently of duplicate-key warnings.
Activity
fix(sql): preserve accepted INSERT IGNORE rows across constraint fail…
XuPeng-SH commentedon Nov 30, 2026
转测前实测:从 #33528 最终
main@1dfcb9cf2e10ac9676411658f3eb8bc7ba155e5b本地构建(Go 1.27.1 / Linux amd64),经真实 MySQL TCP 连接隔离单 CN,git_version()返回完整 SHA。两个新库共 33/33 检查通过,子表均无自增列,原始INSERT IGNORE INTO c VALUES(1,999),(2,1)均只留(2,1),SHOW WARNINGS各有且仅有一个 1452。孤儿单行也返回 1452 warning;无IGNORE时 1452 error 且严格回滚整批;全合法批次无 warning 且两个合法行均入库。服务正常退出。本轮未在旧版重跑,旧版告警为空来自原 issue;未另外检查混合 duplicate+orphan 的警告计数、生产/多 CN 配置或二进制协议。QA 可按原用例复核警告数量和新连接回读。
Ariznawlll commentedon Dec 1, 2026
已在当前官方 main
ba6081a1eaf7210acefd7181da5bfc07db10e8bc完成原场景验收并关闭。git_version()与精确源码 SHA 一致;binary SHA-256:a856cb87a5b5af72d1b4aa9536a13919e8b46c819adc5f25688d9742f98a0848。INSERT IGNORE成功且仅影响 1 行,SHOW WARNINGS返回 warning 1452,新连接严格读到(2,1)。SELECT 42及新连接健康检查通过。dcb9259f9e7b8d0fe482c784a07fb524a9a0c540,本地 offline 967/967 PASS;未叠加旧 PR374/353。新 PR 的远端检查刚启动,不提前冒称全绿。证据:
qa-33521-constraints/main-ba608/。