Bug #6398 update of primary key fails
Submitted: 3 Nov 2004 10:57 Modified: 6 Nov 2004 13:25
Reporter: Tomas Ulin Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S1 (Critical)
Version:4.1.8 bk OS:
Assigned to: Martin Skold CPU Architecture:Any

[3 Nov 2004 10:57] Tomas Ulin
Description:

mysql> create table t1 (a int primary key);
Query OK, 0 rows affected (0.05 sec)

mysql> insert into t1 values (1);
Query OK, 1 row affected (0.00 sec)

mysql> select * from t1;
+---+
| a |
+---+
| 1 |
+---+
1 row in set (0.00 sec)

mysql> update t1 set a=20 where a=1;
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> select * from t1;
+---+
| a |
+---+
| 1 |
+---+
1 row in set (0.00 sec)

mysql> update t1 set a=a+1;
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> select * from t1;
+---+
| a |
+---+
| 2 |
+---+
1 row in set (0.03 sec)

How to repeat:
create table t1 (a int primary key);
insert into t1 values (1);
select * from t1;
update t1 set a=20 where a=1;
select * from t1;
update t1 set a=a+1;
select * from t1;
[3 Nov 2004 15:04] Martin Skold
delete_row is using the wrong key when updating as the result of a primary key read.
Changed to read key from old_data for primary_key_updates.