Remove copy_db method from connection

This commit is contained in:
PThorpe92
2025-08-14 13:18:55 -04:00
parent cc2fed3297
commit 7c021c01f8

View File

@@ -1913,48 +1913,6 @@ impl Connection {
self.query_only.set(value);
}
#[cfg(feature = "fs")]
/// Copy the current Database and write out to a new file.
/// TODO: sqlite3 instead essentially does the equivalent of
/// `.dump` and creates a new .db file from that.
///
/// Because we are instead making a copy of the File, as a side-effect we are
/// also having to checkpoint the database.
pub fn copy_db(&self, file: &str) -> Result<()> {
if !self.is_db_initialized() {
return Err(LimboError::Page1NotAlloc);
}
let pager = self.pager.borrow();
if let Some(wal) = pager.wal.as_ref() {
let checkpoint_result = self
._db
.io
.block(|| wal.borrow_mut().checkpoint(&pager, CheckpointMode::Full))?;
if checkpoint_result.everything_backfilled() {
let c = Completion::new_sync(|_| {});
let c = pager.db_file.sync(c)?;
// sync the db file to ensure checkpointed frames were flushed.
self._db.io.wait_for_completion(c)?;
// CheckpointResult here still holds the checkpoint/writer lock until it goes out of scope,
// so it's safe to copy from file.
let src_io = self._db.io.clone();
// use a new PlatformIO instance as the dest_io when copying the file to account that src could be memory
let dest_io: Arc<dyn IO> = Arc::new(PlatformIO::new()?);
pager.db_file.copy_to(&*src_io, &*dest_io, file)?;
return Ok(());
} else {
// unable to backfill all frames to the db file, so we cannot support copying file
return Err(LimboError::Busy);
}
}
Err(LimboError::InternalError(
"not yet supported for DB's without WAL".into(),
))
}
/// Creates a HashSet of modules that have been loaded
pub fn get_syms_vtab_mods(&self) -> std::collections::HashSet<String> {
self.syms.borrow().vtab_modules.keys().cloned().collect()