コード例 #1
0
ファイル: ndb_async2.cpp プロジェクト: 4T-Shirt/mysql
void
T5_Callback_2(int result, NdbConnection * pCON, void * threadData){
  ThreadData * td = (ThreadData *)threadData;  
  if (result == -1) {
    CHECK_ALLOWED_ERROR("T5-2: execute", td, pCON->getNdbError());
    td->pNDB->closeTransaction(pCON);
    start_T5(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("T5(%.*s, %.2d): - Callback 2 - deleting(%.*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, "T5-3: getNdbOperation", td,
	       pCON->getNdbError());
    
    MyOp->deleteTuple();
    MyOp->equal(IND_SESSION_SUBSCRIBER,
		(char*)td->transactionData.number);
    MyOp->equal(IND_SESSION_SERVER,
		(char*)&td->transactionData.server_id);
    /* Operation 4 */
    
    /* Operation 5 */
    MyOp = pCON->getNdbOperation(SERVER_TABLE);
    CHECK_NULL(MyOp, "T5-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_DELETES, (uint32)1);
    td->transactionData.branchExecuted = 1;
  } else {
    td->transactionData.branchExecuted = 0;

    DEBUG5("T5(%.*s, %.2d): - Callback 2 - no delete - %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 - "));
  }
  
  if(!td->transactionData.do_rollback && td->transactionData.branchExecuted){
    if (stat_async == 1) {
      pCON->executeAsynchPrepare( Commit , T5_Callback_3, td);
    } else {
      int result = pCON->execute( Commit );
      T5_Callback_3(result, pCON, (void*)td);
      return;
    }//if
  } else {
    if (stat_async == 1) {
      pCON->executeAsynchPrepare( Rollback , T5_Callback_3, td);
    } else {
      int result = pCON->execute( Rollback );
      T5_Callback_3(result, pCON, (void*)td);
      return;
    }//if
  }
}
コード例 #2
0
ファイル: ndb_async2.cpp プロジェクト: jimodb/codes
void
T5_Callback_2(int result, NdbConnection * pCON, void * threadData) {
    ThreadData * td = (ThreadData *)threadData;
    if (result == -1) {
        CHECK_ALLOWED_ERROR("T5-2: execute", td, pCON->getNdbError());
        td->pNDB->closeTransaction(pCON);
        start_T5(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("T5(%.*s, %.2d): - Callback 2 - deleting(%.*s)",
               SUBSCRIBER_NUMBER_LENGTH,
               td->transactionData.number,
               td->transactionData.server_id,
               SUBSCRIBER_NUMBER_SUFFIX_LENGTH,
               td->transactionData.suffix);

        if (td->ndbRecordSharedData)
        {
            char* rowPtr= (char*) &td->transactionData;
            const NdbRecord* record= td->ndbRecordSharedData->
                                     sessionTableNdbRecord;
            Uint32 m=0;
            unsigned char* mask= (unsigned char*) &m;

            const NdbOperation* MyOp= pCON->deleteTuple(record, rowPtr, record);
            CHECK_NULL((void*) MyOp, "T5-3: deleteTuple", td,
                       pCON->getNdbError());

            record= td->ndbRecordSharedData->
                    serverTableNdbRecord;
            m= 0;

            NdbOperation::OperationOptions opts;
            opts.optionsPresent= NdbOperation::OperationOptions::OO_INTERPRETED;
            opts.interpretedCode= td->ndbRecordSharedData->incrServerDeletesProg;

            MyOp= pCON->updateTuple(record, rowPtr, record, rowPtr, mask,
                                    &opts, sizeof(opts));

            CHECK_NULL((void*)MyOp, "T5-2: updateTuple", td,
                       pCON->getNdbError());
        }
        else
        {
            /* Operation 3 */
            NdbOperation * MyOp = pCON->getNdbOperation(SESSION_TABLE);
            CHECK_NULL(MyOp, "T5-3: getNdbOperation", td,
                       pCON->getNdbError());

            MyOp->deleteTuple();
            MyOp->equal(IND_SESSION_SUBSCRIBER,
                        (char*)td->transactionData.number);
            MyOp->equal(IND_SESSION_SERVER,
                        (char*)&td->transactionData.server_id);
            /* Operation 4 */

            /* Operation 5 */
            MyOp = pCON->getNdbOperation(SERVER_TABLE);
            CHECK_NULL(MyOp, "T5-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_DELETES, (uint32)1);
        }
        td->transactionData.branchExecuted = 1;
    } else {
        td->transactionData.branchExecuted = 0;

        DEBUG5("T5(%.*s, %.2d): - Callback 2 - no delete - %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 - "));
    }

    if(!td->transactionData.do_rollback && td->transactionData.branchExecuted) {
        if (stat_async == 1) {
            pCON->executeAsynchPrepare( Commit , T5_Callback_3, td);
        } else {
            int result = pCON->execute( Commit );
            T5_Callback_3(result, pCON, (void*)td);
            return;
        }//if
    } else {
        if (stat_async == 1) {
            pCON->executeAsynchPrepare( Rollback , T5_Callback_3, td);
        } else {
            int result = pCON->execute( Rollback );
            T5_Callback_3(result, pCON, (void*)td);
            return;
        }//if
    }
}