mirror of
https://github.com/isar/rusqlite.git
synced 2025-01-19 16:20:51 +08:00
Merge pull request #1347 from gwenn/savepoint_drop_bug
Savepoint Drop bug
This commit is contained in:
commit
8173695d1f
@ -344,7 +344,9 @@ impl Savepoint<'_> {
|
||||
return Ok(());
|
||||
}
|
||||
match self.drop_behavior() {
|
||||
DropBehavior::Commit => self.commit_().or_else(|_| self.rollback()),
|
||||
DropBehavior::Commit => self
|
||||
.commit_()
|
||||
.or_else(|_| self.rollback().and_then(|_| self.commit_())),
|
||||
DropBehavior::Rollback => self.rollback().and_then(|_| self.commit_()),
|
||||
DropBehavior::Ignore => Ok(()),
|
||||
DropBehavior::Panic => panic!("Savepoint dropped unexpectedly."),
|
||||
@ -686,6 +688,22 @@ mod test {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_savepoint_release_error() -> Result<()> {
|
||||
let mut db = checked_memory_handle()?;
|
||||
|
||||
db.pragma_update(None, "foreign_keys", true)?;
|
||||
db.execute_batch("CREATE TABLE r(n INTEGER PRIMARY KEY NOT NULL); CREATE TABLE f(n REFERENCES r(n) DEFERRABLE INITIALLY DEFERRED);")?;
|
||||
{
|
||||
let mut sp = db.savepoint()?;
|
||||
sp.execute("INSERT INTO f VALUES (0)", [])?;
|
||||
sp.set_drop_behavior(DropBehavior::Commit);
|
||||
}
|
||||
assert!(db.is_autocommit());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_savepoint_names() -> Result<()> {
|
||||
let mut db = checked_memory_handle()?;
|
||||
|
Loading…
x
Reference in New Issue
Block a user