I think this is a bug in MySQL 5.1.16-beta (I'm using SUSE 10.2 Linux),
but I can't find any information on it.

 

When performing an update which doesn't change any rows, I get different
results back depending on the declarations of the fields in the table.

 

If a 'normal' NDB table is created and an inserted row is updated:

 

mysql> CREATE TABLE table1 (field1 int(11), field2 int(11)) engine ndb;

Query OK, 0 rows affected (1.17 sec)

 

mysql> insert into table1 values (1,2);

Query OK, 1 row affected (0.04 sec)

 

mysql> update table1 set field2=3 where field1=1; -- This should return
one changed row

Query OK, 1 row affected (0.00 sec)

Rows matched: 1  Changed: 1  Warnings: 0

 

mysql> update table1 set field2=3 where field1=1; -- The same update
should return 0 rows

Query OK, 0 rows affected (0.00 sec)

Rows matched: 1  Changed: 0  Warnings: 0

 

The second update is 'changing' the record to the same value currently
in the database, so it returns 0 records changed.

 

However, if the table is changed so that field1 is a primary key, the
number of rows changed is different:

 

mysql> CREATE TABLE table2 (field1 int(11) primary key, field2 int(11))
engine ndb;

Query OK, 0 rows affected (4.18 sec)

 

mysql> insert into table2 values (1,2);

Query OK, 1 row affected (0.00 sec)

 

mysql> update table2 set field2=3 where field1=1;

Query OK, 1 row affected (0.00 sec)

Rows matched: 1  Changed: 1  Warnings: 0

 

mysql> update table2 set field2=3 where field1=1;

Query OK, 1 row affected (0.01 sec)

Rows matched: 1  Changed: 1  Warnings: 0

 

Here the second update reports 1 row has changed, even though the data
is the same.

 

This doesn't happen in MySQL 5.1.11 on the same machine. In both cases
I'm running a single node cluster on one box (I know that's a bit
pointless but it's meant to be a proof of concept :-)). I tried the same
tests using InnoDB and got 1 Changed row in each case, and with MyISAM I
got 0 rows changed.

 

Can anyone confirm if they have the same problem or if it's something
I've done wrong?

 

Brian

 

Reply via email to