Bug 462434 - Transaction semantics are bad
authorShawn Wilsher <sdwilsh@shawnwilsher.com>
Thu, 30 Oct 2008 18:46:25 -0400
changeset 21127 f7e6ad1f2be31715c94f3795f9b51e71e1093c4b
parent 21126 9df2c8634ffad31f7b84c61c82d9f0032fb5d8cb
child 21128 fd8dd4d3ff480e8d9339e31837e4662ef13b5af3
push id3336
push usersdwilsh@shawnwilsher.com
push dateThu, 30 Oct 2008 22:46:46 +0000
treeherdermozilla-central@f7e6ad1f2be3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs462434
milestone1.9.1b2pre
Bug 462434 - Transaction semantics are bad This propagates errors in starting and ending transactions. r=asuth
storage/src/mozStorageConnection.cpp
--- a/storage/src/mozStorageConnection.cpp
+++ b/storage/src/mozStorageConnection.cpp
@@ -525,39 +525,40 @@ mozStorageConnection::BeginTransactionAs
         case TRANSACTION_EXCLUSIVE:
             rv = ExecuteSimpleSQL(NS_LITERAL_CSTRING("BEGIN EXCLUSIVE"));
             break;
         default:
             return NS_ERROR_ILLEGAL_VALUE;
     }
     if (NS_SUCCEEDED(rv))
         mTransactionInProgress = PR_TRUE;
-    return NS_OK;
+    return rv;
 }
 
 NS_IMETHODIMP
 mozStorageConnection::CommitTransaction()
 {
     nsAutoLock mutex(mTransactionMutex);
     if (!mTransactionInProgress)
         return NS_ERROR_FAILURE;
-    nsresult rv = ExecuteSimpleSQL (NS_LITERAL_CSTRING("COMMIT TRANSACTION"));
-    // even if the commit fails, the transaction is aborted
-    mTransactionInProgress = PR_FALSE;
+    nsresult rv = ExecuteSimpleSQL(NS_LITERAL_CSTRING("COMMIT TRANSACTION"));
+    if (NS_SUCCEEDED(rv))
+        mTransactionInProgress = PR_FALSE;
     return rv;
 }
 
 NS_IMETHODIMP
 mozStorageConnection::RollbackTransaction()
 {
     nsAutoLock mutex(mTransactionMutex);
     if (!mTransactionInProgress)
         return NS_ERROR_FAILURE;
-    nsresult rv = ExecuteSimpleSQL (NS_LITERAL_CSTRING("ROLLBACK TRANSACTION"));
-    mTransactionInProgress = PR_FALSE;
+    nsresult rv = ExecuteSimpleSQL(NS_LITERAL_CSTRING("ROLLBACK TRANSACTION"));
+    if (NS_SUCCEEDED(rv))
+        mTransactionInProgress = PR_FALSE;
     return rv;
 }
 
 /**
  ** Table creation
  **/
 
 NS_IMETHODIMP