Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions src/SQLite.Net/SQLiteConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1135,9 +1135,29 @@ public void Commit()
{
if (Interlocked.Exchange(ref _transactionDepth, 0) != 0)
{
Execute("commit");
// Do nothing on a commit with no open transaction

try
{
Execute("commit");
}
catch (Exception)
{
// something went wrong. at least we should clean up
try
{
Execute("rollback");
}
catch
{
// if rollback won't work (e.g. commit was already ok) just silent fail
// i did not see this, but just to be safe
}

// and throw the original exception anyway
throw;
}
}
// Do nothing on a commit with no open transaction
}

/// <summary>
Expand Down