summaryrefslogtreecommitdiff
path: root/ndb/test/ndbapi/testBlobs.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ndb/test/ndbapi/testBlobs.cpp')
-rw-r--r--ndb/test/ndbapi/testBlobs.cpp84
1 files changed, 64 insertions, 20 deletions
diff --git a/ndb/test/ndbapi/testBlobs.cpp b/ndb/test/ndbapi/testBlobs.cpp
index 506ff188ff6..fff5ac247df 100644
--- a/ndb/test/ndbapi/testBlobs.cpp
+++ b/ndb/test/ndbapi/testBlobs.cpp
@@ -839,9 +839,6 @@ insertPk(int style)
CHK(g_con->execute(NoCommit) == 0);
CHK(writeBlobData(tup) == 0);
}
- // just another trap
- if (urandom(10) == 0)
- CHK(g_con->execute(NoCommit) == 0);
if (++n == g_opt.m_batch) {
CHK(g_con->execute(Commit) == 0);
g_ndb->closeTransaction(g_con);
@@ -963,21 +960,31 @@ static int
deletePk()
{
DBG("--- deletePk ---");
+ unsigned n = 0;
+ CHK((g_con = g_ndb->startTransaction()) != 0);
for (unsigned k = 0; k < g_opt.m_rows; k++) {
Tup& tup = g_tups[k];
DBG("deletePk pk1=" << hex << tup.m_pk1);
- CHK((g_con = g_ndb->startTransaction()) != 0);
CHK((g_opr = g_con->getNdbOperation(g_opt.m_tname)) != 0);
CHK(g_opr->deleteTuple() == 0);
CHK(g_opr->equal("PK1", tup.m_pk1) == 0);
if (g_opt.m_pk2len != 0)
CHK(g_opr->equal("PK2", tup.m_pk2) == 0);
- CHK(g_con->execute(Commit) == 0);
- g_ndb->closeTransaction(g_con);
+ if (++n == g_opt.m_batch) {
+ CHK(g_con->execute(Commit) == 0);
+ g_ndb->closeTransaction(g_con);
+ CHK((g_con = g_ndb->startTransaction()) != 0);
+ n = 0;
+ }
g_opr = 0;
- g_con = 0;
tup.m_exists = false;
}
+ if (n != 0) {
+ CHK(g_con->execute(Commit) == 0);
+ n = 0;
+ }
+ g_ndb->closeTransaction(g_con);
+ g_con = 0;
return 0;
}
@@ -1080,19 +1087,27 @@ static int
deleteIdx()
{
DBG("--- deleteIdx ---");
+ unsigned n = 0;
+ CHK((g_con = g_ndb->startTransaction()) != 0);
for (unsigned k = 0; k < g_opt.m_rows; k++) {
Tup& tup = g_tups[k];
DBG("deleteIdx pk1=" << hex << tup.m_pk1);
- CHK((g_con = g_ndb->startTransaction()) != 0);
CHK((g_opx = g_con->getNdbIndexOperation(g_opt.m_x1name, g_opt.m_tname)) != 0);
CHK(g_opx->deleteTuple() == 0);
CHK(g_opx->equal("PK2", tup.m_pk2) == 0);
- CHK(g_con->execute(Commit) == 0);
- g_ndb->closeTransaction(g_con);
+ if (++n == g_opt.m_batch) {
+ CHK(g_con->execute(Commit) == 0);
+ g_ndb->closeTransaction(g_con);
+ CHK((g_con = g_ndb->startTransaction()) != 0);
+ n = 0;
+ }
g_opx = 0;
- g_con = 0;
tup.m_exists = false;
}
+ if (n != 0) {
+ CHK(g_con->execute(Commit) == 0);
+ n = 0;
+ }
return 0;
}
@@ -1220,20 +1235,49 @@ deleteScan(bool idx)
CHK(g_ops->getValue("PK2", tup.m_pk2) != 0);
CHK(g_con->execute(NoCommit) == 0);
unsigned rows = 0;
+ unsigned n = 0;
while (1) {
int ret;
tup.m_pk1 = (Uint32)-1;
memset(tup.m_pk2, 'x', g_opt.m_pk2len);
- CHK((ret = g_ops->nextResult()) == 0 || ret == 1);
+ CHK((ret = g_ops->nextResult(true)) == 0 || ret == 1);
if (ret == 1)
break;
- DBG("deleteScan" << (idx ? "Idx" : "") << " pk1=" << hex << tup.m_pk1);
- CHK(g_ops->deleteCurrentTuple() == 0);
- CHK(g_con->execute(NoCommit) == 0);
- Uint32 k = tup.m_pk1 - g_opt.m_pk1off;
- CHK(k < g_opt.m_rows && g_tups[k].m_exists);
- g_tups[k].m_exists = false;
- rows++;
+ while (1) {
+ DBG("deleteScan" << (idx ? "Idx" : "") << " pk1=" << hex << tup.m_pk1);
+ Uint32 k = tup.m_pk1 - g_opt.m_pk1off;
+ CHK(k < g_opt.m_rows && g_tups[k].m_exists);
+ g_tups[k].m_exists = false;
+ CHK(g_ops->deleteCurrentTuple() == 0);
+ rows++;
+ tup.m_pk1 = (Uint32)-1;
+ memset(tup.m_pk2, 'x', g_opt.m_pk2len);
+ CHK((ret = g_ops->nextResult(false)) == 0 || ret == 1 || ret == 2);
+ if (++n == g_opt.m_batch || ret == 2) {
+ DBG("execute batch: n=" << n << " ret=" << ret);
+ switch (0) {
+ case 0: // works normally
+ CHK(g_con->execute(NoCommit) == 0);
+ CHK(true || g_con->restart() == 0);
+ break;
+ case 1: // nonsense - g_con is invalid for 2nd batch
+ CHK(g_con->execute(Commit) == 0);
+ CHK(true || g_con->restart() == 0);
+ break;
+ case 2: // DBTC sendSignalErrorRefuseLab
+ CHK(g_con->execute(NoCommit) == 0);
+ CHK(g_con->restart() == 0);
+ break;
+ case 3: // 266 time-out
+ CHK(g_con->execute(Commit) == 0);
+ CHK(g_con->restart() == 0);
+ break;
+ }
+ n = 0;
+ }
+ if (ret == 2)
+ break;
+ }
}
CHK(g_con->execute(Commit) == 0);
g_ndb->closeTransaction(g_con);
@@ -1256,7 +1300,7 @@ static int
testmain()
{
g_ndb = new Ndb(g_ncc, "TEST_DB");
- CHK(g_ndb->init() == 0);
+ CHK(g_ndb->init(20) == 0);
CHK(g_ndb->waitUntilReady() == 0);
g_dic = g_ndb->getDictionary();
g_tups = new Tup [g_opt.m_rows];