Mark self.committed only after command succeeds

Fixes #366
This commit is contained in:
Kornel 2018-07-27 17:13:11 +01:00
parent a7479488b8
commit 1e29cf4a0f

View File

@ -167,8 +167,9 @@ impl<'conn> Transaction<'conn> {
} }
fn commit_(&mut self) -> Result<()> { fn commit_(&mut self) -> Result<()> {
self.conn.execute_batch("COMMIT")?;
self.committed = true; self.committed = true;
self.conn.execute_batch("COMMIT") Ok(())
} }
/// A convenience method which consumes and rolls back a transaction. /// A convenience method which consumes and rolls back a transaction.
@ -177,8 +178,9 @@ impl<'conn> Transaction<'conn> {
} }
fn rollback_(&mut self) -> Result<()> { fn rollback_(&mut self) -> Result<()> {
self.conn.execute_batch("ROLLBACK")?;
self.committed = true; self.committed = true;
self.conn.execute_batch("ROLLBACK") Ok(())
} }
/// Consumes the transaction, committing or rolling back according to the current setting /// Consumes the transaction, committing or rolling back according to the current setting
@ -277,9 +279,10 @@ impl<'conn> Savepoint<'conn> {
} }
fn commit_(&mut self) -> Result<()> { fn commit_(&mut self) -> Result<()> {
self.committed = true;
self.conn self.conn
.execute_batch(&format!("RELEASE {}", self.name)) .execute_batch(&format!("RELEASE {}", self.name))?;
self.committed = true;
Ok(())
} }
/// A convenience method which rolls back a savepoint. /// A convenience method which rolls back a savepoint.