diff options
author | unknown <mskold@mysql.com> | 2005-04-20 11:26:57 +0200 |
---|---|---|
committer | unknown <mskold@mysql.com> | 2005-04-20 11:26:57 +0200 |
commit | 8d683973339d7d53977433fbd6a55038e6763e71 (patch) | |
tree | 3b86d1cc641c4a4386b6b97a533bd607206e88fe | |
parent | ccd4e77be70946138b41a518a03e462ae37ca543 (diff) | |
parent | a8261608e313b2e5eb18b7b25d5b0cdeaeae239d (diff) | |
download | mariadb-git-8d683973339d7d53977433fbd6a55038e6763e71.tar.gz |
Merge mskold@bk-internal.mysql.com:/home/bk/mysql-4.1
into mysql.com:/usr/local/home/marty/MySQL/mysql-4.1
25 files changed, 84 insertions, 23 deletions
diff --git a/mysql-test/r/ndb_update.result b/mysql-test/r/ndb_update.result index 5df5c861cfb..c2247564e65 100644 --- a/mysql-test/r/ndb_update.result +++ b/mysql-test/r/ndb_update.result @@ -2,12 +2,32 @@ DROP TABLE IF EXISTS t1; 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; diff --git a/mysql-test/t/ndb_alter_table.test b/mysql-test/t/ndb_alter_table.test index 3ff2e735cb5..9cc1426554f 100644 --- a/mysql-test/t/ndb_alter_table.test +++ b/mysql-test/t/ndb_alter_table.test @@ -1,5 +1,6 @@ -- source include/have_ndb.inc -- source include/have_multi_ndb.inc +-- source include/not_embedded.inc --disable_warnings DROP TABLE IF EXISTS t1; diff --git a/mysql-test/t/ndb_autodiscover.test b/mysql-test/t/ndb_autodiscover.test index 037115f5e82..bd73a36fcab 100644 --- a/mysql-test/t/ndb_autodiscover.test +++ b/mysql-test/t/ndb_autodiscover.test @@ -1,4 +1,5 @@ -- source include/have_ndb.inc +-- source include/not_embedded.inc --disable_warnings drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10; diff --git a/mysql-test/t/ndb_autodiscover2.test b/mysql-test/t/ndb_autodiscover2.test index 11e1cc204f7..76baa31a2a9 100644 --- a/mysql-test/t/ndb_autodiscover2.test +++ b/mysql-test/t/ndb_autodiscover2.test @@ -1,4 +1,5 @@ -- source include/have_ndb.inc +-- source include/not_embedded.inc # # Simple test to show use of discover when the server has been restarted diff --git a/mysql-test/t/ndb_basic.test b/mysql-test/t/ndb_basic.test index 66300f61fc3..24baf8d9fb4 100644 --- a/mysql-test/t/ndb_basic.test +++ b/mysql-test/t/ndb_basic.test @@ -1,4 +1,5 @@ -- source include/have_ndb.inc +-- source include/not_embedded.inc --disable_warnings DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7; diff --git a/mysql-test/t/ndb_blob.test b/mysql-test/t/ndb_blob.test index 96e38bfb58e..b265809b75f 100644 --- a/mysql-test/t/ndb_blob.test +++ b/mysql-test/t/ndb_blob.test @@ -1,4 +1,5 @@ --source include/have_ndb.inc +-- source include/not_embedded.inc --disable_warnings drop table if exists t1; diff --git a/mysql-test/t/ndb_cache.test b/mysql-test/t/ndb_cache.test index abd09424f64..5ba42f9b23c 100644 --- a/mysql-test/t/ndb_cache.test +++ b/mysql-test/t/ndb_cache.test @@ -1,5 +1,6 @@ -- source include/have_query_cache.inc -- source include/have_ndb.inc +-- source include/not_embedded.inc set GLOBAL query_cache_size=1355776; reset query cache; diff --git a/mysql-test/t/ndb_charset.test b/mysql-test/t/ndb_charset.test index 1b9e7e8bfcc..242f9192948 100644 --- a/mysql-test/t/ndb_charset.test +++ b/mysql-test/t/ndb_charset.test @@ -1,4 +1,5 @@ --source include/have_ndb.inc +-- source include/not_embedded.inc --disable_warnings drop table if exists t1; diff --git a/mysql-test/t/ndb_index.test b/mysql-test/t/ndb_index.test index e65b24a9b20..93085dea587 100644 --- a/mysql-test/t/ndb_index.test +++ b/mysql-test/t/ndb_index.test @@ -1,4 +1,5 @@ -- source include/have_ndb.inc +-- source include/not_embedded.inc --disable_warnings drop table if exists t1; diff --git a/mysql-test/t/ndb_index_ordered.test b/mysql-test/t/ndb_index_ordered.test index 010060a694d..4bc2021d45e 100644 --- a/mysql-test/t/ndb_index_ordered.test +++ b/mysql-test/t/ndb_index_ordered.test @@ -1,4 +1,5 @@ -- source include/have_ndb.inc +-- source include/not_embedded.inc --disable_warnings drop table if exists t1, test1, test2; diff --git a/mysql-test/t/ndb_index_unique.test b/mysql-test/t/ndb_index_unique.test index 9bbea75028b..67cf6cb4537 100644 --- a/mysql-test/t/ndb_index_unique.test +++ b/mysql-test/t/ndb_index_unique.test @@ -1,4 +1,5 @@ -- source include/have_ndb.inc +-- source include/not_embedded.inc --disable_warnings drop table if exists t1, t2, t3, t4, t5, t6, t7; diff --git a/mysql-test/t/ndb_insert.test b/mysql-test/t/ndb_insert.test index 611df3d84e9..f88d33f22f4 100644 --- a/mysql-test/t/ndb_insert.test +++ b/mysql-test/t/ndb_insert.test @@ -1,4 +1,5 @@ -- source include/have_ndb.inc +-- source include/not_embedded.inc --disable_warnings DROP TABLE IF EXISTS t1; diff --git a/mysql-test/t/ndb_limit.test b/mysql-test/t/ndb_limit.test index c2d7a0ecfec..0df3b2f7566 100644 --- a/mysql-test/t/ndb_limit.test +++ b/mysql-test/t/ndb_limit.test @@ -1,4 +1,5 @@ -- source include/have_ndb.inc +-- source include/not_embedded.inc --disable_warnings DROP TABLE IF EXISTS t2; diff --git a/mysql-test/t/ndb_lock.test b/mysql-test/t/ndb_lock.test index 39a8655b972..b93abbd564b 100644 --- a/mysql-test/t/ndb_lock.test +++ b/mysql-test/t/ndb_lock.test @@ -1,4 +1,5 @@ -- source include/have_ndb.inc +-- source include/not_embedded.inc connect (con1,localhost,root,,); connect (con2,localhost,root,,); diff --git a/mysql-test/t/ndb_minmax.test b/mysql-test/t/ndb_minmax.test index 3be193ce602..97ea84f98ef 100644 --- a/mysql-test/t/ndb_minmax.test +++ b/mysql-test/t/ndb_minmax.test @@ -1,4 +1,5 @@ -- source include/have_ndb.inc +-- source include/not_embedded.inc --disable_warnings drop table if exists t1, t2; diff --git a/mysql-test/t/ndb_multi.test b/mysql-test/t/ndb_multi.test index 27ddd6508e9..24651913a79 100644 --- a/mysql-test/t/ndb_multi.test +++ b/mysql-test/t/ndb_multi.test @@ -1,5 +1,6 @@ -- source include/have_ndb.inc -- source include/have_multi_ndb.inc +-- source include/not_embedded.inc --disable_warnings diff --git a/mysql-test/t/ndb_replace.test b/mysql-test/t/ndb_replace.test index 59454b5a9fa..1c06a9a6633 100644 --- a/mysql-test/t/ndb_replace.test +++ b/mysql-test/t/ndb_replace.test @@ -1,4 +1,5 @@ -- source include/have_ndb.inc +-- source include/not_embedded.inc # # Test of REPLACE with NDB diff --git a/mysql-test/t/ndb_restore.test b/mysql-test/t/ndb_restore.test index d413453fb0e..ee47f7da6bc 100644 --- a/mysql-test/t/ndb_restore.test +++ b/mysql-test/t/ndb_restore.test @@ -1,4 +1,5 @@ -- source include/have_ndb.inc +-- source include/not_embedded.inc --disable_warnings use test; diff --git a/mysql-test/t/ndb_subquery.test b/mysql-test/t/ndb_subquery.test index cebc1920eaa..9d3a256a263 100644 --- a/mysql-test/t/ndb_subquery.test +++ b/mysql-test/t/ndb_subquery.test @@ -1,4 +1,5 @@ -- source include/have_ndb.inc +-- source include/not_embedded.inc --disable_warnings drop table if exists t1; diff --git a/mysql-test/t/ndb_transaction.test b/mysql-test/t/ndb_transaction.test index f8ed22207ea..ae02059786d 100644 --- a/mysql-test/t/ndb_transaction.test +++ b/mysql-test/t/ndb_transaction.test @@ -1,4 +1,5 @@ -- source include/have_ndb.inc +-- source include/not_embedded.inc --disable_warnings DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7; diff --git a/mysql-test/t/ndb_truncate.test b/mysql-test/t/ndb_truncate.test index 63bb8cbefb6..7c0f79bcc59 100644 --- a/mysql-test/t/ndb_truncate.test +++ b/mysql-test/t/ndb_truncate.test @@ -1,4 +1,5 @@ -- source include/have_ndb.inc +-- source include/not_embedded.inc --disable_warnings DROP TABLE IF EXISTS t2; diff --git a/mysql-test/t/ndb_types.test b/mysql-test/t/ndb_types.test index d66718ca4e4..4276fa147eb 100644 --- a/mysql-test/t/ndb_types.test +++ b/mysql-test/t/ndb_types.test @@ -1,4 +1,5 @@ -- source include/have_ndb.inc +-- source include/not_embedded.inc --disable_warnings DROP TABLE IF EXISTS t1; diff --git a/mysql-test/t/ndb_update.test b/mysql-test/t/ndb_update.test index 3b0e84e2344..5453e41f937 100644 --- a/mysql-test/t/ndb_update.test +++ b/mysql-test/t/ndb_update.test @@ -1,4 +1,5 @@ -- source include/have_ndb.inc +-- source include/not_embedded.inc --disable_warnings DROP TABLE IF EXISTS t1; @@ -14,9 +15,20 @@ DROP TABLE IF EXISTS t1; 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 diff --git a/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp b/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp index 03a0590b6e2..efd4c2a46d0 100644 --- a/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp +++ b/ndb/src/kernel/blocks/dbtc/DbtcMain.cpp @@ -1838,7 +1838,6 @@ void Dbtc::execKEYINFO(Signal* signal) do { if (cfirstfreeDatabuf == RNIL) { jam(); - abort(); seizeDatabuferrorLab(signal); return; }//if diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index d14d5f6f5c3..a6b4f928e72 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -1863,8 +1863,10 @@ int ha_ndbcluster::write_row(byte *record) 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 ha_ndbcluster::update_row(const byte *old_data, byte *new_data) { 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 @@ int ha_ndbcluster::update_row(const byte *old_data, byte *new_data) 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 @@ int ha_ndbcluster::update_row(const byte *old_data, byte *new_data) { 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 @@ int ha_ndbcluster::delete_row(const byte *record) 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 { |