Beispiel #1
0
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
}
Beispiel #2
0
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);
    }

    const NdbOperation* op= NULL;

    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_NUMBER);
        SET_MASK(mask, IND_SUBSCRIBER_LOCATION);
        SET_MASK(mask, IND_SUBSCRIBER_CHANGED_BY);
        SET_MASK(mask, IND_SUBSCRIBER_CHANGED_TIME);

        op= pCON->updateTuple(record,
                              rowPtr,
                              record,
                              rowPtr,
                              mask);
    }
    else
    {
        NdbOperation *MyOp = pCON->getNdbOperation(SUBSCRIBER_TABLE);
        op= MyOp;
        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 (op != NULL)
    {
        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(NULL, "T1: getNdbOperation", td, pCON->getNdbError());
    }//if
}