本文整理汇总了C++中Ndb::closeTransaction方法的典型用法代码示例。如果您正苦于以下问题:C++ Ndb::closeTransaction方法的具体用法?C++ Ndb::closeTransaction怎么用?C++ Ndb::closeTransaction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ndb
的用法示例。
在下文中一共展示了Ndb::closeTransaction方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run_master_update
static void run_master_update(struct Xxx &xxx, struct XxxR &xxxr)
{
Ndb *ndb = xxx.ndb;
const NdbDictionary::Table *myTable = xxx.table;
int retry_sleep= 10; /* 10 milliseconds */
int retries= 100;
while (1)
{
Uint32 val;
NdbTransaction *trans = ndb->startTransaction();
if (trans == NULL)
goto err;
{
NdbOperation *op = trans->getNdbOperation(myTable);
if (op == NULL)
APIERROR(trans->getNdbError());
op->readTupleExclusive();
op->equal(xxx.pk_col, xxxr.pk_val);
op->getValue(xxx.col, (char *)&val);
}
if (trans->execute(NdbTransaction::NoCommit))
goto err;
//fprintf(stderr, "read %u\n", val);
xxxr.val = val + 1;
{
NdbOperation *op = trans->getNdbOperation(myTable);
if (op == NULL)
APIERROR(trans->getNdbError());
op->updateTuple();
op->equal(xxx.pk_col, xxxr.pk_val);
op->setValue(xxx.col, xxxr.val);
}
if (trans->execute(NdbTransaction::Commit))
goto err;
ndb->closeTransaction(trans);
//fprintf(stderr, "updated to %u\n", xxxr.val);
break;
err:
const NdbError this_error= trans ?
trans->getNdbError() : ndb->getNdbError();
if (this_error.status == NdbError::TemporaryError)
{
if (retries--)
{
if (trans)
ndb->closeTransaction(trans);
NdbSleep_MilliSleep(retry_sleep);
continue; // retry
}
}
if (trans)
ndb->closeTransaction(trans);
APIERROR(this_error);
}
/* update done start timer */
gettimeofday(&xxxr.start_time, 0);
}
示例2: 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;
}
示例3: do_update
/*****************************************************************
* Update the second attribute in half of the tuples (adding 10) *
*****************************************************************/
static void do_update(Ndb &myNdb, const char* table)
{
const NdbDictionary::Dictionary* myDict= myNdb.getDictionary();
const NdbDictionary::Table *myTable= myDict->getTable(table);
if (myTable == NULL)
APIERROR(myDict->getNdbError());
for (int i = 0; i < 10; i+=2) {
NdbTransaction *myTransaction= myNdb.startTransaction();
if (myTransaction == NULL) APIERROR(myNdb.getNdbError());
NdbOperation *myOperation= myTransaction->getNdbOperation(myTable);
if (myOperation == NULL) APIERROR(myTransaction->getNdbError());
myOperation->updateTuple();
myOperation->equal( "ATTR1", i );
myOperation->setValue( "ATTR2", i+10);
if( myTransaction->execute( NdbTransaction::Commit ) == -1 )
APIERROR(myTransaction->getNdbError());
myNdb.closeTransaction(myTransaction);
}
}
示例4: do_insert
/**************************************************************************
* Using 5 transactions, insert 10 tuples in table: (0,0),(1,1),...,(9,9) *
**************************************************************************/
static void do_insert(Ndb &myNdb)
{
const NdbDictionary::Dictionary* myDict= myNdb.getDictionary();
const NdbDictionary::Table *myTable= myDict->getTable("MYTABLENAME");
if (myTable == NULL)
APIERROR(myDict->getNdbError());
for (int i = 0; i < 5; i++) {
NdbTransaction *myTransaction= myNdb.startTransaction();
if (myTransaction == NULL) APIERROR(myNdb.getNdbError());
NdbOperation *myOperation= myTransaction->getNdbOperation(myTable);
if (myOperation == NULL) APIERROR(myTransaction->getNdbError());
myOperation->insertTuple();
myOperation->equal("ATTR1", i);
myOperation->setValue("ATTR2", i);
myOperation= myTransaction->getNdbOperation(myTable);
if (myOperation == NULL) APIERROR(myTransaction->getNdbError());
myOperation->insertTuple();
myOperation->equal("ATTR1", i+5);
myOperation->setValue("ATTR2", i+5);
if (myTransaction->execute( NdbTransaction::Commit ) == -1)
APIERROR(myTransaction->getNdbError());
myNdb.closeTransaction(myTransaction);
}
}
示例5:
/**
* Transaction 1 - T1
*
* Update location and changed by/time on a subscriber
*
* Input:
* SubscriberNumber,
* Location,
* ChangedBy,
* ChangedTime
*
* Output:
*/
int
T1(void * obj,
const SubscriberNumber number,
const Location new_location,
const ChangedBy changed_by,
const ChangedTime changed_time,
BenchmarkTime * transaction_time){
Ndb * pNDB = (Ndb *) obj;
DEBUG2("T1(%.*s):\n", SUBSCRIBER_NUMBER_LENGTH, number);
BenchmarkTime start;
get_time(&start);
int check;
NdbRecAttr * check2;
NdbConnection * MyTransaction = pNDB->startTransaction();
if (MyTransaction == NULL)
error_handler("T1-1: startTranscation", pNDB->getNdbErrorString(), 0);
NdbOperation *MyOperation = MyTransaction->getNdbOperation(SUBSCRIBER_TABLE);
CHECK_NULL(MyOperation, "T1: getNdbOperation", MyTransaction);
check = MyOperation->updateTuple();
CHECK_MINUS_ONE(check, "T1: updateTuple",
MyTransaction);
check = MyOperation->equal(IND_SUBSCRIBER_NUMBER,
number);
CHECK_MINUS_ONE(check, "T1: equal subscriber",
MyTransaction);
check = MyOperation->setValue(IND_SUBSCRIBER_LOCATION,
(char *)&new_location);
CHECK_MINUS_ONE(check, "T1: setValue location",
MyTransaction);
check = MyOperation->setValue(IND_SUBSCRIBER_CHANGED_BY,
changed_by);
CHECK_MINUS_ONE(check, "T1: setValue changed_by",
MyTransaction);
check = MyOperation->setValue(IND_SUBSCRIBER_CHANGED_TIME,
changed_time);
CHECK_MINUS_ONE(check, "T1: setValue changed_time",
MyTransaction);
check = MyTransaction->execute( Commit );
CHECK_MINUS_ONE(check, "T1: Commit",
MyTransaction);
pNDB->closeTransaction(MyTransaction);
get_time(transaction_time);
time_diff(transaction_time, &start);
return 0;
}
示例6: runVerifyUndoData
int runVerifyUndoData(NDBT_Context* ctx, NDBT_Step* step){
int records = ctx->getNumRecords();
Ndb* pNdb = GETNDB(step);
int count = 0;
int num = 5;
if (records - 5 < 0)
num = 1;
const NdbDictionary::Table* tab =
GETNDB(step)->getDictionary()->getTable(ctx->getTab()->getName());
if(tab == 0) {
g_err << " Can't find table" << endl;
return NDBT_FAILED;
}
UtilTransactions utilTrans(* tab);
HugoTransactions hugoTrans(* tab);
// Check that there are as many records as we expected
if(utilTrans.selectCount(pNdb, 64, &count) != 0) {
g_err << "Can't get records count" << endl;
return NDBT_FAILED;
}
g_err << "count = " << count;
g_err << " records = " << records;
g_err << endl;
if (count != records) {
g_err << "The records count is not correct" << endl;
return NDBT_FAILED;
}
// make sure all the update data is there
NdbTransaction *pTransaction= pNdb->startTransaction();
if (pTransaction == NULL) {
g_err << "Can't get transaction pointer" << endl;
return NDBT_FAILED;
}
if(hugoTrans.setTransaction(pTransaction) != 0) {
g_err << "Set transaction error" << endl;
pNdb->closeTransaction(pTransaction);
return NDBT_FAILED;
}
if(hugoTrans.pkReadRecord(pNdb, 0, records, NdbOperation::LM_Read) != 0) {
g_err << "Can't read record" << endl;
return NDBT_FAILED;
}
if(hugoTrans.verifyUpdatesValue(0, records) != 0) {
g_err << "The records restored with undo log is not correct" << endl;
return NDBT_FAILED;
}
hugoTrans.closeTransaction(pNdb);
return NDBT_OK;
}
示例7:
int
insert_subscriber(void * obj,
SubscriberNumber number,
SubscriberName name,
GroupId groupId,
Location l,
ActiveSessions activeSessions,
ChangedBy changedBy,
ChangedTime changedTime){
Ndb * pNDB = (Ndb *)obj;
int check;
NdbConnection * MyTransaction = pNDB->startTransaction();
if (MyTransaction == NULL)
error_handler("startTranscation", pNDB->getNdbErrorString(), 0);
NdbOperation *MyOperation = MyTransaction->getNdbOperation(SUBSCRIBER_TABLE);
CHECK_NULL(MyOperation, "getNdbOperation", MyTransaction);
check = MyOperation->insertTuple();
CHECK_MINUS_ONE(check, "insertTuple", MyTransaction);
check = MyOperation->equal(SUBSCRIBER_NUMBER, number);
CHECK_MINUS_ONE(check, "equal", MyTransaction);
check = MyOperation->setValue(SUBSCRIBER_NAME, name);
CHECK_MINUS_ONE(check, "setValue name", MyTransaction);
check = MyOperation->setValue(SUBSCRIBER_GROUP, (char*)&groupId);
CHECK_MINUS_ONE(check, "setValue group", MyTransaction);
check = MyOperation->setValue(SUBSCRIBER_LOCATION, (char*)&l);
CHECK_MINUS_ONE(check, "setValue location", MyTransaction);
check = MyOperation->setValue(SUBSCRIBER_SESSIONS, (char*)&activeSessions);
CHECK_MINUS_ONE(check, "setValue sessions", MyTransaction);
check = MyOperation->setValue(SUBSCRIBER_CHANGED_BY, changedBy);
CHECK_MINUS_ONE(check, "setValue changedBy", MyTransaction);
check = MyOperation->setValue(SUBSCRIBER_CHANGED_TIME, changedTime);
CHECK_MINUS_ONE(check, "setValue changedTime", MyTransaction);
check = MyTransaction->execute( Commit );
CHECK_MINUS_ONE(check, "commit", MyTransaction);
pNDB->closeTransaction(MyTransaction);
return 0;
}
示例8:
/**
* Transaction 1 - T1
*
* Update location and changed by/time on a subscriber
*
* Input:
* SubscriberNumber,
* Location,
* ChangedBy,
* ChangedTime
*
* Output:
*/
void
userTransaction_T1(UserHandle * uh,
SubscriberNumber number,
Location new_location,
ChangedBy changed_by,
ChangedTime changed_time){
Ndb * pNDB = uh->pNDB;
DEBUG2("T1(%.*s):\n", SUBSCRIBER_NUMBER_LENGTH, number);
int check;
NdbRecAttr * check2;
NdbConnection * MyTransaction = pNDB->startTransaction();
if (MyTransaction != NULL) {
NdbOperation *MyOperation = MyTransaction->getNdbOperation(SUBSCRIBER_TABLE);
if (MyOperation != NULL) {
MyOperation->updateTuple();
MyOperation->equal(IND_SUBSCRIBER_NUMBER,
number);
MyOperation->setValue(IND_SUBSCRIBER_LOCATION,
(char *)&new_location);
MyOperation->setValue(IND_SUBSCRIBER_CHANGED_BY,
changed_by);
MyOperation->setValue(IND_SUBSCRIBER_CHANGED_TIME,
changed_time);
check = MyTransaction->execute( Commit );
if (check != -1) {
pNDB->closeTransaction(MyTransaction);
return;
} else {
CHECK_MINUS_ONE(check, "T1: Commit",
MyTransaction);
}//if
} else {
CHECK_NULL(MyOperation, "T1: getNdbOperation", MyTransaction);
}//if
} else {
error_handler("T1-1: startTranscation", pNDB->getNdbErrorString(), pNDB->getNdbError());
}//if
}
示例9: do_delete
/*************************************************
* Delete one tuple (the one with primary key 3) *
*************************************************/
static void do_delete(Ndb &myNdb, const char* table)
{
const NdbDictionary::Dictionary* myDict= myNdb.getDictionary();
const NdbDictionary::Table *myTable= myDict->getTable(table);
if (myTable == NULL)
APIERROR(myDict->getNdbError());
NdbTransaction *myTransaction= myNdb.startTransaction();
if (myTransaction == NULL) APIERROR(myNdb.getNdbError());
NdbOperation *myOperation= myTransaction->getNdbOperation(myTable);
if (myOperation == NULL) APIERROR(myTransaction->getNdbError());
myOperation->deleteTuple();
myOperation->equal( "ATTR1", 3 );
if (myTransaction->execute(NdbTransaction::Commit) == -1)
APIERROR(myTransaction->getNdbError());
myNdb.closeTransaction(myTransaction);
}
示例10: do_read
/*****************************
* Read and print all tuples *
*****************************/
static void do_read(Ndb &myNdb, const char* table)
{
const NdbDictionary::Dictionary* myDict= myNdb.getDictionary();
const NdbDictionary::Table *myTable= myDict->getTable(table);
if (myTable == NULL)
APIERROR(myDict->getNdbError());
std::cout << "ATTR1 ATTR2" << std::endl;
for (int i = 0; i < 10; i++) {
NdbTransaction *myTransaction= myNdb.startTransaction();
if (myTransaction == NULL) APIERROR(myNdb.getNdbError());
NdbOperation *myOperation= myTransaction->getNdbOperation(myTable);
if (myOperation == NULL) APIERROR(myTransaction->getNdbError());
myOperation->readTuple(NdbOperation::LM_Read);
myOperation->equal("ATTR1", i);
NdbRecAttr *myRecAttr= myOperation->getValue("ATTR2", NULL);
if (myRecAttr == NULL) APIERROR(myTransaction->getNdbError());
if(myTransaction->execute( NdbTransaction::Commit ) == -1)
{
if (i == 3) {
std::cout << "Detected that deleted tuple doesn't exist!" << std::endl;
} else {
APIERROR(myTransaction->getNdbError());
}
}
if (i != 3) {
printf(" %2d %2d\n", i, myRecAttr->u_32_value());
}
myNdb.closeTransaction(myTransaction);
}
}
示例11: main
//.........这里部分代码省略.........
const NdbDictionary::Dictionary* myDict= myNdb->getDictionary();
const NdbDictionary::Table *myTable= myDict->getTable("api_simple_index");
if (myTable == NULL)
APIERROR(myDict->getNdbError());
const NdbDictionary::Index *myIndex= myDict->getIndex("MYINDEXNAME$unique","api_simple_index");
if (myIndex == NULL)
APIERROR(myDict->getNdbError());
/**************************************************************************
* Using 5 transactions, insert 10 tuples in table: (0,0),(1,1),...,(9,9) *
**************************************************************************/
for (int i = 0; i < 5; i++) {
NdbTransaction *myTransaction= myNdb->startTransaction();
if (myTransaction == NULL) APIERROR(myNdb->getNdbError());
NdbOperation *myOperation= myTransaction->getNdbOperation(myTable);
if (myOperation == NULL) APIERROR(myTransaction->getNdbError());
myOperation->insertTuple();
myOperation->equal("ATTR1", i);
myOperation->setValue("ATTR2", i);
myOperation = myTransaction->getNdbOperation(myTable);
if (myOperation == NULL) APIERROR(myTransaction->getNdbError());
myOperation->insertTuple();
myOperation->equal("ATTR1", i+5);
myOperation->setValue("ATTR2", i+5);
if (myTransaction->execute( NdbTransaction::Commit ) == -1)
APIERROR(myTransaction->getNdbError());
myNdb->closeTransaction(myTransaction);
}
/*****************************************
* Read and print all tuples using index *
*****************************************/
std::cout << "ATTR1 ATTR2" << std::endl;
for (int i = 0; i < 10; i++) {
NdbTransaction *myTransaction= myNdb->startTransaction();
if (myTransaction == NULL) APIERROR(myNdb->getNdbError());
NdbIndexOperation *myIndexOperation=
myTransaction->getNdbIndexOperation(myIndex);
if (myIndexOperation == NULL) APIERROR(myTransaction->getNdbError());
myIndexOperation->readTuple(NdbOperation::LM_Read);
myIndexOperation->equal("ATTR2", i);
NdbRecAttr *myRecAttr= myIndexOperation->getValue("ATTR1", NULL);
if (myRecAttr == NULL) APIERROR(myTransaction->getNdbError());
if(myTransaction->execute( NdbTransaction::Commit,
NdbOperation::AbortOnError ) != -1)
printf(" %2d %2d\n", myRecAttr->u_32_value(), i);
myNdb->closeTransaction(myTransaction);
}
/*****************************************************************
* Update the second attribute in half of the tuples (adding 10) *
*****************************************************************/
for (int i = 0; i < 10; i+=2) {
示例12: trans
//.........这里部分代码省略.........
while (1)
{
require(table_list.size() == 1);
const char* tabname = table_list[0].c_str();
const NdbDictionary::Table* tab = 0;
CHK2((tab = pDict->getTable(tabname)) != 0,
tabname << ": " << pDict->getNdbError());
const int ncol = tab->getNoOfColumns();
{
HugoTransactions trans(*tab);
CHK2(trans.loadTable(pNdb, records) == 0, trans.getNdbError());
}
for (int r = 0; r < records; r++)
{
// with 1000 records will surely hit bug case
const int lm = myRandom48(4); // 2
const int nval = myRandom48(ncol + 1); // most
const bool exist = myRandom48(2); // false
NdbTransaction* pTx = 0;
NdbOperation* pOp = 0;
CHK2((pTx = pNdb->startTransaction()) != 0,
pNdb->getNdbError());
CHK2((pOp = pTx->getNdbOperation(tab)) != 0,
pTx->getNdbError());
CHK2((pOp->readTuple((NdbOperation::LockMode)lm)) == 0,
pOp->getNdbError());
for (int id = 0; id <= 0; id++)
{
const NdbDictionary::Column* c = tab->getColumn(id);
require(c != 0 && c->getPrimaryKey() &&
c->getType() == NdbDictionary::Column::Unsigned);
Uint32 val = myRandom48(records);
if (!exist)
val = 0xaaaa0000 + myRandom48(0xffff + 1);
const char* valp = (const char*)&val;
CHK2(pOp->equal(id, valp) == 0, pOp->getNdbError());
}
CHK2(result == NDBT_OK, "failed");
for (int id = 0; id < nval; id++)
{
const NdbDictionary::Column* c = tab->getColumn(id);
require(c != 0 && (id == 0 || !c->getPrimaryKey()));
CHK2(pOp->getValue(id) != 0, pOp->getNdbError());
}
CHK2(result == NDBT_OK, "failed");
char info1[200];
sprintf(info1, "lm=%d nval=%d exist=%d",
lm, nval, exist);
g_info << "PK read T1 exec: " << info1 << endl;
Uint64 t1 = NdbTick_CurrentMillisecond();
int ret = pTx->execute(NdbTransaction::NoCommit);
Uint64 t2 = NdbTick_CurrentMillisecond();
int msec = (int)(t2-t1);
const NdbError& txerr = pTx->getNdbError();
const NdbError& operr = pOp->getNdbError();
char info2[200];
sprintf(info2, "%s msec=%d ret=%d txerr=%d operr=%d",
info1, msec, ret, txerr.code, operr.code);
g_info << "PK read T1 done: " << info2 << endl;
if (ret == 0 && txerr.code == 0 && operr.code == 0)
{
CHK2(exist, "row should not be found: " << info2);
}
else if (ret == 0 && txerr.code == 626 && operr.code == 626)
{
CHK2(!exist, "row should be found: " << info2);
}
else if (txerr.status == NdbError::TemporaryError)
{
g_err << "PK read T1 temporary error (tx): " << info2 << endl;
NdbSleep_MilliSleep(50);
}
else if (operr.status == NdbError::TemporaryError)
{
g_err << "PK read T1 temporary error (op): " << info2 << endl;
NdbSleep_MilliSleep(50);
}
else
{
// gets 4012 before bugfix
CHK2(false, "unexpected error: " << info2);
}
pNdb->closeTransaction(pTx);
pTx = 0;
}
break;
}
g_err << "Clear half started hold..." << endl;
ctx->setProperty("HalfStartedHold", (Uint32)0);
return result;
}
示例13: DEBUG
//.........这里部分代码省略.........
/* Operation 3 */
MyOperation = MyTransaction->getNdbOperation(SESSION_TABLE);
CHECK_NULL(MyOperation, "T5-3: getNdbOperation",
MyTransaction);
check = MyOperation->deleteTuple();
CHECK_MINUS_ONE(check, "T5-3: deleteTuple",
MyTransaction);
check = MyOperation->equal(IND_SESSION_SUBSCRIBER,
(char*)inNumber);
CHECK_MINUS_ONE(check, "T5-3: equal number",
MyTransaction);
check = MyOperation->equal(IND_SESSION_SERVER,
(char*)&inServerId);
CHECK_MINUS_ONE(check, "T5-3: equal server id",
MyTransaction);
check = MyTransaction->execute( NoCommit );
CHECK_MINUS_ONE(check, "T5-3: NoCommit",
MyTransaction);
/* Operation 4 */
MyOperation = MyTransaction->getNdbOperation(SUBSCRIBER_TABLE);
CHECK_NULL(MyOperation, "T5-4: getNdbOperation",
MyTransaction);
check = MyOperation->interpretedUpdateTuple();
CHECK_MINUS_ONE(check, "T5-4: interpretedUpdateTuple",
MyTransaction);
check = MyOperation->equal(IND_SUBSCRIBER_NUMBER,
(char*)inNumber);
CHECK_MINUS_ONE(check, "T5-4: equal number",
MyTransaction);
check = MyOperation->subValue(IND_SUBSCRIBER_SESSIONS,
(uint32)inServerBit);
CHECK_MINUS_ONE(check, "T5-4: dec value",
MyTransaction);
check = MyTransaction->execute( NoCommit );
CHECK_MINUS_ONE(check, "T5-4: NoCommit",
MyTransaction);
/* Operation 5 */
MyOperation = MyTransaction->getNdbOperation(SERVER_TABLE);
CHECK_NULL(MyOperation, "T5-5: getNdbOperation",
MyTransaction);
check = MyOperation->interpretedUpdateTuple();
CHECK_MINUS_ONE(check, "T5-5: interpretedUpdateTuple",
MyTransaction);
check = MyOperation->equal(IND_SERVER_ID,
(char*)&inServerId);
CHECK_MINUS_ONE(check, "T5-5: equal serverId",
MyTransaction);
check = MyOperation->equal(IND_SERVER_SUBSCRIBER_SUFFIX,
(char*)inSuffix);
CHECK_MINUS_ONE(check, "T5-5: equal suffix",
MyTransaction);
check = MyOperation->incValue(IND_SERVER_DELETES, (uint32)1);
CHECK_MINUS_ONE(check, "T5-5: inc value",
MyTransaction);
check = MyTransaction->execute( NoCommit );
CHECK_MINUS_ONE(check, "T5-5: NoCommit",
MyTransaction);
(* outBranchExecuted) = 1;
} else {
DEBUG1("%s", ((permission & inServerBit) ? "permission - " : "no permission - "));
DEBUG1("%s", ((sessions & inServerBit) ? "in session - " : "no in session - "));
(* outBranchExecuted) = 0;
}
if(!inDoRollback) {
DEBUG("commit\n");
check = MyTransaction->execute( Commit );
CHECK_MINUS_ONE(check, "T5: Commit",
MyTransaction);
} else {
DEBUG("rollback\n");
check = MyTransaction->execute(Rollback);
CHECK_MINUS_ONE(check, "T5:Rollback",
MyTransaction);
}
pNDB->closeTransaction(MyTransaction);
get_time(outTransactionTime);
time_diff(outTransactionTime, &start);
return 0;
}
示例14:
/**
* Transaction 2 - T2
*
* Read from Subscriber:
*
* Input:
* SubscriberNumber
*
* Output:
* Location
* Changed by
* Changed Timestamp
* Name
*/
int
T2(void * obj,
const SubscriberNumber number,
Location * readLocation,
ChangedBy changed_by,
ChangedTime changed_time,
SubscriberName subscriberName,
BenchmarkTime * transaction_time) {
Ndb * pNDB = (Ndb *) obj;
BenchmarkTime start;
get_time(&start);
int check;
NdbRecAttr * check2;
NdbConnection * MyTransaction = pNDB->startTransaction();
if (MyTransaction == NULL)
error_handler("T2: startTranscation", pNDB->getNdbErrorString(), 0);
NdbOperation *MyOperation= MyTransaction->getNdbOperation(SUBSCRIBER_TABLE);
CHECK_NULL(MyOperation, "T2: getNdbOperation",
MyTransaction);
check = MyOperation->readTuple();
CHECK_MINUS_ONE(check, "T2: readTuple",
MyTransaction);
check = MyOperation->equal(IND_SUBSCRIBER_NUMBER,
number);
CHECK_MINUS_ONE(check, "T2: equal subscriber",
MyTransaction);
check2 = MyOperation->getValue(IND_SUBSCRIBER_LOCATION,
(char *)readLocation);
CHECK_NULL(check2, "T2: getValue location",
MyTransaction);
check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_BY,
changed_by);
CHECK_NULL(check2, "T2: getValue changed_by",
MyTransaction);
check2 = MyOperation->getValue(IND_SUBSCRIBER_CHANGED_TIME,
changed_time);
CHECK_NULL(check2, "T2: getValue changed_time",
MyTransaction);
check2 = MyOperation->getValue(IND_SUBSCRIBER_NAME,
subscriberName);
CHECK_NULL(check2, "T2: getValue name",
MyTransaction);
check = MyTransaction->execute( Commit );
CHECK_MINUS_ONE(check, "T2: Commit",
MyTransaction);
pNDB->closeTransaction(MyTransaction);
get_time(transaction_time);
time_diff(transaction_time, &start);
return 0;
}
示例15: runTestBug19537
int runTestBug19537(NDBT_Context* ctx, NDBT_Step* step){
const NdbDictionary::Table * pTab = ctx->getTab();
Ndb* pNdb = GETNDB(step);
if (strcmp(pTab->getName(), "T1") != 0) {
g_err << "runTestBug19537: skip, table != T1" << endl;
return NDBT_OK;
}
NdbConnection* pTrans = pNdb->startTransaction();
if (pTrans == NULL){
ERR(pNdb->getNdbError());
return NDBT_FAILED;
}
NdbOperation* pOp = pTrans->getNdbOperation(pTab->getName());
if (pOp == NULL) {
ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans);
return NDBT_FAILED;
}
if (pOp->interpretedUpdateTuple() == -1) {
ERR(pOp->getNdbError());
pNdb->closeTransaction(pTrans);
return NDBT_FAILED;
}
// Primary keys
const Uint32 pkVal = 1;
if (pOp->equal("KOL1", pkVal) == -1) {
ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans);
return NDBT_FAILED;
}
// Load 64-bit constant into register 1 and
// write from register 1 to 32-bit column KOL2
const Uint64 reg_val = 0x0102030405060708ULL;
#if 0
Uint32 reg_ptr32[2];
memcpy(&(reg_ptr32[0]), (Uint8*)®_val, sizeof(Uint32));
memcpy(&(reg_ptr32[1]), ((Uint8*)®_val)+4, sizeof(Uint32));
if (reg_ptr32[0] == 0x05060708 && reg_ptr32[1] == 0x01020304) {
g_err << "runTestBug19537: platform is LITTLE endian" << endl;
} else if (reg_ptr32[0] == 0x01020304 && reg_ptr32[1] == 0x05060708) {
g_err << "runTestBug19537: platform is BIG endian" << endl;
} else {
g_err << "runTestBug19537: impossible platform"
<< hex << " [0]=" << reg_ptr32[0] << " [1]=" <<reg_ptr32[1] << endl;
pNdb->closeTransaction(pTrans);
return NDBT_FAILED;
}
#endif
if (pOp->load_const_u64(1, reg_val) == -1 ||
pOp->write_attr("KOL2", 1) == -1) {
ERR(pOp->getNdbError());
pNdb->closeTransaction(pTrans);
return NDBT_FAILED;
}
if (pTrans->execute(Commit) == -1) {
ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans);
return NDBT_FAILED;
}
// Read value via a new transaction
pTrans = pNdb->startTransaction();
if (pTrans == NULL){
ERR(pNdb->getNdbError());
return NDBT_FAILED;
}
pOp = pTrans->getNdbOperation(pTab->getName());
if (pOp == NULL) {
ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans);
return NDBT_FAILED;
}
Uint32 kol2 = 0x09090909;
if (pOp->readTuple() == -1 ||
pOp->equal("KOL1", pkVal) == -1 ||
pOp->getValue("KOL2", (char*)&kol2) == 0) {
ERR(pOp->getNdbError());
pNdb->closeTransaction(pTrans);
return NDBT_FAILED;
}
if (pTrans->execute(Commit) == -1) {
ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans);
return NDBT_FAILED;
}
//.........这里部分代码省略.........