Bug #121461 INSERT ... SELECT duplicate key reports the source table instead of the target
Submitted: 9 Oct 1:03
Reporter: Jiyuan Li Email Updates:
Status: Open Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S3 (Non-critical)
Version:|26.10.0-cluster OS:Ubuntu (24.04)
Assigned to: CPU Architecture:Any

[9 Oct 1:03] Jiyuan Li
Description:
INSERT ... SELECT duplicate key reports the source table instead of the target on NDB engine, and on InnoDB it reports the correct warning. 

How to repeat:
SET SESSION sql_mode='';
CREATE TABLE src (id INT PRIMARY KEY, v INT) ENGINE=NDB;
CREATE TABLE t   (id INT PRIMARY KEY, v INT) ENGINE=NDB;
INSERT INTO src VALUES (1,10),(2,20);
INSERT INTO t VALUES (7,111);
INSERT INTO t SELECT 7, v FROM src;
-- ERROR 1062 (23000): Duplicate entry '0' for key 'src.PRIMARY'
-- here the table in ERROR is src

DROP TABLE src;
DROP TABLE t;
CREATE TABLE src (id INT PRIMARY KEY, v INT) ENGINE=InnoDB;
CREATE TABLE t   (id INT PRIMARY KEY, v INT) ENGINE=InnoDB;
INSERT INTO src VALUES (1,10),(2,20);
INSERT INTO t VALUES (7,111);
INSERT INTO t SELECT 7, v FROM src;
-- ERROR 1062 (23000): Duplicate entry '7' for key 't.PRIMARY'
-- here the table in ERROR is t