From bcc517cb3751296d131ed27fa776a0f0ba87eb6f Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 17 Aug 2007 14:32:39 +0800 Subject: [PATCH 01/32] BUG#30271 NDB_LE_MemoryUsage.page_size_kb actually returns page size in bytes, not kilobyte ndb/include/mgmapi/ndb_logevent.h: Add page_size_bytes member variable for MemoryUsage. And don't remove page_size_kb member variable at present for the compatibility backward. ndb/src/mgmapi/ndb_logevent.cpp: change the page_size_kb member variable of MemoryUsage to page_size_bytes --- ndb/include/mgmapi/ndb_logevent.h | 8 +++++++- ndb/src/mgmapi/ndb_logevent.cpp | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ndb/include/mgmapi/ndb_logevent.h b/ndb/include/mgmapi/ndb_logevent.h index 76e4c31baa2..389004da06b 100644 --- a/ndb/include/mgmapi/ndb_logevent.h +++ b/ndb/include/mgmapi/ndb_logevent.h @@ -551,7 +551,13 @@ extern "C" { /** Log event specific data for for corresponding NDB_LE_ log event */ struct { int gth; - unsigned page_size_kb; + /* union is for compatibility backward. + * page_size_kb member variable should be removed in the future + */ + union { + unsigned page_size_kb; + unsigned page_size_bytes; + }; unsigned pages_used; unsigned pages_total; unsigned block; diff --git a/ndb/src/mgmapi/ndb_logevent.cpp b/ndb/src/mgmapi/ndb_logevent.cpp index 3885bb79536..f0b7c26cf78 100644 --- a/ndb/src/mgmapi/ndb_logevent.cpp +++ b/ndb/src/mgmapi/ndb_logevent.cpp @@ -256,7 +256,7 @@ struct Ndb_logevent_body_row ndb_logevent_body[]= { ROW( ReceiveBytesStatistic, "mean_received_bytes", 2, mean_received_bytes), ROW( MemoryUsage, "gth", 1, gth), - ROW( MemoryUsage, "page_size_kb", 2, page_size_kb), + ROW( MemoryUsage, "page_size_bytes", 2, page_size_bytes), ROW( MemoryUsage, "pages_used", 3, pages_used), ROW( MemoryUsage, "pages_total", 4, pages_total), ROW( MemoryUsage, "block", 5, block), From dfc14639682d573c620b1b4d6d58788274f8f7ad Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 14 Sep 2007 22:18:20 +0800 Subject: [PATCH 02/32] BUG#28647 Stop backup if disk full storage/ndb/src/kernel/blocks/backup/Backup.cpp: Close files when disk full storage/ndb/src/ndbapi/ndberror.c: Add error messages for backup failure storage/ndb/test/src/NdbBackup.cpp: Add test case for disk full --- mysql-test/r/bdb_notembedded.result | 35 +++++++++++ mysql-test/t/bdb_notembedded.test | 38 ++++++++++++ .../ndb/src/kernel/blocks/backup/Backup.cpp | 59 ++++++++++++++++++- storage/ndb/src/ndbapi/ndberror.c | 2 + storage/ndb/test/src/NdbBackup.cpp | 3 +- 5 files changed, 134 insertions(+), 3 deletions(-) create mode 100644 mysql-test/r/bdb_notembedded.result create mode 100644 mysql-test/t/bdb_notembedded.test diff --git a/mysql-test/r/bdb_notembedded.result b/mysql-test/r/bdb_notembedded.result new file mode 100644 index 00000000000..14cb5fad915 --- /dev/null +++ b/mysql-test/r/bdb_notembedded.result @@ -0,0 +1,35 @@ +set autocommit=1; +reset master; +create table bug16206 (a int); +insert into bug16206 values(1); +start transaction; +insert into bug16206 values(2); +commit; +show binlog events; +Log_name Pos Event_type Server_id End_log_pos Info +f n Format_desc 1 n Server ver: VERSION, Binlog ver: 4 +f n Query 1 n use `test`; create table bug16206 (a int) +f n Query 1 n use `test`; insert into bug16206 values(1) +f n Query 1 n use `test`; insert into bug16206 values(2) +drop table bug16206; +reset master; +create table bug16206 (a int) engine= bdb; +insert into bug16206 values(0); +insert into bug16206 values(1); +start transaction; +insert into bug16206 values(2); +commit; +insert into bug16206 values(3); +show binlog events; +Log_name Pos Event_type Server_id End_log_pos Info +f n Format_desc 1 n Server ver: VERSION, Binlog ver: 4 +f n Query 1 n use `test`; create table bug16206 (a int) engine= bdb +f n Query 1 n use `test`; insert into bug16206 values(0) +f n Query 1 n use `test`; insert into bug16206 values(1) +f n Query 1 n use `test`; BEGIN +f n Query 1 n use `test`; insert into bug16206 values(2) +f n Query 1 n use `test`; COMMIT +f n Query 1 n use `test`; insert into bug16206 values(3) +drop table bug16206; +set autocommit=0; +End of 5.0 tests diff --git a/mysql-test/t/bdb_notembedded.test b/mysql-test/t/bdb_notembedded.test new file mode 100644 index 00000000000..24e64ebbfb2 --- /dev/null +++ b/mysql-test/t/bdb_notembedded.test @@ -0,0 +1,38 @@ +-- source include/not_embedded.inc +-- source include/have_bdb.inc + +# +# Bug #16206: Superfluous COMMIT event in binlog when updating BDB in autocommit mode +# +set autocommit=1; + +let $VERSION=`select version()`; + +reset master; +create table bug16206 (a int); +insert into bug16206 values(1); +start transaction; +insert into bug16206 values(2); +commit; +--replace_result $VERSION VERSION +--replace_column 1 f 2 n 5 n +show binlog events; +drop table bug16206; + +reset master; +create table bug16206 (a int) engine= bdb; +insert into bug16206 values(0); +insert into bug16206 values(1); +start transaction; +insert into bug16206 values(2); +commit; +insert into bug16206 values(3); +--replace_result $VERSION VERSION +--replace_column 1 f 2 n 5 n +show binlog events; +drop table bug16206; + +set autocommit=0; + + +--echo End of 5.0 tests diff --git a/storage/ndb/src/kernel/blocks/backup/Backup.cpp b/storage/ndb/src/kernel/blocks/backup/Backup.cpp index 64e2c41aa69..fb234c2afef 100644 --- a/storage/ndb/src/kernel/blocks/backup/Backup.cpp +++ b/storage/ndb/src/kernel/blocks/backup/Backup.cpp @@ -967,6 +967,7 @@ Backup::checkNodeFail(Signal* signal, ref->backupPtr = ptr.i; ref->backupId = ptr.p->backupId; ref->errorCode = AbortBackupOrd::BackupFailureDueToNodeFail; + ref->nodeId = getOwnNodeId(); gsn= GSN_STOP_BACKUP_REF; len= StopBackupRef::SignalLength; pos= &ref->nodeId - signal->getDataPtr(); @@ -2080,6 +2081,15 @@ Backup::sendDropTrig(Signal* signal, BackupRecordPtr ptr) /** * Insert footers */ + //if backup error, we needn't insert footers + if(ptr.p->checkError()) + { + jam(); + closeFiles(signal, ptr); + ptr.p->errorCode = 0; + return; + } + { BackupFilePtr filePtr LINT_SET_PTR; ptr.p->files.getPtr(filePtr, ptr.p->logFilePtr); @@ -4186,6 +4196,37 @@ Backup::checkFile(Signal* signal, BackupFilePtr filePtr) #if 0 ndbout << "Ptr to data = " << hex << tmp << endl; #endif + BackupRecordPtr ptr LINT_SET_PTR; + c_backupPool.getPtr(ptr, filePtr.p->backupPtr); + + if (ERROR_INSERTED(10036)) + { + jam(); + filePtr.p->m_flags &= ~(Uint32)BackupFile::BF_FILE_THREAD; + filePtr.p->errorCode = 2810; + ptr.p->setErrorCode(2810); + + if(ptr.p->m_gsn == GSN_STOP_BACKUP_REQ) + { + jam(); + closeFile(signal, ptr, filePtr); + } + return; + } + + if(filePtr.p->errorCode != 0) + { + jam(); + ptr.p->setErrorCode(filePtr.p->errorCode); + + if(ptr.p->m_gsn == GSN_STOP_BACKUP_REQ) + { + jam(); + closeFile(signal, ptr, filePtr); + } + return; + } + if (!ready_to_write(ready, sz, eof, filePtr.p)) { jam(); @@ -4217,8 +4258,6 @@ Backup::checkFile(Signal* signal, BackupFilePtr filePtr) ndbrequire(flags & BackupFile::BF_OPEN); ndbrequire(flags & BackupFile::BF_FILE_THREAD); - BackupRecordPtr ptr LINT_SET_PTR; - c_backupPool.getPtr(ptr, filePtr.p->backupPtr); closeFile(signal, ptr, filePtr); } @@ -4581,6 +4620,22 @@ Backup::closeFilesDone(Signal* signal, BackupRecordPtr ptr) jam(); + //error when do insert footer or close file + if(ptr.p->checkError()) + { + StopBackupRef * ref = (StopBackupRef*)signal->getDataPtr(); + ref->backupPtr = ptr.i; + ref->backupId = ptr.p->backupId; + ref->errorCode = ptr.p->errorCode; + ref->nodeId = getOwnNodeId(); + sendSignal(ptr.p->masterRef, GSN_STOP_BACKUP_REF, signal, + StopBackupConf::SignalLength, JBB); + + ptr.p->m_gsn = GSN_STOP_BACKUP_REF; + ptr.p->slaveState.setState(CLEANING); + return; + } + StopBackupConf* conf = (StopBackupConf*)signal->getDataPtrSend(); conf->backupId = ptr.p->backupId; conf->backupPtr = ptr.i; diff --git a/storage/ndb/src/ndbapi/ndberror.c b/storage/ndb/src/ndbapi/ndberror.c index a0417e5b118..e05b9c41b77 100644 --- a/storage/ndb/src/ndbapi/ndberror.c +++ b/storage/ndb/src/ndbapi/ndberror.c @@ -624,6 +624,8 @@ ErrorBundle ErrorCodes[] = { { 4273, DMEC, IE, "No blob table in dict cache" }, { 4274, DMEC, IE, "Corrupted main table PK in blob operation" }, { 4275, DMEC, AE, "The blob method is incompatible with operation type or lock mode" }, + { 2810, DMEC, TR, "No space left on the device" }, + { 2815, DMEC, TR, "Error in reading files, please check file system" }, { NO_CONTACT_WITH_PROCESS, DMEC, AE, "No contact with the process (dead ?)."}, diff --git a/storage/ndb/test/src/NdbBackup.cpp b/storage/ndb/test/src/NdbBackup.cpp index 42b15885089..3fb4de461f0 100644 --- a/storage/ndb/test/src/NdbBackup.cpp +++ b/storage/ndb/test/src/NdbBackup.cpp @@ -350,7 +350,8 @@ FailS_codes[] = { 10025, 10027, 10033, - 10035 + 10035, + 10036 }; int From bafa5fe8aa6a79ab5f28a9275d71647049709863 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 28 Sep 2007 09:16:41 +0800 Subject: [PATCH 03/32] BUG#29851 TRUNCATE causes error 4350 from cluster in INSERT... ON DUPLICATE KEY UPDATE mysql-test/r/ndb_alter_table2.result: Add test case for BUG#29851 mysql-test/t/ndb_alter_table2.test: Add test case for BUG#29851 sql/ha_ndbcluster.cc: Indexes are dropped also when dropping table in GlobalDictCache --- mysql-test/r/ndb_alter_table2.result | 19 +++++++++++++++++ mysql-test/t/ndb_alter_table2.test | 31 ++++++++++++++++++++++++++++ sql/ha_ndbcluster.cc | 10 ++++++++- 3 files changed, 59 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/ndb_alter_table2.result b/mysql-test/r/ndb_alter_table2.result index 399578dc97b..886c300d53d 100644 --- a/mysql-test/r/ndb_alter_table2.result +++ b/mysql-test/r/ndb_alter_table2.result @@ -40,3 +40,22 @@ a b c select * from t1; a b c drop table t1; +DROP TABLE IF EXISTS truncate_test; +CREATE TABLE truncate_test ( +i INT PRIMARY KEY, +a INT, +b VARCHAR(11), +UNIQUE KEY (a) +) ENGINE = NDB; +INSERT INTO truncate_test VALUES (1, 1, 'test') ON DUPLICATE KEY UPDATE b = 'new'; +INSERT INTO truncate_test VALUES (1, 1, 'test') ON DUPLICATE KEY UPDATE b = 'new'; +TRUNCATE truncate_test; +INSERT INTO truncate_test VALUES (1, 1, 'test') ON DUPLICATE KEY UPDATE b = 'new'; +SELECT * FROM truncate_test; +i a b +1 1 test +INSERT INTO truncate_test VALUES (1, 1, 'test') ON DUPLICATE KEY UPDATE b = 'new'; +SELECT * FROM truncate_test; +i a b +1 1 new +DROP TABLE truncate_test; diff --git a/mysql-test/t/ndb_alter_table2.test b/mysql-test/t/ndb_alter_table2.test index 3861fcc6c9d..99c201f7370 100644 --- a/mysql-test/t/ndb_alter_table2.test +++ b/mysql-test/t/ndb_alter_table2.test @@ -81,3 +81,34 @@ select * from t1; select * from t1; drop table t1; + +#For BUG#29851 TRUNCATE causes error 4350 from cluster in INSERT... ON DUPLICATE KEY UPDATE + +connection con1; + +--disable_warnings +DROP TABLE IF EXISTS truncate_test; +--enable_warnings + +CREATE TABLE truncate_test ( + i INT PRIMARY KEY, + a INT, + b VARCHAR(11), + UNIQUE KEY (a) +) ENGINE = NDB; + +INSERT INTO truncate_test VALUES (1, 1, 'test') ON DUPLICATE KEY UPDATE b = 'new'; +INSERT INTO truncate_test VALUES (1, 1, 'test') ON DUPLICATE KEY UPDATE b = 'new'; + +connection con2; +TRUNCATE truncate_test; + +connection con1; +INSERT INTO truncate_test VALUES (1, 1, 'test') ON DUPLICATE KEY UPDATE b = 'new'; +SELECT * FROM truncate_test; + +connection con2; +INSERT INTO truncate_test VALUES (1, 1, 'test') ON DUPLICATE KEY UPDATE b = 'new'; +SELECT * FROM truncate_test; + +DROP TABLE truncate_test; diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 03b6bcf3242..76857900ea2 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -439,7 +439,8 @@ void ha_ndbcluster::no_uncommitted_rows_reset(THD *thd) void ha_ndbcluster::invalidate_dictionary_cache(bool global) { - NDBDICT *dict= get_ndb()->getDictionary(); + Ndb * ndb= get_ndb(); + NDBDICT *dict= ndb->getDictionary(); DBUG_ENTER("invalidate_dictionary_cache"); DBUG_PRINT("info", ("invalidating %s", m_tabname)); @@ -459,6 +460,7 @@ void ha_ndbcluster::invalidate_dictionary_cache(bool global) } else dict->removeCachedTable(m_tabname); + build_index_list(ndb, table, ILBP_OPEN); table->s->version=0L; /* Free when thread is ready */ /* Invalidate indexes */ for (uint i= 0; i < table->s->keys; i++) @@ -470,17 +472,23 @@ void ha_ndbcluster::invalidate_dictionary_cache(bool global) switch (idx_type) { case PRIMARY_KEY_ORDERED_INDEX: case ORDERED_INDEX: + if (!index) + break; if (global) dict->invalidateIndex(index->getName(), m_tabname); else dict->removeCachedIndex(index->getName(), m_tabname); break; case UNIQUE_ORDERED_INDEX: + if (!index) + break; if (global) dict->invalidateIndex(index->getName(), m_tabname); else dict->removeCachedIndex(index->getName(), m_tabname); case UNIQUE_INDEX: + if (!unique_index) + break; if (global) dict->invalidateIndex(unique_index->getName(), m_tabname); else From 3a3e2c796c9a3555b445b940de5670ca683fee2f Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 28 Sep 2007 09:49:16 +0800 Subject: [PATCH 04/32] BUG#28298 Node Id larger than MAX_NDB_NODES in config file doesn't generate error ndb/include/kernel/ndb_limits.h: 1) define a macro MAX_DATA_NODE_ID to set the max ID of data nodes to be MAX_NDB_NODES - 1 2) define a macro MAX_NODES_ID to set the max ID of API and MGM to be MAX_NODES -1 ndb/src/mgmsrv/ConfigInfo.cpp: 1) replace MAX_NODES with MAX_DATA_NODE_ID (= MAX_NDB_NODES - 1) when the NodeId represents data nodes. 2) replace MAX_NODES with MAX_NODES_ID (= MAX_NODES -1) when the NodeId represents API or MGM nodes. --- ndb/include/kernel/ndb_limits.h | 11 +++++++++++ ndb/src/mgmsrv/ConfigInfo.cpp | 12 ++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/ndb/include/kernel/ndb_limits.h b/ndb/include/kernel/ndb_limits.h index c82288c762a..82fd0bd5d51 100644 --- a/ndb/include/kernel/ndb_limits.h +++ b/ndb/include/kernel/ndb_limits.h @@ -27,6 +27,17 @@ #define MAX_NDB_NODES 49 #define MAX_NODES 64 +/************************************************************************** + * IT SHOULD BE (MAX_NDB_NODES - 1). + * WHEN MAX_NDB_NODE IS CHANGED, IT SHOULD BE CHANGED ALSO + **************************************************************************/ +#define MAX_DATA_NODE_ID 48 +/************************************************************************** + * IT SHOULD BE (MAX_NODES - 1). + * WHEN MAX_NODES IS CHANGED, IT SHOULD BE CHANGED ALSO + **************************************************************************/ +#define MAX_NODES_ID 63 + /** * MAX_API_NODES = MAX_NODES - No of NDB Nodes in use */ diff --git a/ndb/src/mgmsrv/ConfigInfo.cpp b/ndb/src/mgmsrv/ConfigInfo.cpp index 0cf37b5f874..657dccb0d98 100644 --- a/ndb/src/mgmsrv/ConfigInfo.cpp +++ b/ndb/src/mgmsrv/ConfigInfo.cpp @@ -398,7 +398,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::CI_INT, MANDATORY, "1", - STR_VALUE(MAX_NODES) }, + STR_VALUE(MAX_DATA_NODE_ID) }, { CFG_NODE_ID, @@ -410,7 +410,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::CI_INT, MANDATORY, "1", - STR_VALUE(MAX_NODES) }, + STR_VALUE(MAX_DATA_NODE_ID) }, { KEY_INTERNAL, @@ -1261,7 +1261,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::CI_INT, MANDATORY, "1", - STR_VALUE(MAX_NODES) }, + STR_VALUE(MAX_NODES_ID) }, { CFG_NODE_ID, @@ -1273,7 +1273,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::CI_INT, MANDATORY, "1", - STR_VALUE(MAX_NODES) }, + STR_VALUE(MAX_NODES_ID) }, { KEY_INTERNAL, @@ -1404,7 +1404,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::CI_INT, MANDATORY, "1", - STR_VALUE(MAX_NODES) }, + STR_VALUE(MAX_NODES_ID) }, { CFG_NODE_ID, @@ -1416,7 +1416,7 @@ const ConfigInfo::ParamInfo ConfigInfo::m_ParamInfo[] = { ConfigInfo::CI_INT, MANDATORY, "1", - STR_VALUE(MAX_NODES) }, + STR_VALUE(MAX_NODES_ID) }, { CFG_LOG_DESTINATION, From dc7ee1f3cb213c9169e0fd7939d01b8e3fccf095 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 12 Nov 2007 14:53:25 +0000 Subject: [PATCH 05/32] BUG#29186 Return error to client in the following condition: 1: Create a log file which is larger than 4G in 32-bit host. 2: Create a data file (tablespace) which is larger than 4G in 32-bit host. storage/ndb/include/kernel/signaldata/CreateFilegroupImpl.hpp: Add error code for log file too large storage/ndb/src/kernel/blocks/ERROR_codes.txt: Add error insert code in lgman and tsman storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp: Add error code definination of lgman and tsman storage/ndb/src/kernel/blocks/lgman.cpp: Return REF when log file more than 4G in 32-bits host storage/ndb/src/kernel/blocks/tsman.cpp: return FER when data file larger than 4G in 32-bits host storage/ndb/src/ndbapi/ndberror.c: Add describe of new errorCode storage/ndb/test/ndbapi/testDict.cpp: Add test case for bug29186 --- mysql-test/r/bdb_notembedded.result | 35 ++++ mysql-test/t/bdb_notembedded.test | 38 ++++ .../kernel/signaldata/CreateFilegroupImpl.hpp | 3 +- storage/ndb/src/kernel/blocks/ERROR_codes.txt | 10 ++ .../ndb/src/kernel/blocks/dbdih/DbdihMain.cpp | 6 + storage/ndb/src/kernel/blocks/lgman.cpp | 16 ++ storage/ndb/src/kernel/blocks/tsman.cpp | 16 ++ storage/ndb/src/ndbapi/ndberror.c | 1 + storage/ndb/test/ndbapi/testDict.cpp | 166 ++++++++++++++++++ 9 files changed, 290 insertions(+), 1 deletion(-) create mode 100644 mysql-test/r/bdb_notembedded.result create mode 100644 mysql-test/t/bdb_notembedded.test diff --git a/mysql-test/r/bdb_notembedded.result b/mysql-test/r/bdb_notembedded.result new file mode 100644 index 00000000000..14cb5fad915 --- /dev/null +++ b/mysql-test/r/bdb_notembedded.result @@ -0,0 +1,35 @@ +set autocommit=1; +reset master; +create table bug16206 (a int); +insert into bug16206 values(1); +start transaction; +insert into bug16206 values(2); +commit; +show binlog events; +Log_name Pos Event_type Server_id End_log_pos Info +f n Format_desc 1 n Server ver: VERSION, Binlog ver: 4 +f n Query 1 n use `test`; create table bug16206 (a int) +f n Query 1 n use `test`; insert into bug16206 values(1) +f n Query 1 n use `test`; insert into bug16206 values(2) +drop table bug16206; +reset master; +create table bug16206 (a int) engine= bdb; +insert into bug16206 values(0); +insert into bug16206 values(1); +start transaction; +insert into bug16206 values(2); +commit; +insert into bug16206 values(3); +show binlog events; +Log_name Pos Event_type Server_id End_log_pos Info +f n Format_desc 1 n Server ver: VERSION, Binlog ver: 4 +f n Query 1 n use `test`; create table bug16206 (a int) engine= bdb +f n Query 1 n use `test`; insert into bug16206 values(0) +f n Query 1 n use `test`; insert into bug16206 values(1) +f n Query 1 n use `test`; BEGIN +f n Query 1 n use `test`; insert into bug16206 values(2) +f n Query 1 n use `test`; COMMIT +f n Query 1 n use `test`; insert into bug16206 values(3) +drop table bug16206; +set autocommit=0; +End of 5.0 tests diff --git a/mysql-test/t/bdb_notembedded.test b/mysql-test/t/bdb_notembedded.test new file mode 100644 index 00000000000..24e64ebbfb2 --- /dev/null +++ b/mysql-test/t/bdb_notembedded.test @@ -0,0 +1,38 @@ +-- source include/not_embedded.inc +-- source include/have_bdb.inc + +# +# Bug #16206: Superfluous COMMIT event in binlog when updating BDB in autocommit mode +# +set autocommit=1; + +let $VERSION=`select version()`; + +reset master; +create table bug16206 (a int); +insert into bug16206 values(1); +start transaction; +insert into bug16206 values(2); +commit; +--replace_result $VERSION VERSION +--replace_column 1 f 2 n 5 n +show binlog events; +drop table bug16206; + +reset master; +create table bug16206 (a int) engine= bdb; +insert into bug16206 values(0); +insert into bug16206 values(1); +start transaction; +insert into bug16206 values(2); +commit; +insert into bug16206 values(3); +--replace_result $VERSION VERSION +--replace_column 1 f 2 n 5 n +show binlog events; +drop table bug16206; + +set autocommit=0; + + +--echo End of 5.0 tests diff --git a/storage/ndb/include/kernel/signaldata/CreateFilegroupImpl.hpp b/storage/ndb/include/kernel/signaldata/CreateFilegroupImpl.hpp index 6140e78cc5a..bbd3e818681 100644 --- a/storage/ndb/include/kernel/signaldata/CreateFilegroupImpl.hpp +++ b/storage/ndb/include/kernel/signaldata/CreateFilegroupImpl.hpp @@ -163,7 +163,8 @@ struct CreateFileImplRef { InvalidFileMetadata = 1510, OutOfMemory = 1511, FileReadError = 1512, - FilegroupNotOnline = 1513 + FilegroupNotOnline = 1513, + FileSizeTooLarge = 1515 }; Uint32 senderData; diff --git a/storage/ndb/src/kernel/blocks/ERROR_codes.txt b/storage/ndb/src/kernel/blocks/ERROR_codes.txt index acfbf649522..5ed4f5b0663 100644 --- a/storage/ndb/src/kernel/blocks/ERROR_codes.txt +++ b/storage/ndb/src/kernel/blocks/ERROR_codes.txt @@ -12,6 +12,8 @@ Next BACKUP 10038 Next DBUTIL 11002 Next DBTUX 12008 Next SUMA 13001 +Next LGMAN 15001 +Next TSMAN 16001 TESTING NODE FAILURE, ARBITRATION --------------------------------- @@ -535,3 +537,11 @@ NDBCNTR: 1000: Crash insertion on SystemError::CopyFragRef 1001: Delay sending NODE_FAILREP (to own node), until error is cleared + +LGMAN: +----- +15000: Fail to create log file + +TSMAN: +----- +16000: Fail to create data file diff --git a/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp b/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp index 762d4ea5141..d2d989ce5b9 100644 --- a/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp +++ b/storage/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp @@ -8286,6 +8286,12 @@ void Dbdih::execDIHNDBTAMPER(Signal* signal) } else if (tuserpointer < 15000) { jam(); tuserblockref = DBDICT_REF; + } else if (tuserpointer < 16000) { + jam(); + tuserblockref = LGMAN_REF; + } else if (tuserpointer < 17000) { + jam(); + tuserblockref = TSMAN_REF; } else if (tuserpointer < 30000) { /*--------------------------------------------------------------------*/ // Ignore errors in the 20000-range. diff --git a/storage/ndb/src/kernel/blocks/lgman.cpp b/storage/ndb/src/kernel/blocks/lgman.cpp index 23738717580..b5e3b55dba5 100644 --- a/storage/ndb/src/kernel/blocks/lgman.cpp +++ b/storage/ndb/src/kernel/blocks/lgman.cpp @@ -547,6 +547,22 @@ Lgman::execCREATE_FILE_REQ(Signal* signal) break; } + if(ERROR_INSERTED(15000) || + (sizeof(void*) == 4 && req->file_size_hi & 0xFFFFFFFF)) + { + jam(); + if(signal->getNoOfSections()) + releaseSections(signal); + + CreateFileImplRef* ref= (CreateFileImplRef*)signal->getDataPtr(); + ref->senderData = senderData; + ref->senderRef = reference(); + ref->errorCode = CreateFileImplRef::FileSizeTooLarge; + sendSignal(senderRef, GSN_CREATE_FILE_REF, signal, + CreateFileImplRef::SignalLength, JBB); + return; + } + new (file_ptr.p) Undofile(req, ptr.i); Local_undofile_list tmp(m_file_pool, ptr.p->m_meta_files); diff --git a/storage/ndb/src/kernel/blocks/tsman.cpp b/storage/ndb/src/kernel/blocks/tsman.cpp index 8f61ec0cf7b..62d169a0081 100644 --- a/storage/ndb/src/kernel/blocks/tsman.cpp +++ b/storage/ndb/src/kernel/blocks/tsman.cpp @@ -523,6 +523,22 @@ Tsman::execCREATE_FILE_REQ(Signal* signal){ break; } + if(ERROR_INSERTED(16000) || + (sizeof(void*) == 4 && req->file_size_hi & 0xFFFFFFFF)) + { + jam(); + if(signal->getNoOfSections()) + releaseSections(signal); + + CreateFileImplRef* ref= (CreateFileImplRef*)signal->getDataPtr(); + ref->senderData = senderData; + ref->senderRef = reference(); + ref->errorCode = CreateFileImplRef::FileSizeTooLarge; + sendSignal(senderRef, GSN_CREATE_FILE_REF, signal, + CreateFileImplRef::SignalLength, JBB); + return; + } + new (file_ptr.p) Datafile(req); Local_datafile_list tmp(m_file_pool, ptr.p->m_meta_files); tmp.add(file_ptr); diff --git a/storage/ndb/src/ndbapi/ndberror.c b/storage/ndb/src/ndbapi/ndberror.c index a0417e5b118..d1b77152b00 100644 --- a/storage/ndb/src/ndbapi/ndberror.c +++ b/storage/ndb/src/ndbapi/ndberror.c @@ -426,6 +426,7 @@ ErrorBundle ErrorCodes[] = { { 1512, DMEC, SE, "File read error" }, { 1513, DMEC, IE, "Filegroup not online" }, { 1514, DMEC, SE, "Currently there is a limit of one logfile group" }, + { 1515, DMEC, SE, "Currently there is a 4G limit of one undo/data-file in 32-bit host" }, { 773, DMEC, SE, "Out of string memory, please modify StringMemory config parameter" }, { 775, DMEC, SE, "Create file is not supported when Diskless=1" }, diff --git a/storage/ndb/test/ndbapi/testDict.cpp b/storage/ndb/test/ndbapi/testDict.cpp index 13c071f968e..22b795a8dba 100644 --- a/storage/ndb/test/ndbapi/testDict.cpp +++ b/storage/ndb/test/ndbapi/testDict.cpp @@ -2357,6 +2357,168 @@ runBug24631(NDBT_Context* ctx, NDBT_Step* step) return NDBT_OK; } +int +runBug29186(NDBT_Context* ctx, NDBT_Step* step) +{ + int lgError = 15000; + int tsError = 16000; + int res; + char lgname[256]; + char ufname[256]; + char tsname[256]; + char dfname[256]; + + NdbRestarter restarter; + + if (restarter.getNumDbNodes() < 2){ + ctx->stopTest(); + return NDBT_OK; + } + + Ndb* pNdb = GETNDB(step); + NdbDictionary::Dictionary* pDict = pNdb->getDictionary(); + NdbDictionary::Dictionary::List list; + + if (pDict->listObjects(list) == -1) + return NDBT_FAILED; + + // 1.create logfile group + const char * lgfound = 0; + + for (Uint32 i = 0; icreateLogfileGroup(lg) != 0) + { + g_err << "Failed to create logfilegroup:" + << endl << pDict->getNdbError() << endl; + return NDBT_FAILED; + } + } + else + { + BaseString::snprintf(lgname, sizeof(lgname), "%s", lgfound); + } + + if(restarter.waitClusterStarted(60)){ + g_err << "waitClusterStarted failed"<< endl; + return NDBT_FAILED; + } + + if(restarter.insertErrorInAllNodes(lgError) != 0){ + g_err << "failed to set error insert"<< endl; + return NDBT_FAILED; + } + + g_info << "error inserted" << endl; + g_info << "waiting some before add log file" << endl; + g_info << "starting create log file group" << endl; + + NdbDictionary::Undofile uf; + BaseString::snprintf(ufname, sizeof(ufname), "%s-%u", lgname, rand()); + uf.setPath(ufname); + uf.setSize(2*1024*1024); + uf.setLogfileGroup(lgname); + + if(pDict->createUndofile(uf) == 0) + { + g_err << "Create log file group should fail on error_insertion " << lgError << endl; + return NDBT_FAILED; + } + + //clear lg error + if(restarter.insertErrorInAllNodes(15099) != 0){ + g_err << "failed to set error insert"<< endl; + return NDBT_FAILED; + } + NdbSleep_SecSleep(5); + + //lg error has been cleared, so we can add undo file + if(pDict->createUndofile(uf) != 0) + { + g_err << "Failed to create undofile:" + << endl << pDict->getNdbError() << endl; + return NDBT_FAILED; + } + + if(restarter.waitClusterStarted(60)){ + g_err << "waitClusterStarted failed"<< endl; + return NDBT_FAILED; + } + + if(restarter.insertErrorInAllNodes(tsError) != 0){ + g_err << "failed to set error insert"<< endl; + return NDBT_FAILED; + } + g_info << "error inserted" << endl; + g_info << "waiting some before create table space" << endl; + g_info << "starting create table space" << endl; + + //r = runCreateTablespace(ctx, step); + BaseString::snprintf(tsname, sizeof(tsname), "TS-%u", rand()); + BaseString::snprintf(dfname, sizeof(dfname), "%s-%u-1.dat", tsname, rand()); + + NdbDictionary::Tablespace ts; + ts.setName(tsname); + ts.setExtentSize(1024*1024); + ts.setDefaultLogfileGroup(lgname); + + if(pDict->createTablespace(ts) != 0) + { + g_err << "Failed to create tablespace:" + << endl << pDict->getNdbError() << endl; + return NDBT_FAILED; + } + + NdbDictionary::Datafile df; + df.setPath(dfname); + df.setSize(1*1024*1024); + df.setTablespace(tsname); + + if(pDict->createDatafile(df) == 0) + { + g_err << "Create table space should fail on error_insertion " << tsError << endl; + return NDBT_FAILED; + } + //Clear the inserted error + if(restarter.insertErrorInAllNodes(16099) != 0){ + g_err << "failed to set error insert"<< endl; + return NDBT_FAILED; + } + NdbSleep_SecSleep(5); + + if (pDict->dropTablespace(pDict->getTablespace(tsname)) != 0) + { + g_err << "Failed to drop tablespace: " << pDict->getNdbError() << endl; + return NDBT_FAILED; + } + + if (lgfound == 0) + { + if (pDict->dropLogfileGroup(pDict->getLogfileGroup(lgname)) != 0) + return NDBT_FAILED; + } + + return NDBT_OK; +} + struct RandSchemaOp { struct Obj @@ -2864,6 +3026,10 @@ TESTCASE("Bug24631", ""){ INITIALIZER(runBug24631); } +TESTCASE("Bug29186", + ""){ + INITIALIZER(runBug29186); +} NDBT_TESTSUITE_END(testDict); int main(int argc, const char** argv){ From 37b188cdffee19d77769ba99a719d436633f6e5b Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 29 Nov 2007 19:19:55 +0800 Subject: [PATCH 06/32] BUG#30417 Cluster misbehaves on auto-inc w/o PK. storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp: The check that how many auto_increment columns in table are there should be preceded creating the table. If there are more than one auto_increment columns, the table shouldn't be created. mysql-test/suite/ndb/r/ndb_autoinc.result: Adding test case for auto_increment isn't the default primary key columns mysql-test/suite/ndb/t/ndb_autoinc.test: Adding test case for auto_increment isn't the default primary key columns --- mysql-test/suite/ndb/r/ndb_autoinc.result | 38 +++++++++++++++++ mysql-test/suite/ndb/t/ndb_autoinc.test | 43 ++++++++++++++++++++ storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp | 31 +++++++------- 3 files changed, 97 insertions(+), 15 deletions(-) create mode 100644 mysql-test/suite/ndb/r/ndb_autoinc.result create mode 100644 mysql-test/suite/ndb/t/ndb_autoinc.test diff --git a/mysql-test/suite/ndb/r/ndb_autoinc.result b/mysql-test/suite/ndb/r/ndb_autoinc.result new file mode 100644 index 00000000000..7ba5ab8def7 --- /dev/null +++ b/mysql-test/suite/ndb/r/ndb_autoinc.result @@ -0,0 +1,38 @@ +DROP TABLE IF EXISTS t1,t2,t3; +USE test; +CREATE TABLE t1 ( +id INT AUTO_INCREMENT, +PRIMARY KEY(id) +) ENGINE=NDBCLUSTER; +CREATE TABLE t2 ( +id INT AUTO_INCREMENT, +KEY(id) +) ENGINE=NDBCLUSTER; +ERROR HY000: Can't create table 'test.t2' (errno: 4335) +SHOW TABLES; +Tables_in_test +t1 +CREATE TABLE t3 ( +id INT AUTO_INCREMENT, +KEY(id) +) ENGINE=MYISAM; +ALTER TABLE t3 +ENGINE NDBCLUSTER; +ERROR HY000: Can't create table 'test.#sql-7b9e_3' (errno: 4335) +SHOW CREATE TABLE t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + KEY `id` (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +ALTER TABLE t3 +ADD PRIMARY KEY (id); +SHOW CREATE TABLE t3; +Table Create Table +t3 CREATE TABLE `t3` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`id`), + KEY `id` (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +DROP TABLE t1, t3; +End of 5.1 tests diff --git a/mysql-test/suite/ndb/t/ndb_autoinc.test b/mysql-test/suite/ndb/t/ndb_autoinc.test new file mode 100644 index 00000000000..3e7ba7bdf6a --- /dev/null +++ b/mysql-test/suite/ndb/t/ndb_autoinc.test @@ -0,0 +1,43 @@ +-- source include/have_ndb.inc +-- source include/not_embedded.inc + +--disable_warnings +DROP TABLE IF EXISTS t1,t2,t3; +--enable_warnings + +USE test; + +CREATE TABLE t1 ( + id INT AUTO_INCREMENT, + PRIMARY KEY(id) +) ENGINE=NDBCLUSTER; + +# Test For bug#30417 +--error 1005 + +CREATE TABLE t2 ( + id INT AUTO_INCREMENT, + KEY(id) +) ENGINE=NDBCLUSTER; + +SHOW TABLES; + +CREATE TABLE t3 ( + id INT AUTO_INCREMENT, + KEY(id) +) ENGINE=MYISAM; + +--error 1005 +ALTER TABLE t3 +ENGINE NDBCLUSTER; + +SHOW CREATE TABLE t3; + +ALTER TABLE t3 +ADD PRIMARY KEY (id); + +SHOW CREATE TABLE t3; + +DROP TABLE t1, t3; + +--echo End of 5.1 tests diff --git a/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp b/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp index ab6d90ad59e..953cfffd73b 100644 --- a/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp +++ b/storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp @@ -2340,6 +2340,22 @@ NdbDictionaryImpl::createTable(NdbTableImpl &t) { DBUG_ENTER("NdbDictionaryImpl::createTable"); + + bool autoIncrement = false; + Uint64 initialValue = 0; + for (Uint32 i = 0; i < t.m_columns.size(); i++) { + const NdbColumnImpl* c = t.m_columns[i]; + assert(c != NULL); + if (c->m_autoIncrement) { + if (autoIncrement) { + m_error.code = 4335; + DBUG_RETURN(-1); + } + autoIncrement = true; + initialValue = c->m_autoIncrementInitialValue; + } + } + // if the new name has not been set, use the copied name if (t.m_newExternalName.empty()) { @@ -2377,21 +2393,6 @@ NdbDictionaryImpl::createTable(NdbTableImpl &t) // auto-increment - use "t" because initial value is not in DICT { - bool autoIncrement = false; - Uint64 initialValue = 0; - for (Uint32 i = 0; i < t.m_columns.size(); i++) { - const NdbColumnImpl* c = t.m_columns[i]; - assert(c != NULL); - if (c->m_autoIncrement) { - if (autoIncrement) { - m_error.code = 4335; - delete t2; - DBUG_RETURN(-1); - } - autoIncrement = true; - initialValue = c->m_autoIncrementInitialValue; - } - } if (autoIncrement) { // XXX unlikely race condition - t.m_id may no longer be same table // the tuple id range is not used on input From 93af2d9dc144f87ee6cb09e738a417d88f591d8c Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 30 Nov 2007 09:56:04 +0800 Subject: [PATCH 07/32] BUG#31245 Stress test fails on NDB:"Unknow prepared statement handler" mysql-test/suite/stress/t/ddl_ndb.test: The default connection should be "default connection". If there is no this statement added, the default connection is server1. --- mysql-test/r/bdb_notembedded.result | 35 ++++++++++++++++++++++++ mysql-test/suite/stress/t/ddl_ndb.test | 2 ++ mysql-test/t/bdb_notembedded.test | 38 ++++++++++++++++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 mysql-test/r/bdb_notembedded.result create mode 100644 mysql-test/t/bdb_notembedded.test diff --git a/mysql-test/r/bdb_notembedded.result b/mysql-test/r/bdb_notembedded.result new file mode 100644 index 00000000000..14cb5fad915 --- /dev/null +++ b/mysql-test/r/bdb_notembedded.result @@ -0,0 +1,35 @@ +set autocommit=1; +reset master; +create table bug16206 (a int); +insert into bug16206 values(1); +start transaction; +insert into bug16206 values(2); +commit; +show binlog events; +Log_name Pos Event_type Server_id End_log_pos Info +f n Format_desc 1 n Server ver: VERSION, Binlog ver: 4 +f n Query 1 n use `test`; create table bug16206 (a int) +f n Query 1 n use `test`; insert into bug16206 values(1) +f n Query 1 n use `test`; insert into bug16206 values(2) +drop table bug16206; +reset master; +create table bug16206 (a int) engine= bdb; +insert into bug16206 values(0); +insert into bug16206 values(1); +start transaction; +insert into bug16206 values(2); +commit; +insert into bug16206 values(3); +show binlog events; +Log_name Pos Event_type Server_id End_log_pos Info +f n Format_desc 1 n Server ver: VERSION, Binlog ver: 4 +f n Query 1 n use `test`; create table bug16206 (a int) engine= bdb +f n Query 1 n use `test`; insert into bug16206 values(0) +f n Query 1 n use `test`; insert into bug16206 values(1) +f n Query 1 n use `test`; BEGIN +f n Query 1 n use `test`; insert into bug16206 values(2) +f n Query 1 n use `test`; COMMIT +f n Query 1 n use `test`; insert into bug16206 values(3) +drop table bug16206; +set autocommit=0; +End of 5.0 tests diff --git a/mysql-test/suite/stress/t/ddl_ndb.test b/mysql-test/suite/stress/t/ddl_ndb.test index 7eb45da8739..1e0a3680f8a 100644 --- a/mysql-test/suite/stress/t/ddl_ndb.test +++ b/mysql-test/suite/stress/t/ddl_ndb.test @@ -10,6 +10,8 @@ # Storage engine to be used in CREATE TABLE --source include/have_ndb.inc +connection default; + let $engine_type= NDB; diff --git a/mysql-test/t/bdb_notembedded.test b/mysql-test/t/bdb_notembedded.test new file mode 100644 index 00000000000..24e64ebbfb2 --- /dev/null +++ b/mysql-test/t/bdb_notembedded.test @@ -0,0 +1,38 @@ +-- source include/not_embedded.inc +-- source include/have_bdb.inc + +# +# Bug #16206: Superfluous COMMIT event in binlog when updating BDB in autocommit mode +# +set autocommit=1; + +let $VERSION=`select version()`; + +reset master; +create table bug16206 (a int); +insert into bug16206 values(1); +start transaction; +insert into bug16206 values(2); +commit; +--replace_result $VERSION VERSION +--replace_column 1 f 2 n 5 n +show binlog events; +drop table bug16206; + +reset master; +create table bug16206 (a int) engine= bdb; +insert into bug16206 values(0); +insert into bug16206 values(1); +start transaction; +insert into bug16206 values(2); +commit; +insert into bug16206 values(3); +--replace_result $VERSION VERSION +--replace_column 1 f 2 n 5 n +show binlog events; +drop table bug16206; + +set autocommit=0; + + +--echo End of 5.0 tests From 6c4500517dc32805efcef75e478eb1c0f7e34284 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 14 Dec 2007 13:43:48 +0100 Subject: [PATCH 08/32] Bug #33237 NDB_MGM 'eat' 99% cpu utilization --- mysql-test/r/bdb_notembedded.result | 35 ---------------------- mysql-test/t/bdb_notembedded.test | 38 ------------------------ ndb/src/mgmclient/CommandInterpreter.cpp | 17 +++++++---- 3 files changed, 11 insertions(+), 79 deletions(-) delete mode 100644 mysql-test/r/bdb_notembedded.result delete mode 100644 mysql-test/t/bdb_notembedded.test diff --git a/mysql-test/r/bdb_notembedded.result b/mysql-test/r/bdb_notembedded.result deleted file mode 100644 index 14cb5fad915..00000000000 --- a/mysql-test/r/bdb_notembedded.result +++ /dev/null @@ -1,35 +0,0 @@ -set autocommit=1; -reset master; -create table bug16206 (a int); -insert into bug16206 values(1); -start transaction; -insert into bug16206 values(2); -commit; -show binlog events; -Log_name Pos Event_type Server_id End_log_pos Info -f n Format_desc 1 n Server ver: VERSION, Binlog ver: 4 -f n Query 1 n use `test`; create table bug16206 (a int) -f n Query 1 n use `test`; insert into bug16206 values(1) -f n Query 1 n use `test`; insert into bug16206 values(2) -drop table bug16206; -reset master; -create table bug16206 (a int) engine= bdb; -insert into bug16206 values(0); -insert into bug16206 values(1); -start transaction; -insert into bug16206 values(2); -commit; -insert into bug16206 values(3); -show binlog events; -Log_name Pos Event_type Server_id End_log_pos Info -f n Format_desc 1 n Server ver: VERSION, Binlog ver: 4 -f n Query 1 n use `test`; create table bug16206 (a int) engine= bdb -f n Query 1 n use `test`; insert into bug16206 values(0) -f n Query 1 n use `test`; insert into bug16206 values(1) -f n Query 1 n use `test`; BEGIN -f n Query 1 n use `test`; insert into bug16206 values(2) -f n Query 1 n use `test`; COMMIT -f n Query 1 n use `test`; insert into bug16206 values(3) -drop table bug16206; -set autocommit=0; -End of 5.0 tests diff --git a/mysql-test/t/bdb_notembedded.test b/mysql-test/t/bdb_notembedded.test deleted file mode 100644 index 24e64ebbfb2..00000000000 --- a/mysql-test/t/bdb_notembedded.test +++ /dev/null @@ -1,38 +0,0 @@ --- source include/not_embedded.inc --- source include/have_bdb.inc - -# -# Bug #16206: Superfluous COMMIT event in binlog when updating BDB in autocommit mode -# -set autocommit=1; - -let $VERSION=`select version()`; - -reset master; -create table bug16206 (a int); -insert into bug16206 values(1); -start transaction; -insert into bug16206 values(2); -commit; ---replace_result $VERSION VERSION ---replace_column 1 f 2 n 5 n -show binlog events; -drop table bug16206; - -reset master; -create table bug16206 (a int) engine= bdb; -insert into bug16206 values(0); -insert into bug16206 values(1); -start transaction; -insert into bug16206 values(2); -commit; -insert into bug16206 values(3); ---replace_result $VERSION VERSION ---replace_column 1 f 2 n 5 n -show binlog events; -drop table bug16206; - -set autocommit=0; - - ---echo End of 5.0 tests diff --git a/ndb/src/mgmclient/CommandInterpreter.cpp b/ndb/src/mgmclient/CommandInterpreter.cpp index 1036461d404..b72f7b12f9b 100644 --- a/ndb/src/mgmclient/CommandInterpreter.cpp +++ b/ndb/src/mgmclient/CommandInterpreter.cpp @@ -921,10 +921,14 @@ event_thread_run(void* p) { do_event_thread= 1; do { - if (ndb_logevent_get_next(log_handle, &log_event, 2000) <= 0) - continue; - Guard g(printmutex); - printLogEvent(&log_event); + int res= ndb_logevent_get_next(log_handle, &log_event, 2000); + if (res > 0) + { + Guard g(printmutex); + printLogEvent(&log_event); + } + else if (res < 0) + break; } while(do_event_thread); ndb_mgm_destroy_logevent_handle(&log_handle); } @@ -2722,8 +2726,9 @@ CommandInterpreter::executeStartBackup(char* parameters, bool interactive) { int count = 0; int retry = 0; + int res; do { - if (ndb_logevent_get_next(log_handle, &log_event, 60000) > 0) + if ((res= ndb_logevent_get_next(log_handle, &log_event, 60000)) > 0) { int print = 0; switch (log_event.type) { @@ -2753,7 +2758,7 @@ CommandInterpreter::executeStartBackup(char* parameters, bool interactive) { retry++; } - } while(count < 2 && retry < 3); + } while(res >= 0 && count < 2 && retry < 3); if (retry >= 3) ndbout << "get backup event failed for " << retry << " times" << endl; From 1f92b717b12d7fe9c12e5ebda9c625266722507a Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 18 Dec 2007 11:54:19 +0100 Subject: [PATCH 09/32] search for clone several step in the path name --- mysql-test/mysql-test-run.pl | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 18633d095b0..6d133c4c435 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -409,13 +409,20 @@ sub main () { { # use default and add any extra_suites as defined $opt_suites= $opt_suites_default; - my $ddd= basename(dirname($glob_mysql_test_dir)); - foreach my $extra_suite (@extra_suites) + my $ccc= dirname($glob_mysql_test_dir); + my $found= 0; + while (!$found and !($ccc eq "/") and !($ccc eq "")) { - if ($extra_suite->[0] eq "$ddd") + my $ddd= basename($ccc); + foreach my $extra_suite (@extra_suites) { - $opt_suites= "$extra_suite->[1],$opt_suites"; + if ($extra_suite->[0] eq "$ddd") + { + $opt_suites= "$extra_suite->[1],$opt_suites"; + $found= 1; + } } + $ccc= dirname($ccc); } } From c7dc182db9e7295224f6ca9b0238969962d78375 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 18 Dec 2007 13:40:35 +0100 Subject: [PATCH 10/32] Bug #33061: ORDER BY DESC becomes ASC in NDB partition pruning to one partition When partition pruning resulted in an ordered index scan spanning only one partition, any descending flag for the scan was wrongly discarded, turning ORDER BY DESC into ORDER BY ASC, and similar problems. Fixed by correctly passing descending flag in SCAN_TABREQ signal sent to data nodes. mysql-test/suite/ndb/r/ndb_partition_key.result: Test case. mysql-test/suite/ndb/r/ndb_partition_range.result: Test case. mysql-test/suite/ndb/t/ndb_partition_key.test: Test case. mysql-test/suite/ndb/t/ndb_partition_range.test: Test case. storage/ndb/src/ndbapi/NdbScanOperation.cpp: Even if ordered scan not requested (no need to merge-sorts scans of each partition), we still need to honor the descending flag. --- .../suite/ndb/r/ndb_partition_key.result | 17 ++++++++ .../suite/ndb/r/ndb_partition_range.result | 8 ++++ mysql-test/suite/ndb/t/ndb_partition_key.test | 4 ++ .../suite/ndb/t/ndb_partition_range.test | 5 +++ storage/ndb/src/ndbapi/NdbScanOperation.cpp | 42 ++++++++++++------- 5 files changed, 61 insertions(+), 15 deletions(-) diff --git a/mysql-test/suite/ndb/r/ndb_partition_key.result b/mysql-test/suite/ndb/r/ndb_partition_key.result index 60e96ce03b6..d87b59d6c0e 100644 --- a/mysql-test/suite/ndb/r/ndb_partition_key.result +++ b/mysql-test/suite/ndb/r/ndb_partition_key.result @@ -38,6 +38,23 @@ a b c 1 10 3 1 11 3 1 12 3 +select max(b) from t1 where a = 1; +max(b) +12 +select b from t1 where a = 1 order by b desc; +b +12 +11 +10 +9 +8 +7 +6 +5 +4 +3 +2 +1 DROP TABLE t1; CREATE TABLE t1 (a INT, b CHAR(10) COLLATE latin1_bin, c INT, d INT, PRIMARY KEY (a,b,c) USING HASH) diff --git a/mysql-test/suite/ndb/r/ndb_partition_range.result b/mysql-test/suite/ndb/r/ndb_partition_range.result index 0c717ed55e9..198898879df 100644 --- a/mysql-test/suite/ndb/r/ndb_partition_range.result +++ b/mysql-test/suite/ndb/r/ndb_partition_range.result @@ -46,6 +46,14 @@ a b c 1 1 1 6 1 1 10 1 1 +INSERT into t1 values (1, 2, 2); +select max(b) from t1 where a = 1; +max(b) +2 +select b from t1 where a = 1 order by b desc; +b +2 +1 drop table t1; CREATE TABLE t1 ( a int not null, diff --git a/mysql-test/suite/ndb/t/ndb_partition_key.test b/mysql-test/suite/ndb/t/ndb_partition_key.test index 78e2c9d15c2..df351ea42c7 100644 --- a/mysql-test/suite/ndb/t/ndb_partition_key.test +++ b/mysql-test/suite/ndb/t/ndb_partition_key.test @@ -38,6 +38,10 @@ insert into t1 values select * from t1 order by b; +# BUG#33061: ORDER BY DESC becomes ASC in NDB partition pruning to one partition +select max(b) from t1 where a = 1; +select b from t1 where a = 1 order by b desc; + DROP TABLE t1; # diff --git a/mysql-test/suite/ndb/t/ndb_partition_range.test b/mysql-test/suite/ndb/t/ndb_partition_range.test index 7952ba502d2..778e552c6d8 100644 --- a/mysql-test/suite/ndb/t/ndb_partition_range.test +++ b/mysql-test/suite/ndb/t/ndb_partition_range.test @@ -48,6 +48,11 @@ select * from t1 where a=21 order by a; select * from t1 where a in (1,6,10,21) order by a; select * from t1 where b=1 and a in (1,6,10,21) order by a; +# BUG#33061: ORDER BY DESC becomes ASC in NDB partition pruning to one partition +INSERT into t1 values (1, 2, 2); +select max(b) from t1 where a = 1; +select b from t1 where a = 1 order by b desc; + drop table t1; # diff --git a/storage/ndb/src/ndbapi/NdbScanOperation.cpp b/storage/ndb/src/ndbapi/NdbScanOperation.cpp index afbec070ac8..96a3ce4332e 100644 --- a/storage/ndb/src/ndbapi/NdbScanOperation.cpp +++ b/storage/ndb/src/ndbapi/NdbScanOperation.cpp @@ -1340,29 +1340,41 @@ NdbIndexScanOperation::readTuples(LockMode lm, if(insertATTRINFO(word) == -1) res = -1; } - if(!res && order_by){ - m_ordered = true; + if (!res) + { + /** + * Note that it is valid to have order_desc true and order_by false. + * + * This means that there will be no merge sort among partitions, but + * each partition will still be returned in descending sort order. + * + * This is useful eg. if it is known that the scan spans only one + * partition. + */ if (order_desc) { m_descending = true; ScanTabReq * req = CAST_PTR(ScanTabReq, theSCAN_TABREQ->getDataPtrSend()); ScanTabReq::setDescendingFlag(req->requestInfo, true); } - Uint32 cnt = m_accessTable->getNoOfColumns() - 1; - m_sort_columns = cnt; // -1 for NDB$NODE - m_current_api_receiver = m_sent_receivers_count; - m_api_receivers_count = m_sent_receivers_count; + if (order_by) { + m_ordered = true; + Uint32 cnt = m_accessTable->getNoOfColumns() - 1; + m_sort_columns = cnt; // -1 for NDB$NODE + m_current_api_receiver = m_sent_receivers_count; + m_api_receivers_count = m_sent_receivers_count; - m_sort_columns = cnt; - for(Uint32 i = 0; im_index->m_columns[i]; - const NdbColumnImpl* col = m_currentTable->getColumn(key->m_keyInfoPos); - NdbRecAttr* tmp = NdbScanOperation::getValue_impl(col, (char*)-1); - UintPtr newVal = UintPtr(tmp); - theTupleKeyDefined[i][0] = FAKE_PTR; - theTupleKeyDefined[i][1] = (newVal & 0xFFFFFFFF); + m_sort_columns = cnt; + for(Uint32 i = 0; im_index->m_columns[i]; + const NdbColumnImpl* col = m_currentTable->getColumn(key->m_keyInfoPos); + NdbRecAttr* tmp = NdbScanOperation::getValue_impl(col, (char*)-1); + UintPtr newVal = UintPtr(tmp); + theTupleKeyDefined[i][0] = FAKE_PTR; + theTupleKeyDefined[i][1] = (newVal & 0xFFFFFFFF); #if (SIZEOF_CHARP == 8) - theTupleKeyDefined[i][2] = (newVal >> 32); + theTupleKeyDefined[i][2] = (newVal >> 32); #endif + } } } m_this_bound_start = 0; From d687f1b45dde8e7d1e8a49836242054e5721e17b Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 19 Dec 2007 18:42:49 +0100 Subject: [PATCH 11/32] Bug #33375 all_set corrupted on table object - make sure to reset the read and write sets --- sql/handler.cc | 2 ++ sql/log_event.cc | 20 ++++++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/sql/handler.cc b/sql/handler.cc index a4926071598..3b1667b0d59 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -3710,6 +3710,8 @@ int handler::ha_reset() DBUG_ASSERT(inited == NONE); /* Free cache used by filesort */ free_io_cache(table); + /* reset the bitmaps to point to defaults */ + table->default_column_bitmaps(); DBUG_RETURN(reset()); } diff --git a/sql/log_event.cc b/sql/log_event.cc index 00e3dc89f6b..182b270ab4d 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -7837,7 +7837,7 @@ int Rows_log_event::find_row(const Relay_log_info *rli) { DBUG_PRINT("info",("ha_index_init returns error %d",error)); table->file->print_error(error, MYF(0)); - DBUG_RETURN(error); + goto err; } /* Fill key data for the row */ @@ -7870,7 +7870,7 @@ int Rows_log_event::find_row(const Relay_log_info *rli) DBUG_PRINT("info",("no record matching the key found in the table")); table->file->print_error(error, MYF(0)); table->file->ha_index_end(); - DBUG_RETURN(error); + goto err; } /* @@ -7898,7 +7898,7 @@ int Rows_log_event::find_row(const Relay_log_info *rli) if (table->key_info->flags & HA_NOSAME) { table->file->ha_index_end(); - DBUG_RETURN(0); + goto ok; } /* @@ -7930,7 +7930,7 @@ int Rows_log_event::find_row(const Relay_log_info *rli) DBUG_PRINT("info",("no record matching the given row found")); table->file->print_error(error, MYF(0)); table->file->ha_index_end(); - DBUG_RETURN(error); + goto err; } } @@ -7951,7 +7951,7 @@ int Rows_log_event::find_row(const Relay_log_info *rli) DBUG_PRINT("info",("error initializing table scan" " (ha_rnd_init returns %d)",error)); table->file->print_error(error, MYF(0)); - DBUG_RETURN(error); + goto err; } /* Continue until we find the right record or have made a full loop */ @@ -7975,7 +7975,7 @@ int Rows_log_event::find_row(const Relay_log_info *rli) " (rnd_next returns %d)",error)); table->file->print_error(error, MYF(0)); table->file->ha_rnd_end(); - DBUG_RETURN(error); + goto err; } } while (restart_count < 2 && record_compare(table)); @@ -7995,10 +7995,14 @@ int Rows_log_event::find_row(const Relay_log_info *rli) table->file->ha_rnd_end(); DBUG_ASSERT(error == HA_ERR_END_OF_FILE || error == HA_ERR_RECORD_DELETED || error == 0); - DBUG_RETURN(error); + goto err; } - +ok: + table->default_column_bitmaps(); DBUG_RETURN(0); +err: + table->default_column_bitmaps(); + DBUG_RETURN(error); } #endif From ecaeffade1e224a4e52096ca21659c19a8312c4c Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 20 Dec 2007 21:06:52 +0100 Subject: [PATCH 12/32] DbUtil.cpp: Rename: storage/ndb/test/src/dbutil.cpp -> storage/ndb/test/src/DbUtil.cpp DbUtil.hpp, DbUtil.cpp: Many changes based off a review from Magnus DbUtil.hpp: Rename: storage/ndb/test/include/dbutil.hpp -> storage/ndb/test/include/DbUtil.hpp storage/ndb/test/src/DbUtil.cpp: Many changes based off a review from Magnus storage/ndb/test/include/DbUtil.hpp: Many changes based off a review from Magnus --- mysql-test/r/bdb_notembedded.result | 35 ++++ mysql-test/t/bdb_notembedded.test | 38 ++++ storage/ndb/test/include/DbUtil.hpp | 129 +++++++++++++ storage/ndb/test/include/dbutil.hpp | 97 ---------- storage/ndb/test/src/DbUtil.cpp | 285 ++++++++++++++++++++++++++++ storage/ndb/test/src/dbutil.cpp | 176 ----------------- 6 files changed, 487 insertions(+), 273 deletions(-) create mode 100644 mysql-test/r/bdb_notembedded.result create mode 100644 mysql-test/t/bdb_notembedded.test create mode 100755 storage/ndb/test/include/DbUtil.hpp delete mode 100755 storage/ndb/test/include/dbutil.hpp create mode 100755 storage/ndb/test/src/DbUtil.cpp delete mode 100755 storage/ndb/test/src/dbutil.cpp diff --git a/mysql-test/r/bdb_notembedded.result b/mysql-test/r/bdb_notembedded.result new file mode 100644 index 00000000000..14cb5fad915 --- /dev/null +++ b/mysql-test/r/bdb_notembedded.result @@ -0,0 +1,35 @@ +set autocommit=1; +reset master; +create table bug16206 (a int); +insert into bug16206 values(1); +start transaction; +insert into bug16206 values(2); +commit; +show binlog events; +Log_name Pos Event_type Server_id End_log_pos Info +f n Format_desc 1 n Server ver: VERSION, Binlog ver: 4 +f n Query 1 n use `test`; create table bug16206 (a int) +f n Query 1 n use `test`; insert into bug16206 values(1) +f n Query 1 n use `test`; insert into bug16206 values(2) +drop table bug16206; +reset master; +create table bug16206 (a int) engine= bdb; +insert into bug16206 values(0); +insert into bug16206 values(1); +start transaction; +insert into bug16206 values(2); +commit; +insert into bug16206 values(3); +show binlog events; +Log_name Pos Event_type Server_id End_log_pos Info +f n Format_desc 1 n Server ver: VERSION, Binlog ver: 4 +f n Query 1 n use `test`; create table bug16206 (a int) engine= bdb +f n Query 1 n use `test`; insert into bug16206 values(0) +f n Query 1 n use `test`; insert into bug16206 values(1) +f n Query 1 n use `test`; BEGIN +f n Query 1 n use `test`; insert into bug16206 values(2) +f n Query 1 n use `test`; COMMIT +f n Query 1 n use `test`; insert into bug16206 values(3) +drop table bug16206; +set autocommit=0; +End of 5.0 tests diff --git a/mysql-test/t/bdb_notembedded.test b/mysql-test/t/bdb_notembedded.test new file mode 100644 index 00000000000..24e64ebbfb2 --- /dev/null +++ b/mysql-test/t/bdb_notembedded.test @@ -0,0 +1,38 @@ +-- source include/not_embedded.inc +-- source include/have_bdb.inc + +# +# Bug #16206: Superfluous COMMIT event in binlog when updating BDB in autocommit mode +# +set autocommit=1; + +let $VERSION=`select version()`; + +reset master; +create table bug16206 (a int); +insert into bug16206 values(1); +start transaction; +insert into bug16206 values(2); +commit; +--replace_result $VERSION VERSION +--replace_column 1 f 2 n 5 n +show binlog events; +drop table bug16206; + +reset master; +create table bug16206 (a int) engine= bdb; +insert into bug16206 values(0); +insert into bug16206 values(1); +start transaction; +insert into bug16206 values(2); +commit; +insert into bug16206 values(3); +--replace_result $VERSION VERSION +--replace_column 1 f 2 n 5 n +show binlog events; +drop table bug16206; + +set autocommit=0; + + +--echo End of 5.0 tests diff --git a/storage/ndb/test/include/DbUtil.hpp b/storage/ndb/test/include/DbUtil.hpp new file mode 100755 index 00000000000..9c885531ee7 --- /dev/null +++ b/storage/ndb/test/include/DbUtil.hpp @@ -0,0 +1,129 @@ +/* Copyright (C) 2007 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +// dbutil.h: interface for the database utilities class. +// Supplies a database to the test application + +#ifndef DBUTIL_HPP +#define DBUTIL_HPP + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +#include +#include +#include +#include +//include "rand.h" +#include +#include "BaseString.hpp" +#include "NDBT.hpp" + +//#define DEBUG +#define DIE_UNLESS(expr) \ + ((void) ((expr) ? 0 : (Die(__FILE__, __LINE__, #expr), 0))) +#define DIE(expr) \ + Die(__FILE__, __LINE__, #expr) +#define myerror(msg) printError(msg) +#define mysterror(stmt, msg) printStError(stmt, msg) +#define CheckStmt(stmt) \ +{ \ +if ( stmt == 0) \ + myerror(NULL); \ +DIE_UNLESS(stmt != 0); \ +} + +#define check_execute(stmt, r) \ +{ \ +if (r) \ + mysterror(stmt, NULL); \ +DIE_UNLESS(r == 0);\ +} + +#define DBU_TRUE 1 +#define DBU_FALSE 0 +#define DBU_FAILED 1 +#define DBU_OK 0 + +class DbUtil +{ +public: + + /* Deprecated, see DbUtil(dbname, suffix) */ + DbUtil(const char * databaseName); + DbUtil(const char* dbname, const char* suffix = NULL); + ~DbUtil(); + + /* Deprecated, see connect() */ + void databaseLogin(const char * system, + const char * usr, + const char * password, + unsigned int portIn, + const char * sockIn, + bool transactional); + + const char * getDbName() {return m_dbname.c_str();}; + const char * getUser() {return m_user.c_str();}; + const char * getPassword(){return m_pass.c_str();}; + const char * getHost() {return m_host.c_str();}; + const char * getSocket() {return m_socket.c_str();}; + const char * getServerType(){return mysql_get_server_info(mysql);}; + const char * getError(); + + MYSQL * getMysql(){return mysql;}; + MYSQL_STMT * STDCALL mysqlSimplePrepare(const char *query); + + void databaseLogout(); + void mysqlCloseStmHandle(MYSQL_STMT *my_stmt); + + int connect(); + int select_DB(); + int doQuery(char * stm); + int doQuery(const char * stm); + int getErrorNumber(); + + unsigned long selectCountTable(const char * table); + +private: + + bool m_connected; + + BaseString m_host; // Computer to connect to + BaseString m_user; // MySQL User + BaseString m_pass; // MySQL User Password + BaseString m_dbname; // Database to use + BaseString m_socket; // MySQL Server Unix Socket + BaseString default_file; + BaseString default_group; + + unsigned int m_port; // MySQL Server port + + MYSQL * mysql; + MYSQL_RES * m_result; + MYSQL_ROW m_row; + + void setDbName(const char * name){m_dbname.assign(name);}; + void setUser(const char * user_name){m_user.assign(user_name);}; + void setPassword(const char * password){m_pass.assign(password);}; + void setHost(const char * system){m_host.assign(system);}; + void setPort(unsigned int portIn){m_port=portIn;}; + void setSocket(const char * sockIn){m_socket.assign(sockIn);}; + void printError(const char *msg); + void printStError(MYSQL_STMT *stmt, const char *msg); + void die(const char *file, int line, const char *expr); // stop program + +}; +#endif + diff --git a/storage/ndb/test/include/dbutil.hpp b/storage/ndb/test/include/dbutil.hpp deleted file mode 100755 index 2b36965715f..00000000000 --- a/storage/ndb/test/include/dbutil.hpp +++ /dev/null @@ -1,97 +0,0 @@ -// dbutil.h: interface for the database utilities class. -////////////////////////////////////////////////////////////////////// -// Supplies a database to the test application -////////////////////////////////////////////////////////////////////// - -#ifndef DBUTIL_HPP -#define DBUTIL_HPP - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -#include -#include -#include -#include -//include "rand.h" -#include - -//#define DEBUG -#define DIE_UNLESS(expr) \ - ((void) ((expr) ? 0 : (Die(__FILE__, __LINE__, #expr), 0))) -#define DIE(expr) \ - Die(__FILE__, __LINE__, #expr) -#define myerror(msg) PrintError(msg) -#define mysterror(stmt, msg) PrintStError(stmt, msg) -#define CheckStmt(stmt) \ -{ \ -if ( stmt == 0) \ - myerror(NULL); \ -DIE_UNLESS(stmt != 0); \ -} - -#define check_execute(stmt, r) \ -{ \ -if (r) \ - mysterror(stmt, NULL); \ -DIE_UNLESS(r == 0);\ -} - -#define TRUE 1 -#define FALSE 0 - - -class dbutil -{ -public: - - dbutil(const char * databaseName); - ~dbutil(); - - void DatabaseLogin(const char * system, - const char * usr, - const char * password, - unsigned int portIn, - const char * sockIn, - bool transactional); - char * GetDbName(){return dbs;}; - char * GetUser(){return user;}; - char * GetPassword(){return pass;}; - char * GetHost(){return host;}; - char * GetSocket(){return socket;}; - const char * GetServerType(){return mysql_get_server_info(myDbHandel);}; - MYSQL* GetDbHandel(){return myDbHandel;}; - MYSQL_STMT *STDCALL MysqlSimplePrepare(const char *query); - int Select_DB(); - int Do_Query(char * stm); - const char * GetError(); - int GetErrorNumber(); - unsigned long SelectCountTable(const char * table); - -private: - - //Connect variables - char * databaseName; //hold results file name - char host[256]; // Computer to connect to - char user[256]; // MySQL User - char pass[256]; // MySQL User Password - char dbs[256]; // Database to use (TPCB) - unsigned int port; // MySQL Server port - char socket[256]; // MySQL Server Unix Socket - MYSQL *myDbHandel; - - void DatabaseLogout(); - - void SetDbName(const char * name){strcpy((char *)dbs, name);}; - void SetUser(const char * userName){strcpy((char *)user, userName);}; - void SetPassword(const char * password){strcpy((char *)pass,password);}; - void SetHost(const char * system){strcpy((char*)host, system);}; - void SetPort(unsigned int portIn){port=portIn;}; - void SetSocket(const char * sockIn){strcpy((char *)socket, sockIn);}; - void PrintError(const char *msg); - void PrintStError(MYSQL_STMT *stmt, const char *msg); - void Die(const char *file, int line, const char *expr); // stop program - -}; -#endif - diff --git a/storage/ndb/test/src/DbUtil.cpp b/storage/ndb/test/src/DbUtil.cpp new file mode 100755 index 00000000000..0611fb2ad4a --- /dev/null +++ b/storage/ndb/test/src/DbUtil.cpp @@ -0,0 +1,285 @@ +/* Copyright (C) 2007 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +/* DbUtil.cpp: implementation of the database utilities class.*/ + +#include "DbUtil.hpp" + +/* Constructors */ + +DbUtil::DbUtil(const char * dbname) +{ + m_port = 0; + m_connected = false; + this->setDbName(dbname); +} + +DbUtil::DbUtil(const char * dbname, const char* suffix) +{ + this->setDbName(dbname); + m_connected = false; + + const char* env= getenv("MYSQL_HOME"); + if (env && strlen(env)) + { + default_file.assfmt("%s/my.cnf", env); + } + + if (suffix != NULL){ + default_group.assfmt("client%s", suffix); + } + else { + default_group.assign("client.1.master"); + } + + ndbout << "default_file: " << default_file.c_str() << endl; + ndbout << "default_group: " << default_group.c_str() << endl; +} + +/* Destructor*/ + +DbUtil::~DbUtil() +{ + this->databaseLogout(); +} + +/* Database Login */ + +void +DbUtil::databaseLogin(const char* system, const char* usr, + const char* password, unsigned int portIn, + const char* sockIn, bool transactional) +{ + if (!(mysql = mysql_init(NULL))) + { + myerror("DB Login-> mysql_init() failed"); + exit(DBU_FAILED); + } + this->setUser(usr); + this->setHost(system); + this->setPassword(password); + this->setPort(portIn); + this->setSocket(sockIn); + + if (!(mysql_real_connect(mysql, + m_host.c_str(), + m_user.c_str(), + m_pass.c_str(), + "test", + m_port, + m_socket.c_str(), 0))) + { + myerror("connection failed"); + mysql_close(mysql); + exit(DBU_FAILED); + } + + mysql->reconnect = DBU_TRUE; + + /* set AUTOCOMMIT */ + if(!transactional) + mysql_autocommit(mysql, DBU_TRUE); + else + mysql_autocommit(mysql, DBU_FALSE); + + #ifdef DEBUG + printf("\n\tConnected to MySQL server version: %s (%lu)\n\n", + mysql_get_server_info(mysql), + (unsigned long) mysql_get_server_version(mysql)); + #endif +} + +/* Database Connect */ + +int +DbUtil::connect() +{ + if (!(mysql = mysql_init(NULL))) + { + myerror("DB connect-> mysql_init() failed"); + return DBU_FAILED; + } + + /* Load connection parameters file and group */ + if (mysql_options(mysql, MYSQL_READ_DEFAULT_FILE, default_file.c_str()) || + mysql_options(mysql, MYSQL_READ_DEFAULT_GROUP, default_group.c_str())) + { + myerror("DB Connect -> mysql_options failed"); + return DBU_FAILED; + } + + /* + Connect, read settings from my.cnf + NOTE! user and password can be stored there as well + */ + + if (mysql_real_connect(mysql, NULL, "root","", m_dbname.c_str(), + 0, NULL, 0) == NULL) + { + myerror("connection failed"); + mysql_close(mysql); + return DBU_FAILED; + } + + m_connected = true; + return DBU_OK; +} + + +/* Database Logout */ + +void +DbUtil::databaseLogout() +{ + if (mysql){ + #ifdef DEBUG + printf("\n\tClosing the MySQL database connection ...\n\n"); + #endif + mysql_close(mysql); + } +} + +/* Prepare MySQL Statements Cont */ + +MYSQL_STMT *STDCALL +DbUtil::mysqlSimplePrepare(const char *query) +{ + #ifdef DEBUG + printf("Inside DbUtil::mysqlSimplePrepare\n"); + #endif + int m_res = DBU_OK; + + MYSQL_STMT *my_stmt= mysql_stmt_init(this->getMysql()); + if (my_stmt && (m_res = mysql_stmt_prepare(my_stmt, query, strlen(query)))){ + this->printStError(my_stmt,"Prepare Statement Failed"); + mysql_stmt_close(my_stmt); + exit(DBU_FAILED); + } + return my_stmt; +} + +/* Close MySQL Statements Handle */ + +void +DbUtil::mysqlCloseStmHandle(MYSQL_STMT *my_stmt) +{ + mysql_stmt_close(my_stmt); +} + +/* Error Printing */ + +void +DbUtil::printError(const char *msg) +{ + if (this->getMysql() && mysql_errno(this->getMysql())) + { + if (this->getMysql()->server_version) + printf("\n [MySQL-%s]", this->getMysql()->server_version); + else + printf("\n [MySQL]"); + printf("[%d] %s\n", this->getErrorNumber(), this->getError()); + } + else if (msg) + printf(" [MySQL] %s\n", msg); +} + +void +DbUtil::printStError(MYSQL_STMT *stmt, const char *msg) +{ + if (stmt && mysql_stmt_errno(stmt)) + { + if (this->getMysql() && this->getMysql()->server_version) + printf("\n [MySQL-%s]", this->getMysql()->server_version); + else + printf("\n [MySQL]"); + + printf("[%d] %s\n", mysql_stmt_errno(stmt), + mysql_stmt_error(stmt)); + } + else if (msg) + printf("[MySQL] %s\n", msg); +} + +/* Select which database to use */ + +int +DbUtil::select_DB() +{ + return mysql_select_db(this->getMysql(), this->getDbName()); +} + +/* Run Simple Queries */ + +int +DbUtil::doQuery(char * stm) +{ + return mysql_query(this->getMysql(), stm); +} + +int +DbUtil::doQuery(const char * stm) +{ + return mysql_query(this->getMysql(), stm); +} + +/* Return MySQL Error String */ + +const char * +DbUtil::getError() +{ + return mysql_error(this->getMysql()); +} + +/* Retrun MySQL Error Number */ + +int +DbUtil::getErrorNumber() +{ + return mysql_errno(this->getMysql()); +} + +/* Count Table Rows */ + +unsigned long +DbUtil::selectCountTable(const char * table) +{ + unsigned long m_count = 0; + BaseString m_query; + + m_query.assfmt("select count(*) from %s", table); + if (mysql_query(this->getMysql(),m_query.c_str()) || + !(m_result=mysql_store_result(this->getMysql()))) + { + this->printError("selectCountTable\n"); + return DBU_FAILED; + } + m_row = mysql_fetch_row(m_result); + m_count = (ulong) strtoull(m_row[0], (char**) 0, 10); + mysql_free_result(m_result); + + return m_count; +} + +/* DIE */ + +void +DbUtil::die(const char *file, int line, const char *expr) +{ + printf("%s:%d: check failed: '%s'\n", file, line, expr); + abort(); +} + +/* EOF */ + diff --git a/storage/ndb/test/src/dbutil.cpp b/storage/ndb/test/src/dbutil.cpp deleted file mode 100755 index 0c936f53182..00000000000 --- a/storage/ndb/test/src/dbutil.cpp +++ /dev/null @@ -1,176 +0,0 @@ -// dbutil.cpp: implementation of the database utilities class. -// -////////////////////////////////////////////////////////////////////// - -#include "dbutil.hpp" - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// -dbutil::dbutil(const char * dbname) -{ - memset(host,' ',sizeof(host)); - memset(user,' ',sizeof(pass)); - memset(dbs,' ',sizeof(dbs)); - port = 0; - memset(socket,' ',sizeof(socket)); - this->SetDbName(dbname); -} - -dbutil::~dbutil() -{ - this->DatabaseLogout(); -} - -////////////////////////////////////////////////////////////////////// -// Database Login -////////////////////////////////////////////////////////////////////// -void dbutil::DatabaseLogin(const char* system, - const char* usr, - const char* password, - unsigned int portIn, - const char* sockIn, - bool transactional - ){ - if (!(myDbHandel = mysql_init(NULL))){ - myerror("mysql_init() failed"); - exit(1); - } - this->SetUser(usr); - this->SetHost(system); - this->SetPassword(password); - this->SetPort(portIn); - this->SetSocket(sockIn); - - if (!(mysql_real_connect(myDbHandel, host, user, pass, "test", port, socket, 0))){ - myerror("connection failed"); - mysql_close(myDbHandel); - fprintf(stdout, "\n Check the connection options using --help or -?\n"); - exit(1); - } - - myDbHandel->reconnect= 1; - - /* set AUTOCOMMIT */ - if(!transactional){ - mysql_autocommit(myDbHandel, TRUE); - } - else{ - mysql_autocommit(myDbHandel, FALSE); - } - - fprintf(stdout, "\n\tConnected to MySQL server version: %s (%lu)\n\n", - mysql_get_server_info(myDbHandel), - (unsigned long) mysql_get_server_version(myDbHandel)); -} - -////////////////////////////////////////////////////////////////////// -// Database Logout -////////////////////////////////////////////////////////////////////// -void dbutil::DatabaseLogout(){ - if (myDbHandel){ - fprintf(stdout, "\n\tClosing the MySQL database connection ...\n\n"); - mysql_close(myDbHandel); - } -} - -////////////////////////////////////////////////////////////////////// -// Prepare MySQL Statements Cont -////////////////////////////////////////////////////////////////////// -MYSQL_STMT *STDCALL dbutil::MysqlSimplePrepare(const char *query){ -#ifdef DEBUG -printf("Inside dbutil::MysqlSimplePrepare\n"); -#endif -int result = 0; - MYSQL_STMT *my_stmt= mysql_stmt_init(this->GetDbHandel()); - if (my_stmt && (result = mysql_stmt_prepare(my_stmt, query, strlen(query)))){ - printf("res = %s\n",mysql_stmt_error(my_stmt)); - mysql_stmt_close(my_stmt); - return 0; - } - return my_stmt; -} -////////////////////////////////////////////////////////////////////// -// Error Printing -////////////////////////////////////////////////////////////////////// -void dbutil::PrintError(const char *msg){ - if (this->GetDbHandel() - && mysql_errno(this->GetDbHandel())){ - if (this->GetDbHandel()->server_version){ - fprintf(stdout, "\n [MySQL-%s]", - this->GetDbHandel()->server_version); - } - else - fprintf(stdout, "\n [MySQL]"); - fprintf(stdout, "[%d] %s\n", - mysql_errno(this->GetDbHandel()), - mysql_error(this->GetDbHandel())); - } - else if (msg) - fprintf(stderr, " [MySQL] %s\n", msg); -} - -void dbutil::PrintStError(MYSQL_STMT *stmt, const char *msg) -{ - if (stmt && mysql_stmt_errno(stmt)) - { - if (this->GetDbHandel() - && this->GetDbHandel()->server_version) - fprintf(stdout, "\n [MySQL-%s]", - this->GetDbHandel()->server_version); - else - fprintf(stdout, "\n [MySQL]"); - - fprintf(stdout, "[%d] %s\n", mysql_stmt_errno(stmt), - mysql_stmt_error(stmt)); - } - else if (msg) - fprintf(stderr, " [MySQL] %s\n", msg); -} -///////////////////////////////////////////////////// -int dbutil::Select_DB() -{ - return mysql_select_db(this->GetDbHandel(), - this->GetDbName()); -} -//////////////////////////////////////////////////// -int dbutil::Do_Query(char * stm) -{ - return mysql_query(this->GetDbHandel(), stm); -} -//////////////////////////////////////////////////// -const char * dbutil::GetError() -{ - return mysql_error(this->GetDbHandel()); -} -//////////////////////////////////////////////////// -int dbutil::GetErrorNumber() -{ - return mysql_errno(this->GetDbHandel()); -} -//////////////////////////////////////////////////// -unsigned long dbutil::SelectCountTable(const char * table) -{ - unsigned long count = 0; - MYSQL_RES *result; - char query[1024]; - MYSQL_ROW row; - - sprintf(query,"select count(*) from `%s`", table); - if (mysql_query(this->GetDbHandel(),query) || !(result=mysql_store_result(this->GetDbHandel()))) - { - printf("error\n"); - return 1; - } - row= mysql_fetch_row(result); - count= (ulong) strtoull(row[0], (char**) 0, 10); - mysql_free_result(result); - - return count; -} -void dbutil::Die(const char *file, int line, const char *expr){ - fprintf(stderr, "%s:%d: check failed: '%s'\n", file, line, expr); - abort(); -} - - From 3ca5566036dbbf53411d83987e9c9ac6a5a6e5ef Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 4 Jan 2008 11:34:23 +0100 Subject: [PATCH 13/32] ndb - dict remove dead code storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp: remove dead code storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp: remove dead code --- storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp | 7 ------- storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp | 2 -- 2 files changed, 9 deletions(-) diff --git a/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp b/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp index 7ced078144a..a61a5bc035c 100644 --- a/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp +++ b/storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp @@ -4086,9 +4086,7 @@ Dbdict::execALTER_TABLE_REQ(Signal* signal) bool ok = false; switch(tabState){ case TableRecord::NOT_DEFINED: - case TableRecord::REORG_TABLE_PREPARED: case TableRecord::DEFINING: - case TableRecord::CHECKED: jam(); alterTableRef(signal, req, AlterTableRef::NoSuchTable); return; @@ -4339,9 +4337,7 @@ Dbdict::execALTER_TAB_REQ(Signal * signal) bool ok = false; switch(tabState){ case TableRecord::NOT_DEFINED: - case TableRecord::REORG_TABLE_PREPARED: case TableRecord::DEFINING: - case TableRecord::CHECKED: jam(); alterTabRef(signal, req, AlterTableRef::NoSuchTable); return; @@ -6690,9 +6686,7 @@ Dbdict::execDROP_TABLE_REQ(Signal* signal){ bool ok = false; switch(tabState){ case TableRecord::NOT_DEFINED: - case TableRecord::REORG_TABLE_PREPARED: case TableRecord::DEFINING: - case TableRecord::CHECKED: jam(); dropTableRef(signal, req, DropTableRef::NoSuchTable); return; @@ -7718,7 +7712,6 @@ Dbdict::execLIST_TABLES_REQ(Signal* signal) if(DictTabInfo::isTable(type)){ switch (tablePtr.p->tabState) { case TableRecord::DEFINING: - case TableRecord::CHECKED: conf->setTableState(pos, DictTabInfo::StateBuilding); break; case TableRecord::PREPARE_DROPPING: diff --git a/storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp b/storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp index 3fff330d699..1189b23c14d 100644 --- a/storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp +++ b/storage/ndb/src/kernel/blocks/dbdict/Dbdict.hpp @@ -320,9 +320,7 @@ public: enum TabState { NOT_DEFINED = 0, - REORG_TABLE_PREPARED = 1, DEFINING = 2, - CHECKED = 3, DEFINED = 4, PREPARE_DROPPING = 5, DROPPING = 6, From 6074712beb90f1ef01716356203c9ec17f61c5de Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 4 Jan 2008 15:33:01 +0100 Subject: [PATCH 14/32] Bug#32648 Test failure between NDB Cluster and other engines mysql-test/suite/ndb_team/t/rpl_ndb_extraColMaster.test: Rename: mysql-test/suite/rpl_ndb/t/rpl_ndb_extraColMaster.test -> mysql-test/suite/ndb_team/t/rpl_ndb_extraColMaster.test mysql-test/suite/ndb_team/r/rpl_ndb_extraColMaster.result: Rename: mysql-test/suite/rpl_ndb/r/rpl_ndb_extraColMaster.result -> mysql-test/suite/ndb_team/r/rpl_ndb_extraColMaster.result mysql-test/suite/ndb_team/t/rpl_ndb_mix_innodb-master.opt: Rename: mysql-test/suite/rpl_ndb/t/rpl_ndb_mix_innodb-master.opt -> mysql-test/suite/ndb_team/t/rpl_ndb_mix_innodb-master.opt mysql-test/suite/ndb_team/t/rpl_ndb_mix_innodb.test: Rename: mysql-test/suite/rpl_ndb/t/rpl_ndb_mix_innodb.test -> mysql-test/suite/ndb_team/t/rpl_ndb_mix_innodb.test mysql-test/suite/ndb_team/r/rpl_ndb_mix_innodb.result: Rename: mysql-test/suite/rpl_ndb/r/rpl_ndb_mix_innodb.result -> mysql-test/suite/ndb_team/r/rpl_ndb_mix_innodb.result mysql-test/suite/ndb_team/t/rpl_ndb_dd_advance.test: Rename: mysql-test/suite/rpl_ndb/t/rpl_ndb_dd_advance.test -> mysql-test/suite/ndb_team/t/rpl_ndb_dd_advance.test mysql-test/suite/ndb_team/r/rpl_ndb_dd_advance.result: Rename: mysql-test/suite/rpl_ndb/r/rpl_ndb_dd_advance.result -> mysql-test/suite/ndb_team/r/rpl_ndb_dd_advance.result --- mysql-test/lib/mtr_cases.pl | 1 + .../r/rpl_ndb_dd_advance.result | 0 .../r/rpl_ndb_extraColMaster.result | 0 .../r/rpl_ndb_mix_innodb.result | 0 mysql-test/suite/ndb_team/t/disabled.def | 3 + .../t/rpl_ndb_dd_advance.test | 0 .../t/rpl_ndb_extraColMaster.test | 0 .../t/rpl_ndb_mix_innodb-master.opt | 0 .../t/rpl_ndb_mix_innodb.test | 0 .../suite/rpl_ndb/r/rpl_ndb_2innodb.result | 61 +-- .../suite/rpl_ndb/r/rpl_ndb_2myisam.result | 57 +-- .../suite/rpl_ndb/r/rpl_ndb_2ndb.result | 401 +++++++++++++++++ .../suite/rpl_ndb/r/rpl_ndb_2other.result | 403 +----------------- mysql-test/suite/rpl_ndb/t/disabled.def | 7 - .../rpl_ndb/t/rpl_ndb_2innodb-master.opt | 2 +- .../suite/rpl_ndb/t/rpl_ndb_2innodb-slave.opt | 2 +- .../suite/rpl_ndb/t/rpl_ndb_2innodb.test | 18 +- .../rpl_ndb/t/rpl_ndb_2myisam-master.opt | 2 +- .../suite/rpl_ndb/t/rpl_ndb_2myisam-slave.opt | 2 +- .../suite/rpl_ndb/t/rpl_ndb_2myisam.test | 16 +- .../suite/rpl_ndb/t/rpl_ndb_2ndb-slave.opt | 1 + mysql-test/suite/rpl_ndb/t/rpl_ndb_2ndb.test | 19 + .../suite/rpl_ndb/t/rpl_ndb_2other-slave.opt | 2 +- .../suite/rpl_ndb/t/rpl_ndb_2other.test | 16 +- 24 files changed, 543 insertions(+), 470 deletions(-) rename mysql-test/suite/{rpl_ndb => ndb_team}/r/rpl_ndb_dd_advance.result (100%) rename mysql-test/suite/{rpl_ndb => ndb_team}/r/rpl_ndb_extraColMaster.result (100%) rename mysql-test/suite/{rpl_ndb => ndb_team}/r/rpl_ndb_mix_innodb.result (100%) rename mysql-test/suite/{rpl_ndb => ndb_team}/t/rpl_ndb_dd_advance.test (100%) rename mysql-test/suite/{rpl_ndb => ndb_team}/t/rpl_ndb_extraColMaster.test (100%) rename mysql-test/suite/{rpl_ndb => ndb_team}/t/rpl_ndb_mix_innodb-master.opt (100%) rename mysql-test/suite/{rpl_ndb => ndb_team}/t/rpl_ndb_mix_innodb.test (100%) create mode 100644 mysql-test/suite/rpl_ndb/r/rpl_ndb_2ndb.result create mode 100644 mysql-test/suite/rpl_ndb/t/rpl_ndb_2ndb-slave.opt create mode 100644 mysql-test/suite/rpl_ndb/t/rpl_ndb_2ndb.test diff --git a/mysql-test/lib/mtr_cases.pl b/mysql-test/lib/mtr_cases.pl index 0d705104303..566f48903f5 100644 --- a/mysql-test/lib/mtr_cases.pl +++ b/mysql-test/lib/mtr_cases.pl @@ -831,6 +831,7 @@ our @tags= ["include/have_ndb.inc", "ndb_test", 1], ["include/have_multi_ndb.inc", "ndb_test", 1], ["include/have_ndb_extra.inc", "ndb_extra", 1], + ["include/ndb_master-slave.inc", "ndb_test", 1], ["require_manager", "require_manager", 1], ); diff --git a/mysql-test/suite/rpl_ndb/r/rpl_ndb_dd_advance.result b/mysql-test/suite/ndb_team/r/rpl_ndb_dd_advance.result similarity index 100% rename from mysql-test/suite/rpl_ndb/r/rpl_ndb_dd_advance.result rename to mysql-test/suite/ndb_team/r/rpl_ndb_dd_advance.result diff --git a/mysql-test/suite/rpl_ndb/r/rpl_ndb_extraColMaster.result b/mysql-test/suite/ndb_team/r/rpl_ndb_extraColMaster.result similarity index 100% rename from mysql-test/suite/rpl_ndb/r/rpl_ndb_extraColMaster.result rename to mysql-test/suite/ndb_team/r/rpl_ndb_extraColMaster.result diff --git a/mysql-test/suite/rpl_ndb/r/rpl_ndb_mix_innodb.result b/mysql-test/suite/ndb_team/r/rpl_ndb_mix_innodb.result similarity index 100% rename from mysql-test/suite/rpl_ndb/r/rpl_ndb_mix_innodb.result rename to mysql-test/suite/ndb_team/r/rpl_ndb_mix_innodb.result diff --git a/mysql-test/suite/ndb_team/t/disabled.def b/mysql-test/suite/ndb_team/t/disabled.def index 8ff2d29147d..714f1014a10 100644 --- a/mysql-test/suite/ndb_team/t/disabled.def +++ b/mysql-test/suite/ndb_team/t/disabled.def @@ -15,3 +15,6 @@ ndb_autodiscover2 : BUG#18952 2006-02-16 jmiller Needs to be fixed w.r.t # the below testcase have been reworked to avoid the bug, test contains comment, keep bug open #ndb_autodiscover3 : bug#21806 #ndb_autodiscover3 : Bug#20872 2007-07-15 ingo master*.err: miscellaneous error messages +#rpl_ndb_extraColMaster : BUG#30854 : Tables name show as binary in slave err msg on vm-win2003-64-b and Solaris +#rpl_ndb_mix_innodb : Bug #32720 Test rpl_ndb_mix_innodb fails on SPARC and PowerPC +#rpl_ndb_dd_advance : Bug #30222 rpl_ndb_dd_advance.test fails diff --git a/mysql-test/suite/rpl_ndb/t/rpl_ndb_dd_advance.test b/mysql-test/suite/ndb_team/t/rpl_ndb_dd_advance.test similarity index 100% rename from mysql-test/suite/rpl_ndb/t/rpl_ndb_dd_advance.test rename to mysql-test/suite/ndb_team/t/rpl_ndb_dd_advance.test diff --git a/mysql-test/suite/rpl_ndb/t/rpl_ndb_extraColMaster.test b/mysql-test/suite/ndb_team/t/rpl_ndb_extraColMaster.test similarity index 100% rename from mysql-test/suite/rpl_ndb/t/rpl_ndb_extraColMaster.test rename to mysql-test/suite/ndb_team/t/rpl_ndb_extraColMaster.test diff --git a/mysql-test/suite/rpl_ndb/t/rpl_ndb_mix_innodb-master.opt b/mysql-test/suite/ndb_team/t/rpl_ndb_mix_innodb-master.opt similarity index 100% rename from mysql-test/suite/rpl_ndb/t/rpl_ndb_mix_innodb-master.opt rename to mysql-test/suite/ndb_team/t/rpl_ndb_mix_innodb-master.opt diff --git a/mysql-test/suite/rpl_ndb/t/rpl_ndb_mix_innodb.test b/mysql-test/suite/ndb_team/t/rpl_ndb_mix_innodb.test similarity index 100% rename from mysql-test/suite/rpl_ndb/t/rpl_ndb_mix_innodb.test rename to mysql-test/suite/ndb_team/t/rpl_ndb_mix_innodb.test diff --git a/mysql-test/suite/rpl_ndb/r/rpl_ndb_2innodb.result b/mysql-test/suite/rpl_ndb/r/rpl_ndb_2innodb.result index f8ec4624062..d1390eb585d 100644 --- a/mysql-test/suite/rpl_ndb/r/rpl_ndb_2innodb.result +++ b/mysql-test/suite/rpl_ndb/r/rpl_ndb_2innodb.result @@ -4,7 +4,13 @@ reset master; reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; start slave; -SET storage_engine=ndb; +CREATE TABLE mysql.ndb_apply_status +( server_id INT UNSIGNED NOT NULL, +epoch BIGINT UNSIGNED NOT NULL, +log_name VARCHAR(255) BINARY NOT NULL, +start_pos BIGINT UNSIGNED NOT NULL, +end_pos BIGINT UNSIGNED NOT NULL, +PRIMARY KEY USING HASH (server_id)) ENGINE=INNODB; --- Doing pre test cleanup --- DROP TABLE IF EXISTS t1; --- Start test 1 Basic testing --- @@ -27,7 +33,7 @@ t1 CREATE TABLE `t1` ( `y` year(4) DEFAULT NULL, `t` date DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY () +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 --- Show table on slave --- SHOW CREATE TABLE t1; Table Create Table @@ -100,7 +106,7 @@ t1 CREATE TABLE `t1` ( `y` year(4) DEFAULT NULL, `t` date DEFAULT NULL, PRIMARY KEY (`id`,`total`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY () +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 --- Make sure that our tables on slave are still same engine --- --- and that the alter statements replicated correctly --- SHOW CREATE TABLE t1; @@ -186,7 +192,7 @@ t1 CREATE TABLE `t1` ( `total` bigint(20) unsigned DEFAULT NULL, `y` year(4) DEFAULT NULL, `t` date DEFAULT NULL -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY RANGE (YEAR(t)) (PARTITION p0 VALUES LESS THAN (1901) ENGINE = ndbcluster, PARTITION p1 VALUES LESS THAN (1946) ENGINE = ndbcluster, PARTITION p2 VALUES LESS THAN (1966) ENGINE = ndbcluster, PARTITION p3 VALUES LESS THAN (1986) ENGINE = ndbcluster, PARTITION p4 VALUES LESS THAN (2005) ENGINE = ndbcluster, PARTITION p5 VALUES LESS THAN MAXVALUE ENGINE = ndbcluster) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (YEAR(t)) (PARTITION p0 VALUES LESS THAN (1901) ENGINE = ndbcluster, PARTITION p1 VALUES LESS THAN (1946) ENGINE = ndbcluster, PARTITION p2 VALUES LESS THAN (1966) ENGINE = ndbcluster, PARTITION p3 VALUES LESS THAN (1986) ENGINE = ndbcluster, PARTITION p4 VALUES LESS THAN (2005) ENGINE = ndbcluster, PARTITION p5 VALUES LESS THAN MAXVALUE ENGINE = ndbcluster) */ --- Show table on slave -- SHOW CREATE TABLE t1; Table Create Table @@ -200,7 +206,7 @@ t1 CREATE TABLE `t1` ( `total` bigint(20) unsigned DEFAULT NULL, `y` year(4) DEFAULT NULL, `t` date DEFAULT NULL -) ENGINE=InnoDB DEFAULT CHARSET=latin1 PARTITION BY RANGE (YEAR(t)) (PARTITION p0 VALUES LESS THAN (1901) ENGINE = InnoDB, PARTITION p1 VALUES LESS THAN (1946) ENGINE = InnoDB, PARTITION p2 VALUES LESS THAN (1966) ENGINE = InnoDB, PARTITION p3 VALUES LESS THAN (1986) ENGINE = InnoDB, PARTITION p4 VALUES LESS THAN (2005) ENGINE = InnoDB, PARTITION p5 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (YEAR(t)) (PARTITION p0 VALUES LESS THAN (1901) ENGINE = InnoDB, PARTITION p1 VALUES LESS THAN (1946) ENGINE = InnoDB, PARTITION p2 VALUES LESS THAN (1966) ENGINE = InnoDB, PARTITION p3 VALUES LESS THAN (1986) ENGINE = InnoDB, PARTITION p4 VALUES LESS THAN (2005) ENGINE = InnoDB, PARTITION p5 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */ --- Perform basic operation on master --- --- and ensure replicated correctly --- "--- Insert into t1 --" as ""; @@ -258,7 +264,7 @@ t1 CREATE TABLE `t1` ( `y` year(4) DEFAULT NULL, `t` date NOT NULL DEFAULT '0000-00-00', PRIMARY KEY (`t`,`id`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY RANGE (YEAR(t)) (PARTITION p0 VALUES LESS THAN (1901) ENGINE = ndbcluster, PARTITION p1 VALUES LESS THAN (1946) ENGINE = ndbcluster, PARTITION p2 VALUES LESS THAN (1966) ENGINE = ndbcluster, PARTITION p3 VALUES LESS THAN (1986) ENGINE = ndbcluster, PARTITION p4 VALUES LESS THAN (2005) ENGINE = ndbcluster, PARTITION p5 VALUES LESS THAN MAXVALUE ENGINE = ndbcluster) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (YEAR(t)) (PARTITION p0 VALUES LESS THAN (1901) ENGINE = ndbcluster, PARTITION p1 VALUES LESS THAN (1946) ENGINE = ndbcluster, PARTITION p2 VALUES LESS THAN (1966) ENGINE = ndbcluster, PARTITION p3 VALUES LESS THAN (1986) ENGINE = ndbcluster, PARTITION p4 VALUES LESS THAN (2005) ENGINE = ndbcluster, PARTITION p5 VALUES LESS THAN MAXVALUE ENGINE = ndbcluster) */ --- Make sure that our tables on slave are still same engine --- --- and that the alter statements replicated correctly --- SHOW CREATE TABLE t1; @@ -274,7 +280,7 @@ t1 CREATE TABLE `t1` ( `y` year(4) DEFAULT NULL, `t` date NOT NULL DEFAULT '0000-00-00', PRIMARY KEY (`t`,`id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 PARTITION BY RANGE (YEAR(t)) (PARTITION p0 VALUES LESS THAN (1901) ENGINE = InnoDB, PARTITION p1 VALUES LESS THAN (1946) ENGINE = InnoDB, PARTITION p2 VALUES LESS THAN (1966) ENGINE = InnoDB, PARTITION p3 VALUES LESS THAN (1986) ENGINE = InnoDB, PARTITION p4 VALUES LESS THAN (2005) ENGINE = InnoDB, PARTITION p5 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (YEAR(t)) (PARTITION p0 VALUES LESS THAN (1901) ENGINE = InnoDB, PARTITION p1 VALUES LESS THAN (1946) ENGINE = InnoDB, PARTITION p2 VALUES LESS THAN (1966) ENGINE = InnoDB, PARTITION p3 VALUES LESS THAN (1986) ENGINE = InnoDB, PARTITION p4 VALUES LESS THAN (2005) ENGINE = InnoDB, PARTITION p5 VALUES LESS THAN MAXVALUE ENGINE = InnoDB) */ --- Perform basic operation on master --- --- and ensure replicated correctly --- "--- Insert into t1 --" as ""; @@ -299,11 +305,11 @@ UPDATE t1 SET b1 = 0, t="2006-02-22" WHERE id = 412; --- Check the update on master --- SELECT id,hex(b1),vc,bc,d,f,total,y,t FROM t1 WHERE id = 412; id hex(b1) vc bc d f total y t -412 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 2006-02-22 +412 0 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 2006-02-22 --- Check Update on slave --- SELECT id,hex(b1),vc,bc,d,f,total,y,t FROM t1 WHERE id = 412; id hex(b1) vc bc d f total y t -412 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 2006-02-22 +412 0 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 2006-02-22 --- Remove a record from t1 on master --- DELETE FROM t1 WHERE id = 42; --- Show current count on master for t1 --- @@ -342,7 +348,7 @@ t1 CREATE TABLE `t1` ( `total` bigint(20) unsigned DEFAULT NULL, `y` year(4) DEFAULT NULL, `t` date DEFAULT NULL -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY LIST (id) (PARTITION p0 VALUES IN (2,4) ENGINE = ndbcluster, PARTITION p1 VALUES IN (42,142) ENGINE = ndbcluster, PARTITION p2 VALUES IN (412) ENGINE = ndbcluster) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (id) (PARTITION p0 VALUES IN (2,4) ENGINE = ndbcluster, PARTITION p1 VALUES IN (42,142) ENGINE = ndbcluster, PARTITION p2 VALUES IN (412) ENGINE = ndbcluster) */ --- Show table on slave --- SHOW CREATE TABLE t1; Table Create Table @@ -356,7 +362,7 @@ t1 CREATE TABLE `t1` ( `total` bigint(20) unsigned DEFAULT NULL, `y` year(4) DEFAULT NULL, `t` date DEFAULT NULL -) ENGINE=InnoDB DEFAULT CHARSET=latin1 PARTITION BY LIST (id) (PARTITION p0 VALUES IN (2,4) ENGINE = InnoDB, PARTITION p1 VALUES IN (42,142) ENGINE = InnoDB, PARTITION p2 VALUES IN (412) ENGINE = InnoDB) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (id) (PARTITION p0 VALUES IN (2,4) ENGINE = InnoDB, PARTITION p1 VALUES IN (42,142) ENGINE = InnoDB, PARTITION p2 VALUES IN (412) ENGINE = InnoDB) */ --- Perform basic operation on master --- --- and ensure replicated correctly --- "--- Insert into t1 --" as ""; @@ -414,7 +420,7 @@ t1 CREATE TABLE `t1` ( `y` year(4) DEFAULT NULL, `t` date DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY LIST (id) (PARTITION p0 VALUES IN (2,4) ENGINE = ndbcluster, PARTITION p1 VALUES IN (42,142) ENGINE = ndbcluster, PARTITION p2 VALUES IN (412) ENGINE = ndbcluster) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (id) (PARTITION p0 VALUES IN (2,4) ENGINE = ndbcluster, PARTITION p1 VALUES IN (42,142) ENGINE = ndbcluster, PARTITION p2 VALUES IN (412) ENGINE = ndbcluster) */ --- Make sure that our tables on slave are still same engine --- --- and that the alter statements replicated correctly --- SHOW CREATE TABLE t1; @@ -430,7 +436,7 @@ t1 CREATE TABLE `t1` ( `y` year(4) DEFAULT NULL, `t` date DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 PARTITION BY LIST (id) (PARTITION p0 VALUES IN (2,4) ENGINE = InnoDB, PARTITION p1 VALUES IN (42,142) ENGINE = InnoDB, PARTITION p2 VALUES IN (412) ENGINE = InnoDB) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (id) (PARTITION p0 VALUES IN (2,4) ENGINE = InnoDB, PARTITION p1 VALUES IN (42,142) ENGINE = InnoDB, PARTITION p2 VALUES IN (412) ENGINE = InnoDB) */ --- Perform basic operation on master --- --- and ensure replicated correctly --- "--- Insert into t1 --" as ""; @@ -495,7 +501,7 @@ t1 CREATE TABLE `t1` ( `total` bigint(20) unsigned DEFAULT NULL, `y` year(4) DEFAULT NULL, `t` date DEFAULT NULL -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY HASH ( YEAR(t)) PARTITIONS 4 +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH ( YEAR(t)) PARTITIONS 4 */ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( @@ -508,7 +514,7 @@ t1 CREATE TABLE `t1` ( `total` bigint(20) unsigned DEFAULT NULL, `y` year(4) DEFAULT NULL, `t` date DEFAULT NULL -) ENGINE=InnoDB DEFAULT CHARSET=latin1 PARTITION BY HASH ( YEAR(t)) PARTITIONS 4 +) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH ( YEAR(t)) PARTITIONS 4 */ --- Perform basic operation on master --- --- and ensure replicated correctly --- "--- Insert into t1 --" as ""; @@ -533,11 +539,11 @@ UPDATE t1 SET b1 = 0, t="2006-02-22" WHERE id = 412; --- Check the update on master --- SELECT id,hex(b1),vc,bc,d,f,total,y,t FROM t1 WHERE id = 412; id hex(b1) vc bc d f total y t -412 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 2006-02-22 +412 0 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 2006-02-22 --- Check Update on slave --- SELECT id,hex(b1),vc,bc,d,f,total,y,t FROM t1 WHERE id = 412; id hex(b1) vc bc d f total y t -412 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 2006-02-22 +412 0 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 2006-02-22 --- Remove a record from t1 on master --- DELETE FROM t1 WHERE id = 42; --- Show current count on master for t1 --- @@ -566,7 +572,7 @@ t1 CREATE TABLE `t1` ( `y` year(4) DEFAULT NULL, `t` date NOT NULL DEFAULT '0000-00-00', PRIMARY KEY (`t`,`id`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY HASH ( YEAR(t)) PARTITIONS 4 +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH ( YEAR(t)) PARTITIONS 4 */ --- Make sure that our tables on slave are still same engine --- --- and that the alter statements replicated correctly --- SHOW CREATE TABLE t1; @@ -582,7 +588,7 @@ t1 CREATE TABLE `t1` ( `y` year(4) DEFAULT NULL, `t` date NOT NULL DEFAULT '0000-00-00', PRIMARY KEY (`t`,`id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 PARTITION BY HASH ( YEAR(t)) PARTITIONS 4 +) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH ( YEAR(t)) PARTITIONS 4 */ --- Perform basic operation on master --- --- and ensure replicated correctly --- "--- Insert into t1 --" as ""; @@ -607,11 +613,11 @@ UPDATE t1 SET b1 = 0, t="2006-02-22" WHERE id = 412; --- Check the update on master --- SELECT id,hex(b1),vc,bc,d,f,total,y,t FROM t1 WHERE id = 412; id hex(b1) vc bc d f total y t -412 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 2006-02-22 +412 0 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 2006-02-22 --- Check Update on slave --- SELECT id,hex(b1),vc,bc,d,f,total,y,t FROM t1 WHERE id = 412; id hex(b1) vc bc d f total y t -412 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 2006-02-22 +412 0 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 2006-02-22 --- Remove a record from t1 on master --- DELETE FROM t1 WHERE id = 42; --- Show current count on master for t1 --- @@ -648,7 +654,7 @@ t1 CREATE TABLE `t1` ( `y` year(4) DEFAULT NULL, `t` date DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY () PARTITIONS 4 +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY () PARTITIONS 4 */ --- Show that tables on slave --- SHOW CREATE TABLE t1; Table Create Table @@ -663,7 +669,7 @@ t1 CREATE TABLE `t1` ( `y` year(4) DEFAULT NULL, `t` date DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 PARTITION BY KEY () PARTITIONS 4 +) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY () PARTITIONS 4 */ --- Perform basic operation on master --- --- and ensure replicated correctly --- "--- Insert into t1 --" as ""; @@ -720,7 +726,7 @@ t1 CREATE TABLE `t1` ( `y` year(4) DEFAULT NULL, `t` date DEFAULT NULL, PRIMARY KEY (`id`,`total`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY () PARTITIONS 4 +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY () PARTITIONS 4 */ --- Make sure that our tables on slave are still right type --- --- and that the alter statements replicated correctly --- SHOW CREATE TABLE t1; @@ -736,7 +742,7 @@ t1 CREATE TABLE `t1` ( `y` year(4) DEFAULT NULL, `t` date DEFAULT NULL, PRIMARY KEY (`id`,`total`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 PARTITION BY KEY () PARTITIONS 4 +) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY () PARTITIONS 4 */ --- Perform basic operation on master --- --- and ensure replicated correctly --- "--- Insert into t1 --" as ""; @@ -793,7 +799,7 @@ t1 CREATE TABLE `t1` ( `y` year(4) DEFAULT NULL, `t` date DEFAULT NULL, PRIMARY KEY (`id`,`total`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY () PARTITIONS 4 +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY () PARTITIONS 4 */ --- Make sure that our tables on slave are still same engine --- --- and that the alter statements replicated correctly --- SHOW CREATE TABLE t1; @@ -809,7 +815,7 @@ t1 CREATE TABLE `t1` ( `y` year(4) DEFAULT NULL, `t` date DEFAULT NULL, PRIMARY KEY (`id`,`total`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 PARTITION BY KEY () PARTITIONS 4 +) ENGINE=InnoDB DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY () PARTITIONS 4 */ --- Perform basic operation on master --- --- and ensure replicated correctly --- "--- Insert into t1 --" as ""; @@ -853,3 +859,4 @@ DELETE FROM t1; --- End test 5 key partition testing --- --- Do Cleanup --- DROP TABLE IF EXISTS t1; +drop table mysql.ndb_apply_status; diff --git a/mysql-test/suite/rpl_ndb/r/rpl_ndb_2myisam.result b/mysql-test/suite/rpl_ndb/r/rpl_ndb_2myisam.result index 8611d83f3f3..05bc480c50d 100644 --- a/mysql-test/suite/rpl_ndb/r/rpl_ndb_2myisam.result +++ b/mysql-test/suite/rpl_ndb/r/rpl_ndb_2myisam.result @@ -4,7 +4,13 @@ reset master; reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; start slave; -SET storage_engine=ndb; +CREATE TABLE mysql.ndb_apply_status +( server_id INT UNSIGNED NOT NULL, +epoch BIGINT UNSIGNED NOT NULL, +log_name VARCHAR(255) BINARY NOT NULL, +start_pos BIGINT UNSIGNED NOT NULL, +end_pos BIGINT UNSIGNED NOT NULL, +PRIMARY KEY USING HASH (server_id)) ENGINE=MYISAM; --- Doing pre test cleanup --- DROP TABLE IF EXISTS t1; --- Start test 1 Basic testing --- @@ -186,7 +192,7 @@ t1 CREATE TABLE `t1` ( `total` bigint(20) unsigned DEFAULT NULL, `y` year(4) DEFAULT NULL, `t` date DEFAULT NULL -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY RANGE (YEAR(t)) (PARTITION p0 VALUES LESS THAN (1901) ENGINE = ndbcluster, PARTITION p1 VALUES LESS THAN (1946) ENGINE = ndbcluster, PARTITION p2 VALUES LESS THAN (1966) ENGINE = ndbcluster, PARTITION p3 VALUES LESS THAN (1986) ENGINE = ndbcluster, PARTITION p4 VALUES LESS THAN (2005) ENGINE = ndbcluster, PARTITION p5 VALUES LESS THAN MAXVALUE ENGINE = ndbcluster) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (YEAR(t)) (PARTITION p0 VALUES LESS THAN (1901) ENGINE = ndbcluster, PARTITION p1 VALUES LESS THAN (1946) ENGINE = ndbcluster, PARTITION p2 VALUES LESS THAN (1966) ENGINE = ndbcluster, PARTITION p3 VALUES LESS THAN (1986) ENGINE = ndbcluster, PARTITION p4 VALUES LESS THAN (2005) ENGINE = ndbcluster, PARTITION p5 VALUES LESS THAN MAXVALUE ENGINE = ndbcluster) */ --- Show table on slave -- SHOW CREATE TABLE t1; Table Create Table @@ -200,7 +206,7 @@ t1 CREATE TABLE `t1` ( `total` bigint(20) unsigned DEFAULT NULL, `y` year(4) DEFAULT NULL, `t` date DEFAULT NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY RANGE (YEAR(t)) (PARTITION p0 VALUES LESS THAN (1901) ENGINE = MyISAM, PARTITION p1 VALUES LESS THAN (1946) ENGINE = MyISAM, PARTITION p2 VALUES LESS THAN (1966) ENGINE = MyISAM, PARTITION p3 VALUES LESS THAN (1986) ENGINE = MyISAM, PARTITION p4 VALUES LESS THAN (2005) ENGINE = MyISAM, PARTITION p5 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (YEAR(t)) (PARTITION p0 VALUES LESS THAN (1901) ENGINE = MyISAM, PARTITION p1 VALUES LESS THAN (1946) ENGINE = MyISAM, PARTITION p2 VALUES LESS THAN (1966) ENGINE = MyISAM, PARTITION p3 VALUES LESS THAN (1986) ENGINE = MyISAM, PARTITION p4 VALUES LESS THAN (2005) ENGINE = MyISAM, PARTITION p5 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */ --- Perform basic operation on master --- --- and ensure replicated correctly --- "--- Insert into t1 --" as ""; @@ -258,7 +264,7 @@ t1 CREATE TABLE `t1` ( `y` year(4) DEFAULT NULL, `t` date NOT NULL DEFAULT '0000-00-00', PRIMARY KEY (`t`,`id`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY RANGE (YEAR(t)) (PARTITION p0 VALUES LESS THAN (1901) ENGINE = ndbcluster, PARTITION p1 VALUES LESS THAN (1946) ENGINE = ndbcluster, PARTITION p2 VALUES LESS THAN (1966) ENGINE = ndbcluster, PARTITION p3 VALUES LESS THAN (1986) ENGINE = ndbcluster, PARTITION p4 VALUES LESS THAN (2005) ENGINE = ndbcluster, PARTITION p5 VALUES LESS THAN MAXVALUE ENGINE = ndbcluster) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (YEAR(t)) (PARTITION p0 VALUES LESS THAN (1901) ENGINE = ndbcluster, PARTITION p1 VALUES LESS THAN (1946) ENGINE = ndbcluster, PARTITION p2 VALUES LESS THAN (1966) ENGINE = ndbcluster, PARTITION p3 VALUES LESS THAN (1986) ENGINE = ndbcluster, PARTITION p4 VALUES LESS THAN (2005) ENGINE = ndbcluster, PARTITION p5 VALUES LESS THAN MAXVALUE ENGINE = ndbcluster) */ --- Make sure that our tables on slave are still same engine --- --- and that the alter statements replicated correctly --- SHOW CREATE TABLE t1; @@ -274,7 +280,7 @@ t1 CREATE TABLE `t1` ( `y` year(4) DEFAULT NULL, `t` date NOT NULL DEFAULT '0000-00-00', PRIMARY KEY (`t`,`id`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY RANGE (YEAR(t)) (PARTITION p0 VALUES LESS THAN (1901) ENGINE = MyISAM, PARTITION p1 VALUES LESS THAN (1946) ENGINE = MyISAM, PARTITION p2 VALUES LESS THAN (1966) ENGINE = MyISAM, PARTITION p3 VALUES LESS THAN (1986) ENGINE = MyISAM, PARTITION p4 VALUES LESS THAN (2005) ENGINE = MyISAM, PARTITION p5 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY RANGE (YEAR(t)) (PARTITION p0 VALUES LESS THAN (1901) ENGINE = MyISAM, PARTITION p1 VALUES LESS THAN (1946) ENGINE = MyISAM, PARTITION p2 VALUES LESS THAN (1966) ENGINE = MyISAM, PARTITION p3 VALUES LESS THAN (1986) ENGINE = MyISAM, PARTITION p4 VALUES LESS THAN (2005) ENGINE = MyISAM, PARTITION p5 VALUES LESS THAN MAXVALUE ENGINE = MyISAM) */ --- Perform basic operation on master --- --- and ensure replicated correctly --- "--- Insert into t1 --" as ""; @@ -299,11 +305,11 @@ UPDATE t1 SET b1 = 0, t="2006-02-22" WHERE id = 412; --- Check the update on master --- SELECT id,hex(b1),vc,bc,d,f,total,y,t FROM t1 WHERE id = 412; id hex(b1) vc bc d f total y t -412 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 2006-02-22 +412 0 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 2006-02-22 --- Check Update on slave --- SELECT id,hex(b1),vc,bc,d,f,total,y,t FROM t1 WHERE id = 412; id hex(b1) vc bc d f total y t -412 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 2006-02-22 +412 0 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 2006-02-22 --- Remove a record from t1 on master --- DELETE FROM t1 WHERE id = 42; --- Show current count on master for t1 --- @@ -342,7 +348,7 @@ t1 CREATE TABLE `t1` ( `total` bigint(20) unsigned DEFAULT NULL, `y` year(4) DEFAULT NULL, `t` date DEFAULT NULL -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY LIST (id) (PARTITION p0 VALUES IN (2,4) ENGINE = ndbcluster, PARTITION p1 VALUES IN (42,142) ENGINE = ndbcluster, PARTITION p2 VALUES IN (412) ENGINE = ndbcluster) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (id) (PARTITION p0 VALUES IN (2,4) ENGINE = ndbcluster, PARTITION p1 VALUES IN (42,142) ENGINE = ndbcluster, PARTITION p2 VALUES IN (412) ENGINE = ndbcluster) */ --- Show table on slave --- SHOW CREATE TABLE t1; Table Create Table @@ -356,7 +362,7 @@ t1 CREATE TABLE `t1` ( `total` bigint(20) unsigned DEFAULT NULL, `y` year(4) DEFAULT NULL, `t` date DEFAULT NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY LIST (id) (PARTITION p0 VALUES IN (2,4) ENGINE = MyISAM, PARTITION p1 VALUES IN (42,142) ENGINE = MyISAM, PARTITION p2 VALUES IN (412) ENGINE = MyISAM) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (id) (PARTITION p0 VALUES IN (2,4) ENGINE = MyISAM, PARTITION p1 VALUES IN (42,142) ENGINE = MyISAM, PARTITION p2 VALUES IN (412) ENGINE = MyISAM) */ --- Perform basic operation on master --- --- and ensure replicated correctly --- "--- Insert into t1 --" as ""; @@ -414,7 +420,7 @@ t1 CREATE TABLE `t1` ( `y` year(4) DEFAULT NULL, `t` date DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY LIST (id) (PARTITION p0 VALUES IN (2,4) ENGINE = ndbcluster, PARTITION p1 VALUES IN (42,142) ENGINE = ndbcluster, PARTITION p2 VALUES IN (412) ENGINE = ndbcluster) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (id) (PARTITION p0 VALUES IN (2,4) ENGINE = ndbcluster, PARTITION p1 VALUES IN (42,142) ENGINE = ndbcluster, PARTITION p2 VALUES IN (412) ENGINE = ndbcluster) */ --- Make sure that our tables on slave are still same engine --- --- and that the alter statements replicated correctly --- SHOW CREATE TABLE t1; @@ -430,7 +436,7 @@ t1 CREATE TABLE `t1` ( `y` year(4) DEFAULT NULL, `t` date DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY LIST (id) (PARTITION p0 VALUES IN (2,4) ENGINE = MyISAM, PARTITION p1 VALUES IN (42,142) ENGINE = MyISAM, PARTITION p2 VALUES IN (412) ENGINE = MyISAM) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY LIST (id) (PARTITION p0 VALUES IN (2,4) ENGINE = MyISAM, PARTITION p1 VALUES IN (42,142) ENGINE = MyISAM, PARTITION p2 VALUES IN (412) ENGINE = MyISAM) */ --- Perform basic operation on master --- --- and ensure replicated correctly --- "--- Insert into t1 --" as ""; @@ -495,7 +501,7 @@ t1 CREATE TABLE `t1` ( `total` bigint(20) unsigned DEFAULT NULL, `y` year(4) DEFAULT NULL, `t` date DEFAULT NULL -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY HASH ( YEAR(t)) PARTITIONS 4 +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH ( YEAR(t)) PARTITIONS 4 */ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( @@ -508,7 +514,7 @@ t1 CREATE TABLE `t1` ( `total` bigint(20) unsigned DEFAULT NULL, `y` year(4) DEFAULT NULL, `t` date DEFAULT NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY HASH ( YEAR(t)) PARTITIONS 4 +) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH ( YEAR(t)) PARTITIONS 4 */ --- Perform basic operation on master --- --- and ensure replicated correctly --- "--- Insert into t1 --" as ""; @@ -533,11 +539,11 @@ UPDATE t1 SET b1 = 0, t="2006-02-22" WHERE id = 412; --- Check the update on master --- SELECT id,hex(b1),vc,bc,d,f,total,y,t FROM t1 WHERE id = 412; id hex(b1) vc bc d f total y t -412 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 2006-02-22 +412 0 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 2006-02-22 --- Check Update on slave --- SELECT id,hex(b1),vc,bc,d,f,total,y,t FROM t1 WHERE id = 412; id hex(b1) vc bc d f total y t -412 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 2006-02-22 +412 0 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 2006-02-22 --- Remove a record from t1 on master --- DELETE FROM t1 WHERE id = 42; --- Show current count on master for t1 --- @@ -566,7 +572,7 @@ t1 CREATE TABLE `t1` ( `y` year(4) DEFAULT NULL, `t` date NOT NULL DEFAULT '0000-00-00', PRIMARY KEY (`t`,`id`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY HASH ( YEAR(t)) PARTITIONS 4 +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH ( YEAR(t)) PARTITIONS 4 */ --- Make sure that our tables on slave are still same engine --- --- and that the alter statements replicated correctly --- SHOW CREATE TABLE t1; @@ -582,7 +588,7 @@ t1 CREATE TABLE `t1` ( `y` year(4) DEFAULT NULL, `t` date NOT NULL DEFAULT '0000-00-00', PRIMARY KEY (`t`,`id`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY HASH ( YEAR(t)) PARTITIONS 4 +) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY HASH ( YEAR(t)) PARTITIONS 4 */ --- Perform basic operation on master --- --- and ensure replicated correctly --- "--- Insert into t1 --" as ""; @@ -607,11 +613,11 @@ UPDATE t1 SET b1 = 0, t="2006-02-22" WHERE id = 412; --- Check the update on master --- SELECT id,hex(b1),vc,bc,d,f,total,y,t FROM t1 WHERE id = 412; id hex(b1) vc bc d f total y t -412 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 2006-02-22 +412 0 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 2006-02-22 --- Check Update on slave --- SELECT id,hex(b1),vc,bc,d,f,total,y,t FROM t1 WHERE id = 412; id hex(b1) vc bc d f total y t -412 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 2006-02-22 +412 0 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 2006-02-22 --- Remove a record from t1 on master --- DELETE FROM t1 WHERE id = 42; --- Show current count on master for t1 --- @@ -648,7 +654,7 @@ t1 CREATE TABLE `t1` ( `y` year(4) DEFAULT NULL, `t` date DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY () PARTITIONS 4 +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY () PARTITIONS 4 */ --- Show that tables on slave --- SHOW CREATE TABLE t1; Table Create Table @@ -663,7 +669,7 @@ t1 CREATE TABLE `t1` ( `y` year(4) DEFAULT NULL, `t` date DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY KEY () PARTITIONS 4 +) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY () PARTITIONS 4 */ --- Perform basic operation on master --- --- and ensure replicated correctly --- "--- Insert into t1 --" as ""; @@ -720,7 +726,7 @@ t1 CREATE TABLE `t1` ( `y` year(4) DEFAULT NULL, `t` date DEFAULT NULL, PRIMARY KEY (`id`,`total`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY () PARTITIONS 4 +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY () PARTITIONS 4 */ --- Make sure that our tables on slave are still right type --- --- and that the alter statements replicated correctly --- SHOW CREATE TABLE t1; @@ -736,7 +742,7 @@ t1 CREATE TABLE `t1` ( `y` year(4) DEFAULT NULL, `t` date DEFAULT NULL, PRIMARY KEY (`id`,`total`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY KEY () PARTITIONS 4 +) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY () PARTITIONS 4 */ --- Perform basic operation on master --- --- and ensure replicated correctly --- "--- Insert into t1 --" as ""; @@ -793,7 +799,7 @@ t1 CREATE TABLE `t1` ( `y` year(4) DEFAULT NULL, `t` date DEFAULT NULL, PRIMARY KEY (`id`,`total`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 PARTITION BY KEY () PARTITIONS 4 +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY () PARTITIONS 4 */ --- Make sure that our tables on slave are still same engine --- --- and that the alter statements replicated correctly --- SHOW CREATE TABLE t1; @@ -809,7 +815,7 @@ t1 CREATE TABLE `t1` ( `y` year(4) DEFAULT NULL, `t` date DEFAULT NULL, PRIMARY KEY (`id`,`total`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY KEY () PARTITIONS 4 +) ENGINE=MyISAM DEFAULT CHARSET=latin1 /*!50100 PARTITION BY KEY () PARTITIONS 4 */ --- Perform basic operation on master --- --- and ensure replicated correctly --- "--- Insert into t1 --" as ""; @@ -853,3 +859,4 @@ DELETE FROM t1; --- End test 5 key partition testing --- --- Do Cleanup --- DROP TABLE IF EXISTS t1; +drop table mysql.ndb_apply_status; diff --git a/mysql-test/suite/rpl_ndb/r/rpl_ndb_2ndb.result b/mysql-test/suite/rpl_ndb/r/rpl_ndb_2ndb.result new file mode 100644 index 00000000000..a28ec04fdf0 --- /dev/null +++ b/mysql-test/suite/rpl_ndb/r/rpl_ndb_2ndb.result @@ -0,0 +1,401 @@ +stop slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +reset master; +reset slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +start slave; +SET storage_engine=ndb; + +=== NDB -> NDB === + +SET storage_engine=ndb; +--- Doing pre test cleanup --- +DROP TABLE IF EXISTS t1; +--- Create Table Section --- +CREATE TABLE t1 (id MEDIUMINT NOT NULL, +b1 INT, +vc VARCHAR(255), +bc CHAR(255), +d DECIMAL(10,4) DEFAULT 0, +f FLOAT DEFAULT 0, +total BIGINT UNSIGNED, +y YEAR, +t DATE, +PRIMARY KEY(id)); +--- Show table on master --- +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `id` mediumint(9) NOT NULL, + `b1` int(11) DEFAULT NULL, + `vc` varchar(255) DEFAULT NULL, + `bc` char(255) DEFAULT NULL, + `d` decimal(10,4) DEFAULT '0.0000', + `f` float DEFAULT '0', + `total` bigint(20) unsigned DEFAULT NULL, + `y` year(4) DEFAULT NULL, + `t` date DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 +--- Show table on slave --- +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `id` mediumint(9) NOT NULL, + `b1` int(11) DEFAULT NULL, + `vc` varchar(255) DEFAULT NULL, + `bc` char(255) DEFAULT NULL, + `d` decimal(10,4) DEFAULT '0.0000', + `f` float DEFAULT '0', + `total` bigint(20) unsigned DEFAULT NULL, + `y` year(4) DEFAULT NULL, + `t` date DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +STOP SLAVE; +RESET SLAVE; +RESET MASTER; +START SLAVE; +--- Populate t1 with data --- +--- Select from t1 on master --- +select * +from t1 +order by id; +id b1 vc bc d f total y t +2 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1965-11-14 +4 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1985-11-14 +42 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1905-11-14 +142 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1995-11-14 +412 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 2005-11-14 +--- Select from t1 on slave --- +select * +from t1 +order by id; +id b1 vc bc d f total y t +2 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1965-11-14 +4 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1985-11-14 +42 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1905-11-14 +142 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1995-11-14 +412 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 2005-11-14 +--- Perform basic operation on master --- +--- and ensure replicated correctly --- +--- Update t1 on master -- +UPDATE t1 SET b1 = 0, bc='updated', t="2006-02-22" +WHERE id < 100 +ORDER BY id; +--- Check the update on master --- +SELECT * +FROM t1 +WHERE id < 100 +ORDER BY id; +id b1 vc bc d f total y t +2 0 Testing MySQL databases is a cool updated 654321.4321 15.21 0 1965 2006-02-22 +4 0 Testing MySQL databases is a cool updated 654321.4321 15.21 0 1965 2006-02-22 +42 0 Testing MySQL databases is a cool updated 654321.4321 15.21 0 1965 2006-02-22 +--- Check Update on slave --- +SELECT * +FROM t1 +WHERE id < 100 +ORDER BY id; +id b1 vc bc d f total y t +2 0 Testing MySQL databases is a cool updated 654321.4321 15.21 0 1965 2006-02-22 +4 0 Testing MySQL databases is a cool updated 654321.4321 15.21 0 1965 2006-02-22 +42 0 Testing MySQL databases is a cool updated 654321.4321 15.21 0 1965 2006-02-22 +--- Remove a record from t1 on master --- +DELETE FROM t1 WHERE id = 412; +--- Show current count on master for t1 --- +SELECT COUNT(*) FROM t1; +COUNT(*) +4 +--- Show current count on slave for t1 --- +SELECT COUNT(*) FROM t1; +COUNT(*) +4 +TRUNCATE TABLE t1; +--- Check that simple Alter statements are replicated correctly -- +ALTER TABLE t1 DROP PRIMARY KEY; +ALTER TABLE t1 MODIFY vc char(32); +--- Show the new improved table on the master --- +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `id` mediumint(9) NOT NULL, + `b1` int(11) DEFAULT NULL, + `vc` char(32) DEFAULT NULL, + `bc` char(255) DEFAULT NULL, + `d` decimal(10,4) DEFAULT '0.0000', + `f` float DEFAULT '0', + `total` bigint(20) unsigned DEFAULT NULL, + `y` year(4) DEFAULT NULL, + `t` date DEFAULT NULL +) ENGINE=ndbcluster DEFAULT CHARSET=latin1 +--- Make sure that our tables on slave are still same engine --- +--- and that the alter statements replicated correctly --- +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `id` mediumint(9) NOT NULL, + `b1` int(11) DEFAULT NULL, + `vc` char(32) DEFAULT NULL, + `bc` char(255) DEFAULT NULL, + `d` decimal(10,4) DEFAULT '0.0000', + `f` float DEFAULT '0', + `total` bigint(20) unsigned DEFAULT NULL, + `y` year(4) DEFAULT NULL, + `t` date DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +STOP SLAVE; +RESET SLAVE; +RESET MASTER; +START SLAVE; +--- Populate t1 with data --- +--- Select from t1 on master --- +select * +from t1 +order by id; +id b1 vc bc d f total y t +2 1 Testing MySQL databases is a coo Must make it bug free for the customer 654321.4321 15.21 0 1965 1965-11-14 +4 1 Testing MySQL databases is a coo Must make it bug free for the customer 654321.4321 15.21 0 1965 1985-11-14 +42 1 Testing MySQL databases is a coo Must make it bug free for the customer 654321.4321 15.21 0 1965 1905-11-14 +142 1 Testing MySQL databases is a coo Must make it bug free for the customer 654321.4321 15.21 0 1965 1995-11-14 +412 1 Testing MySQL databases is a coo Must make it bug free for the customer 654321.4321 15.21 0 1965 2005-11-14 +--- Select from t1 on slave --- +select * +from t1 +order by id; +id b1 vc bc d f total y t +2 1 Testing MySQL databases is a coo Must make it bug free for the customer 654321.4321 15.21 0 1965 1965-11-14 +4 1 Testing MySQL databases is a coo Must make it bug free for the customer 654321.4321 15.21 0 1965 1985-11-14 +42 1 Testing MySQL databases is a coo Must make it bug free for the customer 654321.4321 15.21 0 1965 1905-11-14 +142 1 Testing MySQL databases is a coo Must make it bug free for the customer 654321.4321 15.21 0 1965 1995-11-14 +412 1 Testing MySQL databases is a coo Must make it bug free for the customer 654321.4321 15.21 0 1965 2005-11-14 +--- Perform basic operation on master --- +--- and ensure replicated correctly --- +--- Update t1 on master -- +UPDATE t1 SET b1 = 0, bc='updated', t="2006-02-22" +WHERE id < 100 +ORDER BY id; +--- Check the update on master --- +SELECT * +FROM t1 +WHERE id < 100 +ORDER BY id; +id b1 vc bc d f total y t +2 0 Testing MySQL databases is a coo updated 654321.4321 15.21 0 1965 2006-02-22 +4 0 Testing MySQL databases is a coo updated 654321.4321 15.21 0 1965 2006-02-22 +42 0 Testing MySQL databases is a coo updated 654321.4321 15.21 0 1965 2006-02-22 +--- Check Update on slave --- +SELECT * +FROM t1 +WHERE id < 100 +ORDER BY id; +id b1 vc bc d f total y t +2 0 Testing MySQL databases is a coo updated 654321.4321 15.21 0 1965 2006-02-22 +4 0 Testing MySQL databases is a coo updated 654321.4321 15.21 0 1965 2006-02-22 +42 0 Testing MySQL databases is a coo updated 654321.4321 15.21 0 1965 2006-02-22 +--- Remove a record from t1 on master --- +DELETE FROM t1 WHERE id = 412; +--- Show current count on master for t1 --- +SELECT COUNT(*) FROM t1; +COUNT(*) +4 +--- Show current count on slave for t1 --- +SELECT COUNT(*) FROM t1; +COUNT(*) +4 +TRUNCATE TABLE t1; +--- Check that replication works when slave has more columns than master +ALTER TABLE t1 ADD PRIMARY KEY(id,total); +ALTER TABLE t1 MODIFY vc TEXT; +INSERT INTO t1 VALUES(3,1,'Testing MySQL databases is a cool ', +'Must make it bug free for the customer', +654321.4321,15.21,0,1965,"1905-11-14"); +INSERT INTO t1 VALUES(20,1,'Testing MySQL databases is a cool ', +'Must make it bug free for the customer', +654321.4321,15.21,0,1965,"1965-11-14"); +INSERT INTO t1 VALUES(50,1,'Testing MySQL databases is a cool ', +'Must make it bug free for the customer', +654321.4321,15.21,0,1965,"1985-11-14"); +--- Add columns on slave --- +ALTER TABLE t1 ADD (u int, v char(16) default 'default'); +UPDATE t1 SET u=7 WHERE id < 50; +UPDATE t1 SET v='explicit' WHERE id >10; +--- Show changed table on slave --- +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `id` mediumint(9) NOT NULL, + `b1` int(11) DEFAULT NULL, + `vc` text, + `bc` char(255) DEFAULT NULL, + `d` decimal(10,4) DEFAULT '0.0000', + `f` float DEFAULT '0', + `total` bigint(20) unsigned NOT NULL DEFAULT '0', + `y` year(4) DEFAULT NULL, + `t` date DEFAULT NULL, + `u` int(11) DEFAULT NULL, + `v` char(16) DEFAULT 'default', + PRIMARY KEY (`id`,`total`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +SELECT * +FROM t1 +ORDER BY id; +id b1 vc bc d f total y t u v +3 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1905-11-14 7 default +20 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1965-11-14 7 explicit +50 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1985-11-14 NULL explicit +STOP SLAVE; +RESET SLAVE; +RESET MASTER; +START SLAVE; +--- Populate t1 with data --- +--- Select from t1 on master --- +select * +from t1 +order by id; +id b1 vc bc d f total y t +2 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1965-11-14 +3 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1905-11-14 +4 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1985-11-14 +20 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1965-11-14 +42 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1905-11-14 +50 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1985-11-14 +142 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1995-11-14 +412 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 2005-11-14 +--- Select from t1 on slave --- +select * +from t1 +order by id; +id b1 vc bc d f total y t u v +2 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1965-11-14 NULL default +3 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1905-11-14 7 default +4 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1985-11-14 NULL default +20 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1965-11-14 7 explicit +42 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1905-11-14 NULL default +50 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1985-11-14 NULL explicit +142 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1995-11-14 NULL default +412 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 2005-11-14 NULL default +--- Perform basic operation on master --- +--- and ensure replicated correctly --- +--- Update t1 on master -- +UPDATE t1 SET b1 = 0, bc='updated', t="2006-02-22" +WHERE id < 100 +ORDER BY id; +--- Check the update on master --- +SELECT * +FROM t1 +WHERE id < 100 +ORDER BY id; +id b1 vc bc d f total y t +2 0 Testing MySQL databases is a cool updated 654321.4321 15.21 0 1965 2006-02-22 +3 0 Testing MySQL databases is a cool updated 654321.4321 15.21 0 1965 2006-02-22 +4 0 Testing MySQL databases is a cool updated 654321.4321 15.21 0 1965 2006-02-22 +20 0 Testing MySQL databases is a cool updated 654321.4321 15.21 0 1965 2006-02-22 +42 0 Testing MySQL databases is a cool updated 654321.4321 15.21 0 1965 2006-02-22 +50 0 Testing MySQL databases is a cool updated 654321.4321 15.21 0 1965 2006-02-22 +--- Check Update on slave --- +SELECT * +FROM t1 +WHERE id < 100 +ORDER BY id; +id b1 vc bc d f total y t u v +2 0 Testing MySQL databases is a cool updated 654321.4321 15.21 0 1965 2006-02-22 NULL default +3 0 Testing MySQL databases is a cool updated 654321.4321 15.21 0 1965 2006-02-22 7 default +4 0 Testing MySQL databases is a cool updated 654321.4321 15.21 0 1965 2006-02-22 NULL default +20 0 Testing MySQL databases is a cool updated 654321.4321 15.21 0 1965 2006-02-22 7 explicit +42 0 Testing MySQL databases is a cool updated 654321.4321 15.21 0 1965 2006-02-22 NULL default +50 0 Testing MySQL databases is a cool updated 654321.4321 15.21 0 1965 2006-02-22 NULL explicit +--- Remove a record from t1 on master --- +DELETE FROM t1 WHERE id = 412; +--- Show current count on master for t1 --- +SELECT COUNT(*) FROM t1; +COUNT(*) +7 +--- Show current count on slave for t1 --- +SELECT COUNT(*) FROM t1; +COUNT(*) +7 +TRUNCATE TABLE t1; +TRUNCATE TABLE t1; +--- Check that replication works when master has more columns than slave +--- Remove columns on slave --- +ALTER TABLE t1 DROP COLUMN v; +ALTER TABLE t1 DROP COLUMN u; +ALTER TABLE t1 DROP COLUMN t; +ALTER TABLE t1 DROP COLUMN y; +--- Show changed table on slave --- +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `id` mediumint(9) NOT NULL, + `b1` int(11) DEFAULT NULL, + `vc` text, + `bc` char(255) DEFAULT NULL, + `d` decimal(10,4) DEFAULT '0.0000', + `f` float DEFAULT '0', + `total` bigint(20) unsigned NOT NULL DEFAULT '0', + PRIMARY KEY (`id`,`total`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +STOP SLAVE; +RESET SLAVE; +RESET MASTER; +START SLAVE; +--- Populate t1 with data --- +--- Select from t1 on master --- +select * +from t1 +order by id; +id b1 vc bc d f total y t +2 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1965-11-14 +4 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1985-11-14 +42 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1905-11-14 +142 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1995-11-14 +412 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 2005-11-14 +--- Select from t1 on slave --- +select * +from t1 +order by id; +id b1 vc bc d f total +2 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 +4 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 +42 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 +142 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 +412 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 +--- Perform basic operation on master --- +--- and ensure replicated correctly --- +--- Update t1 on master -- +UPDATE t1 SET b1 = 0, bc='updated', t="2006-02-22" +WHERE id < 100 +ORDER BY id; +--- Check the update on master --- +SELECT * +FROM t1 +WHERE id < 100 +ORDER BY id; +id b1 vc bc d f total y t +2 0 Testing MySQL databases is a cool updated 654321.4321 15.21 0 1965 2006-02-22 +4 0 Testing MySQL databases is a cool updated 654321.4321 15.21 0 1965 2006-02-22 +42 0 Testing MySQL databases is a cool updated 654321.4321 15.21 0 1965 2006-02-22 +--- Check Update on slave --- +SELECT * +FROM t1 +WHERE id < 100 +ORDER BY id; +id b1 vc bc d f total +2 0 Testing MySQL databases is a cool updated 654321.4321 15.21 0 +4 0 Testing MySQL databases is a cool updated 654321.4321 15.21 0 +42 0 Testing MySQL databases is a cool updated 654321.4321 15.21 0 +--- Remove a record from t1 on master --- +DELETE FROM t1 WHERE id = 412; +--- Show current count on master for t1 --- +SELECT COUNT(*) FROM t1; +COUNT(*) +4 +--- Show current count on slave for t1 --- +SELECT COUNT(*) FROM t1; +COUNT(*) +4 +TRUNCATE TABLE t1; +TRUNCATE TABLE t1; +--- Do Cleanup -- +DROP TABLE IF EXISTS t1; diff --git a/mysql-test/suite/rpl_ndb/r/rpl_ndb_2other.result b/mysql-test/suite/rpl_ndb/r/rpl_ndb_2other.result index 56b997028e9..f838b406b21 100644 --- a/mysql-test/suite/rpl_ndb/r/rpl_ndb_2other.result +++ b/mysql-test/suite/rpl_ndb/r/rpl_ndb_2other.result @@ -8,6 +8,13 @@ SET storage_engine=ndb; === NDB -> MYISAM === +CREATE TABLE mysql.ndb_apply_status +( server_id INT UNSIGNED NOT NULL, +epoch BIGINT UNSIGNED NOT NULL, +log_name VARCHAR(255) BINARY NOT NULL, +start_pos BIGINT UNSIGNED NOT NULL, +end_pos BIGINT UNSIGNED NOT NULL, +PRIMARY KEY USING HASH (server_id)) ENGINE=MYISAM; SET storage_engine=myisam; --- Doing pre test cleanup --- DROP TABLE IF EXISTS t1; @@ -402,6 +409,7 @@ DROP TABLE IF EXISTS t1; === NDB -> INNODB === +alter table mysql.ndb_apply_status engine=innodb; SET storage_engine=innodb; --- Doing pre test cleanup --- DROP TABLE IF EXISTS t1; @@ -793,397 +801,4 @@ TRUNCATE TABLE t1; TRUNCATE TABLE t1; --- Do Cleanup -- DROP TABLE IF EXISTS t1; - -=== NDB -> NDB === - -SET storage_engine=ndb; ---- Doing pre test cleanup --- -DROP TABLE IF EXISTS t1; ---- Create Table Section --- -CREATE TABLE t1 (id MEDIUMINT NOT NULL, -b1 INT, -vc VARCHAR(255), -bc CHAR(255), -d DECIMAL(10,4) DEFAULT 0, -f FLOAT DEFAULT 0, -total BIGINT UNSIGNED, -y YEAR, -t DATE, -PRIMARY KEY(id)); ---- Show table on master --- -SHOW CREATE TABLE t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `id` mediumint(9) NOT NULL, - `b1` int(11) DEFAULT NULL, - `vc` varchar(255) DEFAULT NULL, - `bc` char(255) DEFAULT NULL, - `d` decimal(10,4) DEFAULT '0.0000', - `f` float DEFAULT '0', - `total` bigint(20) unsigned DEFAULT NULL, - `y` year(4) DEFAULT NULL, - `t` date DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 ---- Show table on slave --- -SHOW CREATE TABLE t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `id` mediumint(9) NOT NULL, - `b1` int(11) DEFAULT NULL, - `vc` varchar(255) DEFAULT NULL, - `bc` char(255) DEFAULT NULL, - `d` decimal(10,4) DEFAULT '0.0000', - `f` float DEFAULT '0', - `total` bigint(20) unsigned DEFAULT NULL, - `y` year(4) DEFAULT NULL, - `t` date DEFAULT NULL, - PRIMARY KEY (`id`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 -STOP SLAVE; -RESET SLAVE; -RESET MASTER; -START SLAVE; ---- Populate t1 with data --- ---- Select from t1 on master --- -select * -from t1 -order by id; -id b1 vc bc d f total y t -2 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1965-11-14 -4 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1985-11-14 -42 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1905-11-14 -142 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1995-11-14 -412 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 2005-11-14 ---- Select from t1 on slave --- -select * -from t1 -order by id; -id b1 vc bc d f total y t -2 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1965-11-14 -4 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1985-11-14 -42 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1905-11-14 -142 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1995-11-14 -412 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 2005-11-14 ---- Perform basic operation on master --- ---- and ensure replicated correctly --- ---- Update t1 on master -- -UPDATE t1 SET b1 = 0, bc='updated', t="2006-02-22" -WHERE id < 100 -ORDER BY id; ---- Check the update on master --- -SELECT * -FROM t1 -WHERE id < 100 -ORDER BY id; -id b1 vc bc d f total y t -2 0 Testing MySQL databases is a cool updated 654321.4321 15.21 0 1965 2006-02-22 -4 0 Testing MySQL databases is a cool updated 654321.4321 15.21 0 1965 2006-02-22 -42 0 Testing MySQL databases is a cool updated 654321.4321 15.21 0 1965 2006-02-22 ---- Check Update on slave --- -SELECT * -FROM t1 -WHERE id < 100 -ORDER BY id; -id b1 vc bc d f total y t -2 0 Testing MySQL databases is a cool updated 654321.4321 15.21 0 1965 2006-02-22 -4 0 Testing MySQL databases is a cool updated 654321.4321 15.21 0 1965 2006-02-22 -42 0 Testing MySQL databases is a cool updated 654321.4321 15.21 0 1965 2006-02-22 ---- Remove a record from t1 on master --- -DELETE FROM t1 WHERE id = 412; ---- Show current count on master for t1 --- -SELECT COUNT(*) FROM t1; -COUNT(*) -4 ---- Show current count on slave for t1 --- -SELECT COUNT(*) FROM t1; -COUNT(*) -4 -TRUNCATE TABLE t1; ---- Check that simple Alter statements are replicated correctly -- -ALTER TABLE t1 DROP PRIMARY KEY; -ALTER TABLE t1 MODIFY vc char(32); ---- Show the new improved table on the master --- -SHOW CREATE TABLE t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `id` mediumint(9) NOT NULL, - `b1` int(11) DEFAULT NULL, - `vc` char(32) DEFAULT NULL, - `bc` char(255) DEFAULT NULL, - `d` decimal(10,4) DEFAULT '0.0000', - `f` float DEFAULT '0', - `total` bigint(20) unsigned DEFAULT NULL, - `y` year(4) DEFAULT NULL, - `t` date DEFAULT NULL -) ENGINE=ndbcluster DEFAULT CHARSET=latin1 ---- Make sure that our tables on slave are still same engine --- ---- and that the alter statements replicated correctly --- -SHOW CREATE TABLE t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `id` mediumint(9) NOT NULL, - `b1` int(11) DEFAULT NULL, - `vc` char(32) DEFAULT NULL, - `bc` char(255) DEFAULT NULL, - `d` decimal(10,4) DEFAULT '0.0000', - `f` float DEFAULT '0', - `total` bigint(20) unsigned DEFAULT NULL, - `y` year(4) DEFAULT NULL, - `t` date DEFAULT NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 -STOP SLAVE; -RESET SLAVE; -RESET MASTER; -START SLAVE; ---- Populate t1 with data --- ---- Select from t1 on master --- -select * -from t1 -order by id; -id b1 vc bc d f total y t -2 1 Testing MySQL databases is a coo Must make it bug free for the customer 654321.4321 15.21 0 1965 1965-11-14 -4 1 Testing MySQL databases is a coo Must make it bug free for the customer 654321.4321 15.21 0 1965 1985-11-14 -42 1 Testing MySQL databases is a coo Must make it bug free for the customer 654321.4321 15.21 0 1965 1905-11-14 -142 1 Testing MySQL databases is a coo Must make it bug free for the customer 654321.4321 15.21 0 1965 1995-11-14 -412 1 Testing MySQL databases is a coo Must make it bug free for the customer 654321.4321 15.21 0 1965 2005-11-14 ---- Select from t1 on slave --- -select * -from t1 -order by id; -id b1 vc bc d f total y t -2 1 Testing MySQL databases is a coo Must make it bug free for the customer 654321.4321 15.21 0 1965 1965-11-14 -4 1 Testing MySQL databases is a coo Must make it bug free for the customer 654321.4321 15.21 0 1965 1985-11-14 -42 1 Testing MySQL databases is a coo Must make it bug free for the customer 654321.4321 15.21 0 1965 1905-11-14 -142 1 Testing MySQL databases is a coo Must make it bug free for the customer 654321.4321 15.21 0 1965 1995-11-14 -412 1 Testing MySQL databases is a coo Must make it bug free for the customer 654321.4321 15.21 0 1965 2005-11-14 ---- Perform basic operation on master --- ---- and ensure replicated correctly --- ---- Update t1 on master -- -UPDATE t1 SET b1 = 0, bc='updated', t="2006-02-22" -WHERE id < 100 -ORDER BY id; ---- Check the update on master --- -SELECT * -FROM t1 -WHERE id < 100 -ORDER BY id; -id b1 vc bc d f total y t -2 0 Testing MySQL databases is a coo updated 654321.4321 15.21 0 1965 2006-02-22 -4 0 Testing MySQL databases is a coo updated 654321.4321 15.21 0 1965 2006-02-22 -42 0 Testing MySQL databases is a coo updated 654321.4321 15.21 0 1965 2006-02-22 ---- Check Update on slave --- -SELECT * -FROM t1 -WHERE id < 100 -ORDER BY id; -id b1 vc bc d f total y t -2 0 Testing MySQL databases is a coo updated 654321.4321 15.21 0 1965 2006-02-22 -4 0 Testing MySQL databases is a coo updated 654321.4321 15.21 0 1965 2006-02-22 -42 0 Testing MySQL databases is a coo updated 654321.4321 15.21 0 1965 2006-02-22 ---- Remove a record from t1 on master --- -DELETE FROM t1 WHERE id = 412; ---- Show current count on master for t1 --- -SELECT COUNT(*) FROM t1; -COUNT(*) -4 ---- Show current count on slave for t1 --- -SELECT COUNT(*) FROM t1; -COUNT(*) -4 -TRUNCATE TABLE t1; ---- Check that replication works when slave has more columns than master -ALTER TABLE t1 ADD PRIMARY KEY(id,total); -ALTER TABLE t1 MODIFY vc TEXT; -INSERT INTO t1 VALUES(3,1,'Testing MySQL databases is a cool ', -'Must make it bug free for the customer', -654321.4321,15.21,0,1965,"1905-11-14"); -INSERT INTO t1 VALUES(20,1,'Testing MySQL databases is a cool ', -'Must make it bug free for the customer', -654321.4321,15.21,0,1965,"1965-11-14"); -INSERT INTO t1 VALUES(50,1,'Testing MySQL databases is a cool ', -'Must make it bug free for the customer', -654321.4321,15.21,0,1965,"1985-11-14"); ---- Add columns on slave --- -ALTER TABLE t1 ADD (u int, v char(16) default 'default'); -UPDATE t1 SET u=7 WHERE id < 50; -UPDATE t1 SET v='explicit' WHERE id >10; ---- Show changed table on slave --- -SHOW CREATE TABLE t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `id` mediumint(9) NOT NULL, - `b1` int(11) DEFAULT NULL, - `vc` text, - `bc` char(255) DEFAULT NULL, - `d` decimal(10,4) DEFAULT '0.0000', - `f` float DEFAULT '0', - `total` bigint(20) unsigned NOT NULL DEFAULT '0', - `y` year(4) DEFAULT NULL, - `t` date DEFAULT NULL, - `u` int(11) DEFAULT NULL, - `v` char(16) DEFAULT 'default', - PRIMARY KEY (`id`,`total`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 -SELECT * -FROM t1 -ORDER BY id; -id b1 vc bc d f total y t u v -3 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1905-11-14 7 default -20 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1965-11-14 7 explicit -50 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1985-11-14 NULL explicit -STOP SLAVE; -RESET SLAVE; -RESET MASTER; -START SLAVE; ---- Populate t1 with data --- ---- Select from t1 on master --- -select * -from t1 -order by id; -id b1 vc bc d f total y t -2 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1965-11-14 -3 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1905-11-14 -4 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1985-11-14 -20 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1965-11-14 -42 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1905-11-14 -50 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1985-11-14 -142 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1995-11-14 -412 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 2005-11-14 ---- Select from t1 on slave --- -select * -from t1 -order by id; -id b1 vc bc d f total y t u v -2 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1965-11-14 NULL default -3 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1905-11-14 7 default -4 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1985-11-14 NULL default -20 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1965-11-14 7 explicit -42 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1905-11-14 NULL default -50 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1985-11-14 NULL explicit -142 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1995-11-14 NULL default -412 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 2005-11-14 NULL default ---- Perform basic operation on master --- ---- and ensure replicated correctly --- ---- Update t1 on master -- -UPDATE t1 SET b1 = 0, bc='updated', t="2006-02-22" -WHERE id < 100 -ORDER BY id; ---- Check the update on master --- -SELECT * -FROM t1 -WHERE id < 100 -ORDER BY id; -id b1 vc bc d f total y t -2 0 Testing MySQL databases is a cool updated 654321.4321 15.21 0 1965 2006-02-22 -3 0 Testing MySQL databases is a cool updated 654321.4321 15.21 0 1965 2006-02-22 -4 0 Testing MySQL databases is a cool updated 654321.4321 15.21 0 1965 2006-02-22 -20 0 Testing MySQL databases is a cool updated 654321.4321 15.21 0 1965 2006-02-22 -42 0 Testing MySQL databases is a cool updated 654321.4321 15.21 0 1965 2006-02-22 -50 0 Testing MySQL databases is a cool updated 654321.4321 15.21 0 1965 2006-02-22 ---- Check Update on slave --- -SELECT * -FROM t1 -WHERE id < 100 -ORDER BY id; -id b1 vc bc d f total y t u v -2 0 Testing MySQL databases is a cool updated 654321.4321 15.21 0 1965 2006-02-22 NULL default -3 0 Testing MySQL databases is a cool updated 654321.4321 15.21 0 1965 2006-02-22 7 default -4 0 Testing MySQL databases is a cool updated 654321.4321 15.21 0 1965 2006-02-22 NULL default -20 0 Testing MySQL databases is a cool updated 654321.4321 15.21 0 1965 2006-02-22 7 explicit -42 0 Testing MySQL databases is a cool updated 654321.4321 15.21 0 1965 2006-02-22 NULL default -50 0 Testing MySQL databases is a cool updated 654321.4321 15.21 0 1965 2006-02-22 NULL explicit ---- Remove a record from t1 on master --- -DELETE FROM t1 WHERE id = 412; ---- Show current count on master for t1 --- -SELECT COUNT(*) FROM t1; -COUNT(*) -7 ---- Show current count on slave for t1 --- -SELECT COUNT(*) FROM t1; -COUNT(*) -7 -TRUNCATE TABLE t1; -TRUNCATE TABLE t1; ---- Check that replication works when master has more columns than slave ---- Remove columns on slave --- -ALTER TABLE t1 DROP COLUMN v; -ALTER TABLE t1 DROP COLUMN u; -ALTER TABLE t1 DROP COLUMN t; -ALTER TABLE t1 DROP COLUMN y; ---- Show changed table on slave --- -SHOW CREATE TABLE t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `id` mediumint(9) NOT NULL, - `b1` int(11) DEFAULT NULL, - `vc` text, - `bc` char(255) DEFAULT NULL, - `d` decimal(10,4) DEFAULT '0.0000', - `f` float DEFAULT '0', - `total` bigint(20) unsigned NOT NULL DEFAULT '0', - PRIMARY KEY (`id`,`total`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 -STOP SLAVE; -RESET SLAVE; -RESET MASTER; -START SLAVE; ---- Populate t1 with data --- ---- Select from t1 on master --- -select * -from t1 -order by id; -id b1 vc bc d f total y t -2 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1965-11-14 -4 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1985-11-14 -42 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1905-11-14 -142 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 1995-11-14 -412 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 1965 2005-11-14 ---- Select from t1 on slave --- -select * -from t1 -order by id; -id b1 vc bc d f total -2 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 -4 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 -42 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 -142 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 -412 1 Testing MySQL databases is a cool Must make it bug free for the customer 654321.4321 15.21 0 ---- Perform basic operation on master --- ---- and ensure replicated correctly --- ---- Update t1 on master -- -UPDATE t1 SET b1 = 0, bc='updated', t="2006-02-22" -WHERE id < 100 -ORDER BY id; ---- Check the update on master --- -SELECT * -FROM t1 -WHERE id < 100 -ORDER BY id; -id b1 vc bc d f total y t -2 0 Testing MySQL databases is a cool updated 654321.4321 15.21 0 1965 2006-02-22 -4 0 Testing MySQL databases is a cool updated 654321.4321 15.21 0 1965 2006-02-22 -42 0 Testing MySQL databases is a cool updated 654321.4321 15.21 0 1965 2006-02-22 ---- Check Update on slave --- -SELECT * -FROM t1 -WHERE id < 100 -ORDER BY id; -id b1 vc bc d f total -2 0 Testing MySQL databases is a cool updated 654321.4321 15.21 0 -4 0 Testing MySQL databases is a cool updated 654321.4321 15.21 0 -42 0 Testing MySQL databases is a cool updated 654321.4321 15.21 0 ---- Remove a record from t1 on master --- -DELETE FROM t1 WHERE id = 412; ---- Show current count on master for t1 --- -SELECT COUNT(*) FROM t1; -COUNT(*) -4 ---- Show current count on slave for t1 --- -SELECT COUNT(*) FROM t1; -COUNT(*) -4 -TRUNCATE TABLE t1; -TRUNCATE TABLE t1; ---- Do Cleanup -- -DROP TABLE IF EXISTS t1; +drop table mysql.ndb_apply_status; diff --git a/mysql-test/suite/rpl_ndb/t/disabled.def b/mysql-test/suite/rpl_ndb/t/disabled.def index bb701b9dc3e..1ca2fff0b3e 100644 --- a/mysql-test/suite/rpl_ndb/t/disabled.def +++ b/mysql-test/suite/rpl_ndb/t/disabled.def @@ -11,13 +11,6 @@ ############################################################################## -rpl_ndb_2innodb : Bug #32648 Test failure between NDB Cluster and other engines -rpl_ndb_2myisam : Bug #32648 Test failure between NDB Cluster and other engines -rpl_ndb_2other : Bug #32648 Test failure between NDB Cluster and other engines rpl_ndb_ctype_ucs2_def : BUG#27404 util thd mysql_parse sig11 when mysqld default multibyte charset -rpl_ndb_extraColMaster : BUG#30854 : Tables name show as binary in slave err msg on vm-win2003-64-b and Solaris -rpl_ndb_mix_innodb : Bug #32720 Test rpl_ndb_mix_innodb fails on SPARC and PowerPC # the below testcase have been reworked to avoid the bug, test contains comment, keep bug open - -#rpl_ndb_dd_advance : Bug#25913 rpl_ndb_dd_advance fails randomly diff --git a/mysql-test/suite/rpl_ndb/t/rpl_ndb_2innodb-master.opt b/mysql-test/suite/rpl_ndb/t/rpl_ndb_2innodb-master.opt index 701dddb075b..9a3f30e4bd0 100644 --- a/mysql-test/suite/rpl_ndb/t/rpl_ndb_2innodb-master.opt +++ b/mysql-test/suite/rpl_ndb/t/rpl_ndb_2innodb-master.opt @@ -1 +1 @@ ---default-storage-engine=ndbcluster +--new --default-storage-engine=ndbcluster diff --git a/mysql-test/suite/rpl_ndb/t/rpl_ndb_2innodb-slave.opt b/mysql-test/suite/rpl_ndb/t/rpl_ndb_2innodb-slave.opt index d8857e54be2..0d3f1619f1e 100644 --- a/mysql-test/suite/rpl_ndb/t/rpl_ndb_2innodb-slave.opt +++ b/mysql-test/suite/rpl_ndb/t/rpl_ndb_2innodb-slave.opt @@ -1 +1 @@ ---innodb --default-storage-engine=innodb +--innodb --default-storage-engine=innodb --ndbcluster=0 diff --git a/mysql-test/suite/rpl_ndb/t/rpl_ndb_2innodb.test b/mysql-test/suite/rpl_ndb/t/rpl_ndb_2innodb.test index 30e4e49eb7a..a91429f6014 100644 --- a/mysql-test/suite/rpl_ndb/t/rpl_ndb_2innodb.test +++ b/mysql-test/suite/rpl_ndb/t/rpl_ndb_2innodb.test @@ -8,9 +8,19 @@ # test and to have control over the tests. ############################################################## -- source include/have_ndb.inc --- source include/ndb_master-slave.inc -connection slave; +-- source include/master-slave.inc + +-- connection slave -- source include/have_innodb.inc -connection master; -SET storage_engine=ndb; +CREATE TABLE mysql.ndb_apply_status + ( server_id INT UNSIGNED NOT NULL, + epoch BIGINT UNSIGNED NOT NULL, + log_name VARCHAR(255) BINARY NOT NULL, + start_pos BIGINT UNSIGNED NOT NULL, + end_pos BIGINT UNSIGNED NOT NULL, + PRIMARY KEY USING HASH (server_id)) ENGINE=INNODB; + --source extra/rpl_tests/rpl_ndb_2multi_eng.test + +--connection slave +drop table mysql.ndb_apply_status; diff --git a/mysql-test/suite/rpl_ndb/t/rpl_ndb_2myisam-master.opt b/mysql-test/suite/rpl_ndb/t/rpl_ndb_2myisam-master.opt index 701dddb075b..b63ef44e8fc 100644 --- a/mysql-test/suite/rpl_ndb/t/rpl_ndb_2myisam-master.opt +++ b/mysql-test/suite/rpl_ndb/t/rpl_ndb_2myisam-master.opt @@ -1 +1 @@ ---default-storage-engine=ndbcluster +--new --default-storage-engine=ndbcluster diff --git a/mysql-test/suite/rpl_ndb/t/rpl_ndb_2myisam-slave.opt b/mysql-test/suite/rpl_ndb/t/rpl_ndb_2myisam-slave.opt index 6035ce27c46..9b5f524e131 100644 --- a/mysql-test/suite/rpl_ndb/t/rpl_ndb_2myisam-slave.opt +++ b/mysql-test/suite/rpl_ndb/t/rpl_ndb_2myisam-slave.opt @@ -1 +1 @@ ---default-storage-engine=myisam +--default-storage-engine=myisam --ndbcluster=0 diff --git a/mysql-test/suite/rpl_ndb/t/rpl_ndb_2myisam.test b/mysql-test/suite/rpl_ndb/t/rpl_ndb_2myisam.test index 182d4c72d87..6a1c4fbc339 100644 --- a/mysql-test/suite/rpl_ndb/t/rpl_ndb_2myisam.test +++ b/mysql-test/suite/rpl_ndb/t/rpl_ndb_2myisam.test @@ -8,6 +8,18 @@ # test and to have control over the tests. ############################################################## -- source include/have_ndb.inc --- source include/ndb_master-slave.inc -SET storage_engine=ndb; +-- source include/master-slave.inc + +-- connection slave +CREATE TABLE mysql.ndb_apply_status + ( server_id INT UNSIGNED NOT NULL, + epoch BIGINT UNSIGNED NOT NULL, + log_name VARCHAR(255) BINARY NOT NULL, + start_pos BIGINT UNSIGNED NOT NULL, + end_pos BIGINT UNSIGNED NOT NULL, + PRIMARY KEY USING HASH (server_id)) ENGINE=MYISAM; + --source extra/rpl_tests/rpl_ndb_2multi_eng.test + +--connection slave +drop table mysql.ndb_apply_status; diff --git a/mysql-test/suite/rpl_ndb/t/rpl_ndb_2ndb-slave.opt b/mysql-test/suite/rpl_ndb/t/rpl_ndb_2ndb-slave.opt new file mode 100644 index 00000000000..acd68493e0a --- /dev/null +++ b/mysql-test/suite/rpl_ndb/t/rpl_ndb_2ndb-slave.opt @@ -0,0 +1 @@ +--log-slave-updates=0 diff --git a/mysql-test/suite/rpl_ndb/t/rpl_ndb_2ndb.test b/mysql-test/suite/rpl_ndb/t/rpl_ndb_2ndb.test new file mode 100644 index 00000000000..1be325ed9a1 --- /dev/null +++ b/mysql-test/suite/rpl_ndb/t/rpl_ndb_2ndb.test @@ -0,0 +1,19 @@ +############################################################# +# Author: Rafal Somla +# Date: 2006-08-20 +# Purpose: Trying to test ability to replicate from cluster +# to other engines (innodb, myisam), see also rpl_ndb_2other.test +############################################################## +--source include/have_binlog_format_mixed_or_row.inc +--source include/ndb_master-slave.inc + +# On master use NDB as storage engine. +connection master; +SET storage_engine=ndb; + +--echo +--echo === NDB -> NDB === +--echo +connection slave; +SET storage_engine=ndb; +--source extra/rpl_tests/rpl_ndb_2multi_basic.test diff --git a/mysql-test/suite/rpl_ndb/t/rpl_ndb_2other-slave.opt b/mysql-test/suite/rpl_ndb/t/rpl_ndb_2other-slave.opt index a6c65034e68..188b31efa8a 100644 --- a/mysql-test/suite/rpl_ndb/t/rpl_ndb_2other-slave.opt +++ b/mysql-test/suite/rpl_ndb/t/rpl_ndb_2other-slave.opt @@ -1 +1 @@ ---innodb --log-slave-updates=0 +--innodb --ndbcluster=0 --log-slave-updates=0 diff --git a/mysql-test/suite/rpl_ndb/t/rpl_ndb_2other.test b/mysql-test/suite/rpl_ndb/t/rpl_ndb_2other.test index b7e393ca3cc..aa1ba733863 100644 --- a/mysql-test/suite/rpl_ndb/t/rpl_ndb_2other.test +++ b/mysql-test/suite/rpl_ndb/t/rpl_ndb_2other.test @@ -7,7 +7,7 @@ --source include/have_ndb.inc --source include/have_innodb.inc --source include/have_binlog_format_mixed_or_row.inc ---source include/ndb_master-slave.inc +--source include/master-slave.inc # On master use NDB as storage engine. connection master; @@ -17,6 +17,13 @@ SET storage_engine=ndb; --echo === NDB -> MYISAM === --echo connection slave; +CREATE TABLE mysql.ndb_apply_status + ( server_id INT UNSIGNED NOT NULL, + epoch BIGINT UNSIGNED NOT NULL, + log_name VARCHAR(255) BINARY NOT NULL, + start_pos BIGINT UNSIGNED NOT NULL, + end_pos BIGINT UNSIGNED NOT NULL, + PRIMARY KEY USING HASH (server_id)) ENGINE=MYISAM; SET storage_engine=myisam; --source extra/rpl_tests/rpl_ndb_2multi_basic.test @@ -24,12 +31,9 @@ SET storage_engine=myisam; --echo === NDB -> INNODB === --echo connection slave; +alter table mysql.ndb_apply_status engine=innodb; SET storage_engine=innodb; --source extra/rpl_tests/rpl_ndb_2multi_basic.test ---echo ---echo === NDB -> NDB === ---echo connection slave; -SET storage_engine=ndb; ---source extra/rpl_tests/rpl_ndb_2multi_basic.test +drop table mysql.ndb_apply_status; From 78d0a794f45fe437f5613a901fd468ab147d6c2e Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 4 Jan 2008 16:49:39 +0100 Subject: [PATCH 15/32] correct result file --- .../ndb_team/r/rpl_ndb_extraColMaster.result | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/mysql-test/suite/ndb_team/r/rpl_ndb_extraColMaster.result b/mysql-test/suite/ndb_team/r/rpl_ndb_extraColMaster.result index 194e6a375f3..3baf6afd56e 100644 --- a/mysql-test/suite/ndb_team/r/rpl_ndb_extraColMaster.result +++ b/mysql-test/suite/ndb_team/r/rpl_ndb_extraColMaster.result @@ -440,14 +440,14 @@ f1 f2 f3 f4 select * from t4 order by f1; f1 f2 f3 f4 1 1 1 first -select * from t31 order by f1; +select * from t31 order by f3; f1 f2 f3 f4 -1 1 5 fifth -1 1 3 third 1 1 1 first -1 1 6 sixth 1 1 2 second +1 1 3 third 1 1 4 fourth +1 1 5 fifth +1 1 6 sixth ** Do updates master ** @@ -563,7 +563,7 @@ Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1534 +Last_Errno 1535 Last_Error Table definition on master and slave does not match: Column 2 type mismatch - received type 5, test.t10 has type 254 Skip_Counter 0 Exec_Master_Log_Pos # @@ -581,7 +581,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno # Last_IO_Error # -Last_SQL_Errno 1534 +Last_SQL_Errno 1535 Last_SQL_Error Table definition on master and slave does not match: Column 2 type mismatch - received type 5, test.t10 has type 254 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; @@ -638,7 +638,7 @@ Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1534 +Last_Errno 1535 Last_Error Table definition on master and slave does not match: Column 2 type mismatch - received type 252, test.t11 has type 15 Skip_Counter 0 Exec_Master_Log_Pos # @@ -656,7 +656,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno # Last_IO_Error # -Last_SQL_Errno 1534 +Last_SQL_Errno 1535 Last_SQL_Error Table definition on master and slave does not match: Column 2 type mismatch - received type 252, test.t11 has type 15 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; @@ -1581,14 +1581,14 @@ f1 f2 f3 f4 select * from t4 order by f1; f1 f2 f3 f4 1 1 1 first -select * from t31 order by f1; +select * from t31 order by f3; f1 f2 f3 f4 -1 1 5 fifth -1 1 3 third 1 1 1 first -1 1 6 sixth 1 1 2 second +1 1 3 third 1 1 4 fourth +1 1 5 fifth +1 1 6 sixth ** Do updates master ** @@ -1704,7 +1704,7 @@ Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1534 +Last_Errno 1535 Last_Error Table definition on master and slave does not match: Column 2 type mismatch - received type 5, test.t10 has type 254 Skip_Counter 0 Exec_Master_Log_Pos # @@ -1722,7 +1722,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno # Last_IO_Error # -Last_SQL_Errno 1534 +Last_SQL_Errno 1535 Last_SQL_Error Table definition on master and slave does not match: Column 2 type mismatch - received type 5, test.t10 has type 254 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; @@ -1779,7 +1779,7 @@ Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table -Last_Errno 1534 +Last_Errno 1535 Last_Error Table definition on master and slave does not match: Column 2 type mismatch - received type 252, test.t11 has type 15 Skip_Counter 0 Exec_Master_Log_Pos # @@ -1797,7 +1797,7 @@ Seconds_Behind_Master # Master_SSL_Verify_Server_Cert No Last_IO_Errno # Last_IO_Error # -Last_SQL_Errno 1534 +Last_SQL_Errno 1535 Last_SQL_Error Table definition on master and slave does not match: Column 2 type mismatch - received type 252, test.t11 has type 15 SET GLOBAL SQL_SLAVE_SKIP_COUNTER=2; START SLAVE; From d2f7c2f9b9455c5fb19049d47bd30529285d1587 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 8 Jan 2008 13:23:35 +0100 Subject: [PATCH 16/32] ndb - bug#33739 page need to refetched after timeslice --- mysql-test/r/bdb_notembedded.result | 35 +++++++++++++++++ mysql-test/t/bdb_notembedded.test | 38 +++++++++++++++++++ .../ndb/src/kernel/blocks/dbtup/DbtupScan.cpp | 18 +++++++++ 3 files changed, 91 insertions(+) create mode 100644 mysql-test/r/bdb_notembedded.result create mode 100644 mysql-test/t/bdb_notembedded.test diff --git a/mysql-test/r/bdb_notembedded.result b/mysql-test/r/bdb_notembedded.result new file mode 100644 index 00000000000..14cb5fad915 --- /dev/null +++ b/mysql-test/r/bdb_notembedded.result @@ -0,0 +1,35 @@ +set autocommit=1; +reset master; +create table bug16206 (a int); +insert into bug16206 values(1); +start transaction; +insert into bug16206 values(2); +commit; +show binlog events; +Log_name Pos Event_type Server_id End_log_pos Info +f n Format_desc 1 n Server ver: VERSION, Binlog ver: 4 +f n Query 1 n use `test`; create table bug16206 (a int) +f n Query 1 n use `test`; insert into bug16206 values(1) +f n Query 1 n use `test`; insert into bug16206 values(2) +drop table bug16206; +reset master; +create table bug16206 (a int) engine= bdb; +insert into bug16206 values(0); +insert into bug16206 values(1); +start transaction; +insert into bug16206 values(2); +commit; +insert into bug16206 values(3); +show binlog events; +Log_name Pos Event_type Server_id End_log_pos Info +f n Format_desc 1 n Server ver: VERSION, Binlog ver: 4 +f n Query 1 n use `test`; create table bug16206 (a int) engine= bdb +f n Query 1 n use `test`; insert into bug16206 values(0) +f n Query 1 n use `test`; insert into bug16206 values(1) +f n Query 1 n use `test`; BEGIN +f n Query 1 n use `test`; insert into bug16206 values(2) +f n Query 1 n use `test`; COMMIT +f n Query 1 n use `test`; insert into bug16206 values(3) +drop table bug16206; +set autocommit=0; +End of 5.0 tests diff --git a/mysql-test/t/bdb_notembedded.test b/mysql-test/t/bdb_notembedded.test new file mode 100644 index 00000000000..24e64ebbfb2 --- /dev/null +++ b/mysql-test/t/bdb_notembedded.test @@ -0,0 +1,38 @@ +-- source include/not_embedded.inc +-- source include/have_bdb.inc + +# +# Bug #16206: Superfluous COMMIT event in binlog when updating BDB in autocommit mode +# +set autocommit=1; + +let $VERSION=`select version()`; + +reset master; +create table bug16206 (a int); +insert into bug16206 values(1); +start transaction; +insert into bug16206 values(2); +commit; +--replace_result $VERSION VERSION +--replace_column 1 f 2 n 5 n +show binlog events; +drop table bug16206; + +reset master; +create table bug16206 (a int) engine= bdb; +insert into bug16206 values(0); +insert into bug16206 values(1); +start transaction; +insert into bug16206 values(2); +commit; +insert into bug16206 values(3); +--replace_result $VERSION VERSION +--replace_column 1 f 2 n 5 n +show binlog events; +drop table bug16206; + +set autocommit=0; + + +--echo End of 5.0 tests diff --git a/storage/ndb/src/kernel/blocks/dbtup/DbtupScan.cpp b/storage/ndb/src/kernel/blocks/dbtup/DbtupScan.cpp index eecbee4c058..36a274ef36a 100644 --- a/storage/ndb/src/kernel/blocks/dbtup/DbtupScan.cpp +++ b/storage/ndb/src/kernel/blocks/dbtup/DbtupScan.cpp @@ -601,6 +601,24 @@ Dbtup::scanNext(Signal* signal, ScanOpPtr scanPtr) if (lcp && lcp_list != RNIL) goto found_lcp_keep; + + switch(pos.m_get){ + case ScanPos::Get_next_tuple: + case ScanPos::Get_next_tuple_fs: + jam(); + key.m_page_idx += size; + // fall through + case ScanPos::Get_tuple: + case ScanPos::Get_tuple_fs: + jam(); + /** + * We need to refetch page after timeslice + */ + pos.m_get = ScanPos::Get_page; + break; + default: + break; + } while (true) { switch (pos.m_get) { From 0f5cf86410aa7006f70bf3dc730f2f175d0b1642 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 8 Jan 2008 23:34:30 +0100 Subject: [PATCH 17/32] NdbRepStress.cpp: Updated with suggestions from Magnus and other fixes and adjustments I found along the way DbUtil.hpp, DbUtil.cpp: fixes and adjustments I found along the way storage/ndb/test/ndbapi/acrt/NdbRepStress.cpp: Updated with suggestions from Magnus and other fixes and adjustments I found along the way storage/ndb/test/src/DbUtil.cpp: fixes and adjustments I found along the way storage/ndb/test/include/DbUtil.hpp: fixes and adjustments I found along the way --- storage/ndb/test/include/DbUtil.hpp | 3 +- storage/ndb/test/ndbapi/acrt/NdbRepStress.cpp | 487 ++++++++++++++++++ storage/ndb/test/src/DbUtil.cpp | 42 +- 3 files changed, 527 insertions(+), 5 deletions(-) create mode 100644 storage/ndb/test/ndbapi/acrt/NdbRepStress.cpp diff --git a/storage/ndb/test/include/DbUtil.hpp b/storage/ndb/test/include/DbUtil.hpp index 9c885531ee7..62aaaf7b5a3 100755 --- a/storage/ndb/test/include/DbUtil.hpp +++ b/storage/ndb/test/include/DbUtil.hpp @@ -89,7 +89,8 @@ public: void mysqlCloseStmHandle(MYSQL_STMT *my_stmt); int connect(); - int select_DB(); + int selectDb(); + int selectDb(const char * m_db); int doQuery(char * stm); int doQuery(const char * stm); int getErrorNumber(); diff --git a/storage/ndb/test/ndbapi/acrt/NdbRepStress.cpp b/storage/ndb/test/ndbapi/acrt/NdbRepStress.cpp new file mode 100644 index 00000000000..7d9b66d8e72 --- /dev/null +++ b/storage/ndb/test/ndbapi/acrt/NdbRepStress.cpp @@ -0,0 +1,487 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static BaseString sqlStm; +static BaseString db; +static int t1_records = 50000; + +/**** TOOL SECTION ****/ + +static uint +urandom() +{ + uint r = (uint)random(); + return r; +} + +static uint +urandom(uint m) +{ + if (m == 0) + return 0; + uint r = urandom(); + r = r % m; + return r; +} + +#define GETNDB(ps) ((NDBT_NdbApiStep*)ps)->getNdb() +/* +*/ + +int +syncSlaveWithMaster() +{ + /* + We need to look at the MAX epoch of the + mysql.ndb_binlog_index table so we will + know when the slave has caught up + */ + + MYSQL_RES * result; + MYSQL_ROW row; + unsigned int masterEpoch = 0; + unsigned int slaveEpoch = 0; + unsigned int slaveEpochOld = 0; + int maxLoops = 100; + int loopCnt = 0; + + //Create a DbUtil object for the master + DbUtil master("mysql",""); + + //Login to Master + if (!master.connect()) + { + return NDBT_FAILED; + } + + //Set the database we are wanting + if (master.selectDb()) + { + return NDBT_FAILED; + } + + //Get max epoch from master + if(master.doQuery("SELECT MAX(epoch) FROM mysql.ndb_binlog_index")) + { + return NDBT_FAILED; + } + result = mysql_use_result(master.getMysql()); + row = mysql_fetch_row(result); + masterEpoch = atoi(row[0]); + mysql_free_result(result); + master.databaseLogout(); + + /* + Now we will pull current epoch from slave. If not the + same as master, we will continue to retrieve the epoch + and compare until it matches or we reach the max loops + allowed. + */ + + //Create a dbutil object for the slave + DbUtil slave("mysql",".slave"); + + //Login to slave + if (!slave.connect()) + { + return NDBT_FAILED; + } + + //Set the database we are wanting + if (slave.selectDb()) + { + return NDBT_FAILED; + } + + while(slaveEpoch != masterEpoch && loopCnt < maxLoops) + { + if(slave.doQuery("SELECT epoch FROM mysql.ndb_apply_status")) + { + return NDBT_FAILED; + } + result = mysql_use_result(slave.getMysql()); + row = mysql_fetch_row(result); + slaveEpoch = atoi(row[0]); + mysql_free_result(result); + + if(slaveEpoch != slaveEpochOld) + { + slaveEpochOld = slaveEpoch; + if(loopCnt > 0) + loopCnt--; + sleep(3); + } + else + { + sleep(1); + loopCnt++; + } + } + + if(slaveEpoch != masterEpoch) + { + g_err << "Slave not in sync with master!" << endl; + return NDBT_FAILED; + } + return NDBT_OK; +} + +int +verifySlaveLoad(BaseString *table) +{ + //First thing to do is sync slave + if(syncSlaveWithMaster()) + { + g_err << "Verify Load -> Syncing with slave failed" << endl; + return NDBT_FAILED; + } + + //Now that slave is sync we can verify load + sqlStm.assfmt("SELECT COUNT(*) FROM %s", table); + MYSQL_RES * result; + MYSQL_ROW row; + unsigned int masterCount = 0; + unsigned int slaveCount = 0; + + //Create a DB Object for the master + DbUtil master(db.c_str()," "); + + //Login to Master + if (!master.connect()) + { + return NDBT_FAILED; + } + + if (master.selectDb()) + { + return NDBT_FAILED; + } + + if(master.doQuery(sqlStm.c_str())) + { + return NDBT_FAILED; + } + result = mysql_use_result(master.getMysql()); + row = mysql_fetch_row(result); + masterCount = atoi(row[0]); + mysql_free_result(result); + master.databaseLogout(); + + //Create a DB Object for slave + DbUtil slave(db.c_str(),".slave"); + + //Login to slave + if (!slave.connect()) + { + return NDBT_FAILED; + } + + if (slave.selectDb()) + { + return NDBT_FAILED; + } + + if(slave.doQuery(sqlStm.c_str())) + { + return NDBT_FAILED; + } + result = mysql_use_result(slave.getMysql()); + row = mysql_fetch_row(result); + slaveCount = atoi(row[0]); + mysql_free_result(result); + + if(slaveCount != masterCount) + { + g_err << "Verify Load -> Slave Count != Master Count " + << endl; + return NDBT_FAILED; + } + return NDBT_OK; +} + +/**** Test Section ****/ + +int +createDB(NDBT_Context* ctx, NDBT_Step* step) +{ + //Setup the BaseString db to use throughout + db.assign("TEST_DB"); + + //Create a dbutil object + DbUtil master("mysql",""); + + //Login to Master + if (!master.connect()) + { + return NDBT_FAILED; + } + + //Check to see if db already there + if (master.selectDb(db.c_str())) + { + return NDBT_FAILED; + } + + //Create TEST_DB + if (master.doQuery("CREATE DATABASE TEST_DB") != 0) + { + return NDBT_FAILED; + } + return NDBT_OK; +} + +int +createTable_rep1(NDBT_Context* ctx, NDBT_Step* step) +{ + BaseString table; + table.assign("rep1"); + + //Ensure slave is up and ready + if(syncSlaveWithMaster() != 0) + { + g_err << "Create Table -> Syncing with slave failed" + << endl; + return NDBT_FAILED; + } + + //Create an SQL Object + DbUtil master(db.c_str(),""); + + //Login to Master + if (!master.connect()) + { + return NDBT_FAILED; + } + + // Set the database we want + if(master.selectDb()) + { + return NDBT_FAILED; + } + + sqlStm.assign("CREATE TABLE rep1 (c1 MEDIUMINT NOT NULL AUTO_INCREMENT," + " c2 FLOAT, c3 CHAR(5), c4 bit(8), c5 FLOAT, c6 INT," + " c7 INT, PRIMARY KEY (c1))ENGINE=NDB"); + + if (master.doQuery(sqlStm.c_str())) + { + return NDBT_FAILED; + } + ctx->setProperty("TABLES",table.c_str()); + HugoTransactions hugoTrans(*ctx->getTab()); + + if (hugoTrans.loadTable(GETNDB(step), t1_records, 1, true, 0) != 0) + { + g_err << "Create Table -> Load failed!" << endl; + return NDBT_FAILED; + } + + if(verifySlaveLoad(&table)!= 0) + { + g_err << "Create Table -> Failed on verify slave load!" + << endl; + return NDBT_FAILED; + } + //else everything is okay + return NDBT_OK; +} + +int +stressNDB_rep1(NDBT_Context* ctx, NDBT_Step* step) +{ + const NdbDictionary::Table * table= ctx->getTab(); + HugoTransactions hugoTrans(* table); + while(!ctx->isTestStopped()) + { + if (hugoTrans.pkUpdateRecords(GETNDB(step), t1_records, 1, 30) != 0) + { + g_err << "pkUpdate Failed!" << endl; + return NDBT_FAILED; + } + if (hugoTrans.scanUpdateRecords(GETNDB(step), t1_records, 1, 30) != 0) + { + g_err << "scanUpdate Failed!" << endl; + return NDBT_FAILED; + } + } + return NDBT_OK; +} + +int +stressSQL_rep1(NDBT_Context* ctx, NDBT_Step* step) +{ + //Create an SQL Object + DbUtil master(db.c_str(),""); + int loops = ctx->getNumLoops(); + uint record = 0; + + //Login to Master + if (!master.connect()) + { + return NDBT_FAILED; + } + + if(master.selectDb()) + { + ctx->stopTest(); + return NDBT_FAILED; + } + + for (int j= 0; loops == 0 || j < loops; j++) + { + record = urandom(t1_records); + sqlStm.assfmt("UPDATE TEST_DB.rep1 SET c2 = 33.3221 where c1 = %u", record); + if(master.doQuery(sqlStm.c_str())) + { + return NDBT_FAILED; + } + } + ctx->stopTest(); + return NDBT_OK; +} + +int +verifySlave_rep1(NDBT_Context* ctx, NDBT_Step* step) +{ + if(syncSlaveWithMaster() != 0) + { + g_err << "Verify Slave rep1 -> Syncing with slave failed" + << endl; + return NDBT_FAILED; + } + //Create SQL Objects + DbUtil master(db.c_str(),""); + DbUtil slave(db.c_str(),".slave"); + MYSQL_RES *resource; + MYSQL_ROW row; + float masterSum; + float slaveSum; + + sqlStm.assign("SELECT SUM(c3) FROM rep1"); + + //Login to Master + if (!master.connect()) + { + return NDBT_FAILED; + } + + if(master.selectDb()) + { + return NDBT_FAILED; + } + + if(master.doQuery(sqlStm.c_str())) + { + return NDBT_FAILED; + } + resource = mysql_use_result(master.getMysql()); + row = mysql_fetch_row(resource); + masterSum = atoi(row[0]); + mysql_free_result(resource); + master.databaseLogout(); + + //Login to slave + if (!slave.connect()) + { + return NDBT_FAILED; + } + + if(slave.selectDb() != 0) + { + return NDBT_FAILED; + } + + if((slave.doQuery(sqlStm.c_str())) != 0) + { + return NDBT_FAILED; + } + resource = mysql_use_result(slave.getMysql()); + row = mysql_fetch_row(resource); + slaveSum = atoi(row[0]); + mysql_free_result(resource); + + if(masterSum != slaveSum) + { + g_err << "VerifySlave -> masterSum != slaveSum..." << endl; + return NDBT_FAILED; + } + return NDBT_OK; +} + +int +dropTEST_DB(NDBT_Context* ctx, NDBT_Step* step) +{ + //Create an SQL Object + DbUtil master(db.c_str(),""); + + //Login to Master + if (!master.connect()) + { + return NDBT_FAILED; + } + + if(master.selectDb() != 0) + { + return NDBT_FAILED; + } + + if(master.doQuery("DROP DATABASE TEST_DB") != 0) + { + return NDBT_FAILED; + } + + if(syncSlaveWithMaster() != 0) + { + g_err << "Drop DB -> Syncing with slave failed" + << endl; + return NDBT_FAILED; + } + return NDBT_OK; +} + +NDBT_TESTSUITE(NdbRepStress); +TESTCASE("PHASE_I_Stress","Basic Replication Stressing") +{ + INITIALIZER(createDB); + INITIALIZER(createTable_rep1); + STEP(stressNDB_rep1); + STEP(stressSQL_rep1); + FINALIZER(verifySlave_rep1); + FINALIZER(dropTEST_DB); +} +NDBT_TESTSUITE_END(NdbRepStress); + +int main(int argc, const char** argv){ + ndb_init(); + NdbRepStress.setCreateAllTables(true); + return NdbRepStress.execute(argc, argv); +} + +template class Vector; +template class Vector; +template class Vector; +template class Vector >; diff --git a/storage/ndb/test/src/DbUtil.cpp b/storage/ndb/test/src/DbUtil.cpp index 0611fb2ad4a..f6c2aee4df5 100755 --- a/storage/ndb/test/src/DbUtil.cpp +++ b/storage/ndb/test/src/DbUtil.cpp @@ -215,23 +215,57 @@ DbUtil::printStError(MYSQL_STMT *stmt, const char *msg) /* Select which database to use */ int -DbUtil::select_DB() +DbUtil::selectDb() { - return mysql_select_db(this->getMysql(), this->getDbName()); + if ((this->getDbName()) != NULL) + { + if(mysql_select_db(this->getMysql(), this->getDbName())) + { + this->printError("mysql_select_db failed"); + return DBU_FAILED; + } + return DBU_OK; + } + this->printError("getDbName() == NULL"); + return DBU_FAILED; } +int +DbUtil::selectDb(const char * m_db) +{ + { + if(mysql_select_db(this->getMysql(), m_db)) + { + this->printError("mysql_select_db failed"); + return DBU_FAILED; + } + return DBU_OK; + } +} + + /* Run Simple Queries */ int DbUtil::doQuery(char * stm) { - return mysql_query(this->getMysql(), stm); + if(mysql_query(this->getMysql(), stm)) + { + this->printError(stm); + return DBU_FAILED; + } + return DBU_OK; } int DbUtil::doQuery(const char * stm) { - return mysql_query(this->getMysql(), stm); + if(mysql_query(this->getMysql(), stm)) + { + this->printError(stm); + return DBU_FAILED; + } + return DBU_OK; } /* Return MySQL Error String */ From 9b14ac8d0199e0f53fa857e85af78a7b1d715e36 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 9 Jan 2008 14:51:08 +0800 Subject: [PATCH 18/32] Fix for view.test. the result should be added by 1 by the year(now()) function. mysql-test/r/view.result: SELECT (year(now())-year(DOB)) AS Age FROM t1 HAVING Age < 75; the above statement in test file has a year(now()) function, the result should increase by 1 from 2007 year to 2008 year. --- mysql-test/r/view.result | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 8d9d802949d..1a1a5f68c6c 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -2698,12 +2698,12 @@ View Create View v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select (year(now()) - year(`t1`.`DOB`)) AS `Age` from `t1` having (`Age` < 75) SELECT (year(now())-year(DOB)) AS Age FROM t1 HAVING Age < 75; Age -43 -39 +44 +40 SELECT * FROM v1; Age -43 -39 +44 +40 DROP VIEW v1; DROP TABLE t1; CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, a char(6) DEFAULT 'xxx'); From 5e85c850accc9d9152032424c61018553324575c Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 9 Jan 2008 18:54:32 +0100 Subject: [PATCH 19/32] DbUtil.hpp, DbUtil.cpp, NdbRepStress.cpp: More code improvments storage/ndb/test/include/DbUtil.hpp: More code improvments storage/ndb/test/src/DbUtil.cpp: More code improvments storage/ndb/test/ndbapi/acrt/NdbRepStress.cpp: More code improvments --- storage/ndb/test/include/DbUtil.hpp | 7 +- storage/ndb/test/ndbapi/acrt/NdbRepStress.cpp | 309 +++++++++--------- storage/ndb/test/src/DbUtil.cpp | 26 +- 3 files changed, 177 insertions(+), 165 deletions(-) diff --git a/storage/ndb/test/include/DbUtil.hpp b/storage/ndb/test/include/DbUtil.hpp index 62aaaf7b5a3..5ca5fca290c 100755 --- a/storage/ndb/test/include/DbUtil.hpp +++ b/storage/ndb/test/include/DbUtil.hpp @@ -90,9 +90,10 @@ public: int connect(); int selectDb(); - int selectDb(const char * m_db); - int doQuery(char * stm); - int doQuery(const char * stm); + int selectDb(const char *); + int createDb(BaseString&); + int doQuery(BaseString&); + int doQuery(const char *); int getErrorNumber(); unsigned long selectCountTable(const char * table); diff --git a/storage/ndb/test/ndbapi/acrt/NdbRepStress.cpp b/storage/ndb/test/ndbapi/acrt/NdbRepStress.cpp index 7d9b66d8e72..c3f3649fba1 100644 --- a/storage/ndb/test/ndbapi/acrt/NdbRepStress.cpp +++ b/storage/ndb/test/ndbapi/acrt/NdbRepStress.cpp @@ -17,16 +17,15 @@ #include #include #include -#include #include -#include +#include + +/* +Will include restart testing in future phases #include #include -#include -#include +*/ -static BaseString sqlStm; -static BaseString db; static int t1_records = 50000; /**** TOOL SECTION ****/ @@ -42,7 +41,7 @@ static uint urandom(uint m) { if (m == 0) - return 0; + return NDBT_OK; uint r = urandom(); r = r % m; return r; @@ -78,12 +77,6 @@ syncSlaveWithMaster() return NDBT_FAILED; } - //Set the database we are wanting - if (master.selectDb()) - { - return NDBT_FAILED; - } - //Get max epoch from master if(master.doQuery("SELECT MAX(epoch) FROM mysql.ndb_binlog_index")) { @@ -93,7 +86,6 @@ syncSlaveWithMaster() row = mysql_fetch_row(result); masterEpoch = atoi(row[0]); mysql_free_result(result); - master.databaseLogout(); /* Now we will pull current epoch from slave. If not the @@ -111,12 +103,6 @@ syncSlaveWithMaster() return NDBT_FAILED; } - //Set the database we are wanting - if (slave.selectDb()) - { - return NDBT_FAILED; - } - while(slaveEpoch != masterEpoch && loopCnt < maxLoops) { if(slave.doQuery("SELECT epoch FROM mysql.ndb_apply_status")) @@ -153,6 +139,16 @@ syncSlaveWithMaster() int verifySlaveLoad(BaseString *table) { + BaseString sqlStm; + BaseString db; + MYSQL_RES * result; + MYSQL_ROW row; + unsigned int masterCount = 0; + unsigned int slaveCount = 0; + + db.assign("TEST_DB"); + sqlStm.assfmt("SELECT COUNT(*) FROM %s", table); + //First thing to do is sync slave if(syncSlaveWithMaster()) { @@ -161,13 +157,6 @@ verifySlaveLoad(BaseString *table) } //Now that slave is sync we can verify load - sqlStm.assfmt("SELECT COUNT(*) FROM %s", table); - MYSQL_RES * result; - MYSQL_ROW row; - unsigned int masterCount = 0; - unsigned int slaveCount = 0; - - //Create a DB Object for the master DbUtil master(db.c_str()," "); //Login to Master @@ -176,11 +165,6 @@ verifySlaveLoad(BaseString *table) return NDBT_FAILED; } - if (master.selectDb()) - { - return NDBT_FAILED; - } - if(master.doQuery(sqlStm.c_str())) { return NDBT_FAILED; @@ -189,7 +173,6 @@ verifySlaveLoad(BaseString *table) row = mysql_fetch_row(result); masterCount = atoi(row[0]); mysql_free_result(result); - master.databaseLogout(); //Create a DB Object for slave DbUtil slave(db.c_str(),".slave"); @@ -200,11 +183,6 @@ verifySlaveLoad(BaseString *table) return NDBT_FAILED; } - if (slave.selectDb()) - { - return NDBT_FAILED; - } - if(slave.doQuery(sqlStm.c_str())) { return NDBT_FAILED; @@ -223,45 +201,141 @@ verifySlaveLoad(BaseString *table) return NDBT_OK; } -/**** Test Section ****/ - -int -createDB(NDBT_Context* ctx, NDBT_Step* step) +int +createTEST_DB(NDBT_Context* ctx, NDBT_Step* step) { - //Setup the BaseString db to use throughout - db.assign("TEST_DB"); + BaseString cdb; + cdb.assign("TEST_DB"); //Create a dbutil object DbUtil master("mysql",""); + if (master.connect()) + { + if (master.createDb(cdb) == NDBT_OK) + { + return NDBT_OK; + } + } + return NDBT_FAILED; +} + +int +dropTEST_DB(NDBT_Context* ctx, NDBT_Step* step) +{ + //Create an SQL Object + DbUtil master("mysql",""); + //Login to Master if (!master.connect()) { return NDBT_FAILED; } - //Check to see if db already there - if (master.selectDb(db.c_str())) + if(master.doQuery("DROP DATABASE TEST_DB") != NDBT_OK) { return NDBT_FAILED; } - //Create TEST_DB - if (master.doQuery("CREATE DATABASE TEST_DB") != 0) + if(syncSlaveWithMaster() != NDBT_OK) { + g_err << "Drop DB -> Syncing with slave failed" + << endl; return NDBT_FAILED; } return NDBT_OK; } +int +verifySlave(BaseString& sqlStm, BaseString& db) +{ + MYSQL_RES* resource; + MYSQL_ROW row; + float masterSum; + float slaveSum; + + //Create SQL Objects + DbUtil master(db.c_str(),""); + DbUtil slave(db.c_str(),".slave"); + + if(syncSlaveWithMaster() != NDBT_OK) + { + g_err << "Verify Slave rep1 -> Syncing with slave failed" + << endl; + return NDBT_FAILED; + } + + //Login to Master + if (!master.connect()) + { + return NDBT_FAILED; + } + + if(master.doQuery(sqlStm.c_str()) != NDBT_OK) + { + return NDBT_FAILED; + } + resource = mysql_use_result(master.getMysql()); + row = mysql_fetch_row(resource); + masterSum = atoi(row[0]); + mysql_free_result(resource); + + //Login to slave + if (!slave.connect()) + { + return NDBT_FAILED; + } + + if(slave.doQuery(sqlStm.c_str()) != NDBT_OK) + { + return NDBT_FAILED; + } + resource = mysql_use_result(slave.getMysql()); + row = mysql_fetch_row(resource); + slaveSum = atoi(row[0]); + mysql_free_result(resource); + + if(masterSum != slaveSum) + { + g_err << "VerifySlave -> masterSum != slaveSum..." << endl; + return NDBT_FAILED; + } + return NDBT_OK; +} + + +/**** Test Section ****/ + +int +createDB(NDBT_Context* ctx, NDBT_Step* step) +{ + BaseString cdb; + cdb.assign("TEST_DB"); + + //Create a dbutil object + DbUtil master("mysql",""); + + if (master.connect()) + { + if (master.createDb(cdb) == NDBT_OK) + { + return NDBT_OK; + } + } + return NDBT_FAILED; +} + int createTable_rep1(NDBT_Context* ctx, NDBT_Step* step) { BaseString table; + BaseString db; + table.assign("rep1"); + db.assign("TEST_DB"); //Ensure slave is up and ready - if(syncSlaveWithMaster() != 0) + if(syncSlaveWithMaster() != NDBT_OK) { g_err << "Create Table -> Syncing with slave failed" << endl; @@ -277,30 +351,22 @@ createTable_rep1(NDBT_Context* ctx, NDBT_Step* step) return NDBT_FAILED; } - // Set the database we want - if(master.selectDb()) - { - return NDBT_FAILED; - } - - sqlStm.assign("CREATE TABLE rep1 (c1 MEDIUMINT NOT NULL AUTO_INCREMENT," - " c2 FLOAT, c3 CHAR(5), c4 bit(8), c5 FLOAT, c6 INT," - " c7 INT, PRIMARY KEY (c1))ENGINE=NDB"); - - if (master.doQuery(sqlStm.c_str())) + if (master.doQuery("CREATE TABLE rep1 (c1 MEDIUMINT NOT NULL AUTO_INCREMENT," + " c2 FLOAT, c3 CHAR(5), c4 bit(8), c5 FLOAT, c6 INT," + " c7 INT, PRIMARY KEY (c1))ENGINE=NDB")) { return NDBT_FAILED; } ctx->setProperty("TABLES",table.c_str()); HugoTransactions hugoTrans(*ctx->getTab()); - if (hugoTrans.loadTable(GETNDB(step), t1_records, 1, true, 0) != 0) + if (hugoTrans.loadTable(GETNDB(step), t1_records, 1, true, 0) != NDBT_OK) { g_err << "Create Table -> Load failed!" << endl; return NDBT_FAILED; } - if(verifySlaveLoad(&table)!= 0) + if(verifySlaveLoad(&table)!= NDBT_OK) { g_err << "Create Table -> Failed on verify slave load!" << endl; @@ -334,18 +400,14 @@ stressNDB_rep1(NDBT_Context* ctx, NDBT_Step* step) int stressSQL_rep1(NDBT_Context* ctx, NDBT_Step* step) { - //Create an SQL Object - DbUtil master(db.c_str(),""); + BaseString sqlStm; + + DbUtil master("TEST_DB",""); int loops = ctx->getNumLoops(); uint record = 0; //Login to Master if (!master.connect()) - { - return NDBT_FAILED; - } - - if(master.selectDb()) { ctx->stopTest(); return NDBT_FAILED; @@ -367,101 +429,36 @@ stressSQL_rep1(NDBT_Context* ctx, NDBT_Step* step) int verifySlave_rep1(NDBT_Context* ctx, NDBT_Step* step) { - if(syncSlaveWithMaster() != 0) - { - g_err << "Verify Slave rep1 -> Syncing with slave failed" - << endl; - return NDBT_FAILED; - } - //Create SQL Objects - DbUtil master(db.c_str(),""); - DbUtil slave(db.c_str(),".slave"); - MYSQL_RES *resource; - MYSQL_ROW row; - float masterSum; - float slaveSum; + BaseString sql; + BaseString db; - sqlStm.assign("SELECT SUM(c3) FROM rep1"); + sql.assign("SELECT SUM(c3) FROM rep1"); + db.assign("TEST_DB"); - //Login to Master - if (!master.connect()) - { + if (verifySlave(sql,db) != NDBT_OK) return NDBT_FAILED; - } - - if(master.selectDb()) - { - return NDBT_FAILED; - } - - if(master.doQuery(sqlStm.c_str())) - { - return NDBT_FAILED; - } - resource = mysql_use_result(master.getMysql()); - row = mysql_fetch_row(resource); - masterSum = atoi(row[0]); - mysql_free_result(resource); - master.databaseLogout(); - - //Login to slave - if (!slave.connect()) - { - return NDBT_FAILED; - } - - if(slave.selectDb() != 0) - { - return NDBT_FAILED; - } - - if((slave.doQuery(sqlStm.c_str())) != 0) - { - return NDBT_FAILED; - } - resource = mysql_use_result(slave.getMysql()); - row = mysql_fetch_row(resource); - slaveSum = atoi(row[0]); - mysql_free_result(resource); - - if(masterSum != slaveSum) - { - g_err << "VerifySlave -> masterSum != slaveSum..." << endl; - return NDBT_FAILED; - } return NDBT_OK; } -int -dropTEST_DB(NDBT_Context* ctx, NDBT_Step* step) -{ - //Create an SQL Object - DbUtil master(db.c_str(),""); +/* TOOLS LIST - //Login to Master - if (!master.connect()) - { - return NDBT_FAILED; - } + syncSlaveWithMaster() + {ensures slave is at same epoch as master} - if(master.selectDb() != 0) - { - return NDBT_FAILED; - } + verifySlaveLoad(BaseString *table) + {ensures slave table has same record count as master} - if(master.doQuery("DROP DATABASE TEST_DB") != 0) - { - return NDBT_FAILED; - } + createTEST_DB() + {Creates TEST_DB database on master} - if(syncSlaveWithMaster() != 0) - { - g_err << "Drop DB -> Syncing with slave failed" - << endl; - return NDBT_FAILED; - } - return NDBT_OK; -} + dropTEST_DB() + {Drops TEST_DB database on master} + + verifySlave(BaseString& sql, BaseSting& db) + {The SQL statement must sum a column and will verify + that the sum of the column is equal on master & slave} +*/ + NDBT_TESTSUITE(NdbRepStress); TESTCASE("PHASE_I_Stress","Basic Replication Stressing") @@ -481,7 +478,3 @@ int main(int argc, const char** argv){ return NdbRepStress.execute(argc, argv); } -template class Vector; -template class Vector; -template class Vector; -template class Vector >; diff --git a/storage/ndb/test/src/DbUtil.cpp b/storage/ndb/test/src/DbUtil.cpp index f6c2aee4df5..1df4f8f745e 100755 --- a/storage/ndb/test/src/DbUtil.cpp +++ b/storage/ndb/test/src/DbUtil.cpp @@ -99,6 +99,7 @@ DbUtil::databaseLogin(const char* system, const char* usr, mysql_get_server_info(mysql), (unsigned long) mysql_get_server_version(mysql)); #endif + this->selectDb(); } /* Database Connect */ @@ -132,7 +133,7 @@ DbUtil::connect() mysql_close(mysql); return DBU_FAILED; } - + this->selectDb(); m_connected = true; return DBU_OK; } @@ -243,15 +244,32 @@ DbUtil::selectDb(const char * m_db) } } +int +DbUtil::createDb(BaseString& m_db) +{ + BaseString stm; + { + if(mysql_select_db(this->getMysql(), m_db.c_str()) == DBU_OK) + { + stm.assfmt("DROP DATABASE %s", m_db.c_str()); + if(this->doQuery(m_db.c_str()) == DBU_FAILED) + return DBU_FAILED; + } + stm.assfmt("CREATE DATABASE %s", m_db.c_str()); + if(this->doQuery(m_db.c_str()) == DBU_FAILED) + return DBU_FAILED; + return DBU_OK; + } +} /* Run Simple Queries */ int -DbUtil::doQuery(char * stm) +DbUtil::doQuery(BaseString& str) { - if(mysql_query(this->getMysql(), stm)) + if(mysql_query(this->getMysql(), str.c_str())) { - this->printError(stm); + this->printError(str.c_str()); return DBU_FAILED; } return DBU_OK; From 44ccc30b030863dde6a65ac380d5e5e85e32abf6 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 9 Jan 2008 19:01:31 +0100 Subject: [PATCH 20/32] NdbRepStress.cpp: More code improvments storage/ndb/test/ndbapi/acrt/NdbRepStress.cpp: More code improvments --- storage/ndb/test/ndbapi/acrt/NdbRepStress.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/storage/ndb/test/ndbapi/acrt/NdbRepStress.cpp b/storage/ndb/test/ndbapi/acrt/NdbRepStress.cpp index c3f3649fba1..775e7ec6288 100644 --- a/storage/ndb/test/ndbapi/acrt/NdbRepStress.cpp +++ b/storage/ndb/test/ndbapi/acrt/NdbRepStress.cpp @@ -26,8 +26,6 @@ Will include restart testing in future phases #include */ -static int t1_records = 50000; - /**** TOOL SECTION ****/ static uint @@ -360,7 +358,7 @@ createTable_rep1(NDBT_Context* ctx, NDBT_Step* step) ctx->setProperty("TABLES",table.c_str()); HugoTransactions hugoTrans(*ctx->getTab()); - if (hugoTrans.loadTable(GETNDB(step), t1_records, 1, true, 0) != NDBT_OK) + if (hugoTrans.loadTable(GETNDB(step), ctx->getNumRecords(), 1, true, 0) != NDBT_OK) { g_err << "Create Table -> Load failed!" << endl; return NDBT_FAILED; @@ -383,12 +381,12 @@ stressNDB_rep1(NDBT_Context* ctx, NDBT_Step* step) HugoTransactions hugoTrans(* table); while(!ctx->isTestStopped()) { - if (hugoTrans.pkUpdateRecords(GETNDB(step), t1_records, 1, 30) != 0) + if (hugoTrans.pkUpdateRecords(GETNDB(step), ctx->getNumRecords(), 1, 30) != 0) { g_err << "pkUpdate Failed!" << endl; return NDBT_FAILED; } - if (hugoTrans.scanUpdateRecords(GETNDB(step), t1_records, 1, 30) != 0) + if (hugoTrans.scanUpdateRecords(GETNDB(step), ctx->getNumRecords(), 1, 30) != 0) { g_err << "scanUpdate Failed!" << endl; return NDBT_FAILED; @@ -415,7 +413,7 @@ stressSQL_rep1(NDBT_Context* ctx, NDBT_Step* step) for (int j= 0; loops == 0 || j < loops; j++) { - record = urandom(t1_records); + record = urandom(ctx->getNumRecords()); sqlStm.assfmt("UPDATE TEST_DB.rep1 SET c2 = 33.3221 where c1 = %u", record); if(master.doQuery(sqlStm.c_str())) { From b048153128e3fff4a8cb280be75c14c913b13acf Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 10 Jan 2008 17:39:50 +0800 Subject: [PATCH 21/32] Shouldn't let the non-deterministic temperary filename output in result file for bug#30417 mysql-test/suite/ndb/r/ndb_autoinc.result: Temperory table name shouldn't output in result file for its name is non-deterministic mysql-test/suite/ndb/t/ndb_autoinc.test: don't output temperary file name --- mysql-test/suite/ndb/r/ndb_autoinc.result | 1 - mysql-test/suite/ndb/t/ndb_autoinc.test | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/ndb/r/ndb_autoinc.result b/mysql-test/suite/ndb/r/ndb_autoinc.result index 7ba5ab8def7..fe9d36393ad 100644 --- a/mysql-test/suite/ndb/r/ndb_autoinc.result +++ b/mysql-test/suite/ndb/r/ndb_autoinc.result @@ -18,7 +18,6 @@ KEY(id) ) ENGINE=MYISAM; ALTER TABLE t3 ENGINE NDBCLUSTER; -ERROR HY000: Can't create table 'test.#sql-7b9e_3' (errno: 4335) SHOW CREATE TABLE t3; Table Create Table t3 CREATE TABLE `t3` ( diff --git a/mysql-test/suite/ndb/t/ndb_autoinc.test b/mysql-test/suite/ndb/t/ndb_autoinc.test index 3e7ba7bdf6a..a5ae52c88d7 100644 --- a/mysql-test/suite/ndb/t/ndb_autoinc.test +++ b/mysql-test/suite/ndb/t/ndb_autoinc.test @@ -27,9 +27,11 @@ CREATE TABLE t3 ( KEY(id) ) ENGINE=MYISAM; +--disable_result_log --error 1005 ALTER TABLE t3 ENGINE NDBCLUSTER; +--enable_result_log SHOW CREATE TABLE t3; From 2f2206840d4f16ec2c30d288c498898d09f11a69 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 10 Jan 2008 18:59:44 +0100 Subject: [PATCH 22/32] Makefile.am: Updated for name chance on dbutil storage/ndb/test/src/Makefile.am: Updated for name chance on dbutil --- storage/ndb/test/src/Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/storage/ndb/test/src/Makefile.am b/storage/ndb/test/src/Makefile.am index aa486108235..8cbe83dfbcf 100644 --- a/storage/ndb/test/src/Makefile.am +++ b/storage/ndb/test/src/Makefile.am @@ -24,9 +24,9 @@ libNDBT_a_SOURCES = \ NdbRestarter.cpp NdbRestarts.cpp NDBT_Output.cpp \ NdbBackup.cpp NdbConfig.cpp NdbGrep.cpp NDBT_Table.cpp \ NdbSchemaCon.cpp NdbSchemaOp.cpp getarg.c \ - CpcClient.cpp NdbMixRestarter.cpp NDBT_Thread.cpp dbutil.cpp + CpcClient.cpp NdbMixRestarter.cpp NDBT_Thread.cpp DbUtil.cpp -INCLUDES_LOC = -I$(top_srcdir)/storage/ndb/src/common/mgmcommon -I$(top_srcdir)/storage/ndb/include/mgmcommon -I$(top_srcdir)/storage/ndb/include/kernel -I$(top_srcdir)/storage/ndb/src/mgmapi +INCLUDES_LOC = -I$(top_srcdir)/storage/ndb/src/common/mgmcommon -I$(top_srcdir)/storage/ndb/include/mgmcommon -I$(top_srcdir)/storage/ndb/include/kernel -I$(top_srcdir)/storage/ndb/src/mgmapi -I$(top_srcdir)/include include $(top_srcdir)/storage/ndb/config/common.mk.am include $(top_srcdir)/storage/ndb/config/type_ndbapitest.mk.am From ed6d97c8666decf7d3a472d9736fb4360756e03e Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 10 Jan 2008 19:07:24 +0100 Subject: [PATCH 23/32] Makefile.am: Updated to build NdbRepStress storage/ndb/test/ndbapi/Makefile.am: Updated to build NdbRepStress --- storage/ndb/test/ndbapi/Makefile.am | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/storage/ndb/test/ndbapi/Makefile.am b/storage/ndb/test/ndbapi/Makefile.am index ad509dbbafe..9f83b061403 100644 --- a/storage/ndb/test/ndbapi/Makefile.am +++ b/storage/ndb/test/ndbapi/Makefile.am @@ -52,7 +52,8 @@ testBitfield \ DbCreate DbAsyncGenerator \ testSRBank \ test_event_merge \ -testIndexStat +testIndexStat \ +NdbRepStress EXTRA_PROGRAMS = \ test_event \ @@ -99,6 +100,7 @@ testReadPerf_SOURCES = testReadPerf.cpp testLcp_SOURCES = testLcp.cpp testPartitioning_SOURCES = testPartitioning.cpp testBitfield_SOURCES = testBitfield.cpp +NdbRepStress_SOURCES = acrt/NdbRepStress.cpp DbCreate_SOURCES = bench/mainPopulate.cpp bench/dbPopulate.cpp bench/userInterface.cpp bench/dbPopulate.h bench/userInterface.h bench/testData.h bench/testDefinitions.h bench/ndb_schema.hpp bench/ndb_error.hpp DbAsyncGenerator_SOURCES = bench/mainAsyncGenerator.cpp bench/asyncGenerator.cpp bench/ndb_async2.cpp bench/dbGenerator.h bench/macros.h bench/userInterface.h bench/testData.h bench/testDefinitions.h bench/ndb_schema.hpp bench/ndb_error.hpp testSRBank_SOURCES = testSRBank.cpp @@ -115,8 +117,10 @@ include $(top_srcdir)/storage/ndb/config/type_ndbapitest.mk.am ##testIndex_INCLUDES = $(INCLUDES) -I$(top_srcdir)/ndb/include/kernel ##testSystemRestart_INCLUDES = $(INCLUDES) -I$(top_srcdir)/ndb/include/kernel ##testTransactions_INCLUDES = $(INCLUDES) -I$(top_srcdir)/ndb/include/kernel +NdbRepStress_INCLUDES = $(INCLUDES) -I$(top_srcdir)/ndb/test/include -I$(top_srcdir)/include testBackup_LDADD = $(LDADD) bank/libbank.a testSRBank_LDADD = bank/libbank.a $(LDADD) +NdbRepStress_LDADD = $(LDADD) $(top_builddir)/libmysql_r/libmysqlclient_r.la # Don't update the files from bitkeeper %::SCCS/s.% From e984956385c6ee6370da97655bc217070558fbb1 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 11 Jan 2008 09:20:16 +0100 Subject: [PATCH 24/32] ndb - bug#33793 dont assume that page is "all empty" only as gci is acked, as release_gci might not have processed it yet storage/ndb/src/kernel/blocks/ERROR_codes.txt: new error codes storage/ndb/src/kernel/blocks/suma/Suma.cpp: dont assume that page is "all empty" only as gci is acked, as release_gci might not have processed it yet storage/ndb/test/ndbapi/test_event.cpp: testcase storage/ndb/test/run-test/daily-basic-tests.txt: testcase --- storage/ndb/src/kernel/blocks/ERROR_codes.txt | 2 +- storage/ndb/src/kernel/blocks/suma/Suma.cpp | 16 ++++- storage/ndb/test/ndbapi/test_event.cpp | 61 +++++++++++++++++++ .../ndb/test/run-test/daily-basic-tests.txt | 4 ++ 4 files changed, 81 insertions(+), 2 deletions(-) diff --git a/storage/ndb/src/kernel/blocks/ERROR_codes.txt b/storage/ndb/src/kernel/blocks/ERROR_codes.txt index b58eeb730f3..f80e25cc8d7 100644 --- a/storage/ndb/src/kernel/blocks/ERROR_codes.txt +++ b/storage/ndb/src/kernel/blocks/ERROR_codes.txt @@ -11,7 +11,7 @@ Next CMVMI 9000 Next BACKUP 10038 Next DBUTIL 11002 Next DBTUX 12008 -Next SUMA 13034 +Next SUMA 13036 TESTING NODE FAILURE, ARBITRATION --------------------------------- diff --git a/storage/ndb/src/kernel/blocks/suma/Suma.cpp b/storage/ndb/src/kernel/blocks/suma/Suma.cpp index 8e6c0cd7ee7..a85bcf3e8a3 100644 --- a/storage/ndb/src/kernel/blocks/suma/Suma.cpp +++ b/storage/ndb/src/kernel/blocks/suma/Suma.cpp @@ -4852,6 +4852,21 @@ Suma::release_gci(Signal* signal, Uint32 buck, Uint32 gci) if(gci >= head.m_max_gci) { jam(); + if (ERROR_INSERTED(13034)) + { + jam(); + SET_ERROR_INSERT_VALUE(13035); + return; + } + if (ERROR_INSERTED(13035)) + { + CLEAR_ERROR_INSERT_VALUE; + NodeReceiverGroup rg(CMVMI, c_nodes_in_nodegroup_mask); + rg.m_nodes.clear(getOwnNodeId()); + signal->theData[0] = 9999; + sendSignal(rg, GSN_NDB_TAMPER, signal, 1, JBA); + return; + } head.m_page_pos = 0; head.m_max_gci = gci; head.m_last_gci = 0; @@ -4923,7 +4938,6 @@ Suma::start_resend(Signal* signal, Uint32 buck) if(min > max) { - ndbrequire(pos.m_page_pos <= 2); ndbrequire(pos.m_page_id == bucket->m_buffer_tail); m_active_buckets.set(buck); m_gcp_complete_rep_count ++; diff --git a/storage/ndb/test/ndbapi/test_event.cpp b/storage/ndb/test/ndbapi/test_event.cpp index 18825d734a4..a7504166065 100644 --- a/storage/ndb/test/ndbapi/test_event.cpp +++ b/storage/ndb/test/ndbapi/test_event.cpp @@ -1838,6 +1838,61 @@ runBug31701(NDBT_Context* ctx, NDBT_Step* step) return NDBT_OK; } +int +runBug33793(NDBT_Context* ctx, NDBT_Step* step) +{ + int result = NDBT_OK; + int loops = ctx->getNumLoops(); + + NdbRestarter restarter; + + if (restarter.getNumDbNodes() < 2){ + ctx->stopTest(); + return NDBT_OK; + } + // This should really wait for applier to start...10s is likely enough + NdbSleep_SecSleep(10); + + while (loops-- && ctx->isTestStopped() == false) + { + int nodeId = restarter.getDbNodeId(rand() % restarter.getNumDbNodes()); + int nodecount = 0; + int nodes[255]; + printf("nodeid: %u : victims: ", nodeId); + for (int i = 0; istopTest(); + return NDBT_OK; +} + + + NDBT_TESTSUITE(test_event); TESTCASE("BasicEventOperation", "Verify that we can listen to Events" @@ -1975,6 +2030,12 @@ TESTCASE("Bug31701", ""){ FINALIZER(runDropEvent); FINALIZER(runDropShadowTable); } +TESTCASE("Bug33793", ""){ + INITIALIZER(runCreateEvent); + STEP(runEventListenerUntilStopped); + STEP(runBug33793); + FINALIZER(runDropEvent); +} NDBT_TESTSUITE_END(test_event); int main(int argc, const char** argv){ diff --git a/storage/ndb/test/run-test/daily-basic-tests.txt b/storage/ndb/test/run-test/daily-basic-tests.txt index ef5082ca30c..9943cd76ac1 100644 --- a/storage/ndb/test/run-test/daily-basic-tests.txt +++ b/storage/ndb/test/run-test/daily-basic-tests.txt @@ -942,3 +942,7 @@ max-time: 300 cmd: test_event args: -n Bug31701 T1 +max-time: 300 +cmd: test_event +args: -n Bug33793 T1 + From 29baec8ae30b315b82be25f10ad84647c973b044 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 17 Jan 2008 15:42:50 +0100 Subject: [PATCH 25/32] Remove "#pragma once" it's already done by "#ifndef DBUTIL_HPP" --- storage/ndb/test/include/DbUtil.hpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/storage/ndb/test/include/DbUtil.hpp b/storage/ndb/test/include/DbUtil.hpp index 5ca5fca290c..c143f0edd70 100755 --- a/storage/ndb/test/include/DbUtil.hpp +++ b/storage/ndb/test/include/DbUtil.hpp @@ -19,9 +19,6 @@ #ifndef DBUTIL_HPP #define DBUTIL_HPP -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 #include #include #include From 24e10360d42b54dd29ed1238a0cc1aa4cb0ffd87 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 17 Jan 2008 15:47:55 +0100 Subject: [PATCH 26/32] DBU_TRUE and DBU_FALSE => TRUE/FALSE --- storage/ndb/test/include/DbUtil.hpp | 2 -- storage/ndb/test/src/DbUtil.cpp | 6 +++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/storage/ndb/test/include/DbUtil.hpp b/storage/ndb/test/include/DbUtil.hpp index c143f0edd70..a1172205ff9 100755 --- a/storage/ndb/test/include/DbUtil.hpp +++ b/storage/ndb/test/include/DbUtil.hpp @@ -49,8 +49,6 @@ if (r) \ DIE_UNLESS(r == 0);\ } -#define DBU_TRUE 1 -#define DBU_FALSE 0 #define DBU_FAILED 1 #define DBU_OK 0 diff --git a/storage/ndb/test/src/DbUtil.cpp b/storage/ndb/test/src/DbUtil.cpp index 1df4f8f745e..5fe3e6e9fbe 100755 --- a/storage/ndb/test/src/DbUtil.cpp +++ b/storage/ndb/test/src/DbUtil.cpp @@ -86,13 +86,13 @@ DbUtil::databaseLogin(const char* system, const char* usr, exit(DBU_FAILED); } - mysql->reconnect = DBU_TRUE; + mysql->reconnect = TRUE; /* set AUTOCOMMIT */ if(!transactional) - mysql_autocommit(mysql, DBU_TRUE); + mysql_autocommit(mysql, TRUE); else - mysql_autocommit(mysql, DBU_FALSE); + mysql_autocommit(mysql, FALSE); #ifdef DEBUG printf("\n\tConnected to MySQL server version: %s (%lu)\n\n", From 4789e3f60669904a3032b59c6fb25f7ba6966bfe Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 18 Jan 2008 22:55:02 +0100 Subject: [PATCH 27/32] Add SqlResultSet storage/ndb/test/include/DbUtil.hpp: Add support for SqlResultSet storage/ndb/test/ndbapi/Makefile.am: Add testNDBT storage/ndb/test/src/DbUtil.cpp: Add support for SqlResultSet storage/ndb/test/src/Makefile.am: Build AtrtClient storage/ndb/test/include/AtrtClient.hpp: New BitKeeper file ``storage/ndb/test/include/AtrtClient.hpp'' storage/ndb/test/ndbapi/testNDBT.cpp: New BitKeeper file ``storage/ndb/test/ndbapi/testNDBT.cpp'' storage/ndb/test/src/AtrtClient.cpp: New BitKeeper file ``storage/ndb/test/src/AtrtClient.cpp'' --- storage/ndb/test/include/AtrtClient.hpp | 56 +++ storage/ndb/test/include/DbUtil.hpp | 92 +++- storage/ndb/test/ndbapi/Makefile.am | 3 + storage/ndb/test/ndbapi/testNDBT.cpp | 173 ++++++++ storage/ndb/test/src/AtrtClient.cpp | 215 ++++++++++ storage/ndb/test/src/DbUtil.cpp | 546 +++++++++++++++++++----- storage/ndb/test/src/Makefile.am | 2 +- 7 files changed, 962 insertions(+), 125 deletions(-) create mode 100644 storage/ndb/test/include/AtrtClient.hpp create mode 100644 storage/ndb/test/ndbapi/testNDBT.cpp create mode 100644 storage/ndb/test/src/AtrtClient.cpp diff --git a/storage/ndb/test/include/AtrtClient.hpp b/storage/ndb/test/include/AtrtClient.hpp new file mode 100644 index 00000000000..5728aca2500 --- /dev/null +++ b/storage/ndb/test/include/AtrtClient.hpp @@ -0,0 +1,56 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#ifndef ATRT_CLIENT_HPP +#define ATRT_CLIENT_HPP + +#include + +class AtrtClient: public DbUtil { +public: + + enum AtrtCommandType { + ATCT_CHANGE_VERSION= 1, + ATCT_RESET_PROC= 2 + }; + + AtrtClient(const char* _user= "root", + const char* _password= "", + const char* _suffix= ".1.atrt"); + AtrtClient(MYSQL*); + ~AtrtClient(); + + + // Command functions + bool changeVersion(int process_id, const char* process_args); + bool resetProc(int process_id); + + // Query functions + bool getConnectString(int cluster_id, SqlResultSet& result); + bool getClusters(SqlResultSet& result); + bool getMgmds(int cluster_id, SqlResultSet& result); + bool getNdbds(int cluster_id, SqlResultSet& result); + +private: + int writeCommand(AtrtCommandType _type, + const Properties& args); + bool readCommand(uint command_id, + SqlResultSet& result); + + bool doCommand(AtrtCommandType _type, + const Properties& args); +}; + +#endif diff --git a/storage/ndb/test/include/DbUtil.hpp b/storage/ndb/test/include/DbUtil.hpp index a1172205ff9..d865c92f9a3 100755 --- a/storage/ndb/test/include/DbUtil.hpp +++ b/storage/ndb/test/include/DbUtil.hpp @@ -19,14 +19,11 @@ #ifndef DBUTIL_HPP #define DBUTIL_HPP -#include -#include -#include +#include +#include +#include +#include #include -//include "rand.h" -#include -#include "BaseString.hpp" -#include "NDBT.hpp" //#define DEBUG #define DIE_UNLESS(expr) \ @@ -49,6 +46,41 @@ if (r) \ DIE_UNLESS(r == 0);\ } + +class SqlResultSet : public Properties { +public: + + // Get row with number + bool get_row(int row_num); + // Load next row + bool next(void); + // Reset iterator + void reset(void); + // Remove current row from resultset + void remove(); + + SqlResultSet(); + ~SqlResultSet(); + + const char* column(const char* col_name); + uint columnAsInt(const char* col_name); + + uint insertId(); + uint affectedRows(); + uint numRows(void); + uint mysqlErrno(); + const char* mysqlError(); + const char* mysqlSqlstate(); + +private: + uint get_int(const char* name); + const char* get_string(const char* name); + + const Properties* m_curr_row; + uint m_curr_row_num; +}; + + #define DBU_FAILED 1 #define DBU_OK 0 @@ -56,11 +88,23 @@ class DbUtil { public: - /* Deprecated, see DbUtil(dbname, suffix) */ - DbUtil(const char * databaseName); - DbUtil(const char* dbname, const char* suffix = NULL); + DbUtil(MYSQL* mysql); + DbUtil(const char* dbname = "mysql", + const char* user = "root", + const char* pass = "", + const char* suffix = NULL); ~DbUtil(); + bool doQuery(const char* query); + bool doQuery(const char* query, SqlResultSet& result); + bool doQuery(const char* query, const Properties& args, SqlResultSet& result); + + bool doQuery(BaseString& str); + bool doQuery(BaseString& str, SqlResultSet& result); + bool doQuery(BaseString& str, const Properties& args, SqlResultSet& result); + + bool waitConnected(int timeout); + /* Deprecated, see connect() */ void databaseLogin(const char * system, const char * usr, @@ -74,25 +118,35 @@ public: const char * getPassword(){return m_pass.c_str();}; const char * getHost() {return m_host.c_str();}; const char * getSocket() {return m_socket.c_str();}; - const char * getServerType(){return mysql_get_server_info(mysql);}; + const char * getServerType(){return mysql_get_server_info(m_mysql);}; const char * getError(); - MYSQL * getMysql(){return mysql;}; + MYSQL * getMysql(){return m_mysql;}; MYSQL_STMT * STDCALL mysqlSimplePrepare(const char *query); void databaseLogout(); void mysqlCloseStmHandle(MYSQL_STMT *my_stmt); int connect(); + void disconnect(); int selectDb(); int selectDb(const char *); int createDb(BaseString&); - int doQuery(BaseString&); - int doQuery(const char *); int getErrorNumber(); unsigned long selectCountTable(const char * table); +protected: + + bool runQuery(const char* query, + const Properties& args, + SqlResultSet& rows); + + bool isConnected(); + + MYSQL * m_mysql; + bool m_free_mysql; /* Don't free mysql* if allocated elsewhere */ + private: bool m_connected; @@ -102,15 +156,11 @@ private: BaseString m_pass; // MySQL User Password BaseString m_dbname; // Database to use BaseString m_socket; // MySQL Server Unix Socket - BaseString default_file; - BaseString default_group; + BaseString m_default_file; + BaseString m_default_group; unsigned int m_port; // MySQL Server port - MYSQL * mysql; - MYSQL_RES * m_result; - MYSQL_ROW m_row; - void setDbName(const char * name){m_dbname.assign(name);}; void setUser(const char * user_name){m_user.assign(user_name);}; void setPassword(const char * password){m_pass.assign(password);}; @@ -120,7 +170,7 @@ private: void printError(const char *msg); void printStError(MYSQL_STMT *stmt, const char *msg); void die(const char *file, int line, const char *expr); // stop program - + }; #endif diff --git a/storage/ndb/test/ndbapi/Makefile.am b/storage/ndb/test/ndbapi/Makefile.am index 9f83b061403..81bb346417f 100644 --- a/storage/ndb/test/ndbapi/Makefile.am +++ b/storage/ndb/test/ndbapi/Makefile.am @@ -53,6 +53,7 @@ DbCreate DbAsyncGenerator \ testSRBank \ test_event_merge \ testIndexStat \ +testNDBT \ NdbRepStress EXTRA_PROGRAMS = \ @@ -99,6 +100,8 @@ ndbapi_slow_select_SOURCES = slow_select.cpp testReadPerf_SOURCES = testReadPerf.cpp testLcp_SOURCES = testLcp.cpp testPartitioning_SOURCES = testPartitioning.cpp +testNDBT_SOURCES = testNDBT.cpp +testNDBT_LDADD = $(LDADD) $(top_srcdir)/libmysql_r/libmysqlclient_r.la testBitfield_SOURCES = testBitfield.cpp NdbRepStress_SOURCES = acrt/NdbRepStress.cpp DbCreate_SOURCES = bench/mainPopulate.cpp bench/dbPopulate.cpp bench/userInterface.cpp bench/dbPopulate.h bench/userInterface.h bench/testData.h bench/testDefinitions.h bench/ndb_schema.hpp bench/ndb_error.hpp diff --git a/storage/ndb/test/ndbapi/testNDBT.cpp b/storage/ndb/test/ndbapi/testNDBT.cpp new file mode 100644 index 00000000000..9c911b9a9d9 --- /dev/null +++ b/storage/ndb/test/ndbapi/testNDBT.cpp @@ -0,0 +1,173 @@ +/* Copyright (C) 2003 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#include +#include +#include +#include + + +int runTestAtrtClient(NDBT_Context* ctx, NDBT_Step* step){ + AtrtClient atrt; + + SqlResultSet clusters; + if (!atrt.getClusters(clusters)) + return NDBT_FAILED; + + int i= 0; + while(clusters.next()) + { + ndbout << clusters.column("name") << endl; + if (i++ == 1){ + ndbout << "removing: " << clusters.column("name") << endl; + clusters.remove(); + } + } + + clusters.reset(); + while(clusters.next()) + { + ndbout << clusters.column("name") << endl; + } + + return NDBT_OK; +} + + +int runTestDbUtil(NDBT_Context* ctx, NDBT_Step* step){ + DbUtil sql; + + { + // Select all rows from mysql.user + SqlResultSet result; + if (!sql.doQuery("SELECT * FROM mysql.user", result)) + return NDBT_FAILED; + // result.print(); + + while(result.next()) + { + ndbout << result.column("host") << ", " + << result.column("uSer") << ", " + << result.columnAsInt("max_updates") << ", " + << endl; + } + + result.reset(); + while(result.next()) + { + ndbout << result.column("host") << endl; + } + } + + { + // No column name, query should fail + Properties args; + SqlResultSet result; + if (sql.doQuery("SELECT * FROM mysql.user WHERE name=?", args, result)) + return NDBT_FAILED; + result.print(); + } + + { + // Select nonexisiting rows from mysql.user + Properties args; + SqlResultSet result; + args.put("0", "no_such_host"); + if (!sql.doQuery("SELECT * FROM mysql.user WHERE host=?", args, result)) + return NDBT_FAILED; + ndbout << "no rows" << endl; + result.print(); + + // Change args to an find one row + args.clear(); + args.put("0", "localhost"); + if (!sql.doQuery("SELECT host, user FROM mysql.user WHERE host=?", + args, result)) + return NDBT_FAILED; + result.print(); + } + + { + if (!sql.doQuery("CREATE TABLE sql_client_test (a int, b varchar(255))")) + return NDBT_FAILED; + + if (!sql.doQuery("INSERT INTO sql_client_test VALUES(1, 'hello'), (2, 'bye')")) + return NDBT_FAILED; + + // Select all rows from sql_client_test + SqlResultSet result; + if (!sql.doQuery("SELECT * FROM sql_client_test", result)) + return NDBT_FAILED; + // result.print(); + + while(result.next()) + { + } + + // Select second row from sql_client_test + Properties args; + args.put("0", 2); + if (!sql.doQuery("SELECT * FROM sql_client_test WHERE a=?", args,result)) + return NDBT_FAILED; + result.print(); + + result.reset(); + while(result.next()) + { + ndbout << "a: " << result.columnAsInt("a") << endl; + ndbout << "b: " << result.column("b") << endl; + if (result.columnAsInt("a") != 2){ + ndbout << "hepp1" << endl; + return NDBT_FAILED; + } + + if (strcmp(result.column("b"), "bye")){ + ndbout << "hepp2" << endl; + return NDBT_FAILED; + } + + } + + if (sql.selectCountTable("sql_client_test") != 2) + { + ndbout << "Got wrong count" << endl; + return NDBT_FAILED; + } + + + if (!sql.doQuery("DROP TABLE sql_client_test")) + return NDBT_FAILED; + + } + + return NDBT_OK; +} + +NDBT_TESTSUITE(testNDBT); +TESTCASE("AtrtClient", + "Test AtrtClient class"){ + INITIALIZER(runTestAtrtClient); +} +TESTCASE("DbUtil", + "Test DbUtil class"){ + INITIALIZER(runTestDbUtil); +} +NDBT_TESTSUITE_END(testNDBT); + +int main(int argc, const char** argv){ + ndb_init(); + return testNDBT.execute(argc, argv); +} + diff --git a/storage/ndb/test/src/AtrtClient.cpp b/storage/ndb/test/src/AtrtClient.cpp new file mode 100644 index 00000000000..5183242f841 --- /dev/null +++ b/storage/ndb/test/src/AtrtClient.cpp @@ -0,0 +1,215 @@ +/* Copyright (C) 2008 MySQL AB + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#include +#include +#include + +AtrtClient::AtrtClient(const char* _user, + const char* _password, + const char* _group_suffix) + : DbUtil(_user, _password, _group_suffix) +{ +} + + +AtrtClient::AtrtClient(MYSQL* mysql) + : DbUtil(mysql) +{ +} + + +AtrtClient::~AtrtClient(){ +} + + +int +AtrtClient::writeCommand(AtrtCommandType _type, + const Properties& args){ + if (!isConnected()) + return false; + + BaseString sql; + sql.assfmt("INSERT command ( "); + + const char* name; + { + Properties::Iterator iter(&args); + while((name= iter.next())){ + sql.appfmt("%s, ", name); + } + } + + sql.appfmt(" state, cmd) VALUES ("); + + { + Properties::Iterator iter(&args); + while((name= iter.next())){ + PropertiesType t; + Uint32 val_i; + BaseString val_s; + args.getTypeOf(name, &t); + switch(t) { + case PropertiesType_Uint32: + args.get(name, &val_i); + sql.appfmt("%d, ", val_i); + break; + case PropertiesType_char: + args.get(name, val_s); + sql.appfmt("'%s', ", val_s.c_str()); + break; + default: + assert(false); + break; + } + } + } + + sql.appfmt("'new', %d)", _type); + if (!doQuery(sql)){ + return -1; + } + + return mysql_insert_id(m_mysql); +} + + +bool +AtrtClient::readCommand(uint command_id, + SqlResultSet& result){ + Properties args; + args.put("0", command_id); + return runQuery("SELECT * FROM command WHERE id = ?", + args, + result); +} + + +bool +AtrtClient::doCommand(AtrtCommandType type, + const Properties& args){ + + int running_timeout= 10; + int total_timeout= 120; + int commandId= writeCommand(type, + args); + if (commandId == -1){ + g_err << "Failed to write command" << endl; + return false; + } + + while (true){ + + SqlResultSet result; + if (!readCommand(commandId, result)) + { + result.print(); + g_err << "Failed to read command "<< commandId << endl; + return false; + } + + // Get first row + result.next(); + + // Check if command has completed + BaseString state(result.column("state")); + if (state == "done") { + return true; + } + + if (state == "new"){ + if (!running_timeout--){ + g_err << "Timeout while waiting for command " + << commandId << " to start run" << endl; + return false; + } + } + else if (!total_timeout--){ + g_err << "Timeout while waiting for result of command " + << commandId << endl; + return false; + } + + + NdbSleep_SecSleep(1); + } + + return false; +} + + +bool +AtrtClient::changeVersion(int process_id, + const char* process_args){ + Properties args; + args.put("process_id", process_id); + args.put("process_args", process_args); + return doCommand(ATCT_CHANGE_VERSION, args); +} + + +bool +AtrtClient::resetProc(int process_id){ + Properties args; + args.put("process_id", process_id); + return doCommand(ATCT_RESET_PROC, args); +} + + +bool +AtrtClient::getConnectString(int cluster_id, SqlResultSet& result){ + Properties args; + args.put("0", cluster_id); + return doQuery("SELECT value as connectstring " \ + "FROM cluster c, process p, host h, options o " \ + "WHERE c.id=p.cluster_id AND p.host_id=h.id AND " \ + "p.id=o.process_id AND c.id=? AND " \ + "o.name='--ndb-connectstring=' AND type='ndb_mgmd'", + args, + result); +} + + +bool +AtrtClient::getClusters(SqlResultSet& result){ + Properties args; + return runQuery("SELECT id, name FROM cluster WHERE name != '.atrt'", + args, + result); +} + + +bool +AtrtClient::getMgmds(int cluster_id, SqlResultSet& result){ + Properties args; + args.put("0", cluster_id); + return runQuery("SELECT * FROM process WHERE cluster_id=? and type='ndb_mgmd'", + args, + result); +} + +bool +AtrtClient::getNdbds(int cluster_id, SqlResultSet& result){ + Properties args; + args.put("0", cluster_id); + return runQuery("SELECT * FROM process WHERE cluster_id=? and type='ndbd'", + args, + result); +} + + + + + diff --git a/storage/ndb/test/src/DbUtil.cpp b/storage/ndb/test/src/DbUtil.cpp index 5fe3e6e9fbe..a52f45b46a7 100755 --- a/storage/ndb/test/src/DbUtil.cpp +++ b/storage/ndb/test/src/DbUtil.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2007 MySQL AB +/* Copyright (C) 2008 MySQL AB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -16,43 +16,89 @@ /* DbUtil.cpp: implementation of the database utilities class.*/ #include "DbUtil.hpp" +#include + /* Constructors */ -DbUtil::DbUtil(const char * dbname) +DbUtil::DbUtil(const char* _dbname, + const char* _user, + const char* _password, + const char* _suffix): + m_connected(false), + m_dbname(_dbname), + m_mysql(NULL), + m_free_mysql(true) { - m_port = 0; - m_connected = false; - this->setDbName(dbname); -} - -DbUtil::DbUtil(const char * dbname, const char* suffix) -{ - this->setDbName(dbname); - m_connected = false; - const char* env= getenv("MYSQL_HOME"); if (env && strlen(env)) { - default_file.assfmt("%s/my.cnf", env); + m_default_file.assfmt("%s/my.cnf", env); } - if (suffix != NULL){ - default_group.assfmt("client%s", suffix); + if (_suffix != NULL){ + m_default_group.assfmt("client%s", _suffix); } else { - default_group.assign("client.1.master"); + m_default_group.assign("client.1.master"); } - ndbout << "default_file: " << default_file.c_str() << endl; - ndbout << "default_group: " << default_group.c_str() << endl; + ndbout << "default_file: " << m_default_file.c_str() << endl; + ndbout << "default_group: " << m_default_group.c_str() << endl; + + m_user.assign(_user); + m_pass.assign(_password); } -/* Destructor*/ + + +DbUtil::DbUtil(MYSQL* mysql): + m_connected(true), + m_mysql(mysql), + m_free_mysql(false) +{ +} + + +bool +DbUtil::isConnected(){ + if (m_connected == true) + { + assert(m_mysql); + return true; + } + return connect() == 0; +} + + +bool +DbUtil::waitConnected(int timeout) { + timeout*= 10; + while(!isConnected()){ + if (timeout-- == 0) + return false; + NdbSleep_MilliSleep(100); + } + return true; +} + + +void +DbUtil::disconnect(){ + if (m_mysql != NULL){ + if (m_free_mysql) + mysql_close(m_mysql); + m_mysql= NULL; + } + m_connected = false; +} + + +/* Destructor */ DbUtil::~DbUtil() { - this->databaseLogout(); + disconnect(); } /* Database Login */ @@ -62,18 +108,18 @@ DbUtil::databaseLogin(const char* system, const char* usr, const char* password, unsigned int portIn, const char* sockIn, bool transactional) { - if (!(mysql = mysql_init(NULL))) + if (!(m_mysql = mysql_init(NULL))) { myerror("DB Login-> mysql_init() failed"); exit(DBU_FAILED); } - this->setUser(usr); - this->setHost(system); - this->setPassword(password); - this->setPort(portIn); - this->setSocket(sockIn); + setUser(usr); + setHost(system); + setPassword(password); + setPort(portIn); + setSocket(sockIn); - if (!(mysql_real_connect(mysql, + if (!(mysql_real_connect(m_mysql, m_host.c_str(), m_user.c_str(), m_pass.c_str(), @@ -82,40 +128,40 @@ DbUtil::databaseLogin(const char* system, const char* usr, m_socket.c_str(), 0))) { myerror("connection failed"); - mysql_close(mysql); + mysql_close(m_mysql); exit(DBU_FAILED); } - mysql->reconnect = TRUE; + m_mysql->reconnect = TRUE; /* set AUTOCOMMIT */ if(!transactional) - mysql_autocommit(mysql, TRUE); + mysql_autocommit(m_mysql, TRUE); else - mysql_autocommit(mysql, FALSE); + mysql_autocommit(m_mysql, FALSE); #ifdef DEBUG printf("\n\tConnected to MySQL server version: %s (%lu)\n\n", - mysql_get_server_info(mysql), - (unsigned long) mysql_get_server_version(mysql)); + mysql_get_server_info(m_mysql), + (unsigned long) mysql_get_server_version(m_mysql)); #endif - this->selectDb(); + selectDb(); } /* Database Connect */ -int +int DbUtil::connect() { - if (!(mysql = mysql_init(NULL))) + if (!(m_mysql = mysql_init(NULL))) { myerror("DB connect-> mysql_init() failed"); return DBU_FAILED; } /* Load connection parameters file and group */ - if (mysql_options(mysql, MYSQL_READ_DEFAULT_FILE, default_file.c_str()) || - mysql_options(mysql, MYSQL_READ_DEFAULT_GROUP, default_group.c_str())) + if (mysql_options(m_mysql, MYSQL_READ_DEFAULT_FILE, m_default_file.c_str()) || + mysql_options(m_mysql, MYSQL_READ_DEFAULT_GROUP, m_default_group.c_str())) { myerror("DB Connect -> mysql_options failed"); return DBU_FAILED; @@ -126,14 +172,14 @@ DbUtil::connect() NOTE! user and password can be stored there as well */ - if (mysql_real_connect(mysql, NULL, "root","", m_dbname.c_str(), + if (mysql_real_connect(m_mysql, NULL, "root","", m_dbname.c_str(), 0, NULL, 0) == NULL) { myerror("connection failed"); - mysql_close(mysql); + mysql_close(m_mysql); return DBU_FAILED; } - this->selectDb(); + selectDb(); m_connected = true; return DBU_OK; } @@ -141,14 +187,14 @@ DbUtil::connect() /* Database Logout */ -void +void DbUtil::databaseLogout() { - if (mysql){ + if (m_mysql){ #ifdef DEBUG printf("\n\tClosing the MySQL database connection ...\n\n"); #endif - mysql_close(mysql); + mysql_close(m_mysql); } } @@ -181,28 +227,28 @@ DbUtil::mysqlCloseStmHandle(MYSQL_STMT *my_stmt) /* Error Printing */ -void +void DbUtil::printError(const char *msg) { - if (this->getMysql() && mysql_errno(this->getMysql())) + if (m_mysql && mysql_errno(m_mysql)) { - if (this->getMysql()->server_version) - printf("\n [MySQL-%s]", this->getMysql()->server_version); + if (m_mysql->server_version) + printf("\n [MySQL-%s]", m_mysql->server_version); else printf("\n [MySQL]"); - printf("[%d] %s\n", this->getErrorNumber(), this->getError()); + printf("[%d] %s\n", getErrorNumber(), getError()); } else if (msg) printf(" [MySQL] %s\n", msg); } -void +void DbUtil::printStError(MYSQL_STMT *stmt, const char *msg) { if (stmt && mysql_stmt_errno(stmt)) { - if (this->getMysql() && this->getMysql()->server_version) - printf("\n [MySQL-%s]", this->getMysql()->server_version); + if (m_mysql && m_mysql->server_version) + printf("\n [MySQL-%s]", m_mysql->server_version); else printf("\n [MySQL]"); @@ -215,19 +261,19 @@ DbUtil::printStError(MYSQL_STMT *stmt, const char *msg) /* Select which database to use */ -int +int DbUtil::selectDb() { - if ((this->getDbName()) != NULL) + if ((getDbName()) != NULL) { - if(mysql_select_db(this->getMysql(), this->getDbName())) + if(mysql_select_db(m_mysql, this->getDbName())) { - this->printError("mysql_select_db failed"); + printError("mysql_select_db failed"); return DBU_FAILED; } return DBU_OK; } - this->printError("getDbName() == NULL"); + printError("getDbName() == NULL"); return DBU_FAILED; } @@ -235,9 +281,9 @@ int DbUtil::selectDb(const char * m_db) { { - if(mysql_select_db(this->getMysql(), m_db)) + if(mysql_select_db(m_mysql, m_db)) { - this->printError("mysql_select_db failed"); + printError("mysql_select_db failed"); return DBU_FAILED; } return DBU_OK; @@ -249,89 +295,383 @@ DbUtil::createDb(BaseString& m_db) { BaseString stm; { - if(mysql_select_db(this->getMysql(), m_db.c_str()) == DBU_OK) + if(mysql_select_db(m_mysql, m_db.c_str()) == DBU_OK) { stm.assfmt("DROP DATABASE %s", m_db.c_str()); - if(this->doQuery(m_db.c_str()) == DBU_FAILED) + if(doQuery(m_db.c_str()) == DBU_FAILED) return DBU_FAILED; } stm.assfmt("CREATE DATABASE %s", m_db.c_str()); - if(this->doQuery(m_db.c_str()) == DBU_FAILED) + if(doQuery(m_db.c_str()) == DBU_FAILED) return DBU_FAILED; return DBU_OK; } } + +/* Count Table Rows */ + +unsigned long +DbUtil::selectCountTable(const char * table) +{ + BaseString query; + SqlResultSet result; + + query.assfmt("select count(*) as count from %s", table); + if (!doQuery(query, result)) { + printError("select count(*) failed"); + return -1; + } + return result.columnAsInt("count"); +} + + /* Run Simple Queries */ -int -DbUtil::doQuery(BaseString& str) -{ - if(mysql_query(this->getMysql(), str.c_str())) - { - this->printError(str.c_str()); - return DBU_FAILED; + +static bool is_int_type(enum_field_types type){ + switch(type){ + case MYSQL_TYPE_TINY: + case MYSQL_TYPE_SHORT: + case MYSQL_TYPE_LONGLONG: + case MYSQL_TYPE_INT24: + case MYSQL_TYPE_LONG: + case MYSQL_TYPE_ENUM: + return true; + default: + return false; } - return DBU_OK; + return false; } -int -DbUtil::doQuery(const char * stm) -{ - if(mysql_query(this->getMysql(), stm)) + +bool +DbUtil::runQuery(const char* sql, + const Properties& args, + SqlResultSet& rows){ + + rows.clear(); + if (!isConnected()) + return false; + + g_debug << "runQuery: " << endl + << " sql: '" << sql << "'" << endl; + + + MYSQL_STMT *stmt= mysql_stmt_init(m_mysql); + if (mysql_stmt_prepare(stmt, sql, strlen(sql))) { - this->printError(stm); - return DBU_FAILED; + g_err << "Failed to prepare: " << mysql_error(m_mysql) << endl; + return false; } - return DBU_OK; + + uint params= mysql_stmt_param_count(stmt); + MYSQL_BIND bind_param[params]; + bzero(bind_param, sizeof(bind_param)); + + for(uint i= 0; i < mysql_stmt_param_count(stmt); i++) + { + BaseString name; + name.assfmt("%d", i); + // Parameters are named 0, 1, 2... + if (!args.contains(name.c_str())) + { + g_err << "param " << i << " missing" << endl; + assert(false); + } + PropertiesType t; + Uint32 val_i; + const char* val_s; + args.getTypeOf(name.c_str(), &t); + switch(t) { + case PropertiesType_Uint32: + args.get(name.c_str(), &val_i); + bind_param[i].buffer_type= MYSQL_TYPE_LONG; + bind_param[i].buffer= (char*)&val_i; + g_debug << " param" << name.c_str() << ": " << val_i << endl; + break; + case PropertiesType_char: + args.get(name.c_str(), &val_s); + bind_param[i].buffer_type= MYSQL_TYPE_STRING; + bind_param[i].buffer= (char*)val_s; + bind_param[i].buffer_length= strlen(val_s); + g_debug << " param" << name.c_str() << ": " << val_s << endl; + break; + default: + assert(false); + break; + } + } + if (mysql_stmt_bind_param(stmt, bind_param)) + { + g_err << "Failed to bind param: " << mysql_error(m_mysql) << endl; + mysql_stmt_close(stmt); + return false; + } + + if (mysql_stmt_execute(stmt)) + { + g_err << "Failed to execute: " << mysql_error(m_mysql) << endl; + mysql_stmt_close(stmt); + return false; + } + + /* + Update max_length, making it possible to know how big + buffers to allocate + */ + my_bool one= 1; + mysql_stmt_attr_set(stmt, STMT_ATTR_UPDATE_MAX_LENGTH, (void*) &one); + + if (mysql_stmt_store_result(stmt)) + { + g_err << "Failed to store result: " << mysql_error(m_mysql) << endl; + mysql_stmt_close(stmt); + return false; + } + + uint row= 0; + MYSQL_RES* res= mysql_stmt_result_metadata(stmt); + if (res != NULL) + { + MYSQL_FIELD *fields= mysql_fetch_fields(res); + uint num_fields= mysql_num_fields(res); + MYSQL_BIND bind_result[num_fields]; + bzero(bind_result, sizeof(bind_result)); + + for (uint i= 0; i < num_fields; i++) + { + if (is_int_type(fields[i].type)){ + bind_result[i].buffer_type= MYSQL_TYPE_LONG; + bind_result[i].buffer= malloc(sizeof(int)); + } + else + { + uint max_length= fields[i].max_length + 1; + bind_result[i].buffer_type= MYSQL_TYPE_STRING; + bind_result[i].buffer= malloc(max_length); + bind_result[i].buffer_length= max_length; + } + } + + if (mysql_stmt_bind_result(stmt, bind_result)){ + g_err << "Failed to bind result: " << mysql_error(m_mysql) << endl; + mysql_stmt_close(stmt); + return false; + } + + while (mysql_stmt_fetch(stmt) != MYSQL_NO_DATA) + { + Properties curr(true); + for (uint i= 0; i < num_fields; i++){ + if (is_int_type(fields[i].type)) + curr.put(fields[i].name, *(int*)bind_result[i].buffer); + else + curr.put(fields[i].name, (char*)bind_result[i].buffer); + } + rows.put("row", row++, &curr); + } + + mysql_free_result(res); + + for (uint i= 0; i < num_fields; i++) + free(bind_result[i].buffer); + + } + + // Save stats in result set + rows.put("rows", row); + rows.put("affected_rows", mysql_affected_rows(m_mysql)); + rows.put("mysql_errno", mysql_errno(m_mysql)); + rows.put("mysql_error", mysql_error(m_mysql)); + rows.put("mysql_sqlstate", mysql_sqlstate(m_mysql)); + rows.put("insert_id", mysql_insert_id(m_mysql)); + + mysql_stmt_close(stmt); + return true; } + +bool +DbUtil::doQuery(const char* query){ + const Properties args; + SqlResultSet result; + return doQuery(query, args, result); +} + + +bool +DbUtil::doQuery(const char* query, SqlResultSet& result){ + Properties args; + return doQuery(query, args, result); +} + + +bool +DbUtil::doQuery(const char* query, const Properties& args, + SqlResultSet& result){ + if (!runQuery(query, args, result)) + return false; + result.get_row(0); // Load first row + return true; +} + + +bool +DbUtil::doQuery(BaseString& str){ + return doQuery(str.c_str()); +} + + +bool +DbUtil::doQuery(BaseString& str, SqlResultSet& result){ + return doQuery(str.c_str(), result); +} + + +bool +DbUtil::doQuery(BaseString& str, const Properties& args, + SqlResultSet& result){ + return doQuery(str.c_str(), args, result); +} + + /* Return MySQL Error String */ -const char * +const char * DbUtil::getError() { return mysql_error(this->getMysql()); } -/* Retrun MySQL Error Number */ +/* Return MySQL Error Number */ -int +int DbUtil::getErrorNumber() { return mysql_errno(this->getMysql()); } -/* Count Table Rows */ - -unsigned long -DbUtil::selectCountTable(const char * table) -{ - unsigned long m_count = 0; - BaseString m_query; - - m_query.assfmt("select count(*) from %s", table); - if (mysql_query(this->getMysql(),m_query.c_str()) || - !(m_result=mysql_store_result(this->getMysql()))) - { - this->printError("selectCountTable\n"); - return DBU_FAILED; - } - m_row = mysql_fetch_row(m_result); - m_count = (ulong) strtoull(m_row[0], (char**) 0, 10); - mysql_free_result(m_result); - - return m_count; -} - /* DIE */ -void +void DbUtil::die(const char *file, int line, const char *expr) { printf("%s:%d: check failed: '%s'\n", file, line, expr); abort(); } + +/* SqlResultSet */ + +bool +SqlResultSet::get_row(int row_num){ + if(!get("row", row_num, &m_curr_row)){ + return false; + } + return true; +} + + +bool +SqlResultSet::next(void){ + return get_row(++m_curr_row_num); +} + + +// Reset iterator +void SqlResultSet::reset(void){ + m_curr_row_num= -1; + m_curr_row= 0; +} + + +// Remove row from resultset +void SqlResultSet::remove(){ + BaseString row_name; + row_name.assfmt("row_%d", m_curr_row_num); + Properties::remove(row_name.c_str()); +} + + +SqlResultSet::SqlResultSet(): m_curr_row(0), m_curr_row_num(-1){ +} + + +SqlResultSet::~SqlResultSet(){ +} + + +const char* SqlResultSet::column(const char* col_name){ + const char* value; + if (!m_curr_row){ + g_err << "ERROR: SqlResultSet::column("<< col_name << ")" << endl + << "There is no row loaded, call next() before " + << "acessing the column values" << endl; + assert(m_curr_row); + } + if (!m_curr_row->get(col_name, &value)) + return NULL; + return value; +} + + +uint SqlResultSet::columnAsInt(const char* col_name){ + uint value; + if (!m_curr_row){ + g_err << "ERROR: SqlResultSet::columnAsInt("<< col_name << ")" << endl + << "There is no row loaded, call next() before " + << "acessing the column values" << endl; + assert(m_curr_row); + } + if (!m_curr_row->get(col_name, &value)) + return (uint)-1; + return value; +} + + +uint SqlResultSet::insertId(){ + return get_int("insert_id"); +} + + +uint SqlResultSet::affectedRows(){ + return get_int("affected_rows"); +} + + +uint SqlResultSet::numRows(void){ + return get_int("rows"); +} + + +uint SqlResultSet::mysqlErrno(void){ + return get_int("mysql_errno"); +} + + +const char* SqlResultSet::mysqlError(void){ + return get_string("mysql_error"); +} + + +const char* SqlResultSet::mysqlSqlstate(void){ + return get_string("mysql_sqlstate"); +} + + +uint SqlResultSet::get_int(const char* name){ + uint value; + get(name, &value); + return value; +} + + +const char* SqlResultSet::get_string(const char* name){ + const char* value; + get(name, &value); + return value; +} + /* EOF */ diff --git a/storage/ndb/test/src/Makefile.am b/storage/ndb/test/src/Makefile.am index 8cbe83dfbcf..1e4f30c3f39 100644 --- a/storage/ndb/test/src/Makefile.am +++ b/storage/ndb/test/src/Makefile.am @@ -23,7 +23,7 @@ libNDBT_a_SOURCES = \ HugoAsynchTransactions.cpp UtilTransactions.cpp \ NdbRestarter.cpp NdbRestarts.cpp NDBT_Output.cpp \ NdbBackup.cpp NdbConfig.cpp NdbGrep.cpp NDBT_Table.cpp \ - NdbSchemaCon.cpp NdbSchemaOp.cpp getarg.c \ + NdbSchemaCon.cpp NdbSchemaOp.cpp getarg.c AtrtClient.cpp \ CpcClient.cpp NdbMixRestarter.cpp NDBT_Thread.cpp DbUtil.cpp INCLUDES_LOC = -I$(top_srcdir)/storage/ndb/src/common/mgmcommon -I$(top_srcdir)/storage/ndb/include/mgmcommon -I$(top_srcdir)/storage/ndb/include/kernel -I$(top_srcdir)/storage/ndb/src/mgmapi -I$(top_srcdir)/include From a79ebb850311886e8d50bb39a14efccc36e88974 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 23 Jan 2008 09:59:06 +0100 Subject: [PATCH 28/32] ndb - bug#33750 make sure that getField does not write after supplied buffer (recommit to correct clone, for easy merging) ndb/include/util/Bitmask.hpp: ndb- bug#33750 make sure that getField does not write after supplied buffer ndb/src/common/util/Bitmask.cpp: ndb- bug#33750 make sure that getField does not write after supplied buffer ndb/test/ndbapi/testBitfield.cpp: move test from Bitmask.cpp into testBitfield for automatic testing --- ndb/include/util/Bitmask.hpp | 10 +- ndb/src/common/util/Bitmask.cpp | 353 ++++----------------------- ndb/test/ndbapi/testBitfield.cpp | 407 ++++++++++++++++++++++++++++++- 3 files changed, 464 insertions(+), 306 deletions(-) diff --git a/ndb/include/util/Bitmask.hpp b/ndb/include/util/Bitmask.hpp index 3b3fe721cca..0383841a666 100644 --- a/ndb/include/util/Bitmask.hpp +++ b/ndb/include/util/Bitmask.hpp @@ -126,6 +126,7 @@ public: /** * setField - Set bitfield at given position and length (max 32 bits) + * Note : length == 0 not supported. */ static void setField(unsigned size, Uint32 data[], unsigned pos, unsigned len, Uint32 val); @@ -133,6 +134,7 @@ public: /** * getField - Get bitfield at given position and length + * Note : length == 0 not supported. */ static void getField(unsigned size, const Uint32 data[], unsigned pos, unsigned len, Uint32 dst[]); @@ -814,7 +816,10 @@ BitmaskImpl::getField(unsigned size, const Uint32 src[], unsigned pos, unsigned len, Uint32 dst[]) { assert(pos + len <= (size << 5)); - + assert (len != 0); + if (len == 0) + return; + src += (pos >> 5); Uint32 offset = pos & 31; * dst = (* src >> offset) & (len >= 32 ? ~0 : (1 << len) - 1); @@ -833,6 +838,9 @@ BitmaskImpl::setField(unsigned size, Uint32 dst[], unsigned pos, unsigned len, const Uint32 src[]) { assert(pos + len <= (size << 5)); + assert(len != 0); + if (len == 0) + return; dst += (pos >> 5); Uint32 offset = pos & 31; diff --git a/ndb/src/common/util/Bitmask.cpp b/ndb/src/common/util/Bitmask.cpp index f5b822ff08e..22919fe585a 100644 --- a/ndb/src/common/util/Bitmask.cpp +++ b/ndb/src/common/util/Bitmask.cpp @@ -16,49 +16,63 @@ #include #include -static -void print(const Uint32 src[], Uint32 len, Uint32 pos = 0) -{ - printf("b'"); - for(unsigned i = 0; i> 5, src, i+pos)) - printf("1"); - else - printf("0"); - if((i & 31) == 31) - printf(" "); - } -} - -#ifndef __TEST_BITMASK__ - void BitmaskImpl::getFieldImpl(const Uint32 src[], unsigned shiftL, unsigned len, Uint32 dst[]) { + /* Copy whole words of src to dst, shifting src left + * by shiftL. Undefined bits of the last written dst word + * should be zeroed. + */ assert(shiftL < 32); unsigned shiftR = 32 - shiftL; unsigned undefined = shiftL ? ~0 : 0; + /* Merge first word with previously set bits if there's a shift */ * dst = shiftL ? * dst : 0; - - while(len >= 32) + + /* Treat the zero-shift case separately to avoid + * trampling or reading past the end of src + */ + if (shiftL == 0) { - * dst++ |= (* src) << shiftL; - * dst = ((* src++) >> shiftR) & undefined; - len -= 32; + while(len >= 32) + { + * dst++ = * src++; + len -=32; + } + + if (len != 0) + { + /* Last word has some bits set */ + Uint32 mask= ((1 << len) -1); // 0000111 + * dst = (* src) & mask; + } } - - if(len < shiftR) + else // shiftL !=0, need to build each word from two words shifted { - * dst |= ((* src) & ((1 << len) - 1)) << shiftL; - } - else - { - * dst++ |= ((* src) << shiftL); - * dst = ((* src) >> shiftR) & ((1 << (len - shiftR)) - 1) & undefined; + while(len >= 32) + { + * dst++ |= (* src) << shiftL; + * dst = ((* src++) >> shiftR) & undefined; + len -= 32; + } + + /* Have space for shiftR more bits in the current dst word + * is that enough? + */ + if(len <= shiftR) + { + /* Fit the remaining bits in the current dst word */ + * dst |= ((* src) & ((1 << len) - 1)) << shiftL; + } + else + { + /* Need to write to two dst words */ + * dst++ |= ((* src) << shiftL); + * dst = ((* src) >> shiftR) & ((1 << (len - shiftR)) - 1) & undefined; + } } } @@ -81,286 +95,23 @@ BitmaskImpl::setFieldImpl(Uint32 dst[], len -= 32; } + /* Copy last bits */ Uint32 mask = ((1 << len) -1); * dst = (* dst & ~mask); - if(len < shiftR) + if(len <= shiftR) { + /* Remaining bits fit in current word */ * dst |= ((* src++) >> shiftL) & mask; } else { + /* Remaining bits update 2 words */ * dst |= ((* src++) >> shiftL); * dst |= ((* src) & ((1 << (len - shiftR)) - 1)) << shiftR ; } } -#else -#define DEBUG 0 -#include -static void do_test(int bitmask_size); - -int -main(int argc, char** argv) -{ - int loops = argc > 1 ? atoi(argv[1]) : 1000; - int max_size = argc > 2 ? atoi(argv[2]) : 1000; - - - for(int i = 0; i data; -}; - -static void require(bool b) -{ - if(!b) abort(); -} - -static -bool cmp(const Uint32 b1[], const Uint32 b2[], Uint32 len) -{ - Uint32 sz32 = (len + 31) >> 5; - for(int i = 0; i> 5, dst, i, (lrand() % 1000) > 500); -} - -static -void simple(int pos, int size) -{ - ndbout_c("simple pos: %d size: %d", pos, size); - Vector _mask; - Vector _src; - Vector _dst; - Uint32 sz32 = (size + pos + 32) >> 5; - const Uint32 sz = 4 * sz32; - - Uint32 zero = 0; - _mask.fill(sz32+1, zero); - _src.fill(sz32+1, zero); - _dst.fill(sz32+1, zero); - - Uint32 * src = _src.getBase(); - Uint32 * dst = _dst.getBase(); - Uint32 * mask = _mask.getBase(); - - memset(src, 0x0, sz); - memset(dst, 0x0, sz); - memset(mask, 0xFF, sz); - rand(src, size); - BitmaskImpl::setField(sz32, mask, pos, size, src); - BitmaskImpl::getField(sz32, mask, pos, size, dst); - printf("src: "); print(src, size+31); printf("\n"); - printf("msk: "); print(mask, (sz32 << 5) + 31); printf("\n"); - printf("dst: "); print(dst, size+31); printf("\n"); - require(cmp(src, dst, size+31)); -}; - -static -void simple2(int size, int loops) -{ - ndbout_c("simple2 %d - ", size); - Vector _mask; - Vector _src; - Vector _dst; - - Uint32 sz32 = (size + 32) >> 5; - Uint32 sz = sz32 << 2; - - Uint32 zero = 0; - _mask.fill(sz32+1, zero); - _src.fill(sz32+1, zero); - _dst.fill(sz32+1, zero); - - Uint32 * src = _src.getBase(); - Uint32 * dst = _dst.getBase(); - Uint32 * mask = _mask.getBase(); - - Vector save; - for(int i = 0; i alloc_list; - bitmask_size = (bitmask_size + 31) & ~31; - Uint32 sz32 = (bitmask_size >> 5); - Vector alloc_mask; - Vector test_mask; - - ndbout_c("Testing bitmask of size %d", bitmask_size); - Uint32 zero = 0; - alloc_mask.fill(sz32, zero); - test_mask.fill(sz32, zero); - - for(int i = 0; i<5000; i++) - { - Vector tmp; - tmp.fill(sz32, zero); - - int pos = lrand() % (bitmask_size - 1); - int free = 0; - if(BitmaskImpl::get(sz32, alloc_mask.getBase(), pos)) - { - // Bit was allocated - // 1) Look up allocation - // 2) Check data - // 3) free it - size_t j; - int min, max; - for(j = 0; j= min && pos < max) - { - break; - } - } - require(pos >= min && pos < max); - BitmaskImpl::getField(sz32, test_mask.getBase(), min, max-min, - tmp.getBase()); - if(DEBUG) - { - printf("freeing [ %d %d ]", min, max); - printf("- mask: "); - print(tmp.getBase(), max - min); - - printf(" save: "); - size_t k; - Alloc& a = alloc_list[j]; - for(k = 0; k> 3; - if(!cmp(tmp.getBase(), alloc_list[j].data.getBase(), max - min)) - { - abort(); - } - while(min < max) - BitmaskImpl::clear(sz32, alloc_mask.getBase(), min++); - alloc_list.erase(j); - } - else - { - Vector tmp; - tmp.fill(sz32, zero); - - // Bit was free - // 1) Check how much space is avaiable - // 2) Create new allocation of lrandom size - // 3) Fill data with lrandom data - // 4) Update alloc mask - while(pos+free < bitmask_size && - !BitmaskImpl::get(sz32, alloc_mask.getBase(), pos+free)) - free++; - - Uint32 sz = - (free <= 64 && ((lrand() % 100) > 80)) ? free : (lrand() % free); - sz = sz ? sz : 1; - sz = pos + sz == bitmask_size ? sz - 1 : sz; - Alloc a; - a.pos = pos; - a.size = sz; - a.data.fill(((sz+31)>> 5)-1, zero); - if(DEBUG) - printf("pos %d -> alloc [ %d %d ]", pos, pos, pos+sz); - for(size_t j = 0; j 500) - BitmaskImpl::set((sz + 31) >> 5, a.data.getBase(), j); - } - if(DEBUG) - { - printf("- mask: "); - print(a.data.getBase(), sz); - printf("\n"); - } - BitmaskImpl::setField(sz32, test_mask.getBase(), pos, sz, - a.data.getBase()); - alloc_list.push_back(a); - } - } -#endif -} - -template class Vector; -template class Vector; - -#endif +/* Bitmask testcase code moved from here to + * storage/ndb/test/ndbapi/testBitfield.cpp + * to get coverage from automated testing + */ diff --git a/ndb/test/ndbapi/testBitfield.cpp b/ndb/test/ndbapi/testBitfield.cpp index e26f495f5a4..6c958da693d 100644 --- a/ndb/test/ndbapi/testBitfield.cpp +++ b/ndb/test/ndbapi/testBitfield.cpp @@ -4,6 +4,8 @@ #include #include #include +#include +#include static const char* _dbname = "TEST_DB"; static int g_loops = 7; @@ -28,6 +30,7 @@ static int unique_indexes(Ndb*, const NdbDictionary::Table* tab); static int ordered_indexes(Ndb*, const NdbDictionary::Table* tab); static int node_restart(Ndb*, const NdbDictionary::Table* tab); static int system_restart(Ndb*, const NdbDictionary::Table* tab); +static int testBitmask(); int main(int argc, char** argv){ @@ -38,6 +41,15 @@ main(int argc, char** argv){ argc--; argv++; + + int res = NDBT_FAILED; + + /* Run cluster-independent tests */ + for (int i=0; i<(10*g_loops); i++) + { + if (NDBT_OK != (res= testBitmask())) + return NDBT_ProgramExit(res); + } Ndb_cluster_connection con(opt_connect_str); if(con.connect(12, 5, 1)) @@ -50,7 +62,6 @@ main(int argc, char** argv){ pNdb = new Ndb(&con, _dbname); pNdb->init(); while (pNdb->waitUntilReady() != 0); - int res = NDBT_FAILED; NdbDictionary::Dictionary * dict = pNdb->getDictionary(); @@ -111,14 +122,12 @@ create_random_table(Ndb* pNdb) do { NdbDictionary::Table tab; Uint32 cols = 1 + (rand() % (NDB_MAX_ATTRIBUTES_IN_TABLE - 1)); - Uint32 keys = NDB_MAX_NO_OF_ATTRIBUTES_IN_KEY; Uint32 length = 4090; - Uint32 key_size = NDB_MAX_KEYSIZE_IN_WORDS; BaseString name; name.assfmt("TAB_%d", rand() & 65535); tab.setName(name.c_str()); - for(int i = 0; i 2; i++) + for(Uint32 i = 0; i 2; i++) { NdbDictionary::Column col; name.assfmt("COL_%d", i); @@ -196,3 +205,393 @@ system_restart(Ndb* pNdb, const NdbDictionary::Table* tab) { return 0; } + +/* Note : folowing classes test functionality of storage/ndb/src/common/util/Bitmask.cpp + * and were originally defined there. + * Set BITMASK_DEBUG to 1 to get more test debugging info. + */ +#define BITMASK_DEBUG 0 + +static +bool cmp(const Uint32 b1[], const Uint32 b2[], Uint32 len) +{ + Uint32 sz32 = (len + 31) >> 5; + for(Uint32 i = 0; i> 5, src, i+pos)) + printf("1"); + else + printf("0"); + if((i & 31) == 31) + printf(" "); + } +} + +static int lrand() +{ + return rand(); +} + +static +void rand(Uint32 dst[], Uint32 len) +{ + for(Uint32 i = 0; i> 5, dst, i, (lrand() % 1000) > 500); +} + +static +int checkNoTramplingGetSetField(const Uint32 totalTests) +{ + const Uint32 numWords= 67; + const Uint32 maxBitsToCopy= (numWords * 32); + Uint32 sourceBuf[numWords]; + Uint32 targetBuf[numWords]; + + ndbout << "Testing : Bitmask NoTrampling\n"; + + memset(sourceBuf, 0x00, (numWords*4)); + + for (Uint32 test=0; test= srcStart) && + (bitNum < (srcStart + length))); + bool actualValue= (((targetWord >> bit) & 1) == 1); + if (BITMASK_DEBUG) + ndbout << "bitNum=%u expectedValue=%u, actual value=%u" + << bitNum << expectedValue << actualValue; + + if (actualValue != expectedValue) + { + ndbout << "Notrampling setField failed for srcStart " + << srcStart + << " length " << length + << " at word " << word << " bit " << bit << "\n"; + ndbout << "bitNum=%u expectedValue=%u, actual value=%u" + << bitNum << expectedValue << actualValue; + return -1; + } + } + } + + } + + return 0; +} + +static +int simple(int pos, int size) +{ + ndbout << "Testing : Bitmask simple pos: " << pos << " size: " << size << "\n"; + Vector _mask; + Vector _src; + Vector _dst; + Uint32 sz32 = (size + pos + 32) >> 5; + const Uint32 sz = 4 * sz32; + + Uint32 zero = 0; + _mask.fill(sz32+1, zero); + _src.fill(sz32+1, zero); + _dst.fill(sz32+1, zero); + + Uint32 * src = _src.getBase(); + Uint32 * dst = _dst.getBase(); + Uint32 * mask = _mask.getBase(); + + memset(src, 0x0, sz); + memset(dst, 0x0, sz); + memset(mask, 0xFF, sz); + rand(src, size); + BitmaskImpl::setField(sz32, mask, pos, size, src); + BitmaskImpl::getField(sz32, mask, pos, size, dst); + if (BITMASK_DEBUG) + { + printf("src: "); print(src, size+31); printf("\n"); + printf("msk: "); print(mask, (sz32 << 5) + 31); printf("\n"); + printf("dst: "); print(dst, size+31); printf("\n"); + } + return (cmp(src, dst, size+31)?0 : -1); +}; + +struct Alloc +{ + Uint32 pos; + Uint32 size; + Vector data; +}; + +static +int +testRanges(Uint32 bitmask_size) +{ + Vector alloc_list; + bitmask_size = (bitmask_size + 31) & ~31; + Uint32 sz32 = (bitmask_size >> 5); + Vector alloc_mask; + Vector test_mask; + + ndbout_c("Testing : Bitmask ranges for bitmask of size %d", bitmask_size); + Uint32 zero = 0; + alloc_mask.fill(sz32, zero); + test_mask.fill(sz32, zero); + + /* Loop a number of times, setting and clearing bits in the mask + * and tracking the modifications in a separate structure. + * Check that both structures remain in sync + */ + for(int i = 0; i<5000; i++) + { + Vector tmp; + tmp.fill(sz32, zero); + + Uint32 pos = lrand() % (bitmask_size - 1); + Uint32 free = 0; + if(BitmaskImpl::get(sz32, alloc_mask.getBase(), pos)) + { + // Bit was allocated + // 1) Look up allocation + // 2) Check data + // 3) free it + size_t j; + Uint32 min, max; + for(j = 0; j= min && pos < max) + { + break; + } + } + if (! ((pos >= min) && (pos < max))) + { + printf("Failed with pos %u, min %u, max %u\n", + pos, min, max); + return -1; + } + BitmaskImpl::getField(sz32, test_mask.getBase(), min, max-min, + tmp.getBase()); + if(BITMASK_DEBUG) + { + printf("freeing [ %d %d ]", min, max); + printf("- mask: "); + print(tmp.getBase(), max - min); + + printf(" save: "); + size_t k; + Alloc& a = alloc_list[j]; + for(k = 0; k tmp; + tmp.fill(sz32, zero); + + // Bit was free + // 1) Check how much space is avaiable + // 2) Create new allocation of lrandom size + // 3) Fill data with lrandom data + // 4) Update alloc mask + while(pos+free < bitmask_size && + !BitmaskImpl::get(sz32, alloc_mask.getBase(), pos+free)) + free++; + + Uint32 sz = + (free <= 64 && ((lrand() % 100) > 80)) ? free : (lrand() % free); + sz = sz ? sz : 1; + sz = pos + sz == bitmask_size ? sz - 1 : sz; + Alloc a; + a.pos = pos; + a.size = sz; + a.data.fill(((sz+31)>> 5)-1, zero); + if(BITMASK_DEBUG) + printf("pos %d -> alloc [ %d %d ]", pos, pos, pos+sz); + for(size_t j = 0; j 500) + BitmaskImpl::set((sz + 31) >> 5, a.data.getBase(), j); + } + if(BITMASK_DEBUG) + { + printf("- mask: "); + print(a.data.getBase(), sz); + printf("\n"); + } + BitmaskImpl::setField(sz32, test_mask.getBase(), pos, sz, + a.data.getBase()); + alloc_list.push_back(a); + } + } + +#ifdef NDB_BM_SUPPORT_RANGE + for(Uint32 i = 0; i<1000; i++) + { + Uint32 sz32 = 10+rand() % 100; + Uint32 zero = 0; + Vector map; + map.fill(sz32, zero); + + Uint32 sz = 32 * sz32; + Uint32 start = (rand() % sz); + Uint32 stop = start + ((rand() % (sz - start)) & 0xFFFFFFFF); + + Vector check; + check.fill(sz32, zero); + + /* Verify range setting method works correctly */ + for(Uint32 j = 0; j= start && j= start && j; +template class Vector; From ac632f5cbbb5b9acbbd8c6ec9d0147893e1878a2 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 23 Jan 2008 12:56:27 +0100 Subject: [PATCH 29/32] ndb - bug#34005 make sure whole send buffer is flushed, even when wrapping around end ndb/src/common/transporter/TCP_Transporter.cpp: ndb - bug#34005 make sure whole send buffer is flush, even when wrapping around end --- .../common/transporter/TCP_Transporter.cpp | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/ndb/src/common/transporter/TCP_Transporter.cpp b/ndb/src/common/transporter/TCP_Transporter.cpp index 91a5fb50c57..8e09c9d90c8 100644 --- a/ndb/src/common/transporter/TCP_Transporter.cpp +++ b/ndb/src/common/transporter/TCP_Transporter.cpp @@ -330,22 +330,32 @@ TCP_Transporter::doSend() { // Empty the SendBuffers - const char * const sendPtr = m_sendBuffer.sendPtr; - const Uint32 sizeToSend = m_sendBuffer.sendDataSize; - if (sizeToSend > 0){ + bool sent_any = true; + while (m_sendBuffer.dataSize > 0) + { + const char * const sendPtr = m_sendBuffer.sendPtr; + const Uint32 sizeToSend = m_sendBuffer.sendDataSize; const int nBytesSent = inet_send(theSocket, sendPtr, sizeToSend, 0); - if (nBytesSent > 0) { + if (nBytesSent > 0) + { + sent_any = true; m_sendBuffer.bytesSent(nBytesSent); sendCount ++; sendSize += nBytesSent; - if(sendCount == reportFreq){ + if(sendCount == reportFreq) + { reportSendLen(get_callback_obj(), remoteNodeId, sendCount, sendSize); sendCount = 0; sendSize = 0; } - } else { + } + else + { + if (nBytesSent < 0 && InetErrno == EAGAIN && sent_any) + break; + // Send failed #if defined DEBUG_TRANSPORTER ndbout_c("Send Failure(disconnect==%d) to node = %d nBytesSent = %d " From 6fc612e87b2c189fc5fd7911345dfc9c02716470 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 23 Jan 2008 21:51:01 +0100 Subject: [PATCH 30/32] correct result to be the same as in 5.0 --- mysql-test/r/view.result | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 7c1da1b3bab..0e3d650c571 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -2720,12 +2720,12 @@ View Create View v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select (year(`t1`.`test_date`) - year(`t1`.`DOB`)) AS `Age` from `t1` having (`Age` < 75) SELECT (year(test_date)-year(DOB)) AS Age FROM t1 HAVING Age < 75; Age -44 -40 +43 +39 SELECT * FROM v1; Age -44 -40 +43 +39 DROP VIEW v1; DROP TABLE t1; CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, a char(6) DEFAULT 'xxx'); From d36be3437bb67a27b833569f3f114c84c5402be9 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 24 Jan 2008 12:06:40 +0100 Subject: [PATCH 31/32] Bug#30366 (recommit) NDB fails to start on OS X, PPC, 64 bit - The errno variable should only be used when the previous socket write failed, it should be regarded as undefined at other times --- storage/ndb/src/common/util/OutputStream.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/storage/ndb/src/common/util/OutputStream.cpp b/storage/ndb/src/common/util/OutputStream.cpp index 0943e47e33f..cd619380e5a 100644 --- a/storage/ndb/src/common/util/OutputStream.cpp +++ b/storage/ndb/src/common/util/OutputStream.cpp @@ -62,7 +62,7 @@ SocketOutputStream::print(const char * fmt, ...){ if(ret >= 0) m_timeout_remain-=time; - if(errno==ETIMEDOUT || m_timeout_remain<=0) + if((ret < 0 && errno==ETIMEDOUT) || m_timeout_remain<=0) { m_timedout= true; ret= -1; @@ -84,7 +84,7 @@ SocketOutputStream::println(const char * fmt, ...){ if(ret >= 0) m_timeout_remain-=time; - if (errno==ETIMEDOUT || m_timeout_remain<=0) + if ((ret < 0 && errno==ETIMEDOUT) || m_timeout_remain<=0) { m_timedout= true; ret= -1; From 22be2b43f0a41082a4b8c11bf479593aad3f35b6 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 24 Jan 2008 12:08:04 +0100 Subject: [PATCH 32/32] Bug#33814 - yassl problems (recommit) extra/yassl/src/template_instnt.cpp: new template instantiation (recommit) --- extra/yassl/src/handshake.cpp | 5 +++++ extra/yassl/src/template_instnt.cpp | 1 + extra/yassl/src/yassl_imp.cpp | 11 ++++++++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/extra/yassl/src/handshake.cpp b/extra/yassl/src/handshake.cpp index 1d5a95820bb..262b5cb3b8b 100644 --- a/extra/yassl/src/handshake.cpp +++ b/extra/yassl/src/handshake.cpp @@ -527,6 +527,11 @@ void ProcessOldClientHello(input_buffer& input, SSL& ssl) input.read(len, sizeof(len)); uint16 randomLen; ato16(len, randomLen); + if (ch.suite_len_ > MAX_SUITE_SZ || sessionLen > ID_LEN || + randomLen > RAN_LEN) { + ssl.SetError(bad_input); + return; + } int j = 0; for (uint16 i = 0; i < ch.suite_len_; i += 3) { diff --git a/extra/yassl/src/template_instnt.cpp b/extra/yassl/src/template_instnt.cpp index f82f7924359..fe3a251b865 100644 --- a/extra/yassl/src/template_instnt.cpp +++ b/extra/yassl/src/template_instnt.cpp @@ -101,6 +101,7 @@ template void ysArrayDelete(unsigned char*); template void ysArrayDelete(char*); template int min(int, int); +template uint16 min(uint16, uint16); template unsigned int min(unsigned int, unsigned int); template unsigned long min(unsigned long, unsigned long); } diff --git a/extra/yassl/src/yassl_imp.cpp b/extra/yassl/src/yassl_imp.cpp index 0bc95f64abc..b43d9c27355 100644 --- a/extra/yassl/src/yassl_imp.cpp +++ b/extra/yassl/src/yassl_imp.cpp @@ -621,6 +621,10 @@ void HandShakeHeader::Process(input_buffer& input, SSL& ssl) } uint len = c24to32(length_); + if (len > input.get_remaining()) { + ssl.SetError(bad_input); + return; + } hashHandShake(ssl, input, len); hs->set_length(len); @@ -1391,10 +1395,15 @@ input_buffer& operator>>(input_buffer& input, ClientHello& hello) // Suites byte tmp[2]; + uint16 len; tmp[0] = input[AUTO]; tmp[1] = input[AUTO]; - ato16(tmp, hello.suite_len_); + ato16(tmp, len); + + hello.suite_len_ = min(len, static_cast(MAX_SUITE_SZ)); input.read(hello.cipher_suites_, hello.suite_len_); + if (len > hello.suite_len_) // ignore extra suites + input.set_current(input.get_current() + len - hello.suite_len_); // Compression hello.comp_len_ = input[AUTO];