core/ext: Switch vtab_modules from Rc to Arc

This commit is contained in:
Pekka Enberg
2025-09-17 10:24:10 +03:00
parent 6cfd803dad
commit 06d869ea5e
4 changed files with 8 additions and 11 deletions

View File

@@ -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<VTabModuleImpl>,
pub implementation: Arc<VTabModuleImpl>,
}
pub(crate) unsafe extern "C" fn register_scalar_function(

View File

@@ -2580,7 +2580,7 @@ pub type StepResult = vdbe::StepResult;
pub struct SymbolTable {
pub functions: HashMap<String, Arc<function::ExternalFunc>>,
pub vtabs: HashMap<String, Arc<VirtualTable>>,
pub vtab_modules: HashMap<String, Rc<crate::ext::VTabImpl>>,
pub vtab_modules: HashMap<String, Arc<crate::ext::VTabImpl>>,
}
impl std::fmt::Debug for SymbolTable {

View File

@@ -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<VTabImpl>) -> String {
fn create_vtable_body_to_str(vtab: &ast::CreateVirtualTable, module: Arc<VTabImpl>) -> String {
let args = vtab
.args
.iter()

View File

@@ -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<VTabModuleImpl>,
implementation: Arc<VTabModuleImpl>,
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<crate::ext::VTabImpl>>,
module: Option<&Arc<crate::ext::VTabImpl>>,
args: Vec<turso_ext::Value>,
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<NonNull<turso_ext::Conn>>,
implementation: Rc<VTabModuleImpl>,
implementation: Arc<VTabModuleImpl>,
}
impl ExtVirtualTableCursor {
fn new(
cursor: NonNull<c_void>,
conn_ptr: NonNull<turso_ext::Conn>,
implementation: Rc<VTabModuleImpl>,
implementation: Arc<VTabModuleImpl>,
) -> crate::Result<Self> {
Ok(Self {
cursor,