diff --git a/core/lib.rs b/core/lib.rs index 2c1161b51..e106a314d 100644 --- a/core/lib.rs +++ b/core/lib.rs @@ -40,6 +40,7 @@ pub mod numeric; #[cfg(not(feature = "fuzz"))] mod numeric; +use crate::incremental::view::ViewTransactionState; use crate::translate::optimizer::optimize_plan; use crate::translate::pragma::TURSO_CDC_DEFAULT_TABLE_NAME; #[cfg(all(feature = "fs", feature = "conn_raw_api"))] @@ -47,7 +48,6 @@ use crate::types::WalFrameInfo; #[cfg(feature = "fs")] use crate::util::{OpenMode, OpenOptions}; use crate::vtab::VirtualTable; -use crate::{incremental::view::ViewTransactionState, schema::Table}; use core::str; pub use error::LimboError; use fallible_iterator::FallibleIterator; @@ -1840,33 +1840,6 @@ 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 { - 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 { - let schema = self._db.schema.lock().unwrap(); - - schema - .tables - .values() - .filter_map(|table| { - if let Table::Virtual(vtab) = table.as_ref() { - vtab.module_name().map(|name| name.to_string()) - } else { - None - } - }) - .collect() - } - pub fn get_query_only(&self) -> bool { self.query_only.get() } @@ -1893,7 +1866,7 @@ impl Connection { self.pager.borrow_mut().db_file.copy_to(&*io, file) } - /// Creates a HashSet of modules that have been loaded, but not necessarily used + /// Creates a HashSet of modules that have been loaded pub fn get_syms_vtab_mods(&self) -> std::collections::HashSet { self.syms .try_borrow() diff --git a/core/translate/pragma.rs b/core/translate/pragma.rs index d012e0b49..5b1550faf 100644 --- a/core/translate/pragma.rs +++ b/core/translate/pragma.rs @@ -401,7 +401,7 @@ fn query_pragma( Ok((program, TransactionMode::None)) } PragmaName::ModuleList => { - let modules = connection.get_vtab_mods(); + let modules = connection.get_syms_vtab_mods(); for module in modules { program.emit_string8(module.to_string(), register); program.emit_result_row(register, 1); diff --git a/core/vtab.rs b/core/vtab.rs index 797fa6f8a..686158e57 100644 --- a/core/vtab.rs +++ b/core/vtab.rs @@ -22,15 +22,10 @@ pub struct VirtualTable { pub(crate) name: String, pub(crate) columns: Vec, pub(crate) kind: VTabKind, - pub(crate) module_name: Option, vtab_type: VirtualTableType, } impl VirtualTable { - pub fn module_name(&self) -> Option<&str> { - self.module_name.as_deref() - } - pub(crate) fn readonly(self: &Arc) -> bool { match &self.vtab_type { VirtualTableType::Pragma(_) => true, @@ -48,7 +43,6 @@ impl VirtualTable { columns: Self::resolve_columns(schema) .expect("built-in function schema resolution should not fail"), kind: VTabKind::TableValuedFunction, - module_name: Some("pragma".to_string()), vtab_type: VirtualTableType::Pragma(tab), }; Arc::new(vtab) @@ -71,7 +65,6 @@ impl VirtualTable { name: name.to_owned(), columns: Self::resolve_columns(schema)?, kind: VTabKind::TableValuedFunction, - module_name: Some(name.to_string()), vtab_type, }; Ok(Arc::new(vtab)) @@ -90,7 +83,6 @@ impl VirtualTable { name: tbl_name.unwrap_or(module_name).to_owned(), columns: Self::resolve_columns(schema)?, kind: VTabKind::VirtualTable, - module_name: Some(module_name.to_string()), vtab_type: VirtualTableType::External(table), }; Ok(Arc::new(vtab)) @@ -105,7 +97,6 @@ impl VirtualTable { let vtab = VirtualTable { name: view_name.to_owned(), columns, - module_name: Some(view_name.to_string()), kind: VTabKind::VirtualTable, vtab_type: VirtualTableType::View(crate::vtab_view::ViewVirtualTable { view }), };