mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Fix savepoint rollback code
This commit is contained in:
parent
86cff3e357
commit
ed34b07500
@ -209,6 +209,22 @@ IDBTransactionRequest::ReleaseSavepoint()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
IDBTransactionRequest::RollbackSavepoint()
|
||||
{
|
||||
NS_PRECONDITION(!NS_IsMainThread(), "Wrong thread!");
|
||||
NS_PRECONDITION(mConnection, "No connection!");
|
||||
|
||||
NS_ASSERTION(mSavepointCount == 1, "Mismatch!");
|
||||
mSavepointCount = 0;
|
||||
|
||||
// TODO try to cache this statement
|
||||
NS_NAMED_LITERAL_CSTRING(savepoint, "ROLLBACK TO " SAVEPOINT_INTERMEDIATE);
|
||||
if (NS_FAILED(mConnection->ExecuteSimpleSQL(savepoint))) {
|
||||
NS_ERROR("Rollback failed!");
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
IDBTransactionRequest::GetOrCreateConnection(mozIStorageConnection** aResult)
|
||||
{
|
||||
|
@ -88,6 +88,7 @@ public:
|
||||
|
||||
bool StartSavepoint();
|
||||
nsresult ReleaseSavepoint();
|
||||
void RollbackSavepoint();
|
||||
|
||||
already_AddRefed<mozIStorageStatement> AddStatement(bool aCreate,
|
||||
bool aOverwrite,
|
||||
|
@ -53,13 +53,17 @@ public:
|
||||
: mTransaction(aTransaction)
|
||||
, mHasSavepoint(false)
|
||||
{
|
||||
NS_ASSERTION(mTransaction, "Null pointer!");
|
||||
|
||||
mHasSavepoint = mTransaction->StartSavepoint();
|
||||
NS_WARN_IF_FALSE(mHasSavepoint, "Failed to make savepoint!");
|
||||
}
|
||||
|
||||
~Savepoint()
|
||||
{
|
||||
Release();
|
||||
if (mHasSavepoint) {
|
||||
mTransaction->RollbackSavepoint();
|
||||
}
|
||||
}
|
||||
|
||||
nsresult Release()
|
||||
|
Loading…
Reference in New Issue
Block a user