From 06d869ea5eea8bd8bc5c010278b568dbeff52fa3 Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Wed, 17 Sep 2025 10:24:10 +0300 Subject: [PATCH] core/ext: Switch vtab_modules from Rc to Arc --- core/ext/mod.rs | 5 ++--- core/lib.rs | 2 +- core/translate/schema.rs | 3 +-- core/vtab.rs | 9 ++++----- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/core/ext/mod.rs b/core/ext/mod.rs index dde4bcea7..ca8f19892 100644 --- a/core/ext/mod.rs +++ b/core/ext/mod.rs @@ -12,7 +12,6 @@ use crate::{LimboError, IO}; pub use dynamic::{add_builtin_vfs_extensions, add_vfs_module, list_vfs_modules, VfsMod}; use std::{ ffi::{c_char, c_void, CStr, CString}, - rc::Rc, sync::{Arc, Mutex}, }; use turso_ext::{ @@ -46,7 +45,7 @@ pub(crate) unsafe extern "C" fn register_vtab_module( }; let ext_ctx = unsafe { &mut *(ctx as *mut ExtensionCtx) }; - let module = Rc::new(module); + let module = Arc::new(module); let vmodule = VTabImpl { module_kind: kind, implementation: module, @@ -77,7 +76,7 @@ pub(crate) unsafe extern "C" fn register_vtab_module( #[derive(Clone)] pub struct VTabImpl { pub module_kind: VTabKind, - pub implementation: Rc, + pub implementation: Arc, } pub(crate) unsafe extern "C" fn register_scalar_function( diff --git a/core/lib.rs b/core/lib.rs index 07d989990..e4a4dad22 100644 --- a/core/lib.rs +++ b/core/lib.rs @@ -2580,7 +2580,7 @@ pub type StepResult = vdbe::StepResult; pub struct SymbolTable { pub functions: HashMap>, pub vtabs: HashMap>, - pub vtab_modules: HashMap>, + pub vtab_modules: HashMap>, } impl std::fmt::Debug for SymbolTable { diff --git a/core/translate/schema.rs b/core/translate/schema.rs index 933deb0d9..56ec54313 100644 --- a/core/translate/schema.rs +++ b/core/translate/schema.rs @@ -1,5 +1,4 @@ use std::ops::Range; -use std::rc::Rc; use std::sync::Arc; use crate::ast; @@ -324,7 +323,7 @@ fn create_table_body_to_str(tbl_name: &ast::QualifiedName, body: &ast::CreateTab sql } -fn create_vtable_body_to_str(vtab: &ast::CreateVirtualTable, module: Rc) -> String { +fn create_vtable_body_to_str(vtab: &ast::CreateVirtualTable, module: Arc) -> String { let args = vtab .args .iter() diff --git a/core/vtab.rs b/core/vtab.rs index 661552ca7..bc3da6d9a 100644 --- a/core/vtab.rs +++ b/core/vtab.rs @@ -6,7 +6,6 @@ use crate::{Connection, LimboError, SymbolTable, Value}; use std::cell::RefCell; use std::ffi::c_void; use std::ptr::NonNull; -use std::rc::Rc; use std::sync::Arc; use turso_ext::{ConstraintInfo, IndexInfo, OrderByInfo, ResultCode, VTabKind, VTabModuleImpl}; use turso_parser::{ast, parser::Parser}; @@ -217,7 +216,7 @@ impl VirtualTableCursor { #[derive(Clone, Debug)] pub(crate) struct ExtVirtualTable { - implementation: Rc, + implementation: Arc, table_ptr: *const c_void, } @@ -243,7 +242,7 @@ impl ExtVirtualTable { /// takes ownership of the provided Args fn create( module_name: &str, - module: Option<&Rc>, + module: Option<&Arc>, args: Vec, kind: VTabKind, ) -> crate::Result<(Self, String)> { @@ -326,14 +325,14 @@ pub struct ExtVirtualTableCursor { // the core `[Connection]` pointer the vtab module needs to // query other internal tables. conn_ptr: Option>, - implementation: Rc, + implementation: Arc, } impl ExtVirtualTableCursor { fn new( cursor: NonNull, conn_ptr: NonNull, - implementation: Rc, + implementation: Arc, ) -> crate::Result { Ok(Self { cursor,