19 #include <NDBT_Test.hpp>
20 #include <HugoTransactions.hpp>
21 #include <UtilTransactions.hpp>
22 #include <NdbRestarter.hpp>
24 #include <signaldata/DumpStateOrd.hpp>
25 #include <../../include/kernel/ndb_limits.h>
26 #include <../../include/kernel/trigger_definitions.h>
27 #include <signaldata/DictTabInfo.hpp>
29 #include <NdbAutoPtr.hpp>
30 #include <NdbMixRestarter.hpp>
31 #include <NdbSqlUtil.hpp>
34 #include <Bitmask.hpp>
36 #define ERR_INSERT_MASTER_FAILURE1 6013
37 #define ERR_INSERT_MASTER_FAILURE2 6014
38 #define ERR_INSERT_MASTER_FAILURE3 6015
40 #define ERR_INSERT_PARTIAL_START_FAIL 6140
41 #define ERR_INSERT_PARTIAL_PARSE_FAIL 6141
42 #define ERR_INSERT_PARTIAL_FLUSH_PREPARE_FAIL 6142
43 #define ERR_INSERT_PARTIAL_PREPARE_FAIL 6143
44 #define ERR_INSERT_PARTIAL_ABORT_PARSE_FAIL 6144
45 #define ERR_INSERT_PARTIAL_ABORT_PREPARE_FAIL 6145
46 #define ERR_INSERT_PARTIAL_FLUSH_COMMIT_FAIL 6146
47 #define ERR_INSERT_PARTIAL_COMMIT_FAIL 6147
48 #define ERR_INSERT_PARTIAL_FLUSH_COMPLETE_FAIL 6148
49 #define ERR_INSERT_PARTIAL_COMPLETE_FAIL 6149
50 #define ERR_INSERT_PARTIAL_END_FAIL 6150
55 #define SUCCEED_COMMIT 3
56 #define SUCCEED_ABORT 4
58 #define ndb_master_failure 1
60 char f_tablename[256];
62 #define CHECK(b) if (!(b)) { \
63 g_err << "ERR: "<< step->getName() \
64 << " failed on line " << __LINE__ << endl; \
65 result = NDBT_FAILED; \
68 #define CHECK2(b, c) if (!(b)) { \
69 g_err << "ERR: "<< step->getName() \
70 << " failed on line " << __LINE__ << ": " << c << endl; \
71 result = NDBT_FAILED; \
75 Ndb* pNdb = GETNDB(step);
76 int records = ctx->getNumRecords();
78 if (hugoTrans.loadTable(pNdb, records) != 0){
85 Ndb* pNdb = GETNDB(step);
88 char failTabName[256];
90 const int expectedDictErrors[6]= {720,
97 for (
int i = 0;
i < 10;
i++){
101 if (pFailTab != NULL){
102 ndbout <<
"|- " << failTabName << endl;
105 if (pFailTab->createTableInDb(pNdb) == 0){
106 ndbout << failTabName <<
" created, this was not expected"<< endl;
107 result = NDBT_FAILED;
113 for (
int e=0; e < 6; e++)
114 errorOk |= (errorCode == expectedDictErrors[e]);
118 ndbout <<
"Failure, got dict error : " << pNdb->
getDictionary()->
119 getNdbError().code << endl;
125 NDBT_Table::discoverTableFromDb(pNdb, failTabName) ;
127 ndbout << failTabName <<
" was found in DB, this was not expected"<< endl;
128 result = NDBT_FAILED;
129 if (pFailTab->
equal(*pTab2) ==
true){
130 ndbout <<
"It was equal" << endl;
132 ndbout <<
"It was not equal" << endl;
136 if (hugoTrans.loadTable(pNdb, records) != 0){
137 ndbout <<
"It can NOT be loaded" << endl;
139 ndbout <<
"It can be loaded" << endl;
142 if (utilTrans.clearTable(pNdb, records, 64) != 0){
143 ndbout <<
"It can NOT be cleared" << endl;
145 ndbout <<
"It can be cleared" << endl;
150 ndbout <<
"It can NOT be dropped" << endl;
152 ndbout <<
"It can be dropped" << endl;
161 Ndb* pNdb = GETNDB(step);
165 if (NDBT_Tables::createTable(pNdb, pTab->
getName()) != 0){
171 NDBT_Table::discoverTableFromDb(pNdb, pTab->
getName());
173 ndbout << pTab->
getName() <<
" was not found in DB"<< endl;
185 Ndb* pNdb = GETNDB(step);
195 Ndb* pNdb = GETNDB(step);
196 int result = NDBT_OK;
197 const char* tabName =
"TRANSACTION";
201 ndbout <<
"|- " << tabName << endl;
204 if (NDBT_Table::discoverTableFromDb(pNdb, tabName) != NULL){
205 ndbout << tabName <<
" was found in DB"<< endl;
210 if (NDBT_Tables::createTable(pNdb, pTab->
getName()) == 0){
211 result = NDBT_FAILED;
215 if (NDBT_Table::discoverTableFromDb(pNdb, tabName) != NULL){
216 ndbout << tabName <<
" was found in DB"<< endl;
217 result = NDBT_FAILED;
225 Ndb* pNdb = GETNDB(step);
226 int result = NDBT_OK;
227 const char* tabName =
"TRANSACTION";
231 ndbout <<
"|- TRANSACTION" << endl;
235 result = NDBT_FAILED;
239 if (NDBT_Table::discoverTableFromDb(pNdb, tabName) != NULL){
240 ndbout << tabName <<
" was found in DB"<< endl;
241 result = NDBT_FAILED;
251 Ndb* pNdb = GETNDB(step);
252 int loops = ctx->getNumLoops();
256 ndbout <<
"|- " << pTab->
getName() << endl;
262 if (NDBT_Tables::createTable(pNdb, pTab->
getName()) != 0){
268 NDBT_Table::discoverTableFromDb(pNdb, pTab->
getName());
270 ndbout << pTab->
getName() <<
" was not found in DB"<< endl;
275 ndbout <<
"Failed to drop "<<pTab2->
getName()<<
" in db" << endl;
281 NDBT_Table::discoverTableFromDb(pNdb, pTab->
getName());
283 ndbout << pTab3->
getName() <<
" was found in DB"<< endl;
294 myRandom48Init((
long)NdbTick_CurrentMillisecond());
295 Ndb* pNdb = GETNDB(step);
297 int loops = ctx->getNumLoops();
298 int records = ctx->getNumRecords();
300 int numAllTables = NDBT_Tables::getNumTables();
304 TabList() { exists = -1; pTab = 0; }
306 TabList* tabList =
new TabList [ numAllTables ];
309 for (num = 0; num < numAllTables; num++) {
313 tabList[num].exists = 0;
319 const bool createIndexes = ctx->getProperty(
"CreateIndexes");
320 const bool loadData = ctx->getProperty(
"LoadData");
323 int result = NDBT_OK;
327 while (i < loops && result == NDBT_OK) {
328 num = myRandom48(numAllTables);
329 if (tabList[num].exists == -1)
331 g_info <<
"loop " << i <<
" tabs " << numExists <<
"/" << numTables << endl;
334 strcpy(tabName, pTab->
getName());
336 if (tabList[num].exists == 0) {
337 if (bias == 0 && myRandom48(100) < 80)
339 g_info << tabName <<
": create" << endl;
342 g_err << tabName <<
": create failed: " << err << endl;
343 result = NDBT_FAILED;
349 g_err << tabName <<
": verify create failed: " << err << endl;
350 result = NDBT_FAILED;
353 tabList[num].pTab = pTab2;
355 g_info << tabName <<
": load data" << endl;
357 if (hugoTrans.loadTable(pNdb, records) != 0) {
358 g_err << tabName <<
": loadTable failed" << endl;
359 result = NDBT_FAILED;
364 int icount = myRandom48(10);
366 for (inum = 0; inum < icount; inum++) {
369 int icols = 1 + myRandom48(tcols);
370 if (icols > NDB_MAX_ATTRIBUTES_IN_INDEX)
371 icols = NDB_MAX_ATTRIBUTES_IN_INDEX;
373 sprintf(indName,
"%s_X%d", tabName, inum);
375 ind.setTable(tabName);
377 ind.setLogging(
false);
382 for (ic = 0; ic < icols; ic++) {
383 int tc = myRandom48(tcols);
390 c->getStorageType() == NdbDictionary::Column::StorageTypeDisk)
394 sprintf(ilist + strlen(ilist),
" %d", tc);
398 g_info << indName <<
": columns:" << ilist << endl;
400 g_info << indName <<
": created" << endl;
403 g_err << indName <<
": create index failed: " << err << endl;
404 if (err.
code != 826 &&
411 result = NDBT_FAILED;
421 num3 = myRandom48(numAllTables);
422 if (num == num3 || tabList[num3].exists == 1)
428 strcpy(tabName3, pTab3->
getName());
430 g_info << tabName3 <<
": update data" << endl;
431 if (hugoTrans.pkUpdateRecords(pNdb, records) != 0) {
432 g_err << tabName3 <<
": pkUpdateRecords failed" << endl;
433 result = NDBT_FAILED;
439 g_info << tabName <<
": update data" << endl;
440 if (hugoTrans.pkUpdateRecords(pNdb, records) != 0) {
441 g_err <<
"pkUpdateRecords failed" << endl;
442 result = NDBT_FAILED;
446 tabList[num].exists = 1;
447 assert(numExists < numTables);
449 if (numExists == numTables)
452 else if (tabList[num].exists == 1) {
453 if (bias == 1 && myRandom48(100) < 80)
455 g_info << tabName <<
": drop" << endl;
456 if (restarter.insertErrorInAllNodes(4013) != 0) {
457 g_err <<
"error insert failed" << endl;
458 result = NDBT_FAILED;
463 g_err << tabName <<
": drop failed: " << err << endl;
464 result = NDBT_FAILED;
469 g_err << tabName <<
": verify drop: table exists" << endl;
470 result = NDBT_FAILED;
476 g_err << tabName <<
": verify drop: " << err << endl;
477 result = NDBT_FAILED;
480 tabList[num].exists = 0;
481 assert(numExists > 0);
489 for (num = 0; num < numAllTables; num++)
490 if (tabList[num].exists == 1)
491 pDic->
dropTable(NDBT_Tables::getTable(num)->getName());
499 Ndb* pNdb = GETNDB(step);
500 int loops = ctx->getNumLoops();
501 int records = ctx->getNumRecords();
505 int val = DumpStateOrd::DihMinTimeBetweenLCP;
506 if(restarter.dumpStateAllNodes(&val, 1) != 0){
508 do { CHECK(0); }
while (0);
509 g_err <<
"Unable to change timebetween LCP" << endl;
514 ndbout <<
"|- " << pTab->
getName() << endl;
520 if (NDBT_Tables::createTable(pNdb, pTab->
getName()) != 0){
526 NDBT_Table::discoverTableFromDb(pNdb, pTab->
getName());
528 ndbout << pTab->
getName() <<
" was not found in DB"<< endl;
533 if (hugoTrans.loadTable(pNdb, records) != 0){
539 if (utilTrans.selectCount(pNdb, 64, &count) != 0){
542 if (count != records){
543 ndbout << count <<
" != "<<records << endl;
548 ndbout <<
"Failed to drop "<<pTab2->
getName()<<
" in db" << endl;
554 NDBT_Table::discoverTableFromDb(pNdb, pTab->
getName());
556 ndbout << pTab3->
getName() <<
" was found in DB"<< endl;
568 Ndb* pNdb = GETNDB(step);
570 if (hugoTrans.fillTable(pNdb) != 0){
577 Ndb* pNdb = GETNDB(step);
578 int records = ctx->getNumRecords();
581 if (utilTrans.clearTable(pNdb, records) != 0){
588 int result = NDBT_OK;
589 int loops = ctx->getNumLoops();
593 ndbout <<
"|- " << pTab->
getName() << endl;
595 while (i < loops && result == NDBT_OK){
596 ndbout << i <<
": " << endl;
599 Ndb* pNdb = GETNDB(step);
600 g_debug <<
"Creating table" << endl;
602 if (NDBT_Tables::createTable(pNdb, pTab->
getName()) != 0){
603 g_err <<
"createTableInDb failed" << endl;
604 result = NDBT_FAILED;
608 g_debug <<
"Verifying creation of table" << endl;
612 NDBT_Table::discoverTableFromDb(pNdb, pTab->
getName());
614 g_err << pTab->
getName() <<
" was not found in DB"<< endl;
615 result = NDBT_FAILED;
619 NdbSleep_MilliSleep(3000);
621 g_debug <<
"Dropping table" << endl;
624 g_err <<
"Failed to drop "<<pTab2->
getName()<<
" in db" << endl;
625 result = NDBT_FAILED;
629 g_debug <<
"Verifying dropping of table" << endl;
633 NDBT_Table::discoverTableFromDb(pNdb, pTab->
getName());
635 g_err << pTab3->
getName() <<
" was found in DB"<< endl;
636 result = NDBT_FAILED;
648 int records = ctx->getNumRecords();
652 while (ctx->isTestStopped() ==
false) {
662 Ndb* pNdb = GETNDB(step);
665 NDBT_Table::discoverTableFromDb(pNdb, pTab->
getName());
671 if ((res = hugoTrans.loadTable(pNdb, records)) != 0){
679 if ((res = hugoTrans.clearTable(pNdb, records)) != 0){
692 int records = ctx->getNumRecords();
694 Ndb* pNdb = GETNDB(step);
697 NDBT_Table::discoverTableFromDb(pNdb, pTab->
getName());
701 while (ctx->isTestStopped() ==
false)
703 ndbout_c(
"loop: %u", i++);
714 if ((res = hugoTrans.loadTable(pNdb, records)) != 0){
722 if ((res = hugoTrans.scanUpdateRecords(pNdb, records)) != 0)
731 if ((res = hugoTrans.clearTable(pNdb, records)) != 0){
744 int records = ctx->getNumRecords();
746 Ndb* pNdb = GETNDB(step);
749 NDBT_Table::discoverTableFromDb(pNdb, pTab->
getName());
753 while (ctx->isTestStopped() ==
false)
755 ndbout_c(
"loop: %u", i++);
766 if ((res = hugoTrans.scanUpdateRecords(pNdb, records)) != 0)
784 int numTables = ctx->getProperty(
"tables", 1000);
785 Ndb* pNdb = GETNDB(step);
788 for (i = 0; i < numTables; i++) {
798 newTab.setName(tabName);
802 if (newTab.createTableInDb(pNdb) != 0) {
803 ndbout << tabName <<
" could not be created: "
814 NDBT_Table::discoverTableFromDb(pNdb, tabName) ;
816 ndbout << tabName <<
" was not found in DB: "
820 if (! newTab.equal(*pTab3)) {
821 ndbout <<
"It was not equal" << endl; abort();
824 int records = ctx->getNumRecords();
826 if (hugoTrans.loadTable(pNdb, records) != 0) {
827 ndbout <<
"It can NOT be loaded" << endl;
831 if (utilTrans.clearTable(pNdb, records, 64) != 0) {
832 ndbout <<
"It can NOT be cleared" << endl;
840 ctx->setProperty(
"maxtables", i);
848 int numTables = ctx->getProperty(
"maxtables", (Uint32)0);
849 Ndb* pNdb = GETNDB(step);
851 for (
int i = 0; i < numTables; i++) {
859 NDBT_Table::discoverTableFromDb(pNdb, tabName) ;
861 ndbout << tabName <<
" was not found in DB: "
867 ndbout << tabName <<
" could not be dropped: "
876 int records = ctx->getNumRecords();
877 int fragTtype = ctx->getProperty(
"FragmentType");
878 Ndb* pNdb = GETNDB(step);
879 int result = NDBT_OK;
895 if (newTab.createTableInDb(pNdb) != 0){
896 ndbout << newTab.getName() <<
" could not be created"
897 <<
", fragmentType = "<<fragTtype <<endl;
904 NDBT_Table::discoverTableFromDb(pNdb, pTab->
getName()) ;
906 ndbout << pTab->
getName() <<
" was not found in DB"<< endl;
912 ndbout << pTab->
getName() <<
" fragmentType error "<< endl;
913 result = NDBT_FAILED;
932 CHECK(hugoTrans.loadTable(pNdb, records) == 0);
933 CHECK(hugoTrans.pkUpdateRecords(pNdb, records) == 0);
934 CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
935 CHECK(count == records);
936 CHECK(hugoTrans.pkDelRecords(pNdb, records/2) == 0);
937 CHECK(hugoTrans.scanUpdateRecords(pNdb, records/2) == 0);
938 CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
939 CHECK(count == (records/2));
942 ndbout <<
"Restarting cluster" << endl;
943 CHECK(restarter.restartAll() == 0);
945 CHECK(restarter.waitClusterStarted(timeout) == 0);
949 CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
950 CHECK(count == (records/2));
952 CHECK(utilTrans.clearTable(pNdb, records) == 0);
953 CHECK(hugoTrans.loadTable(pNdb, records) == 0);
954 CHECK(utilTrans.clearTable(pNdb, records) == 0);
955 CHECK(hugoTrans.loadTable(pNdb, records) == 0);
956 CHECK(hugoTrans.pkUpdateRecords(pNdb, records) == 0);
957 CHECK(utilTrans.clearTable(pNdb, records, 64) == 0);
965 ndbout << pTab3->
getName() <<
" could not be dropped"<< endl;
966 result = NDBT_FAILED;
974 int result = NDBT_OK;
975 int loops = ctx->getNumLoops();
976 int records = ctx->getNumRecords();
977 Ndb* pNdb = GETNDB(step);
982 ndbout <<
"|- " << pTab->
getName() << endl;
986 newTab.setStoredTable(
false);
989 if (newTab.createTableInDb(pNdb) != 0){
995 NDBT_Table::discoverTableFromDb(pNdb, pTab->
getName());
997 ndbout << pTab->
getName() <<
" was not found in DB"<< endl;
1001 if (pTab2->getStoredTable() !=
false){
1002 ndbout << pTab->
getName() <<
" was not temporary in DB"<< endl;
1003 result = NDBT_FAILED;
1008 while (i < loops && result == NDBT_OK){
1009 ndbout << i <<
": ";
1012 CHECK(hugoTrans.loadTable(pNdb, records) == 0);
1016 CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
1017 CHECK(count == records);
1020 ndbout <<
"Restarting cluster" << endl;
1021 CHECK(restarter.restartAll() == 0);
1023 CHECK(restarter.waitClusterStarted(timeout) == 0);
1026 ndbout <<
"Verifying records..." << endl;
1027 CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
1037 ndbout <<
"Failed to drop "<<pTab2->
getName()<<
" in db" << endl;
1038 result = NDBT_FAILED;
1043 NDBT_Table::discoverTableFromDb(pNdb, pTab->
getName());
1045 ndbout << pTab3->
getName() <<
" was found in DB"<< endl;
1046 result = NDBT_FAILED;
1053 int result = NDBT_OK;
1056 ndbout <<
"minPkSize=" <<minPkSize<<endl;
1057 int maxPkSize = MAX_KEY_SIZE_IN_WORDS * 4;
1058 ndbout <<
"maxPkSize=" <<maxPkSize<<endl;
1059 Ndb* pNdb = GETNDB(step);
1060 int numRecords = ctx->getNumRecords();
1062 for (
int i = minPkSize; i < maxPkSize; i++){
1065 int records = numRecords;
1076 ndbout <<
"records =" << records << endl;
1083 ndbout <<
"|- " << tabName << endl;
1085 if (NDBT_Tables::createTable(pNdb, tabName) != 0){
1086 ndbout << tabName <<
" could not be created"<< endl;
1092 NDBT_Table::discoverTableFromDb(pNdb, tabName) ;
1094 g_err << tabName <<
" was not found in DB"<< endl;
1100 if (pTab3->
equal(*NDBT_Tables::getTable(tabName)) ==
false){
1101 g_err <<
"It was not equal" << endl;
1110 CHECK(hugoTrans.loadTable(pNdb, records) == 0);
1111 CHECK(hugoTrans.pkUpdateRecords(pNdb, records) == 0);
1112 CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
1113 CHECK(count == records);
1114 CHECK(hugoTrans.pkDelRecords(pNdb, records/2) == 0);
1115 CHECK(hugoTrans.scanUpdateRecords(pNdb, records/2) == 0);
1116 CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
1117 CHECK(count == (records/2));
1118 CHECK(utilTrans.clearTable(pNdb, records) == 0);
1122 CHECK(hugoTrans.fillTable(pNdb) == 0);
1123 CHECK(utilTrans.clearTable2(pNdb, records) == 0);
1124 CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
1131 ndbout <<
"Failed to drop "<<pTab3->
getName()<<
" in db" << endl;
1139 Ndb* pNdb = GETNDB(step);
1141 int result = NDBT_OK;
1142 int loops = ctx->getNumLoops();
1144 for (
int l = 0; l < loops && result == NDBT_OK ; l++){
1146 Uint32 dataLen = (Uint32)myRandom48(MAX_FRM_DATA_SIZE);
1148 unsigned char data[MAX_FRM_DATA_SIZE];
1150 char start = l + 248;
1151 for(Uint32 i = 0; i < dataLen; i++){
1156 ndbout <<
"dataLen="<<dataLen<<endl;
1157 for (Uint32 i = 0; i < dataLen; i++){
1158 unsigned char c = data[
i];
1159 ndbout << hex << c <<
", ";
1165 void* pData = &data;
1166 newTab.setFrm(pData, dataLen);
1169 if (newTab.createTableInDb(pNdb) != 0){
1170 result = NDBT_FAILED;
1176 NDBT_Table::discoverTableFromDb(pNdb, pTab->
getName());
1178 g_err << pTab->
getName() <<
" was not found in DB"<< endl;
1179 result = NDBT_FAILED;
1184 Uint32 resultLen = pTab2->getFrmLength();
1185 if (dataLen != resultLen){
1186 g_err <<
"Length of data failure" << endl
1187 <<
" expected = " << dataLen << endl
1188 <<
" got = " << resultLen << endl;
1189 result = NDBT_FAILED;
1193 if (memcmp(pData, pData2, resultLen) != 0){
1194 g_err <<
"Wrong data recieved" << endl;
1195 for (
size_t i = 0; i < dataLen; i++){
1196 unsigned char c = ((
unsigned char*)pData2)[
i];
1197 g_err << hex << c <<
", ";
1200 result = NDBT_FAILED;
1204 g_err <<
"It can NOT be dropped" << endl;
1205 result = NDBT_FAILED;
1213 Ndb* pNdb = GETNDB(step);
1215 int result = NDBT_OK;
1216 int loops = ctx->getNumLoops();
1218 for (
int l = 0; l < loops && result == NDBT_OK ; l++){
1220 const Uint32 dataLen = MAX_FRM_DATA_SIZE + 10;
1221 unsigned char data[dataLen];
1223 char start = l + 248;
1224 for(Uint32 i = 0; i < dataLen; i++){
1229 ndbout <<
"dataLen="<<dataLen<<endl;
1230 for (Uint32 i = 0; i < dataLen; i++){
1231 unsigned char c = data[
i];
1232 ndbout << hex << c <<
", ";
1239 void* pData = &data;
1240 newTab.setFrm(pData, dataLen);
1243 if (newTab.createTableInDb(pNdb) == 0){
1244 result = NDBT_FAILED;
1249 NDBT_Table::discoverTableFromDb(pNdb, pTab->
getName());
1251 g_err << pTab->
getName() <<
" was found in DB"<< endl;
1252 result = NDBT_FAILED;
1254 g_err <<
"It can NOT be dropped" << endl;
1255 result = NDBT_FAILED;
1272 g_err <<
"col->getPrimaryKey() != col2->getPrimaryKey()" << endl;
1277 if (!pTab->
equal(*pTab2)){
1278 g_err <<
"equal failed" << endl;
1287 Ndb* pNdb = GETNDB(step);
1289 ndbout <<
"|- " << pTab->
getName() << endl;
1292 if (pTab->createTableInDb(pNdb) != 0){
1297 NDBT_Table::discoverTableFromDb(pNdb, pTab->
getName());
1299 ndbout << pTab->
getName() <<
" was not found in DB"<< endl;
1303 int result = NDBT_OK;
1304 if (verifyTablesAreEqual(pTab, pTab2) != NDBT_OK)
1305 result = NDBT_FAILED;
1312 sprintf(name,
"%s_X007", pTab->
getName());
1313 NDBT_Index* pInd =
new NDBT_Index(name);
1314 pInd->setTable(pTab->
getName());
1317 for (
int i = 0; i < 2; i++){
1319 pInd->addAttribute(*pAttr);
1321 g_info <<
"Create index:" << endl << *pInd;
1322 if (pInd->createIndexInDb(pNdb,
false) != 0){
1323 result = NDBT_FAILED;
1328 NDBT_Table::discoverTableFromDb(pNdb, pTab->
getName());
1330 ndbout << pTab->
getName() <<
" was not found in DB"<< endl;
1334 if (verifyTablesAreEqual(pTab, pTab3) != NDBT_OK)
1335 result = NDBT_FAILED;
1336 if (verifyTablesAreEqual(pTab2, pTab3) != NDBT_OK)
1337 result = NDBT_FAILED;
1341 if (pTab2->getDictionary()->dropTable(pNdb) != 0){
1342 ndbout <<
"Failed to drop "<<pTab2->
getName()<<
" in db" << endl;
1348 NDBT_Table::discoverTableFromDb(pNdb, pTab->
getName());
1350 ndbout << pTab4->
getName() <<
" was found in DB"<< endl;
1358 #define APIERROR(error) \
1359 { g_err << "Error in " << __FILE__ << ", line:" << __LINE__ << ", code:" \
1360 << error.code << ", msg: " << error.message << "." << endl; \
1366 Uint32 startvalues[5] = {256-2, 0, 256*256-2, ~Uint32(0), 256*256*256-2};
1370 for (
int jj = 0; jj < 5 && ret == NDBT_OK; jj++) {
1371 char tabname[] =
"AUTOINCTAB";
1372 Uint32 startvalue = startvalues[jj];
1377 Ndb* myNdb = GETNDB(step);
1381 if (myDict->
getTable(tabname) != NULL) {
1382 g_err <<
"NDB already has example table: " << tabname << endl;
1394 myColumn.setAutoIncrement(
true);
1395 if (startvalue != ~Uint32(0))
1396 myColumn.setAutoIncrementInitialValue(startvalue);
1400 g_err <<
"Failed to create table " << tabname << endl;
1406 if (startvalue == ~Uint32(0))
1409 for (
int i = 0; i < 16; i++) {
1412 if (myNdb->getAutoIncrementValue(tabname, value, 1) == -1) {
1413 g_err <<
"getAutoIncrementValue failed on " << tabname << endl;
1417 else if (value != (startvalue+i)) {
1418 g_err <<
"value = " << value <<
" expected " << startvalue+i << endl;;
1426 g_err <<
"Failed to drop table " << tabname << endl;
1438 int result = NDBT_OK;
1440 Ndb* pNdb = GETNDB(step);
1442 int records = ctx->getNumRecords();
1443 const int loops = ctx->getNumLoops();
1445 ndbout <<
"|- " << ctx->getTab()->
getName() << endl;
1447 for (
int l = 0; l < loops && result == NDBT_OK ; l++){
1451 if (pTab->createTableInDb(pNdb) != 0){
1457 NDBT_Table::discoverTableFromDb(pNdb, pTab->
getName());
1459 ndbout << pTab->
getName() <<
" was not found in DB"<< endl;
1466 if (hugoTrans.loadTable(pNdb, records) != 0){
1473 pTabNewName.append(
"xx");
1478 newTable.
setName(pTabNewName.c_str());
1479 CHECK2(dict->
alterTable(*oldTable, newTable) == 0,
1480 "TableRename failed");
1483 result = NDBT_FAILED;
1490 if (utilTrans.clearTable(pNdb, records) != 0){
1505 if(restarter.getNumDbNodes() < 2)
1508 int result = NDBT_OK;
1510 Ndb* pNdb = GETNDB(step);
1512 int records = ctx->getNumRecords();
1513 const int loops = ctx->getNumLoops();
1515 ndbout <<
"|- " << ctx->getTab()->
getName() << endl;
1517 for (
int l = 0; l < loops && result == NDBT_OK ; l++){
1522 if (pTab->createTableInDb(pNdb) != 0){
1528 NDBT_Table::discoverTableFromDb(pNdb, pTab->
getName());
1530 ndbout << pTab->
getName() <<
" was not found in DB"<< endl;
1537 if (hugoTrans.loadTable(pNdb, records) != 0){
1543 pTabNewName.append(
"xx");
1548 newTable.
setName(pTabNewName.c_str());
1549 CHECK2(dict->
alterTable(*oldTable, newTable) == 0,
1550 "TableRename failed");
1553 result = NDBT_FAILED;
1562 int val = DumpStateOrd::DihMinTimeBetweenLCP;
1563 if(restarter.dumpStateAllNodes(&val, 1) != 0){
1564 do { CHECK(0); }
while(0);
1565 g_err <<
"Failed to set LCP to min value" << endl;
1569 CHECK2(restarter.restartAll() == 0,
1570 "failed to set restartOneDbNode");
1572 CHECK2(restarter.waitClusterStarted() == 0,
1573 "waitClusterStarted failed");
1579 if (utilTrans.clearTable(pNdb, records) != 0){
1596 int result = NDBT_OK;
1598 Ndb* pNdb = GETNDB(step);
1600 int records = ctx->getNumRecords();
1601 const int loops = ctx->getNumLoops();
1603 ndbout <<
"|- " << ctx->getTab()->
getName() << endl;
1607 for (
int l = 0; l < loops && result == NDBT_OK ; l++){
1610 if (NDBT_Tables::createTable(pNdb, myTab.
getName()) != 0){
1616 NDBT_Table::discoverTableFromDb(pNdb, myTab.
getName());
1618 ndbout << myTab.
getName() <<
" was not found in DB"<< endl;
1630 for (Uint32 i= 0; (col= pTab2->
getColumn(i)) != 0; i++)
1632 if (col->getStorageType() == NDB_STORAGETYPE_MEMORY &&
1633 (col->
getDynamic() || col->getArrayType() != NDB_ARRAYTYPE_FIXED))
1646 if (beforeTrans.loadTable(pNdb, records) != 0){
1659 NdbDictionary::Column::StorageTypeMemory,
true);
1663 NdbDictionary::Column::StorageTypeMemory,
true);
1667 NdbDictionary::Column::StorageTypeMemory,
true);
1671 NdbDictionary::Column::StorageTypeMemory,
true);
1674 CHECK2(dict->
alterTable(*oldTable, newTable) == 0,
1675 "TableAddAttrs failed");
1680 result = NDBT_FAILED;
1686 ndbout <<
"delete...";
1687 if (afterTrans.clearTable(pNdb) != 0)
1693 ndbout <<
"insert...";
1694 if (afterTrans.loadTable(pNdb, records) != 0){
1699 ndbout <<
"update...";
1700 if (afterTrans.scanUpdateRecords(pNdb, records) != 0)
1706 ndbout <<
"delete...";
1707 if (afterTrans.clearTable(pNdb) != 0)
1729 int result = NDBT_OK;
1730 int abortAlter = ctx->getProperty(
"AbortAlter", Uint32(0));
1732 int records = ctx->getNumRecords();
1733 const int loops = ctx->getNumLoops();
1736 ndbout <<
"|- " << ctx->getTab()->
getName() << endl;
1743 for (Uint32 i= 0; (col= myTab.
getColumn(i)) != 0; i++)
1745 if (col->getStorageType() == NDB_STORAGETYPE_MEMORY &&
1746 (col->
getDynamic() || col->getArrayType() != NDB_ARRAYTYPE_FIXED))
1758 for (
int l = 0; l < loops && result == NDBT_OK ; l++){
1759 ndbout << l <<
": " << endl;
1761 Ndb* pNdb = GETNDB(step);
1770 ndbout <<
"Altering table" << endl;
1780 NdbDictionary::Column::StorageTypeMemory,
true);
1784 if (abortAlter == 0)
1786 CHECK2(dict->
alterTable(*oldTable, newTable) == 0,
1787 "TableAddAttrsDuring failed");
1791 int nodeId = res.getNode(NdbRestarter::NS_RANDOM);
1792 res.insertErrorInNode(nodeId, 4029);
1793 CHECK2(dict->
alterTable(*oldTable, newTable) != 0,
1794 "TableAddAttrsDuring failed");
1800 hugoTrans.scanUpdateRecords(pNdb, records);
1803 result= NDBT_FAILED;
1827 Ndb* pNdb = GETNDB(step);
1829 const Uint32 count = NDBT_Tables::getNumTables();
1830 for (i=0; i < (int)count; i++){
1837 cols.push_back((
char*)tab2);
1842 const Uint32 times = 10000000;
1844 ndbout_c(
"%d tables and %d columns",
1845 NDBT_Tables::getNumTables(), cols.size()/2);
1847 char ** tcols = cols.getBase();
1849 srand((
unsigned int)time(0));
1850 Uint32
size = cols.size() / 2;
1852 Uint64 start = NdbTick_CurrentMillisecond();
1853 for(i = 0; i<(int)times; i++){
1854 int j = 2 * (rand() %
size);
1856 const char * col = tcols[j+1];
1860 Uint64 stop = NdbTick_CurrentMillisecond();
1867 ndbout_c(
"%d random getColumn(name) in %Ld ms -> %u us/get",
1868 times, stop, Uint32(per));
1875 Ndb* pNdb = GETNDB(step);
1877 lg.setName(
"DEFAULT-LG");
1878 lg.setUndoBufferSize(8*1024*1024);
1883 g_err <<
"Failed to create logfilegroup:"
1889 uf.setPath(
"undofile01.dat");
1890 uf.setSize(5*1024*1024);
1891 uf.setLogfileGroup(
"DEFAULT-LG");
1895 g_err <<
"Failed to create undofile:"
1900 uf.setPath(
"undofile02.dat");
1901 uf.setSize(5*1024*1024);
1902 uf.setLogfileGroup(
"DEFAULT-LG");
1906 g_err <<
"Failed to create undofile:"
1916 Ndb* pNdb = GETNDB(step);
1918 lg.setName(
"DEFAULT-TS");
1919 lg.setExtentSize(1024*1024);
1920 lg.setDefaultLogfileGroup(
"DEFAULT-LG");
1925 g_err <<
"Failed to create tablespace:"
1931 uf.setPath(
"datafile01.dat");
1932 uf.setSize(10*1024*1024);
1933 uf.setTablespace(
"DEFAULT-TS");
1937 g_err <<
"Failed to create datafile:"
1946 Ndb* pNdb = GETNDB(step);
1949 tab.setTablespaceName(
"DEFAULT-TS");
1953 tab.
getColumn(i)->setStorageType(NdbDictionary::Column::StorageTypeDisk);
1958 g_err <<
"Failed to create table:"
1969 if (c->getArrayType() == NDB_ARRAYTYPE_FIXED)
1975 attrDesc.AttributeExtType= c->
getType();
1976 attrDesc.AttributeExtLength= c->
getLength();
1978 attrDesc.AttributeExtScale= c->
getScale();
1980 if (!attrDesc.translateExtType())
1985 if (attrDesc.AttributeSize == 0)
1988 length = 4 * ((c->
getLength() + 31) / 32);
1992 length = ((1 << attrDesc.AttributeSize) * c->
getLength()) >> 3;
1999 #include <NDBT_Tables.hpp>
2004 static int acclst[] = { 3001, 6200, 6202 };
2005 static int tuplst[] = { 4007, 4008, 4009, 4010, 4032, 4033, 4034 };
2006 static int tuxlst[] = { 12001, 12002, 12003, 12004,
2008 static unsigned acccnt =
sizeof(acclst)/
sizeof(acclst[0]);
2009 static unsigned tupcnt =
sizeof(tuplst)/
sizeof(tuplst[0]);
2010 static unsigned tuxcnt =
sizeof(tuxlst)/
sizeof(tuxlst[0]);
2013 int nodeId = restarter.getMasterNodeId();
2014 Ndb* pNdb = GETNDB(step);
2021 if (NdbEnv_GetEnv(
"ERRNO", buf,
sizeof(buf)))
2024 ndbout_c(
"Using errno: %u", errNo);
2037 if (myRandom48(2) == 0)
2039 char defaultBuf[ NDB_MAX_TUPLE_SIZE ];
2041 Uint32 updatesVal = myRandom48(1 << 16);
2042 const char* def= calc.calcValue(0, colNum, updatesVal,
2044 getColumnMaxLength(origCol),
2048 ndbout_c(
"Error setting default value\n");
2052 ndbout <<
"Set default for column " << origCol->
getName()
2055 NdbDictionary::printFormattedValue(ndbout,
2068 idx.setLogging(
false);
2069 for (
int cnt = 0, i_hate_broken_compilers = 0;
2072 i_hate_broken_compilers++) {
2073 if (NdbSqlUtil::check_column_for_ordered_index
2075 tab.
getColumn(i_hate_broken_compilers)->getStorageType() !=
2076 NdbDictionary::Column::StorageTypeDisk)
2078 idx.addColumn(*tab.
getColumn(i_hate_broken_compilers));
2085 if (tab.
getColumn(i)->getStorageType() ==
2086 NdbDictionary::Column::StorageTypeDisk)
2088 NDBT_Tables::create_default_tablespace(pNdb);
2093 const int loops = ctx->getNumLoops();
2094 int result = NDBT_OK;
2097 int dump1 = DumpStateOrd::SchemaResourceSnapshot;
2098 int dump2 = DumpStateOrd::SchemaResourceCheckLeak;
2100 for (
int l = 0; l < loops; l++) {
2101 for (
unsigned i0 = 0; i0 < acccnt; i0++) {
2102 unsigned j = (l == 0 ? i0 : myRandom48(acccnt));
2103 int errval = acclst[j];
2104 if (errNo != 0 && errNo != errval)
2106 g_err <<
"insert error node=" << nodeId <<
" value=" << errval << endl;
2107 CHECK(restarter.dumpStateAllNodes(&dump1, 1) == 0);
2108 CHECK2(restarter.insertErrorInNode(nodeId, errval) == 0,
2109 "failed to set error insert");
2110 NdbSleep_MilliSleep(SAFTY);
2112 "failed to fail after error insert " << errval);
2113 CHECK2(restarter.insertErrorInNode(nodeId, 0) == 0,
2114 "failed to clean error insert value");
2115 CHECK(restarter.dumpStateAllNodes(&dump2, 1) == 0);
2116 NdbSleep_MilliSleep(SAFTY);
2122 for (
unsigned i1 = 0; i1 < tupcnt; i1++) {
2123 unsigned j = (l == 0 ? i1 : myRandom48(tupcnt));
2124 int errval = tuplst[j];
2125 if (errNo != 0 && errNo != errval)
2127 g_err <<
"insert error node=" << nodeId <<
" value=" << errval << endl;
2128 CHECK(restarter.dumpStateAllNodes(&dump1, 1) == 0);
2129 CHECK2(restarter.insertErrorInNode(nodeId, errval) == 0,
2130 "failed to set error insert");
2131 NdbSleep_MilliSleep(SAFTY);
2133 "failed to fail after error insert " << errval);
2134 CHECK2(restarter.insertErrorInNode(nodeId, 0) == 0,
2135 "failed to clean error insert value");
2136 CHECK(restarter.dumpStateAllNodes(&dump2, 1) == 0);
2137 NdbSleep_MilliSleep(SAFTY);
2143 for (
unsigned i2 = 0; i2 < tuxcnt; i2++) {
2144 unsigned j = (l == 0 ? i2 : myRandom48(tuxcnt));
2145 int errval = tuxlst[j];
2146 if (errNo != 0 && errNo != errval)
2151 g_err <<
"insert error node=" << nodeId <<
" value=" << errval << endl;
2152 CHECK(restarter.dumpStateAllNodes(&dump1, 1) == 0);
2153 CHECK2(restarter.insertErrorInNode(nodeId, errval) == 0,
2154 "failed to set error insert");
2155 NdbSleep_MilliSleep(SAFTY);
2158 "failed to fail after error insert " << errval);
2159 CHECK2(restarter.insertErrorInNode(nodeId, 0) == 0,
2160 "failed to clean error insert value");
2161 CHECK(restarter.dumpStateAllNodes(&dump2, 1) == 0);
2162 NdbSleep_MilliSleep(SAFTY);
2181 ctx->setProperty(
"DictOps_CMD", cmd);
2183 if (ctx->isTestStopped())
2185 if (ctx->getProperty(
"DictOps_ACK") == cmd)
2187 NdbSleep_MilliSleep(100);
2196 if (ctx->isTestStopped())
2198 Uint32 cmd = ctx->getProperty(
"DictOps_CMD");
2199 ctx->setProperty(
"DictOps_ACK", cmd);
2204 NdbSleep_MilliSleep(100);
2212 static int errlst_master[] = {
2216 static int errlst_node[] = {
2222 const uint errcnt_master =
sizeof(errlst_master)/
sizeof(errlst_master[0]);
2223 const uint errcnt_node =
sizeof(errlst_node)/
sizeof(errlst_node[0]);
2225 myRandom48Init((
long)NdbTick_CurrentMillisecond());
2227 int result = NDBT_OK;
2228 const int loops = ctx->getNumLoops();
2230 for (
int l = 0; l < loops && result == NDBT_OK; l++) {
2231 g_info <<
"1: === loop " << l <<
" ===" << endl;
2235 int numnodes = restarter.getNumDbNodes();
2236 CHECK(numnodes >= 1);
2240 int masterNodeId = restarter.getMasterNodeId();
2241 CHECK(masterNodeId != -1);
2245 int nodeIdList[2] = { 0, 0 };
2248 if (numnodes >= 2) {
2249 int rand = myRandom48(numnodes);
2250 int nodeId = restarter.getRandomNotMasterNodeId(rand);
2251 CHECK(nodeId != -1);
2252 nodeIdList[nodeIdCnt++] = nodeId;
2255 if (numnodes >= 4 && myRandom48(2) == 0) {
2256 int rand = myRandom48(numnodes);
2257 int nodeId = restarter.getRandomNodeOtherNodeGroup(nodeIdList[0], rand);
2258 CHECK(nodeId != -1);
2259 if (nodeId != masterNodeId)
2260 nodeIdList[nodeIdCnt++] = nodeId;
2263 g_info <<
"1: master=" << masterNodeId <<
" nodes=" << nodeIdList[0] <<
"," << nodeIdList[1] << endl;
2265 const uint timeout = 60;
2266 const unsigned maxsleep = 2000;
2268 bool NF_ops = ctx->getProperty(
"Restart_NF_ops");
2269 uint NF_type = ctx->getProperty(
"Restart_NF_type");
2270 bool NR_ops = ctx->getProperty(
"Restart_NR_ops");
2271 bool NR_error = ctx->getProperty(
"Restart_NR_error");
2273 g_info <<
"1: " << (NF_ops ?
"run" :
"pause") <<
" dict ops" << endl;
2274 if (! send_dict_ops_cmd(ctx, NF_ops ? 1 : 2))
2276 NdbSleep_MilliSleep(myRandom48(maxsleep));
2279 for (
int i = 0; i < nodeIdCnt; i++) {
2280 int nodeId = nodeIdList[
i];
2282 bool nostart =
true;
2283 bool abort = NF_type == 0 ? myRandom48(2) : (NF_type == 2);
2284 bool initial = myRandom48(2);
2287 strcpy(flags,
"flags: nostart");
2289 strcat(flags,
",abort");
2291 strcat(flags,
",initial");
2293 g_info <<
"1: restart " << nodeId <<
" " << flags << endl;
2294 CHECK(restarter.restartOneDbNode(nodeId, initial, nostart, abort) == 0);
2298 g_info <<
"1: wait for nostart" << endl;
2299 CHECK(restarter.waitNodesNoStart(nodeIdList, nodeIdCnt, timeout) == 0);
2300 NdbSleep_MilliSleep(myRandom48(maxsleep));
2303 int err_node[2] = { 0, 0 };
2306 err_master = errlst_master[l % errcnt_master];
2311 for (
int i = 0; i < nodeIdCnt && nodeIdCnt == 1; i++) {
2312 err_node[
i] = errlst_node[l % errcnt_node];
2316 if (err_node[i] == 7176) {
2317 g_info <<
"1: no dict ops due to error insert "
2318 << err_node[
i] << endl;
2324 g_info <<
"1: " << (NR_ops ?
"run" :
"pause") <<
" dict ops" << endl;
2325 if (! send_dict_ops_cmd(ctx, NR_ops ? 1 : 2))
2327 NdbSleep_MilliSleep(myRandom48(maxsleep));
2329 g_info <<
"1: start nodes" << endl;
2330 CHECK(restarter.startNodes(nodeIdList, nodeIdCnt) == 0);
2334 int err = err_master;
2336 g_info <<
"1: insert master error " << err << endl;
2337 CHECK(restarter.insertErrorInNode(masterNodeId, err) == 0);
2341 for (
int i = 0; i < nodeIdCnt; i++) {
2342 int nodeId = nodeIdList[
i];
2344 int err = err_node[
i];
2346 g_info <<
"1: insert node " << nodeId <<
" error " << err << endl;
2347 CHECK(restarter.insertErrorInNode(nodeId, err) == 0);
2351 NdbSleep_MilliSleep(myRandom48(maxsleep));
2353 g_info <<
"1: wait cluster started" << endl;
2354 CHECK(restarter.waitClusterStarted(timeout) == 0);
2355 NdbSleep_MilliSleep(myRandom48(maxsleep));
2357 g_info <<
"1: restart done" << endl;
2360 g_info <<
"1: stop dict ops" << endl;
2361 send_dict_ops_cmd(ctx, 3);
2369 myRandom48Init((
long)NdbTick_CurrentMillisecond());
2370 int result = NDBT_OK;
2372 for (
int l = 0; result == NDBT_OK; l++) {
2373 if (! recv_dict_ops_run(ctx))
2376 g_info <<
"2: === loop " << l <<
" ===" << endl;
2378 Ndb* pNdb = GETNDB(step);
2383 strcpy(tabName, pTab->
getName());
2385 const unsigned long maxsleep = 100;
2387 g_info <<
"2: create table" << endl;
2395 g_err <<
"2: " << tabName <<
": create failed: " << err << endl;
2396 if (err.
code != 711) {
2397 result = NDBT_FAILED;
2400 NdbSleep_MilliSleep(myRandom48(maxsleep));
2404 NdbSleep_MilliSleep(myRandom48(maxsleep));
2406 g_info <<
"2: verify create" << endl;
2408 if (pTab2 == NULL) {
2410 g_err <<
"2: " << tabName <<
": verify create: " << err << endl;
2411 result = NDBT_FAILED;
2414 NdbSleep_MilliSleep(myRandom48(maxsleep));
2420 const char** indlist = NDBT_Tables::getIndexes(tabName);
2422 while (indlist != 0 && *indlist != 0) {
2427 g_info <<
"2: create index " << indnum <<
" " << *indlist << endl;
2430 sprintf(indName,
"%s_X%u", tabName, indnum);
2433 if (strcmp(*indlist,
"UNIQUE") == 0) {
2436 }
else if (strcmp(*indlist,
"ORDERED") == 0) {
2442 const char** indtemp = indlist;
2443 while (*++indtemp != 0) {
2449 g_err <<
"2: " << indName <<
": create failed: " << err << endl;
2450 if (err.
code != 711) {
2451 result = NDBT_FAILED;
2454 NdbSleep_MilliSleep(myRandom48(maxsleep));
2455 goto try_create_index;
2457 indlist = ++indtemp;
2460 if (result == NDBT_FAILED)
2463 uint indcount = indnum;
2465 int records = myRandom48(ctx->getNumRecords());
2466 g_info <<
"2: load " << records <<
" records" << endl;
2468 if (hugoTrans.loadTable(pNdb, records) != 0) {
2470 g_err <<
"2: " << tabName <<
": load failed" << endl;
2471 result = NDBT_FAILED;
2474 NdbSleep_MilliSleep(myRandom48(maxsleep));
2478 while (indnum < indcount) {
2483 g_info <<
"2: drop index " << indnum << endl;
2485 sprintf(indName,
"%s_X%u", tabName, indnum);
2486 if (pDic->
dropIndex(indName, tabName) != 0) {
2489 g_err <<
"2: " << indName <<
": drop failed: " << err << endl;
2490 if (err.
code != 711) {
2491 result = NDBT_FAILED;
2494 NdbSleep_MilliSleep(myRandom48(maxsleep));
2495 goto try_drop_index;
2499 if (result == NDBT_FAILED)
2502 g_info <<
"2: drop" << endl;
2510 g_err <<
"2: " << tabName <<
": drop failed: " << err << endl;
2511 if (err.
code != 711) {
2512 result = NDBT_FAILED;
2515 NdbSleep_MilliSleep(myRandom48(maxsleep));
2519 NdbSleep_MilliSleep(myRandom48(maxsleep));
2521 g_info <<
"2: verify drop" << endl;
2523 if (pTab3 != NULL) {
2524 g_err <<
"2: " << tabName <<
": verify drop: table exists" << endl;
2525 result = NDBT_FAILED;
2531 g_err <<
"2: " << tabName <<
": verify drop: " << err << endl;
2532 result = NDBT_FAILED;
2535 NdbSleep_MilliSleep(myRandom48(maxsleep));
2549 if (res.getNumDbNodes() < 2)
2552 Ndb* pNdb = GETNDB(step);
2566 idx0.setStoredIndex(
false);
2592 t0.loadTable(pNdb, 1000);
2597 t1.loadTable(pNdb, 1000);
2600 int node = res.getRandomNotMasterNodeId(rand());
2601 res.restartOneDbNode(node,
false,
true,
true);
2617 res.waitNodesNoStart(&node, 1);
2618 res.startNodes(&node, 1);
2620 if (res.waitClusterStarted())
2637 const char * lgname,
2638 const char * tsname,
2639 const char * dfname)
2643 ts.setExtentSize(1024*1024);
2644 ts.setDefaultLogfileGroup(lgname);
2646 if(pDict->createTablespace(ts) != 0)
2648 g_err <<
"Failed to create tablespace:"
2655 df.setSize(1*1024*1024);
2656 df.setTablespace(tsname);
2658 if(pDict->createDatafile(df) != 0)
2660 g_err <<
"Failed to create datafile:"
2676 if (res.getNumDbNodes() < 2)
2679 Ndb* pNdb = GETNDB(step);
2686 const char * lgfound = 0;
2688 for (Uint32 i = 0; i<list.
count; i++)
2707 lg.setUndoBufferSize(8*1024*1024);
2708 if(pDict->createLogfileGroup(lg) != 0)
2710 g_err <<
"Failed to create logfilegroup:"
2718 uf.setSize(2*1024*1024);
2719 uf.setLogfileGroup(lgname);
2721 if(pDict->createUndofile(uf) != 0)
2723 g_err <<
"Failed to create undofile:"
2736 if (create_tablespace(pDict, lgname, tsname, dfname))
2740 int node = res.getRandomNotMasterNodeId(rand());
2741 res.restartOneDbNode(node,
false,
true,
true);
2742 NdbSleep_SecSleep(3);
2744 if (pDict->dropDatafile(pDict->getDatafile(0, dfname)) != 0)
2746 g_err <<
"Failed to drop datafile: " << pDict->
getNdbError() << endl;
2750 if (pDict->dropTablespace(pDict->getTablespace(tsname)) != 0)
2752 g_err <<
"Failed to drop tablespace: " << pDict->
getNdbError() << endl;
2756 if (res.waitNodesNoStart(&node, 1))
2759 res.startNodes(&node, 1);
2760 if (res.waitClusterStarted())
2763 if (create_tablespace(pDict, lgname, tsname, dfname))
2766 if (pDict->dropDatafile(pDict->getDatafile(0, dfname)) != 0)
2768 g_err <<
"Failed to drop datafile: " << pDict->
getNdbError() << endl;
2772 if (pDict->dropTablespace(pDict->getTablespace(tsname)) != 0)
2774 g_err <<
"Failed to drop tablespace: " << pDict->
getNdbError() << endl;
2780 if (pDict->dropLogfileGroup(pDict->getLogfileGroup(lgname)) != 0)
2790 int lgError = 15000;
2791 int tsError = 16000;
2799 if (restarter.getNumDbNodes() < 2){
2804 Ndb* pNdb = GETNDB(step);
2812 const char * lgfound = 0;
2814 for (Uint32 i = 0; i<list.
count; i++)
2833 lg.setUndoBufferSize(8*1024*1024);
2834 if(pDict->createLogfileGroup(lg) != 0)
2836 g_err <<
"Failed to create logfilegroup:"
2846 if(restarter.waitClusterStarted(60)){
2847 g_err <<
"waitClusterStarted failed"<< endl;
2851 if(restarter.insertErrorInAllNodes(lgError) != 0){
2852 g_err <<
"failed to set error insert"<< endl;
2856 g_info <<
"error inserted" << endl;
2857 g_info <<
"waiting some before add log file" << endl;
2858 g_info <<
"starting create log file group" << endl;
2863 uf.setSize(2*1024*1024);
2864 uf.setLogfileGroup(lgname);
2866 if(pDict->createUndofile(uf) == 0)
2868 g_err <<
"Create log file group should fail on error_insertion " << lgError << endl;
2873 if(restarter.insertErrorInAllNodes(15099) != 0){
2874 g_err <<
"failed to set error insert"<< endl;
2877 NdbSleep_SecSleep(5);
2880 if(pDict->createUndofile(uf) != 0)
2882 g_err <<
"Failed to create undofile:"
2887 if(restarter.waitClusterStarted(60)){
2888 g_err <<
"waitClusterStarted failed"<< endl;
2892 if(restarter.insertErrorInAllNodes(tsError) != 0){
2893 g_err <<
"failed to set error insert"<< endl;
2896 g_info <<
"error inserted" << endl;
2897 g_info <<
"waiting some before create table space" << endl;
2898 g_info <<
"starting create table space" << endl;
2906 ts.setExtentSize(1024*1024);
2907 ts.setDefaultLogfileGroup(lgname);
2909 if(pDict->createTablespace(ts) != 0)
2911 g_err <<
"Failed to create tablespace:"
2918 df.setSize(1*1024*1024);
2919 df.setTablespace(tsname);
2921 if(pDict->createDatafile(df) == 0)
2923 g_err <<
"Create table space should fail on error_insertion " << tsError << endl;
2927 if(restarter.insertErrorInAllNodes(16099) != 0){
2928 g_err <<
"failed to set error insert"<< endl;
2931 NdbSleep_SecSleep(5);
2933 if (pDict->dropTablespace(pDict->getTablespace(tsname)) != 0)
2935 g_err <<
"Failed to drop tablespace: " << pDict->
getNdbError() << endl;
2941 if (pDict->dropLogfileGroup(pDict->getLogfileGroup(lgname)) != 0)
2953 ownseed = (unsigned)NdbTick_CurrentMillisecond();
2965 struct Obj* m_parent;
2971 int schema_op(
Ndb*);
2975 Obj* get_obj(Uint32 mask);
2977 int create_index(
Ndb*,
Obj*);
2978 int alter_table(
Ndb*,
Obj*);
2981 void remove_obj(
Obj*);
2990 RandSchemaOp::schema_op(
Ndb* ndb)
2992 struct Obj* obj = 0;
2995 switch(ndb_rand_r(seed) % 5){
3001 return create_index(ndb, obj);
3013 return alter_table(ndb, obj);
3019 if ((obj = get_obj(type)) == 0)
3025 RandSchemaOp::get_obj(Uint32 mask)
3028 for (Uint32 i = 0; i<m_objects.size(); i++)
3030 if ((1 << m_objects[i]->m_type) & mask)
3031 tmp.push_back(m_objects[i]);
3036 return tmp[ndb_rand_r(seed)%tmp.size()];
3044 int numTables = NDBT_Tables::getNumTables();
3045 int num = ndb_rand_r(seed) % numTables;
3049 pTab.setForceVarPart(
true);
3055 pTab.
getName(), ndb_rand_r(seed));
3062 if (NDBT_Tables::createTable(ndb, pTab.
getName()))
3068 ndbout_c(
"create table %s", pTab.
getName());
3071 trans.loadTable(ndb, 1000);
3074 obj->m_name.assign(pTab.
getName());
3077 m_objects.push_back(obj);
3083 RandSchemaOp::create_index(
Ndb* ndb, Obj* tab)
3093 bool ordered = ndb_rand_r(seed) & 1;
3094 bool stored = ndb_rand_r(seed) & 1;
3096 Uint32 type = ordered ?
3103 ordered ?
"OI" :
"UI");
3111 ndbout_c(
"create index %s", buf);
3116 idx0.setStoredIndex(ordered ?
false : stored);
3129 obj->m_name.assign(buf);
3131 obj->m_parent = tab;
3132 m_objects.push_back(obj);
3134 tab->m_dependant.push_back(obj);
3145 ndbout_c(
"drop table %s", obj->m_name.
c_str());
3153 while(obj->m_dependant.size())
3155 remove_obj(obj->m_dependant[0]);
3162 ndbout_c(
"drop index %s", obj->m_name.
c_str());
3164 obj->m_parent->m_name.
c_str()))
3174 RandSchemaOp::remove_obj(Obj* obj)
3180 for (i = 0; i<obj->m_parent->m_dependant.size(); i++)
3182 if (obj->m_parent->m_dependant[i] == obj)
3185 obj->m_parent->m_dependant.erase(i);
3194 for (i = 0; i<m_objects.size(); i++)
3196 if (m_objects[i] == obj)
3209 RandSchemaOp::alter_table(
Ndb* ndb, Obj* obj)
3219 while (ops.
length() == 0 && (mask != 0))
3221 switch((type = (ndb_rand_r(seed) & 1))){
3224 if ((mask & (1 << type)) == 0)
3237 ndbout_c(
"not supported...");
3238 mask &= ~(1 <<
type);
3249 unsigned no = ndb_rand_r(seed);
3262 ndbout_c(
"altering %s ops: %s", pOld->
getName(), ops.
c_str());
3271 obj->m_name.assign(tNew.
getName());
3280 RandSchemaOp::validate(
Ndb* ndb)
3283 for (Uint32 i = 0; i<m_objects.size(); i++)
3288 pDict->
getTable(m_objects[i]->m_name.c_str());
3290 trans.scanUpdateRecords(ndb, 1000);
3291 trans.clearTable(ndb);
3292 trans.loadTable(ndb, 1000);
3315 RandSchemaOp::cleanup(
Ndb* ndb)
3318 for (i = m_objects.size() - 1; i >= 0; i--)
3320 switch(m_objects[i]->m_type){
3332 for (i = m_objects.size() - 1; i >= 0; i--)
3334 switch(m_objects[i]->m_type){
3344 assert(m_objects.size() == 0);
3348 extern unsigned opt_seed;
3353 Ndb* pNdb = GETNDB(step);
3354 int loops = ctx->getNumLoops();
3356 unsigned seed = opt_seed;
3359 if (res.getNumDbNodes() < 2)
3362 if (res.init(ctx, step))
3365 for (
int i = 0; i<loops; i++)
3367 for (Uint32 j = 0; j<10; j++)
3368 if (dict.schema_op(pNdb))
3371 if (res.dostep(ctx, step))
3374 if (dict.validate(pNdb))
3378 if (res.finish(ctx, step))
3381 if (dict.validate(pNdb))
3384 if (dict.cleanup(pNdb))
3394 lg.setName(
"DEFAULT-LG");
3395 lg.setUndoBufferSize(8*1024*1024);
3397 if (res.getNumDbNodes() < 2)
3400 Ndb* pNdb = GETNDB(step);
3403 int node = res.getRandomNotMasterNodeId(rand());
3404 res.restartOneDbNode(node,
true,
true,
false);
3406 if(pDict->createLogfileGroup(lg) != 0){
3407 g_err <<
"Failed to create logfilegroup:"
3413 uf.setPath(
"undofile01.dat");
3414 uf.setSize(5*1024*1024);
3415 uf.setLogfileGroup(
"DEFAULT-LG");
3417 if(pDict->createUndofile(uf) != 0){
3418 g_err <<
"Failed to create undofile:"
3423 res.waitNodesNoStart(&node, 1);
3424 res.startNodes(&node, 1);
3426 if (res.waitClusterStarted()){
3427 g_err <<
"Node restart failed"
3432 if (pDict->dropLogfileGroup(pDict->getLogfileGroup(lg.getName())) != 0){
3433 g_err <<
"Drop of LFG Failed"
3446 Ndb* pNdb = GETNDB(step);
3454 const char * tableFound = 0;
3455 for (i = 0; i < list.
count; i++){
3459 if(tableFound != 0){
3461 !is_prefix(tableFound,
"NDB$BLOB"))
3464 g_err <<
"Failed to drop table: " << tableFound << pDict->
getNdbError() << endl;
3477 const char * dfFound = 0;
3478 for (i = 0; i < list.
count; i++){
3483 if(pDict->dropDatafile(pDict->getDatafile(0, dfFound)) != 0){
3484 g_err <<
"Failed to drop datafile: " << pDict->
getNdbError() << endl;
3496 const char * tsFound = 0;
3497 for (i = 0; i <list.
count; i++){
3502 if(pDict->dropTablespace(pDict->getTablespace(tsFound)) != 0){
3503 g_err <<
"Failed to drop tablespace: " << pDict->
getNdbError() << endl;
3517 const char * lgFound = 0;
3518 for (i = 0; i < list.
count; i++){
3523 if (pDict->dropLogfileGroup(pDict->getLogfileGroup(lgFound)) != 0){
3524 g_err <<
"Failed to drop tablespace: " << pDict->
getNdbError() << endl;
3542 restarter.waitClusterStarted(300);
3544 NdbSleep_SecSleep(3);
3554 Ndb* pNdb = GETNDB(step);
3558 lg.setName(
"DEFAULT-LG");
3559 lg.setUndoBufferSize(8*1024*1024);
3562 if(pDict->createLogfileGroup(lg) != 0){
3563 g_err <<
"Failed to create logfilegroup:"
3569 uf.setPath(
"undofile01.dat");
3570 uf.setSize(5*1024*1024);
3571 uf.setLogfileGroup(
"DEFAULT-LG");
3573 if(pDict->createUndofile(uf) != 0){
3574 g_err <<
"Failed to create undofile:"
3582 if (create_tablespace(pDict, lg.getName(), tsname, dfname)){
3583 g_err <<
"Failed to create undofile:"
3594 Ndb* pNdb = GETNDB(step);
3603 for (Uint32 i = 0; err[
i] != 0; i++)
3605 int val2[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 1 };
3607 if (res.dumpStateAllNodes(val2, 2))
3610 if (res.insertErrorInAllNodes(932))
3617 if (res.insertErrorInAllNodes(code))
3622 lg.setName(
"DEFAULT-LG");
3623 lg.setUndoBufferSize(8*1024*1024);
3626 uf.setPath(
"undofile01.dat");
3627 uf.setSize(5*1024*1024);
3628 uf.setLogfileGroup(
"DEFAULT-LG");
3630 int r = pDict->createLogfileGroup(lg);
3635 ndbout << __LINE__ <<
" : " << pDict->
getNdbError() << endl;
3639 if (res.insertErrorInAllNodes(err[i]))
3642 pDict->createUndofile(uf);
3645 if (res.waitClusterNoStart())
3649 if (res.waitClusterStarted())
3658 ndbout << __LINE__ << endl;
3662 if (pDict->createLogfileGroup(lg) != 0)
3664 ndbout << __LINE__ <<
" : " << pDict->
getNdbError() << endl;
3674 ndbout << __LINE__ << endl;
3678 if (pDict->createUndofile(uf) != 0)
3680 ndbout << __LINE__ <<
" : " << pDict->
getNdbError() << endl;
3690 ndbout << __LINE__ <<
" : " << pDict->
getNdbError() << endl;
3694 if (pDict->dropLogfileGroup(lg2))
3696 ndbout << __LINE__ <<
" : " << pDict->
getNdbError() << endl;
3710 res.restartAll2(NdbRestarter::NRRF_INITIAL |
3711 NdbRestarter::NRRF_NOSTART |
3712 NdbRestarter::NRRF_ABORT);
3713 if (res.waitClusterNoStart())
3717 if (res.waitClusterStarted())
3729 Ndb* pNdb = GETNDB(step);
3736 bool ddFound =
false;
3737 for (i = 0; i <list.
count; i++){
3748 if(ddFound ==
true){
3749 g_err <<
"DropDDObjects Failed: DD found:"
3762 static const uint MaxMsg = 100;
3767 char msgName[20], ackName[20];
3768 sprintf(msgName,
"Msg%d%d", loc, rem);
3769 sprintf(ackName,
"Ack%d%d", loc, rem);
3770 g_info << loc <<
": send to:" << rem <<
" msg:" << msg << endl;
3771 ctx->setProperty(msgName, msg);
3775 if (ctx->isTestStopped())
3778 if ((ret = ctx->getProperty(ackName, (Uint32)0)) != 0)
3780 if (++cnt % 100 == 0)
3781 g_info << loc <<
": send to:" << rem <<
" wait for ack" << endl;
3782 NdbSleep_MilliSleep(10);
3784 ctx->setProperty(ackName, (Uint32)0);
3789 poll_msg(
NDBT_Context* ctx,
int loc,
int rem,
char* msg)
3791 char msgName[20], ackName[20];
3792 sprintf(msgName,
"Msg%d%d", rem, loc);
3793 sprintf(ackName,
"Ack%d%d", rem, loc);
3795 if ((ptr = ctx->getProperty(msgName, (
char*)0)) != 0 && ptr[0] != 0)
3797 assert(strlen(ptr) < MaxMsg);
3798 memset(msg, 0, MaxMsg);
3800 g_info << loc <<
": recv from:" << rem <<
" msg:" << msg << endl;
3801 ctx->setProperty(msgName,
"");
3802 ctx->setProperty(ackName, (Uint32)1);
3809 recv_msg(
NDBT_Context* ctx,
int loc,
int rem,
char* msg)
3814 if (ctx->isTestStopped())
3816 if (poll_msg(ctx, loc, rem, msg))
3818 if (++cnt % 100 == 0)
3819 g_info << loc <<
": recv from:" << rem <<
" wait for msg" << endl;
3820 NdbSleep_MilliSleep(10);
3825 const char* tabName_Bug48604 =
"TBug48604";
3826 const char* indName_Bug48604 =
"TBug48604X1";
3831 Ndb* pNdb = GETNDB(step);
3834 int result = NDBT_OK;
3851 CHECK((pTab = pDic->
getTable(tabName_Bug48604)) != 0);
3860 Ndb* pNdb = GETNDB(step);
3863 int result = NDBT_OK;
3870 g_info <<
"index create.." << endl;
3872 CHECK((pInd = pDic->
getIndex(indName_Bug48604, tabName_Bug48604)) != 0);
3873 g_info <<
"index created" << endl;
3883 Ndb* pNdb = GETNDB(step);
3887 (void)pDic->
dropTable(tabName_Bug48604);
3888 int loc = step->getStepNo() - 1;
3890 g_err <<
"main" << endl;
3891 int result = NDBT_OK;
3892 int loops = ctx->getNumLoops();
3897 CHECK((pTab = runBug48604createtable(ctx, step)) != 0);
3898 CHECK(send_msg(ctx, 0, 1,
"s"));
3901 while (result == NDBT_OK && loop++ < loops)
3903 g_err <<
"loop:" << loop << endl;
3906 const char* ops[][3] =
3908 {
"ozin",
"oc",
"oa" },
3909 {
"oziun",
"oc",
"oa" },
3910 {
"ozidn",
"oc",
"oa" },
3911 {
"ozicun",
"oc",
"oa" },
3912 {
"ozicuuun",
"oc",
"oa" },
3913 {
"ozicdn",
"oc",
"oa" },
3914 {
"ozicdin",
"oc",
"oa" },
3915 {
"ozicdidiuuudidn",
"oc",
"oa" },
3916 {
"ozicdidiuuudidin",
"oc",
"oa" }
3918 const int cnt =
sizeof(ops)/
sizeof(ops[0]);
3920 for (i = 0; result == NDBT_OK && i < cnt; i++)
3923 for (j = 1; result == NDBT_OK && j <= 2; j++)
3927 CHECK(send_msg(ctx, 0, 1, ops[i][0]));
3928 CHECK(recv_msg(ctx, 0, 1, msg) && msg[0] ==
'o');
3929 CHECK((pInd = runBug48604createindex(ctx, step)) != 0);
3930 CHECK(send_msg(ctx, 0, 1, ops[i][j]));
3931 CHECK(recv_msg(ctx, 0, 1, msg) && msg[0] ==
'o');
3933 CHECK(pDic->
dropIndex(indName_Bug48604, tabName_Bug48604) == 0);
3934 g_info <<
"index dropped" << endl;
3942 (void)send_msg(ctx, 0, 1,
"x");
3944 g_err <<
"main: exit:" << result << endl;
3951 Ndb* pNdb = GETNDB(step);
3955 int loc = step->getStepNo() - 1;
3957 g_err <<
"ops: loc:" << loc << endl;
3958 int result = NDBT_OK;
3959 int records = ctx->getNumRecords();
3964 CHECK(recv_msg(ctx, loc, 0, msg));
3965 assert(msg[0] ==
's');
3966 CHECK((pTab = pDic->
getTable(tabName_Bug48604)) != 0);
3968 bool have_trans =
false;
3971 while (result == NDBT_OK && !ctx->isTestStopped())
3973 CHECK(recv_msg(ctx, loc, 0, msg));
3980 while (result == NDBT_OK && (c = *p++) != 0)
3985 CHECK(ops.execute_NoCommit(pNdb) == 0);
3986 g_info << loc <<
": not committed" << endl;
3992 CHECK(ops.execute_Commit(pNdb) == 0);
3993 ops.closeTransaction(pNdb);
3995 g_info << loc <<
": committed" << endl;
4001 CHECK(ops.execute_Rollback(pNdb) == 0);
4002 ops.closeTransaction(pNdb);
4004 g_info << loc <<
": aborted" << endl;
4007 if (c ==
'i' || c ==
'u' || c ==
'd')
4011 CHECK(ops.startTransaction(pNdb) == 0);
4013 g_info << loc <<
": trans started" << endl;
4016 for (i = 0; result == NDBT_OK && i < records; i++)
4019 CHECK(ops.pkInsertRecord(pNdb, i, 1, opseq) == 0);
4021 CHECK(ops.pkUpdateRecord(pNdb, i, 1, opseq) == 0);
4023 CHECK(ops.pkDeleteRecord(pNdb, i, 1) == 0);
4026 sprintf(op_str,
"%c", c);
4027 g_info << loc <<
": op:" << op_str <<
" records:" << records << endl;
4033 CHECK(ops.clearTable(pNdb) == 0);
4038 CHECK(send_msg(ctx, loc, 0,
"o"));
4045 g_err <<
"ops: loc:" << loc <<
" exit:" << result << endl;
4046 if (result != NDBT_OK)
4054 Ndb* pNdb = GETNDB(step);
4057 for (Uint32 j = 0; j< 2; j++)
4069 ndbout_c(
"Failed to create table...");
4076 for (Uint32 i = 0; i<2; i++)
4081 ndbout <<
"Alter with duplicate name succeeded!!" << endl;
4085 ndbout <<
"Alter with duplicate name failed...good" << endl
4102 static bool st_core_on_err =
false;
4107 g_err << "FAIL " << __LINE__ << " " << #x << endl; \
4108 if (st_core_on_err) abort(); \
4112 #define chk2(x, e) \
4115 g_err << "FAIL " << __LINE__ << " " << #x << ": " << e << endl; \
4116 if (st_core_on_err) abort(); \
4124 uint
n = (uint)ndb_rand();
4129 randomly(uint k, uint m)
4131 uint n = urandom(m);
4141 static ST_Objlist st_objlist;
4143 static const ST_Obj* st_find_obj(
const char* db,
const char* name);
4146 #define ST_MAX_NAME_SIZE (MAX_TAB_NAME_SIZE + 100)
4150 char dbname[ST_MAX_NAME_SIZE];
4151 char name[ST_MAX_NAME_SIZE];
4155 bool exists()
const {
4156 return !(!create && commit);
4158 virtual bool is_trigger()
const {
4161 virtual bool is_index()
const {
4164 virtual bool is_table()
const {
4167 virtual const char* realname()
const {
4170 ST_Obj(
const char* a_dbname,
const char* a_name) {
4172 strcpy(dbname, a_dbname);
4173 strcpy(name, a_name);
4177 assert(st_find_obj(dbname, name) == 0);
4178 st_objlist.push_back(
this);
4184 operator<<(NdbOut& out,
const ST_Obj& obj)
4186 out << obj.name <<
"[" << obj.id <<
"]";
4193 mutable char realname_buf[ST_MAX_NAME_SIZE];
4194 virtual bool is_trigger()
const {
4197 virtual const char* realname()
const;
4198 ST_Trg(
const char* a_db,
const char* a_name) :
4213 ST_Trglist* trglist;
4215 virtual bool is_index()
const {
4218 bool is_unique()
const {
4221 const ST_Trg& trg(
int k)
const {
4222 return *((*trglist)[k]);
4225 return *((*trglist)[k]);
4227 ST_Ind(
const char* a_db,
const char* a_name) :
4232 trglist =
new ST_Trglist;
4244 ST_Trg::realname()
const
4248 const char* p =
name;
4249 const char* q = strchr(p,
'<');
4250 const char* r = strchr(p,
'>');
4251 assert(q != 0 && r != 0 && q < r);
4252 assert(ind->id != -1);
4253 sprintf(realname_buf,
"%.*s%d%s", (
int)(q - p), p, ind->id, r + 1);
4254 return realname_buf;
4263 ST_Indlist* indlist;
4266 int indorderedcount;
4267 virtual bool is_table()
const {
4270 const ST_Ind& ind(
int j)
const {
4271 return *((*indlist)[j]);
4274 return *((*indlist)[j]);
4276 ST_Tab(
const char* a_db,
const char* a_name) :
4280 indlist =
new ST_Indlist;
4283 indorderedcount = 0;
4301 for (i = 0; i < MAX_NODES; i++)
4302 state[i].node_type = NDB_MGM_NODE_TYPE_UNKNOWN;
4312 ST_Restarter::get_state(
int node_id) {
4313 assert(node_id > 0 && node_id < MAX_NODES);
4314 assert(!first_time);
4315 return state[node_id];
4321 int node_id = new_state.
node_id;
4322 assert(1 <= node_id && node_id < MAX_NODES);
4331 old_state = new_state;
4335 ST_Restarter::get_status()
4337 if (getStatus() == -1)
4340 for (i = 0; i < (int)mgmNodes.size(); i++)
4341 set_state(mgmNodes[i]);
4342 for (i = 0; i < (int)ndbNodes.size(); i++)
4343 set_state(ndbNodes[i]);
4344 for (i = 0; i < (int)apiNodes.size(); i++)
4345 set_state(apiNodes[i]);
4356 char dbname[ST_MAX_NAME_SIZE];
4357 ST_Tablist* tablist;
4365 const ST_Tab& tab(
int i)
const {
4366 return *((*tablist)[
i]);
4369 return *((*tablist)[
i]);
4377 restarter = a_restarter;
4378 numdbnodes = restarter->getNumDbNodes();
4379 assert(numdbnodes >= 1);
4381 tablist =
new ST_Tablist;
4387 node_id = ncc->node_id();
4389 assert(restarter->get_status() == 0);
4392 assert(state.version != 0);
4393 g_info <<
"node_id:" << node_id << endl;
4413 st_drop_all_tables(
ST_Con& c)
4415 g_info <<
"st_drop_all_tables" << endl;
4419 for (n = 0; n < (int)list.
count; n++) {
4423 strcmp(element.
database,
"TEST_DB") == 0) {
4435 int numTables = ctx->getNumTables();
4438 for (i = 0; i < numTables; i++) {
4440 #if ndb_test_ALL_TABLES_is_fixed
4445 pTab = NDBT_Tables::getTable(tables[i].c_str());
4447 assert(pTab != 0 && pTab->
getName() != 0);
4455 if (pCol->getStorageType() !=
4456 NdbDictionary::Column::StorageTypeMemory) {
4457 g_err << pTab->
getName() <<
": skip non-mem table for now" << endl;
4466 c.tablist->push_back(
new ST_Tab(c.dbname, pTab->
getName()));
4468 ST_Tab& tab = *c.tablist->back();
4472 const char** indspec = NDBT_Tables::getIndexes(tab.name);
4474 while (indspec != 0 && *indspec != 0) {
4475 char ind_name[ST_MAX_NAME_SIZE];
4476 sprintf(ind_name,
"%sX%d", tab.name, tab.indcount);
4477 tab.indlist->push_back(
new ST_Ind(
"sys", ind_name));
4478 ST_Ind& ind = *tab.indlist->back();
4485 const char* type = *indspec++;
4486 if (strcmp(type,
"UNIQUE") == 0) {
4489 tab.induniquecount++;
4491 {
char trg_name[ST_MAX_NAME_SIZE];
4492 sprintf(trg_name,
"NDB$INDEX_<%s>_UI", ind.name);
4493 ind.trglist->push_back(
new ST_Trg(
"", trg_name));
4494 ST_Trg& trg = *ind.trglist->back();
4497 trg.event = TriggerEvent::TE_INSERT;
4501 else if (strcmp(type,
"ORDERED") == 0) {
4504 tab.indorderedcount++;
4506 {
char trg_name[ST_MAX_NAME_SIZE];
4507 sprintf(trg_name,
"NDB$INDEX_<%s>_CUSTOM", ind.name);
4508 ind.trglist->push_back(
new ST_Trg(
"", trg_name));
4509 ST_Trg& trg = *ind.trglist->back();
4512 trg.event = TriggerEvent::TE_CUSTOM;
4519 const char* sep =
"";
4520 const char* colname;
4521 while ((colname = *indspec++) != 0) {
4526 ind.colnames.
appfmt(
"%s%s", sep, colname);
4539 st_report_db_nodes(
ST_Con& c, NdbOut& out)
4541 chk1(c.restarter->get_status() == 0);
4545 r1[0] =r2[0] = r3[0] = 0;
4547 for (i = 1; i < MAX_NODES; i++) {
4557 sprintf(r + strlen(r),
"%s%d", r[0] == 0 ?
"" :
",", i);
4560 if (r2[0] != 0 || r3[0] != 0) {
4561 out <<
"nodes up:" << r1 <<
" down:" << r2 <<
" unknown:" << r3 << endl;
4564 out <<
"nodes up:" << r1 <<
" (all)" << endl;
4571 st_check_db_nodes(
ST_Con& c,
int ignore_node_id = -1)
4573 chk1(c.restarter->get_status() == 0);
4575 for (i = 1; i < MAX_NODES; i++) {
4578 i != ignore_node_id) {
4589 st_wait_db_node_up(
ST_Con& c,
int node_id)
4593 int milli_sleep = 2000;
4594 while (count++ < max_count) {
4596 chk1(st_check_db_nodes(c, node_id) == 0);
4602 g_info <<
"waiting count:" << count <<
"/" << max_count << endl;
4603 NdbSleep_MilliSleep(milli_sleep);
4616 assert(c.xcon == 0);
4617 g_info <<
"start extra connection" << endl;
4622 chk2((ret = xncc->
connect(30, 1, 0)) == 0,
"ret:" << ret);
4624 Ndb* xndb =
new Ndb(xncc, c.dbname);
4625 chk1(xndb->
init() == 0);
4628 c.xcon =
new ST_Con(xncc, xndb, c.restarter);
4630 c.xcon->tablist = c.tablist;
4631 c.xcon->tabcount = c.tabcount;
4632 c.xcon->is_xcon =
true;
4642 assert(c.xcon != 0);
4643 int node_id = c.xcon->node_id;
4644 g_info <<
"stop extra connection node_id:" << node_id << endl;
4646 c.xcon->restarter = 0;
4647 c.xcon->tablist = 0;
4648 c.xcon->tabcount = 0;
4653 chk1(c.restarter->get_status() == 0);
4656 if (state.version == 0)
4658 g_info <<
"waiting count:" << ++count << endl;
4659 NdbSleep_MilliSleep(10 * count);
4676 value(0), code(0), master(-1), node(0), list(0), ends(
true)
4679 value(0), code(0), master(-1), node(0), list(l), ends(
false)
4682 value(v), code(c), master(m), node(0), list(0), ends(
false)
4687 operator<<(NdbOut& out,
const ST_Errins& errins)
4689 out <<
"value:" << errins.value;
4690 out <<
" code:" << errins.code;
4691 out <<
" master:" << errins.master;
4692 out <<
" node:" << errins.node;
4700 while (!list[size++].ends)
4703 uint n = urandom(size - 1);
4705 if (errins.list == 0) {
4706 assert(errins.value != 0);
4709 return st_get_errins(c, errins.list);
4715 assert(errins.value != 0);
4716 if (c.numdbnodes < 2)
4718 else if (errins.master == -1)
4719 errins.master = randomly(1, 2);
4720 if (errins.master) {
4721 errins.node = c.restarter->getMasterNodeId();
4723 uint rand = urandom(c.numdbnodes);
4724 errins.node = c.restarter->getRandomNotMasterNodeId(rand);
4726 g_info <<
"errins: " << errins << endl;
4727 chk2(c.restarter->insertErrorInNode(errins.node, errins.value) == 0, errins);
4728 c.restarter->get_status();
4737 st_find_obj(
const char* dbname,
const char* name)
4739 const ST_Obj* ret_objp = 0;
4741 for (i = 0; i < (int)st_objlist.size(); i++) {
4742 const ST_Obj* objp = st_objlist[
i];
4743 if (strcmp(objp->dbname, dbname) == 0 &&
4744 strcmp(objp->name, name) == 0) {
4745 assert(ret_objp == 0);
4755 st_print_obj(
const char* dbname,
const char* name,
int line = 0)
4757 const ST_Obj* objp = st_find_obj(dbname, name);
4758 g_info << name <<
": by name:";
4760 g_info <<
" create:" << objp->create
4761 <<
" commit:" << objp->commit
4762 <<
" exists:" << objp->exists();
4764 g_info <<
" not found";
4766 g_info <<
" line:" << line;
4776 bool create_old = obj.create;
4777 bool commit_old = obj.commit;
4778 if (!c.tx_commit && !obj.commit)
4779 obj.create = !obj.create;
4781 if (create_old != obj.create || commit_old != obj.commit) {
4782 g_info << obj.name <<
": set commit:"
4783 <<
" create:" << create_old <<
"->" << obj.create
4784 <<
" commit:" << commit_old <<
"->" << obj.commit << endl;
4792 st_set_commit_obj(c, trg);
4799 st_set_commit_obj(c, ind);
4801 for (k = 0; k < ind.trgcount; k++) {
4802 ST_Trg& trg = ind.trg(k);
4803 st_set_commit_obj(c, trg);
4810 st_set_commit_obj(c, tab);
4812 for (j = 0; j < tab.indcount; j++) {
4813 ST_Ind& ind = tab.ind(j);
4814 st_set_commit_ind(c, ind);
4819 st_set_commit_all(
ST_Con& c)
4822 for (i = 0; i < c.tabcount; i++) {
4824 st_set_commit_tab(c, tab);
4831 bool create_old = obj.create;
4832 bool commit_old = obj.commit;
4833 obj.create = create;
4834 obj.commit = !c.tx_on;
4835 if (create_old != obj.create || commit_old != obj.commit) {
4836 g_info << obj.name <<
": set create:"
4837 <<
" create:" << create_old <<
"->" << obj.create
4838 <<
" commit:" << commit_old <<
"->" << obj.commit << endl;
4845 st_set_create_obj(c, trg, create);
4851 st_set_create_obj(c, ind, create);
4853 for (k = 0; k < ind.trgcount; k++) {
4854 ST_Trg& trg = ind.trg(k);
4855 st_set_create_trg(c, trg, create);
4862 st_set_create_obj(c, tab, create);
4864 for (j = 0; j < tab.indcount; j++) {
4865 ST_Ind& ind = tab.ind(j);
4867 assert(!ind.exists());
4870 st_set_create_ind(c, ind,
false);
4880 switch (element.
type) {
4883 if (strcmp(element.
database,
"mysql") == 0)
4885 if (strncmp(element.
name,
"NDB$BLOB", 8) == 0)
4900 st_match_obj(
const ST_Obj& obj,
4903 int veryverbose = 0;
4907 <<
" " << obj.type <<
"-" << element.
type
4908 <<
" " << obj.dbname <<
"-" << element.
database
4909 <<
" " << obj.realname() <<
"-" << element.
name << endl;
4912 obj.type == element.
type &&
4913 strcmp(obj.dbname, element.
database) == 0 &&
4914 strcmp(obj.realname(), element.
name) == 0;
4918 st_verify_obj(
const ST_Obj& obj,
4921 chk2(obj.exists(), obj.name);
4928 else if (obj.create) {
4929 if (obj.is_table() || obj.is_index())
4931 if (obj.is_trigger())
4935 if (obj.is_trigger())
4937 if (obj.is_table() || obj.is_index())
4946 st_verify_obj(
const ST_Obj& obj,
4951 for (n = 0; n < (int)list.
count; n++) {
4954 if (!st_known_type(element))
4956 if (st_match_obj(obj, element)) {
4957 chk1(st_verify_obj(obj, element) == 0);
4962 chk2(found == 1, obj.name);
4964 chk2(found == 0, obj.name);
4971 st_verify_obj(
const ST_Obj& obj,
4976 if (st_match_obj(obj, element)) {
4977 chk1(st_verify_obj(obj, element) == 0);
4982 chk2(st_match_obj(obj, element) ==
false, obj.name);
4990 st_verify_list(
ST_Con& c)
4996 for (i = 0; i < c.tabcount; i++) {
4997 const ST_Tab& tab = c.tab(i);
4998 chk1(st_verify_obj(tab, list) == 0);
4999 for (j = 0; j < tab.indcount; j++) {
5000 const ST_Ind& ind = tab.ind(j);
5001 chk1(st_verify_obj(ind, list) == 0);
5002 for (k = 0; k < ind.trgcount; k++) {
5003 const ST_Trg& trg = ind.trg(k);
5004 chk1(st_verify_obj(trg, list) == 0);
5009 for (n = 0; n < (int)list.
count; n++) {
5012 if (!st_known_type(element))
5015 for (i = 0; i < c.tabcount; i++) {
5016 const ST_Tab& tab = c.tab(i);
5017 chk1(st_verify_obj(tab, element, found) == 0);
5018 for (j = 0; j < tab.indcount; j++) {
5019 const ST_Ind& ind = tab.ind(j);
5020 chk1(st_verify_obj(ind, element, found) == 0);
5021 for (k = 0; k < ind.trgcount; k++) {
5022 const ST_Trg& trg = ind.trg(k);
5023 chk1(st_verify_obj(trg, element, found) == 0);
5027 const char* dot = element.
database[0] != 0 ?
"." :
"";
5028 chk2(found == 1, element.
database << dot << element.
name);
5041 g_info <<
"st_wait_idle" << endl;
5044 int milli_sleep = 1000;
5045 while (count++ < max_count) {
5050 for (n = 0; n < (int)list.
count; n++) {
5053 if (!st_known_type(element))
5062 g_info <<
"waiting count:" << count <<
"/" << max_count << endl;
5063 NdbSleep_MilliSleep(milli_sleep);
5065 g_err <<
"st_wait_idle: objects did not become Online" << endl;
5087 c1.
getType() == NdbDictionary::Column::Decimalunsigned) {
5103 chk1(c1.getArrayType() == c2.getArrayType());
5104 chk1(c1.getStorageType() == c2.getStorageType());
5106 chk1(c1.getAutoIncrement() == c2.getAutoIncrement());
5133 assert(c1 != 0 && c2 != 0);
5134 chk2(st_equal_column(*c1, *c2, type) == 0,
"col:" << n);
5137 chk1(t1.getTemporary() == t2.getTemporary());
5158 assert(c1 != 0 && c2 != 0);
5159 chk2(st_equal_column(*c1, *c2, type) == 0,
"col:" << n);
5162 chk1(i1.getTemporary() == i2.getTemporary());
5178 chk1(st_equal_table(*tab.tab, *pTab) == 0);
5180 g_info << tab <<
": verified exists tx_on:" << c.tx_on << endl;
5182 chk2(pTab == 0, tab);
5184 g_info << tab <<
": verified not exists tx_on:" << c.tx_on << endl;
5201 chk1(st_equal_index(*ind.ind, *pInd) == 0);
5203 g_info << ind <<
": verified exists tx_on:" << c.tx_on << endl;
5205 chk2(pInd == 0, ind);
5207 g_info << ind <<
": verified not exists tx_on:" << c.tx_on << endl;
5218 chk1(st_verify_list(c) == 0);
5220 for (i = 0; i < c.tabcount; i++) {
5222 chk1(st_verify_table(c, tab) == 0);
5223 for (j = 0; j < tab.indcount; j++) {
5224 ST_Ind& ind = tab.ind(j);
5225 chk1(st_verify_index(c, ind) == 0);
5239 ST_AbortFlag = NdbDictionary::Dictionary::SchemaTransAbort;
5242 ST_BackgroundFlag = NdbDictionary::Dictionary::SchemaTransBackground;
5250 st_begin_trans(
ST_Con& c,
int code = 0)
5252 g_info <<
"begin trans";
5259 g_info <<
" - expect error " << code << endl;
5262 chk2(error.code == code, error <<
" wanted: " << code);
5272 assert(errins.code != 0);
5273 chk1(st_do_errins(c, errins) == 0);
5274 chk1(st_begin_trans(c, errins.code) == 0);
5284 while (++tries <= retry.max_tries) {
5290 chk2(code == 0 || code == 780 || code == 701, c.dic->
getNdbError());
5293 g_info <<
"begin trans at try " << tries << endl;
5296 NdbSleep_MilliSleep(retry.sleep_ms);
5304 st_end_trans(
ST_Con& c, uint flags)
5306 g_info <<
"end trans flags:" << hex << flags << endl;
5308 g_info <<
"end trans result:" << res << endl;
5311 c.tx_commit = !(flags & ST_AbortFlag);
5312 st_set_commit_all(c);
5319 st_end_trans_aborted(
ST_Con& c, uint flags)
5321 g_info <<
"end trans flags:" << hex << flags << endl;
5323 g_info <<
"end trans result:" << res << endl;
5324 if (flags & ST_AbortFlag)
5329 c.tx_commit = (flags & ST_AbortFlag);
5338 chk1(st_do_errins(c, errins) == 0);
5339 chk1(st_end_trans(c, flags) == 0);
5348 chk1(st_do_errins(c, errins) == 0);
5349 chk1(st_end_trans_aborted(c, flags) == 0);
5358 g_info << tab.name <<
": load data rows:" << rows << endl;
5359 assert(tab.tab_r != 0);
5361 chk1(ht.loadTable(c.ndb, rows) == 0);
5370 g_info << tab.name <<
": create table";
5373 assert(!tab.exists());
5375 g_info << tab.name <<
": created" << endl;
5376 st_set_create_tab(c, tab,
true);
5379 g_info <<
" - expect error " << code << endl;
5382 chk2(error.code == code, error <<
" wanted: " << code);
5384 chk1(st_verify_table(c, tab) == 0);
5393 assert(errins.code != 0);
5394 chk1(st_do_errins(c, errins) == 0);
5395 chk1(st_create_table(c, tab, errins.code) == 0);
5404 g_info << tab.name <<
": drop table";
5407 assert(tab.exists());
5410 g_info << tab.name <<
": dropped" << endl;
5411 st_set_create_tab(c, tab,
false);
5413 g_info <<
" - expect error " << code << endl;
5417 chk2(error.code == code, error <<
" wanted: " << code);
5419 chk1(st_verify_table(c, tab) == 0);
5428 assert(errins.code != 0);
5429 chk1(st_do_errins(c, errins) == 0);
5430 chk1(st_drop_table(c, tab, errins.code) == 0);
5440 g_info << ind.name <<
": create index on "
5441 << tab.name <<
"(" << ind.colnames.
c_str() <<
")";
5444 assert(!ind.exists());
5446 st_set_create_ind(c, ind,
true);
5447 g_info << ind.name <<
": created" << endl;
5449 g_info <<
" - expect error " << code << endl;
5450 chk1(c.dic->
createIndex(*ind.ind, *tab.tab_r) == -1);
5452 chk2(error.code == code, error <<
" wanted: " << code);
5454 chk1(st_verify_index(c, ind) == 0);
5463 assert(errins.code != 0);
5464 chk1(st_do_errins(c, errins) == 0);
5465 chk1(st_create_index(c, ind, errins.code) == 0);
5475 g_info << ind.name <<
": drop index";
5478 assert(ind.exists());
5481 g_info << ind.name <<
": dropped" << endl;
5482 st_set_create_ind(c, ind,
false);
5484 g_info <<
" expect error " << code << endl;
5486 chk1(c.dic->
dropIndex(ind.name, tab.name) == -1);
5488 chk2(error.code == code, error <<
" wanted: " << code);
5490 chk1(st_verify_index(c, ind) == 0);
5499 assert(errins.code != 0);
5500 chk1(st_do_errins(c, errins) == 0);
5501 chk1(st_drop_index(c, ind, errins.code) == 0);
5510 chk1(st_create_table(c, tab) == 0);
5512 for (j = 0; j < tab.indcount; j++) {
5513 ST_Ind& ind = tab.ind(j);
5514 chk1(st_create_index(c, ind) == 0);
5524 st_drop_test_tables(
ST_Con& c)
5526 g_info <<
"st_drop_test_tables" << endl;
5528 for (i = 0; i < c.tabcount; i++) {
5531 chk1(st_drop_table(c, tab) == 0);
5541 st_errins_begin_trans[] = {
5547 st_errins_end_trans1[] = {
5548 ST_Errins(ERR_INSERT_MASTER_FAILURE1, 0, 1),
5553 st_errins_end_trans2[] = {
5554 ST_Errins(ERR_INSERT_MASTER_FAILURE2, 0, 1),
5559 st_errins_end_trans3[] = {
5560 ST_Errins(ERR_INSERT_MASTER_FAILURE3, 0, 1),
5565 st_errins_table[] = {
5573 st_errins_index[] = {
5589 st_errins_index_create[] = {
5598 st_errins_index_drop[] = {
5606 st_test_create(
ST_Con& c,
int arg = -1)
5608 int do_abort = (arg == 1);
5610 chk1(st_begin_trans(c) == 0);
5611 for (i = 0; i < c.tabcount; i++) {
5613 chk1(st_create_table_index(c, tab) == 0);
5615 chk1(st_verify_list(c) == 0);
5617 chk1(st_end_trans(c, 0) == 0);
5619 chk1(st_end_trans(c, ST_AbortFlag) == 0);
5620 chk1(st_verify_list(c) == 0);
5622 chk1(st_drop_test_tables(c) == 0);
5629 st_test_drop(
ST_Con& c,
int arg = -1)
5631 int do_abort = (arg == 1);
5633 for (i = 0; i < c.tabcount; i++) {
5635 chk1(st_create_table_index(c, tab) == 0);
5637 chk1(st_begin_trans(c) == 0);
5638 for (i = 0; i < c.tabcount; i++) {
5640 chk1(st_drop_table(c, tab) == 0);
5642 chk1(st_verify_list(c) == 0);
5644 chk1(st_end_trans(c, 0) == 0);
5646 chk1(st_end_trans(c, ST_AbortFlag) == 0);
5647 chk1(st_verify_list(c) == 0);
5654 st_test_rollback_create_table(
ST_Con& c,
int arg = -1)
5657 chk1(st_begin_trans(c) == 0);
5658 for (i = 0; i < c.tabcount; i++) {
5662 chk1(st_create_table(c, tab, errins) == 0);
5664 chk1(st_create_table(c, tab) == 0);
5667 chk1(st_end_trans(c, 0) == 0);
5668 chk1(st_verify_list(c) == 0);
5669 for (i = 0; i < c.tabcount; i++) {
5672 assert(!tab.exists());
5674 assert(tab.exists());
5675 chk1(st_drop_table(c, tab) == 0);
5684 st_test_rollback_drop_table(
ST_Con& c,
int arg = -1)
5687 for (i = 0; i < c.tabcount; i++) {
5689 chk1(st_create_table(c, tab) == 0);
5691 chk1(st_begin_trans(c) == 0);
5692 for (i = 0; i < c.tabcount; i++) {
5696 chk1(st_drop_table(c, tab, errins) == 0);
5698 chk1(st_drop_table(c, tab) == 0);
5701 chk1(st_end_trans(c, 0) == 0);
5702 chk1(st_verify_list(c) == 0);
5703 for (i = 0; i < c.tabcount; i++) {
5706 assert(tab.exists());
5707 chk1(st_drop_table(c, tab) == 0);
5709 assert(!tab.exists());
5718 st_test_rollback_create_index(
ST_Con& c,
int arg = -1)
5721 for (i = 0; i < c.tabcount; i++) {
5723 if (tab.indcount < 1)
5725 chk1(st_create_table(c, tab) == 0);
5726 chk1(st_begin_trans(c) == 0);
5727 for (j = 0; j < tab.indcount; j++) {
5728 ST_Ind& ind = tab.ind(j);
5731 chk1(st_create_index(c, ind, errins) == 0);
5733 chk1(st_create_index(c, ind) == 0);
5736 chk1(st_end_trans(c, 0) == 0);
5737 chk1(st_verify_list(c) == 0);
5738 for (j = 0; j < tab.indcount; j++) {
5739 ST_Ind& ind = tab.ind(j);
5741 assert(!ind.exists());
5743 assert(ind.exists());
5744 chk1(st_drop_index(c, ind) == 0);
5747 chk1(st_drop_table(c, tab) == 0);
5755 st_test_rollback_drop_index(
ST_Con& c,
int arg = -1)
5758 for (i = 0; i < c.tabcount; i++) {
5760 if (tab.indcount < 1)
5762 chk1(st_create_table_index(c, tab) == 0);
5764 for (i = 0; i < c.tabcount; i++) {
5766 if (tab.indcount < 1)
5768 chk1(st_begin_trans(c) == 0);
5769 for (j = 0; j < tab.indcount; j++) {
5770 ST_Ind& ind = tab.ind(j);
5773 chk1(st_drop_index(c, ind, errins) == 0);
5775 chk1(st_drop_index(c, ind) == 0);
5778 chk1(st_end_trans(c, 0) == 0);
5779 chk1(st_verify_list(c) == 0);
5780 for (j = 0; j < tab.indcount; j++) {
5781 ST_Ind& ind = tab.ind(j);
5783 assert(ind.exists());
5784 chk1(st_drop_index(c, ind) == 0);
5786 assert(!ind.exists());
5796 st_test_dup_create_table(
ST_Con& c,
int arg = -1)
5801 for (do_trans = 0; do_trans <= 1; do_trans++) {
5802 for (do_abort = 0; do_abort <= do_trans; do_abort++) {
5803 g_info <<
"trans:" << do_trans
5804 <<
" abort:" << do_abort << endl;
5805 for (i = 0; i < c.tabcount; i++) {
5808 chk1(st_begin_trans(c) == 0);
5809 chk1(st_create_table(c, tab) == 0);
5810 chk1(st_create_table(c, tab, 721) == 0);
5813 chk1(st_end_trans(c, 0) == 0);
5815 chk1(st_end_trans(c, ST_AbortFlag) == 0);
5817 chk1(st_verify_list(c) == 0);
5819 chk1(st_drop_table(c, tab) == 0);
5830 st_test_dup_drop_table(
ST_Con& c,
int arg = -1)
5835 for (do_trans = 0; do_trans <= 1; do_trans++) {
5836 for (do_abort = 0; do_abort <= do_trans; do_abort++) {
5837 g_info <<
"trans:" << do_trans
5838 <<
" abort:" << do_abort << endl;
5839 for (i = 0; i < c.tabcount; i++) {
5841 chk1(st_create_table(c, tab) == 0);
5843 chk1(st_begin_trans(c) == 0);
5844 chk1(st_drop_table(c, tab) == 0);
5846 chk1(st_drop_table(c, tab, 723) == 0);
5848 chk1(st_drop_table(c, tab, 785) == 0);
5851 chk1(st_end_trans(c, 0) == 0);
5853 chk1(st_end_trans(c, ST_AbortFlag) == 0);
5855 chk1(st_verify_list(c) == 0);
5857 chk1(st_drop_table(c, tab) == 0);
5868 st_test_dup_create_index(
ST_Con& c,
int arg = -1)
5873 for (do_trans = 0; do_trans <= 1; do_trans++) {
5874 for (do_abort = 0; do_abort <= do_trans; do_abort++) {
5875 g_info <<
"trans:" << do_trans
5876 <<
" abort:" << do_abort << endl;
5877 for (i = 0; i < c.tabcount; i++) {
5879 if (tab.indcount < 1)
5881 chk1(st_create_table(c, tab) == 0);
5882 for (j = 0; j < tab.indcount; j++) {
5883 ST_Ind& ind = tab.ind(j);
5885 chk1(st_begin_trans(c) == 0);
5886 chk1(st_create_index(c, ind) == 0);
5887 chk1(st_create_index(c, ind, 721) == 0);
5890 chk1(st_end_trans(c, 0) == 0);
5892 chk1(st_end_trans(c, ST_AbortFlag) == 0);
5894 chk1(st_verify_list(c) == 0);
5896 chk1(st_drop_table(c, tab) == 0);
5906 st_test_dup_drop_index(
ST_Con& c,
int arg = -1)
5911 for (do_trans = 0; do_trans <= 1; do_trans++) {
5912 for (do_abort = 0; do_abort <= do_trans; do_abort++) {
5913 g_info <<
"trans:" << do_trans
5914 <<
" abort:" << do_abort << endl;
5915 for (i = 0; i < c.tabcount; i++) {
5917 if (tab.indcount < 1)
5919 chk1(st_create_table(c, tab) == 0);
5920 for (j = 0; j < tab.indcount; j++) {
5921 ST_Ind& ind = tab.ind(j);
5922 chk1(st_create_index(c, ind) == 0);
5924 chk1(st_begin_trans(c) == 0);
5925 chk1(st_drop_index(c, ind) == 0);
5927 chk1(st_drop_index(c, ind, 4243) == 0);
5929 chk1(st_drop_index(c, ind, 785) == 0);
5932 chk1(st_end_trans(c, 0) == 0);
5934 chk1(st_end_trans(c, ST_AbortFlag) == 0);
5936 chk1(st_verify_list(c) == 0);
5938 chk1(st_drop_table(c, tab) == 0);
5948 st_test_build_index(
ST_Con& c,
int arg = -1)
5951 for (i = 0; i < c.tabcount; i++) {
5953 if (tab.indcount < 1)
5955 chk1(st_create_table(c, tab) == 0);
5956 chk1(st_load_table(c, tab) == 0);
5957 for (j = 0; j < tab.indcount; j++) {
5958 ST_Ind& ind = tab.ind(j);
5959 chk1(st_create_index(c, ind) == 0);
5960 chk1(st_verify_list(c) == 0);
5962 chk1(st_drop_table(c, tab) == 0);
5970 st_test_local_create_list[] = {
5980 st_test_local_create(
ST_Con& c,
int arg = -1)
5983 ST_Errins *list = st_test_local_create_list;
5985 sizeof(st_test_local_create_list)/
sizeof(st_test_local_create_list[0]);
5986 assert(0 <= n && n < listlen);
5987 const bool only_unique = (n == 0 || n == 1 || n == 4 || n == 5);
5989 for (i = 0; i < c.tabcount; i++) {
5991 bool tabdone =
false;
5992 for (j = 0; j < tab.indcount; j++) {
5993 ST_Ind& ind = tab.ind(j);
5994 if (only_unique && !ind.is_unique())
5997 chk1(st_create_table(c, tab) == 0);
5998 chk1(st_load_table(c, tab) == 0);
6002 chk1(st_create_index(c, ind, errins) == 0);
6003 chk1(st_verify_list(c) == 0);
6006 chk1(st_drop_table(c, tab) == 0);
6015 static const uint ST_AllowAbort = 1;
6016 static const uint ST_AllowErrins = 2;
6019 st_test_trans(
ST_Con& c,
int arg = -1)
6021 if ((arg & ST_AllowErrins) && randomly(2, 3)) {
6022 ST_Errins errins = st_get_errins(c, st_errins_begin_trans);
6023 chk1(st_begin_trans(c, errins) == 0);
6025 chk1(st_begin_trans(c) == 0);
6026 if (randomly(1, 5)) {
6027 g_info <<
"try duplicate begin trans" << endl;
6028 chk1(st_begin_trans(c, 4410) == 0);
6031 if ((arg & ST_AllowAbort) && randomly(1, 3)) {
6032 chk1(st_end_trans(c, ST_AbortFlag) == 0);
6034 chk1(st_end_trans(c, 0) == 0);
6043 st_test_create_table(
ST_Con& c,
int arg = -1)
6045 bool trans = randomly(3, 4);
6046 bool simpletrans = !trans && randomly(1, 2);
6047 g_info <<
"trans:" << trans <<
" simpletrans:" << simpletrans << endl;
6049 chk1(st_begin_trans(c) == 0);
6052 for (i = 0; i < c.tabcount; i++) {
6055 g_info << tab.name <<
": skip existing" << endl;
6058 g_info << tab.name <<
": to create" << endl;
6060 chk1(st_begin_trans(c) == 0);
6062 if ((arg & ST_AllowErrins) && randomly(1, 3)) {
6063 ST_Errins errins = st_get_errins(c, st_errins_table);
6064 chk1(st_create_table(c, tab, errins) == 0);
6067 chk1(st_end_trans(c, 0) == 0);
6069 chk1(st_end_trans(c, ST_AbortFlag) == 0);
6072 chk1(st_create_table(c, tab) == 0);
6075 if ((arg & ST_AllowAbort) && randomly(4, 5))
6076 flags |= ST_AbortFlag;
6077 chk1(st_end_trans(c, flags) == 0);
6080 if (tab.exists() && randomly(1, 3)) {
6081 g_info << tab.name <<
": try duplicate create" << endl;
6082 chk1(st_create_table(c, tab, 721) == 0);
6087 if ((arg & ST_AllowAbort) && randomly(4, 5))
6088 flags |= ST_AbortFlag;
6089 chk1(st_end_trans(c, flags) == 0);
6097 st_test_drop_table(
ST_Con& c,
int arg = -1)
6099 bool trans = randomly(3, 4);
6100 bool simpletrans = !trans && randomly(1, 2);
6101 g_info <<
"trans:" << trans <<
" simpletrans:" << simpletrans << endl;
6103 chk1(st_begin_trans(c) == 0);
6106 for (i = 0; i < c.tabcount; i++) {
6108 if (!tab.exists()) {
6109 g_info << tab.name <<
": skip not existing" << endl;
6112 g_info << tab.name <<
": to drop" << endl;
6114 chk1(st_begin_trans(c) == 0);
6116 if ((arg & ST_AllowErrins) && randomly(1, 3)) {
6117 ST_Errins errins = st_get_errins(c, st_errins_table);
6118 chk1(st_drop_table(c, tab, errins) == 0);
6121 chk1(st_end_trans(c, 0) == 0);
6123 chk1(st_end_trans(c, ST_AbortFlag) == 0);
6126 chk1(st_drop_table(c, tab) == 0);
6129 if ((arg & ST_AllowAbort) && randomly(4, 5))
6130 flags |= ST_AbortFlag;
6131 chk1(st_end_trans(c, flags) == 0);
6134 if (!tab.exists() && randomly(1, 3)) {
6135 g_info << tab.name <<
": try duplicate drop" << endl;
6136 chk1(st_drop_table(c, tab, 723) == 0);
6141 if ((arg & ST_AllowAbort) && randomly(4, 5))
6142 flags |= ST_AbortFlag;
6143 chk1(st_end_trans(c, flags) == 0);
6151 st_test_table(
ST_Con& c,
int arg = -1)
6153 chk1(st_test_create_table(c) == NDBT_OK);
6154 chk1(st_test_drop_table(c) == NDBT_OK);
6161 st_test_create_index(
ST_Con& c,
int arg = -1)
6163 bool trans = randomly(3, 4);
6164 bool simpletrans = !trans && randomly(1, 2);
6165 g_info <<
"trans:" << trans <<
" simpletrans:" << simpletrans << endl;
6167 chk1(st_begin_trans(c) == 0);
6170 for (i = 0; i < c.tabcount; i++) {
6172 if (tab.indcount == 0)
6174 if (!tab.exists()) {
6175 g_info << tab.name <<
": to create" << endl;
6176 chk1(st_create_table(c, tab) == 0);
6178 for (j = 0; j < tab.indcount; j++) {
6179 ST_Ind& ind = tab.ind(j);
6181 g_info << ind.name <<
": skip existing" << endl;
6184 g_info << ind.name <<
": to create" << endl;
6186 chk1(st_begin_trans(c) == 0);
6188 if ((arg & ST_AllowErrins) && randomly(1, 3)) {
6189 const ST_Errins* list = st_errins_index_create;
6190 ST_Errins errins = st_get_errins(c, list);
6191 chk1(st_create_index(c, ind, errins) == 0);
6194 chk1(st_end_trans(c, 0) == 0);
6196 chk1(st_end_trans(c, ST_AbortFlag) == 0);
6199 chk1(st_create_index(c, ind) == 0);
6202 if ((arg & ST_AllowAbort) && randomly(4, 5))
6203 flags |= ST_AbortFlag;
6204 chk1(st_end_trans(c, flags) == 0);
6207 if (ind.exists() && randomly(1, 3)) {
6208 g_info << ind.name <<
": try duplicate create" << endl;
6209 chk1(st_create_index(c, ind, 721) == 0);
6215 if ((arg & ST_AllowAbort) && randomly(4, 5))
6216 flags |= ST_AbortFlag;
6217 chk1(st_end_trans(c, flags) == 0);
6225 st_test_drop_index(
ST_Con& c,
int arg = -1)
6227 bool trans = randomly(3, 4);
6228 bool simpletrans = !trans && randomly(1, 2);
6229 g_info <<
"trans:" << trans <<
" simpletrans:" << simpletrans << endl;
6231 chk1(st_begin_trans(c) == 0);
6234 for (i = 0; i < c.tabcount; i++) {
6236 if (tab.indcount == 0)
6238 if (!tab.exists()) {
6239 g_info << tab.name <<
": skip not existing" << endl;
6242 for (j = 0; j < tab.indcount; j++) {
6243 ST_Ind& ind = tab.ind(j);
6244 if (!ind.exists()) {
6245 g_info << ind.name <<
": skip not existing" << endl;
6248 g_info << ind.name <<
": to drop" << endl;
6250 chk1(st_begin_trans(c) == 0);
6252 if ((arg & ST_AllowErrins) && randomly(1, 3)) {
6253 const ST_Errins* list = st_errins_index_drop;
6254 ST_Errins errins = st_get_errins(c, list);
6255 chk1(st_drop_index(c, ind, errins) == 0);
6258 chk1(st_end_trans(c, 0) == 0);
6260 chk1(st_end_trans(c, ST_AbortFlag) == 0);
6263 chk1(st_drop_index(c, ind) == 0);
6266 if ((arg & ST_AllowAbort) && randomly(4, 5))
6267 flags |= ST_AbortFlag;
6268 chk1(st_end_trans(c, flags) == 0);
6271 if (!ind.exists() && randomly(1, 3)) {
6272 g_info << ind.name <<
": try duplicate drop" << endl;
6273 chk1(st_drop_index(c, ind, 4243) == 0);
6279 if ((arg & ST_AllowAbort) && randomly(4, 5))
6280 flags |= ST_AbortFlag;
6281 chk1(st_end_trans(c, flags) == 0);
6289 st_test_index(
ST_Con& c,
int arg = -1)
6291 chk1(st_test_create_index(c) == NDBT_OK);
6292 chk1(st_test_drop_index(c) == NDBT_OK);
6301 st_test_anf_parse(
ST_Con& c,
int arg = -1)
6304 chk1(st_start_xcon(c) == 0);
6307 chk1(st_begin_trans(xc) == 0);
6308 for (i = 0; i < c.tabcount; i++) {
6310 chk1(st_create_table_index(xc, tab) == 0);
6314 xc.tx_commit =
false;
6315 st_set_commit_all(xc);
6316 chk1(st_stop_xcon(c) == 0);
6317 chk1(st_wait_idle(c) == 0);
6318 chk1(st_verify_list(c) == 0);
6326 st_test_anf_background(
ST_Con& c,
int arg = -1)
6329 chk1(st_start_xcon(c) == 0);
6332 chk1(st_begin_trans(xc) == 0);
6333 for (i = 0; i < c.tabcount; i++) {
6335 chk1(st_create_table(xc, tab) == 0);
6338 st_end_trans(xc, ST_BackgroundFlag);
6339 chk1(st_stop_xcon(c) == 0);
6340 chk1(st_wait_idle(c) == 0);
6341 chk1(st_verify_list(c) == 0);
6349 st_test_anf_fail_begin(
ST_Con& c,
int arg = -1)
6351 chk1(st_start_xcon(c) == 0);
6357 chk1(st_do_errins(xc, errins1) == 0);
6358 chk1(st_do_errins(xc, errins2) == 0);
6360 chk1(st_begin_trans(xc, 4009) == 0);
6364 xc.tx_commit =
false;
6365 st_set_commit_all(xc);
6366 chk1(st_stop_xcon(c) == 0);
6370 chk1(st_begin_trans(c, retry) == 0);
6371 chk1(st_wait_idle(c) == 0);
6372 chk1(st_verify_list(c) == 0);
6380 st_test_snf_parse(
ST_Con& c,
int arg = -1)
6382 bool do_abort = (arg == 1);
6383 chk1(st_begin_trans(c) == 0);
6388 midcount = c.tabcount / 2;
6390 for (i = 0; i < c.tabcount; i++) {
6392 if (i == midcount) {
6393 assert(c.numdbnodes > 1);
6394 uint rand = urandom(c.numdbnodes);
6395 node_id = c.restarter->getRandomNotMasterNodeId(rand);
6396 g_info <<
"restart node " << node_id <<
" (async)" << endl;
6398 chk1(c.restarter->restartOneDbNode2(node_id, flags) == 0);
6399 chk1(c.restarter->waitNodesNoStart(&node_id, 1) == 0);
6400 chk1(c.restarter->startNodes(&node_id, 1) == 0);
6402 chk1(st_create_table_index(c, tab) == 0);
6405 chk1(st_end_trans(c, 0) == 0);
6407 chk1(st_end_trans(c, ST_AbortFlag) == 0);
6409 g_info <<
"wait for node " << node_id <<
" to come up" << endl;
6410 chk1(c.restarter->waitClusterStarted() == 0);
6411 g_info <<
"verify all" << endl;
6412 chk1(st_verify_all(c) == 0);
6419 st_test_mnf_parse(
ST_Con& c,
int arg = -1)
6422 bool do_abort = (arg == 1);
6423 chk1(st_begin_trans(c) == 0);
6428 midcount = c.tabcount / 2;
6430 for (i = 0; i < c.tabcount; i++) {
6432 chk1(st_create_table_index(c, tab) == 0);
6433 if (i == midcount) {
6434 assert(c.numdbnodes > 1);
6435 node_id = c.restarter->getMasterNodeId();
6436 g_info <<
"restart node " << node_id <<
" (async)" << endl;
6438 chk1(c.restarter->restartOneDbNode2(node_id, flags) == 0);
6439 chk1(c.restarter->waitNodesNoStart(&node_id, 1) == 0);
6440 chk1(c.restarter->startNodes(&node_id, 1) == 0);
6445 chk1(st_end_trans_aborted(c, ST_CommitFlag) == 0);
6447 chk1(st_end_trans_aborted(c, ST_AbortFlag) == 0);
6449 g_info <<
"wait for node " << node_id <<
" to come up" << endl;
6450 chk1(c.restarter->waitClusterStarted() == 0);
6451 g_info <<
"verify all" << endl;
6452 for (i = 0; i < c.tabcount; i++) {
6457 NDBT_Table::discoverTableFromDb(c.ndb, tab.name);
6469 st_test_mnf_prepare(
ST_Con& c,
int arg = -1)
6473 ST_Errins errins = st_get_errins(c, st_errins_end_trans1);
6476 chk1(st_begin_trans(c) == 0);
6477 for (i = 0; i < c.tabcount; i++) {
6479 chk1(st_create_table_index(c, tab) == 0);
6483 chk1(st_end_trans_aborted(c, errins, ST_BackgroundFlag) == 0);
6484 chk1(st_wait_idle(c) == 0);
6487 chk1(st_end_trans_aborted(c, errins, ST_CommitFlag) == 0);
6488 chk1(c.restarter->waitClusterStarted() == 0);
6490 for (i = 0; i < c.tabcount; i++) {
6495 NDBT_Table::discoverTableFromDb(c.ndb, tab.name);
6504 st_test_mnf_commit1(
ST_Con& c,
int arg = -1)
6508 ST_Errins errins = st_get_errins(c, st_errins_end_trans2);
6511 chk1(st_begin_trans(c) == 0);
6512 for (i = 0; i < c.tabcount; i++) {
6514 chk1(st_create_table_index(c, tab) == 0);
6518 chk1(st_end_trans(c, errins, ST_BackgroundFlag) == 0);
6519 chk1(st_wait_idle(c) == 0);
6522 chk1(st_end_trans(c, errins, ST_CommitFlag) == 0);
6523 chk1(c.restarter->waitClusterStarted() == 0);
6525 for (i = 0; i < c.tabcount; i++) {
6527 chk1(st_verify_table(c, tab) == 0);
6529 chk1(st_drop_test_tables(c) == 0);
6536 st_test_mnf_commit2(
ST_Con& c,
int arg = -1)
6540 ST_Errins errins = st_get_errins(c, st_errins_end_trans3);
6543 chk1(st_begin_trans(c) == 0);
6544 for (i = 0; i < c.tabcount; i++) {
6546 chk1(st_create_table_index(c, tab) == 0);
6550 chk1(st_end_trans(c, errins, ST_BackgroundFlag) == 0);
6551 chk1(st_wait_idle(c) == 0);
6554 chk1(st_end_trans(c, errins, ST_CommitFlag) == 0);
6555 chk1(c.restarter->waitClusterStarted() == 0);
6557 chk1(st_verify_all(c) == 0);
6558 for (i = 0; i < c.tabcount; i++) {
6560 chk1(st_load_table(c, tab) == 0);
6562 chk1(st_drop_test_tables(c) == 0);
6569 st_test_mnf_run_commit(
ST_Con& c,
int arg = -1)
6576 if (arg == FAIL_BEGIN)
6579 if (restarter.getNumDbNodes() < 3)
6581 chk1(st_begin_trans(c) == -1);
6585 chk1(st_begin_trans(c) == 0);
6586 for (i = 0; i < c.tabcount; i++) {
6588 if (arg == FAIL_CREATE)
6590 chk1(st_create_table_index(c, tab) == -1);
6594 chk1(st_create_table_index(c, tab) == 0);
6596 if (arg == FAIL_END)
6598 chk1(st_end_trans(c, ST_CommitFlag) == -1);
6601 chk1(st_end_trans(c, ST_CommitFlag) == 0);
6604 g_info <<
"wait for master node to come up" << endl;
6605 chk1(c.restarter->waitClusterStarted() == 0);
6607 g_info <<
"verify all" << endl;
6608 for (i = 0; i < c.tabcount; i++) {
6618 NDBT_Table::discoverTableFromDb(c.ndb, tab.name);
6623 chk1(st_verify_table(c, tab) == 0);
6633 st_test_mnf_run_abort(
ST_Con& c,
int arg = -1)
6638 bool do_abort = (arg == SUCCEED_ABORT);
6641 chk1(st_begin_trans(c) == 0);
6642 for (i = 0; i < c.tabcount; i++) {
6644 chk1(st_create_table_index(c, tab) == 0);
6647 chk1(st_end_trans(c, ST_CommitFlag) == -1);
6649 chk1(st_end_trans_aborted(c, ST_AbortFlag) == 0);
6651 g_info <<
"wait for master node to come up" << endl;
6652 chk1(c.restarter->waitClusterStarted() == 0);
6654 g_info <<
"verify all" << endl;
6655 for (i = 0; i < c.tabcount; i++) {
6660 NDBT_Table::discoverTableFromDb(c.ndb, tab.name);
6670 st_test_mnf_start_partial(
ST_Con& c,
int arg = -1)
6672 ST_Errins errins(ERR_INSERT_PARTIAL_START_FAIL, 0, 1);
6673 chk1(st_do_errins(c, errins) == 0);
6674 return st_test_mnf_run_commit(c, arg);
6680 st_test_mnf_parse_partial(
ST_Con& c,
int arg = -1)
6682 ST_Errins errins(ERR_INSERT_PARTIAL_PARSE_FAIL, 0, 1);
6683 chk1(st_do_errins(c, errins) == 0);
6684 return st_test_mnf_run_commit(c, arg);
6690 st_test_mnf_flush_prepare_partial(
ST_Con& c,
int arg = -1)
6692 ST_Errins errins(ERR_INSERT_PARTIAL_FLUSH_PREPARE_FAIL, 0, 1);
6693 chk1(st_do_errins(c, errins) == 0);
6694 return st_test_mnf_run_commit(c, arg);
6700 st_test_mnf_prepare_partial(
ST_Con& c,
int arg = -1)
6702 ST_Errins errins(ERR_INSERT_PARTIAL_PREPARE_FAIL, 0, 1);
6703 chk1(st_do_errins(c, errins) == 0);
6704 return st_test_mnf_run_commit(c, arg);
6710 st_test_mnf_abort_parse_partial(
ST_Con& c,
int arg = -1)
6712 ST_Errins errins(ERR_INSERT_PARTIAL_ABORT_PARSE_FAIL, 0, 1);
6713 chk1(st_do_errins(c, errins) == 0);
6714 return st_test_mnf_run_abort(c, arg);
6720 st_test_mnf_abort_prepare_partial(
ST_Con& c,
int arg = -1)
6722 ST_Errins errins(ERR_INSERT_PARTIAL_ABORT_PREPARE_FAIL, 0, 1);
6723 chk1(st_do_errins(c, errins) == 0);
6724 return st_test_mnf_run_abort(c, arg);
6730 st_test_mnf_flush_commit_partial(
ST_Con& c,
int arg = -1)
6733 ST_Errins errins(ERR_INSERT_PARTIAL_FLUSH_COMMIT_FAIL, 0, 1);
6734 chk1(st_do_errins(c, errins) == 0);
6735 if (restarter.getNumDbNodes() < 3)
6737 return st_test_mnf_run_commit(c, FAIL_END);
6739 return st_test_mnf_run_commit(c, arg);
6745 st_test_mnf_commit_partial(
ST_Con& c,
int arg = -1)
6747 ST_Errins errins(ERR_INSERT_PARTIAL_COMMIT_FAIL, 0, 1);
6748 chk1(st_do_errins(c, errins) == 0);
6749 return st_test_mnf_run_commit(c, arg);
6755 st_test_mnf_flush_complete_partial(
ST_Con& c,
int arg = -1)
6757 ST_Errins errins(ERR_INSERT_PARTIAL_FLUSH_COMPLETE_FAIL, 0, 1);
6758 chk1(st_do_errins(c, errins) == 0);
6759 return st_test_mnf_run_commit(c, arg);
6765 st_test_mnf_complete_partial(
ST_Con& c,
int arg = -1)
6767 ST_Errins errins(ERR_INSERT_PARTIAL_COMPLETE_FAIL, 0, 1);
6768 chk1(st_do_errins(c, errins) == 0);
6769 return st_test_mnf_run_commit(c, arg);
6775 st_test_mnf_end_partial(
ST_Con& c,
int arg = -1)
6777 ST_Errins errins(ERR_INSERT_PARTIAL_END_FAIL, 0, 1);
6778 chk1(st_do_errins(c, errins) == 0);
6779 return st_test_mnf_run_commit(c, arg);
6785 st_test_sr_parse(
ST_Con& c,
int arg = -1)
6787 bool do_abort = (arg == 1);
6788 chk1(st_begin_trans(c) == 0);
6790 for (i = 0; i < c.tabcount; i++) {
6792 chk1(st_create_table_index(c, tab) == 0);
6795 chk1(st_end_trans(c, 0) == 0);
6797 chk1(st_end_trans(c, ST_AbortFlag) == 0);
6799 g_info <<
"restart all" << endl;
6801 flags = NdbRestarter::NRRF_NOSTART;
6802 chk1(c.restarter->restartAll2(flags) == 0);
6803 g_info <<
"wait for cluster started" << endl;
6804 chk1(c.restarter->waitClusterNoStart() == 0);
6805 chk1(c.restarter->startAll() == 0);
6806 chk1(c.restarter->waitClusterStarted() == 0);
6807 g_info <<
"verify all" << endl;
6808 chk1(st_verify_all(c) == 0);
6816 st_test_sr_commit(
ST_Con& c,
int arg = -1)
6818 g_info <<
"not yet" << endl;
6829 int (*func)(
ST_Con& c,
int arg);
6837 out <<
"CASE " << test.key;
6838 out <<
" " << test.name;
6840 out <<
"+" << test.arg;
6841 out <<
" - " << test.desc;
6847 #define func(f) f, #f
6850 func(st_test_create),
6851 "create all within trans, commit" },
6853 func(st_test_create),
6854 "create all within trans, abort" },
6857 "drop all within trans, commit" },
6860 "drop all within trans, abort" },
6862 func(st_test_rollback_create_table),
6863 "partial rollback of create table ops" },
6865 func(st_test_rollback_drop_table),
6866 "partial rollback of drop table ops" },
6868 func(st_test_rollback_create_index),
6869 "partial rollback of create index ops" },
6871 func(st_test_rollback_drop_index),
6872 "partial rollback of drop index ops" },
6874 func(st_test_dup_create_table),
6875 "try to create same table twice" },
6877 func(st_test_dup_drop_table),
6878 "try to drop same table twice" },
6880 func(st_test_dup_create_index),
6881 "try to create same index twice" },
6883 func(st_test_dup_drop_index),
6884 "try to drop same index twice" },
6886 func(st_test_build_index),
6887 "build index on non-empty table" },
6889 func(st_test_local_create),
6890 "fail trigger create in TC, master errins 8033" },
6892 func(st_test_local_create),
6893 "fail trigger create in TC, slave errins 8033" },
6895 func(st_test_local_create),
6896 "fail trigger create in TUP, master errins 4003" },
6898 func(st_test_local_create),
6899 "fail trigger create in TUP, slave errins 4003" },
6901 func(st_test_local_create),
6902 "fail index create in TC, master errins 8034" },
6904 func(st_test_local_create),
6905 "fail index create in TC, slave errins 8034" },
6908 func(st_test_trans),
6909 "start and stop schema trans" },
6910 {
"o2", 1, ST_AllowAbort,
6911 func(st_test_trans),
6912 "start and stop schema trans, allow abort" },
6913 {
"o3", 1, ST_AllowAbort | ST_AllowErrins,
6914 func(st_test_trans),
6915 "start and stop schema trans, allow abort errins" },
6918 func(st_test_create_table),
6919 "create tables at random" },
6920 {
"p2", 1, ST_AllowAbort,
6921 func(st_test_create_table),
6922 "create tables at random, allow abort" },
6923 {
"p3", 1, ST_AllowAbort | ST_AllowErrins,
6924 func(st_test_create_table),
6925 "create tables at random, allow abort errins" },
6928 func(st_test_table),
6929 "create and drop tables at random" },
6930 {
"p5", 1, ST_AllowAbort,
6931 func(st_test_table),
6932 "create and drop tables at random, allow abort" },
6933 {
"p6", 1, ST_AllowAbort | ST_AllowErrins,
6934 func(st_test_table),
6935 "create and drop tables at random, allow abort errins" },
6938 func(st_test_create_index),
6939 "create indexes at random" },
6940 {
"q2", 1, ST_AllowAbort,
6941 func(st_test_create_index),
6942 "create indexes at random, allow abort" },
6943 {
"q3", 1, ST_AllowAbort | ST_AllowErrins,
6944 func(st_test_create_index),
6945 "create indexes at random, allow abort errins" },
6948 func(st_test_index),
6949 "create and drop indexes at random" },
6950 {
"q5", 1, ST_AllowAbort,
6951 func(st_test_index),
6952 "create and drop indexes at random, allow abort" },
6953 {
"q6", 1, ST_AllowAbort | ST_AllowErrins,
6954 func(st_test_index),
6955 "create and drop indexes at random, allow abort errins" },
6958 func(st_test_anf_parse),
6959 "api node fail in parse phase" },
6961 func(st_test_anf_background),
6962 "api node fail after background trans" },
6964 func(st_test_anf_fail_begin),
6965 "api node fail in middle of kernel begin trans" },
6968 func(st_test_snf_parse),
6969 "slave node fail in parse phase, commit" },
6971 func(st_test_snf_parse),
6972 "slave node fail in parse phase, abort" },
6974 func(st_test_sr_parse),
6975 "system restart in parse phase, commit" },
6977 func(st_test_sr_parse),
6978 "system restart in parse phase, abort" },
6979 #ifdef ndb_master_failure
6981 func(st_test_mnf_parse),
6982 "master node fail in parse phase, commit" },
6984 func(st_test_mnf_parse),
6985 "master node fail in parse phase, abort" },
6987 func(st_test_mnf_prepare),
6988 "master node fail in prepare phase" },
6990 func(st_test_mnf_commit1),
6991 "master node fail in start of commit phase" },
6993 func(st_test_mnf_commit2),
6994 "master node fail in end of commit phase" },
6995 {
"y1", 2, FAIL_BEGIN,
6996 func(st_test_mnf_start_partial),
6997 "master node fail in start phase, partial rollback" },
6998 {
"y2", 2, FAIL_CREATE,
6999 func(st_test_mnf_parse_partial),
7000 "master node fail in parse phase, partial rollback" },
7001 {
"y3", 2, FAIL_END,
7002 func(st_test_mnf_flush_prepare_partial),
7003 "master node fail in flush prepare phase, partial rollback" },
7004 {
"y4", 2, FAIL_END,
7005 func(st_test_mnf_prepare_partial),
7006 "master node fail in prepare phase, partial rollback" },
7007 {
"y5", 2, SUCCEED_COMMIT,
7008 func(st_test_mnf_flush_commit_partial),
7009 "master node fail in flush commit phase, partial rollback" },
7010 {
"y6", 2, SUCCEED_COMMIT,
7011 func(st_test_mnf_commit_partial),
7012 "master node fail in commit phase, commit, partial rollforward" },
7013 {
"y7", 2, SUCCEED_COMMIT,
7014 func(st_test_mnf_flush_complete_partial),
7015 "master node fail in flush complete phase, commit, partial rollforward" },
7016 {
"y8", 2, SUCCEED_COMMIT,
7017 func(st_test_mnf_complete_partial),
7018 "master node fail in complete phase, commit, partial rollforward" },
7019 {
"y9", 2, SUCCEED_COMMIT,
7020 func(st_test_mnf_end_partial),
7021 "master node fail in end phase, commit, partial rollforward" },
7022 {
"z1", 2, SUCCEED_ABORT,
7023 func(st_test_mnf_abort_parse_partial),
7024 "master node fail in abort parse phase, partial rollback" },
7025 {
"z2", 2, FAIL_END,
7026 func(st_test_mnf_abort_prepare_partial),
7027 "master node fail in abort prepare phase, partial rollback" },
7029 func(st_test_mnf_prepare),
7030 "master node fail in prepare phase in background" },
7032 func(st_test_mnf_commit1),
7033 "master node fail in start of commit phase in background" },
7035 func(st_test_mnf_commit2),
7036 "master node fail in end of commit phase in background" },
7043 st_test_count =
sizeof(st_test_list)/
sizeof(st_test_list[0]);
7045 static const char* st_test_case = 0;
7046 static const char* st_test_skip = 0;
7049 st_test_match(
const ST_Test& test)
7052 if (st_test_case == 0)
7054 if (strstr(st_test_case, test.key) != 0)
7056 p = strchr(st_test_case, test.key[0]);
7057 if (p != 0 && (p[1] <
'0' || p[1] >
'9'))
7061 if (st_test_skip == 0)
7063 if (strstr(st_test_skip, test.key) != 0)
7065 p = strchr(st_test_skip, test.key[0]);
7066 if (p != 0 && (p[1] <
'0' || p[1] >
'9'))
7074 chk1(st_end_trans(c, ST_AbortFlag) == 0);
7075 chk1(st_drop_test_tables(c) == 0);
7076 chk1(st_check_db_nodes(c) == 0);
7078 g_err << test << endl;
7079 if (c.numdbnodes < test.mindbnodes) {
7080 g_err <<
"skip, too few db nodes" << endl;
7084 chk1((*test.func)(c, test.arg) == NDBT_OK);
7085 chk1(st_check_db_nodes(c) == 0);
7093 static int st_random_seed = -1;
7098 {
const char* env = NdbEnv_GetEnv(
"NDB_TEST_DBUG", 0, 0);
7099 if (env != 0 && env[0] != 0)
7102 {
const char* env = NdbEnv_GetEnv(
"NDB_TEST_CORE", 0, 0);
7103 if (env != 0 && env[0] != 0 && env[0] !=
'0' && env[0] !=
'N')
7104 st_core_on_err =
true;
7106 {
const char* env = NdbEnv_GetEnv(
"NDB_TEST_CASE", 0, 0);
7109 {
const char* env = NdbEnv_GetEnv(
"NDB_TEST_SKIP", 0, 0);
7112 {
const char* env = NdbEnv_GetEnv(
"NDB_TEST_SEED", 0, 0);
7114 st_random_seed = atoi(env);
7117 if (st_test_case != 0 && strcmp(st_test_case,
"?") == 0) {
7119 ndbout <<
"case func+arg desc" << endl;
7120 for (i = 0; i < st_test_count; i++) {
7121 const ST_Test& test = st_test_list[
i];
7122 ndbout << test << endl;
7124 return NDBT_WRONGARGS;
7127 if (st_random_seed == -1)
7128 st_random_seed = (short)getpid();
7129 if (st_random_seed != 0) {
7130 g_err <<
"random seed: " << st_random_seed << endl;
7131 ndb_srand(st_random_seed);
7133 g_err <<
"random seed: loop number" << endl;
7137 Ndb* ndb = GETNDB(step);
7139 ST_Con c(ncc, ndb, restarter);
7141 chk1(st_drop_all_tables(c) == 0);
7142 st_init_objects(c, ctx);
7145 numloops = ctx->getNumLoops();
7147 for (c.loop = 0; numloops == 0 || c.loop < numloops; c.loop++) {
7148 g_err <<
"LOOP " << c.loop << endl;
7149 if (st_random_seed == 0)
7152 for (i = 0; i < st_test_count; i++) {
7153 const ST_Test& test = st_test_list[
i];
7154 if (st_test_match(test)) {
7155 chk1(st_test(c, test) == NDBT_OK);
7160 st_report_db_nodes(c, g_err);
7163 st_report_db_nodes(c, g_err);
7172 static int lst[] = { 6204, 6205, 6206, 6207, 6208, 6209, 6210, 6211, 0 };
7175 int nodeId = restarter.getMasterNodeId();
7176 Ndb* pNdb = GETNDB(step);
7181 if (NdbEnv_GetEnv(
"ERRNO", buf,
sizeof(buf)))
7184 ndbout_c(
"Using errno: %u", errNo);
7187 const int loops = ctx->getNumLoops();
7188 int result = NDBT_OK;
7190 int dump1 = DumpStateOrd::SchemaResourceSnapshot;
7191 int dump2 = DumpStateOrd::SchemaResourceCheckLeak;
7197 if (pDic->
getHashMap(hm, hm.getName()) != -1)
7203 for (
int l = 0; l < loops; l++)
7205 for (
unsigned i0 = 0; lst[i0]; i0++)
7207 unsigned j = (l == 0 ? i0 : myRandom48(i0 + l));
7208 int errval = lst[j];
7209 if (errNo != 0 && errNo != errval)
7211 g_info <<
"insert error node=" << nodeId <<
" value=" << errval << endl;
7212 CHECK2(restarter.insertErrorInNode(nodeId, errval) == 0,
7213 "failed to set error insert");
7214 CHECK(restarter.dumpStateAllNodes(&dump1, 1) == 0);
7217 CHECK2(res != 0,
"create hashmap failed to fail");
7220 CHECK2(res != 0,
"create hashmap existed");
7222 CHECK2(restarter.insertErrorInNode(nodeId, 0) == 0,
7223 "failed to clear error insert");
7224 CHECK(restarter.dumpStateAllNodes(&dump2, 1) == 0);
7235 static int lst[] = { 7211, 7212, 4050, 12008, 6212, 6124, 6213, 6214, 0 };
7237 Ndb* pNdb = GETNDB(step);
7241 int nodeId = restarter.getMasterNodeId();
7245 if (NdbEnv_GetEnv(
"ERRNO", buf,
sizeof(buf)))
7248 ndbout_c(
"Using errno: %u", errNo);
7253 idx.setTable(tab.getName());
7255 idx.setLogging(
false);
7256 for (
int cnt = 0, i_hate_broken_compilers = 0;
7258 i_hate_broken_compilers < tab.getNoOfColumns();
7259 i_hate_broken_compilers++) {
7260 if (NdbSqlUtil::check_column_for_ordered_index
7261 (tab.getColumn(i_hate_broken_compilers)->getType(), 0) == 0 &&
7262 tab.getColumn(i_hate_broken_compilers)->getStorageType() !=
7263 NdbDictionary::Column::StorageTypeDisk)
7265 idx.addColumn(*tab.getColumn(i_hate_broken_compilers));
7270 for (
int i = 0; i<tab.getNoOfColumns(); i++)
7272 if (tab.getColumn(i)->getStorageType() ==
7273 NdbDictionary::Column::StorageTypeDisk)
7275 NDBT_Tables::create_default_tablespace(pNdb);
7280 const int loops = ctx->getNumLoops();
7281 int result = NDBT_OK;
7285 ndbout <<
"FAIL: " << pDic->
getNdbError() << endl;
7291 ndbout <<
"FAIL: " << pDic->
getNdbError() << endl;
7298 restarter.getNumDbNodes());
7302 ndbout <<
"Failed to beginSchemaTrans()" << pDic->
getNdbError() << endl;
7308 ndbout <<
"Failed to create hashmap: " << pDic->
getNdbError() << endl;
7314 ndbout <<
"Failed to endSchemaTrans()" << pDic->
getNdbError() << endl;
7318 int dump1 = DumpStateOrd::SchemaResourceSnapshot;
7319 int dump2 = DumpStateOrd::SchemaResourceCheckLeak;
7321 for (
int l = 0; l < loops; l++)
7323 for (
unsigned i0 = 0; lst[i0]; i0++)
7325 unsigned j = (l == 0 ? i0 : myRandom48(
sizeof(lst)/
sizeof(lst[0]) - 1));
7326 int errval = lst[j];
7327 if (errNo != 0 && errNo != errval)
7329 g_err <<
"insert error node=" << nodeId <<
" value=" << errval << endl;
7330 CHECK(restarter.dumpStateAllNodes(&dump1, 1) == 0);
7331 CHECK2(restarter.insertErrorInNode(nodeId, errval) == 0,
7332 "failed to set error insert");
7334 NdbSleep_MilliSleep(SAFTY);
7342 "failed to fail after error insert " << errval);
7343 CHECK2(restarter.insertErrorInNode(nodeId, 0) == 0,
7344 "failed to clear error insert");
7345 CHECK(restarter.dumpStateAllNodes(&dump2, 1) == 0);
7346 NdbSleep_MilliSleep(SAFTY);
7352 "table has been altered!");
7365 int result = NDBT_OK;
7367 Ndb* pNdb = GETNDB(step);
7369 int records = ctx->getNumRecords();
7370 const int loops = ctx->getNumLoops();
7372 ndbout <<
"|- " << ctx->getTab()->
getName() << endl;
7377 for (
int l = 0; l < loops && result == NDBT_OK ; l++)
7380 if (NDBT_Tables::createTable(pNdb, myTab.
getName()) != 0){
7386 NDBT_Table::discoverTableFromDb(pNdb, myTab.
getName());
7388 ndbout << myTab.
getName() <<
" was not found in DB"<< endl;
7396 if (beforeTrans.loadTable(pNdb, records) != 0){
7408 CHECK2(dict->
alterTable(*oldTable, newTable) == 0,
7409 "TableAddAttrs failed");
7418 ndbout <<
"delete...";
7419 if (afterTrans.clearTable(pNdb) != 0)
7425 ndbout <<
"insert...";
7426 if (afterTrans.loadTable(pNdb, records) != 0){
7431 ndbout <<
"update...";
7432 if (afterTrans.scanUpdateRecords(pNdb, records) != 0)
7438 ndbout <<
"delete...";
7439 if (afterTrans.clearTable(pNdb) != 0)
7460 Ndb* pNdb = GETNDB(step);
7464 creTab.setForceVarPart(
true);
7469 g_err << __LINE__ <<
": " << pDic->
getNdbError() << endl;
7475 while (ret == NDBT_OK) {
7477 assert(pOldTab != 0);
7484 g_err << __LINE__ <<
": " <<
"got status " << old_st << endl;
7489 if (old_cols != cols || old_vers != vers) {
7490 g_err << __LINE__ <<
": "
7491 <<
"got cols,vers " << old_cols <<
"," << old_vers
7492 <<
" expected " << cols <<
"," << vers << endl;
7496 if (old_cols >= 100)
7502 sprintf(colName,
"COL41905_%02d", cols);
7503 g_info <<
"add " << colName << endl;
7506 NdbDictionary::Column::StorageTypeMemory,
true);
7509 ctx->setProperty(
"Bug41905", 1);
7510 NdbSleep_MilliSleep(10);
7512 const bool removeEarly = (uint)rand() % 2;
7513 g_info <<
"removeEarly = " << removeEarly << endl;
7516 g_err << __LINE__ <<
": " << pDic->
getNdbError() << endl;
7521 g_err << __LINE__ <<
": " << pDic->
getNdbError() << endl;
7527 pDic->removeTableGlobal(*pOldTab, 0);
7530 g_err << __LINE__ <<
": " << pDic->
getNdbError() << endl;
7538 pDic->removeTableGlobal(*pOldTab, 0);
7539 ctx->setProperty(
"Bug41905", 2);
7540 NdbSleep_MilliSleep(10);
7543 ctx->setProperty(
"Bug41905", 3);
7552 Ndb* pNdb = GETNDB(step);
7557 if (ctx->getProperty(
"Bug41905") == 1)
7559 if (ctx->getProperty(
"Bug41905") == 3)
7561 NdbSleep_MilliSleep(10);
7564 uint ms = (uint)rand() % 1000;
7565 NdbSleep_MilliSleep(ms);
7566 g_info <<
"get begin ms=" << ms << endl;
7569 Uint32 oldstatus = 0;
7576 if (oldstatus == 2 && status == 3)
7577 g_info <<
"code=" << code <<
" status=" << status << endl;
7579 pDic->removeTableGlobal(*pTmp, 0);
7580 if (ctx->getProperty(
"Bug41905") != 1)
7582 NdbSleep_MilliSleep(10);
7584 g_info <<
"get end count=" << count << endl;
7605 idx0.setStoredIndex(
false);
7621 Ndb* pNdb = GETNDB(step);
7626 if (res.getNumDbNodes() < 2)
7653 if (createIndexes(pDic, tab1, 4))
7659 for (
int j = 0; j<res.getNumDbNodes(); j++)
7661 int node = res.getDbNodeId(j);
7662 int ng = res.getNodeGroup(node);
7663 if (nodeGroupMap.get(ng))
7665 group2.push_back(node);
7669 group1.push_back(node);
7670 nodeGroupMap.set(ng);
7675 NdbRestarter::NRRF_NOSTART |
7676 NdbRestarter::NRRF_ABORT);
7678 res.waitNodesNoStart(group1.getBase(), (int)group1.size());
7679 res.startNodes(group1.getBase(), (int)group1.size());
7680 res.waitClusterStarted();
7683 NdbRestarter::NRRF_NOSTART |
7684 NdbRestarter::NRRF_ABORT);
7685 res.waitNodesNoStart(group2.getBase(), (int)group2.size());
7686 res.startNodes(group2.getBase(), (int)group2.size());
7687 res.waitClusterStarted();
7701 if (createIndexes(pDic, tab0, 4))
7704 res.restartAll2(NdbRestarter::NRRF_NOSTART | NdbRestarter::NRRF_ABORT);
7705 res.waitClusterNoStart();
7707 res.waitClusterStarted();
7727 Ndb* pNdb = GETNDB(step);
7731 int records = ctx->getNumRecords();
7737 idx.setLogging(
false);
7738 for (
int cnt = 0, i_hate_broken_compilers = 0;
7741 i_hate_broken_compilers++) {
7742 if (NdbSqlUtil::check_column_for_ordered_index
7744 tab.
getColumn(i_hate_broken_compilers)->getStorageType() !=
7745 NdbDictionary::Column::StorageTypeDisk)
7747 idx.addColumn(*tab.
getColumn(i_hate_broken_compilers));
7754 if (tab.
getColumn(i)->getStorageType() ==
7755 NdbDictionary::Column::StorageTypeDisk)
7757 NDBT_Tables::create_default_tablespace(pNdb);
7762 const int loops = ctx->getNumLoops();
7763 int result = NDBT_OK;
7767 ndbout <<
"FAIL: " << pDic->
getNdbError() << endl;
7773 ndbout <<
"FAIL: " << pDic->
getNdbError() << endl;
7777 for (
int i = 0; i<loops; i++)
7782 CHECK2(trans.loadTable(pNdb, records) == 0,
7783 "load table failed");
7788 ndbout_c(
"alter from %u to %u partitions",
7794 ndbout <<
"Failed to beginSchemaTrans()" << pDic->
getNdbError() << endl;
7800 ndbout <<
"Failed to create hashmap: " << pDic->
getNdbError() << endl;
7806 ndbout <<
"Failed to endSchemaTrans()" << pDic->
getNdbError() << endl;
7831 "altered table does not have correct frag count");
7835 CHECK2(trans.scanUpdateRecords(pNdb, records) == 0,
7836 "scan update failed");
7837 trans.startTransaction(pNdb);
7838 trans.pkUpdateRecord(pNdb, 0);
7839 trans.execute_Commit(pNdb);
7840 ndbout_c(
"before restart, gci: %d", trans.getRecordGci(0));
7841 trans.closeTransaction(pNdb);
7846 if (res.getNumDbNodes() > 1)
7848 int nodeId = res.getNode(NdbRestarter::NS_RANDOM);
7849 ndbout_c(
"performing node-restart of node %d", nodeId);
7850 CHECK2(res.restartOneDbNode(nodeId,
7854 "restart one node failed");
7855 CHECK2(res.waitNodesNoStart(&nodeId, 1) == 0,
7856 "wait node started failed");
7857 CHECK2(res.startNodes(&nodeId, 1) == 0,
7858 "start node failed");
7863 ndbout_c(
"performing system restart");
7864 CHECK2(res.restartAll(
false,
true,
false) == 0,
7865 "restart all failed");
7866 CHECK2(res.waitClusterNoStart() == 0,
7867 "waitClusterNoStart failed");
7868 CHECK2(res.startAll() == 0,
7873 CHECK2(res.waitClusterStarted() == 0,
7874 "wait cluster started failed");
7876 Uint32 restartGCI = 0;
7878 "getRestartGCI failed");
7879 ndbout_c(
"restartGCI: %u", restartGCI);
7887 CHECK2(trans.selectCount(pNdb, 0, &cnt) == 0,
7888 "select count failed");
7890 CHECK2(cnt == records,
7891 "table does not have correct record count: "
7892 << cnt <<
" != " << records);
7895 "altered table does not have correct frag count");
7897 CHECK2(trans.scanUpdateRecords(pNdb, records) == 0,
7898 "scan update failed");
7899 CHECK2(trans.pkUpdateRecords(pNdb, records) == 0,
7900 "pkUpdateRecords failed");
7901 CHECK2(trans.clearTable(pNdb) == 0,
7902 "clear table failed");
7914 Ndb* pNdb = GETNDB(step);
7920 for (
unsigned i = 0; i< 25; i++)
7929 g_err <<
"Failed to create table" << copy.
getName() <<
"\n"
7936 g_err <<
"Failed to retreive table" << copy.
getName() << endl;
7943 res.restartAll2(NdbRestarter::NRRF_ABORT | NdbRestarter::NRRF_NOSTART);
7944 res.waitClusterNoStart();
7946 res.waitClusterStarted();
7948 for (
unsigned i = 0; i< 25; i++)
7957 g_err <<
"Failed to retreive table" << copy.
getName() << endl;
7964 g_err <<
"Failed to drop table" << copy.
getName() <<
"\n"
7971 for (
unsigned i = 0; i< 25; i++)
7980 g_err <<
"Failed to create table" << copy.
getName() <<
"\n"
7987 g_err <<
"Failed to retreive table" << copy.
getName() << endl;
7994 for (
unsigned i = 0; i< 25; i++)
8003 g_err <<
"Failed to retreive table" << copy.
getName() << endl;
8010 g_err <<
"Failed to drop table" << copy.
getName() <<
"\n"
8021 for (
size_t i = 0; i<ids.size(); i++)
8024 for (
size_t j = 0; j<ids2.size(); j++)
8034 ndbout_c(
"reused %u table-ids out of %u",
8035 (
unsigned)reused, (
unsigned)ids.size());
8037 if (reused >= (ids.size() >> 2))
8049 #define CHK2(b, e) \
8051 g_err << "ERR: " << #b << " failed at line " << __LINE__ \
8052 << ": " << e << endl; \
8053 result = NDBT_FAILED; \
8058 #define CHK3(b, e, x) \
8060 int n = sizeof(x)/sizeof(x[0]); \
8062 for (i = 0; i < n; i++) { \
8063 int s = (x[i] >= 0 ? +1 : -1); \
8064 if (e.code == s * x[i]) { \
8066 g_info << "OK: " << #b << " failed at line " << __LINE__ \
8067 << ": " << e << endl; \
8072 g_err << "ERR: " << #b << " failed at line " << __LINE__ \
8073 << ": " << e << endl; \
8074 result = NDBT_FAILED; \
8079 const char* tabName_Bug58277 =
"TBug58277";
8080 const char* indName_Bug58277 =
"TBug58277X1";
8086 Uint32 sub_steps = ctx->getProperty(
"SubSteps", (Uint32)0);
8087 require(sub_steps != 0);
8089 require(ctx->getProperty(
"SubCount", (Uint32)0) == 0);
8091 g_info <<
"step main: set " << state << endl;
8092 require(ctx->getProperty(state, (Uint32)0) == 0);
8093 ctx->setProperty(state, (Uint32)1);
8095 ctx->getPropertyWait(
"SubCount", sub_steps);
8096 if (ctx->isTestStopped())
8098 g_info <<
"step main: sub-steps got " << state << endl;
8100 ctx->setProperty(
"SubCount", (Uint32)0);
8101 ctx->setProperty(state, (Uint32)0);
8108 g_info <<
"step " << step->getStepNo() <<
": wait for " << state << endl;
8109 ctx->getPropertyWait(state, (Uint32)1);
8110 if (ctx->isTestStopped())
8113 ctx->incProperty(
"SubCount");
8114 g_info <<
"step " << step->getStepNo() <<
": got " << state << endl;
8121 Ndb* pNdb = GETNDB(step);
8123 int result = NDBT_OK;
8124 const int rows = ctx->getNumRecords();
8125 const char* tabname = tabName_Bug58277;
8129 CHK2(rows > 0,
"cannot use --records=0");
8130 g_info <<
"create table " << tabname << endl;
8132 const char* name[] = {
"a",
"b" };
8133 for (
int i = 0; i <= 1; i++)
8137 c.setPrimaryKey(i == 0);
8138 c.setNullable(
false);
8141 if (rand() % 3 != 0)
8143 g_info <<
"set FragAllLarge" << endl;
8155 Ndb* pNdb = GETNDB(step);
8157 int result = NDBT_OK;
8158 const int rows = ctx->getNumRecords();
8159 const char* tabname = tabName_Bug58277;
8163 g_info <<
"load table" << endl;
8168 for (
int i = 0; i < rows; i++)
8175 CHK2(pOp->insertTuple() == 0, pOp->getNdbError());
8177 Uint32 bVal = rand() % rows;
8178 CHK2(pOp->equal(
"a", (
char*)&aVal) == 0, pOp->getNdbError());
8179 CHK2(pOp->setValue(
"b", bVal) == 0, pOp->getNdbError());
8190 CHK2(result == NDBT_OK,
"load failed");
8193 CHK2(result == NDBT_OK,
"load failed");
8194 g_info <<
"load " << cnt <<
" rows" << endl;
8203 Ndb* pNdb = GETNDB(step);
8205 int result = NDBT_OK;
8206 const char* tabname = tabName_Bug58277;
8207 const char* indname = indName_Bug58277;
8211 g_info <<
"create index " << indname << endl;
8213 ind.setTable(tabname);
8215 ind.setLogging(
false);
8230 Ndb* pNdb = GETNDB(step);
8232 const int loops = ctx->getNumLoops();
8233 int result = NDBT_OK;
8236 const char* tabname = tabName_Bug58277;
8237 const char* indname = indName_Bug58277;
8240 const int errloops = loops < 5 ? loops : 5;
8242 while (!ctx->isTestStopped() && errloop < errloops)
8244 g_info <<
"===== errloop " << errloop <<
" =====" << endl;
8248 CHK2(runBug58277createtable(ctx, step) == NDBT_OK,
"create table failed");
8249 CHK2(runBug58277loadtable(ctx, step) == NDBT_OK,
"load table failed");
8250 CHK2(runBug58277createindex(ctx, step) == NDBT_OK,
"create index failed");
8259 const int errcnt = (int)(
sizeof(errins)/
sizeof(errins[0]));
8260 for (
int i = 0; i < errcnt; i += 2)
8262 const int ei = errins[i + 0];
8263 const int ec = errins[i + 1];
8264 CHK2(restarter.insertErrorInAllNodes(ei) == 0,
"value " << ei);
8269 CHK2((pSOp = pSTx->getNdbIndexScanOperation(pInd)) != 0, pSTx->getNdbError());
8273 CHK2(pSOp->readTuples(lm, flags) == 0, pSOp->getNdbError());
8276 CHK2(pSOp->getValue(
"a", (
char*)&aVal) != 0, pSOp->getNdbError());
8277 CHK2(pSTx->execute(NoCommit) == 0, pSTx->getNdbError());
8279 CHK2(pSOp->nextResult(
true) == -1,
"failed to fail on " << ei);
8280 CHK2(pSOp->getNdbError().code == ec,
"expect " << ec <<
" got " << pSOp->getNdbError());
8283 g_info <<
"error " << ei <<
" " << ec <<
" ok" << endl;
8284 CHK2(restarter.insertErrorInAllNodes(0) == 0,
"value " << 0);
8286 CHK2(result == NDBT_OK,
"test error handling failed");
8289 if (errloop == errloops)
8292 g_info <<
"table " << tabname <<
" dropped" << endl;
8295 if (result != NDBT_OK)
8297 g_info <<
"stop test at line " << __LINE__ << endl;
8306 Ndb* pNdb = GETNDB(step);
8308 int result = NDBT_OK;
8309 const char* tabname = tabName_Bug58277;
8310 const char* indname = indName_Bug58277;
8313 while (!ctx->isTestStopped())
8315 sync_sub_step(ctx, step,
"Start");
8316 if (ctx->isTestStopped())
8318 dropms = ctx->getProperty(
"DropMs", (Uint32)0);
8319 NdbSleep_MilliSleep(dropms);
8321 g_info <<
"drop index " << indname << endl;
8324 CHK2(pDic->
getIndex(indname, tabname) == 0,
"failed");
8325 g_info <<
"drop index done" << endl;
8327 sync_sub_step(ctx, step,
"Stop");
8328 if (ctx->isTestStopped())
8331 if (result != NDBT_OK)
8333 g_info <<
"stop test at line " << __LINE__ << endl;
8342 Ndb* pNdb = GETNDB(step);
8344 int result = NDBT_OK;
8345 const int rows = ctx->getNumRecords();
8346 const char* tabname = tabName_Bug58277;
8347 const char* indname = indName_Bug58277;
8348 const int range_max = ctx->getProperty(
"RANGE_MAX", (Uint32)0);
8349 require(range_max > 0);
8350 const bool scan_delete = ctx->getProperty(
"SCAN_DELETE", (Uint32)0);
8369 int range_cnt = rand() % range_max;
8370 if (range_cnt > 1 || rand() % 5 == 0)
8371 flags |= NdbIndexScanOperation::SF_MultiRange;
8372 CHK2(pSOp->readTuples(lm, flags) == 0, pSOp->getNdbError());
8373 g_info <<
"range cnt " << range_cnt << endl;
8374 for (
int i = 0; i < range_cnt; )
8378 if (rand() % 5 == 0)
8380 if (rand() % 5 != 0)
8381 tlo = 0 + rand() % 2;
8382 if (rand() % 5 != 0)
8383 thi = 2 + rand() % 2;
8388 if (tlo == -1 && thi == -1)
8394 blo = rand() % rows;
8395 CHK2(pSOp->setBound(
"b", tlo, &blo) == 0, pSOp->getNdbError());
8399 bhi = rand() % (rows + 1);
8401 bhi = rand() % (rows + 1);
8402 CHK2(pSOp->setBound(
"b", thi, &bhi) == 0, pSOp->getNdbError());
8404 CHK2(pSOp->end_of_bound() == 0, pSOp->getNdbError());
8407 CHK2(result == NDBT_OK,
"set bound ranges failed");
8410 CHK2(pSOp->getValue(
"a", (
char*)&aVal) != 0, pSOp->getNdbError());
8425 CHK3((ret = pSOp->nextResult(
true)) != -1, pSOp->getNdbError(), x);
8427 require(ret == 0 || ret == 1);
8436 int type = 1 + rand() % 3;
8446 CHK2((pOp = pSOp->updateCurrentTuple(pTx)) != 0, pSOp->getNdbError());
8447 Uint32 bVal = (Uint32)(rand() % rows);
8453 CHK2(pSOp->deleteCurrentTuple(pTx) == 0, pSOp->getNdbError());
8459 CHK2(result == NDBT_OK,
"scan takeover error");
8471 CHK2((ret = pSOp->nextResult(
false)) != -1, pSOp->getNdbError());
8472 require(ret == 0 || ret == 2);
8476 CHK2(result == NDBT_OK,
"batch failed");
8487 CHK2(result == NDBT_OK,
"batch failed");
8497 int result = NDBT_OK;
8499 while (!ctx->isTestStopped())
8501 sync_sub_step(ctx, step,
"Start");
8502 if (ctx->isTestStopped())
8504 g_info <<
"start scan loop" << endl;
8505 while (!ctx->isTestStopped())
8507 g_info <<
"start scan" << endl;
8508 int cnt[1+3] = { 0, 0, 0, 0 };
8509 CHK2(runBug58277scanop(ctx, step, cnt) == NDBT_OK,
"scan failed");
8510 g_info <<
"scan ops " << cnt[1] <<
"/-/" << cnt[3] << endl;
8512 if (ctx->getProperty(
"Stop", (Uint32)0) == 1)
8514 sync_sub_step(ctx, step,
"Stop");
8518 CHK2(result == NDBT_OK,
"scan loop failed");
8520 if (result != NDBT_OK)
8522 g_info <<
"stop test at line " << __LINE__ << endl;
8531 Ndb* pNdb = GETNDB(step);
8533 int result = NDBT_OK;
8534 const int rows = ctx->getNumRecords();
8535 const char* tabname = tabName_Bug58277;
8545 CHK2((pOp = pTx->getNdbOperation(pTab)) != 0, pTx->getNdbError());
8546 int type = 1 + rand() % 3;
8547 Uint32 aVal = rand() % rows;
8548 Uint32 bVal = rand() % rows;
8554 CHK2(pOp->updateTuple() == 0, pOp->getNdbError());
8555 CHK2(pOp->equal(
"a", (
char*)&aVal) == 0, pOp->getNdbError());
8556 CHK2(pOp->setValue(
"b", bVal) == 0, pOp->getNdbError());
8561 CHK3(pTx->execute(Commit) == 0, pTx->getNdbError(), x);
8566 CHK2(pOp->insertTuple() == 0, pOp->getNdbError());
8567 CHK2(pOp->equal(
"a", (
char*)&aVal) == 0, pOp->getNdbError());
8568 CHK2(pOp->setValue(
"b", bVal) == 0, pOp->getNdbError());
8573 CHK3(pTx->execute(Commit) == 0, pTx->getNdbError(), x);
8578 CHK2(pOp->deleteTuple() == 0, pOp->getNdbError());
8579 CHK2(pOp->equal(
"a", (
char*)&aVal) == 0, pOp->getNdbError());
8584 CHK3(pTx->execute(Commit) == 0, pTx->getNdbError(), x);
8590 CHK2(result == NDBT_OK,
"pk op failed");
8602 int result = NDBT_OK;
8604 while (!ctx->isTestStopped())
8606 sync_sub_step(ctx, step,
"Start");
8607 if (ctx->isTestStopped())
8610 g_info <<
"start pk loop" << endl;
8611 int cnt[1+3] = { 0, 0, 0, 0 };
8612 while (!ctx->isTestStopped())
8614 CHK2(runBug58277pkop(ctx, step, cnt) == NDBT_OK,
"pk op failed");
8616 if (ctx->getProperty(
"Stop", (Uint32)0) == 1)
8618 sync_sub_step(ctx, step,
"Stop");
8622 CHK2(result == NDBT_OK,
"pk loop failed");
8623 g_info <<
"pk ops " << cnt[1] <<
"/" << cnt[2] <<
"/" << cnt[3] << endl;
8625 if (result != NDBT_OK)
8627 g_info <<
"stop test at line " << __LINE__ << endl;
8636 int result = NDBT_OK;
8639 while (!ctx->isTestStopped())
8641 int sleepms = rand() % 5000;
8642 g_info <<
"rand sleep " << sleepms <<
" ms" << endl;
8643 NdbSleep_MilliSleep(sleepms);
8644 if (rand() % 5 == 0)
8646 g_info <<
"rand force LCP" << endl;
8647 int dump1[] = { DumpStateOrd::DihStartLcpImmediately };
8648 CHK2(restarter.dumpStateAllNodes(dump1, 1) == 0,
"failed");
8651 if (result != NDBT_OK)
8653 g_info <<
"stop test at line " << __LINE__ << endl;
8656 g_info <<
"rand exit" << endl;
8663 Ndb* pNdb = GETNDB(step);
8665 const int loops = ctx->getNumLoops();
8666 int result = NDBT_OK;
8667 const bool rss_check = ctx->getProperty(
"RSS_CHECK", (Uint32)0);
8669 const char* tabname = tabName_Bug58277;
8670 const char* indname = indName_Bug58277;
8674 while (!ctx->isTestStopped())
8676 g_info <<
"===== loop " << loop <<
" =====" << endl;
8680 CHK2(runBug58277createtable(ctx, step) == NDBT_OK,
"create table failed");
8681 CHK2(runBug58277loadtable(ctx, step) == NDBT_OK,
"load table failed");
8686 g_info <<
"save all resource usage" << endl;
8687 int dump1[] = { DumpStateOrd::SchemaResourceSnapshot };
8688 CHK2(restarter.dumpStateAllNodes(dump1, 1) == 0,
"failed");
8691 CHK2(runBug58277createindex(ctx, step) == NDBT_OK,
"create index failed");
8695 int dropms = dropmin + rand() % (dropmax - dropmin + 1);
8696 g_info <<
"drop in " << dropms <<
" ms" << endl;
8697 ctx->setProperty(
"DropMs", dropms);
8699 sync_main_step(ctx, step,
"Start");
8700 if (ctx->isTestStopped())
8704 int stopvar = rand() % 100;
8705 int stopsgn = (rand() % 2 == 0 ? +1 : -1);
8706 int stopms = dropms + stopsgn * stopvar;
8707 NdbSleep_MilliSleep(stopms);
8709 sync_main_step(ctx, step,
"Stop");
8710 if (ctx->isTestStopped())
8715 CHK2(pDic->
getIndex(indname, tabname) == 0,
"failed");
8719 g_info <<
"check all resource usage" << endl;
8720 int dump2[] = { DumpStateOrd::SchemaResourceCheckLeak };
8721 CHK2(restarter.dumpStateAllNodes(dump2, 1) == 0,
"failed");
8723 g_info <<
"check cluster is up" << endl;
8724 CHK2(restarter.waitClusterStarted() == 0,
"failed");
8727 if (++loop == loops)
8730 g_info <<
"table " << tabname <<
" dropped" << endl;
8735 g_info <<
"stop test at line " << __LINE__ << endl;
8743 Ndb* pNdb = GETNDB(step);
8745 const int loops = ctx->getNumLoops();
8746 int result = NDBT_OK;
8747 const bool rss_check = ctx->getProperty(
"RSS_CHECK", (Uint32)0);
8749 const char* tabname = tabName_Bug58277;
8754 while (!ctx->isTestStopped())
8756 g_info <<
"===== loop " << loop <<
" =====" << endl;
8760 CHK2(runBug58277createtable(ctx, step) == NDBT_OK,
"create table failed");
8761 CHK2(runBug58277createindex(ctx, step) == NDBT_OK,
"create index failed");
8764 CHK2(runBug58277loadtable(ctx, step) == NDBT_OK,
"load table failed");
8768 g_info <<
"save all resource usage" << endl;
8769 int dump1[] = { DumpStateOrd::SchemaResourceSnapshot };
8770 CHK2(restarter.dumpStateAllNodes(dump1, 1) == 0,
"failed");
8775 int dropms = dropmin + rand() % (dropmax - dropmin + 1);
8776 int stopms = dropms;
8778 sync_main_step(ctx, step,
"Start");
8779 if (ctx->isTestStopped())
8782 g_info <<
"stop in " << stopms <<
" ms" << endl;
8783 NdbSleep_MilliSleep(stopms);
8785 sync_main_step(ctx, step,
"Stop");
8786 if (ctx->isTestStopped())
8791 g_info <<
"check all resource usage" << endl;
8792 int dump2[] = { DumpStateOrd::SchemaResourceCheckLeak };
8793 CHK2(restarter.dumpStateAllNodes(dump2, 1) == 0,
"failed");
8795 g_info <<
"check cluster is up" << endl;
8796 CHK2(restarter.waitClusterStarted() == 0,
"failed");
8799 if (++loop == loops)
8802 g_info <<
"table " << tabname <<
" dropped" << endl;
8807 g_info <<
"stop test at line " << __LINE__ << endl;
8812 NDBT_TESTSUITE(testDict);
8813 TESTCASE(
"testDropDDObjects",
8814 "* 1. start cluster\n"
8817 "* 4. run DropDDObjects\n"
8818 "* 5. Verify DropDDObjectsRestart worked\n"){
8819 INITIALIZER(runWaitStarted);
8820 INITIALIZER(runDropDDObjects);
8821 INITIALIZER(testDropDDObjectsSetup);
8822 STEP(runDropDDObjects);
8823 FINALIZER(DropDDObjectsVerify);
8826 TESTCASE(
"Bug29501",
8827 "* 1. start cluster\n"
8828 "* 2. Restart 1 node -abort -nostart\n"
8830 "* 4. Restart data node\n"
8831 "* 5. Restart 1 node -nostart\n"
8833 INITIALIZER(runWaitStarted);
8834 INITIALIZER(runDropDDObjects);
8836 FINALIZER(runDropDDObjects);
8838 TESTCASE(
"CreateAndDrop",
8839 "Try to create and drop the table loop number of times\n"){
8840 INITIALIZER(runCreateAndDrop);
8842 TESTCASE(
"CreateAndDropAtRandom",
8843 "Try to create and drop table at random loop number of times\n"
8844 "Uses all available tables\n"
8845 "Uses error insert 4013 to make TUP verify table descriptor"){
8846 INITIALIZER(runCreateAndDropAtRandom);
8848 TESTCASE(
"CreateAndDropIndexes",
8849 "Like CreateAndDropAtRandom but also creates random ordered\n"
8850 "indexes and loads data as a simple check of index operation"){
8851 TC_PROPERTY(
"CreateIndexes", 1);
8852 TC_PROPERTY(
"LoadData", 1);
8853 INITIALIZER(runCreateAndDropAtRandom);
8855 TESTCASE(
"CreateAndDropWithData",
8856 "Try to create and drop the table when it's filled with data\n"
8857 "do this loop number of times\n"){
8858 INITIALIZER(runCreateAndDropWithData);
8860 TESTCASE(
"CreateAndDropDuring",
8861 "Try to create and drop the table when other thread is using it\n"
8862 "do this loop number of times\n"){
8863 STEP(runCreateAndDropDuring);
8864 STEP(runUseTableUntilStopped);
8866 TESTCASE(
"CreateInvalidTables",
8867 "Try to create the invalid tables we have defined\n"){
8868 INITIALIZER(runCreateInvalidTables);
8870 TESTCASE(
"CreateTableWhenDbIsFull",
8871 "Try to create a new table when db already is full\n"){
8872 INITIALIZER(runCreateTheTable);
8873 INITIALIZER(runFillTable);
8874 INITIALIZER(runCreateTableWhenDbIsFull);
8875 INITIALIZER(runDropTableWhenDbIsFull);
8876 FINALIZER(runDropTheTable);
8878 TESTCASE(
"FragmentTypeSingle",
8879 "Create the table with fragment type Single\n"){
8881 INITIALIZER(runTestFragmentTypes);
8883 TESTCASE(
"FragmentTypeAllSmall",
8884 "Create the table with fragment type AllSmall\n"){
8886 INITIALIZER(runTestFragmentTypes);
8888 TESTCASE(
"FragmentTypeAllMedium",
8889 "Create the table with fragment type AllMedium\n"){
8891 INITIALIZER(runTestFragmentTypes);
8893 TESTCASE(
"FragmentTypeAllLarge",
8894 "Create the table with fragment type AllLarge\n"){
8896 INITIALIZER(runTestFragmentTypes);
8898 TESTCASE(
"TemporaryTables",
8899 "Create the table as temporary and make sure it doesn't\n"
8900 "contain any data when system is restarted\n"){
8901 INITIALIZER(runTestTemporaryTables);
8903 TESTCASE(
"CreateMaxTables",
8904 "Create tables until db says that it can't create any more\n"){
8905 TC_PROPERTY(
"tables", 1000);
8906 INITIALIZER(runCreateMaxTables);
8907 INITIALIZER(runDropMaxTables);
8910 "Create tables with all different primary key sizes.\n"\
8911 "Test all data operations insert, update, delete etc.\n"\
8913 INITIALIZER(runPkSizes);
8915 TESTCASE(
"StoreFrm",
8916 "Test that a frm file can be properly stored as part of the\n"
8918 INITIALIZER(runStoreFrm);
8920 TESTCASE(
"GetPrimaryKey",
8921 "Test the function NdbDictionary::Column::getPrimaryKey\n"
8922 "It should return true only if the column is part of \n"
8923 "the primary key in the table"){
8924 INITIALIZER(runGetPrimaryKey);
8926 TESTCASE(
"StoreFrmError",
8927 "Test that a frm file with too long length can't be stored."){
8928 INITIALIZER(runStoreFrmError);
8930 TESTCASE(
"TableRename",
8931 "Test basic table rename"){
8932 INITIALIZER(runTableRename);
8934 TESTCASE(
"TableRenameSR",
8935 "Test that table rename can handle system restart"){
8936 INITIALIZER(runTableRenameSR);
8938 TESTCASE(
"DictionaryPerf",
8940 INITIALIZER(runTestDictionaryPerf);
8942 TESTCASE(
"CreateLogfileGroup",
""){
8943 INITIALIZER(runCreateLogfileGroup);
8945 TESTCASE(
"CreateTablespace",
""){
8946 INITIALIZER(runCreateTablespace);
8948 TESTCASE(
"CreateDiskTable",
""){
8949 INITIALIZER(runCreateDiskTable);
8951 TESTCASE(
"FailAddFragment",
8952 "Fail add fragment or attribute in ACC or TUP or TUX\n"){
8953 INITIALIZER(runFailAddFragment);
8955 TESTCASE(
"Restart_NF1",
8956 "DICT ops during node graceful shutdown (not master)"){
8957 TC_PROPERTY(
"Restart_NF_ops", 1);
8958 TC_PROPERTY(
"Restart_NF_type", 1);
8962 TESTCASE(
"Restart_NF2",
8963 "DICT ops during node shutdown abort (not master)"){
8964 TC_PROPERTY(
"Restart_NF_ops", 1);
8965 TC_PROPERTY(
"Restart_NF_type", 2);
8969 TESTCASE(
"Restart_NR1",
8970 "DICT ops during node startup (not master)"){
8971 TC_PROPERTY(
"Restart_NR_ops", 1);
8975 TESTCASE(
"Restart_NR2",
8976 "DICT ops during node startup with crash inserts (not master)"){
8977 TC_PROPERTY(
"Restart_NR_ops", 1);
8978 TC_PROPERTY(
"Restart_NR_error", 1);
8982 TESTCASE(
"TableAddAttrs",
8983 "Add attributes to an existing table using alterTable()"){
8984 INITIALIZER(runTableAddAttrs);
8986 TESTCASE(
"TableAddAttrsDuring",
8987 "Try to add attributes to the table when other thread is using it\n"
8988 "do this loop number of times\n"){
8989 INITIALIZER(runCreateTheTable);
8990 STEP(runTableAddAttrsDuring);
8991 STEP(runUseTableUntilStopped2);
8992 STEP(runUseTableUntilStopped3);
8993 FINALIZER(runDropTheTable);
8995 TESTCASE(
"TableAddAttrsDuringError",
8996 "Try to add attributes to the table when other thread is using it\n"
8997 "do this loop number of times\n"){
8998 TC_PROPERTY(
"AbortAlter", 1);
8999 INITIALIZER(runCreateTheTable);
9000 STEP(runTableAddAttrsDuring);
9001 STEP(runUseTableUntilStopped2);
9002 STEP(runUseTableUntilStopped3);
9003 FINALIZER(runDropTheTable);
9005 TESTCASE(
"Bug21755",
9007 INITIALIZER(runBug21755);
9009 TESTCASE(
"DictRestart",
9011 INITIALIZER(runDictRestart);
9013 TESTCASE(
"Bug24631",
9015 INITIALIZER(runBug24631);
9017 TESTCASE(
"Bug36702",
"")
9019 INITIALIZER(runDropDDObjects);
9020 INITIALIZER(runBug36072);
9021 FINALIZER(restartClusterInitial);
9023 TESTCASE(
"Bug29186",
9025 INITIALIZER(runBug29186);
9027 TESTCASE(
"Bug48604",
9028 "Online ordered index build.\n"
9029 "Complements testOIBasic -case f"){
9031 STEP(runBug48604ops);
9032 #if 0 // for future MT test
9033 STEP(runBug48604ops);
9034 STEP(runBug48604ops);
9035 STEP(runBug48604ops);
9038 TESTCASE(
"Bug54651",
""){
9039 INITIALIZER(runBug54651);
9042 TESTCASE(
"SchemaTrans",
9043 "Schema transactions"){
9045 STEP(runSchemaTrans);
9047 TESTCASE(
"FailCreateHashmap",
9048 "Fail create hashmap")
9050 INITIALIZER(runFailCreateHashmap);
9052 TESTCASE(
"FailAddPartition",
9053 "Fail add partition")
9055 INITIALIZER(runFailAddPartition);
9057 TESTCASE(
"TableAddPartitions",
9058 "Add partitions to an existing table using alterTable()"){
9059 INITIALIZER(runTableAddPartition);
9061 TESTCASE(
"Bug41905",
9064 STEP(runBug41905getTable);
9066 TESTCASE(
"Bug46552",
"")
9068 INITIALIZER(runBug46552);
9070 TESTCASE(
"Bug46585",
"")
9072 INITIALIZER(runWaitStarted);
9073 INITIALIZER(runBug46585);
9075 TESTCASE(
"Bug53944",
"")
9077 INITIALIZER(runBug53944);
9079 TESTCASE(
"Bug58277",
9080 "Dropping busy ordered index can crash data node.\n"
9081 "Give any tablename as argument (T1)"){
9082 TC_PROPERTY(
"RSS_CHECK", (Uint32)
true);
9083 TC_PROPERTY(
"RANGE_MAX", (Uint32)5);
9084 INITIALIZER(runBug58277errtest);
9087 TC_PROPERTY(
"SubSteps", 7);
9088 STEP(runBug58277drop);
9093 STEP(runBug58277scan);
9094 STEP(runBug58277scan);
9095 STEP(runBug58277scan);
9096 STEP(runBug58277scan);
9097 STEP(runBug58277pk);
9098 STEP(runBug58277pk);
9100 STEP(runBug58277rand);
9102 TESTCASE(
"Bug57057",
9103 "MRR + delete leaks stored procs (fixed under Bug58277).\n"
9104 "Give any tablename as argument (T1)"){
9105 TC_PROPERTY(
"RSS_CHECK", (Uint32)
true);
9106 TC_PROPERTY(
"RANGE_MAX", (Uint32)100);
9107 TC_PROPERTY(
"SCAN_DELETE", (Uint32)1);
9109 TC_PROPERTY(
"SubSteps", 1);
9110 STEP(runBug58277scan);
9112 NDBT_TESTSUITE_END(testDict);
9114 int main(
int argc,
const char** argv){
9116 NDBT_TESTSUITE_INSTANCE(testDict);
9118 testDict.setCreateTable(
false);
9119 myRandom48Init((
long)NdbTick_CurrentMillisecond());
9120 return testDict.execute(argc, argv);