mirror of
https://github.com/isar/rusqlite.git
synced 2025-01-19 22:00:50 +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(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
match self.drop_behavior() {
|
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::Rollback => self.rollback().and_then(|_| self.commit_()),
|
||||||
DropBehavior::Ignore => Ok(()),
|
DropBehavior::Ignore => Ok(()),
|
||||||
DropBehavior::Panic => panic!("Savepoint dropped unexpectedly."),
|
DropBehavior::Panic => panic!("Savepoint dropped unexpectedly."),
|
||||||
@ -686,6 +688,22 @@ mod test {
|
|||||||
Ok(())
|
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]
|
#[test]
|
||||||
fn test_savepoint_names() -> Result<()> {
|
fn test_savepoint_names() -> Result<()> {
|
||||||
let mut db = checked_memory_handle()?;
|
let mut db = checked_memory_handle()?;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user