本文整理汇总了C++中NdbOperation::incValue方法的典型用法代码示例。如果您正苦于以下问题:C++ NdbOperation::incValue方法的具体用法?C++ NdbOperation::incValue怎么用?C++ NdbOperation::incValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NdbOperation
的用法示例。
在下文中一共展示了NdbOperation::incValue方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: memcpy
void
T3_Callback_2(int result, NdbConnection * pCON, void * threadData){
ThreadData * td = (ThreadData *)threadData;
CHECK_MINUS_ONE(result, "T3-2: NoCommit", pCON);
Uint32 permission = td->transactionData.permission;
Uint32 sessions = td->transactionData.sessions;
Uint32 server_bit = td->transactionData.server_bit;
if(((permission & server_bit) == server_bit) &&
((sessions & server_bit) == server_bit)){
memcpy(td->transactionData.suffix,
&td->transactionData.number
[SUBSCRIBER_NUMBER_LENGTH-SUBSCRIBER_NUMBER_SUFFIX_LENGTH],
SUBSCRIBER_NUMBER_SUFFIX_LENGTH);
DEBUG5("T3(%.*s, %.2d): - Callback 2 - reading(%.*s)\n",
SUBSCRIBER_NUMBER_LENGTH,
td->transactionData.number,
td->transactionData.server_id,
SUBSCRIBER_NUMBER_SUFFIX_LENGTH,
td->transactionData.suffix);
/* Operation 3 */
NdbOperation * MyOp = pCON->getNdbOperation(SESSION_TABLE);
CHECK_NULL(MyOp, "T3-3: getNdbOperation",
pCON);
MyOp->simpleRead();
MyOp->equal(IND_SESSION_SUBSCRIBER,
(char*)td->transactionData.number);
MyOp->equal(IND_SESSION_SERVER,
(char*)&td->transactionData.server_id);
MyOp->getValue(IND_SESSION_DATA,
(char *)td->transactionData.session_details);
/* Operation 4 */
MyOp = pCON->getNdbOperation(SERVER_TABLE);
CHECK_NULL(MyOp, "T3-4: getNdbOperation",
pCON);
MyOp->interpretedUpdateTuple();
MyOp->equal(IND_SERVER_ID,
(char*)&td->transactionData.server_id);
MyOp->equal(IND_SERVER_SUBSCRIBER_SUFFIX,
(char*)td->transactionData.suffix);
MyOp->incValue(IND_SERVER_READS, (uint32)1);
td->transactionData.branchExecuted = 1;
} else {
DEBUG3("T3(%.*s, %.2d): - Callback 2 - no read\n",
SUBSCRIBER_NUMBER_LENGTH,
td->transactionData.number,
td->transactionData.server_id);
td->transactionData.branchExecuted = 0;
}
pCON->executeAsynchPrepare( Commit, T3_Callback_3, td );
}
示例2: 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;
}
示例3: while
//.........这里部分代码省略.........
const NdbError err = pTrans->getNdbError();
if (err.status == NdbError::TemporaryError){
ERR(err);
closeTransaction(pNdb);
NdbSleep_MilliSleep(50);
retryAttempt++;
continue;
}
ERR(err);
closeTransaction(pNdb);
return NDBT_FAILED;
}
int updates = calc.getUpdatesValue(&row) + 1;
NdbOperation* pUpdOp;
pUpdOp = pTrans->getNdbOperation(tab.getName());
if (pUpdOp == NULL) {
ERR(pTrans->getNdbError());
closeTransaction(pNdb);
return NDBT_FAILED;
}
check = pUpdOp->interpretedUpdateTuple();
if( check == -1 ) {
ERR(pTrans->getNdbError());
closeTransaction(pNdb);
return NDBT_FAILED;
}
// PKs
if (equalForRow(pUpdOp, r) != 0)
{
closeTransaction(pNdb);
return NDBT_FAILED;
}
// Update col
for(a = 0; a<tab.getNoOfColumns(); a++){
if ((tab.getColumn(a)->getPrimaryKey() == false) &&
(calc.isUpdateCol(a) == true)){
// TODO switch for 32/64 bit
const NdbDictionary::Column* attr = tab.getColumn(a);
Uint32 valToIncWith = 1;
check = pUpdOp->incValue(attr->getName(), valToIncWith);
if( check == -1 ) {
ERR(pTrans->getNdbError());
closeTransaction(pNdb);
return NDBT_FAILED;
}
}
}
// Remaining attributes
for(a = 0; a<tab.getNoOfColumns(); a++){
if ((tab.getColumn(a)->getPrimaryKey() == false) &&
(calc.isUpdateCol(a) == false)){
if(setValueForAttr(pUpdOp, a, r, updates ) != 0){
ERR(pTrans->getNdbError());
closeTransaction(pNdb);
return NDBT_FAILED;
}
}
}
check = pTrans->execute(Commit, AbortOnError);
if( check == -1 ) {
const NdbError err = pTrans->getNdbError();
if (err.status == NdbError::TemporaryError){
ERR(err);
closeTransaction(pNdb);
NdbSleep_MilliSleep(50);
retryAttempt++;
continue;
}
ERR(err);
ndbout << "r = " << r << endl;
closeTransaction(pNdb);
return NDBT_FAILED;
}
else{
updated++;
m_latest_gci = pTrans->getGCI();
}
closeTransaction(pNdb);
r++; // Read next record
}
g_info << "|- " << updated << " records updated" << endl;
return NDBT_OK;
}
示例4: memcpy
void
T3_Callback_2(int result, NdbConnection * pCON, void * threadData){
ThreadData * td = (ThreadData *)threadData;
if (result == -1) {
CHECK_ALLOWED_ERROR("T3-2: execute", td, pCON->getNdbError());
td->pNDB->closeTransaction(pCON);
start_T3(td->pNDB, td, stat_async);
return;
}//if
Uint32 permission = td->transactionData.permission;
Uint32 sessions = td->transactionData.sessions;
Uint32 server_bit = td->transactionData.server_bit;
if(((permission & server_bit) == server_bit) &&
((sessions & server_bit) == server_bit)){
memcpy(td->transactionData.suffix,
&td->transactionData.number[SFX_START],
SUBSCRIBER_NUMBER_SUFFIX_LENGTH);
DEBUG5("T3(%.*s, %.2d): - Callback 2 - reading(%.*s)",
SUBSCRIBER_NUMBER_LENGTH,
td->transactionData.number,
td->transactionData.server_id,
SUBSCRIBER_NUMBER_SUFFIX_LENGTH,
td->transactionData.suffix);
/* Operation 3 */
NdbOperation * MyOp = pCON->getNdbOperation(SESSION_TABLE);
CHECK_NULL(MyOp, "T3-3: getNdbOperation", td,
pCON->getNdbError());
MyOp->simpleRead();
MyOp->equal(IND_SESSION_SUBSCRIBER,
(char*)td->transactionData.number);
MyOp->equal(IND_SESSION_SERVER,
(char*)&td->transactionData.server_id);
MyOp->getValue(IND_SESSION_DATA,
(char *)td->transactionData.session_details);
/* Operation 4 */
MyOp = pCON->getNdbOperation(SERVER_TABLE);
CHECK_NULL(MyOp, "T3-4: getNdbOperation", td,
pCON->getNdbError());
MyOp->interpretedUpdateTuple();
MyOp->equal(IND_SERVER_ID,
(char*)&td->transactionData.server_id);
MyOp->equal(IND_SERVER_SUBSCRIBER_SUFFIX,
(char*)td->transactionData.suffix);
MyOp->incValue(IND_SERVER_READS, (uint32)1);
td->transactionData.branchExecuted = 1;
} else {
DEBUG3("T3(%.*s, %.2d): - Callback 2 - no read",
SUBSCRIBER_NUMBER_LENGTH,
td->transactionData.number,
td->transactionData.server_id);
td->transactionData.branchExecuted = 0;
}
if (stat_async == 1) {
pCON->executeAsynchPrepare( Commit , T3_Callback_3, td);
} else {
int result = pCON->execute( Commit );
T3_Callback_3(result, pCON, (void*)td);
return;
}//if
}
示例5: memcpy
//.........这里部分代码省略.........
ActiveSessions sessions;
Permission permission;
SubscriberSuffix inSuffix;
int check;
NdbRecAttr * check2;
MyTransaction = pNDB->startTransaction();
if (MyTransaction == NULL)
error_handler("T5-1: startTranscation", pNDB->getNdbErrorString(), pNDB->getNdbError());
MyOperation= MyTransaction->getNdbOperation(SUBSCRIBER_TABLE);
CHECK_NULL(MyOperation, "T5-1: getNdbOperation",
MyTransaction);
MyOperation->interpretedUpdateTuple();
MyOperation->equal(IND_SUBSCRIBER_NUMBER,
inNumber);
MyOperation->getValue(IND_SUBSCRIBER_LOCATION,
(char *)&outLocation);
MyOperation->getValue(IND_SUBSCRIBER_CHANGED_BY,
&outChangedBy[0]);
MyOperation->getValue(IND_SUBSCRIBER_CHANGED_TIME,
&outChangedTime[0]);
MyOperation->getValue(IND_SUBSCRIBER_GROUP,
(char *)&groupId);
MyOperation->getValue(IND_SUBSCRIBER_SESSIONS,
(char *)&sessions);
MyOperation->subValue(IND_SUBSCRIBER_SESSIONS,
(uint32)inServerBit);
MyTransaction->execute( NoCommit );
/* Operation 2 */
MyOperation = MyTransaction->getNdbOperation(GROUP_TABLE);
CHECK_NULL(MyOperation, "T5-2: getNdbOperation",
MyTransaction);
MyOperation->readTuple();
MyOperation->equal(IND_GROUP_ID,
(char*)&groupId);
MyOperation->getValue(IND_GROUP_ALLOW_DELETE,
(char *)&permission);
check = MyTransaction->execute( NoCommit );
CHECK_MINUS_ONE(check, "T5-2: NoCommit",
MyTransaction);
if(((permission & inServerBit) == inServerBit) &&
((sessions & inServerBit) == inServerBit)){
memcpy(inSuffix,
&inNumber[SUBSCRIBER_NUMBER_LENGTH-SUBSCRIBER_NUMBER_SUFFIX_LENGTH], SUBSCRIBER_NUMBER_SUFFIX_LENGTH);
DEBUG2("deleting(%.*s) - ", SUBSCRIBER_NUMBER_SUFFIX_LENGTH, inSuffix);
/* Operation 3 */
MyOperation = MyTransaction->getNdbOperation(SESSION_TABLE);
CHECK_NULL(MyOperation, "T5-3: getNdbOperation",
MyTransaction);
MyOperation->deleteTuple();
MyOperation->equal(IND_SESSION_SUBSCRIBER,
(char*)inNumber);
MyOperation->equal(IND_SESSION_SERVER,
(char*)&inServerId);
/* Operation 4 */
/* Operation 5 */
MyOperation = MyTransaction->getNdbOperation(SERVER_TABLE);
CHECK_NULL(MyOperation, "T5-5: getNdbOperation",
MyTransaction);
MyOperation->interpretedUpdateTuple();
MyOperation->equal(IND_SERVER_ID,
(char*)&inServerId);
MyOperation->equal(IND_SERVER_SUBSCRIBER_SUFFIX,
(char*)inSuffix);
MyOperation->incValue(IND_SERVER_DELETES, (uint32)1);
(* outBranchExecuted) = 1;
} else {
(* outBranchExecuted) = 0;
DEBUG1("%s", ((permission & inServerBit) ? "permission - " : "no permission - "));
DEBUG1("%s", ((sessions & inServerBit) ? "in session - " : "no in session - "));
}
if(!inDoRollback && (* outBranchExecuted)){
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);
}
示例6: memcpy
void
T4_Callback_2(int result, NdbConnection * pCON, void * threadData) {
ThreadData * td = (ThreadData *)threadData;
if (result == -1) {
CHECK_ALLOWED_ERROR("T4-2: execute", td, pCON->getNdbError());
td->pNDB->closeTransaction(pCON);
start_T4(td->pNDB, td, stat_async);
return;
}//if
Uint32 permission = td->transactionData.permission;
Uint32 sessions = td->transactionData.sessions;
Uint32 server_bit = td->transactionData.server_bit;
if(((permission & server_bit) == server_bit) &&
((sessions & server_bit) == 0)) {
memcpy(td->transactionData.suffix,
&td->transactionData.number[SFX_START],
SUBSCRIBER_NUMBER_SUFFIX_LENGTH);
DEBUG5("T4(%.*s, %.2d): - Callback 2 - inserting(%.*s)",
SUBSCRIBER_NUMBER_LENGTH,
td->transactionData.number,
td->transactionData.server_id,
SUBSCRIBER_NUMBER_SUFFIX_LENGTH,
td->transactionData.suffix);
/* Operations 3 + 4 */
if (td->ndbRecordSharedData)
{
char* rowPtr= (char*) &td->transactionData;
const NdbRecord* record= td->ndbRecordSharedData->
sessionTableNdbRecord;
Uint32 m=0;
unsigned char* mask= (unsigned char*) &m;
SET_MASK(mask, IND_SESSION_SUBSCRIBER);
SET_MASK(mask, IND_SESSION_SERVER);
SET_MASK(mask, IND_SESSION_DATA);
const NdbOperation* MyOp= pCON->insertTuple(record, rowPtr, mask);
CHECK_NULL((void*)MyOp, "T4-3: insertTuple", td,
pCON->getNdbError());
record= td->ndbRecordSharedData->
serverTableNdbRecord;
m= 0;
NdbOperation::OperationOptions opts;
opts.optionsPresent= NdbOperation::OperationOptions::OO_INTERPRETED;
opts.interpretedCode= td->ndbRecordSharedData->incrServerInsertsProg;
MyOp= pCON->updateTuple(record, rowPtr, record, rowPtr, mask,
&opts, sizeof(opts));
CHECK_NULL((void*)MyOp, "T4-3: updateTuple", td,
pCON->getNdbError());
}
else
{
NdbOperation * MyOp = pCON->getNdbOperation(SESSION_TABLE);
CHECK_NULL(MyOp, "T4-3: getNdbOperation", td,
pCON->getNdbError());
MyOp->insertTuple();
MyOp->equal(IND_SESSION_SUBSCRIBER,
(char*)td->transactionData.number);
MyOp->equal(IND_SESSION_SERVER,
(char*)&td->transactionData.server_id);
MyOp->setValue(IND_SESSION_DATA,
(char *)td->transactionData.session_details);
/* Operation 4 */
/* Operation 5 */
MyOp = pCON->getNdbOperation(SERVER_TABLE);
CHECK_NULL(MyOp, "T4-5: getNdbOperation", td,
pCON->getNdbError());
MyOp->interpretedUpdateTuple();
MyOp->equal(IND_SERVER_ID,
(char*)&td->transactionData.server_id);
MyOp->equal(IND_SERVER_SUBSCRIBER_SUFFIX,
(char*)td->transactionData.suffix);
MyOp->incValue(IND_SERVER_INSERTS, (uint32)1);
}
td->transactionData.branchExecuted = 1;
} else {
td->transactionData.branchExecuted = 0;
DEBUG5("T4(%.*s, %.2d): - Callback 2 - %s %s",
SUBSCRIBER_NUMBER_LENGTH,
td->transactionData.number,
td->transactionData.server_id,
((permission & server_bit) ?
"permission - " : "no permission - "),
((sessions & server_bit) ?
"in session - " : "no in session - "));
}
//.........这里部分代码省略.........
示例7: runTestIncValue32
int runTestIncValue32(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;
}
int check = pOp->interpretedUpdateTuple();
if( check == -1 ) {
ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans);
return NDBT_FAILED;
}
// Primary keys
Uint32 pkVal = 1;
check = pOp->equal("KOL1", pkVal );
if( check == -1 ) {
ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans);
return NDBT_FAILED;
}
// Attributes
// Perform initial read of column start value
NdbRecAttr* initialVal = pOp->getValue("KOL2");
if( initialVal == NULL ) {
ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans);
return NDBT_FAILED;
}
// Update the column
Uint32 valToIncWith = 1;
check = pOp->incValue("KOL2", valToIncWith);
if( check == -1 ) {
ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans);
return NDBT_FAILED;
}
// Perform final read of column after value
NdbRecAttr* afterVal = pOp->getValue("KOL2");
if( afterVal == NULL ) {
ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans);
return NDBT_FAILED;
}
check = pTrans->execute(Commit);
if( check == -1 ) {
ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans);
return NDBT_FAILED;
}
Uint32 oldValue = initialVal->u_32_value();
Uint32 newValue = afterVal->u_32_value();
Uint32 expectedValue = oldValue + valToIncWith;
if (newValue != expectedValue)
{
g_err << "Failed : Expected " << oldValue << "+" <<
valToIncWith << "=" << expectedValue <<
" but received " << newValue << endl;
pNdb->closeTransaction(pTrans);
return NDBT_FAILED;
}
pNdb->closeTransaction(pTrans);
return NDBT_OK;
}
示例8: runTestIncValue32
int runTestIncValue32(NDBT_Context* ctx, NDBT_Step* step){
int result = NDBT_OK;
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;
}
int check = pOp->interpretedUpdateTuple();
if( check == -1 ) {
ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans);
return NDBT_FAILED;
}
// Primary keys
Uint32 pkVal = 1;
check = pOp->equal("KOL1", pkVal );
if( check == -1 ) {
ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans);
return NDBT_FAILED;
}
// Attributes
// Update column
Uint32 valToIncWith = 1;
check = pOp->incValue("KOL2", valToIncWith);
if( check == -1 ) {
ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans);
return NDBT_FAILED;
}
NdbRecAttr* valueRec = pOp->getValue("KOL2");
if( valueRec == NULL ) {
ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans);
return NDBT_FAILED;
}
check = pTrans->execute(Commit);
if( check == -1 ) {
ERR(pTrans->getNdbError());
pNdb->closeTransaction(pTrans);
return NDBT_FAILED;
}
Uint32 value = valueRec->u_32_value();
pNdb->closeTransaction(pTrans);
return NDBT_OK;
}