Skip to content

[Bug]: insert ignore values reported error Inconsistent with MySQL behavior #15345

Closed

Description

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Branch Name

main

Commit ID

85734e6

Other Environment Information

- Hardware parameters:
- OS type:
- Others:

Actual Behavior

mo insert ignore values目前和mysql差异:
1: null约束报错,mysql不报错
企业微信截图_83957d89-7354-420b-b17d-f3023d0376a4
企业微信截图_50f89551-2692-4e43-b636-fc713798da9e

2.外键约束报错,mysql不报错
企业微信截图_51c6b1e0-5286-4230-94ad-896bd9223c23

3.超出类型值范围报错,mysql不报错
企业微信截图_8b145678-3969-40fb-ad09-63b84bc716be

4.类型不匹配报错,mysql不报错
企业微信截图_c0b33fd2-9f98-4b63-9abc-c46272eaa612

Expected Behavior

No response

Steps to Reproduce

1.
create table insert_ignore_04 (product_id INT NOT NULL AUTO_INCREMENT,product_name VARCHAR(255) NOT NULL,quantity_in_stock INT DEFAULT 0,price DECIMAL(10, 2) NOT NULL,PRIMARY KEY (product_id));
insert ignore into insert_ignore_04(product_name, price) VALUES('Laptop', 1200.00),('Monitor', 150.00),('Keyboard', NULL),('Mouse', 15.00);
insert ignore into insert_ignore_04(product_name, quantity_in_stock,price) VALUES(NULL, 5,1200.00),('board',6, NULL),('phone',NULL,1500.00);
select * from insert_ignore_04;

2.
create table parent_table(parent_id INT AUTO_INCREMENT PRIMARY KEY,parent_name VARCHAR(255) NOT NULL);
create table child_table(child_id INT AUTO_INCREMENT PRIMARY KEY,child_name VARCHAR(255) NOT NULL,parent_id INT,FOREIGN KEY (parent_id) REFERENCES parent_table(parent_id)
);
insert ignore into parent_table (parent_name) VALUES ('Parent 1'), ('Parent 2'), ('Parent 3');
insert ignore into child_table (child_name, parent_id) VALUES('Child 1', 1),('Child 2', 2),('Child 3', 4),('Child 4', 1);

3.
create table insert_ignore_02(c1 int,c2 decimal(6,2),unique key(c1));
insert ignore into insert_ignore_02 values("abc",1234.56);

4.
create table insert_ignore_05(id TINYINT,created_at DATETIME);
insert ignore INTO insert_ignore_05 (id, created_at) VALUES(130, '2024-04-03 10:00:00'),(-129, '2024-04-03 11:00:00'),(100, '2024-04-03 12:00:00');

Additional information

No response

Activity

  1. ghost added
    kind/bug
    on Apr 7, 2024
  2. ghost added
    severity/s0
    on Apr 7, 2024
  3. ghost added this to the 1.2.0 milestone on Apr 7, 2024
  4. modified the milestones: 1.2.0, 1.3.0-Backlog on Apr 7, 2024
  5. ghost added
    bvt
    on Apr 7, 2024
  6. ouyuanning commented on Apr 11, 2024

    @ouyuanning
    Contributor

    语法不一致的部分暂不做处理

  7. ouyuanning commented on Apr 16, 2024

    @ouyuanning
    Contributor

    语法不一致的部分暂不做处理

  8. ouyuanning commented on Apr 19, 2024

    @ouyuanning
    Contributor

    语法不一致的部分暂不做处理

  9. ouyuanning commented on Apr 24, 2024

    @ouyuanning
    Contributor

    锦赛统一处理吧。
    近期先只处理性能问题就好了。语法的问题,可以留到后面的版本再处理

  10. 56 remaining items

  11. Repository owner unassigned on Aug 6, 2026
  12. ghost assigned on Aug 6, 2026
  13. slyunnn commented on Aug 7, 2026

    @slyunnn

    #15345 回归验证结论:通过:外键问题已修复

  14. ck89119 commented on Aug 11, 2026

    @ck89119
    Contributor

    @slyunnn 你看下上面我和龙冉的comment

    未修复的3个类型是MySQL中不合理的地方,mo不兼容这些,报错是期望行为

  15. slyunnn commented on Aug 11, 2026

    @slyunnn

    Regression and extended verification for #15345 (2026-08-11)

    Verification environment

    • MatrixOne main: d01c85974f9540f8baa2e768ca86fea952941fe2
    • The previously verified commit
      43c89646245491ef68557699a0e1a394de8b1919
      is included in this main.
    • MOTR branch: test/issue-15345-insert-ignore-fk
    • MOTR commit: 8e7bb69a6521491ef9b2e93be7e0f5dea2f64b22
    • Topology: local single-node MatrixOne service.

    Regression verification

    Reproduced the original foreign-key scenario:

    • Input includes valid rows referencing parents 1 and 2, plus one row referencing nonexistent parent_id = 4.
    • The invalid foreign-key row was skipped.
    • All valid rows were inserted successfully.

    Result: passed.

    Extended verification

    • Nullable foreign key:

      • parent_id = NULL was inserted successfully.
      • A row referencing nonexistent parent_id = 9 was skipped.
    • Mixed unique-key and foreign-key conflicts:

      • Existing rows remained unchanged.
      • Rows with either a duplicate unique key or invalid foreign key were skipped.
      • Valid rows in the same multi-row INSERT IGNORE statement were inserted.
    • FOREIGN_KEY_CHECKS = 0:

      • Rows with unmatched parent references were inserted successfully.
      • Nullable foreign-key rows were also inserted.

    MOTR regression

    • Added:
      • suites/14_issue_regression/t/issue_15345_insert_ignore_fk.test
      • suites/14_issue_regression/r/issue_15345_insert_ignore_fk.result
    • Record: 20/20 statements passed.
    • Replay: 20/20 statements passed.

    Scope clarification

    NOT NULL violations, invalid type casts, and numeric overflows remain different from MySQL’s permissive INSERT IGNORE conversion behavior. They are outside the accepted scope of this issue and are not treated as foreign-key row-
    level ignore defects.

    Final conclusion

    The intended behavior of #15345 is fixed on current main: INSERT IGNORE processes foreign-key conflicts per row,
    drops only invalid rows, and retains other valid rows in the same statement.

    The original scenario and all extended foreign-key cases passed. The issue can be closed after merging the MOTR
    regression PR.

  16. assigned and unassigned on Aug 11, 2026
  17. assigned and unassigned on Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bvtkind/buglong-term-job

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions