From d7977c25a83fd2b5713c6bb1a8214ef5023f1469 Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Wed, 17 Sep 2025 11:46:14 +0300 Subject: [PATCH] core/vtab: Mark VTabModuleImpl as Send and Sync --- core/vtab.rs | 4 ++-- extensions/core/src/vtabs.rs | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/core/vtab.rs b/core/vtab.rs index bc3da6d9a..c19bdc15b 100644 --- a/core/vtab.rs +++ b/core/vtab.rs @@ -412,7 +412,7 @@ impl Drop for ExtVirtualTableCursor { } } -pub trait InternalVirtualTable: std::fmt::Debug { +pub trait InternalVirtualTable: std::fmt::Debug + Send + Sync { fn name(&self) -> String; fn open( &self, @@ -427,7 +427,7 @@ pub trait InternalVirtualTable: std::fmt::Debug { fn sql(&self) -> String; } -pub trait InternalVirtualTableCursor { +pub trait InternalVirtualTableCursor: Send + Sync { /// next returns `Ok(true)` if there are more rows, and `Ok(false)` otherwise. fn next(&mut self) -> Result; fn rowid(&self) -> i64; diff --git a/extensions/core/src/vtabs.rs b/extensions/core/src/vtabs.rs index 5db7137a0..449b26269 100644 --- a/extensions/core/src/vtabs.rs +++ b/extensions/core/src/vtabs.rs @@ -30,6 +30,11 @@ pub struct VTabModuleImpl { pub best_idx: BestIdxFn, } +// SAFETY: VTabModuleImpl contains function pointers and a name pointer that are +// immutable after creation and, therefore, safe to share between threads. +unsafe impl Send for VTabModuleImpl {} +unsafe impl Sync for VTabModuleImpl {} + #[repr(C)] pub struct VTabCreateResult { pub code: ResultCode,