mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-18 14:35:14 +01:00
feat: listing both used and non-used modules
This commit is contained in:
20
core/lib.rs
20
core/lib.rs
@@ -1840,6 +1840,17 @@ impl Connection {
|
||||
self.pager.borrow().clone()
|
||||
}
|
||||
|
||||
/// Union of the virtual tables that have been loaded and not used
|
||||
/// and the vitual tables that have been loaded and used
|
||||
pub fn get_vtab_mods(&self) -> std::collections::HashSet<String> {
|
||||
let syms_mods = self.get_syms_vtab_mods();
|
||||
let used_mods = self.get_used_vtab_mods();
|
||||
|
||||
used_mods.union(&syms_mods).cloned().collect()
|
||||
}
|
||||
|
||||
/// Creates a HashSet of modules that have been used, modules that have been
|
||||
/// loaded but not used by any virtual table will NOT be listed here
|
||||
pub fn get_used_vtab_mods(&self) -> std::collections::HashSet<String> {
|
||||
let schema = self._db.schema.lock().unwrap();
|
||||
|
||||
@@ -1880,6 +1891,15 @@ impl Connection {
|
||||
.borrow_mut()
|
||||
.wal_checkpoint(disabled, CheckpointMode::Truncate)?;
|
||||
self.pager.borrow_mut().db_file.copy_to(&*io, file)
|
||||
/// Creates a HashSet of modules that have been loaded, but not necessarily used
|
||||
pub fn get_syms_vtab_mods(&self) -> std::collections::HashSet<String> {
|
||||
self.syms
|
||||
.try_borrow()
|
||||
.unwrap()
|
||||
.vtab_modules
|
||||
.keys()
|
||||
.cloned()
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -401,8 +401,7 @@ fn query_pragma(
|
||||
Ok((program, TransactionMode::None))
|
||||
}
|
||||
PragmaName::ModuleList => {
|
||||
let modules = connection.get_used_vtab_mods();
|
||||
|
||||
let modules = connection.get_vtab_mods();
|
||||
for module in modules {
|
||||
program.emit_string8(module.to_string(), register);
|
||||
program.emit_result_row(register, 1);
|
||||
|
||||
Reference in New Issue
Block a user