20 #include <NDBT_Test.hpp>
21 #include <HugoTransactions.hpp>
22 #include <UtilTransactions.hpp>
23 #include <NdbRestarter.hpp>
24 #include <NdbRestarts.hpp>
30 #define CHECK(b) if (!(b)) { \
31 ndbout << "ERR: "<< step->getName() \
32 << " failed on line " << __LINE__ << endl; \
33 result = NDBT_FAILED; \
37 int records = ctx->getNumRecords();
38 int batchSize = ctx->getProperty(
"BatchSize", 1);
41 if (hugoTrans.pkDelRecords(GETNDB(step), records, batchSize) != 0){
49 int records = ctx->getNumRecords();
51 if (hugoTrans.loadTable(GETNDB(step), records) != 0){
58 int records = ctx->getNumRecords();
63 if (hugoTrans.pkInterpretedUpdateRecords(GETNDB(step),
69 if (hugoTrans.pkReadRecords(GETNDB(step),
80 Ndb* pNdb = GETNDB(step);
82 if (strcmp(pTab->
getName(),
"T1") != 0) {
83 g_err <<
"runTestBug19537: skip, table != T1" << endl;
111 check = pOp->
equal(
"KOL1", pkVal );
122 if( initialVal == NULL ) {
129 Uint32 valToIncWith = 1;
130 check = pOp->
incValue(
"KOL2", valToIncWith);
139 if( afterVal == NULL ) {
145 check = pTrans->
execute(Commit);
154 Uint32 expectedValue = oldValue + valToIncWith;
156 if (newValue != expectedValue)
158 g_err <<
"Failed : Expected " << oldValue <<
"+" <<
159 valToIncWith <<
"=" << expectedValue <<
160 " but received " << newValue << endl;
173 Ndb* pNdb = GETNDB(step);
175 if (strcmp(pTab->
getName(),
"T1") != 0) {
176 g_err <<
"runTestBug19537: skip, table != T1" << endl;
202 const Uint32 pkVal = 1;
203 if (pOp->
equal(
"KOL1", pkVal) == -1) {
211 const Uint64 reg_val = 0x0102030405060708ULL;
213 memcpy(reg_ptr32+0, (Uint8*)®_val,
sizeof(Uint32));
214 memcpy(reg_ptr32+1, ((Uint8*)®_val)+4,
sizeof(Uint32));
215 if (reg_ptr32[0] == 0x05060708 && reg_ptr32[1] == 0x01020304) {
216 g_err <<
"runTestBug19537: platform is LITTLE endian" << endl;
217 }
else if (reg_ptr32[0] == 0x01020304 && reg_ptr32[1] == 0x05060708) {
218 g_err <<
"runTestBug19537: platform is BIG endian" << endl;
220 g_err <<
"runTestBug19537: impossible platform"
221 << hex <<
" [0]=" << reg_ptr32[0] <<
" [1]=" <<reg_ptr32[1] << endl;
226 if (pOp->load_const_u64(1, reg_val) == -1 ||
233 if (pTrans->
execute(Commit) == -1) {
254 Uint32 kol2 = 0x09090909;
256 pOp->
equal(
"KOL1", pkVal) == -1 ||
257 pOp->
getValue(
"KOL2", (
char*)&kol2) == 0) {
263 if (pTrans->
execute(Commit) == -1) {
271 if (kol2 == 0x01020304) {
272 g_err <<
"runTestBug19537: the bug manifests itself !" << endl;
277 if (kol2 != 0x05060708) {
278 g_err <<
"runTestBug19537: impossible KOL2 " << hex << kol2 << endl;
290 Ndb* pNdb = GETNDB(step);
291 const Uint32 okSize= 10000;
292 const Uint32 tooBig= 30000;
294 Uint32 codeBuff[tooBig];
297 for (i = 0; i <= 1; i++) {
298 g_info <<
"bug34107:" << (i == 0 ?
" small" :
" too big") << endl;
308 ERR(pTrans->getNdbError());
329 int n = i == 0 ? okSize : tooBig;
332 for (k = 0; k <
n; k++) {
336 if (
code.interpret_exit_ok() == -1) {
337 ERR(
code.getNdbError());
343 if (
code.finalise() != 0)
345 ERR(
code.getNdbError());
357 if (pTrans->execute(NoCommit) == -1) {
358 ERR(pTrans->getNdbError());
368 if (i == 0 && ret != 1) {
369 ERR(pTrans->getNdbError());
374 if (i == 1 && ret != -1) {
375 g_err <<
"unexpected big filter success" << endl;
380 g_err <<
"unexpected big filter error code, wanted 874" << endl;
381 ERR(pTrans->getNdbError());
392 static char pkIdxName[256];
397 Ndb* pNdb = GETNDB(step);
399 bool orderedIndex = ctx->getProperty(
"OrderedIndex", (
unsigned)0);
400 bool logged = ctx->getProperty(
"LoggedIndexes", (Uint32)0);
401 bool noddl= ctx->getProperty(
"NoDDL");
406 ndbout <<
"Creating " << ((logged)?
"logged ":
"temporary ") <<
"ordered index "
407 << pkIdxName <<
" (";
409 ndbout <<
"Creating " << ((logged)?
"logged ":
"temporary ") <<
"unique index "
410 << pkIdxName <<
" (";
413 pIdx.setTable(pTab->
getName());
421 pIdx.addIndexColumn(col->
getName());
422 ndbout << col->
getName() <<
" ";
426 pIdx.setStoredIndex(logged);
431 getDictionary()->getIndex(pkIdxName, pTab->
getName());
435 ndbout <<
"Failed - Index does not exist and DDL not allowed" << endl;
447 ndbout <<
"FAILED!" << endl;
454 ndbout <<
"OK!" << endl;
462 Ndb* pNdb = GETNDB(step);
464 bool noddl= ctx->getProperty(
"NoDDL");
469 ndbout <<
"Dropping index " << pkIdxName <<
" ";
472 ndbout <<
"FAILED!" << endl;
476 ndbout <<
"OK!" << endl;
483 #define CHK_RET_FAILED(x) if (!(x)) { ndbout_c("Failed on line: %u", __LINE__); return NDBT_FAILED; }
489 Ndb* pNdb = GETNDB(step);
493 CHK_RET_FAILED(pIdx != 0);
496 CHK_RET_FAILED(pRowRecord != 0);
498 CHK_RET_FAILED(pIdxRecord != 0);
500 const Uint32 len = NdbDictionary::getRecordRowLength(pRowRecord);
501 Uint8 * pRow =
new Uint8[len];
505 calc.equalForRow(pRow, pRowRecord, 0);
508 CHK_RET_FAILED(pTrans != 0);
511 code.interpret_exit_ok();
515 bzero(&opts,
sizeof(opts));
516 opts.optionsPresent = NdbOperation::OperationOptions::OO_INTERPRETED;
517 opts.interpretedCode = &code;
519 const NdbOperation * pOp = pTrans->readTuple(pIdxRecord, (
char*)pRow,
520 pRowRecord, (
char*)pRow,
526 int res = pTrans->
execute(Commit, AbortOnError);
528 CHK_RET_FAILED(res == 0);
535 NDBT_TESTSUITE(testInterpreter);
536 TESTCASE(
"IncValue32",
537 "Test incValue for 32 bit integer\n"){
538 INITIALIZER(runLoadTable);
539 INITIALIZER(runTestIncValue32);
540 FINALIZER(runClearTable);
542 TESTCASE(
"IncValue64",
543 "Test incValue for 64 bit integer\n"){
544 INITIALIZER(runLoadTable);
545 INITIALIZER(runTestIncValue64);
546 FINALIZER(runClearTable);
549 "Test big-endian write_attr of 32 bit integer\n"){
550 INITIALIZER(runLoadTable);
551 INITIALIZER(runTestBug19537);
552 FINALIZER(runClearTable);
555 "Test too big scan filter (error 874)\n"){
556 INITIALIZER(runLoadTable);
557 INITIALIZER(runTestBug34107);
558 FINALIZER(runClearTable);
561 TESTCASE(
"MaxTransactions",
562 "Start transactions until no more can be created\n"){
563 INITIALIZER(runTestMaxTransaction);
565 TESTCASE(
"MaxOperations",
566 "Get operations until no more can be created\n"){
567 INITIALIZER(runLoadTable);
568 INITIALIZER(runTestMaxOperations);
569 FINALIZER(runClearTable);
571 TESTCASE(
"MaxGetValue",
572 "Call getValue loads of time\n"){
573 INITIALIZER(runLoadTable);
574 INITIALIZER(runTestGetValue);
575 FINALIZER(runClearTable);
578 "Call equal loads of time\n"){
579 INITIALIZER(runTestEqual);
581 TESTCASE(
"DeleteNdb",
582 "Make sure that a deleted Ndb object is properly deleted\n"
583 "and removed from transporter\n"){
584 INITIALIZER(runLoadTable);
585 INITIALIZER(runTestDeleteNdb);
586 FINALIZER(runClearTable);
588 TESTCASE(
"WaitUntilReady",
589 "Make sure you get an error message when calling waitUntilReady\n"
590 "without an init'ed Ndb\n"){
591 INITIALIZER(runTestWaitUntilReady);
593 TESTCASE(
"GetOperationNoTab",
594 "Call getNdbOperation on a table that does not exist\n"){
595 INITIALIZER(runGetNdbOperationNoTab);
597 TESTCASE(
"MissingOperation",
598 "Missing operation request(insertTuple) should give an error code\n"){
599 INITIALIZER(runMissingOperation);
601 TESTCASE(
"GetValueInUpdate",
602 "Test that it's not possible to perform getValue in an update\n"){
603 INITIALIZER(runLoadTable);
604 INITIALIZER(runGetValueInUpdate);
605 FINALIZER(runClearTable);
607 TESTCASE(
"UpdateWithoutKeys",
608 "Test that it's not possible to perform update without setting\n"
610 INITIALIZER(runLoadTable);
611 INITIALIZER(runUpdateWithoutKeys);
612 FINALIZER(runClearTable);
614 TESTCASE(
"UpdateWithoutValues",
615 "Test that it's not possible to perform update without setValues\n"){
616 INITIALIZER(runLoadTable);
617 INITIALIZER(runUpdateWithoutValues);
618 FINALIZER(runClearTable);
620 TESTCASE(
"NdbErrorOperation",
621 "Test that NdbErrorOperation is properly set"){
622 INITIALIZER(runCheckGetNdbErrorOperation);
625 TESTCASE(
"InterpretedUKLookup",
"")
627 INITIALIZER(runLoadTable);
628 INITIALIZER(createPkIndex);
629 INITIALIZER(runInterpretedUKLookup);
630 INITIALIZER(createPkIndex_Drop);
632 NDBT_TESTSUITE_END(testInterpreter);
634 int main(
int argc,
const char** argv){
637 NDBT_TESTSUITE_INSTANCE(testInterpreter);
638 return testInterpreter.execute(argc, argv);