diff options
author | Alex Auvolat <alex@adnab.me> | 2022-06-08 17:49:36 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2022-06-08 17:49:36 +0200 |
commit | ab374e71787b1da37e1f885e88090bbcbd53ec47 (patch) | |
tree | 7863a488fdb9acf9d198fb992b34b67ca42f5f26 /src/db/sqlite_adapter.rs | |
parent | f8a6fff2b7bb754fa315e1c00b0f6adea4586fa8 (diff) | |
download | garage-ab374e71787b1da37e1f885e88090bbcbd53ec47.tar.gz garage-ab374e71787b1da37e1f885e88090bbcbd53ec47.zip |
Add .clear() on db trees
Diffstat (limited to 'src/db/sqlite_adapter.rs')
-rw-r--r-- | src/db/sqlite_adapter.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/db/sqlite_adapter.rs b/src/db/sqlite_adapter.rs index 14bf35ff..68d96ca0 100644 --- a/src/db/sqlite_adapter.rs +++ b/src/db/sqlite_adapter.rs @@ -182,6 +182,16 @@ impl IDb for SqliteDb { Ok(old_val) } + fn clear(&self, tree: usize) -> Result<()> { + trace!("clear {}: lock db", tree); + let this = self.0.lock().unwrap(); + trace!("clear {}: lock acquired", tree); + + let tree = this.get_tree(tree)?; + this.db.execute(&format!("DELETE FROM {}", tree), [])?; + Ok(()) + } + fn iter(&self, tree: usize) -> Result<ValueIter<'_>> { trace!("iter {}: lock db", tree); let this = self.0.lock().unwrap(); |