int runScanRefreshNoTimeout(NDBT_Context* ctx, NDBT_Step* step){ int result = NDBT_OK; int loops = ctx->getNumLoops(); int records = ctx->getNumRecords(); int stepNo = step->getStepNo(); int maxSleep = (int)(TIMEOUT * 0.3); ndbout << "TransactionInactiveTimeout="<< TIMEOUT << ", maxSleep="<<maxSleep<<endl; HugoOperations hugoOps(*ctx->getTab()); Ndb* pNdb = GETNDB(step); for (int l = 1; l < loops && result == NDBT_OK; l++){ do{ // Start an insert trans CHECK(hugoOps.startTransaction(pNdb) == 0); int recordNo = records + (stepNo*loops) + l; CHECK(hugoOps.pkInsertRecord(pNdb, recordNo) == 0); CHECK(hugoOps.execute_NoCommit(pNdb) == 0); for (int i = 0; i < 3; i++) { NdbTransaction* pTrans = hugoOps.getTransaction(); Vector<NdbScanOperation*> ops; for (int j = 0; j <= i; j++) { // Perform buddy scan reads NdbScanOperation* pOp = pTrans->getNdbScanOperation(ctx->getTab()); CHECK(pOp != 0); CHECK(pOp->readTuples(NdbOperation::LM_Read, 0, 0, 1) == 0); ops.push_back(pOp); } CHECK(pTrans->execute(NoCommit) == 0); for (unsigned i = 0; i<TIMEOUT; i += 1000) { pTrans->refresh(); NdbSleep_MilliSleep(1000); } int res; for (unsigned j = 0; j < ops.size(); j++) { while((res = ops[j]->nextResult()) == 0); CHECK(res != -1); } } // Expect that transaction has NOT timed-out CHECK(hugoOps.execute_Commit(pNdb) == 0); } while(false); hugoOps.closeTransaction(pNdb); } return result; }
int runBuddyTransNoTimeout(NDBT_Context* ctx, NDBT_Step* step){ int result = NDBT_OK; int loops = ctx->getNumLoops(); int records = ctx->getNumRecords(); int stepNo = step->getStepNo(); int maxSleep = (int)(TIMEOUT * 0.3); ndbout << "TransactionInactiveTimeout="<< TIMEOUT << ", maxSleep="<<maxSleep<<endl; HugoOperations hugoOps(*ctx->getTab()); Ndb* pNdb = GETNDB(step); for (int l = 1; l < loops && result == NDBT_OK; l++){ do{ // Start an insert trans CHECK(hugoOps.startTransaction(pNdb) == 0); int recordNo = records + (stepNo*loops) + l; CHECK(hugoOps.pkInsertRecord(pNdb, recordNo) == 0); CHECK(hugoOps.execute_NoCommit(pNdb) == 0); int remain = maxSleep; for (int i = 0; i < 3; i++) { NdbTransaction* pTrans = hugoOps.getTransaction(); // Perform buddy scan reads NdbScanOperation* pOp = pTrans->getNdbScanOperation(ctx->getTab()); CHECK(pOp != 0); CHECK(pOp->readTuples(NdbOperation::LM_Read, 0, 0, 1) == 0); CHECK(pTrans->execute(NoCommit) == 0); while(pOp->nextResult() == 0); int sleep = myRandom48(remain); remain = remain - sleep + 1; ndbout << "Sleeping for " << sleep << " milliseconds" << endl; NdbSleep_MilliSleep(sleep); } // Expect that transaction has NOT timed-out CHECK(hugoOps.execute_Commit(pNdb) == 0); } while(false); hugoOps.closeTransaction(pNdb); } return result; }
int runBuddyTransTimeout(NDBT_Context* ctx, NDBT_Step* step){ int result = NDBT_OK; int loops = ctx->getNumLoops(); int records = ctx->getNumRecords(); int stepNo = step->getStepNo(); ndbout << "TransactionInactiveTimeout="<< TIMEOUT <<endl; HugoOperations hugoOps(*ctx->getTab()); Ndb* pNdb = GETNDB(step); for (int l = 1; l < loops && result == NDBT_OK; l++){ NdbTransaction* pTrans = 0; do{ pTrans = pNdb->startTransaction(); NdbScanOperation* pOp = pTrans->getNdbScanOperation(ctx->getTab()); CHECK(pOp->readTuples(NdbOperation::LM_Read, 0, 0, 1) == 0); CHECK(pTrans->execute(NoCommit) == 0); int sleep = 2 * TIMEOUT; ndbout << "Sleeping for " << sleep << " milliseconds" << endl; NdbSleep_MilliSleep(sleep); int res = 0; while((res = pOp->nextResult()) == 0); ndbout_c("res: %d", res); CHECK(res == -1); } while(false); if (pTrans) { pTrans->close(); } } return result; }
int scan_print(Ndb * myNdb) { // Scan all records exclusive and update // them one by one int retryAttempt = 0; const int retryMax = 10; int fetchedRows = 0; int check; NdbError err; NdbTransaction *myTrans; NdbScanOperation *myScanOp; /* Result of reading attribute value, three columns: REG_NO, BRAND, and COLOR */ NdbRecAttr * myRecAttr[3]; const NdbDictionary::Dictionary* myDict= myNdb->getDictionary(); const NdbDictionary::Table *myTable= myDict->getTable("api_scan"); if (myTable == NULL) APIERROR(myDict->getNdbError()); /** * Loop as long as : * retryMax not reached * failed operations due to TEMPORARY erros * * Exit loop; * retyrMax reached * Permanent error (return -1) */ while (true) { if (retryAttempt >= retryMax) { std::cout << "ERROR: has retried this operation " << retryAttempt << " times, failing!" << std::endl; return -1; } myTrans = myNdb->startTransaction(); if (myTrans == NULL) { const NdbError err = myNdb->getNdbError(); if (err.status == NdbError::TemporaryError) { milliSleep(50); retryAttempt++; continue; } std::cout << err.message << std::endl; return -1; } /* * Define a scan operation. * NDBAPI. */ myScanOp = myTrans->getNdbScanOperation(myTable); if (myScanOp == NULL) { std::cout << myTrans->getNdbError().message << std::endl; myNdb->closeTransaction(myTrans); return -1; } /** * Read without locks, without being placed in lock queue */ if( myScanOp->readTuples(NdbOperation::LM_CommittedRead) == -1) { std::cout << myTrans->getNdbError().message << std::endl; myNdb->closeTransaction(myTrans); return -1; } /** * Define storage for fetched attributes. * E.g., the resulting attributes of executing * myOp->getValue("REG_NO") is placed in myRecAttr[0]. * No data exists in myRecAttr until transaction has commited! */ myRecAttr[0] = myScanOp->getValue("REG_NO"); myRecAttr[1] = myScanOp->getValue("BRAND"); myRecAttr[2] = myScanOp->getValue("COLOR"); if(myRecAttr[0] ==NULL || myRecAttr[1] == NULL || myRecAttr[2]==NULL) { std::cout << myTrans->getNdbError().message << std::endl; myNdb->closeTransaction(myTrans); return -1; } /** * Start scan (NoCommit since we are only reading at this stage); */ if(myTrans->execute(NdbTransaction::NoCommit) != 0){ err = myTrans->getNdbError(); if(err.status == NdbError::TemporaryError){ std::cout << myTrans->getNdbError().message << std::endl; myNdb->closeTransaction(myTrans); milliSleep(50); continue; } std::cout << err.code << std::endl; std::cout << myTrans->getNdbError().code << std::endl; myNdb->closeTransaction(myTrans); return -1; } /** * start of loop: nextResult(true) means that "parallelism" number of * rows are fetched from NDB and cached in NDBAPI */ while((check = myScanOp->nextResult(true)) == 0){ do { fetchedRows++; /** * print REG_NO unsigned int */ std::cout << myRecAttr[0]->u_32_value() << "\t"; /** * print BRAND character string */ std::cout << myRecAttr[1]->aRef() << "\t"; /** * print COLOR character string */ std::cout << myRecAttr[2]->aRef() << std::endl; /** * nextResult(false) means that the records * cached in the NDBAPI are modified before * fetching more rows from NDB. */ } while((check = myScanOp->nextResult(false)) == 0); } myNdb->closeTransaction(myTrans); return 1; } return -1; }
int scan_update(Ndb* myNdb, int update_column, const char * before_color, const char * after_color) { // Scan all records exclusive and update // them one by one int retryAttempt = 0; const int retryMax = 10; int updatedRows = 0; int check; NdbError err; NdbTransaction *myTrans; NdbScanOperation *myScanOp; const NdbDictionary::Dictionary* myDict= myNdb->getDictionary(); const NdbDictionary::Table *myTable= myDict->getTable("api_scan"); if (myTable == NULL) APIERROR(myDict->getNdbError()); /** * Loop as long as : * retryMax not reached * failed operations due to TEMPORARY erros * * Exit loop; * retryMax reached * Permanent error (return -1) */ while (true) { if (retryAttempt >= retryMax) { std::cout << "ERROR: has retried this operation " << retryAttempt << " times, failing!" << std::endl; return -1; } myTrans = myNdb->startTransaction(); if (myTrans == NULL) { const NdbError err = myNdb->getNdbError(); if (err.status == NdbError::TemporaryError) { milliSleep(50); retryAttempt++; continue; } std::cout << err.message << std::endl; return -1; } /** * Get a scan operation. */ myScanOp = myTrans->getNdbScanOperation(myTable); if (myScanOp == NULL) { std::cout << myTrans->getNdbError().message << std::endl; myNdb->closeTransaction(myTrans); return -1; } /** * Define a result set for the scan. */ if( myScanOp->readTuples(NdbOperation::LM_Exclusive) ) { std::cout << myTrans->getNdbError().message << std::endl; myNdb->closeTransaction(myTrans); return -1; } /** * Use NdbScanFilter to define a search critera */ NdbScanFilter filter(myScanOp) ; if(filter.begin(NdbScanFilter::AND) < 0 || filter.cmp(NdbScanFilter::COND_EQ, update_column, before_color, 20) <0|| filter.end() <0) { std::cout << myTrans->getNdbError().message << std::endl; myNdb->closeTransaction(myTrans); return -1; } /** * Start scan (NoCommit since we are only reading at this stage); */ if(myTrans->execute(NdbTransaction::NoCommit) != 0) { err = myTrans->getNdbError(); if(err.status == NdbError::TemporaryError){ std::cout << myTrans->getNdbError().message << std::endl; myNdb->closeTransaction(myTrans); milliSleep(50); continue; } std::cout << myTrans->getNdbError().code << std::endl; myNdb->closeTransaction(myTrans); return -1; } /** * start of loop: nextResult(true) means that "parallelism" number of * rows are fetched from NDB and cached in NDBAPI */ while((check = myScanOp->nextResult(true)) == 0){ do { /** * Get update operation */ NdbOperation * myUpdateOp = myScanOp->updateCurrentTuple(); if (myUpdateOp == 0) { std::cout << myTrans->getNdbError().message << std::endl; myNdb->closeTransaction(myTrans); return -1; } updatedRows++; /** * do the update */ myUpdateOp->setValue(update_column, after_color); /** * nextResult(false) means that the records * cached in the NDBAPI are modified before * fetching more rows from NDB. */ } while((check = myScanOp->nextResult(false)) == 0); /** * NoCommit when all cached tuple have been updated */ if(check != -1) { check = myTrans->execute(NdbTransaction::NoCommit); } /** * Check for errors */ err = myTrans->getNdbError(); if(check == -1) { if(err.status == NdbError::TemporaryError){ std::cout << myTrans->getNdbError().message << std::endl; myNdb->closeTransaction(myTrans); milliSleep(50); continue; } } /** * End of loop */ } /** * Commit all prepared operations */ if(myTrans->execute(NdbTransaction::Commit) == -1) { if(err.status == NdbError::TemporaryError){ std::cout << myTrans->getNdbError().message << std::endl; myNdb->closeTransaction(myTrans); milliSleep(50); continue; } } std::cout << myTrans->getNdbError().message << std::endl; myNdb->closeTransaction(myTrans); return 0; } if(myTrans!=0) { std::cout << myTrans->getNdbError().message << std::endl; myNdb->closeTransaction(myTrans); } return -1; }
int select_count(Ndb* pNdb, const NdbDictionary::Table* pTab, int parallelism, Uint64* count_rows, NdbOperation::LockMode lock) { int retryAttempt = 0; const int retryMax = 100; int check; NdbTransaction *pTrans; NdbScanOperation *pOp; const Uint32 codeWords= 1; Uint32 codeSpace[ codeWords ]; NdbInterpretedCode code(NULL, // Table is irrelevant &codeSpace[0], codeWords); if ((code.interpret_exit_last_row() != 0) || (code.finalise() != 0)) { ERR(code.getNdbError()); return NDBT_FAILED; } while (true) { if (retryAttempt >= retryMax) { g_info << "ERROR: has retried this operation " << retryAttempt << " times, failing!" << endl; return NDBT_FAILED; } pTrans = pNdb->startTransaction(); if (pTrans == NULL) { const NdbError err = pNdb->getNdbError(); if (err.status == NdbError::TemporaryError) { NdbSleep_MilliSleep(50); retryAttempt++; continue; } ERR(err); return NDBT_FAILED; } pOp = pTrans->getNdbScanOperation(pTab->getName()); if (pOp == NULL) { ERR(pTrans->getNdbError()); pNdb->closeTransaction(pTrans); return NDBT_FAILED; } if( pOp->readTuples(NdbScanOperation::LM_Dirty) ) { ERR(pTrans->getNdbError()); pNdb->closeTransaction(pTrans); return NDBT_FAILED; } check = pOp->setInterpretedCode(&code); if( check == -1 ) { ERR(pTrans->getNdbError()); pNdb->closeTransaction(pTrans); return NDBT_FAILED; } Uint64 tmp; Uint32 row_size; pOp->getValue(NdbDictionary::Column::ROW_COUNT, (char*)&tmp); pOp->getValue(NdbDictionary::Column::ROW_SIZE, (char*)&row_size); check = pTrans->execute(NdbTransaction::NoCommit); if( check == -1 ) { ERR(pTrans->getNdbError()); pNdb->closeTransaction(pTrans); return NDBT_FAILED; } Uint64 row_count = 0; int eof; while((eof = pOp->nextResult(true)) == 0) { row_count += tmp; } if (eof == -1) { const NdbError err = pTrans->getNdbError(); if (err.status == NdbError::TemporaryError) { pNdb->closeTransaction(pTrans); NdbSleep_MilliSleep(50); retryAttempt++; continue; } ERR(err); pNdb->closeTransaction(pTrans); return NDBT_FAILED; } pNdb->closeTransaction(pTrans); if (count_rows != NULL) { *count_rows = row_count; } return NDBT_OK; } return NDBT_FAILED; }
int clear_table(Ndb* pNdb, const NdbDictionary::Table* pTab, bool fetch_across_commit, int parallelism) { // Scan all records exclusive and delete // them one by one int retryAttempt = 0; const int retryMax = 10; int deletedRows = 0; int check; NdbTransaction *pTrans; NdbScanOperation *pOp; NdbError err; int par = parallelism; while (true){ restart: if (retryAttempt++ >= retryMax){ g_info << "ERROR: has retried this operation " << retryAttempt << " times, failing!" << endl; return NDBT_FAILED; } pTrans = pNdb->startTransaction(); if (pTrans == NULL) { err = pNdb->getNdbError(); if (err.status == NdbError::TemporaryError){ ERR(err); NdbSleep_MilliSleep(50); continue; } goto failed; } pOp = pTrans->getNdbScanOperation(pTab->getName()); if (pOp == NULL) { goto failed; } int flags = 0; flags |= _tupscan ? NdbScanOperation::SF_TupScan : 0; flags |= _diskscan ? NdbScanOperation::SF_DiskScan : 0; if( pOp->readTuples(NdbOperation::LM_Exclusive, flags, par) ) { goto failed; } if(pTrans->execute(NdbTransaction::NoCommit) != 0){ err = pTrans->getNdbError(); if(err.status == NdbError::TemporaryError){ ERR(err); pNdb->closeTransaction(pTrans); NdbSleep_MilliSleep(50); continue; } goto failed; } while((check = pOp->nextResult(true)) == 0){ do { if (pOp->deleteCurrentTuple() != 0){ goto failed; } deletedRows++; } while((check = pOp->nextResult(false)) == 0); if(check != -1){ if (fetch_across_commit) { check = pTrans->execute(NdbTransaction::Commit); pTrans->restart(); // new tx id } else { check = pTrans->execute(NdbTransaction::NoCommit); } } err = pTrans->getNdbError(); if(check == -1){ if(err.status == NdbError::TemporaryError){ ERR(err); pNdb->closeTransaction(pTrans); NdbSleep_MilliSleep(50); par = 1; goto restart; } goto failed; } } if(check == -1){ err = pTrans->getNdbError(); if(err.status == NdbError::TemporaryError){ ERR(err); pNdb->closeTransaction(pTrans); NdbSleep_MilliSleep(50); par = 1; goto restart; } goto failed; } if (! fetch_across_commit && pTrans->execute(NdbTransaction::Commit) != 0) { err = pTrans->getNdbError(); goto failed; } pNdb->closeTransaction(pTrans); return NDBT_OK; } return NDBT_FAILED; failed: if(pTrans != 0) pNdb->closeTransaction(pTrans); ERR(err); return (err.code != 0 ? err.code : NDBT_FAILED); }
int calc_var_column(const NdbDictionary::Table * t, const NdbDictionary::Index * ix, int col, Ndb* ndb, bool longvarchar, bool ftScan, bool ignoreData) { char buff[8052]; memset(buff, 0, sizeof(buff)); int sz=0; NdbTransaction * trans = ndb->startTransaction(); if(trans==0) abort(); NdbScanOperation * sop; sop=trans->getNdbScanOperation(t); sop->readTuples(); NdbRecAttr * attr=sop->getValue(col, buff); int rows=0; int charset_size=1; bool no_data=false; //Set charset cost (for binary and latin1 cost is 1) const NdbDictionary::Column * c = t->getColumn(col); const NdbDictionary::Column::Type type = c->getType(); if ((type == NdbDictionary::Column::Varchar) || (type == NdbDictionary::Column::Longvarchar)) { CHARSET_INFO * cs2; cs2= (CHARSET_INFO*)(c->getCharset()); if(cs2!=0) { if(strncmp(cs2->name, "utf8",4)==0) { charset_size=3; printf( "---\tWARNING! cs2->name charset used, each character cost : %d bytes\n",charset_size); } if(strncmp(cs2->name, "ucs2",4)==0) { charset_size=2; printf( "---\tWARNING! cs2->name charset used, each character cost : %d bytes\n",charset_size); } } } //Set var header size int headerSize=longvarchar ? 2 : 1; if(trans->execute(NdbTransaction::NoCommit, NdbOperation::AbortOnError, 1) == -1) { no_data=true; trans->close(); } if(!no_data) { int check=0; while( ((check = sop->nextResult(true)) == 0) && !ignoreData) { rows++; if (verbose) { printf("attribut %d size = %d \n",rows,attr->isNULL()==1 ? 0 : attr->get_size_in_bytes()); } if(attr->isNULL()==1) { sz+=0; //for the time being until we know for sure.. } else { //attr->get_size_in_bytes return lengh of attr including header attr cost = (length-header*charset) sz+=((attr->get_size_in_bytes() - headerSize)* charset_size); } if(rows==1024 && !ftScan) break; } trans->close(); } if(rows==0) { sz = (int)(((float)(t->getColumn(col)->getSizeInBytes()))* (float)((float)loadfactor/100)); printf("---\tWARNING! No reference data found for VAR*. Defaulting to max size (loadfactor=100 percent)..%d bytes \n",sz); printf("\tConsider loading database with average data for exact measurement\n"); return sz+waste_sz(sz); } int tmpsz=(sz/rows)+headerSize; sz=tmpsz + waste_sz(tmpsz); if(ix) printf("---\t\tVAR* attribute is %d bytes averaged over %d rows\n", sz, rows); else printf("---\tVAR* attribute is %d bytes averaged over %d rows\n", sz, rows); return sz; }
int calc_blob_column(const NdbDictionary::Table * t, const NdbDictionary::Index * ix, int col, Ndb* ndb, int & szRam, int & szDisk, bool ftScan) { NdbTransaction * trans = ndb->startTransaction(); NdbScanOperation * sop = trans->getNdbScanOperation(t); sop->readTuples(); NdbBlob * blob = sop->getBlobHandle(col); bool no_data=false; if(trans->execute(NdbTransaction::NoCommit, NdbOperation::AbortOnError, 1) == -1) { no_data=true; sop->close(); trans->close(); } unsigned long long len=0; int rows=0; int check=0; const NdbDictionary::Column * c = t->getColumn(col); int part_size= c->getPartSize(); if(!no_data) { while(((check = sop->nextResult(true)) == 0) && !ignoreData) { int isnull; rows++; blob->getNull(isnull); if(isnull) len=0; else blob->getLength(len); /* printf("blob is %llu\n", len); if(len>256) { szRam+=(((len-256)/part_size) + 1)*part_size+256; printf("len2=%llu, part-size=%d, len=%llu\n", (((len-256)/part_size) + 1)*part_size+256, part_size, len); } else */ szRam+=(int)len; if(rows==1000 && !ftScan) break; } sop->close(); trans->close(); } if(rows==0) { if (c->getStorageType() == NdbDictionary::Column::StorageTypeDisk) { printf("---\tWARNING! No reference data found for BLOB/TEXT. " "Defaulting to 256 bytes DataMemory, %d bytes Diskspace! \n",(part_size<=256 ? 0:part_size)); printf("\tConsider loading database with average data for exact" " measurement. \n"); szRam=256; szDisk=(part_size<=256 ? 0:part_size); return 0; } else { printf("---\tWARNING! No reference data found for BLOB/TEXT. " "Defaulting to %d bytes DataMemory ! \n", (part_size<=256 ? 256:part_size+256)); printf("\tConsider loading database with average data for exact" " measurement. \n"); szRam=(part_size<=256 ? 256:part_size+256); szDisk=0; return 0; } } if (c->getStorageType() == NdbDictionary::Column::StorageTypeDisk) { int averageSz=szRam/rows; if((averageSz)>256) { szRam=256; szDisk=((averageSz-256)/part_size) *part_size + (((averageSz-256)%part_size)==0 ? 0:part_size); } else { szRam=256; szDisk=0; } } else { int averageSz=szRam/rows; szDisk=0; if((averageSz)<256) { szRam=256; } else { szRam=256 + ((averageSz-256)/part_size)*part_size + (((averageSz-256)%part_size)==0 ? 0:part_size); } } printf("---\tBLOB/TEXT attribute is %d bytes (RAM) and %d bytes (DISK)" " averaged over %d rows\n", szRam, szDisk, rows); return 0; }
int scanReadRecords(Ndb* pNdb, const NdbDictionary::Table* pTab, const NdbDictionary::Index* pIdx, int parallel, int _lock, bool headers, bool useHexFormat, char delimiter, bool order, bool descending) { int retryAttempt = 0; const int retryMax = 100; int check; NdbTransaction *pTrans; NdbScanOperation *pOp; NdbIndexScanOperation * pIOp= 0; NDBT_ResultRow * row = new NDBT_ResultRow(*pTab, delimiter); while (true) { if (retryAttempt >= retryMax) { ndbout << "ERROR: has retried this operation " << retryAttempt << " times, failing!" << endl; return -1; } pTrans = pNdb->startTransaction(); if (pTrans == NULL) { const NdbError err = pNdb->getNdbError(); if (err.status == NdbError::TemporaryError) { NdbSleep_MilliSleep(50); retryAttempt++; continue; } ERR(err); return -1; } pOp = (!pIdx) ? pTrans->getNdbScanOperation(pTab->getName()) : pIOp=pTrans->getNdbIndexScanOperation(pIdx->getName(), pTab->getName()); if (pOp == NULL) { ERR(pTrans->getNdbError()); pNdb->closeTransaction(pTrans); return -1; } int rs; unsigned scan_flags = 0; if (_tup) scan_flags |= NdbScanOperation::SF_TupScan; switch(_lock + (3 * order)) { case 1: rs = pOp->readTuples(NdbScanOperation::LM_Read, scan_flags, parallel); break; case 2: rs = pOp->readTuples(NdbScanOperation::LM_Exclusive, scan_flags, parallel); break; case 3: rs = pIOp->readTuples(NdbScanOperation::LM_CommittedRead, 0, parallel, true, descending); break; case 4: rs = pIOp->readTuples(NdbScanOperation::LM_Read, 0, parallel, true, descending); break; case 5: rs = pIOp->readTuples(NdbScanOperation::LM_Exclusive, 0, parallel, true, descending); break; case 0: default: rs = pOp->readTuples(NdbScanOperation::LM_CommittedRead, scan_flags, parallel); break; } if( rs != 0 ) { ERR(pTrans->getNdbError()); pNdb->closeTransaction(pTrans); return -1; } if(0) { NdbScanFilter sf(pOp); #if 0 sf.begin(NdbScanFilter::AND); sf.le(0, (Uint32)10); sf.end(); #elif 0 sf.begin(NdbScanFilter::OR); sf.begin(NdbScanFilter::AND); sf.ge(0, (Uint32)10); sf.lt(0, (Uint32)20); sf.end(); sf.begin(NdbScanFilter::AND); sf.ge(0, (Uint32)30); sf.lt(0, (Uint32)40); sf.end(); sf.end(); #elif 1 sf.begin(NdbScanFilter::AND); sf.begin(NdbScanFilter::OR); sf.begin(NdbScanFilter::AND); sf.ge(0, (Uint32)10); sf.lt(0, (Uint32)20); sf.end(); sf.begin(NdbScanFilter::AND); sf.ge(0, (Uint32)30); sf.lt(0, (Uint32)40); sf.end(); sf.end(); sf.begin(NdbScanFilter::OR); sf.begin(NdbScanFilter::AND); sf.ge(0, (Uint32)0); sf.lt(0, (Uint32)50); sf.end(); sf.begin(NdbScanFilter::AND); sf.ge(0, (Uint32)100); sf.lt(0, (Uint32)200); sf.end(); sf.end(); sf.end(); #endif } else { check = pOp->interpret_exit_ok(); if( check == -1 ) { ERR(pTrans->getNdbError()); pNdb->closeTransaction(pTrans); return -1; } } bool disk= false; for(int a = 0; a<pTab->getNoOfColumns(); a++) { const NdbDictionary::Column* col = pTab->getColumn(a); if(col->getStorageType() == NdbDictionary::Column::StorageTypeDisk) disk= true; if (!nodata) if((row->attributeStore(a) = pOp->getValue(col)) == 0) { ERR(pTrans->getNdbError()); pNdb->closeTransaction(pTrans); return -1; } } NdbRecAttr * disk_ref= 0; if(_dumpDisk && disk) disk_ref = pOp->getValue(NdbDictionary::Column::DISK_REF); NdbRecAttr * rowid= 0, *frag = 0, *gci = 0; if (use_rowid) { frag = pOp->getValue(NdbDictionary::Column::FRAGMENT); rowid = pOp->getValue(NdbDictionary::Column::ROWID); } if (use_gci) { gci = pOp->getValue(NdbDictionary::Column::ROW_GCI); } check = pTrans->execute(NdbTransaction::NoCommit); if( check == -1 ) { const NdbError err = pTrans->getNdbError(); if (err.status == NdbError::TemporaryError) { pNdb->closeTransaction(pTrans); NdbSleep_MilliSleep(50); retryAttempt++; continue; } ERR(err); pNdb->closeTransaction(pTrans); return -1; } if (rowid) ndbout << "ROWID\t"; if (gci) ndbout << "\tGCI"; if (headers && !nodata) row->header(ndbout); if (disk_ref) ndbout << "\tDISK_REF"; ndbout << endl; int eof; int rows = 0; eof = pOp->nextResult(); while(eof == 0) { rows++; if (useHexFormat) ndbout.setHexFormat(1); if (rowid) { ndbout << "[ fragment: " << frag->u_32_value() << " m_page: " << rowid->u_32_value() << " m_page_idx: " << *(Uint32*)(rowid->aRef() + 4) << " ]"; ndbout << "\t"; } if (gci) { if (gci->isNULL()) ndbout << "NULL\t"; else ndbout << gci->u_64_value() << "\t"; } if (!nodata) ndbout << (*row); if(disk_ref) { ndbout << "\t"; ndbout << "[ m_file_no: " << *(Uint16*)(disk_ref->aRef()+6) << " m_page: " << disk_ref->u_32_value() << " m_page_idx: " << *(Uint16*)(disk_ref->aRef() + 4) << " ]"; } if (rowid || disk_ref || gci || !nodata) ndbout << endl; eof = pOp->nextResult(); } if (eof == -1) { const NdbError err = pTrans->getNdbError(); if (err.status == NdbError::TemporaryError) { pNdb->closeTransaction(pTrans); NdbSleep_MilliSleep(50); retryAttempt++; continue; } ERR(err); pNdb->closeTransaction(pTrans); return -1; } pNdb->closeTransaction(pTrans); ndbout << rows << " rows returned" << endl; return 0; } return -1; }