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


C++ NdbConnection::execute方法代码示例

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


在下文中一共展示了NdbConnection::execute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

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

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

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

示例4: print_part_info

static 
void print_part_info(Ndb* pNdb, NDBT_Table* pTab)
{
  InfoInfo g_part_info[] = {
    { "Partition", 0, NdbDictionary::Column::FRAGMENT },
    { "Row count", 0, NdbDictionary::Column::ROW_COUNT },
    { "Commit count", 0, NdbDictionary::Column::COMMIT_COUNT },
    { "Frag fixed memory", 0, NdbDictionary::Column::FRAGMENT_FIXED_MEMORY },
    { "Frag varsized memory", 0, NdbDictionary::Column::FRAGMENT_VARSIZED_MEMORY },
    { 0, 0, 0 }
  };

  ndbout << "-- Per partition info -- " << endl;
  
  NdbConnection* pTrans = pNdb->startTransaction();
  if (pTrans == 0)
    return;
  
  do
  {
    NdbScanOperation* pOp= pTrans->getNdbScanOperation(pTab->getName());
    if (pOp == NULL)
      break;
    
    int rs = pOp->readTuples(NdbOperation::LM_CommittedRead); 
    if (rs != 0)
      break;
    
    if (pOp->interpret_exit_last_row() != 0)
      break;
    
    Uint32 i = 0;
    for(i = 0; g_part_info[i].m_title != 0; i++)
    {
      if ((g_part_info[i].m_rec_attr = pOp->getValue(g_part_info[i].m_column)) == 0)
	break;
    }

    if (g_part_info[i].m_title != 0)
      break;

    if (pTrans->execute(NoCommit) != 0)
      break;
	
    for (i = 0; g_part_info[i].m_title != 0; i++)
      ndbout << g_part_info[i].m_title << "\t";
    ndbout << endl;
    
    while(pOp->nextResult() == 0)
    {
      for(i = 0; g_part_info[i].m_title != 0; i++)
      {
	ndbout << *g_part_info[i].m_rec_attr << "\t";
      }
      ndbout << endl;
    }
  } while(0);
  
  pTrans->close();
}
开发者ID:A-eolus,项目名称:mysql,代码行数:60,代码来源:desc.cpp

示例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;
}
开发者ID:A-eolus,项目名称:mysql,代码行数:72,代码来源:ndb_user_transaction4.cpp

示例6: 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
}
开发者ID:jimodb,项目名称:codes,代码行数:73,代码来源:ndb_async2.cpp

示例7: 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;

};
开发者ID:colingpt,项目名称:mysql-5.5.36,代码行数:55,代码来源:interpreterInTup.cpp

示例8: 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;
}
开发者ID:colingpt,项目名称:mysql-5.5.36,代码行数:52,代码来源:acid.cpp

示例9:

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;
}
开发者ID:Cona19,项目名称:mysql5.6.24-improve,代码行数:49,代码来源:ndb_user_populate.cpp

示例10: 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;
}
开发者ID:colingpt,项目名称:mysql-5.5.36,代码行数:48,代码来源:interpreterInTup.cpp

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

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

示例13:

/**
 * 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
}
开发者ID:0x00xw,项目名称:mysql-2,代码行数:54,代码来源:ndb_user_transaction6.cpp

示例14: 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;
};
开发者ID:colingpt,项目名称:mysql-5.5.36,代码行数:37,代码来源:interpreterInTup.cpp

示例15: utilTrans

inline
int 
ScanInterpretTest::scanReadVerify(Ndb* pNdb,
				  int records,
				  int parallelism,
				  ScanFilter& filter){
  int                  retryAttempt = 0;
  const int            retryMax = 100;
  int                  check;
  NdbConnection	       *pTrans;
  NdbScanOperation	       *pOp;
  
  while (true){
    
    if (retryAttempt >= retryMax){
      ndbout << "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;
    }
    
    
    pOp = pTrans->getNdbScanOperation(tab.getName());	
    if (pOp == NULL) {  if (pOp->getValue("KOL2") == 0){
    ERR(pNdb->getNdbError());
    return NDBT_FAILED;
  }
  

      ERR(pTrans->getNdbError());
      pNdb->closeTransaction(pTrans);
      return NDBT_FAILED;
    }
   
    if( pOp->readTuples(NdbScanOperation::LM_Read, 0, parallelism) ) {
      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;
    }

    
    // Read all attributes  
    for(int a = 0; a<tab.getNoOfColumns(); a++){
      if((row.attributeStore(a) = 
	  pOp->getValue(tab.getColumn(a)->getName())) == 0) {
	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 eof;
    int rows = 0;
    int rowsNoExist = 0;
    int rowsExist = 0;    
    int existingRecordsNotFound = 0;
    int nonExistingRecordsFound = 0;


    NdbConnection* pExistTrans;
    NdbConnection* pNoExistTrans;
    
    while((eof = pOp->nextResult(true)) == 0){
      pExistTrans = pNdb->startTransaction();
      if (pExistTrans == NULL) {
	const NdbError err = pNdb->getNdbError();
	ERR(err);
	return NDBT_FAILED;
      }
      pNoExistTrans = pNdb->startTransaction();
      if (pNoExistTrans == NULL) {
	const NdbError err = pNdb->getNdbError();
	ERR(err);
	return NDBT_FAILED;
      }
//.........这里部分代码省略.........
开发者ID:4T-Shirt,项目名称:mysql,代码行数:101,代码来源:ScanInterpretTest.hpp


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