mirror of
https://github.com/MariaDB/server.git
synced 2026-04-28 03:05:33 +02:00
wl1873 impl + test prg
ndb/include/ndbapi/NdbResultSet.hpp: NdbResultSet::restart ndb/include/ndbapi/NdbScanOperation.hpp: NdbResultSet::restart ndb/src/ndbapi/NdbResultSet.cpp: NdbResultSet::restart ndb/src/ndbapi/NdbScanOperation.cpp: NdbResultSet::restart ndb/test/ndbapi/testScan.cpp: Test case for scan restart
This commit is contained in:
parent
c203ec5dfb
commit
6fcaa7d5ac
5 changed files with 197 additions and 2 deletions
|
|
@ -970,6 +970,93 @@ int runCheckInactivityBeforeClose(NDBT_Context* ctx, NDBT_Step* step){
|
|||
|
||||
}
|
||||
|
||||
int runScanRestart(NDBT_Context* ctx, NDBT_Step* step){
|
||||
int loops = ctx->getNumLoops();
|
||||
int records = ctx->getNumRecords();
|
||||
Ndb * pNdb = GETNDB(step);
|
||||
const NdbDictionary::Table* pTab = ctx->getTab();
|
||||
|
||||
HugoCalculator calc(* pTab);
|
||||
NDBT_ResultRow tmpRow(* pTab);
|
||||
|
||||
int i = 0;
|
||||
while (i<loops && !ctx->isTestStopped()) {
|
||||
g_info << i++ << ": ";
|
||||
const int record = (rand() % records);
|
||||
g_info << " row=" << record;
|
||||
|
||||
NdbConnection* pCon = pNdb->startTransaction();
|
||||
NdbScanOperation* pOp = pCon->getNdbScanOperation(pTab->getName());
|
||||
if (pOp == NULL) {
|
||||
ERR(pCon->getNdbError());
|
||||
return NDBT_FAILED;
|
||||
}
|
||||
|
||||
NdbResultSet* rs = pOp->readTuples();
|
||||
if( rs == 0 ) {
|
||||
ERR(pCon->getNdbError());
|
||||
return NDBT_FAILED;
|
||||
}
|
||||
|
||||
int check = pOp->interpret_exit_ok();
|
||||
if( check == -1 ) {
|
||||
ERR(pCon->getNdbError());
|
||||
return NDBT_FAILED;
|
||||
}
|
||||
|
||||
// Define attributes to read
|
||||
for(int a = 0; a<pTab->getNoOfColumns(); a++){
|
||||
if((tmpRow.attributeStore(a) =
|
||||
pOp->getValue(pTab->getColumn(a)->getName())) == 0) {
|
||||
ERR(pCon->getNdbError());
|
||||
return NDBT_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
check = pCon->execute(NoCommit);
|
||||
if( check == -1 ) {
|
||||
ERR(pCon->getNdbError());
|
||||
return NDBT_FAILED;
|
||||
}
|
||||
|
||||
int res;
|
||||
int row = 0;
|
||||
while(row < record && (res = rs->nextResult()) == 0) {
|
||||
if(calc.verifyRowValues(&tmpRow) != 0){
|
||||
abort();
|
||||
return NDBT_FAILED;
|
||||
}
|
||||
row++;
|
||||
}
|
||||
if(row != record){
|
||||
ERR(pCon->getNdbError());
|
||||
abort();
|
||||
return NDBT_FAILED;
|
||||
}
|
||||
g_info << " restarting" << endl;
|
||||
if((res = rs->restart()) != 0){
|
||||
ERR(pCon->getNdbError());
|
||||
abort();
|
||||
return NDBT_FAILED;
|
||||
}
|
||||
|
||||
row = 0;
|
||||
while((res = rs->nextResult()) == 0) {
|
||||
if(calc.verifyRowValues(&tmpRow) != 0){
|
||||
abort();
|
||||
return NDBT_FAILED;
|
||||
}
|
||||
row++;
|
||||
}
|
||||
if(res != 1 || row != records){
|
||||
ERR(pCon->getNdbError());
|
||||
abort();
|
||||
return NDBT_FAILED;
|
||||
}
|
||||
pCon->close();
|
||||
}
|
||||
return NDBT_OK;
|
||||
}
|
||||
|
||||
|
||||
NDBT_TESTSUITE(testScan);
|
||||
|
|
@ -1393,6 +1480,12 @@ TESTCASE("ScanReadWhileNodeIsDown",
|
|||
STEP(runStopAndStartNode);
|
||||
FINALIZER(runClearTable);
|
||||
}
|
||||
TESTCASE("ScanRestart",
|
||||
"Verify restart functionallity"){
|
||||
INITIALIZER(runLoadTable);
|
||||
STEP(runScanRestart);
|
||||
FINALIZER(runClearTable);
|
||||
}
|
||||
NDBT_TESTSUITE_END(testScan);
|
||||
|
||||
int main(int argc, const char** argv){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue