Commit 8f7bb4ec authored by mskold@mysql.com's avatar mskold@mysql.com

Merge mskold@bk-internal.mysql.com:/home/bk/mysql-4.1

into mysql.com:/usr/local/home/marty/MySQL/mysql-4.1
parents f284512c c9e68705
...@@ -2,12 +2,32 @@ DROP TABLE IF EXISTS t1; ...@@ -2,12 +2,32 @@ DROP TABLE IF EXISTS t1;
CREATE TABLE t1 ( CREATE TABLE t1 (
pk1 INT NOT NULL PRIMARY KEY, pk1 INT NOT NULL PRIMARY KEY,
b INT NOT NULL, b INT NOT NULL,
c INT NOT NULL c INT NOT NULL UNIQUE
) ENGINE=ndbcluster; ) 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; UPDATE t1 set b = c;
select * from t1 order by pk1; select * from t1 order by pk1;
pk1 b c pk1 b c
0 1 1 0 0 0
1 2 2 1 1 1
2 3 3 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;
-- source include/have_ndb.inc -- source include/have_ndb.inc
-- source include/have_multi_ndb.inc -- source include/have_multi_ndb.inc
-- source include/not_embedded.inc
--disable_warnings --disable_warnings
DROP TABLE IF EXISTS t1; DROP TABLE IF EXISTS t1;
......
-- source include/have_ndb.inc -- source include/have_ndb.inc
-- source include/not_embedded.inc
--disable_warnings --disable_warnings
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10;
......
-- source include/have_ndb.inc -- source include/have_ndb.inc
-- source include/not_embedded.inc
# #
# Simple test to show use of discover when the server has been restarted # Simple test to show use of discover when the server has been restarted
......
-- source include/have_ndb.inc -- source include/have_ndb.inc
-- source include/not_embedded.inc
--disable_warnings --disable_warnings
DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7; DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7;
......
--source include/have_ndb.inc --source include/have_ndb.inc
-- source include/not_embedded.inc
--disable_warnings --disable_warnings
drop table if exists t1; drop table if exists t1;
......
-- source include/have_query_cache.inc -- source include/have_query_cache.inc
-- source include/have_ndb.inc -- source include/have_ndb.inc
-- source include/not_embedded.inc
set GLOBAL query_cache_size=1355776; set GLOBAL query_cache_size=1355776;
reset query cache; reset query cache;
......
--source include/have_ndb.inc --source include/have_ndb.inc
-- source include/not_embedded.inc
--disable_warnings --disable_warnings
drop table if exists t1; drop table if exists t1;
......
-- source include/have_ndb.inc -- source include/have_ndb.inc
-- source include/not_embedded.inc
--disable_warnings --disable_warnings
drop table if exists t1; drop table if exists t1;
......
-- source include/have_ndb.inc -- source include/have_ndb.inc
-- source include/not_embedded.inc
--disable_warnings --disable_warnings
drop table if exists t1, test1, test2; drop table if exists t1, test1, test2;
......
-- source include/have_ndb.inc -- source include/have_ndb.inc
-- source include/not_embedded.inc
--disable_warnings --disable_warnings
drop table if exists t1, t2, t3, t4, t5, t6, t7; drop table if exists t1, t2, t3, t4, t5, t6, t7;
......
-- source include/have_ndb.inc -- source include/have_ndb.inc
-- source include/not_embedded.inc
--disable_warnings --disable_warnings
DROP TABLE IF EXISTS t1; DROP TABLE IF EXISTS t1;
......
-- source include/have_ndb.inc -- source include/have_ndb.inc
-- source include/not_embedded.inc
--disable_warnings --disable_warnings
DROP TABLE IF EXISTS t2; DROP TABLE IF EXISTS t2;
......
-- source include/have_ndb.inc -- source include/have_ndb.inc
-- source include/not_embedded.inc
connect (con1,localhost,root,,); connect (con1,localhost,root,,);
connect (con2,localhost,root,,); connect (con2,localhost,root,,);
......
-- source include/have_ndb.inc -- source include/have_ndb.inc
-- source include/not_embedded.inc
--disable_warnings --disable_warnings
drop table if exists t1, t2; drop table if exists t1, t2;
......
-- source include/have_ndb.inc -- source include/have_ndb.inc
-- source include/have_multi_ndb.inc -- source include/have_multi_ndb.inc
-- source include/not_embedded.inc
--disable_warnings --disable_warnings
......
-- source include/have_ndb.inc -- source include/have_ndb.inc
-- source include/not_embedded.inc
# #
# Test of REPLACE with NDB # Test of REPLACE with NDB
......
-- source include/have_ndb.inc -- source include/have_ndb.inc
-- source include/not_embedded.inc
--disable_warnings --disable_warnings
use test; use test;
......
-- source include/have_ndb.inc -- source include/have_ndb.inc
-- source include/not_embedded.inc
--disable_warnings --disable_warnings
drop table if exists t1; drop table if exists t1;
......
-- source include/have_ndb.inc -- source include/have_ndb.inc
-- source include/not_embedded.inc
--disable_warnings --disable_warnings
DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7; DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7;
......
-- source include/have_ndb.inc -- source include/have_ndb.inc
-- source include/not_embedded.inc
--disable_warnings --disable_warnings
DROP TABLE IF EXISTS t2; DROP TABLE IF EXISTS t2;
......
-- source include/have_ndb.inc -- source include/have_ndb.inc
-- source include/not_embedded.inc
--disable_warnings --disable_warnings
DROP TABLE IF EXISTS t1; DROP TABLE IF EXISTS t1;
......
-- source include/have_ndb.inc -- source include/have_ndb.inc
-- source include/not_embedded.inc
--disable_warnings --disable_warnings
DROP TABLE IF EXISTS t1; DROP TABLE IF EXISTS t1;
...@@ -14,9 +15,20 @@ DROP TABLE IF EXISTS t1; ...@@ -14,9 +15,20 @@ DROP TABLE IF EXISTS t1;
CREATE TABLE t1 ( CREATE TABLE t1 (
pk1 INT NOT NULL PRIMARY KEY, pk1 INT NOT NULL PRIMARY KEY,
b INT NOT NULL, b INT NOT NULL,
c INT NOT NULL c INT NOT NULL UNIQUE
) ENGINE=ndbcluster; ) 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; UPDATE t1 set b = c;
select * from t1 order by pk1; 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
...@@ -1838,7 +1838,6 @@ void Dbtc::execKEYINFO(Signal* signal) ...@@ -1838,7 +1838,6 @@ void Dbtc::execKEYINFO(Signal* signal)
do { do {
if (cfirstfreeDatabuf == RNIL) { if (cfirstfreeDatabuf == RNIL) {
jam(); jam();
abort();
seizeDatabuferrorLab(signal); seizeDatabuferrorLab(signal);
return; return;
}//if }//if
......
...@@ -1863,8 +1863,10 @@ int ha_ndbcluster::write_row(byte *record) ...@@ -1863,8 +1863,10 @@ int ha_ndbcluster::write_row(byte *record)
m_skip_auto_increment= !auto_increment_column_changed; m_skip_auto_increment= !auto_increment_column_changed;
} }
if ((res= set_primary_key(op))) if ((res= (m_primary_key_update ?
return res; set_primary_key_from_old_data(op, record)
: set_primary_key(op))))
return res;
} }
// Set non-key attribute(s) // Set non-key attribute(s)
...@@ -2001,7 +2003,7 @@ int ha_ndbcluster::update_row(const byte *old_data, byte *new_data) ...@@ -2001,7 +2003,7 @@ int ha_ndbcluster::update_row(const byte *old_data, byte *new_data)
{ {
int read_res, insert_res, delete_res; 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 // Get all old fields, since we optimize away fields not in query
read_res= complemented_pk_read(old_data, new_data); read_res= complemented_pk_read(old_data, new_data);
if (read_res) if (read_res)
...@@ -2009,15 +2011,7 @@ int ha_ndbcluster::update_row(const byte *old_data, byte *new_data) ...@@ -2009,15 +2011,7 @@ int ha_ndbcluster::update_row(const byte *old_data, byte *new_data)
DBUG_PRINT("info", ("pk read failed")); DBUG_PRINT("info", ("pk read failed"));
DBUG_RETURN(read_res); 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 // Delete old row
DBUG_PRINT("info", ("insert succeded"));
m_primary_key_update= TRUE; m_primary_key_update= TRUE;
delete_res= delete_row(old_data); delete_res= delete_row(old_data);
m_primary_key_update= FALSE; m_primary_key_update= FALSE;
...@@ -2025,9 +2019,23 @@ int ha_ndbcluster::update_row(const byte *old_data, byte *new_data) ...@@ -2025,9 +2019,23 @@ int ha_ndbcluster::update_row(const byte *old_data, byte *new_data)
{ {
DBUG_PRINT("info", ("delete failed")); DBUG_PRINT("info", ("delete failed"));
// Undo write_row(new_data) // 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); DBUG_RETURN(0);
} }
...@@ -2125,8 +2133,9 @@ int ha_ndbcluster::delete_row(const byte *record) ...@@ -2125,8 +2133,9 @@ int ha_ndbcluster::delete_row(const byte *record)
no_uncommitted_rows_update(-1); no_uncommitted_rows_update(-1);
// If deleting from cursor, NoCommit will be handled in next_result if (!m_primary_key_update)
DBUG_RETURN(0); // If deleting from cursor, NoCommit will be handled in next_result
DBUG_RETURN(0);
} }
else else
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment