Skip to content

[Bug]: UPDATE IGNORE still errors on duplicate unique-key updates #25347

Closed

Description

@Ariznawlll

Is there an existing issue for the same bug?

I have checked the existing issues.

Existing issue #15345 covers INSERT IGNORE reporting errors for several incompatible rows. This issue is for UPDATE IGNORE: MySQL skips the duplicate-key update and keeps the row unchanged, while MatrixOne returns a duplicate-key error.

Branch Name

main

Commit ID

0e8602b78

Other Environment Information

  • Local MatrixOne built from latest origin/main
  • MySQL oracle: MySQL 8.0.45

Actual Behavior

UPDATE IGNORE still reports a duplicate unique-key error when the update would conflict with an existing unique key.

Observed on MatrixOne latest main:

ERROR 1062 (HY000): Duplicate entry '(b,x)' for key '(a,b)'

The data remains unchanged after the failed statement, but the statement should not error in MySQL-compatible IGNORE mode.

Expected Behavior

MySQL skips the conflicting update row and keeps it unchanged:

id  a     b
1   b     x
2   NULL  x
3   a     x

Steps to Reproduce

DROP DATABASE IF EXISTS mysql_compat_update_ignore_min;
CREATE DATABASE mysql_compat_update_ignore_min;
USE mysql_compat_update_ignore_min;

CREATE TABLE t (
  id int primary key,
  a varchar(16) null,
  b varchar(16) null,
  unique key uq_ab(a,b),
  index idx_ab(a,b,id)
);

INSERT INTO t VALUES (1,null,'x'),(2,null,'x'),(3,'a','x');

UPDATE t SET a='b', b='x' WHERE id=1;

UPDATE IGNORE t SET a='b', b='x' WHERE id=2;

SELECT id, a, b FROM t ORDER BY id;

Additional information

MySQL 8.0.45 result:

id  a     b
1   b     x
2   NULL  x
3   a     x

MatrixOne latest main at 0e8602b78:

ERROR 1062 (HY000): Duplicate entry '(b,x)' for key '(a,b)'

This was found while backfilling Model 3 NULL / unique composite-index compatibility coverage. The case also exercises MySQL's rule that unique indexes permit multiple NULL values, then checks UPDATE IGNORE behavior when a later update would create a non-NULL duplicate key.

Activity

  1. added
    kind/bug
    severity/s1
    on Jul 2, 2026
  2. added
    severity/s0
    and removed
    severity/s1
    on Jul 2, 2026
  3. added this to the MO-202607 milestone on Jul 2, 2026
  4. added theissue type on Jul 2, 2026
  5. added and removed
    severity/s0
    on Jul 2, 2026
  6. assigned and unassigned on Jul 15, 2026
  7. Ariznawlll commented on Jul 15, 2026

    @Ariznawlll
    CollaboratorAuthor

    最新 main 可复核验证(MOTR)

    实际执行命令

    # MatrixOne:全新隔离 worktree,构建并启动最新 main
    git fetch origin main
    git worktree add --detach /tmp/matrixone-motr-pr48-main-20260715 origin/main
    make thirdparties
    CGO_CFLAGS='-I$(pwd)/thirdparties/install/include' make build
    ./mo-service -launch ./etc/launch/launch.toml
    
    # MOTR:先录制并人工检查 result,再做非 record 稳定性回归
    ./motr --record --do-test '14_issue_regression.issue_(25151|25347|25384|25502|25546|25617|25626)' -v
    ./motr --repeat 5 --do-test '14_issue_regression.issue_(25151|25347|25384|25502|25546|25617|25626)' -v
    • 源码 HEAD:f1c0a92d882dbdad469ffd2c96f607796207c797
    • 服务端核对:git_version()=f1c0a92d8
    • 总结果:35/35 success,380/380 条语句符合预期,0 failed。

    本 issue 实际用例

    1. 创建包含复合唯一键 uq_ab(a,b) 的表,并插入两个允许共存的 (NULL,'x')。
    2. 先让 id=1 占有唯一键 ('b','x')。
    3. 对 id=2 执行 UPDATE IGNORE ... SET a='b',b='x',制造唯一键冲突。
    4. 断言语句不报 1062;id=2 保持 (NULL,'x');全表只有一行 ('b','x')。
    5. 该 case 连续执行 5 次,5/5 成功。
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