Below is the list of changes that have just been committed into a local
4.1 repository of marty. When marty does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet
1.2196 05/04/19 11:21:26 mskold@stripped +3 -0
Fix for Bug #9691 UPDATE fails on attempt to update primary key
mysql-test/r/ndb_update.result
1.3 05/04/19 11:20:56 mskold@stripped +25 -5
Fix for Bug #9691 UPDATE fails on attempt to update primary key
sql/ha_ndbcluster.cc
1.142 05/04/19 11:20:55 mskold@stripped +24 -15
Fix for Bug #9691 UPDATE fails on attempt to update primary key
mysql-test/t/ndb_update.test
1.3 05/04/19 11:20:55 mskold@stripped +13 -2
Fix for Bug #9691 UPDATE fails on attempt to update primary key
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: mskold
# Host: blowfish.ndb.mysql.com
# Root: /usr/local/home/marty/MySQL/mysql-4.1
--- 1.141/sql/ha_ndbcluster.cc Fri Apr 15 16:13:57 2005
+++ 1.142/sql/ha_ndbcluster.cc Tue Apr 19 11:20:55 2005
@@ -1863,8 +1863,10 @@
m_skip_auto_increment= !auto_increment_column_changed;
}
- if ((res= set_primary_key(op)))
- return res;
+ if ((res= (m_primary_key_update ?
+ set_primary_key_from_old_data(op, record)
+ : set_primary_key(op))))
+ return res;
}
// Set non-key attribute(s)
@@ -2001,7 +2003,7 @@
{
int read_res, insert_res, delete_res;
- DBUG_PRINT("info", ("primary key update, doing pk read+insert+delete"));
+ DBUG_PRINT("info", ("primary key update, doing pk read+delete+insert"));
// Get all old fields, since we optimize away fields not in query
read_res= complemented_pk_read(old_data, new_data);
if (read_res)
@@ -2009,15 +2011,7 @@
DBUG_PRINT("info", ("pk read failed"));
DBUG_RETURN(read_res);
}
- // Insert new row
- insert_res= write_row(new_data);
- if (insert_res)
- {
- DBUG_PRINT("info", ("insert failed"));
- DBUG_RETURN(insert_res);
- }
// Delete old row
- DBUG_PRINT("info", ("insert succeded"));
m_primary_key_update= TRUE;
delete_res= delete_row(old_data);
m_primary_key_update= FALSE;
@@ -2025,9 +2019,23 @@
{
DBUG_PRINT("info", ("delete failed"));
// Undo write_row(new_data)
- DBUG_RETURN(delete_row(new_data));
+ DBUG_RETURN(delete_res);
}
- DBUG_PRINT("info", ("insert+delete succeeded"));
+ // Insert new row
+ DBUG_PRINT("info", ("delete succeded"));
+ insert_res= write_row(new_data);
+ if (insert_res)
+ {
+ DBUG_PRINT("info", ("insert failed"));
+ if (trans->commitStatus() == NdbConnection::Started)
+ {
+ m_primary_key_update= TRUE;
+ insert_res= write_row((byte *)old_data);
+ m_primary_key_update= FALSE;
+ }
+ DBUG_RETURN(insert_res);
+ }
+ DBUG_PRINT("info", ("delete+insert succeeded"));
DBUG_RETURN(0);
}
@@ -2125,8 +2133,9 @@
no_uncommitted_rows_update(-1);
- // If deleting from cursor, NoCommit will be handled in next_result
- DBUG_RETURN(0);
+ if (!m_primary_key_update)
+ // If deleting from cursor, NoCommit will be handled in next_result
+ DBUG_RETURN(0);
}
else
{
--- 1.2/mysql-test/r/ndb_update.result Sun Nov 28 22:32:51 2004
+++ 1.3/mysql-test/r/ndb_update.result Tue Apr 19 11:20:56 2005
@@ -2,12 +2,32 @@
CREATE TABLE t1 (
pk1 INT NOT NULL PRIMARY KEY,
b INT NOT NULL,
-c INT NOT NULL
+c INT NOT NULL UNIQUE
) ENGINE=ndbcluster;
-INSERT INTO t1 VALUES (0, 0, 1),(1,1,2),(2,2,3);
+INSERT INTO t1 VALUES (0, 1, 0),(1,2,1),(2,3,2);
UPDATE t1 set b = c;
select * from t1 order by pk1;
pk1 b c
-0 1 1
-1 2 2
-2 3 3
+0 0 0
+1 1 1
+2 2 2
+UPDATE t1 set pk1 = 4 where pk1 = 1;
+select * from t1 order by pk1;
+pk1 b c
+0 0 0
+2 2 2
+4 1 1
+UPDATE t1 set pk1 = 1, c = 2 where pk1 = 4;
+ERROR 23000: Duplicate entry '1' for key 1
+select * from t1 order by pk1;
+pk1 b c
+0 0 0
+2 2 2
+4 1 1
+UPDATE t1 set pk1 = pk1 + 10;
+select * from t1 order by pk1;
+pk1 b c
+10 0 0
+12 2 2
+14 1 1
+DROP TABLE IF EXISTS t1;
--- 1.2/mysql-test/t/ndb_update.test Sun Nov 28 22:32:51 2004
+++ 1.3/mysql-test/t/ndb_update.test Tue Apr 19 11:20:55 2005
@@ -14,9 +14,20 @@
CREATE TABLE t1 (
pk1 INT NOT NULL PRIMARY KEY,
b INT NOT NULL,
- c INT NOT NULL
+ c INT NOT NULL UNIQUE
) ENGINE=ndbcluster;
-INSERT INTO t1 VALUES (0, 0, 1),(1,1,2),(2,2,3);
+INSERT INTO t1 VALUES (0, 1, 0),(1,2,1),(2,3,2);
UPDATE t1 set b = c;
select * from t1 order by pk1;
+UPDATE t1 set pk1 = 4 where pk1 = 1;
+select * from t1 order by pk1;
+-- error 1062
+UPDATE t1 set pk1 = 1, c = 2 where pk1 = 4;
+select * from t1 order by pk1;
+UPDATE t1 set pk1 = pk1 + 10;
+select * from t1 order by pk1;
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
| Thread |
|---|
| • bk commit into 4.1 tree (mskold:1.2196) BUG#9691 | Martin Skold | 19 Apr |