当前位置: 首页>>代码示例>>C++>>正文


C++ NdbOperation::interpretedUpdateTuple方法代码示例

本文整理汇总了C++中NdbOperation::interpretedUpdateTuple方法的典型用法代码示例。如果您正苦于以下问题:C++ NdbOperation::interpretedUpdateTuple方法的具体用法?C++ NdbOperation::interpretedUpdateTuple怎么用?C++ NdbOperation::interpretedUpdateTuple使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NdbOperation的用法示例。


在下文中一共展示了NdbOperation::interpretedUpdateTuple方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 ); 
}
开发者ID:Cona19,项目名称:mysql5.6.24-improve,代码行数:58,代码来源:ndb_async1.cpp

示例2: DEBUG


//.........这里部分代码省略.........
    if(((permission & inServerBit) == inServerBit) &&
            ((sessions   & inServerBit) == inServerBit)) {

        DEBUG("deleting - ");

        /* 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);
开发者ID:colingpt,项目名称:mysql-5.5.36,代码行数:66,代码来源:ndb_user_transaction2.cpp

示例3: while

int 
HugoTransactions::pkInterpretedUpdateRecords(Ndb* pNdb, 
					     int records,
					     int batch){
  int updated = 0;
  int r = 0;
  int retryAttempt = 0;
  int check, a;

  while (r < records){
    
    if (retryAttempt >= m_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){
	ERR(err);
	NdbSleep_MilliSleep(50);
	retryAttempt++;
	continue;
      }
      ERR(err);
      return NDBT_FAILED;
    }

   NdbOperation* pOp = pTrans->getNdbOperation(tab.getName());	
   if (pOp == NULL) {
     ERR(pTrans->getNdbError());
     closeTransaction(pNdb);
     return NDBT_FAILED;
   }
   
   check = pOp->readTupleExclusive();
   if( check == -1 ) {
     ERR(pTrans->getNdbError());
     closeTransaction(pNdb);
     return NDBT_FAILED;
   }
   
   // Define primary keys
   if (equalForRow(pOp, r) != 0)
   {
     closeTransaction(pNdb);
     return NDBT_FAILED;
   }
   
   // Read update value
   for(a = 0; a<tab.getNoOfColumns(); a++){
     if (calc.isUpdateCol(a) == true){
       if((row.attributeStore(a) = 
	   pOp->getValue(tab.getColumn(a)->getName())) == 0) {
	 ERR(pTrans->getNdbError());
	 closeTransaction(pNdb);
	 return NDBT_FAILED;
       }
     }
   }
   
    check = pTrans->execute(NoCommit, 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);
      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)
    {
//.........这里部分代码省略.........
开发者ID:Abner-Sun,项目名称:mysql5.1-vx-pre1,代码行数:101,代码来源:HugoTransactions.cpp

示例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
}
开发者ID:4T-Shirt,项目名称:mysql,代码行数:68,代码来源:ndb_async2.cpp

示例5: 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 - "));
    }
//.........这里部分代码省略.........
开发者ID:jimodb,项目名称:codes,代码行数:101,代码来源:ndb_async2.cpp

示例6: memcpy

/**
 * Transaction 5 - T5
 * 
 * Delete session
 *
 * Input:
 *   SubscriberNumber
 *   ServerId
 *   ServerBit
 *   DoRollback
 * Output:
 *   ChangedBy
 *   ChangedTime
 *   Location
 *   BranchExecuted
 */
void
userTransaction_T5(UserHandle * uh,
		   SubscriberNumber   inNumber,
		   ServerId           inServerId,
		   ServerBit          inServerBit,
		   DoRollback         inDoRollback,
		   BranchExecuted   * outBranchExecuted){
  Ndb * pNDB = uh->pNDB;

  DEBUG3("T5(%.*s, %.2d): ", SUBSCRIBER_NUMBER_LENGTH, inNumber, inServerId);

  NdbConnection * MyTransaction = 0;
  NdbOperation  * MyOperation = 0;

  char             outChangedBy   [sizeof(ChangedBy)  +(4-(sizeof(ChangedBy)   & 3))];
  char             outChangedTime [sizeof(ChangedTime)+(4-(sizeof(ChangedTime) & 3))];
  Location         outLocation;
  GroupId          groupId;
  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 */
        
//.........这里部分代码省略.........
开发者ID:0x00xw,项目名称:mysql-2,代码行数:101,代码来源:ndb_user_transaction6.cpp

示例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;
}
开发者ID:,项目名称:,代码行数:92,代码来源:

示例8: 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*)&reg_val, sizeof(Uint32));
  memcpy(&(reg_ptr32[1]), ((Uint8*)&reg_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;
  }

//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例9: update_rows

void  update_rows(Ndb* pMyNdb, int tupleType, int opType) {
    /****************************************************************
    *    Update rows in SimpleTable
    *    Only updates the first 3 cols.
    ***************************************************************/

    int check = -1 ;
    int loop_count_ops = nRecords ;
    int readValue[MAXATTR] = {0} ;
    TTYPE ret_val = NO_FAIL ;
    NdbConnection     *MyTransaction = NULL ;
    NdbOperation      *MyOperation = NULL ;

    ndbout << "Updating records ..." << endl << endl;

    for (int count=0 ; count < loop_count_ops ; count++) {

        MyTransaction = pMyNdb->startTransaction();
        if (!MyTransaction) {
            error_handler(pMyNdb->getNdbError(), NO_FAIL);
            return;
        }//if

        MyOperation = MyTransaction->getNdbOperation(tableName);
        if (MyOperation == NULL) {
            error_handler(pMyNdb->getNdbError(), NO_FAIL);
            return;
        }//if

        //   if (operationType == 3)
        check = MyOperation->interpretedUpdateTuple();
        // else if (operationType == 4)
        // check = MyOperation->interpretedDirtyUpdate();
        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);

        switch(tupleType) {
        case 1:
            ret_val = t_exitMethods(count+1, MyOperation,  opType);
            break;
        case 2:
            ret_val = t_incValue(count+1, MyOperation);
            break;
        case 3:
            ret_val = t_subValue(count+1, MyOperation);
            break;
        case 4:
            ret_val = t_readAttr(count+1, MyOperation);
            break;
        case 5:
            ret_val = t_writeAttr(count+1, MyOperation);
            break;
        case 6:
            ret_val = t_loadConst(count+1, MyOperation,  opType);
            break;
        case 7:
            ret_val = t_branch(count+1, MyOperation);
            break;
        case 8:
            ret_val = t_branchIfNull(count+1, MyOperation);
            break;
        case 9:
            ret_val = t_addReg(count+1, MyOperation);
            break;
        case 10:
            ret_val = t_subReg(count+1, MyOperation);
            break;
        case 11:
            ret_val = t_subroutineWithBranchLabel(count+1, MyOperation);
            break;
        default:
            break ;
        }

        MyOperation->getValue("COL1", (char*)&readValue);

        if (MyTransaction->execute( Commit ) == -1 ) {
            error_handler(MyTransaction->getNdbError(), ret_val);
        } else if (NO_FAIL == ret_val ) {
            ndbout << "OK" << endl;
        } else {
            bTestPassed = -1;
            ndbout << "Test passed when expected to fail" << endl;
        }//if
        pMyNdb->closeTransaction(MyTransaction);

    }

    ndbout << "Finished updating records" << endl;
    return;
};
开发者ID:colingpt,项目名称:mysql-5.5.36,代码行数:95,代码来源:interpreterInTup.cpp

示例10: 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;
}
开发者ID:Abner-Sun,项目名称:mysql5.1-vx-pre1,代码行数:73,代码来源:testInterpreter.cpp


注:本文中的NdbOperation::interpretedUpdateTuple方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。