mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-04 15:54:23 +01:00
feat: removed module_name from VirtualTable, instead looking only at symbol tables
This commit is contained in:
31
core/lib.rs
31
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<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();
|
||||
|
||||
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<String> {
|
||||
self.syms
|
||||
.try_borrow()
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -22,15 +22,10 @@ pub struct VirtualTable {
|
||||
pub(crate) name: String,
|
||||
pub(crate) columns: Vec<Column>,
|
||||
pub(crate) kind: VTabKind,
|
||||
pub(crate) module_name: Option<String>,
|
||||
vtab_type: VirtualTableType,
|
||||
}
|
||||
|
||||
impl VirtualTable {
|
||||
pub fn module_name(&self) -> Option<&str> {
|
||||
self.module_name.as_deref()
|
||||
}
|
||||
|
||||
pub(crate) fn readonly(self: &Arc<VirtualTable>) -> 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 }),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user