~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/transaction_services.cc

  • Committer: lbieber
  • Date: 2010-09-18 02:42:50 UTC
  • mfrom: (1774.1.1 build)
  • Revision ID: lbieber@orisndriz08-20100918024250-all17fhukrpaigqo
Merge Joe - Rework the rollback to savepoint code in terms of the transaction log

Show diffs side-by-side

added added

removed removed

Lines of Context:
822
822
  if (shouldConstructMessages())
823
823
  {
824
824
    cleanupTransactionMessage(getActiveTransactionMessage(session), session);
825
 
    message::Transaction *savepoint_transaction= sv.getTransactionSavepoint();
826
 
 
827
 
    google::protobuf::RepeatedPtrField< message::Statement> *statements= 
828
 
      savepoint_transaction->mutable_statement();
829
 
 
830
 
    /* A iterator is used here rather then the other GPB functions as there needs
831
 
       to be a check for the case where there are no statements (a NULL value) */
832
 
    if (statements != NULL)
 
825
    message::Transaction *savepoint_transaction= sv.getTransactionMessage();
 
826
    if (savepoint_transaction != NULL)
833
827
    {
834
 
      google::protobuf::RepeatedPtrField< message::Statement>::iterator it= 
835
 
        statements->begin();
836
 
      google::protobuf::RepeatedPtrField< message::Statement>::iterator end_it= 
837
 
        statements->end();
838
 
 
839
 
      message::Statement *new_statement= NULL;
840
 
      
841
 
      for (; it != end_it; ++it)
 
828
      /* Make a copy of the savepoint transaction, this is necessary to assure proper cleanup. 
 
829
         Upon commit the savepoint_transaction_copy will be cleaned up by a call to 
 
830
         cleanupTransactionMessage(). The Transaction message in NamedSavepoint will be cleaned
 
831
         up when the savepoint is cleaned up. This avoids calling delete twice on the Transaction.
 
832
      */ 
 
833
      message::Transaction *savepoint_transaction_copy= new message::Transaction(*sv.getTransactionMessage());
 
834
      uint32_t num_statements = savepoint_transaction_copy->statement_size();
 
835
      if (num_statements == 0)
 
836
      {    
 
837
        session->setStatementMessage(NULL);
 
838
      }    
 
839
      else 
842
840
      {
843
 
        new_statement= &*it;
844
 
      }
845
 
 
846
 
      session->setTransactionMessage(savepoint_transaction);
847
 
      session->setStatementMessage(new_statement);
 
841
        session->setStatementMessage(savepoint_transaction_copy->mutable_statement(num_statements - 1));    
 
842
      }    
 
843
      session->setTransactionMessage(savepoint_transaction_copy);
848
844
    }
849
845
  }
 
846
 
850
847
  return error;
851
848
}
852
849
 
900
897
    {
901
898
      message::Transaction *transaction_savepoint= 
902
899
        new message::Transaction(*transaction);
903
 
      sv.setTransactionSavepoint(transaction_savepoint);
 
900
      sv.setTransactionMessage(transaction_savepoint);
904
901
    }
905
902
  } 
906
903
 
932
929
    }
933
930
  }
934
931
  
935
 
  if (shouldConstructMessages())
936
 
  {
937
 
    delete sv.getTransactionSavepoint();
938
 
    sv.setTransactionSavepoint(NULL);
939
 
  }
940
 
 
941
932
  return error;
942
933
}
943
934