59 #include <NdbThread.h>
63 #include <NdbTimer.hpp>
65 #include <NdbTest.hpp>
66 #include <NDBT_Error.hpp>
67 #include <NdbSchemaCon.hpp>
74 #define NDB_MAXTHREADS 256
82 #define MAXATTRSIZE 64
102 StartType threadStart;
107 extern "C" void* flexScanThread(
void*);
108 static int setAttrNames(
void);
109 static int setTableNames(
void);
110 static int createTables(
Ndb* pMyNdb);
111 static void sleepBeforeStartingTest(
int seconds);
112 static int readArguments(
int argc,
const char** argv);
113 static void setAttrValues(
int* attrValue,
116 static int insertRows(
Ndb* pNdb,
int* pkValue,
int* attrValue, StartType tType);
117 static int readRows(
Ndb* pNdb,
int* pkValue,
int* readValue);
118 static int deleteRows(
Ndb* pNdb,
int* pkValue);
119 static int scanReadRows(
Ndb* pNdb,
int* readValue);
120 static int scanUpdateRows(
Ndb* pNdb,
int* readValue,
int* attrValue);
121 static int scanDeleteRows(
Ndb* pNdb,
int* readValue);
122 static int verifyDeleteRows(
Ndb* pNdb,
int* pkValue,
int* readValue);
123 static void Compare(
int* attrValue,
int* readValue);
124 static void UpdateArray(
int *attrValue);
126 static int tNoOfThreads = 1;
127 static int tNoOfAttributes = 25;
128 static int tNoOfTables = 1;
129 static int tAttributeSize = 1;
130 static int tNodeId = 0;
131 static int tNoOfOperations = 500;
132 static int tNoOfLoops = 1;
133 static int tAbortAfter = 0;
134 static int tParallellism = 1;
136 static char tableName[MAXTABLES][MAXSTRLEN];
137 static char attrName[MAXATTR][MAXSTRLEN];
139 static unsigned int tSleepTime = 0;
141 static int theStdTableNameFlag = 0;
142 static int theTableCreateFlag = 0;
143 static int theScanAbortTestFlag = 0;
144 static int theNoScanUpdateFlag = 0;
145 static int theNoScanDeleteFlag = 0;
154 #define START_TIMER { NdbTimer timer; timer.doStart();
155 #define STOP_TIMER timer.doStop();
156 #define PRINT_TIMER(text, trans, opertrans) timer.printTransactionStatistics(text, trans, opertrans); };
158 static void UpdateArray(
int *attrValue)
164 int* pValue = attrValue;
166 for (tableCount = 0; tableCount < tNoOfTables; tableCount++) {
167 for (attrCount = 0; attrCount < tNoOfAttributes-1; attrCount++) {
168 for (opCount = 0; opCount < tNoOfOperations; opCount++) {
169 for (sizeCount = 0; sizeCount < tAttributeSize; sizeCount++) {
185 static void Compare(
int* attrValue,
int* readValue)
192 for (tableCount = 0; tableCount < tNoOfTables; tableCount++) {
193 for (attrCount = 0; attrCount < tNoOfAttributes-1; attrCount++) {
194 for (OpCount = 0; OpCount < tNoOfOperations; OpCount++) {
195 if (memcmp(&(attrValue[tableCount*(tNoOfAttributes-1)*tNoOfOperations +
196 attrCount*tNoOfOperations + OpCount]),
197 &(readValue[tableCount*(tNoOfAttributes-1)*tNoOfOperations +
198 attrCount*tNoOfOperations + OpCount]),
199 tAttributeSize) != 0) {
204 ndbout <<
"Mismatch found.";
229 static void printInfo()
231 ndbout << endl <<
"FLEXSCAN - Starting normal mode" << endl;
232 ndbout <<
"Perform benchmark of insert, update and delete transactions"<< endl;
233 ndbout <<
" NdbAPI node with id = " << tNodeId << endl;
234 ndbout <<
" " << tNoOfThreads <<
" thread(s) " << endl;
235 ndbout <<
" " << tNoOfLoops <<
" iterations " << endl;
236 ndbout <<
" " << tNoOfTables <<
" table(s) and " << 1 <<
" operation(s) per transaction "
238 ndbout <<
" " << tNoOfAttributes <<
" attributes per table incl. pk" << endl;
239 ndbout <<
" " << tNoOfOperations <<
" transaction(s) per thread and round " << endl;
240 if (theScanAbortTestFlag == 1) {
241 ndbout <<
" Scan abort test after " << tAbortAfter <<
" tuples" << endl;
243 ndbout <<
" " << tParallellism <<
" parallellism in scans" << endl;
244 ndbout <<
" " << tAttributeSize <<
" is the number of 32 bit words per attribute " <<
249 static void tellThreads(
ThreadNdb *threadArrayP, StartType what)
253 for (i = 0; i < tNoOfThreads ; i++)
254 threadArrayP[i].threadStart = what;
257 static void waitForThreads(
ThreadNdb *threadArrayP)
264 NdbSleep_MilliSleep(10);
267 for (i = 0; i < tNoOfThreads ; i++) {
268 if (threadArrayP[i].threadReady == 0) {
277 static void resetThreads(
ThreadNdb *threadArrayP)
281 for (i = 0; i < tNoOfThreads ; i++) {
282 threadArrayP[
i].threadReady = 0;
283 threadArrayP[
i].threadResult = 0;
284 threadArrayP[
i].threadStart = stIdle;
290 static int checkThreadResults(
ThreadNdb *threadArrayP,
char *action)
295 for (i = 0; i < tNoOfThreads; i++) {
296 if (threadArrayP[i].threadResult != 0) {
297 ndbout <<
"Thread " << i <<
" reported fatal error "
298 << threadArrayP[
i].threadResult <<
" during " << action << endl;
307 NDB_COMMAND(flexScan,
"flexScan",
"flexScan",
"flexScan", 65535)
314 int returnValue = NDBT_OK;
315 int every2ndScanDelete = 0;
321 if (readArguments(argc, argv) != 0) {
322 ndbout <<
"Wrong arguments to flexScan" << endl;
323 return NDBT_ProgramExit(NDBT_WRONGARGS);
329 check = setAttrNames();
331 ndbout <<
"Couldn't set attribute names" << endl;
332 return NDBT_ProgramExit(NDBT_FAILED);
334 check = setTableNames();
336 ndbout <<
"Couldn't set table names" << endl;
337 return NDBT_ProgramExit(NDBT_FAILED);
340 pMyNdb =
new Ndb (
"TEST_DB");
346 NdbThread_SetConcurrencyLevel(tNoOfThreads + 2);
352 ndbout <<
"NDB is not ready" << endl <<
"Benchmark failed" << endl;
353 returnValue = NDBT_FAILED;
358 if (createTables(pMyNdb) != 0) {
359 ndbout <<
"Could not create tables" << endl;
360 returnValue = NDBT_FAILED;
363 sleepBeforeStartingTest(tSleepTime);
365 resetThreads(pThreads);
367 for (
int i = 0; i < tNoOfThreads ; i++){
368 pThreads[
i].ThreadNo =
i;
370 pThreads[
i].threadLife = NdbThread_Create(flexScanThread,
371 (
void**)&pThreads[i],
373 "flexScanThread", NDB_THREAD_PRIO_LOW);
374 if (pThreads[i].threadLife == NULL) {
375 ndbout <<
"Could not create thread " << i << endl;
376 returnValue = NDBT_FAILED;
383 waitForThreads(pThreads);
384 if (checkThreadResults(pThreads,
"init") != 0) {
385 returnValue = NDBT_FAILED;
388 if (returnValue == NDBT_OK) {
389 ndbout <<
"All threads started" << endl;
393 resetThreads(pThreads);
395 if ((tNoOfLoops != 0) && (tNoOfLoops <= tLoops)) {
402 tellThreads(pThreads, stInsert);
403 waitForThreads(pThreads);
406 if (checkThreadResults(pThreads,
"insert") != 0) {
407 returnValue = NDBT_FAILED;
410 PRINT_TIMER(
"insert", tNoOfOperations*tNoOfThreads, tNoOfTables);
412 resetThreads(pThreads);
417 tellThreads(pThreads, stRead);
418 waitForThreads(pThreads);
421 if (checkThreadResults(pThreads,
"read") != 0) {
422 returnValue = NDBT_FAILED;
425 PRINT_TIMER(
"read", tNoOfOperations*tNoOfThreads, tNoOfTables);
427 resetThreads(pThreads);
432 tellThreads(pThreads, stUpdate);
433 waitForThreads(pThreads);
436 if (checkThreadResults(pThreads,
"update") != 0) {
437 returnValue = NDBT_FAILED;
440 PRINT_TIMER(
"update", tNoOfOperations*tNoOfThreads, tNoOfTables);
442 resetThreads(pThreads);
447 tellThreads(pThreads, stScanRead);
448 waitForThreads(pThreads);
451 if (checkThreadResults(pThreads,
"scanread") != 0) {
452 returnValue = NDBT_FAILED;
455 PRINT_TIMER(
"scanread", tNoOfTables*tNoOfThreads, 1);
457 resetThreads(pThreads);
462 tellThreads(pThreads, stUpdate);
463 waitForThreads(pThreads);
466 if (checkThreadResults(pThreads,
"update") != 0) {
467 returnValue = NDBT_FAILED;
470 PRINT_TIMER(
"update", tNoOfOperations*tNoOfThreads, tNoOfTables);
472 resetThreads(pThreads);
477 tellThreads(pThreads, stRead);
478 waitForThreads(pThreads);
481 if (checkThreadResults(pThreads,
"read") != 0) {
482 returnValue = NDBT_FAILED;
485 PRINT_TIMER(
"read", tNoOfOperations*tNoOfThreads, tNoOfTables);
487 resetThreads(pThreads);
490 if (theNoScanUpdateFlag == 0) {
494 tellThreads(pThreads, stScanUpdate);
495 waitForThreads(pThreads);
498 if (checkThreadResults(pThreads,
"scanupdate") != 0) {
499 returnValue = NDBT_FAILED;
502 PRINT_TIMER(
"scanupdate", tNoOfTables*tNoOfThreads, 1);
504 resetThreads(pThreads);
509 tellThreads(pThreads, stRead);
511 waitForThreads(pThreads);
514 if (checkThreadResults(pThreads,
"read") != 0) {
515 returnValue = NDBT_FAILED;
518 PRINT_TIMER(
"read", tNoOfOperations*tNoOfThreads, tNoOfTables);
520 resetThreads(pThreads);
524 if ((every2ndScanDelete % 2 == 0) || (theNoScanDeleteFlag == 1)){
527 tellThreads(pThreads, stDelete);
528 waitForThreads(pThreads);
531 if (checkThreadResults(pThreads,
"delete") != 0) {
532 returnValue = NDBT_FAILED;
535 PRINT_TIMER(
"delete", tNoOfOperations*tNoOfThreads, tNoOfTables);
536 resetThreads(pThreads);
539 resetThreads(pThreads);
541 tellThreads(pThreads, stScanDelete);
542 waitForThreads(pThreads);
545 if (checkThreadResults(pThreads,
"scandelete") != 0) {
546 returnValue = NDBT_FAILED;
549 PRINT_TIMER(
"scandelete", tNoOfTables*tNoOfThreads, 1);
551 resetThreads(pThreads);
553 every2ndScanDelete++;
555 resetThreads(pThreads);
557 tellThreads(pThreads, stVerifyDelete);
558 waitForThreads(pThreads);
561 if (checkThreadResults(pThreads,
"verifydelete") != 0) {
562 returnValue = NDBT_FAILED;
565 PRINT_TIMER(
"verifydelete", tNoOfOperations*tNoOfThreads*tNoOfTables, 1);
567 resetThreads(pThreads);
569 ndbout <<
"--------------------------------------------------" << endl;
578 tellThreads(pThreads, stStop);
579 waitForThreads(pThreads);
587 if (returnValue == NDBT_OK) {
588 ndbout << endl <<
"Benchmark completed successfully" << endl;
591 ndbout << endl <<
"Benchmark failed" << endl;
595 return NDBT_ProgramExit(returnValue);;
602 unsigned int thread_no = pThreadData->ThreadNo;
603 unsigned int thread_base = (thread_no * 2000000) + (tNodeId * 26000);
604 int tThreadResult = 0;
607 StartType tType = stLast;
609 int* attrValue = NULL;
610 int* readValue = NULL;
613 AllocSize = tNoOfTables * (tNoOfAttributes-1) * tNoOfOperations *
614 tAttributeSize *
sizeof(
int);
615 attrValue = (
int*)malloc(AllocSize);
616 readValue = (
int*)malloc(AllocSize);
617 pkValue = (
int*)malloc(tNoOfOperations *
sizeof(
int));
618 if ((attrValue == NULL) || (readValue == NULL) || (pkValue == NULL)) {
620 pThreadData->threadStart = stIdle;
623 setAttrValues(attrValue, readValue, thread_base);
625 MyNdb =
new Ndb(
"TEST_DB" );
629 pThreadData->threadStart = stIdle;
633 for (
int c = 0; c < tNoOfOperations; c++) {
634 pkValue[c] = (int)(c + thread_base);
638 pThreadData->threadResult = tThreadResult;
639 pThreadData->threadReady = 1;
641 while (pThreadData->threadStart == stIdle) {
642 NdbSleep_MilliSleep(10);
646 if (pThreadData->threadStart >= stStop){
647 pThreadData->threadReady = 1;
650 tType = pThreadData->threadStart;
651 pThreadData->threadStart = stIdle;
655 check = insertRows(MyNdb, pkValue, attrValue, tType);
658 check = readRows(MyNdb, pkValue, readValue);
659 Compare(attrValue, readValue);
662 UpdateArray(attrValue);
663 check = insertRows(MyNdb, pkValue, attrValue, tType);
667 check = scanReadRows(MyNdb, readValue);
668 Compare(attrValue, readValue);
671 UpdateArray(attrValue);
674 check = scanUpdateRows(MyNdb, readValue, attrValue);
677 check = deleteRows(MyNdb, pkValue);
680 check = scanDeleteRows(MyNdb, readValue);
683 check = verifyDeleteRows(MyNdb, pkValue, readValue);
686 ndbout <<
"tType is " << tType << endl;
691 tThreadResult = check;
693 if (tThreadResult != 0) {
703 if (attrValue != NULL) {
706 if (readValue != NULL) {
709 if (pkValue != NULL) {
718 static int setAttrNames()
723 for (i = 0; i < MAXATTR ; i++) {
734 static int setTableNames()
741 for (i = 0; i < MAXTABLES ; i++) {
743 if (theStdTableNameFlag == 0) {
745 (
int)(NdbTick_CurrentMillisecond() / 1000));
761 static int createTables(
Ndb* pMyNdb)
770 if (theTableCreateFlag == 0) {
775 ndbout << endl <<
"Creating " << tableName[i - 1] <<
"..." << endl;
777 MySchemaTransaction = NdbSchemaCon::startSchemaTrans(pMyNdb);
778 if( MySchemaTransaction == NULL ) {
783 if( MySchemaOp == NULL ) {
784 NdbSchemaCon::closeSchemaTrans(MySchemaTransaction);
794 NdbSchemaCon::closeSchemaTrans(MySchemaTransaction);
798 check = MySchemaOp->
createAttribute( (
char*)attrName[0], TupleKey, 32, PKSIZE,
799 UnSigned, MMBased, NotNullAttribute );
801 NdbSchemaCon::closeSchemaTrans(MySchemaTransaction);
805 for (j = 1; j < tNoOfAttributes ; j++) {
806 check = MySchemaOp->
createAttribute( (
char*)attrName[j], NoKey, 32, tAttributeSize,
807 UnSigned, MMBased, NotNullAttribute );
809 NdbSchemaCon::closeSchemaTrans(MySchemaTransaction);
814 if (MySchemaTransaction->
execute() == -1) {
816 ndbout <<
"Probably, " << tableName[i - 1] <<
" already exist" << endl;
819 NdbSchemaCon::closeSchemaTrans(MySchemaTransaction);
820 }
while (tNoOfTables > i);
826 static void printUsage()
828 ndbout <<
"Usage of flexScan:" << endl;
829 ndbout <<
"-f <path> Location of my.cnf file, default: my.cnf" << endl;
830 ndbout <<
"-t <int> Number of threads to start, default 1" << endl;
831 ndbout <<
"-o <int> Number of operations per loop, default 500" << endl;
832 ndbout <<
"-l <int> Number of loops to run, default 1, 0=infinite" << endl;
833 ndbout <<
"-a <int> Number of attributes, default 25" << endl;
834 ndbout <<
"-c <int> Number of tables, default 1" << endl;
835 ndbout <<
"-s <int> Size of each attribute, default 1" << endl;
836 ndbout <<
"-stdtables Use standard table names" << endl;
837 ndbout <<
"-no_table_create Don't create tables in db" << endl;
838 ndbout <<
"-sleep <int> Sleep a number of seconds before running the test" << endl;
839 ndbout <<
"-p <int> Parallellism to use 1-32, default:1" << endl;
840 ndbout <<
"-abort <int> Test scan abort after a number of tuples" << endl;
841 ndbout <<
"-no_scan_update Don't do scan updates" << endl;
842 ndbout <<
"-no_scan_delete Don't do scan deletes" << endl;
843 ndbout <<
"-h Print this text" << endl;
848 static int readArguments(
int argc,
const char** argv)
858 if (strcmp(argv[i],
"-t") == 0) {
859 if (argv[i + 1] != NULL) {
860 tNoOfThreads = atoi(argv[i + 1]);
861 if ((tNoOfThreads < 1) || (tNoOfThreads > NDB_MAXTHREADS)) {
869 else if (strcmp(argv[i],
"-o") == 0) {
870 if (argv[i + 1] != NULL) {
871 tNoOfOperations = atoi(argv[i + 1]);
872 if (tNoOfOperations < 1) {
880 else if (strcmp(argv[i],
"-a") == 0) {
881 if (argv[i + 1] != NULL) {
882 tNoOfAttributes = atoi(argv[i + 1]);
883 if ((tNoOfAttributes < 2) || (tNoOfAttributes > MAXATTR)) {
891 else if (strcmp(argv[i],
"-c") == 0) {
892 if (argv[i + 1] != NULL) {
893 tNoOfTables = atoi(argv[i+1]);
894 if ((tNoOfTables < 1) || (tNoOfTables > MAXTABLES)) {
902 else if (strcmp(argv[i],
"-l") == 0) {
903 if (argv[i + 1] != NULL) {
904 tNoOfLoops = atoi(argv[i+1]);
905 if ((tNoOfLoops < 0) || (tNoOfLoops > 100000)) {
913 else if (strcmp(argv[i],
"-s") == 0) {
914 if (argv[i + 1] != NULL) {
915 tAttributeSize = atoi(argv[i+1]);
916 if ((tAttributeSize < 1) || (tAttributeSize > MAXATTRSIZE)) {
924 else if (strcmp(argv[i],
"-no_table_create") == 0) {
925 theTableCreateFlag = 1;
929 else if (strcmp(argv[i],
"-stdtables") == 0) {
930 theStdTableNameFlag = 1;
934 else if (strcmp(argv[i],
"-sleep") == 0) {
935 if (argv[i + 1] != NULL) {
936 tSleepTime = atoi(argv[i+1]);
937 if ((tSleepTime < 1) || (tSleepTime > 3600)) {
945 else if (strcmp(argv[i],
"-abort") == 0) {
947 theScanAbortTestFlag = 1;
948 if (argv[i + 1] != NULL) {
949 tAbortAfter = atoi(argv[i + 1]);
955 else if (strcmp(argv[i],
"-p") == 0) {
956 if (argv[i + 1] != NULL) {
957 tParallellism = atoi(argv[i + 1]);
958 if ((tParallellism < 1) || (tParallellism > 32)) {
966 else if (strcmp(argv[i],
"-h") == 0) {
971 else if (strcmp(argv[i],
"-no_scan_update") == 0) {
972 theNoScanUpdateFlag = 1;
976 else if (strcmp(argv[i],
"-no_scan_delete") == 0) {
977 theNoScanDeleteFlag = 1;
989 if ((retValue != 0) || (printFlag == 1)) {
997 static void sleepBeforeStartingTest(
int seconds)
1000 ndbout <<
"Sleeping(" <<seconds <<
")...";
1001 NdbSleep_SecSleep(seconds);
1002 ndbout <<
" done!" << endl;
1006 static void setAttrValues(
int* attrValue,
1018 for (tableCount = 0; tableCount < tNoOfTables; tableCount++) {
1019 for (attrCount = 0; attrCount < tNoOfAttributes-1; attrCount++) {
1020 for (OpCount = 0; OpCount < tNoOfOperations; OpCount++) {
1021 pAttr = &(attrValue[tableCount*(tNoOfAttributes-1)*tNoOfOperations +
1022 attrCount*tNoOfOperations + OpCount]);
1023 pRead = &(readValue[tableCount*(tNoOfAttributes-1)*tNoOfOperations +
1024 attrCount*tNoOfOperations + OpCount]);
1025 for (attrSize = 0; attrSize < tAttributeSize; attrSize++){
1026 *pAttr = (int)(Offset + tableCount + attrCount + OpCount + attrSize);
1041 static int insertRows(
Ndb* pNdb,
1054 for (opCount = 0; opCount < tNoOfOperations; opCount++) {
1056 if (MyTransaction == NULL) {
1060 for (tableCount = 0; tableCount < tNoOfTables; tableCount++) {
1062 MyOperations[tableCount] =
1064 if (MyOperations[tableCount] == NULL) {
1070 if (tType == stUpdate) {
1073 else if (tType == stInsert) {
1084 check = MyOperations[tableCount]->
equal((
char*)attrName[0],
1085 (
char*)&(pkValue[opCount]));
1091 for (attrCount = 0; attrCount < tNoOfAttributes - 1; attrCount++) {
1092 int Index = tableCount * (tNoOfAttributes - 1) * tNoOfOperations * tAttributeSize +
1093 attrCount * tNoOfOperations * tAttributeSize + opCount * tAttributeSize;
1094 check = MyOperations[tableCount]->
1095 setValue((
char*)attrName[attrCount + 1],
1096 (
char*)&(attrValue[Index]));
1105 check = MyTransaction->
execute(Commit);
1111 int retCode = flexScanErrorData->handleErrorCommon(MyTransaction->
getNdbError());
1114 ndbout_c(
"execute: %d, %d, %s", opCount, tType, MyTransaction->
getNdbError().
message);
1117 }
else if (retCode == 2) {
1118 ndbout <<
"4115 should not happen in flexBench" << endl;
1120 }
else if (retCode == 3) {
1141 static int readRows(
Ndb* pNdb,
1156 for (opCount = 0; opCount < tNoOfOperations; opCount++) {
1158 if (MyTransaction == NULL) {
1162 for (tableCount = 0; tableCount < tNoOfTables; tableCount++) {
1164 MyOperations[tableCount] =
1166 if (MyOperations[tableCount] == NULL) {
1172 check = MyOperations[tableCount]->
readTuple();
1178 check = MyOperations[tableCount]->
1179 equal((
char*)attrName[0], (
char*)&(pkValue[opCount]));
1185 for (
int attrCount = 0; attrCount < tNoOfAttributes - 1; attrCount++) {
1186 Index = tableCount * (tNoOfAttributes - 1) * tNoOfOperations * tAttributeSize +
1187 attrCount * tNoOfOperations * tAttributeSize + opCount * tAttributeSize;
1188 tmp = MyOperations[tableCount]->
1189 getValue((
char*)attrName[attrCount + 1], (
char*)&(readValue[Index]));
1198 check = MyTransaction->
execute(Commit);
1204 int retCode = flexScanErrorData->handleErrorCommon(MyTransaction->
getNdbError());
1207 ndbout_c(
"execute: %d, %s", opCount, MyTransaction ->getNdbError().
message );
1210 }
else if (retCode == 2) {
1211 ndbout <<
"4115 should not happen in flexBench" << endl;
1213 }
else if (retCode == 3) {
1222 ndbout_c(
"execute: %s", MyTransaction ->getNdbError().
message );
1234 static int scanReadRows(
Ndb* pNdb,
int* readValue)
1246 for (tableCount = 0; tableCount < tNoOfTables; tableCount++) {
1248 if (MyTransaction == NULL) {
1253 if (MyOperation == NULL) {
1258 check = MyOperation->openScanRead(tParallellism);
1264 for (
int attrCount = 0; attrCount < tNoOfAttributes-1; attrCount++) {
1267 getValue((
char*)attrName[attrCount+1],
1268 (
char*)&(readValue[tableCount*(tNoOfAttributes-1)*tNoOfOperations*tAttributeSize +
1269 attrCount*tNoOfOperations*tAttributeSize]));
1276 check = MyTransaction->executeScan();
1282 check = MyTransaction->nextScanResult();
1283 while (check == 0) {
1285 if (theScanAbortTestFlag == 1) {
1286 if (countAbort == tAbortAfter) {
1287 MyTransaction->stopScan();
1288 ndbout <<
"scanread aborted on request after " << countAbort*tParallellism <<
1294 check = MyTransaction->nextScanResult();
1303 static int scanUpdateRows(
Ndb* pNdb,
1318 for (tableCount = 0; tableCount < tNoOfTables; tableCount++) {
1320 if (MyTransaction == NULL) {
1325 if (MyOperation == NULL) {
1330 check = MyOperation->openScanExclusive(tParallellism);
1337 for (
int attrCount = 0; attrCount < tNoOfAttributes-1; attrCount++) {
1338 tTmp = MyOperation->
1339 getValue((
char*)attrName[attrCount+1],
1340 (
char*)&(readValue[tableCount*(tNoOfAttributes-1)*tNoOfOperations*tAttributeSize +
1341 attrCount*tNoOfOperations*tAttributeSize]));
1351 check = MyTransaction->executeScan();
1356 check = MyTransaction->nextScanResult();
1358 while (check == 0) {
1360 MyTakeOverOp = MyOperation->takeOverForUpdate(MyTakeOverTrans);
1361 for (attrCount = 0; attrCount < tNoOfAttributes-1; attrCount++) {
1362 check = MyTakeOverOp->
setValue((
char*)attrName[attrCount+1],
1363 (
char*)&(attrValue[tableCount*(tNoOfAttributes-1)*tNoOfOperations*tAttributeSize +
1364 attrCount*tNoOfOperations*tAttributeSize + opCount*tAttributeSize]));
1367 check = MyTakeOverTrans->
execute(Commit);
1369 check = MyTransaction->nextScanResult();
1378 int retCode = flexScanErrorData->handleErrorCommon(MyTakeOverTrans->
getNdbError());
1384 }
else if (retCode == 2) {
1385 ndbout <<
"4115 should not happen in flexBench" << endl;
1387 }
else if (retCode == 3) {
1409 static int scanDeleteRows(
Ndb* pNdb,
int* readValue)
1421 for (tableCount = 0; tableCount < tNoOfTables; tableCount++) {
1423 if (MyTransaction == NULL) {
1429 if (MyOperation == NULL) {
1434 check = MyOperation->openScanExclusive(tParallellism);
1440 for (
int attrCount = 0; attrCount < tNoOfAttributes-1; attrCount++) {
1441 tTmp = MyOperation->
1442 getValue((
char*)attrName[attrCount+1],
1443 (
char*)&(readValue[tableCount*(tNoOfAttributes-1)*tNoOfOperations +
1444 attrCount*tNoOfOperations]));
1451 check = MyTransaction->executeScan();
1456 check = MyTransaction->nextScanResult();
1457 while (check == 0) {
1459 MyTakeOverOp = MyOperation->takeOverForDelete(MyTakeOverTrans);
1462 check = MyTakeOverTrans->
execute(Commit);
1466 int retCode =flexScanErrorData->handleErrorCommon(MyTakeOverTrans->
getNdbError());
1472 }
else if (retCode == 2) {
1473 ndbout <<
"4115 should not happen in flexBench" << endl;
1475 }
else if (retCode == 3) {
1488 check = MyTransaction->nextScanResult();
1495 static int deleteRows(
Ndb* pNdb,
1505 for (opCount = 0; opCount < tNoOfOperations; opCount++) {
1507 if (MyTransaction == NULL) {
1511 for (tableCount = 0; tableCount < tNoOfTables; tableCount++) {
1513 MyOperations[tableCount] =
1515 if (MyOperations[tableCount] == NULL) {
1527 check = MyOperations[tableCount]->
1528 equal((
char*)attrName[0], (
char*)&(pkValue[opCount]));
1537 check = MyTransaction->
execute(Commit);
1542 int retCode = flexScanErrorData->handleErrorCommon(MyTransaction->
getNdbError());
1548 }
else if (retCode == 2) {
1549 ndbout <<
"4115 should not happen in flexBench" << endl;
1551 }
else if (retCode == 3) {
1583 static int verifyDeleteRows(
Ndb* pNdb,
1598 for (opCount = 0; opCount < tNoOfOperations; opCount++) {
1599 for (tableCount = 0; tableCount < tNoOfTables; tableCount++) {
1601 if (MyTransaction == NULL) {
1608 if (MyOperations == NULL) {
1620 check = MyOperations->
1621 equal((
char*)attrName[0], (
char*)&(pkValue[opCount]));
1627 for (
int attrCount = 0; attrCount < tNoOfAttributes - 1; attrCount++) {
1628 Index = tableCount * (tNoOfAttributes - 1) * tNoOfOperations * tAttributeSize +
1629 attrCount * tNoOfOperations * tAttributeSize + opCount * tAttributeSize;
1630 tmp = MyOperations->
1631 getValue((
char*)attrName[attrCount + 1], (
char*)&(readValue[Index]));
1639 check = MyTransaction->
execute(Commit);
1643 else if (check == 0) {
1645 ndbout <<
"tuple " << tableName[tableCount] <<
":" <<
1646 opCount <<
" was never deleted" << endl;
1651 ndbout <<
"Unexpected error during delete" << endl;