Bug #5320 Cluster: different error message returned than under MyISAM/InnoDB
Submitted: 31 Aug 2004 16:38 Modified: 31 Aug 2004 21:40
Reporter: Trudy Pelzer Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S3 (Non-critical)
Version:4.1.4-gamma (ndb) OS:Linux (SuSE 9.1)
Assigned to: CPU Architecture:Any

[31 Aug 2004 16:38] Trudy Pelzer
Description:
I get a different error number and message when doing the same
thing on MyISAM/InnoDB and Cluster. 

I have three tables, called s (Type=MyISAM), s_i (Type=InnoDB),
and s_n (Type=NDBCluster). The tables all look like this (note
the primary key on column sno):

mysql> show columns from s_n;
+--------+--------------+------+-----+---------+-------+
| Field  | Type         | Null | Key | Default | Extra |
+--------+--------------+------+-----+---------+-------+
| sno    | char(3)      |      | PRI |         |       |
| sname  | varchar(8)   | YES  |     | NULL    |       |
| status | decimal(3,0) | YES  |     | NULL    |       |
| city   | varchar(10)  | YES  |     | NULL    |       |
+--------+--------------+------+-----+---------+-------+
4 rows in set (0.01 sec)

I attempt to add duplicate key values to each table:

mysql> insert into s (sno) values('s6');
Query OK, 1 row affected (0.00 sec)
mysql> insert into s (sno) values('s6');
ERROR 1062 (23000): Duplicate entry 's6' for key 1

mysql> insert into s_i (sno) values('s6');
Query OK, 1 row affected (0.00 sec)
mysql> insert into s_i (sno) values('s6');
ERROR 1062 (23000): Duplicate entry 's6' for key 1

mysql> insert into s_n (sno) values('s6');
Query OK, 1 row affected (0.00 sec)
mysql> insert into s_n (sno) values('s6');
ERROR 1022 (23000): Can't write; duplicate key in table 's_n'

Note that the MyISAM and InnoDB table attempts return
ERROR 1062 (23000): Duplicate entry 's6' for key 1.
But the Cluster table attempt returns
ERROR 1022 (23000): Can't write; duplicate key in table 's_n'

If a programmer, writing an error handling routine, is depending
on a specific error being returned by MySQL, it should be the
same error regardless of which engine is in use.

How to repeat:
create table tmyisam (col1 int not null primary key);
create table tndb (col1 int not null primary key) engine=ndbcluster;
insert into tmyisam values(10);
insert into tmyisam values(10);
insert into tndb values(10);
insert into tndb values(10);

Suggested fix:
Return the same error number and message in all cases,
regardless of rthe engine type in use.
[31 Aug 2004 21:40] Martin Skold
Duplicate of bug#5312 Ndb Cluster returns wrong error code for duplicate key at insert