Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When an exception is thrown during commit() it will execute a rollback cmd on the database #237

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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