本文整理汇总了C++中NdbConnection::getNdbError方法的典型用法代码示例。如果您正苦于以下问题:C++ NdbConnection::getNdbError方法的具体用法?C++ NdbConnection::getNdbError怎么用?C++ NdbConnection::getNdbError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NdbConnection
的用法示例。
在下文中一共展示了NdbConnection::getNdbError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UpdateTransaction
int UpdateTransaction(Ndb* pNdb, long iContextId, NdbError& err)
{
int iRes = -1;
NdbConnection* pNdbConnection = pNdb->startTransaction(0, (const char*)&iContextId, 4);
if(pNdbConnection)
{
NdbOperation* pNdbOperation = pNdbConnection->getNdbOperation(g_szTableName);
if(pNdbOperation)
{
if(!pNdbOperation->updateTuple()
&& !pNdbOperation->equal(c_szContextId, (Int32)iContextId)
&& !pNdbOperation->setValue(c_szContextData, STATUS_DATA, g_nStatusDataSize))
{
if(!pNdbConnection->execute(Commit))
iRes = 0;
else
err = pNdbConnection->getNdbError();
}
else
err = pNdbOperation->getNdbError();
}
else
err = pNdbConnection->getNdbError();
pNdb->closeTransaction(pNdbConnection);
}
else
err = pNdb->getNdbError();
return iRes;
}
示例2: DeleteTransaction
int DeleteTransaction(Ndb* pNdb, long iContextId, NdbError& err)
{
int iRes = -1;
NdbConnection* pNdbConnection = pNdb->startTransaction(0, (const char*)&iContextId, 4);
if(pNdbConnection)
{
NdbOperation* pNdbOperation = pNdbConnection->getNdbOperation(g_szTableName);
if(pNdbOperation)
{
if(!pNdbOperation->deleteTuple()
&& !pNdbOperation->equal(c_szContextId, (Int32)iContextId))
{
if(pNdbConnection->execute(Commit) == 0)
iRes = 0;
else
err = pNdbConnection->getNdbError();
}
else
err = pNdbOperation->getNdbError();
}
else
err = pNdbConnection->getNdbError();
pNdb->closeTransaction(pNdbConnection);
}
else
err = pNdb->getNdbError();
return iRes;
}
示例3: while
/**
* Transaction 2 - T2
*
* Read from Subscriber:
*
* Input:
* SubscriberNumber
*
* Output:
* Location
* Changed by
* Changed Timestamp
* Name
*/
void
start_T2(Ndb * pNDB, ThreadData * td, int async) {
DEBUG3("T2(%.*s, %d): - Starting", SUBSCRIBER_NUMBER_LENGTH,
td->transactionData.number,
td->transactionData.location);
NdbConnection * pCON = 0;
while((pCON = startTransaction(pNDB, td)) == 0) {
CHECK_ALLOWED_ERROR("T2-1: startTransaction", td, pNDB->getNdbError());
NdbSleep_MilliSleep(10);
}
if (td->ndbRecordSharedData)
{
char* rowPtr= (char*) &td->transactionData;
const NdbRecord* record= td->ndbRecordSharedData->
subscriberTableNdbRecord;
Uint32 m=0;
unsigned char* mask= (unsigned char*) &m;
SET_MASK(mask, IND_SUBSCRIBER_LOCATION);
SET_MASK(mask, IND_SUBSCRIBER_CHANGED_BY);
SET_MASK(mask, IND_SUBSCRIBER_CHANGED_TIME);
SET_MASK(mask, IND_SUBSCRIBER_NAME);
const NdbOperation* MyOp= pCON->readTuple(record, rowPtr, record, rowPtr,
NdbOperation::LM_Read, mask);
CHECK_NULL((void*) MyOp, "T2: readTuple", td,
pCON->getNdbError());
}
else
{
NdbOperation *MyOp= pCON->getNdbOperation(SUBSCRIBER_TABLE);
CHECK_NULL(MyOp, "T2: getNdbOperation", td,
pCON->getNdbError());
MyOp->readTuple();
MyOp->equal(IND_SUBSCRIBER_NUMBER,
td->transactionData.number);
MyOp->getValue(IND_SUBSCRIBER_LOCATION,
(char *)&td->transactionData.location);
MyOp->getValue(IND_SUBSCRIBER_CHANGED_BY,
td->transactionData.changed_by);
MyOp->getValue(IND_SUBSCRIBER_CHANGED_TIME,
td->transactionData.changed_time);
MyOp->getValue(IND_SUBSCRIBER_NAME,
td->transactionData.name);
}
if (async == 1) {
pCON->executeAsynchPrepare( Commit , T2_Callback, td);
} else {
int result = pCON->execute(Commit);
T2_Callback(result, pCON, (void*)td);
return;
}//if
}
示例4: read_and_verify_rows
void read_and_verify_rows(Ndb* pMyNdb, bool pre) {
int check = -1 ;
int loop_count_ops = nRecords;
char expectedCOL1[NUMBEROFRECORDS] = {0} ;
char expectedCOL2[NUMBEROFRECORDS] = {0} ;
NdbConnection *pMyTransaction = NULL ;
NdbOperation *MyOp = NULL ;
NdbRecAttr* tTmp = NULL ;
int readValue[MAXATTR] = {0} ;
ndbout << "Verifying records...\n"<< endl;
for (int count=0 ; count < loop_count_ops ; count++) {
pMyTransaction = pMyNdb->startTransaction();
if (!pMyTransaction) error_handler(pMyNdb->getNdbError(), NO_FAIL);
MyOp = pMyTransaction->getNdbOperation(tableName);
if (!MyOp) error_handler( pMyTransaction->getNdbError(), NO_FAIL);
check = MyOp->readTuple();
if( check == -1 ) error_handler( MyOp->getNdbError(), NO_FAIL);
check = MyOp->equal( attrName[0],(char*)&pkValue[count] );
if( check == -1 ) error_handler( MyOp->getNdbError(), NO_FAIL);
for (int count_attributes = 1; count_attributes < MAXATTR; count_attributes++) {
tTmp = MyOp->getValue( (char*)attrName[count_attributes], (char*)&readValue[count_attributes] );
if(!tTmp) error_handler( MyOp->getNdbError(), NO_FAIL);
}
if( pMyTransaction->execute( Commit ) == -1 ) {
error_handler(pMyTransaction->getNdbError(), NO_FAIL);
} else {
if (pre) {
expectedCOL1[count] = readValue[1];
expectedCOL2[count] = readValue[2];
}
ndbout << attrName[1] << "\t " << readValue[1] << "\t "
<< attrName[2] << "\t " << readValue[2] << endl;
}
pMyNdb->closeTransaction(pMyTransaction);
}
ndbout << "\nOK\n" << endl;
return;
};
示例5: GETNDB
static int
runFullScan(NDBT_Context* ctx, NDBT_Step* step)
{
NDBT_Table* pTab = ctx->getTab();
Ndb* pNdb = GETNDB(step);
unsigned cntIndex = getTableProperty(ctx, pTab, "numIndex");
for (unsigned numIndex = 0; numIndex < cntIndex; numIndex++) {
char buf[200];
sprintf(buf, "%s_X%03d", pTab->getName(), numIndex);
NDBT_Index* pInd = NDBT_Index::discoverIndexFromDb(pNdb, buf, pTab->getName());
assert(pInd != 0);
g_info << "Scan index:" << pInd->getName() << endl << *pInd;
NdbConnection* pCon = pNdb->startTransaction();
if (pCon == 0) {
ERR(pNdb->getNdbError());
return NDBT_FAILED;
}
NdbOperation* pOp = pCon->getNdbOperation(pInd->getName(),
pTab->getName());
if (pOp == 0) {
ERR(pCon->getNdbError());
pNdb->closeTransaction(pCon);
return NDBT_FAILED;
}
if (pOp->openScanRead() != 0) {
ERR(pCon->getNdbError());
pNdb->closeTransaction(pCon);
return NDBT_FAILED;
}
if (pCon->executeScan() != 0) {
ERR(pCon->getNdbError());
pNdb->closeTransaction(pCon);
return NDBT_FAILED;
}
unsigned rows = 0;
while (1) {
int ret = pCon->nextScanResult();
if (ret == 0) {
rows++;
} else if (ret == 1) {
break;
} else {
ERR(pCon->getNdbError());
pNdb->closeTransaction(pCon);
return NDBT_FAILED;
}
}
pNdb->closeTransaction(pCon);
g_info << "Scanned " << rows << " rows" << endl;
}
return NDBT_OK;
}
示例6: write_rows
void write_rows (Ndb* pMyNdb) {
/****************************************************************
* Insert rows into SimpleTable
*
***************************************************************/
int check = -1 ;
int loop_count_ops = nRecords ;
NdbOperation *MyOperation = NULL ;
NdbConnection *MyTransaction = NULL ;
ndbout << endl << "Writing records ..." << flush;
for (int count=0 ; count < loop_count_ops ; count++) {
MyTransaction = pMyNdb->startTransaction();
if (!MyTransaction) {
error_handler(pMyNdb->getNdbError(), NO_FAIL);
}//if
MyOperation = MyTransaction->getNdbOperation(tableName);
if (!MyOperation) {
error_handler(pMyNdb->getNdbError(), NO_FAIL);
}//if
check = MyOperation->writeTuple();
if( check == -1 ) error_handler(MyTransaction->getNdbError(), NO_FAIL);
check = MyOperation->equal( attrName[0],(char*)&pkValue[count] );
if( check == -1 ) error_handler(MyTransaction->getNdbError(), NO_FAIL);
// Update the columns, index column already ok.
for (int i = 1 ; i < MAXATTR; i++) {
if ((i == 2) && (count > 4)) {
check = MyOperation->setValue(attrName[i], (char*)&attrValue[count + 1]);
} else {
check = MyOperation->setValue(attrName[i], (char*)&attrValue[count]);
}
if( check == -1 ) error_handler(MyTransaction->getNdbError(), NO_FAIL);
}
check = MyTransaction->execute( Commit );
if(check == -1 ) error_handler(MyTransaction->getNdbError(), NO_FAIL);
pMyNdb->closeTransaction(MyTransaction);
}
ndbout <<" \tOK" << endl;
return;
}
示例7: while
void
start_T1(Ndb * pNDB, ThreadData * td, int async){
DEBUG2("T1(%.*s): - Starting", SUBSCRIBER_NUMBER_LENGTH,
td->transactionData.number);
NdbConnection * pCON = 0;
while((pCON = startTransaction(pNDB, td)) == 0){
CHECK_ALLOWED_ERROR("T1: startTransaction", td, pNDB->getNdbError());
NdbSleep_MilliSleep(10);
}
NdbOperation *MyOp = pCON->getNdbOperation(SUBSCRIBER_TABLE);
if (MyOp != NULL) {
MyOp->updateTuple();
MyOp->equal(IND_SUBSCRIBER_NUMBER,
td->transactionData.number);
MyOp->setValue(IND_SUBSCRIBER_LOCATION,
(char *)&td->transactionData.location);
MyOp->setValue(IND_SUBSCRIBER_CHANGED_BY,
td->transactionData.changed_by);
MyOp->setValue(IND_SUBSCRIBER_CHANGED_TIME,
td->transactionData.changed_time);
if (async == 1) {
pCON->executeAsynchPrepare( Commit , T1_Callback, td);
} else {
int result = pCON->execute(Commit);
T1_Callback(result, pCON, (void*)td);
return;
}//if
} else {
CHECK_NULL(MyOp, "T1: getNdbOperation", td, pCON->getNdbError());
}//if
}
示例8: QueryTransaction
int QueryTransaction(Ndb* pNdb,
long iContextId,
long* piVersion,
long* piLockFlag,
long* piLockTime,
long* piLockTimeUSec,
char* pchContextData,
NdbError& err)
{
int iRes = -1;
NdbConnection* pNdbConnection = pNdb->startTransaction(0, (const char*)&iContextId, 4);
if(pNdbConnection)
{
NdbOperation* pNdbOperation = pNdbConnection->getNdbOperation(g_szTableName);
if(pNdbOperation)
{
NdbRecAttr* pNdbRecAttrVersion;
NdbRecAttr* pNdbRecAttrLockFlag;
NdbRecAttr* pNdbRecAttrLockTime;
NdbRecAttr* pNdbRecAttrLockTimeUSec;
NdbRecAttr* pNdbRecAttrContextData;
if(!pNdbOperation->readTuple()
&& !pNdbOperation->equal(c_szContextId, (Int32)iContextId)
&& (pNdbRecAttrVersion=pNdbOperation->getValue(c_szVersion, (char*)piVersion))
&& (pNdbRecAttrLockFlag=pNdbOperation->getValue(c_szLockFlag, (char*)piLockFlag))
&& (pNdbRecAttrLockTime=pNdbOperation->getValue(c_szLockTime, (char*)piLockTime))
&& (pNdbRecAttrLockTimeUSec=pNdbOperation->getValue(c_szLockTimeUSec, (char*)piLockTimeUSec))
&& (pNdbRecAttrContextData=pNdbOperation->getValue(c_szContextData, pchContextData)))
{
if(!pNdbConnection->execute(Commit))
iRes = 0;
else
err = pNdbConnection->getNdbError();
}
else
err = pNdbOperation->getNdbError();
}
else
err = pNdbConnection->getNdbError();
pNdb->closeTransaction(pNdbConnection);
}
else
err = pNdb->getNdbError();
return iRes;
}
示例9: InsertTransaction
int InsertTransaction(Ndb* pNdb,
long iContextID,
long iVersion,
long iLockFlag,
long iLockTime,
long iLockTimeUSec,
const char* pchContextData,
NdbError& err)
{
int iRes = -1;
NdbConnection* pNdbConnection = pNdb->startTransaction(0, (const char*)&iContextID, 4);
if(pNdbConnection)
{
NdbOperation* pNdbOperation = pNdbConnection->getNdbOperation(g_szTableName);
if(pNdbOperation)
{
if(!(g_bWriteTuple ? pNdbOperation->writeTuple() : pNdbOperation->insertTuple())
&& !pNdbOperation->equal(c_szContextId, (Int32)iContextID)
&& !pNdbOperation->setValue(c_szVersion, (Int32)iVersion)
&& !pNdbOperation->setValue(c_szLockFlag, (Int32)iLockFlag)
&& !pNdbOperation->setValue(c_szLockTime, (Int32)iLockTime)
&& !pNdbOperation->setValue(c_szLockTimeUSec, (Int32)iLockTimeUSec)
&& !pNdbOperation->setValue(c_szContextData, pchContextData, g_nStatusDataSize))
{
if(!pNdbConnection->execute(Commit))
iRes = 0;
else
err = pNdbConnection->getNdbError();
}
else
err = pNdbOperation->getNdbError();
}
else
err = pNdbConnection->getNdbError();
pNdb->closeTransaction(pNdbConnection);
}
else
err = pNdb->getNdbError();
return iRes;
}
示例10: runPkReadPkUpdateUntilStopped
int runPkReadPkUpdateUntilStopped(NDBT_Context* ctx, NDBT_Step* step){
int result = NDBT_OK;
int records = ctx->getNumRecords();
Ndb* pNdb = GETNDB(step);
int i = 0;
HugoOperations hugoOps(*ctx->getTab());
while (ctx->isTestStopped() == false) {
g_info << i++ << ": ";
int rows = (rand()%records)+1;
int batch = (rand()%rows)+1;
int row = (records - rows) ? rand() % (records - rows) : 0;
int j,k;
for(j = 0; j<rows; j += batch)
{
k = batch;
if(j+k > rows)
k = rows - j;
if(hugoOps.startTransaction(pNdb) != 0)
goto err;
if(hugoOps.pkReadRecord(pNdb, row+j, k, NdbOperation::LM_Exclusive) != 0)
goto err;
if(hugoOps.execute_NoCommit(pNdb) != 0)
goto err;
if(hugoOps.pkUpdateRecord(pNdb, row+j, k, rand()) != 0)
goto err;
if(hugoOps.execute_Commit(pNdb) != 0)
goto err;
if(hugoOps.closeTransaction(pNdb) != 0)
return NDBT_FAILED;
}
continue;
err:
NdbConnection* pCon = hugoOps.getTransaction();
if(pCon == 0)
continue;
NdbError error = pCon->getNdbError();
hugoOps.closeTransaction(pNdb);
if (error.status == NdbError::TemporaryError){
NdbSleep_MilliSleep(50);
continue;
}
return NDBT_FAILED;
}
return NDBT_OK;
}
示例11: NdbThreadFuncUpdate
extern "C" void* NdbThreadFuncUpdate(void* pArg)
{
myRandom48Init((long int)NdbTick_CurrentMillisecond());
unsigned nSucc = 0;
unsigned nFail = 0;
Ndb* pNdb = NULL ;
pNdb = new Ndb("TEST_DB");
VerifyMethodInt(pNdb, init());
VerifyMethodInt(pNdb, waitUntilReady());
while(NdbMutex_Trylock(g_pNdbMutex)) {
Uint32 nWarehouse = myRandom48(g_nWarehouseCount);
NdbConnection* pNdbConnection = NULL ;
VerifyMethodPtr(pNdbConnection, pNdb, startTransaction());
CHK_TR(pNdbConnection) ; // epaulsa
NdbOperation* pNdbOperationW = NULL ;
VerifyMethodPtr(pNdbOperationW, pNdbConnection, getNdbOperation(c_szWarehouse));
VerifyMethodInt(pNdbOperationW, interpretedUpdateTuple());
VerifyMethodInt(pNdbOperationW, equal(c_szWarehouseNumber, nWarehouse));
VerifyMethodInt(pNdbOperationW, incValue(c_szWarehouseCount, Uint32(1)));
Uint32 nWarehouseSum = 0;
for(Uint32 nDistrict=0; nDistrict<g_nDistrictPerWarehouse; ++nDistrict) {
NdbOperation* pNdbOperationD = NULL ;
VerifyMethodPtr(pNdbOperationD, pNdbConnection, getNdbOperation(c_szDistrict));
VerifyMethodInt(pNdbOperationD, interpretedUpdateTuple());
VerifyMethodInt(pNdbOperationD, equal(c_szDistrictWarehouseNumber, nWarehouse));
VerifyMethodInt(pNdbOperationD, equal(c_szDistrictNumber, nDistrict));
VerifyMethodInt(pNdbOperationD, incValue(c_szDistrictCount, Uint32(1)));
Uint32 nDistrictSum = myRandom48(100);
nWarehouseSum += nDistrictSum;
VerifyMethodInt(pNdbOperationD, setValue(c_szDistrictSum, nDistrictSum));
}
VerifyMethodInt(pNdbOperationW, setValue(c_szWarehouseSum, nWarehouseSum));
int iExec = pNdbConnection->execute(Commit);
int iError = pNdbConnection->getNdbError().code;
if(iExec<0 && iError!=0 && iError!=266 && iError!=626) {
ReportMethodInt(iExec, pNdbConnection, "pNdbConnection", "execute(Commit)", __FILE__, __LINE__);
}
if(iExec==0) {
++nSucc;
} else {
++nFail;
}
VerifyMethodVoid(pNdb, closeTransaction(pNdbConnection));
}
ndbout << "update: " << nSucc << " succeeded, " << nFail << " failed " << endl;
NdbMutex_Unlock(g_pNdbMutex);
delete pNdb;
pNdb = NULL ;
return NULL;
}
示例12: verify_deleted
void verify_deleted(Ndb* pMyNdb) {
int check = -1 ;
int loop_count_ops = nRecords;
NdbOperation* pMyOperation = NULL ;
ndbout << "Verifying deleted records..."<< flush;
for (int count=0 ; count < loop_count_ops ; count++) {
NdbConnection* pMyTransaction = pMyNdb->startTransaction();
if (!pMyTransaction) error_handler(pMyNdb->getNdbError(), NO_FAIL);
pMyOperation = pMyTransaction->getNdbOperation(tableName);
if (!pMyOperation) error_handler(pMyNdb->getNdbError(), NO_FAIL);
check = pMyOperation->readTuple();
if( check == -1 ) error_handler( pMyTransaction->getNdbError(), NO_FAIL);
check = pMyOperation->equal( attrName[0],(char*)&pkValue[count] );
if( check == -1 ) error_handler( pMyTransaction->getNdbError(), NO_FAIL);
// Exepect to receive an error
if(pMyTransaction->execute(Commit) != -1)
if( 626 == pMyTransaction->getNdbError().code) {
ndbout << pMyTransaction->getNdbError() << endl ;
ndbout << "OK" << endl ;
} else {
error_handler(pMyTransaction->getNdbError(), NO_FAIL) ;
}
pMyNdb->closeTransaction(pMyTransaction);
}
ndbout << "OK" << endl;
return;
};
示例13: readTable
static void readTable(Ndb &myNdb, unsigned int noOfTuples, unsigned int noOfOperations, bool oneTrans, bool twoKey, bool longKey)
{
Uint64 tbefore, tafter, before, after;
NdbConnection *myTrans;
NdbOperation *myOp;
char name[] = "Kalle0000000";
NdbRecAttr* myRecAttrArr[MAX_NO_PARALLEL_OPERATIONS];
tbefore = NdbTick_CurrentMillisecond();
if (oneTrans) myTrans = myNdb.startTransaction();
for (unsigned int i = 0; i<noOfTuples; i++) {
if (!oneTrans) myTrans = myNdb.startTransaction();
for(unsigned int j = 1;
((j<=noOfOperations)&&(i<noOfTuples));
(++j<=noOfOperations)?i++:i) {
if (myTrans == NULL)
error_handler4(__LINE__, myNdb.getNdbError());
myOp = myTrans->getNdbOperation("PERSON");
if (myOp == NULL)
error_handler4(__LINE__, myTrans->getNdbError());
myOp->readTuple();
sprintf(name, "Kalle%.7i", i);
if (longKey)
memcpy(longName, name, strlen(name));
if (myOp->equal("NAME", (longKey)?longName:name) == -1) {
error_handler4(__LINE__, myTrans->getNdbError());
myNdb.closeTransaction(myTrans);
break;
}
if (twoKey)
if (myOp->equal("KEY2", i) == -1) {
error_handler4(__LINE__, myTrans->getNdbError());
myNdb.closeTransaction(myTrans);
break;
}
myRecAttrArr[j-1] = myOp->getValue("PNUM2", NULL);
}
if (noOfOperations == 1)
printf("Trying to read person %s\n", name);
else
printf("Trying to read %u persons\n", noOfOperations);
before = NdbTick_CurrentMillisecond();
if (myTrans->execute( (oneTrans) ? NoCommit : Commit ) == -1)
{
error_handler4(__LINE__, myTrans->getNdbError());
myNdb.closeTransaction(myTrans);
break;
}
after = NdbTick_CurrentMillisecond();
if (noOfOperations == 1)
printf("Read person %s, %u msec\n", name, (Uint32) after - before);
else
printf("Read %u persons, %u msec\n", noOfOperations, (Uint32) after - before);
for(unsigned int j = 0; j<noOfOperations; j++)
printf("PNUM2 = %u\n", myRecAttrArr[j]->u_32_value());
if (!oneTrans) myNdb.closeTransaction(myTrans);
}
if (oneTrans) {
if (myTrans->execute( Commit ) == -1) {
error_handler4(__LINE__, myTrans->getNdbError());
}
myNdb.closeTransaction(myTrans);
}
tafter = NdbTick_CurrentMillisecond();
ndbout << "Read "<< noOfTuples << " tuples in " << ((oneTrans) ? 1 : noOfTuples) << " transaction(s), " << tafter - tbefore << " msec" << endl;
}
示例14: while
inline
int
ScanFunctions::scanReadFunctions(Ndb* pNdb,
int records,
int parallelism,
ActionType action,
bool exclusive){
int retryAttempt = 0;
const int retryMax = 100;
int sleepTime = 10;
int check;
NdbConnection *pTrans = 0;
NdbScanOperation *pOp = 0;
while (true){
if (retryAttempt >= retryMax){
g_err << "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){
ERR(err);
NdbSleep_MilliSleep(50);
retryAttempt++;
continue;
}
ERR(err);
return NDBT_FAILED;
}
// Execute the scan without defining a scan operation
pOp = pTrans->getNdbScanOperation(tab.getName());
if (pOp == NULL) {
ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans);
return NDBT_FAILED;
}
if( pOp->readTuples(exclusive ?
NdbScanOperation::LM_Exclusive :
NdbScanOperation::LM_Read) ) {
ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans);
return NDBT_FAILED;
}
if (action == OnlyOpenScanOnce){
// Call openScan one more time when it's already defined
if( pOp->readTuples(NdbScanOperation::LM_Read) ) {
ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans);
return NDBT_FAILED;
}
}
if (action==EqualAfterOpenScan){
check = pOp->equal(tab.getColumn(0)->getName(), 10);
if( check == -1 ) {
ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans);
return NDBT_FAILED;
}
}
check = pOp->interpret_exit_ok();
if( check == -1 ) {
ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans);
return NDBT_FAILED;
}
for(int a = 0; a<tab.getNoOfColumns(); a++){
if(pOp->getValue(tab.getColumn(a)->getName()) == NULL) {
ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans);
return NDBT_FAILED;
}
}
check = pTrans->execute(NoCommit);
if( check == -1 ) {
ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans);
return NDBT_FAILED;
}
int abortCount = records / 10;
bool abortTrans = (action==CloseWithoutStop);
int eof;
int rows = 0;
eof = pOp->nextResult();
while(eof == 0){
rows++;
//.........这里部分代码省略.........
示例15: NdbThreadFuncRead
extern "C" void* NdbThreadFuncRead(void* pArg)
{
myRandom48Init((long int)NdbTick_CurrentMillisecond());
unsigned nSucc = 0;
unsigned nFail = 0;
NdbRecAttr** ppNdbRecAttrDSum = new NdbRecAttr*[g_nDistrictPerWarehouse];
NdbRecAttr** ppNdbRecAttrDCnt = new NdbRecAttr*[g_nDistrictPerWarehouse];
Ndb* pNdb = NULL ;
pNdb = new Ndb("TEST_DB");
VerifyMethodInt(pNdb, init());
VerifyMethodInt(pNdb, waitUntilReady());
while(NdbMutex_Trylock(g_pNdbMutex)) {
Uint32 nWarehouse = myRandom48(g_nWarehouseCount);
NdbConnection* pNdbConnection = NULL ;
VerifyMethodPtr(pNdbConnection, pNdb, startTransaction());
CHK_TR(pNdbConnection) ; // epaulsa
NdbOperation* pNdbOperationW = NULL ;
VerifyMethodPtr(pNdbOperationW, pNdbConnection, getNdbOperation(c_szWarehouse));
VerifyMethodInt(pNdbOperationW, readTuple());
VerifyMethodInt(pNdbOperationW, equal(c_szWarehouseNumber, nWarehouse));
NdbRecAttr* pNdbRecAttrWSum;
VerifyMethodPtr(pNdbRecAttrWSum, pNdbOperationW, getValue(c_szWarehouseSum, 0));
NdbRecAttr* pNdbRecAttrWCnt;
VerifyMethodPtr(pNdbRecAttrWCnt, pNdbOperationW, getValue(c_szWarehouseCount, 0));
for(Uint32 nDistrict=0; nDistrict<g_nDistrictPerWarehouse; ++nDistrict) {
NdbOperation* pNdbOperationD = NULL ;
VerifyMethodPtr(pNdbOperationD, pNdbConnection, getNdbOperation(c_szDistrict));
VerifyMethodInt(pNdbOperationD, readTuple());
VerifyMethodInt(pNdbOperationD, equal(c_szDistrictWarehouseNumber, nWarehouse));
VerifyMethodInt(pNdbOperationD, equal(c_szDistrictNumber, nDistrict));
VerifyMethodPtr(ppNdbRecAttrDSum[nDistrict], pNdbOperationD, getValue(c_szDistrictSum, 0));
VerifyMethodPtr(ppNdbRecAttrDCnt[nDistrict], pNdbOperationD, getValue(c_szDistrictCount, 0));
}
int iExec = pNdbConnection->execute(Commit);
int iError = pNdbConnection->getNdbError().code;
if(iExec<0 && iError!=0 && iError!=266 && iError!=626) {
ReportMethodInt(iExec, pNdbConnection, "pNdbConnection", "execute(Commit)", __FILE__, __LINE__);
}
if(iExec==0) {
Uint32 nSum = 0;
Uint32 nCnt = 0;
for(Uint32 nDistrict=0; nDistrict<g_nDistrictPerWarehouse; ++nDistrict) {
nSum += ppNdbRecAttrDSum[nDistrict]->u_32_value();
nCnt += ppNdbRecAttrDCnt[nDistrict]->u_32_value();
}
if(nSum!=pNdbRecAttrWSum->u_32_value()
|| nCnt!=g_nDistrictPerWarehouse*pNdbRecAttrWCnt->u_32_value()) {
ndbout << "INCONSISTENT!" << endl;
ndbout << "iExec==" << iExec << endl;
ndbout << "iError==" << iError << endl;
ndbout << endl;
ndbout << c_szWarehouseSum << "==" << pNdbRecAttrWSum->u_32_value() << ", ";
ndbout << c_szWarehouseCount << "==" << pNdbRecAttrWCnt->u_32_value() << endl;
ndbout << "nSum==" << nSum << ", nCnt=" << nCnt << endl;
for(Uint32 nDistrict=0; nDistrict<g_nDistrictPerWarehouse; ++nDistrict) {
ndbout << c_szDistrictSum << "[" << nDistrict << "]==" << ppNdbRecAttrDSum[nDistrict]->u_32_value() << ", ";
ndbout << c_szDistrictCount << "[" << nDistrict << "]==" << ppNdbRecAttrDCnt[nDistrict]->u_32_value() << endl;
}
VerifyMethodVoid(pNdb, closeTransaction(pNdbConnection));
delete pNdb;
pNdb = NULL ;
delete[] ppNdbRecAttrDSum;
ppNdbRecAttrDSum = NULL ;
delete[] ppNdbRecAttrDCnt;
ppNdbRecAttrDCnt = NULL ;
NDBT_ProgramExit(NDBT_FAILED);
}
++nSucc;
} else {
++nFail;
}
VerifyMethodVoid(pNdb, closeTransaction(pNdbConnection));
}
ndbout << "read: " << nSucc << " succeeded, " << nFail << " failed " << endl;
NdbMutex_Unlock(g_pNdbMutex);
delete pNdb;
pNdb = NULL ;
delete[] ppNdbRecAttrDSum;
ppNdbRecAttrDSum = NULL ;
delete[] ppNdbRecAttrDCnt;
ppNdbRecAttrDCnt = NULL ;
return NULL;
}