Bug 462434 - Transaction semantics are bad

This propagates errors in starting and ending transactions.
r=asuth
This commit is contained in:
Shawn Wilsher 2008-10-30 18:46:25 -04:00
Родитель 0c6223cfa4
Коммит d407c1afce
1 изменённых файлов: 7 добавлений и 6 удалений

Просмотреть файл

@ -530,7 +530,7 @@ mozStorageConnection::BeginTransactionAs(PRInt32 aTransactionType)
}
if (NS_SUCCEEDED(rv))
mTransactionInProgress = PR_TRUE;
return NS_OK;
return rv;
}
NS_IMETHODIMP
@ -539,9 +539,9 @@ 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;
}
@ -551,8 +551,9 @@ 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;
}