mirror of
https://github.com/tursodatabase/limbo.git
synced 2025-08-04 18:18:03 +00:00
Rename limbo_ext
crate to turso_ext
This commit is contained in:
parent
51b6e347a8
commit
eb0de4066b
49 changed files with 317 additions and 318 deletions
60
Cargo.lock
generated
60
Cargo.lock
generated
|
@ -1763,8 +1763,8 @@ dependencies = [
|
||||||
name = "limbo_completion"
|
name = "limbo_completion"
|
||||||
version = "0.1.0-pre.2"
|
version = "0.1.0-pre.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"limbo_ext",
|
|
||||||
"mimalloc",
|
"mimalloc",
|
||||||
|
"turso_ext",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1773,10 +1773,10 @@ version = "0.1.0-pre.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"blake3",
|
"blake3",
|
||||||
"data-encoding",
|
"data-encoding",
|
||||||
"limbo_ext",
|
|
||||||
"md5",
|
"md5",
|
||||||
"mimalloc",
|
"mimalloc",
|
||||||
"ring",
|
"ring",
|
||||||
|
"turso_ext",
|
||||||
"urlencoding",
|
"urlencoding",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1785,29 +1785,9 @@ name = "limbo_csv"
|
||||||
version = "0.1.0-pre.2"
|
version = "0.1.0-pre.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"csv",
|
"csv",
|
||||||
"limbo_ext",
|
|
||||||
"mimalloc",
|
"mimalloc",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
]
|
"turso_ext",
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "limbo_ext"
|
|
||||||
version = "0.1.0-pre.2"
|
|
||||||
dependencies = [
|
|
||||||
"chrono",
|
|
||||||
"getrandom 0.3.2",
|
|
||||||
"turso_macros",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "limbo_ext_tests"
|
|
||||||
version = "0.1.0-pre.2"
|
|
||||||
dependencies = [
|
|
||||||
"env_logger 0.11.7",
|
|
||||||
"lazy_static",
|
|
||||||
"limbo_ext",
|
|
||||||
"log",
|
|
||||||
"mimalloc",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1815,35 +1795,35 @@ name = "limbo_ipaddr"
|
||||||
version = "0.1.0-pre.2"
|
version = "0.1.0-pre.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ipnetwork",
|
"ipnetwork",
|
||||||
"limbo_ext",
|
|
||||||
"mimalloc",
|
"mimalloc",
|
||||||
|
"turso_ext",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "limbo_percentile"
|
name = "limbo_percentile"
|
||||||
version = "0.1.0-pre.2"
|
version = "0.1.0-pre.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"limbo_ext",
|
|
||||||
"mimalloc",
|
"mimalloc",
|
||||||
|
"turso_ext",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "limbo_regexp"
|
name = "limbo_regexp"
|
||||||
version = "0.1.0-pre.2"
|
version = "0.1.0-pre.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"limbo_ext",
|
|
||||||
"mimalloc",
|
"mimalloc",
|
||||||
"regex",
|
"regex",
|
||||||
|
"turso_ext",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "limbo_series"
|
name = "limbo_series"
|
||||||
version = "0.1.0-pre.2"
|
version = "0.1.0-pre.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"limbo_ext",
|
|
||||||
"mimalloc",
|
"mimalloc",
|
||||||
"quickcheck",
|
"quickcheck",
|
||||||
"quickcheck_macros",
|
"quickcheck_macros",
|
||||||
|
"turso_ext",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1934,19 +1914,19 @@ name = "limbo_time"
|
||||||
version = "0.1.0-pre.2"
|
version = "0.1.0-pre.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"limbo_ext",
|
|
||||||
"mimalloc",
|
"mimalloc",
|
||||||
"strum",
|
"strum",
|
||||||
"strum_macros",
|
"strum_macros",
|
||||||
"thiserror 2.0.12",
|
"thiserror 2.0.12",
|
||||||
|
"turso_ext",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "limbo_uuid"
|
name = "limbo_uuid"
|
||||||
version = "0.1.0-pre.2"
|
version = "0.1.0-pre.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"limbo_ext",
|
|
||||||
"mimalloc",
|
"mimalloc",
|
||||||
|
"turso_ext",
|
||||||
"uuid",
|
"uuid",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -3763,7 +3743,6 @@ dependencies = [
|
||||||
"limbo_completion",
|
"limbo_completion",
|
||||||
"limbo_crypto",
|
"limbo_crypto",
|
||||||
"limbo_csv",
|
"limbo_csv",
|
||||||
"limbo_ext",
|
|
||||||
"limbo_ipaddr",
|
"limbo_ipaddr",
|
||||||
"limbo_percentile",
|
"limbo_percentile",
|
||||||
"limbo_regexp",
|
"limbo_regexp",
|
||||||
|
@ -3796,10 +3775,31 @@ dependencies = [
|
||||||
"test-log",
|
"test-log",
|
||||||
"thiserror 1.0.69",
|
"thiserror 1.0.69",
|
||||||
"tracing",
|
"tracing",
|
||||||
|
"turso_ext",
|
||||||
"turso_macros",
|
"turso_macros",
|
||||||
"uncased",
|
"uncased",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "turso_ext"
|
||||||
|
version = "0.1.0-pre.2"
|
||||||
|
dependencies = [
|
||||||
|
"chrono",
|
||||||
|
"getrandom 0.3.2",
|
||||||
|
"turso_macros",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "turso_ext_tests"
|
||||||
|
version = "0.1.0-pre.2"
|
||||||
|
dependencies = [
|
||||||
|
"env_logger 0.11.7",
|
||||||
|
"lazy_static",
|
||||||
|
"log",
|
||||||
|
"mimalloc",
|
||||||
|
"turso_ext",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "turso_macros"
|
name = "turso_macros"
|
||||||
version = "0.1.0-pre.2"
|
version = "0.1.0-pre.2"
|
||||||
|
|
|
@ -43,8 +43,8 @@ limbo_completion = { path = "extensions/completion", version = "0.1.0-pre.2" }
|
||||||
turso_core = { path = "core", version = "0.1.0-pre.2" }
|
turso_core = { path = "core", version = "0.1.0-pre.2" }
|
||||||
limbo_crypto = { path = "extensions/crypto", version = "0.1.0-pre.2" }
|
limbo_crypto = { path = "extensions/crypto", version = "0.1.0-pre.2" }
|
||||||
limbo_csv = { path = "extensions/csv", version = "0.1.0-pre.2" }
|
limbo_csv = { path = "extensions/csv", version = "0.1.0-pre.2" }
|
||||||
limbo_ext = { path = "extensions/core", version = "0.1.0-pre.2" }
|
turso_ext = { path = "extensions/core", version = "0.1.0-pre.2" }
|
||||||
limbo_ext_tests = { path = "extensions/tests", version = "0.1.0-pre.2" }
|
turso_ext_tests = { path = "extensions/tests", version = "0.1.0-pre.2" }
|
||||||
limbo_ipaddr = { path = "extensions/ipaddr", version = "0.1.0-pre.2" }
|
limbo_ipaddr = { path = "extensions/ipaddr", version = "0.1.0-pre.2" }
|
||||||
turso_macros = { path = "macros", version = "0.1.0-pre.2" }
|
turso_macros = { path = "macros", version = "0.1.0-pre.2" }
|
||||||
limbo_percentile = { path = "extensions/percentile", version = "0.1.0-pre.2" }
|
limbo_percentile = { path = "extensions/percentile", version = "0.1.0-pre.2" }
|
||||||
|
|
|
@ -16,7 +16,7 @@ path = "lib.rs"
|
||||||
[features]
|
[features]
|
||||||
antithesis = ["dep:antithesis_sdk"]
|
antithesis = ["dep:antithesis_sdk"]
|
||||||
default = ["fs", "uuid", "time", "json", "static", "series"]
|
default = ["fs", "uuid", "time", "json", "static", "series"]
|
||||||
fs = ["limbo_ext/vfs"]
|
fs = ["turso_ext/vfs"]
|
||||||
json = []
|
json = []
|
||||||
uuid = ["limbo_uuid/static"]
|
uuid = ["limbo_uuid/static"]
|
||||||
io_uring = ["dep:io-uring", "rustix/io_uring", "dep:libc"]
|
io_uring = ["dep:io-uring", "rustix/io_uring", "dep:libc"]
|
||||||
|
@ -27,7 +27,7 @@ crypto = ["limbo_crypto/static"]
|
||||||
series = ["limbo_series/static"]
|
series = ["limbo_series/static"]
|
||||||
ipaddr = ["limbo_ipaddr/static"]
|
ipaddr = ["limbo_ipaddr/static"]
|
||||||
completion = ["limbo_completion/static"]
|
completion = ["limbo_completion/static"]
|
||||||
static = ["limbo_ext/static"]
|
static = ["turso_ext/static"]
|
||||||
fuzz = []
|
fuzz = []
|
||||||
csv = ["limbo_csv/static"]
|
csv = ["limbo_csv/static"]
|
||||||
omit_autovacuum = []
|
omit_autovacuum = []
|
||||||
|
@ -47,7 +47,7 @@ libloading = "0.8.6"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
antithesis_sdk = { version = "0.2.5", optional = true }
|
antithesis_sdk = { version = "0.2.5", optional = true }
|
||||||
limbo_ext = { workspace = true, features = ["core_only"] }
|
turso_ext = { workspace = true, features = ["core_only"] }
|
||||||
cfg_block = "0.1.1"
|
cfg_block = "0.1.1"
|
||||||
fallible-iterator = "0.3.0"
|
fallible-iterator = "0.3.0"
|
||||||
hex = "0.4.3"
|
hex = "0.4.3"
|
||||||
|
|
|
@ -80,8 +80,8 @@ macro_rules! bail_constraint_error {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<limbo_ext::ResultCode> for LimboError {
|
impl From<turso_ext::ResultCode> for LimboError {
|
||||||
fn from(err: limbo_ext::ResultCode) -> Self {
|
fn from(err: turso_ext::ResultCode) -> Self {
|
||||||
LimboError::ExtensionError(err.to_string())
|
LimboError::ExtensionError(err.to_string())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,11 +3,11 @@ use crate::{
|
||||||
Connection, LimboError,
|
Connection, LimboError,
|
||||||
};
|
};
|
||||||
use libloading::{Library, Symbol};
|
use libloading::{Library, Symbol};
|
||||||
use limbo_ext::{ExtensionApi, ExtensionApiRef, ExtensionEntryPoint, ResultCode, VfsImpl};
|
|
||||||
use std::{
|
use std::{
|
||||||
ffi::{c_char, CString},
|
ffi::{c_char, CString},
|
||||||
sync::{Arc, Mutex, OnceLock},
|
sync::{Arc, Mutex, OnceLock},
|
||||||
};
|
};
|
||||||
|
use turso_ext::{ExtensionApi, ExtensionApiRef, ExtensionEntryPoint, ResultCode, VfsImpl};
|
||||||
|
|
||||||
type ExtensionStore = Vec<(Arc<Library>, ExtensionApiRef)>;
|
type ExtensionStore = Vec<(Arc<Library>, ExtensionApiRef)>;
|
||||||
static EXTENSIONS: OnceLock<Arc<Mutex<ExtensionStore>>> = OnceLock::new();
|
static EXTENSIONS: OnceLock<Arc<Mutex<ExtensionStore>>> = OnceLock::new();
|
||||||
|
@ -33,9 +33,9 @@ impl Connection {
|
||||||
self: &Arc<Connection>,
|
self: &Arc<Connection>,
|
||||||
path: P,
|
path: P,
|
||||||
) -> crate::Result<()> {
|
) -> crate::Result<()> {
|
||||||
use limbo_ext::ExtensionApiRef;
|
use turso_ext::ExtensionApiRef;
|
||||||
|
|
||||||
let api = Box::new(self.build_limbo_ext());
|
let api = Box::new(self.build_turso_ext());
|
||||||
let lib =
|
let lib =
|
||||||
unsafe { Library::new(path).map_err(|e| LimboError::ExtensionError(e.to_string()))? };
|
unsafe { Library::new(path).map_err(|e| LimboError::ExtensionError(e.to_string()))? };
|
||||||
let entry: Symbol<ExtensionEntryPoint> = unsafe {
|
let entry: Symbol<ExtensionEntryPoint> = unsafe {
|
||||||
|
@ -93,7 +93,7 @@ pub(crate) unsafe extern "C" fn register_vfs(
|
||||||
pub fn add_builtin_vfs_extensions(
|
pub fn add_builtin_vfs_extensions(
|
||||||
api: Option<ExtensionApi>,
|
api: Option<ExtensionApi>,
|
||||||
) -> crate::Result<Vec<(String, Arc<VfsMod>)>> {
|
) -> crate::Result<Vec<(String, Arc<VfsMod>)>> {
|
||||||
use limbo_ext::VfsInterface;
|
use turso_ext::VfsInterface;
|
||||||
|
|
||||||
let mut vfslist: Vec<*const VfsImpl> = Vec::new();
|
let mut vfslist: Vec<*const VfsImpl> = Vec::new();
|
||||||
let mut api = match api {
|
let mut api = match api {
|
||||||
|
|
|
@ -6,15 +6,15 @@ use crate::UringIO;
|
||||||
use crate::{function::ExternalFunc, Connection, Database, LimboError, IO};
|
use crate::{function::ExternalFunc, Connection, Database, LimboError, IO};
|
||||||
#[cfg(feature = "fs")]
|
#[cfg(feature = "fs")]
|
||||||
pub use dynamic::{add_builtin_vfs_extensions, add_vfs_module, list_vfs_modules, VfsMod};
|
pub use dynamic::{add_builtin_vfs_extensions, add_vfs_module, list_vfs_modules, VfsMod};
|
||||||
use limbo_ext::{
|
|
||||||
ExtensionApi, InitAggFunction, ResultCode, ScalarFunction, VTabKind, VTabModuleImpl,
|
|
||||||
};
|
|
||||||
pub use limbo_ext::{FinalizeFunction, StepFunction, Value as ExtValue, ValueType as ExtValueType};
|
|
||||||
use std::{
|
use std::{
|
||||||
ffi::{c_char, c_void, CStr, CString},
|
ffi::{c_char, c_void, CStr, CString},
|
||||||
rc::Rc,
|
rc::Rc,
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
|
use turso_ext::{
|
||||||
|
ExtensionApi, InitAggFunction, ResultCode, ScalarFunction, VTabKind, VTabModuleImpl,
|
||||||
|
};
|
||||||
|
pub use turso_ext::{FinalizeFunction, StepFunction, Value as ExtValue, ValueType as ExtValueType};
|
||||||
pub use vtab_xconnect::{close, execute, prepare_stmt};
|
pub use vtab_xconnect::{close, execute, prepare_stmt};
|
||||||
type ExternAggFunc = (InitAggFunction, StepFunction, FinalizeFunction);
|
type ExternAggFunc = (InitAggFunction, StepFunction, FinalizeFunction);
|
||||||
|
|
||||||
|
@ -154,14 +154,14 @@ impl Connection {
|
||||||
ResultCode::OK
|
ResultCode::OK
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn build_limbo_ext(&self) -> ExtensionApi {
|
pub fn build_turso_ext(&self) -> ExtensionApi {
|
||||||
ExtensionApi {
|
ExtensionApi {
|
||||||
ctx: self as *const _ as *mut c_void,
|
ctx: self as *const _ as *mut c_void,
|
||||||
register_scalar_function,
|
register_scalar_function,
|
||||||
register_aggregate_function,
|
register_aggregate_function,
|
||||||
register_vtab_module,
|
register_vtab_module,
|
||||||
#[cfg(feature = "fs")]
|
#[cfg(feature = "fs")]
|
||||||
vfs_interface: limbo_ext::VfsInterface {
|
vfs_interface: turso_ext::VfsInterface {
|
||||||
register_vfs: dynamic::register_vfs,
|
register_vfs: dynamic::register_vfs,
|
||||||
builtin_vfs: std::ptr::null_mut(),
|
builtin_vfs: std::ptr::null_mut(),
|
||||||
builtin_vfs_count: 0,
|
builtin_vfs_count: 0,
|
||||||
|
@ -171,7 +171,7 @@ impl Connection {
|
||||||
|
|
||||||
pub fn register_builtins(&self) -> Result<(), String> {
|
pub fn register_builtins(&self) -> Result<(), String> {
|
||||||
#[allow(unused_variables)]
|
#[allow(unused_variables)]
|
||||||
let mut ext_api = self.build_limbo_ext();
|
let mut ext_api = self.build_turso_ext();
|
||||||
#[cfg(feature = "uuid")]
|
#[cfg(feature = "uuid")]
|
||||||
if unsafe { !limbo_uuid::register_extension_static(&mut ext_api).is_ok() } {
|
if unsafe { !limbo_uuid::register_extension_static(&mut ext_api).is_ok() } {
|
||||||
return Err("Failed to register uuid extension".to_string());
|
return Err("Failed to register uuid extension".to_string());
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use crate::{types::Value, Connection, Statement, StepResult};
|
use crate::{types::Value, Connection, Statement, StepResult};
|
||||||
use limbo_ext::{Conn as ExtConn, ResultCode, Stmt, Value as ExtValue};
|
|
||||||
use std::{
|
use std::{
|
||||||
boxed::Box,
|
boxed::Box,
|
||||||
ffi::{c_char, c_void, CStr, CString},
|
ffi::{c_char, c_void, CStr, CString},
|
||||||
|
@ -7,6 +6,7 @@ use std::{
|
||||||
ptr,
|
ptr,
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
|
use turso_ext::{Conn as ExtConn, ResultCode, Stmt, Value as ExtValue};
|
||||||
|
|
||||||
/// Free memory for the internal context of the connection.
|
/// Free memory for the internal context of the connection.
|
||||||
/// This function does not close the core connection itself,
|
/// This function does not close the core connection itself,
|
||||||
|
@ -21,7 +21,7 @@ pub unsafe extern "C" fn close(ctx: *mut c_void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Wrapper around core Connection::execute with optional arguments to bind
|
/// Wrapper around core Connection::execute with optional arguments to bind
|
||||||
/// to the statment This function takes ownership of the optional limbo_ext::Value array if provided
|
/// to the statment This function takes ownership of the optional turso_ext::Value array if provided
|
||||||
pub unsafe extern "C" fn execute(
|
pub unsafe extern "C" fn execute(
|
||||||
ctx: *mut ExtConn,
|
ctx: *mut ExtConn,
|
||||||
sql: *const c_char,
|
sql: *const c_char,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use limbo_ext::{FinalizeFunction, InitAggFunction, ScalarFunction, StepFunction};
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::fmt::{Debug, Display};
|
use std::fmt::{Debug, Display};
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
use turso_ext::{FinalizeFunction, InitAggFunction, ScalarFunction, StepFunction};
|
||||||
|
|
||||||
use crate::LimboError;
|
use crate::LimboError;
|
||||||
|
|
||||||
|
|
|
@ -3,10 +3,10 @@ use crate::ext::VfsMod;
|
||||||
use crate::io::clock::{Clock, Instant};
|
use crate::io::clock::{Clock, Instant};
|
||||||
use crate::io::CompletionType;
|
use crate::io::CompletionType;
|
||||||
use crate::{LimboError, Result};
|
use crate::{LimboError, Result};
|
||||||
use limbo_ext::{VfsFileImpl, VfsImpl};
|
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::ffi::{c_void, CString};
|
use std::ffi::{c_void, CString};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use turso_ext::{VfsFileImpl, VfsImpl};
|
||||||
|
|
||||||
impl Clock for VfsMod {
|
impl Clock for VfsMod {
|
||||||
fn now(&self) -> Instant {
|
fn now(&self) -> Instant {
|
||||||
|
@ -29,7 +29,7 @@ impl IO for VfsMod {
|
||||||
if file.is_null() {
|
if file.is_null() {
|
||||||
return Err(LimboError::ExtensionError("File not found".to_string()));
|
return Err(LimboError::ExtensionError("File not found".to_string()));
|
||||||
}
|
}
|
||||||
Ok(Arc::new(limbo_ext::VfsFileImpl::new(file, self.ctx)?))
|
Ok(Arc::new(turso_ext::VfsFileImpl::new(file, self.ctx)?))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_once(&self) -> Result<()> {
|
fn run_once(&self) -> Result<()> {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use limbo_ext::VTabKind;
|
|
||||||
use limbo_sqlite3_parser::ast::{self, SortOrder};
|
use limbo_sqlite3_parser::ast::{self, SortOrder};
|
||||||
|
use turso_ext::VTabKind;
|
||||||
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use limbo_ext::{ConstraintInfo, ConstraintOp};
|
|
||||||
use limbo_sqlite3_parser::ast::{self, SortOrder};
|
use limbo_sqlite3_parser::ast::{self, SortOrder};
|
||||||
use std::{cell::Cell, cmp::Ordering, rc::Rc, sync::Arc};
|
use std::{cell::Cell, cmp::Ordering, rc::Rc, sync::Arc};
|
||||||
|
use turso_ext::{ConstraintInfo, ConstraintOp};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
function::AggFunc,
|
function::AggFunc,
|
||||||
|
|
|
@ -20,8 +20,8 @@ use crate::LimboError;
|
||||||
use crate::SymbolTable;
|
use crate::SymbolTable;
|
||||||
use crate::{bail_parse_error, Result};
|
use crate::{bail_parse_error, Result};
|
||||||
|
|
||||||
use limbo_ext::VTabKind;
|
|
||||||
use limbo_sqlite3_parser::ast::{fmt::ToTokens, CreateVirtualTable};
|
use limbo_sqlite3_parser::ast::{fmt::ToTokens, CreateVirtualTable};
|
||||||
|
use turso_ext::VTabKind;
|
||||||
|
|
||||||
pub fn translate_create_table(
|
pub fn translate_create_table(
|
||||||
query_mode: QueryMode,
|
query_mode: QueryMode,
|
||||||
|
@ -483,7 +483,7 @@ fn create_vtable_body_to_str(vtab: &CreateVirtualTable, module: Rc<VTabImpl>) ->
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.unwrap_or(&vec![])
|
.unwrap_or(&vec![])
|
||||||
.iter()
|
.iter()
|
||||||
.map(|a| limbo_ext::Value::from_text(a.to_string()))
|
.map(|a| turso_ext::Value::from_text(a.to_string()))
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
let schema = module
|
let schema = module
|
||||||
.implementation
|
.implementation
|
||||||
|
@ -738,7 +738,7 @@ pub fn translate_drop_table(
|
||||||
// From what I see, TableValuedFunction is not stored in the schema as a table.
|
// From what I see, TableValuedFunction is not stored in the schema as a table.
|
||||||
// But this line here below is a safeguard in case this behavior changes in the future
|
// But this line here below is a safeguard in case this behavior changes in the future
|
||||||
// And mirrors what SQLite does.
|
// And mirrors what SQLite does.
|
||||||
if matches!(vtab.kind, limbo_ext::VTabKind::TableValuedFunction) {
|
if matches!(vtab.kind, turso_ext::VTabKind::TableValuedFunction) {
|
||||||
return Err(crate::LimboError::ParseError(format!(
|
return Err(crate::LimboError::ParseError(format!(
|
||||||
"table {} may not be dropped",
|
"table {} may not be dropped",
|
||||||
vtab.name
|
vtab.name
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use limbo_ext::{AggCtx, FinalizeFunction, StepFunction};
|
|
||||||
use limbo_sqlite3_parser::ast::SortOrder;
|
use limbo_sqlite3_parser::ast::SortOrder;
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
use turso_ext::{AggCtx, FinalizeFunction, StepFunction};
|
||||||
|
|
||||||
use crate::error::LimboError;
|
use crate::error::LimboError;
|
||||||
use crate::ext::{ExtValue, ExtValueType};
|
use crate::ext::{ExtValue, ExtValueType};
|
||||||
|
|
22
core/util.rs
22
core/util.rs
|
@ -207,7 +207,7 @@ fn module_name_from_sql(sql: &str) -> Result<&str> {
|
||||||
|
|
||||||
// CREATE VIRTUAL TABLE table_name USING module_name(arg1, arg2, ...);
|
// CREATE VIRTUAL TABLE table_name USING module_name(arg1, arg2, ...);
|
||||||
// CREATE VIRTUAL TABLE table_name USING module_name;
|
// CREATE VIRTUAL TABLE table_name USING module_name;
|
||||||
fn module_args_from_sql(sql: &str) -> Result<Vec<limbo_ext::Value>> {
|
fn module_args_from_sql(sql: &str) -> Result<Vec<turso_ext::Value>> {
|
||||||
if !sql.contains('(') {
|
if !sql.contains('(') {
|
||||||
return Ok(vec![]);
|
return Ok(vec![]);
|
||||||
}
|
}
|
||||||
|
@ -233,7 +233,7 @@ fn module_args_from_sql(sql: &str) -> Result<Vec<limbo_ext::Value>> {
|
||||||
chars.next();
|
chars.next();
|
||||||
} else {
|
} else {
|
||||||
in_quotes = false;
|
in_quotes = false;
|
||||||
args.push(limbo_ext::Value::from_text(current_arg.trim().to_string()));
|
args.push(turso_ext::Value::from_text(current_arg.trim().to_string()));
|
||||||
current_arg.clear();
|
current_arg.clear();
|
||||||
// Skip until comma or end
|
// Skip until comma or end
|
||||||
while let Some(&nc) = chars.peek() {
|
while let Some(&nc) = chars.peek() {
|
||||||
|
@ -256,7 +256,7 @@ fn module_args_from_sql(sql: &str) -> Result<Vec<limbo_ext::Value>> {
|
||||||
',' => {
|
',' => {
|
||||||
if !in_quotes {
|
if !in_quotes {
|
||||||
if !current_arg.trim().is_empty() {
|
if !current_arg.trim().is_empty() {
|
||||||
args.push(limbo_ext::Value::from_text(current_arg.trim().to_string()));
|
args.push(turso_ext::Value::from_text(current_arg.trim().to_string()));
|
||||||
current_arg.clear();
|
current_arg.clear();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -270,7 +270,7 @@ fn module_args_from_sql(sql: &str) -> Result<Vec<limbo_ext::Value>> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if !current_arg.trim().is_empty() && !in_quotes {
|
if !current_arg.trim().is_empty() && !in_quotes {
|
||||||
args.push(limbo_ext::Value::from_text(current_arg.trim().to_string()));
|
args.push(turso_ext::Value::from_text(current_arg.trim().to_string()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if in_quotes {
|
if in_quotes {
|
||||||
|
@ -1032,29 +1032,29 @@ pub fn parse_signed_number(expr: &Expr) -> Result<Value> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// for TVF's we need these at planning time so we cannot emit translate_expr
|
// for TVF's we need these at planning time so we cannot emit translate_expr
|
||||||
pub fn vtable_args(args: &[ast::Expr]) -> Vec<limbo_ext::Value> {
|
pub fn vtable_args(args: &[ast::Expr]) -> Vec<turso_ext::Value> {
|
||||||
let mut vtable_args = Vec::new();
|
let mut vtable_args = Vec::new();
|
||||||
for arg in args {
|
for arg in args {
|
||||||
match arg {
|
match arg {
|
||||||
Expr::Literal(lit) => match lit {
|
Expr::Literal(lit) => match lit {
|
||||||
Literal::Numeric(i) => {
|
Literal::Numeric(i) => {
|
||||||
if i.contains('.') {
|
if i.contains('.') {
|
||||||
vtable_args.push(limbo_ext::Value::from_float(i.parse().unwrap()));
|
vtable_args.push(turso_ext::Value::from_float(i.parse().unwrap()));
|
||||||
} else {
|
} else {
|
||||||
vtable_args.push(limbo_ext::Value::from_integer(i.parse().unwrap()));
|
vtable_args.push(turso_ext::Value::from_integer(i.parse().unwrap()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Literal::String(s) => {
|
Literal::String(s) => {
|
||||||
vtable_args.push(limbo_ext::Value::from_text(s.clone()));
|
vtable_args.push(turso_ext::Value::from_text(s.clone()));
|
||||||
}
|
}
|
||||||
Literal::Blob(b) => {
|
Literal::Blob(b) => {
|
||||||
vtable_args.push(limbo_ext::Value::from_blob(b.as_bytes().into()));
|
vtable_args.push(turso_ext::Value::from_blob(b.as_bytes().into()));
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
vtable_args.push(limbo_ext::Value::null());
|
vtable_args.push(turso_ext::Value::null());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_ => vtable_args.push(limbo_ext::Value::null()),
|
_ => vtable_args.push(turso_ext::Value::null()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
vtable_args
|
vtable_args
|
||||||
|
|
12
core/vtab.rs
12
core/vtab.rs
|
@ -3,12 +3,12 @@ use crate::schema::Column;
|
||||||
use crate::util::{columns_from_create_table_body, vtable_args};
|
use crate::util::{columns_from_create_table_body, vtable_args};
|
||||||
use crate::{Connection, LimboError, SymbolTable, Value};
|
use crate::{Connection, LimboError, SymbolTable, Value};
|
||||||
use fallible_iterator::FallibleIterator;
|
use fallible_iterator::FallibleIterator;
|
||||||
use limbo_ext::{ConstraintInfo, IndexInfo, OrderByInfo, ResultCode, VTabKind, VTabModuleImpl};
|
|
||||||
use limbo_sqlite3_parser::{ast, lexer::sql::Parser};
|
use limbo_sqlite3_parser::{ast, lexer::sql::Parser};
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::ffi::c_void;
|
use std::ffi::c_void;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use turso_ext::{ConstraintInfo, IndexInfo, OrderByInfo, ResultCode, VTabKind, VTabModuleImpl};
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
enum VirtualTableType {
|
enum VirtualTableType {
|
||||||
|
@ -62,7 +62,7 @@ impl VirtualTable {
|
||||||
pub fn table(
|
pub fn table(
|
||||||
tbl_name: Option<&str>,
|
tbl_name: Option<&str>,
|
||||||
module_name: &str,
|
module_name: &str,
|
||||||
args: Vec<limbo_ext::Value>,
|
args: Vec<turso_ext::Value>,
|
||||||
syms: &SymbolTable,
|
syms: &SymbolTable,
|
||||||
) -> crate::Result<Rc<VirtualTable>> {
|
) -> crate::Result<Rc<VirtualTable>> {
|
||||||
let module = syms.vtab_modules.get(module_name);
|
let module = syms.vtab_modules.get(module_name);
|
||||||
|
@ -178,7 +178,7 @@ impl VirtualTableCursor {
|
||||||
struct ExtVirtualTable {
|
struct ExtVirtualTable {
|
||||||
implementation: Rc<VTabModuleImpl>,
|
implementation: Rc<VTabModuleImpl>,
|
||||||
table_ptr: *const c_void,
|
table_ptr: *const c_void,
|
||||||
connection_ptr: RefCell<Option<*mut limbo_ext::Conn>>,
|
connection_ptr: RefCell<Option<*mut turso_ext::Conn>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for ExtVirtualTable {
|
impl Drop for ExtVirtualTable {
|
||||||
|
@ -187,7 +187,7 @@ impl Drop for ExtVirtualTable {
|
||||||
if conn.is_null() {
|
if conn.is_null() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// free the memory for the limbo_ext::Conn itself
|
// free the memory for the turso_ext::Conn itself
|
||||||
let mut conn = unsafe { Box::from_raw(conn) };
|
let mut conn = unsafe { Box::from_raw(conn) };
|
||||||
// frees the boxed Weak pointer
|
// frees the boxed Weak pointer
|
||||||
conn.close();
|
conn.close();
|
||||||
|
@ -212,7 +212,7 @@ impl ExtVirtualTable {
|
||||||
fn create(
|
fn create(
|
||||||
module_name: &str,
|
module_name: &str,
|
||||||
module: Option<&Rc<crate::ext::VTabImpl>>,
|
module: Option<&Rc<crate::ext::VTabImpl>>,
|
||||||
args: Vec<limbo_ext::Value>,
|
args: Vec<turso_ext::Value>,
|
||||||
kind: VTabKind,
|
kind: VTabKind,
|
||||||
) -> crate::Result<(Self, String)> {
|
) -> crate::Result<(Self, String)> {
|
||||||
let module = module.ok_or(LimboError::ExtensionError(format!(
|
let module = module.ok_or(LimboError::ExtensionError(format!(
|
||||||
|
@ -243,7 +243,7 @@ impl ExtVirtualTable {
|
||||||
fn open(&self, conn: Arc<Connection>) -> crate::Result<ExtVirtualTableCursor> {
|
fn open(&self, conn: Arc<Connection>) -> crate::Result<ExtVirtualTableCursor> {
|
||||||
// we need a Weak<Connection> to upgrade and call from the extension.
|
// we need a Weak<Connection> to upgrade and call from the extension.
|
||||||
let weak_box: *mut Arc<Connection> = Box::into_raw(Box::new(conn));
|
let weak_box: *mut Arc<Connection> = Box::into_raw(Box::new(conn));
|
||||||
let conn = limbo_ext::Conn::new(
|
let conn = turso_ext::Conn::new(
|
||||||
weak_box.cast(),
|
weak_box.cast(),
|
||||||
crate::ext::prepare_stmt,
|
crate::ext::prepare_stmt,
|
||||||
crate::ext::execute,
|
crate::ext::execute,
|
||||||
|
|
|
@ -8,7 +8,7 @@ repository.workspace = true
|
||||||
description = "Limbo completion extension"
|
description = "Limbo completion extension"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
limbo_ext = { workspace = true, features = ["static"] }
|
turso_ext = { workspace = true, features = ["static"] }
|
||||||
|
|
||||||
[target.'cfg(not(target_family = "wasm"))'.dependencies]
|
[target.'cfg(not(target_family = "wasm"))'.dependencies]
|
||||||
mimalloc = { version = "0.1", default-features = false }
|
mimalloc = { version = "0.1", default-features = false }
|
||||||
|
@ -17,4 +17,4 @@ mimalloc = { version = "0.1", default-features = false }
|
||||||
crate-type = ["cdylib", "lib"]
|
crate-type = ["cdylib", "lib"]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
static = ["limbo_ext/static"]
|
static = ["turso_ext/static"]
|
||||||
|
|
|
@ -6,7 +6,7 @@ mod keywords;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use keywords::KEYWORDS;
|
use keywords::KEYWORDS;
|
||||||
use limbo_ext::{
|
use turso_ext::{
|
||||||
register_extension, Connection, ResultCode, VTabCursor, VTabModule, VTabModuleDerive, VTable,
|
register_extension, Connection, ResultCode, VTabCursor, VTabModule, VTabModuleDerive, VTable,
|
||||||
Value,
|
Value,
|
||||||
};
|
};
|
||||||
|
@ -67,7 +67,7 @@ struct CompletionVTabModule {}
|
||||||
impl VTabModule for CompletionVTabModule {
|
impl VTabModule for CompletionVTabModule {
|
||||||
type Table = CompletionTable;
|
type Table = CompletionTable;
|
||||||
const NAME: &'static str = "completion";
|
const NAME: &'static str = "completion";
|
||||||
const VTAB_KIND: limbo_ext::VTabKind = limbo_ext::VTabKind::TableValuedFunction;
|
const VTAB_KIND: turso_ext::VTabKind = turso_ext::VTabKind::TableValuedFunction;
|
||||||
|
|
||||||
fn create(_args: &[Value]) -> Result<(String, Self::Table), ResultCode> {
|
fn create(_args: &[Value]) -> Result<(String, Self::Table), ResultCode> {
|
||||||
let schema = "CREATE TABLE completion(
|
let schema = "CREATE TABLE completion(
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[package]
|
[package]
|
||||||
name = "limbo_ext"
|
name = "turso_ext"
|
||||||
version.workspace = true
|
version.workspace = true
|
||||||
authors.workspace = true
|
authors.workspace = true
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# Limbo extension API
|
# Turso extension API
|
||||||
|
|
||||||
The `limbo_ext` crate simplifies the creation and registration of libraries meant to extend the functionality of `Limbo`, that can be loaded
|
The `turso_ext` crate simplifies the creation and registration of libraries meant to extend the functionality of `Turso`, that can be loaded
|
||||||
like traditional `sqlite3` extensions, but are able to be written in much more ergonomic Rust.
|
like traditional `sqlite3` extensions, but are able to be written in much more ergonomic Rust.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
@ -10,7 +10,7 @@ like traditional `sqlite3` extensions, but are able to be written in much more e
|
||||||
- [ x ] **Scalar Functions**: Create scalar functions using the `scalar` macro.
|
- [ x ] **Scalar Functions**: Create scalar functions using the `scalar` macro.
|
||||||
- [ x ] **Aggregate Functions**: Define aggregate functions with `AggregateDerive` macro and `AggFunc` trait.
|
- [ x ] **Aggregate Functions**: Define aggregate functions with `AggregateDerive` macro and `AggFunc` trait.
|
||||||
- [ x ] **Virtual tables**: Create a module for a virtual table with the `VTabModuleDerive` macro and `VTabCursor` trait.
|
- [ x ] **Virtual tables**: Create a module for a virtual table with the `VTabModuleDerive` macro and `VTabCursor` trait.
|
||||||
- [ x ] **VFS Modules**: Extend Limbo's OS interface by implementing `VfsExtension` and `VfsFile` traits.
|
- [ x ] **VFS Modules**: Extend Turso's OS interface by implementing `VfsExtension` and `VfsFile` traits.
|
||||||
---
|
---
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
@ -28,10 +28,10 @@ creating an extension inside `core`, this step should be skipped.
|
||||||
```toml
|
```toml
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
static = ["limbo_ext/static"]
|
static = ["turso_ext/static"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
limbo_ext = { path = "path/to/limbo/extensions/core", features = ["static", "vfs"] } # temporary until crate is published
|
turso_ext = { path = "path/to/limbo/extensions/core", features = ["static", "vfs"] } # temporary until crate is published
|
||||||
|
|
||||||
# mimalloc is required if you intend on linking dynamically. It is imported for you by the register_extension
|
# mimalloc is required if you intend on linking dynamically. It is imported for you by the register_extension
|
||||||
# macro, so no configuration is needed. But it must be added to your Cargo.toml
|
# macro, so no configuration is needed. But it must be added to your Cargo.toml
|
||||||
|
@ -71,7 +71,7 @@ file as the `register_extension` macro.
|
||||||
|
|
||||||
### Scalar Example:
|
### Scalar Example:
|
||||||
```rust
|
```rust
|
||||||
use limbo_ext::{register_extension, Value, scalar};
|
use turso_ext::{register_extension, Value, scalar};
|
||||||
|
|
||||||
/// Annotate each with the scalar macro, specifying the name you would like to call it with
|
/// Annotate each with the scalar macro, specifying the name you would like to call it with
|
||||||
/// and optionally, an alias.. e.g. SELECT double(4); or SELECT twice(4);
|
/// and optionally, an alias.. e.g. SELECT double(4); or SELECT twice(4);
|
||||||
|
@ -98,7 +98,7 @@ fn double(&self, args: &[Value]) -> Value {
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
|
|
||||||
use limbo_ext::{register_extension, AggregateDerive, AggFunc, Value};
|
use turso_ext::{register_extension, AggregateDerive, AggFunc, Value};
|
||||||
/// annotate your struct with the AggregateDerive macro, and it must implement the below AggFunc trait
|
/// annotate your struct with the AggregateDerive macro, and it must implement the below AggFunc trait
|
||||||
#[derive(AggregateDerive)]
|
#[derive(AggregateDerive)]
|
||||||
struct Percentile;
|
struct Percentile;
|
||||||
|
@ -317,7 +317,7 @@ You can use the `Rc<Connection>` to query the same underlying connection that cr
|
||||||
**NOTE**: Requires 'vfs' feature enabled.
|
**NOTE**: Requires 'vfs' feature enabled.
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use limbo_ext::{ExtResult as Result, VfsDerive, VfsExtension, VfsFile};
|
use turso_ext::{ExtResult as Result, VfsDerive, VfsExtension, VfsFile};
|
||||||
|
|
||||||
/// Your struct must also impl Default
|
/// Your struct must also impl Default
|
||||||
#[derive(VfsDerive, Default)]
|
#[derive(VfsDerive, Default)]
|
||||||
|
@ -421,7 +421,7 @@ Edit the workspace `Cargo.toml` to include your extension as a workspace depende
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
turso_core = { path = "core", version = "0.0.17" }
|
turso_core = { path = "core", version = "0.0.17" }
|
||||||
limbo_crypto = { path = "extensions/crypto", version = "0.0.17" }
|
limbo_crypto = { path = "extensions/crypto", version = "0.0.17" }
|
||||||
limbo_ext = { path = "extensions/core", version = "0.0.17" }
|
turso_ext = { path = "extensions/core", version = "0.0.17" }
|
||||||
limbo_macros = { path = "macros", version = "0.0.17" }
|
limbo_macros = { path = "macros", version = "0.0.17" }
|
||||||
limbo_uuid = { path = "extensions/uuid", version = "0.0.17" }
|
limbo_uuid = { path = "extensions/uuid", version = "0.0.17" }
|
||||||
...
|
...
|
||||||
|
@ -448,7 +448,7 @@ Lastly, you have to register your extension statically in the core crate:
|
||||||
```diff
|
```diff
|
||||||
pub fn register_builtins(&self) -> Result<(), String> {
|
pub fn register_builtins(&self) -> Result<(), String> {
|
||||||
#[allow(unused_variables)]
|
#[allow(unused_variables)]
|
||||||
let ext_api = self.build_limbo_ext();
|
let ext_api = self.build_turso_ext();
|
||||||
#[cfg(feature = "uuid")]
|
#[cfg(feature = "uuid")]
|
||||||
if unsafe { !limbo_uuid::register_extension_static(&ext_api).is_ok() } {
|
if unsafe { !limbo_uuid::register_extension_static(&ext_api).is_ok() } {
|
||||||
return Err("Failed to register uuid extension".to_string());
|
return Err("Failed to register uuid extension".to_string());
|
||||||
|
|
|
@ -11,12 +11,12 @@ description = "Limbo crypto extension"
|
||||||
crate-type = ["cdylib", "lib"]
|
crate-type = ["cdylib", "lib"]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
static= [ "limbo_ext/static" ]
|
static= [ "turso_ext/static" ]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
blake3 = "1.5.5"
|
blake3 = "1.5.5"
|
||||||
data-encoding = "2.7.0"
|
data-encoding = "2.7.0"
|
||||||
limbo_ext = { workspace = true, features = ["static"] }
|
turso_ext = { workspace = true, features = ["static"] }
|
||||||
md5 = "0.7.0"
|
md5 = "0.7.0"
|
||||||
ring = "0.17.8"
|
ring = "0.17.8"
|
||||||
urlencoding = "2.1.3"
|
urlencoding = "2.1.3"
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
use crate::Error;
|
use crate::Error;
|
||||||
use blake3::Hasher;
|
use blake3::Hasher;
|
||||||
use data_encoding::{BASE32, BASE64, HEXLOWER};
|
use data_encoding::{BASE32, BASE64, HEXLOWER};
|
||||||
use limbo_ext::{Value, ValueType};
|
|
||||||
use ring::digest::{self, digest};
|
use ring::digest::{self, digest};
|
||||||
use std::{borrow::Cow, error::Error as StdError};
|
use std::{borrow::Cow, error::Error as StdError};
|
||||||
|
use turso_ext::{Value, ValueType};
|
||||||
|
|
||||||
pub fn sha256(data: &Value) -> Result<Vec<u8>, Error> {
|
pub fn sha256(data: &Value) -> Result<Vec<u8>, Error> {
|
||||||
match data.value_type() {
|
match data.value_type() {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crypto::{blake3, decode, encode, md5, sha1, sha256, sha384, sha512};
|
use crypto::{blake3, decode, encode, md5, sha1, sha256, sha384, sha512};
|
||||||
use limbo_ext::{register_extension, scalar, ResultCode, Value};
|
use turso_ext::{register_extension, scalar, ResultCode, Value};
|
||||||
|
|
||||||
mod crypto;
|
mod crypto;
|
||||||
|
|
||||||
|
|
|
@ -11,10 +11,10 @@ description = "Limbo CSV extension"
|
||||||
crate-type = ["cdylib", "lib"]
|
crate-type = ["cdylib", "lib"]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
static = ["limbo_ext/static"]
|
static = ["turso_ext/static"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
limbo_ext = { workspace = true, features = ["static"] }
|
turso_ext = { workspace = true, features = ["static"] }
|
||||||
csv = "1.3.1"
|
csv = "1.3.1"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
|
|
@ -20,13 +20,13 @@
|
||||||
//! accepts `yes`/`no`, `on`/`off`, `true`/`false`, or `1`/`0`
|
//! accepts `yes`/`no`, `on`/`off`, `true`/`false`, or `1`/`0`
|
||||||
//! - `columns` — number of columns
|
//! - `columns` — number of columns
|
||||||
//! - `schema` — optional custom SQL `CREATE TABLE` schema
|
//! - `schema` — optional custom SQL `CREATE TABLE` schema
|
||||||
use limbo_ext::{
|
|
||||||
register_extension, Connection, ConstraintInfo, IndexInfo, OrderByInfo, ResultCode, VTabCursor,
|
|
||||||
VTabKind, VTabModule, VTabModuleDerive, VTable, Value,
|
|
||||||
};
|
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{Read, Seek, SeekFrom};
|
use std::io::{Read, Seek, SeekFrom};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use turso_ext::{
|
||||||
|
register_extension, Connection, ConstraintInfo, IndexInfo, OrderByInfo, ResultCode, VTabCursor,
|
||||||
|
VTabKind, VTabModule, VTabModuleDerive, VTable, Value,
|
||||||
|
};
|
||||||
|
|
||||||
register_extension! {
|
register_extension! {
|
||||||
vtabs: { CsvVTabModule }
|
vtabs: { CsvVTabModule }
|
||||||
|
@ -392,9 +392,9 @@ impl VTabCursor for CsvCursor {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use limbo_ext::{Value, ValueType};
|
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use tempfile::NamedTempFile;
|
use tempfile::NamedTempFile;
|
||||||
|
use turso_ext::{Value, ValueType};
|
||||||
|
|
||||||
fn write_csv(content: &str) -> NamedTempFile {
|
fn write_csv(content: &str) -> NamedTempFile {
|
||||||
let mut tmp = NamedTempFile::new().expect("Failed to create temp file");
|
let mut tmp = NamedTempFile::new().expect("Failed to create temp file");
|
||||||
|
|
|
@ -11,10 +11,10 @@ description = "Limbo IPAddr extension"
|
||||||
crate-type = ["cdylib", "lib"]
|
crate-type = ["cdylib", "lib"]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
static= [ "limbo_ext/static" ]
|
static= [ "turso_ext/static" ]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
limbo_ext = { workspace = true, features = ["static"] }
|
turso_ext = { workspace = true, features = ["static"] }
|
||||||
ipnetwork = "0.21.1"
|
ipnetwork = "0.21.1"
|
||||||
|
|
||||||
[target.'cfg(not(target_family = "wasm"))'.dependencies]
|
[target.'cfg(not(target_family = "wasm"))'.dependencies]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use std::net::IpAddr;
|
use std::net::IpAddr;
|
||||||
|
|
||||||
use ipnetwork::IpNetwork;
|
use ipnetwork::IpNetwork;
|
||||||
use limbo_ext::{register_extension, scalar, ResultCode, Value};
|
use turso_ext::{register_extension, scalar, ResultCode, Value};
|
||||||
|
|
||||||
register_extension! {
|
register_extension! {
|
||||||
scalars: { ip_contains, ip_family, ip_host, ip_masklen, ip_network },
|
scalars: { ip_contains, ip_family, ip_host, ip_masklen, ip_network },
|
||||||
|
|
|
@ -11,10 +11,10 @@ description = "Limbo percentile extension"
|
||||||
crate-type = ["cdylib", "lib"]
|
crate-type = ["cdylib", "lib"]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
static = ["limbo_ext/static"]
|
static = ["turso_ext/static"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
limbo_ext = { workspace = true, features = ["static"] }
|
turso_ext = { workspace = true, features = ["static"] }
|
||||||
|
|
||||||
[target.'cfg(not(target_family = "wasm"))'.dependencies]
|
[target.'cfg(not(target_family = "wasm"))'.dependencies]
|
||||||
mimalloc = { version = "0.1", default-features = false }
|
mimalloc = { version = "0.1", default-features = false }
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use limbo_ext::{register_extension, AggFunc, AggregateDerive, Value};
|
use turso_ext::{register_extension, AggFunc, AggregateDerive, Value};
|
||||||
|
|
||||||
register_extension! {
|
register_extension! {
|
||||||
aggregates: { Median, Percentile, PercentileCont, PercentileDisc }
|
aggregates: { Median, Percentile, PercentileCont, PercentileDisc }
|
||||||
|
|
|
@ -8,7 +8,7 @@ repository.workspace = true
|
||||||
description = "Limbo regexp extension"
|
description = "Limbo regexp extension"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
static = ["limbo_ext/static"]
|
static = ["turso_ext/static"]
|
||||||
defaults = []
|
defaults = []
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
|
@ -16,7 +16,7 @@ crate-type = ["cdylib", "lib"]
|
||||||
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
limbo_ext = { workspace = true, features = ["static"] }
|
turso_ext = { workspace = true, features = ["static"] }
|
||||||
regex = "1.11.1"
|
regex = "1.11.1"
|
||||||
|
|
||||||
[target.'cfg(not(target_family = "wasm"))'.dependencies]
|
[target.'cfg(not(target_family = "wasm"))'.dependencies]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use limbo_ext::{register_extension, scalar, Value, ValueType};
|
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
use turso_ext::{register_extension, scalar, Value, ValueType};
|
||||||
|
|
||||||
register_extension! {
|
register_extension! {
|
||||||
scalars: { regexp, regexp_like, regexp_substr, regexp_replace }
|
scalars: { regexp, regexp_like, regexp_substr, regexp_replace }
|
||||||
|
|
|
@ -8,14 +8,14 @@ repository.workspace = true
|
||||||
description = "Limbo series extension"
|
description = "Limbo series extension"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
static = ["limbo_ext/static"]
|
static = ["turso_ext/static"]
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
crate-type = ["cdylib", "lib"]
|
crate-type = ["cdylib", "lib"]
|
||||||
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
limbo_ext = { workspace = true, features = ["static"] }
|
turso_ext = { workspace = true, features = ["static"] }
|
||||||
|
|
||||||
[target.'cfg(not(target_family = "wasm"))'.dependencies]
|
[target.'cfg(not(target_family = "wasm"))'.dependencies]
|
||||||
mimalloc = { version = "0.1", default-features = false }
|
mimalloc = { version = "0.1", default-features = false }
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use limbo_ext::{
|
use turso_ext::{
|
||||||
register_extension, Connection, ResultCode, VTabCursor, VTabKind, VTabModule, VTabModuleDerive,
|
register_extension, Connection, ResultCode, VTabCursor, VTabKind, VTabModule, VTabModuleDerive,
|
||||||
VTable, Value,
|
VTable, Value,
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[package]
|
[package]
|
||||||
name = "limbo_ext_tests"
|
name = "turso_ext_tests"
|
||||||
version.workspace = true
|
version.workspace = true
|
||||||
authors.workspace = true
|
authors.workspace = true
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
|
@ -11,12 +11,12 @@ description = "Limbo extension tests"
|
||||||
crate-type = ["cdylib", "lib"]
|
crate-type = ["cdylib", "lib"]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
static= [ "limbo_ext/static" ]
|
static= [ "turso_ext/static" ]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
env_logger = "0.11.6"
|
env_logger = "0.11.6"
|
||||||
lazy_static = "1.5.0"
|
lazy_static = "1.5.0"
|
||||||
limbo_ext = { workspace = true, features = ["static", "vfs"] }
|
turso_ext = { workspace = true, features = ["static", "vfs"] }
|
||||||
log = "0.4.26"
|
log = "0.4.26"
|
||||||
|
|
||||||
[target.'cfg(not(target_family = "wasm"))'.dependencies]
|
[target.'cfg(not(target_family = "wasm"))'.dependencies]
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use limbo_ext::{
|
|
||||||
register_extension, scalar, Connection, ConstraintInfo, ConstraintOp, ConstraintUsage,
|
|
||||||
ExtResult, IndexInfo, OrderByInfo, ResultCode, StepResult, VTabCursor, VTabKind, VTabModule,
|
|
||||||
VTabModuleDerive, VTable, Value,
|
|
||||||
};
|
|
||||||
#[cfg(not(target_family = "wasm"))]
|
|
||||||
use limbo_ext::{VfsDerive, VfsExtension, VfsFile};
|
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::fs::{File, OpenOptions};
|
use std::fs::{File, OpenOptions};
|
||||||
use std::io::{Read, Seek, SeekFrom, Write};
|
use std::io::{Read, Seek, SeekFrom, Write};
|
||||||
use std::num::NonZeroUsize;
|
use std::num::NonZeroUsize;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
use turso_ext::{
|
||||||
|
register_extension, scalar, Connection, ConstraintInfo, ConstraintOp, ConstraintUsage,
|
||||||
|
ExtResult, IndexInfo, OrderByInfo, ResultCode, StepResult, VTabCursor, VTabKind, VTabModule,
|
||||||
|
VTabModuleDerive, VTable, Value,
|
||||||
|
};
|
||||||
|
#[cfg(not(target_family = "wasm"))]
|
||||||
|
use turso_ext::{VfsDerive, VfsExtension, VfsFile};
|
||||||
|
|
||||||
register_extension! {
|
register_extension! {
|
||||||
vtabs: { KVStoreVTabModule, TableStatsVtabModule },
|
vtabs: { KVStoreVTabModule, TableStatsVtabModule },
|
||||||
|
@ -241,8 +241,8 @@ pub struct TestFS;
|
||||||
// Test that we can have additional extension types in the same file
|
// Test that we can have additional extension types in the same file
|
||||||
// and still register the vfs at comptime if linking staticly
|
// and still register the vfs at comptime if linking staticly
|
||||||
#[scalar(name = "test_scalar")]
|
#[scalar(name = "test_scalar")]
|
||||||
fn test_scalar(_args: limbo_ext::Value) -> limbo_ext::Value {
|
fn test_scalar(_args: turso_ext::Value) -> turso_ext::Value {
|
||||||
limbo_ext::Value::from_integer(42)
|
turso_ext::Value::from_integer(42)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(target_family = "wasm"))]
|
#[cfg(not(target_family = "wasm"))]
|
||||||
|
|
|
@ -11,14 +11,14 @@ description = "Limbo time extension"
|
||||||
crate-type = ["cdylib", "lib"]
|
crate-type = ["cdylib", "lib"]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
static = ["limbo_ext/static"]
|
static = ["turso_ext/static"]
|
||||||
|
|
||||||
[target.'cfg(not(target_family = "wasm"))'.dependencies]
|
[target.'cfg(not(target_family = "wasm"))'.dependencies]
|
||||||
mimalloc = { version = "0.1", default-features = false }
|
mimalloc = { version = "0.1", default-features = false }
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
chrono = "0.4.39"
|
chrono = "0.4.39"
|
||||||
limbo_ext = { workspace = true, features = ["static"] }
|
turso_ext = { workspace = true, features = ["static"] }
|
||||||
strum = "0.26.3"
|
strum = "0.26.3"
|
||||||
strum_macros = "0.26.3"
|
strum_macros = "0.26.3"
|
||||||
thiserror = "2.0.11"
|
thiserror = "2.0.11"
|
||||||
|
|
|
@ -2,10 +2,10 @@ use std::str::FromStr as _;
|
||||||
|
|
||||||
use chrono::prelude::*;
|
use chrono::prelude::*;
|
||||||
use core::cmp::Ordering;
|
use core::cmp::Ordering;
|
||||||
use limbo_ext::ValueType;
|
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
use turso_ext::ValueType;
|
||||||
|
|
||||||
use limbo_ext::{register_extension, scalar, ResultCode, Value};
|
use turso_ext::{register_extension, scalar, ResultCode, Value};
|
||||||
|
|
||||||
mod time;
|
mod time;
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ use std::ops::{Deref, Sub};
|
||||||
use chrono::{self, DateTime, Timelike, Utc};
|
use chrono::{self, DateTime, Timelike, Utc};
|
||||||
use chrono::{prelude::*, DurationRound};
|
use chrono::{prelude::*, DurationRound};
|
||||||
|
|
||||||
use limbo_ext::Value;
|
use turso_ext::Value;
|
||||||
|
|
||||||
use crate::{Result, TimeError};
|
use crate::{Result, TimeError};
|
||||||
|
|
||||||
|
|
|
@ -11,10 +11,10 @@ description = "Limbo UUID extension"
|
||||||
crate-type = ["cdylib", "lib"]
|
crate-type = ["cdylib", "lib"]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
static= [ "limbo_ext/static" ]
|
static= [ "turso_ext/static" ]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
limbo_ext = { workspace = true, features = ["static"] }
|
turso_ext = { workspace = true, features = ["static"] }
|
||||||
uuid = { version = "1.11.0", features = ["v4", "v7"] }
|
uuid = { version = "1.11.0", features = ["v4", "v7"] }
|
||||||
|
|
||||||
[target.'cfg(not(target_family = "wasm"))'.dependencies]
|
[target.'cfg(not(target_family = "wasm"))'.dependencies]
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use limbo_ext::{register_extension, scalar, ResultCode, Value, ValueType};
|
use turso_ext::{register_extension, scalar, ResultCode, Value, ValueType};
|
||||||
|
|
||||||
register_extension! {
|
register_extension! {
|
||||||
scalars: {uuid4_str, uuid4_blob, uuid7_str, uuid7, uuid7_ts, uuid_str, uuid_blob },
|
scalars: {uuid4_str, uuid4_blob, uuid7_str, uuid7, uuid7_ts, uuid_str, uuid_blob },
|
||||||
|
|
26
fuzz/Cargo.lock
generated
26
fuzz/Cargo.lock
generated
|
@ -564,21 +564,12 @@ dependencies = [
|
||||||
"turso_core",
|
"turso_core",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "limbo_ext"
|
|
||||||
version = "0.1.0-pre.2"
|
|
||||||
dependencies = [
|
|
||||||
"chrono",
|
|
||||||
"getrandom 0.3.1",
|
|
||||||
"turso_macros",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "limbo_series"
|
name = "limbo_series"
|
||||||
version = "0.1.0-pre.2"
|
version = "0.1.0-pre.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"limbo_ext",
|
|
||||||
"mimalloc",
|
"mimalloc",
|
||||||
|
"turso_ext",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -605,19 +596,19 @@ name = "limbo_time"
|
||||||
version = "0.1.0-pre.2"
|
version = "0.1.0-pre.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"limbo_ext",
|
|
||||||
"mimalloc",
|
"mimalloc",
|
||||||
"strum",
|
"strum",
|
||||||
"strum_macros",
|
"strum_macros",
|
||||||
"thiserror 2.0.12",
|
"thiserror 2.0.12",
|
||||||
|
"turso_ext",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "limbo_uuid"
|
name = "limbo_uuid"
|
||||||
version = "0.1.0-pre.2"
|
version = "0.1.0-pre.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"limbo_ext",
|
|
||||||
"mimalloc",
|
"mimalloc",
|
||||||
|
"turso_ext",
|
||||||
"uuid",
|
"uuid",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1145,7 +1136,6 @@ dependencies = [
|
||||||
"julian_day_converter",
|
"julian_day_converter",
|
||||||
"libloading",
|
"libloading",
|
||||||
"libm",
|
"libm",
|
||||||
"limbo_ext",
|
|
||||||
"limbo_series",
|
"limbo_series",
|
||||||
"limbo_sqlite3_parser",
|
"limbo_sqlite3_parser",
|
||||||
"limbo_time",
|
"limbo_time",
|
||||||
|
@ -1164,10 +1154,20 @@ dependencies = [
|
||||||
"strum_macros",
|
"strum_macros",
|
||||||
"thiserror 1.0.69",
|
"thiserror 1.0.69",
|
||||||
"tracing",
|
"tracing",
|
||||||
|
"turso_ext",
|
||||||
"turso_macros",
|
"turso_macros",
|
||||||
"uncased",
|
"uncased",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "turso_ext"
|
||||||
|
version = "0.1.0-pre.2"
|
||||||
|
dependencies = [
|
||||||
|
"chrono",
|
||||||
|
"getrandom 0.3.1",
|
||||||
|
"turso_macros",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "turso_macros"
|
name = "turso_macros"
|
||||||
version = "0.1.0-pre.2"
|
version = "0.1.0-pre.2"
|
||||||
|
|
|
@ -15,9 +15,9 @@ pub fn derive_agg_func(input: TokenStream) -> TokenStream {
|
||||||
let expanded = quote! {
|
let expanded = quote! {
|
||||||
impl #struct_name {
|
impl #struct_name {
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn #init_fn_name() -> *mut ::limbo_ext::AggCtx {
|
pub extern "C" fn #init_fn_name() -> *mut ::turso_ext::AggCtx {
|
||||||
let state = ::std::boxed::Box::new(<#struct_name as ::limbo_ext::AggFunc>::State::default());
|
let state = ::std::boxed::Box::new(<#struct_name as ::turso_ext::AggFunc>::State::default());
|
||||||
let ctx = ::std::boxed::Box::new(::limbo_ext::AggCtx {
|
let ctx = ::std::boxed::Box::new(::turso_ext::AggCtx {
|
||||||
state: ::std::boxed::Box::into_raw(state) as *mut ::std::os::raw::c_void,
|
state: ::std::boxed::Box::into_raw(state) as *mut ::std::os::raw::c_void,
|
||||||
});
|
});
|
||||||
::std::boxed::Box::into_raw(ctx)
|
::std::boxed::Box::into_raw(ctx)
|
||||||
|
@ -25,29 +25,29 @@ pub fn derive_agg_func(input: TokenStream) -> TokenStream {
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn #step_fn_name(
|
pub extern "C" fn #step_fn_name(
|
||||||
ctx: *mut ::limbo_ext::AggCtx,
|
ctx: *mut ::turso_ext::AggCtx,
|
||||||
argc: i32,
|
argc: i32,
|
||||||
argv: *const ::limbo_ext::Value,
|
argv: *const ::turso_ext::Value,
|
||||||
) {
|
) {
|
||||||
unsafe {
|
unsafe {
|
||||||
let ctx = &mut *ctx;
|
let ctx = &mut *ctx;
|
||||||
let state = &mut *(ctx.state as *mut <#struct_name as ::limbo_ext::AggFunc>::State);
|
let state = &mut *(ctx.state as *mut <#struct_name as ::turso_ext::AggFunc>::State);
|
||||||
let args = ::std::slice::from_raw_parts(argv, argc as usize);
|
let args = ::std::slice::from_raw_parts(argv, argc as usize);
|
||||||
<#struct_name as ::limbo_ext::AggFunc>::step(state, args);
|
<#struct_name as ::turso_ext::AggFunc>::step(state, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn #finalize_fn_name(
|
pub extern "C" fn #finalize_fn_name(
|
||||||
ctx: *mut ::limbo_ext::AggCtx
|
ctx: *mut ::turso_ext::AggCtx
|
||||||
) -> ::limbo_ext::Value {
|
) -> ::turso_ext::Value {
|
||||||
unsafe {
|
unsafe {
|
||||||
let ctx = &mut *ctx;
|
let ctx = &mut *ctx;
|
||||||
let state = ::std::boxed::Box::from_raw(ctx.state as *mut <#struct_name as ::limbo_ext::AggFunc>::State);
|
let state = ::std::boxed::Box::from_raw(ctx.state as *mut <#struct_name as ::turso_ext::AggFunc>::State);
|
||||||
match <#struct_name as ::limbo_ext::AggFunc>::finalize(*state) {
|
match <#struct_name as ::turso_ext::AggFunc>::finalize(*state) {
|
||||||
Ok(val) => val,
|
Ok(val) => val,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
::limbo_ext::Value::error_with_message(e.to_string())
|
::turso_ext::Value::error_with_message(e.to_string())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,17 +55,17 @@ pub fn derive_agg_func(input: TokenStream) -> TokenStream {
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn #register_fn_name(
|
pub unsafe extern "C" fn #register_fn_name(
|
||||||
api: *const ::limbo_ext::ExtensionApi
|
api: *const ::turso_ext::ExtensionApi
|
||||||
) -> ::limbo_ext::ResultCode {
|
) -> ::turso_ext::ResultCode {
|
||||||
if api.is_null() {
|
if api.is_null() {
|
||||||
return ::limbo_ext::ResultCode::Error;
|
return ::turso_ext::ResultCode::Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
let api = &*api;
|
let api = &*api;
|
||||||
let name_str = #struct_name::NAME;
|
let name_str = #struct_name::NAME;
|
||||||
let c_name = match ::std::ffi::CString::new(name_str) {
|
let c_name = match ::std::ffi::CString::new(name_str) {
|
||||||
Ok(cname) => cname,
|
Ok(cname) => cname,
|
||||||
Err(_) => return ::limbo_ext::ResultCode::Error,
|
Err(_) => return ::turso_ext::ResultCode::Error,
|
||||||
};
|
};
|
||||||
|
|
||||||
(api.register_aggregate_function)(
|
(api.register_aggregate_function)(
|
||||||
|
@ -73,11 +73,11 @@ pub fn derive_agg_func(input: TokenStream) -> TokenStream {
|
||||||
c_name.as_ptr(),
|
c_name.as_ptr(),
|
||||||
#struct_name::ARGS,
|
#struct_name::ARGS,
|
||||||
#struct_name::#init_fn_name
|
#struct_name::#init_fn_name
|
||||||
as ::limbo_ext::InitAggFunction,
|
as ::turso_ext::InitAggFunction,
|
||||||
#struct_name::#step_fn_name
|
#struct_name::#step_fn_name
|
||||||
as ::limbo_ext::StepFunction,
|
as ::turso_ext::StepFunction,
|
||||||
#struct_name::#finalize_fn_name
|
#struct_name::#finalize_fn_name
|
||||||
as ::limbo_ext::FinalizeFunction,
|
as ::turso_ext::FinalizeFunction,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ pub fn register_extension(input: TokenStream) -> TokenStream {
|
||||||
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
|
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
|
||||||
|
|
||||||
#[cfg(feature = "static")]
|
#[cfg(feature = "static")]
|
||||||
pub unsafe extern "C" fn register_extension_static(api: &mut ::limbo_ext::ExtensionApi) -> ::limbo_ext::ResultCode {
|
pub unsafe extern "C" fn register_extension_static(api: &mut ::turso_ext::ExtensionApi) -> ::turso_ext::ResultCode {
|
||||||
#(#static_scalars)*
|
#(#static_scalars)*
|
||||||
|
|
||||||
#(#static_aggregates)*
|
#(#static_aggregates)*
|
||||||
|
@ -101,12 +101,12 @@ pub fn register_extension(input: TokenStream) -> TokenStream {
|
||||||
#[cfg(not(target_family = "wasm"))]
|
#[cfg(not(target_family = "wasm"))]
|
||||||
#(#static_vfs)*
|
#(#static_vfs)*
|
||||||
|
|
||||||
::limbo_ext::ResultCode::OK
|
::turso_ext::ResultCode::OK
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "static"))]
|
#[cfg(not(feature = "static"))]
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn register_extension(api: &::limbo_ext::ExtensionApi) -> ::limbo_ext::ResultCode {
|
pub unsafe extern "C" fn register_extension(api: &::turso_ext::ExtensionApi) -> ::turso_ext::ResultCode {
|
||||||
#(#scalar_calls)*
|
#(#scalar_calls)*
|
||||||
|
|
||||||
#(#aggregate_calls)*
|
#(#aggregate_calls)*
|
||||||
|
@ -115,7 +115,7 @@ pub fn register_extension(input: TokenStream) -> TokenStream {
|
||||||
|
|
||||||
#(#vfs_calls)*
|
#(#vfs_calls)*
|
||||||
|
|
||||||
::limbo_ext::ResultCode::OK
|
::turso_ext::ResultCode::OK
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ pub fn scalar(attr: TokenStream, input: TokenStream) -> TokenStream {
|
||||||
let alias_check = if let Some(alias) = &scalar_info.alias {
|
let alias_check = if let Some(alias) = &scalar_info.alias {
|
||||||
quote! {
|
quote! {
|
||||||
let Ok(alias_c_name) = ::std::ffi::CString::new(#alias) else {
|
let Ok(alias_c_name) = ::std::ffi::CString::new(#alias) else {
|
||||||
return ::limbo_ext::ResultCode::Error;
|
return ::turso_ext::ResultCode::Error;
|
||||||
};
|
};
|
||||||
(api.register_scalar_function)(
|
(api.register_scalar_function)(
|
||||||
api.ctx,
|
api.ctx,
|
||||||
|
@ -38,14 +38,14 @@ pub fn scalar(attr: TokenStream, input: TokenStream) -> TokenStream {
|
||||||
let expanded = quote! {
|
let expanded = quote! {
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn #register_fn_name(
|
pub unsafe extern "C" fn #register_fn_name(
|
||||||
api: *const ::limbo_ext::ExtensionApi
|
api: *const ::turso_ext::ExtensionApi
|
||||||
) -> ::limbo_ext::ResultCode {
|
) -> ::turso_ext::ResultCode {
|
||||||
if api.is_null() {
|
if api.is_null() {
|
||||||
return ::limbo_ext::ResultCode::Error;
|
return ::turso_ext::ResultCode::Error;
|
||||||
}
|
}
|
||||||
let api = unsafe { &*api };
|
let api = unsafe { &*api };
|
||||||
let Ok(c_name) = ::std::ffi::CString::new(#name) else {
|
let Ok(c_name) = ::std::ffi::CString::new(#name) else {
|
||||||
return ::limbo_ext::ResultCode::Error;
|
return ::turso_ext::ResultCode::Error;
|
||||||
};
|
};
|
||||||
(api.register_scalar_function)(
|
(api.register_scalar_function)(
|
||||||
api.ctx,
|
api.ctx,
|
||||||
|
@ -53,14 +53,14 @@ pub fn scalar(attr: TokenStream, input: TokenStream) -> TokenStream {
|
||||||
#fn_name,
|
#fn_name,
|
||||||
);
|
);
|
||||||
#alias_check
|
#alias_check
|
||||||
::limbo_ext::ResultCode::OK
|
::turso_ext::ResultCode::OK
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn #fn_name(
|
pub unsafe extern "C" fn #fn_name(
|
||||||
argc: i32,
|
argc: i32,
|
||||||
argv: *const ::limbo_ext::Value
|
argv: *const ::turso_ext::Value
|
||||||
) -> ::limbo_ext::Value {
|
) -> ::turso_ext::Value {
|
||||||
let #args_variable_name = if argv.is_null() || argc <= 0 {
|
let #args_variable_name = if argv.is_null() || argc <= 0 {
|
||||||
&[]
|
&[]
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -21,11 +21,11 @@ pub fn derive_vfs_module(input: TokenStream) -> TokenStream {
|
||||||
|
|
||||||
let expanded = quote! {
|
let expanded = quote! {
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub unsafe extern "C" fn #register_static() -> *const ::limbo_ext::VfsImpl {
|
pub unsafe extern "C" fn #register_static() -> *const ::turso_ext::VfsImpl {
|
||||||
let ctx = #struct_name::default();
|
let ctx = #struct_name::default();
|
||||||
let ctx = ::std::boxed::Box::into_raw(::std::boxed::Box::new(ctx)) as *const ::std::ffi::c_void;
|
let ctx = ::std::boxed::Box::into_raw(::std::boxed::Box::new(ctx)) as *const ::std::ffi::c_void;
|
||||||
let name = ::std::ffi::CString::new(<#struct_name as ::limbo_ext::VfsExtension>::NAME).unwrap().into_raw();
|
let name = ::std::ffi::CString::new(<#struct_name as ::turso_ext::VfsExtension>::NAME).unwrap().into_raw();
|
||||||
let vfs_mod = ::limbo_ext::VfsImpl {
|
let vfs_mod = ::turso_ext::VfsImpl {
|
||||||
vfs: ctx,
|
vfs: ctx,
|
||||||
name,
|
name,
|
||||||
open: #open_fn_name,
|
open: #open_fn_name,
|
||||||
|
@ -40,15 +40,15 @@ pub fn derive_vfs_module(input: TokenStream) -> TokenStream {
|
||||||
gen_random_number: #generate_random_number_fn_name,
|
gen_random_number: #generate_random_number_fn_name,
|
||||||
current_time: #get_current_time_fn_name,
|
current_time: #get_current_time_fn_name,
|
||||||
};
|
};
|
||||||
::std::boxed::Box::into_raw(::std::boxed::Box::new(vfs_mod)) as *const ::limbo_ext::VfsImpl
|
::std::boxed::Box::into_raw(::std::boxed::Box::new(vfs_mod)) as *const ::turso_ext::VfsImpl
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn #register_fn_name(api: &::limbo_ext::ExtensionApi) -> ::limbo_ext::ResultCode {
|
pub unsafe extern "C" fn #register_fn_name(api: &::turso_ext::ExtensionApi) -> ::turso_ext::ResultCode {
|
||||||
let ctx = #struct_name::default();
|
let ctx = #struct_name::default();
|
||||||
let ctx = ::std::boxed::Box::into_raw(::std::boxed::Box::new(ctx)) as *const ::std::ffi::c_void;
|
let ctx = ::std::boxed::Box::into_raw(::std::boxed::Box::new(ctx)) as *const ::std::ffi::c_void;
|
||||||
let name = ::std::ffi::CString::new(<#struct_name as ::limbo_ext::VfsExtension>::NAME).unwrap().into_raw();
|
let name = ::std::ffi::CString::new(<#struct_name as ::turso_ext::VfsExtension>::NAME).unwrap().into_raw();
|
||||||
let vfs_mod = ::limbo_ext::VfsImpl {
|
let vfs_mod = ::turso_ext::VfsImpl {
|
||||||
vfs: ctx,
|
vfs: ctx,
|
||||||
name,
|
name,
|
||||||
open: #open_fn_name,
|
open: #open_fn_name,
|
||||||
|
@ -63,7 +63,7 @@ pub fn derive_vfs_module(input: TokenStream) -> TokenStream {
|
||||||
gen_random_number: #generate_random_number_fn_name,
|
gen_random_number: #generate_random_number_fn_name,
|
||||||
current_time: #get_current_time_fn_name,
|
current_time: #get_current_time_fn_name,
|
||||||
};
|
};
|
||||||
let vfsimpl = ::std::boxed::Box::into_raw(::std::boxed::Box::new(vfs_mod)) as *const ::limbo_ext::VfsImpl;
|
let vfsimpl = ::std::boxed::Box::into_raw(::std::boxed::Box::new(vfs_mod)) as *const ::turso_ext::VfsImpl;
|
||||||
(api.vfs_interface.register_vfs)(name, vfsimpl)
|
(api.vfs_interface.register_vfs)(name, vfsimpl)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,36 +74,36 @@ pub fn derive_vfs_module(input: TokenStream) -> TokenStream {
|
||||||
flags: i32,
|
flags: i32,
|
||||||
direct: bool,
|
direct: bool,
|
||||||
) -> *const ::std::ffi::c_void {
|
) -> *const ::std::ffi::c_void {
|
||||||
let ctx = &*(ctx as *const ::limbo_ext::VfsImpl);
|
let ctx = &*(ctx as *const ::turso_ext::VfsImpl);
|
||||||
let Ok(path_str) = ::std::ffi::CStr::from_ptr(path).to_str() else {
|
let Ok(path_str) = ::std::ffi::CStr::from_ptr(path).to_str() else {
|
||||||
return ::std::ptr::null_mut();
|
return ::std::ptr::null_mut();
|
||||||
};
|
};
|
||||||
let vfs = &*(ctx.vfs as *const #struct_name);
|
let vfs = &*(ctx.vfs as *const #struct_name);
|
||||||
let Ok(file_handle) = <#struct_name as ::limbo_ext::VfsExtension>::open_file(vfs, path_str, flags, direct) else {
|
let Ok(file_handle) = <#struct_name as ::turso_ext::VfsExtension>::open_file(vfs, path_str, flags, direct) else {
|
||||||
return ::std::ptr::null();
|
return ::std::ptr::null();
|
||||||
};
|
};
|
||||||
let boxed = ::std::boxed::Box::into_raw(::std::boxed::Box::new(file_handle)) as *const ::std::ffi::c_void;
|
let boxed = ::std::boxed::Box::into_raw(::std::boxed::Box::new(file_handle)) as *const ::std::ffi::c_void;
|
||||||
let Ok(vfs_file) = ::limbo_ext::VfsFileImpl::new(boxed, ctx) else {
|
let Ok(vfs_file) = ::turso_ext::VfsFileImpl::new(boxed, ctx) else {
|
||||||
return ::std::ptr::null();
|
return ::std::ptr::null();
|
||||||
};
|
};
|
||||||
::std::boxed::Box::into_raw(::std::boxed::Box::new(vfs_file)) as *const ::std::ffi::c_void
|
::std::boxed::Box::into_raw(::std::boxed::Box::new(vfs_file)) as *const ::std::ffi::c_void
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn #close_fn_name(file_ptr: *const ::std::ffi::c_void) -> ::limbo_ext::ResultCode {
|
pub unsafe extern "C" fn #close_fn_name(file_ptr: *const ::std::ffi::c_void) -> ::turso_ext::ResultCode {
|
||||||
if file_ptr.is_null() {
|
if file_ptr.is_null() {
|
||||||
return ::limbo_ext::ResultCode::Error;
|
return ::turso_ext::ResultCode::Error;
|
||||||
}
|
}
|
||||||
let vfs_file: &mut ::limbo_ext::VfsFileImpl = &mut *(file_ptr as *mut ::limbo_ext::VfsFileImpl);
|
let vfs_file: &mut ::turso_ext::VfsFileImpl = &mut *(file_ptr as *mut ::turso_ext::VfsFileImpl);
|
||||||
let vfs_instance = &*(vfs_file.vfs as *const #struct_name);
|
let vfs_instance = &*(vfs_file.vfs as *const #struct_name);
|
||||||
|
|
||||||
// this time we need to own it so we can drop it
|
// this time we need to own it so we can drop it
|
||||||
let file: ::std::boxed::Box<<#struct_name as ::limbo_ext::VfsExtension>::File> =
|
let file: ::std::boxed::Box<<#struct_name as ::turso_ext::VfsExtension>::File> =
|
||||||
::std::boxed::Box::from_raw(vfs_file.file as *mut <#struct_name as ::limbo_ext::VfsExtension>::File);
|
::std::boxed::Box::from_raw(vfs_file.file as *mut <#struct_name as ::turso_ext::VfsExtension>::File);
|
||||||
if let Err(e) = <#struct_name as ::limbo_ext::VfsExtension>::close(vfs_instance, *file) {
|
if let Err(e) = <#struct_name as ::turso_ext::VfsExtension>::close(vfs_instance, *file) {
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
::limbo_ext::ResultCode::OK
|
::turso_ext::ResultCode::OK
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
@ -111,25 +111,25 @@ pub fn derive_vfs_module(input: TokenStream) -> TokenStream {
|
||||||
if file_ptr.is_null() {
|
if file_ptr.is_null() {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
let vfs_file: &mut ::limbo_ext::VfsFileImpl = &mut *(file_ptr as *mut ::limbo_ext::VfsFileImpl);
|
let vfs_file: &mut ::turso_ext::VfsFileImpl = &mut *(file_ptr as *mut ::turso_ext::VfsFileImpl);
|
||||||
let file: &mut <#struct_name as ::limbo_ext::VfsExtension>::File =
|
let file: &mut <#struct_name as ::turso_ext::VfsExtension>::File =
|
||||||
&mut *(vfs_file.file as *mut <#struct_name as ::limbo_ext::VfsExtension>::File);
|
&mut *(vfs_file.file as *mut <#struct_name as ::turso_ext::VfsExtension>::File);
|
||||||
match <#struct_name as ::limbo_ext::VfsExtension>::File::read(file, ::std::slice::from_raw_parts_mut(buf, count), count, offset) {
|
match <#struct_name as ::turso_ext::VfsExtension>::File::read(file, ::std::slice::from_raw_parts_mut(buf, count), count, offset) {
|
||||||
Ok(n) => n,
|
Ok(n) => n,
|
||||||
Err(_) => -1,
|
Err(_) => -1,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn #run_once_fn_name(ctx: *const ::std::ffi::c_void) -> ::limbo_ext::ResultCode {
|
pub unsafe extern "C" fn #run_once_fn_name(ctx: *const ::std::ffi::c_void) -> ::turso_ext::ResultCode {
|
||||||
if ctx.is_null() {
|
if ctx.is_null() {
|
||||||
return ::limbo_ext::ResultCode::Error;
|
return ::turso_ext::ResultCode::Error;
|
||||||
}
|
}
|
||||||
let ctx = &mut *(ctx as *mut #struct_name);
|
let ctx = &mut *(ctx as *mut #struct_name);
|
||||||
if let Err(e) = <#struct_name as ::limbo_ext::VfsExtension>::run_once(ctx) {
|
if let Err(e) = <#struct_name as ::turso_ext::VfsExtension>::run_once(ctx) {
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
::limbo_ext::ResultCode::OK
|
::turso_ext::ResultCode::OK
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
@ -137,41 +137,41 @@ pub fn derive_vfs_module(input: TokenStream) -> TokenStream {
|
||||||
if file_ptr.is_null() {
|
if file_ptr.is_null() {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
let vfs_file: &mut ::limbo_ext::VfsFileImpl = &mut *(file_ptr as *mut ::limbo_ext::VfsFileImpl);
|
let vfs_file: &mut ::turso_ext::VfsFileImpl = &mut *(file_ptr as *mut ::turso_ext::VfsFileImpl);
|
||||||
let file: &mut <#struct_name as ::limbo_ext::VfsExtension>::File =
|
let file: &mut <#struct_name as ::turso_ext::VfsExtension>::File =
|
||||||
&mut *(vfs_file.file as *mut <#struct_name as ::limbo_ext::VfsExtension>::File);
|
&mut *(vfs_file.file as *mut <#struct_name as ::turso_ext::VfsExtension>::File);
|
||||||
match <#struct_name as ::limbo_ext::VfsExtension>::File::write(file, ::std::slice::from_raw_parts(buf, count), count, offset) {
|
match <#struct_name as ::turso_ext::VfsExtension>::File::write(file, ::std::slice::from_raw_parts(buf, count), count, offset) {
|
||||||
Ok(n) => n,
|
Ok(n) => n,
|
||||||
Err(_) => -1,
|
Err(_) => -1,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn #lock_fn_name(file_ptr: *const ::std::ffi::c_void, exclusive: bool) -> ::limbo_ext::ResultCode {
|
pub unsafe extern "C" fn #lock_fn_name(file_ptr: *const ::std::ffi::c_void, exclusive: bool) -> ::turso_ext::ResultCode {
|
||||||
if file_ptr.is_null() {
|
if file_ptr.is_null() {
|
||||||
return ::limbo_ext::ResultCode::Error;
|
return ::turso_ext::ResultCode::Error;
|
||||||
}
|
}
|
||||||
let vfs_file: &mut ::limbo_ext::VfsFileImpl = &mut *(file_ptr as *mut ::limbo_ext::VfsFileImpl);
|
let vfs_file: &mut ::turso_ext::VfsFileImpl = &mut *(file_ptr as *mut ::turso_ext::VfsFileImpl);
|
||||||
let file: &mut <#struct_name as ::limbo_ext::VfsExtension>::File =
|
let file: &mut <#struct_name as ::turso_ext::VfsExtension>::File =
|
||||||
&mut *(vfs_file.file as *mut <#struct_name as ::limbo_ext::VfsExtension>::File);
|
&mut *(vfs_file.file as *mut <#struct_name as ::turso_ext::VfsExtension>::File);
|
||||||
if let Err(e) = <#struct_name as ::limbo_ext::VfsExtension>::File::lock(file, exclusive) {
|
if let Err(e) = <#struct_name as ::turso_ext::VfsExtension>::File::lock(file, exclusive) {
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
::limbo_ext::ResultCode::OK
|
::turso_ext::ResultCode::OK
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn #unlock_fn_name(file_ptr: *const ::std::ffi::c_void) -> ::limbo_ext::ResultCode {
|
pub unsafe extern "C" fn #unlock_fn_name(file_ptr: *const ::std::ffi::c_void) -> ::turso_ext::ResultCode {
|
||||||
if file_ptr.is_null() {
|
if file_ptr.is_null() {
|
||||||
return ::limbo_ext::ResultCode::Error;
|
return ::turso_ext::ResultCode::Error;
|
||||||
}
|
}
|
||||||
let vfs_file: &mut ::limbo_ext::VfsFileImpl = &mut *(file_ptr as *mut ::limbo_ext::VfsFileImpl);
|
let vfs_file: &mut ::turso_ext::VfsFileImpl = &mut *(file_ptr as *mut ::turso_ext::VfsFileImpl);
|
||||||
let file: &mut <#struct_name as ::limbo_ext::VfsExtension>::File =
|
let file: &mut <#struct_name as ::turso_ext::VfsExtension>::File =
|
||||||
&mut *(vfs_file.file as *mut <#struct_name as ::limbo_ext::VfsExtension>::File);
|
&mut *(vfs_file.file as *mut <#struct_name as ::turso_ext::VfsExtension>::File);
|
||||||
if let Err(e) = <#struct_name as ::limbo_ext::VfsExtension>::File::unlock(file) {
|
if let Err(e) = <#struct_name as ::turso_ext::VfsExtension>::File::unlock(file) {
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
::limbo_ext::ResultCode::OK
|
::turso_ext::ResultCode::OK
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
@ -179,10 +179,10 @@ pub fn derive_vfs_module(input: TokenStream) -> TokenStream {
|
||||||
if file_ptr.is_null() {
|
if file_ptr.is_null() {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
let vfs_file: &mut ::limbo_ext::VfsFileImpl = &mut *(file_ptr as *mut ::limbo_ext::VfsFileImpl);
|
let vfs_file: &mut ::turso_ext::VfsFileImpl = &mut *(file_ptr as *mut ::turso_ext::VfsFileImpl);
|
||||||
let file: &mut <#struct_name as ::limbo_ext::VfsExtension>::File =
|
let file: &mut <#struct_name as ::turso_ext::VfsExtension>::File =
|
||||||
&mut *(vfs_file.file as *mut <#struct_name as ::limbo_ext::VfsExtension>::File);
|
&mut *(vfs_file.file as *mut <#struct_name as ::turso_ext::VfsExtension>::File);
|
||||||
if <#struct_name as ::limbo_ext::VfsExtension>::File::sync(file).is_err() {
|
if <#struct_name as ::turso_ext::VfsExtension>::File::sync(file).is_err() {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
0
|
0
|
||||||
|
@ -193,22 +193,22 @@ pub fn derive_vfs_module(input: TokenStream) -> TokenStream {
|
||||||
if file_ptr.is_null() {
|
if file_ptr.is_null() {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
let vfs_file: &mut ::limbo_ext::VfsFileImpl = &mut *(file_ptr as *mut ::limbo_ext::VfsFileImpl);
|
let vfs_file: &mut ::turso_ext::VfsFileImpl = &mut *(file_ptr as *mut ::turso_ext::VfsFileImpl);
|
||||||
let file: &mut <#struct_name as ::limbo_ext::VfsExtension>::File =
|
let file: &mut <#struct_name as ::turso_ext::VfsExtension>::File =
|
||||||
&mut *(vfs_file.file as *mut <#struct_name as ::limbo_ext::VfsExtension>::File);
|
&mut *(vfs_file.file as *mut <#struct_name as ::turso_ext::VfsExtension>::File);
|
||||||
<#struct_name as ::limbo_ext::VfsExtension>::File::size(file)
|
<#struct_name as ::turso_ext::VfsExtension>::File::size(file)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn #generate_random_number_fn_name() -> i64 {
|
pub unsafe extern "C" fn #generate_random_number_fn_name() -> i64 {
|
||||||
let obj = #struct_name::default();
|
let obj = #struct_name::default();
|
||||||
<#struct_name as ::limbo_ext::VfsExtension>::generate_random_number(&obj)
|
<#struct_name as ::turso_ext::VfsExtension>::generate_random_number(&obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn #get_current_time_fn_name() -> *const ::std::ffi::c_char {
|
pub unsafe extern "C" fn #get_current_time_fn_name() -> *const ::std::ffi::c_char {
|
||||||
let obj = #struct_name::default();
|
let obj = #struct_name::default();
|
||||||
let time = <#struct_name as ::limbo_ext::VfsExtension>::get_current_time(&obj);
|
let time = <#struct_name as ::turso_ext::VfsExtension>::get_current_time(&obj);
|
||||||
// release ownership of the string to core
|
// release ownership of the string to core
|
||||||
::std::ffi::CString::new(time).unwrap().into_raw() as *const ::std::ffi::c_char
|
::std::ffi::CString::new(time).unwrap().into_raw() as *const ::std::ffi::c_char
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,23 +23,23 @@ pub fn derive_vtab_module(input: TokenStream) -> TokenStream {
|
||||||
impl #struct_name {
|
impl #struct_name {
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
unsafe extern "C" fn #create_fn_name(
|
unsafe extern "C" fn #create_fn_name(
|
||||||
argv: *const ::limbo_ext::Value, argc: i32
|
argv: *const ::turso_ext::Value, argc: i32
|
||||||
) -> ::limbo_ext::VTabCreateResult {
|
) -> ::turso_ext::VTabCreateResult {
|
||||||
let args = if argv.is_null() {
|
let args = if argv.is_null() {
|
||||||
&Vec::new()
|
&Vec::new()
|
||||||
} else {
|
} else {
|
||||||
::std::slice::from_raw_parts(argv, argc as usize)
|
::std::slice::from_raw_parts(argv, argc as usize)
|
||||||
};
|
};
|
||||||
match <#struct_name as ::limbo_ext::VTabModule>::create(&args) {
|
match <#struct_name as ::turso_ext::VTabModule>::create(&args) {
|
||||||
Ok((schema, table)) => {
|
Ok((schema, table)) => {
|
||||||
::limbo_ext::VTabCreateResult {
|
::turso_ext::VTabCreateResult {
|
||||||
code: ::limbo_ext::ResultCode::OK,
|
code: ::turso_ext::ResultCode::OK,
|
||||||
schema: ::std::ffi::CString::new(schema).unwrap().into_raw(),
|
schema: ::std::ffi::CString::new(schema).unwrap().into_raw(),
|
||||||
table: ::std::boxed::Box::into_raw(::std::boxed::Box::new(table)) as *const ::std::ffi::c_void,
|
table: ::std::boxed::Box::into_raw(::std::boxed::Box::new(table)) as *const ::std::ffi::c_void,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
::limbo_ext::VTabCreateResult {
|
::turso_ext::VTabCreateResult {
|
||||||
code: e,
|
code: e,
|
||||||
schema: ::std::ptr::null(),
|
schema: ::std::ptr::null(),
|
||||||
table: ::std::ptr::null(),
|
table: ::std::ptr::null(),
|
||||||
|
@ -49,14 +49,14 @@ pub fn derive_vtab_module(input: TokenStream) -> TokenStream {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
unsafe extern "C" fn #open_fn_name(table: *const ::std::ffi::c_void, conn: *mut ::limbo_ext::Conn) -> *const ::std::ffi::c_void {
|
unsafe extern "C" fn #open_fn_name(table: *const ::std::ffi::c_void, conn: *mut ::turso_ext::Conn) -> *const ::std::ffi::c_void {
|
||||||
if table.is_null() {
|
if table.is_null() {
|
||||||
return ::std::ptr::null();
|
return ::std::ptr::null();
|
||||||
}
|
}
|
||||||
let table = table as *const <#struct_name as ::limbo_ext::VTabModule>::Table;
|
let table = table as *const <#struct_name as ::turso_ext::VTabModule>::Table;
|
||||||
let table: &<#struct_name as ::limbo_ext::VTabModule>::Table = &*table;
|
let table: &<#struct_name as ::turso_ext::VTabModule>::Table = &*table;
|
||||||
let conn = if conn.is_null() { None } else { Some(::std::sync::Arc::new(::limbo_ext::Connection::new(conn)))};
|
let conn = if conn.is_null() { None } else { Some(::std::sync::Arc::new(::turso_ext::Connection::new(conn)))};
|
||||||
if let Ok(cursor) = <#struct_name as ::limbo_ext::VTabModule>::Table::open(table, conn) {
|
if let Ok(cursor) = <#struct_name as ::turso_ext::VTabModule>::Table::open(table, conn) {
|
||||||
return ::std::boxed::Box::into_raw(::std::boxed::Box::new(cursor)) as *const ::std::ffi::c_void;
|
return ::std::boxed::Box::into_raw(::std::boxed::Box::new(cursor)) as *const ::std::ffi::c_void;
|
||||||
} else {
|
} else {
|
||||||
return ::std::ptr::null();
|
return ::std::ptr::null();
|
||||||
|
@ -66,60 +66,60 @@ pub fn derive_vtab_module(input: TokenStream) -> TokenStream {
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
unsafe extern "C" fn #close_fn_name(
|
unsafe extern "C" fn #close_fn_name(
|
||||||
cursor: *const ::std::ffi::c_void
|
cursor: *const ::std::ffi::c_void
|
||||||
) -> ::limbo_ext::ResultCode {
|
) -> ::turso_ext::ResultCode {
|
||||||
if cursor.is_null() {
|
if cursor.is_null() {
|
||||||
return ::limbo_ext::ResultCode::Error;
|
return ::turso_ext::ResultCode::Error;
|
||||||
}
|
}
|
||||||
let cursor = cursor as *mut <<#struct_name as ::limbo_ext::VTabModule>::Table as ::limbo_ext::VTable>::Cursor;
|
let cursor = cursor as *mut <<#struct_name as ::turso_ext::VTabModule>::Table as ::turso_ext::VTable>::Cursor;
|
||||||
let cursor = ::std::boxed::Box::from_raw(cursor);
|
let cursor = ::std::boxed::Box::from_raw(cursor);
|
||||||
<<#struct_name as ::limbo_ext::VTabModule>::Table as ::limbo_ext::VTable>::Cursor::close(&*cursor)
|
<<#struct_name as ::turso_ext::VTabModule>::Table as ::turso_ext::VTable>::Cursor::close(&*cursor)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
unsafe extern "C" fn #filter_fn_name(
|
unsafe extern "C" fn #filter_fn_name(
|
||||||
cursor: *const ::std::ffi::c_void,
|
cursor: *const ::std::ffi::c_void,
|
||||||
argc: i32,
|
argc: i32,
|
||||||
argv: *const ::limbo_ext::Value,
|
argv: *const ::turso_ext::Value,
|
||||||
idx_str: *const ::std::ffi::c_char,
|
idx_str: *const ::std::ffi::c_char,
|
||||||
idx_num: i32,
|
idx_num: i32,
|
||||||
) -> ::limbo_ext::ResultCode {
|
) -> ::turso_ext::ResultCode {
|
||||||
if cursor.is_null() {
|
if cursor.is_null() {
|
||||||
return ::limbo_ext::ResultCode::Error;
|
return ::turso_ext::ResultCode::Error;
|
||||||
}
|
}
|
||||||
let cursor = &mut *(cursor as *mut <<#struct_name as ::limbo_ext::VTabModule>::Table as ::limbo_ext::VTable>::Cursor);
|
let cursor = &mut *(cursor as *mut <<#struct_name as ::turso_ext::VTabModule>::Table as ::turso_ext::VTable>::Cursor);
|
||||||
let args = ::std::slice::from_raw_parts(argv, argc as usize);
|
let args = ::std::slice::from_raw_parts(argv, argc as usize);
|
||||||
let idx_str = if idx_str.is_null() {
|
let idx_str = if idx_str.is_null() {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
Some((unsafe { ::std::ffi::CStr::from_ptr(idx_str).to_str().unwrap() }, idx_num))
|
Some((unsafe { ::std::ffi::CStr::from_ptr(idx_str).to_str().unwrap() }, idx_num))
|
||||||
};
|
};
|
||||||
<<#struct_name as ::limbo_ext::VTabModule>::Table as ::limbo_ext::VTable>::Cursor::filter(cursor, args, idx_str)
|
<<#struct_name as ::turso_ext::VTabModule>::Table as ::turso_ext::VTable>::Cursor::filter(cursor, args, idx_str)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
unsafe extern "C" fn #column_fn_name(
|
unsafe extern "C" fn #column_fn_name(
|
||||||
cursor: *const ::std::ffi::c_void,
|
cursor: *const ::std::ffi::c_void,
|
||||||
idx: u32,
|
idx: u32,
|
||||||
) -> ::limbo_ext::Value {
|
) -> ::turso_ext::Value {
|
||||||
if cursor.is_null() {
|
if cursor.is_null() {
|
||||||
return ::limbo_ext::Value::error(::limbo_ext::ResultCode::Error);
|
return ::turso_ext::Value::error(::turso_ext::ResultCode::Error);
|
||||||
}
|
}
|
||||||
let cursor = &*(cursor as *const <<#struct_name as ::limbo_ext::VTabModule>::Table as ::limbo_ext::VTable>::Cursor);
|
let cursor = &*(cursor as *const <<#struct_name as ::turso_ext::VTabModule>::Table as ::turso_ext::VTable>::Cursor);
|
||||||
match <<#struct_name as ::limbo_ext::VTabModule>::Table as ::limbo_ext::VTable>::Cursor::column(cursor, idx) {
|
match <<#struct_name as ::turso_ext::VTabModule>::Table as ::turso_ext::VTable>::Cursor::column(cursor, idx) {
|
||||||
Ok(val) => val,
|
Ok(val) => val,
|
||||||
Err(e) => ::limbo_ext::Value::error_with_message(e.to_string())
|
Err(e) => ::turso_ext::Value::error_with_message(e.to_string())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
unsafe extern "C" fn #next_fn_name(
|
unsafe extern "C" fn #next_fn_name(
|
||||||
cursor: *const ::std::ffi::c_void,
|
cursor: *const ::std::ffi::c_void,
|
||||||
) -> ::limbo_ext::ResultCode {
|
) -> ::turso_ext::ResultCode {
|
||||||
if cursor.is_null() {
|
if cursor.is_null() {
|
||||||
return ::limbo_ext::ResultCode::Error;
|
return ::turso_ext::ResultCode::Error;
|
||||||
}
|
}
|
||||||
let cursor = &mut *(cursor as *mut <<#struct_name as ::limbo_ext::VTabModule>::Table as ::limbo_ext::VTable>::Cursor);
|
let cursor = &mut *(cursor as *mut <<#struct_name as ::turso_ext::VTabModule>::Table as ::turso_ext::VTable>::Cursor);
|
||||||
<<#struct_name as ::limbo_ext::VTabModule>::Table as ::limbo_ext::VTable>::Cursor::next(cursor)
|
<<#struct_name as ::turso_ext::VTabModule>::Table as ::turso_ext::VTable>::Cursor::next(cursor)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
@ -129,30 +129,30 @@ pub fn derive_vtab_module(input: TokenStream) -> TokenStream {
|
||||||
if cursor.is_null() {
|
if cursor.is_null() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
let cursor = &*(cursor as *const <<#struct_name as ::limbo_ext::VTabModule>::Table as ::limbo_ext::VTable>::Cursor);
|
let cursor = &*(cursor as *const <<#struct_name as ::turso_ext::VTabModule>::Table as ::turso_ext::VTable>::Cursor);
|
||||||
<<#struct_name as ::limbo_ext::VTabModule>::Table as ::limbo_ext::VTable>::Cursor::eof(cursor)
|
<<#struct_name as ::turso_ext::VTabModule>::Table as ::turso_ext::VTable>::Cursor::eof(cursor)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
unsafe extern "C" fn #update_fn_name(
|
unsafe extern "C" fn #update_fn_name(
|
||||||
table: *const ::std::ffi::c_void,
|
table: *const ::std::ffi::c_void,
|
||||||
argc: i32,
|
argc: i32,
|
||||||
argv: *const ::limbo_ext::Value,
|
argv: *const ::turso_ext::Value,
|
||||||
p_out_rowid: *mut i64,
|
p_out_rowid: *mut i64,
|
||||||
) -> ::limbo_ext::ResultCode {
|
) -> ::turso_ext::ResultCode {
|
||||||
if table.is_null() {
|
if table.is_null() {
|
||||||
return ::limbo_ext::ResultCode::Error;
|
return ::turso_ext::ResultCode::Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
let table = &mut *(table as *mut <#struct_name as ::limbo_ext::VTabModule>::Table);
|
let table = &mut *(table as *mut <#struct_name as ::turso_ext::VTabModule>::Table);
|
||||||
let args = ::std::slice::from_raw_parts(argv, argc as usize);
|
let args = ::std::slice::from_raw_parts(argv, argc as usize);
|
||||||
|
|
||||||
let old_rowid = match args.get(0).map(|v| v.value_type()) {
|
let old_rowid = match args.get(0).map(|v| v.value_type()) {
|
||||||
Some(::limbo_ext::ValueType::Integer) => args.get(0).unwrap().to_integer(),
|
Some(::turso_ext::ValueType::Integer) => args.get(0).unwrap().to_integer(),
|
||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
let new_rowid = match args.get(1).map(|v| v.value_type()) {
|
let new_rowid = match args.get(1).map(|v| v.value_type()) {
|
||||||
Some(::limbo_ext::ValueType::Integer) => args.get(1).unwrap().to_integer(),
|
Some(::turso_ext::ValueType::Integer) => args.get(1).unwrap().to_integer(),
|
||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
let columns = &args[2..];
|
let columns = &args[2..];
|
||||||
|
@ -160,29 +160,29 @@ pub fn derive_vtab_module(input: TokenStream) -> TokenStream {
|
||||||
// DELETE: old_rowid provided, no new_rowid
|
// DELETE: old_rowid provided, no new_rowid
|
||||||
(Some(old), None) => {
|
(Some(old), None) => {
|
||||||
if <#struct_name as VTabModule>::Table::delete(table, old).is_err() {
|
if <#struct_name as VTabModule>::Table::delete(table, old).is_err() {
|
||||||
return ::limbo_ext::ResultCode::Error;
|
return ::turso_ext::ResultCode::Error;
|
||||||
}
|
}
|
||||||
return ::limbo_ext::ResultCode::OK;
|
return ::turso_ext::ResultCode::OK;
|
||||||
}
|
}
|
||||||
// UPDATE: old_rowid provided and new_rowid may exist
|
// UPDATE: old_rowid provided and new_rowid may exist
|
||||||
(Some(old), Some(new)) => {
|
(Some(old), Some(new)) => {
|
||||||
if <#struct_name as VTabModule>::Table::update(table, old, &columns).is_err() {
|
if <#struct_name as VTabModule>::Table::update(table, old, &columns).is_err() {
|
||||||
return ::limbo_ext::ResultCode::Error;
|
return ::turso_ext::ResultCode::Error;
|
||||||
}
|
}
|
||||||
return ::limbo_ext::ResultCode::OK;
|
return ::turso_ext::ResultCode::OK;
|
||||||
}
|
}
|
||||||
// INSERT: no old_rowid (old_rowid = None)
|
// INSERT: no old_rowid (old_rowid = None)
|
||||||
(None, _) => {
|
(None, _) => {
|
||||||
if let Ok(rowid) = <#struct_name as VTabModule>::Table::insert(table, &columns) {
|
if let Ok(rowid) = <#struct_name as VTabModule>::Table::insert(table, &columns) {
|
||||||
if !p_out_rowid.is_null() {
|
if !p_out_rowid.is_null() {
|
||||||
*p_out_rowid = rowid;
|
*p_out_rowid = rowid;
|
||||||
return ::limbo_ext::ResultCode::RowID;
|
return ::turso_ext::ResultCode::RowID;
|
||||||
}
|
}
|
||||||
return ::limbo_ext::ResultCode::OK;
|
return ::turso_ext::ResultCode::OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ::limbo_ext::ResultCode::Error;
|
return ::turso_ext::ResultCode::Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
@ -190,51 +190,51 @@ pub fn derive_vtab_module(input: TokenStream) -> TokenStream {
|
||||||
if cursor.is_null() {
|
if cursor.is_null() {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
let cursor = &*(cursor as *const <<#struct_name as ::limbo_ext::VTabModule>::Table as ::limbo_ext::VTable>::Cursor);
|
let cursor = &*(cursor as *const <<#struct_name as ::turso_ext::VTabModule>::Table as ::turso_ext::VTable>::Cursor);
|
||||||
<<#struct_name as ::limbo_ext::VTabModule>::Table as ::limbo_ext::VTable>::Cursor::rowid(cursor)
|
<<#struct_name as ::turso_ext::VTabModule>::Table as ::turso_ext::VTable>::Cursor::rowid(cursor)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
unsafe extern "C" fn #destroy_fn_name(
|
unsafe extern "C" fn #destroy_fn_name(
|
||||||
table: *const ::std::ffi::c_void,
|
table: *const ::std::ffi::c_void,
|
||||||
) -> ::limbo_ext::ResultCode {
|
) -> ::turso_ext::ResultCode {
|
||||||
if table.is_null() {
|
if table.is_null() {
|
||||||
return ::limbo_ext::ResultCode::Error;
|
return ::turso_ext::ResultCode::Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Take ownership of the table so it can be properly dropped.
|
// Take ownership of the table so it can be properly dropped.
|
||||||
let mut table: ::std::boxed::Box<<#struct_name as ::limbo_ext::VTabModule>::Table> =
|
let mut table: ::std::boxed::Box<<#struct_name as ::turso_ext::VTabModule>::Table> =
|
||||||
::std::boxed::Box::from_raw(table as *mut <#struct_name as ::limbo_ext::VTabModule>::Table);
|
::std::boxed::Box::from_raw(table as *mut <#struct_name as ::turso_ext::VTabModule>::Table);
|
||||||
if <#struct_name as VTabModule>::Table::destroy(&mut *table).is_err() {
|
if <#struct_name as VTabModule>::Table::destroy(&mut *table).is_err() {
|
||||||
return ::limbo_ext::ResultCode::Error;
|
return ::turso_ext::ResultCode::Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ::limbo_ext::ResultCode::OK;
|
return ::turso_ext::ResultCode::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn #best_idx_fn_name(
|
pub unsafe extern "C" fn #best_idx_fn_name(
|
||||||
constraints: *const ::limbo_ext::ConstraintInfo,
|
constraints: *const ::turso_ext::ConstraintInfo,
|
||||||
n_constraints: i32,
|
n_constraints: i32,
|
||||||
order_by: *const ::limbo_ext::OrderByInfo,
|
order_by: *const ::turso_ext::OrderByInfo,
|
||||||
n_order_by: i32,
|
n_order_by: i32,
|
||||||
) -> ::limbo_ext::ExtIndexInfo {
|
) -> ::turso_ext::ExtIndexInfo {
|
||||||
let constraints = if n_constraints > 0 { std::slice::from_raw_parts(constraints, n_constraints as usize) } else { &[] };
|
let constraints = if n_constraints > 0 { std::slice::from_raw_parts(constraints, n_constraints as usize) } else { &[] };
|
||||||
let order_by = if n_order_by > 0 { std::slice::from_raw_parts(order_by, n_order_by as usize) } else { &[] };
|
let order_by = if n_order_by > 0 { std::slice::from_raw_parts(order_by, n_order_by as usize) } else { &[] };
|
||||||
<#struct_name as ::limbo_ext::VTabModule>::Table::best_index(constraints, order_by).to_ffi()
|
<#struct_name as ::turso_ext::VTabModule>::Table::best_index(constraints, order_by).to_ffi()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn #register_fn_name(
|
pub unsafe extern "C" fn #register_fn_name(
|
||||||
api: *const ::limbo_ext::ExtensionApi
|
api: *const ::turso_ext::ExtensionApi
|
||||||
) -> ::limbo_ext::ResultCode {
|
) -> ::turso_ext::ResultCode {
|
||||||
if api.is_null() {
|
if api.is_null() {
|
||||||
return ::limbo_ext::ResultCode::Error;
|
return ::turso_ext::ResultCode::Error;
|
||||||
}
|
}
|
||||||
let api = &*api;
|
let api = &*api;
|
||||||
let name = <#struct_name as ::limbo_ext::VTabModule>::NAME;
|
let name = <#struct_name as ::turso_ext::VTabModule>::NAME;
|
||||||
let name_c = ::std::ffi::CString::new(name).unwrap().into_raw() as *const ::std::ffi::c_char;
|
let name_c = ::std::ffi::CString::new(name).unwrap().into_raw() as *const ::std::ffi::c_char;
|
||||||
let module = ::limbo_ext::VTabModuleImpl {
|
let module = ::turso_ext::VTabModuleImpl {
|
||||||
name: name_c,
|
name: name_c,
|
||||||
create: Self::#create_fn_name,
|
create: Self::#create_fn_name,
|
||||||
open: Self::#open_fn_name,
|
open: Self::#open_fn_name,
|
||||||
|
@ -248,7 +248,7 @@ pub fn derive_vtab_module(input: TokenStream) -> TokenStream {
|
||||||
destroy: Self::#destroy_fn_name,
|
destroy: Self::#destroy_fn_name,
|
||||||
best_idx: Self::#best_idx_fn_name,
|
best_idx: Self::#best_idx_fn_name,
|
||||||
};
|
};
|
||||||
(api.register_vtab_module)(api.ctx, name_c, module, <#struct_name as ::limbo_ext::VTabModule>::VTAB_KIND)
|
(api.register_vtab_module)(api.ctx, name_c, module, <#struct_name as ::turso_ext::VTabModule>::VTAB_KIND)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -137,7 +137,7 @@ fn generate_get_description(
|
||||||
|
|
||||||
/// Register your extension with 'core' by providing the relevant functions
|
/// Register your extension with 'core' by providing the relevant functions
|
||||||
///```ignore
|
///```ignore
|
||||||
///use limbo_ext::{register_extension, scalar, Value, AggregateDerive, AggFunc};
|
///use turso_ext::{register_extension, scalar, Value, AggregateDerive, AggFunc};
|
||||||
///
|
///
|
||||||
/// register_extension!{ scalars: { return_one }, aggregates: { SumPlusOne } }
|
/// register_extension!{ scalars: { return_one }, aggregates: { SumPlusOne } }
|
||||||
///
|
///
|
||||||
|
@ -175,7 +175,7 @@ pub fn register_extension(input: TokenStream) -> TokenStream {
|
||||||
/// Declare a scalar function for your extension. This requires the name:
|
/// Declare a scalar function for your extension. This requires the name:
|
||||||
/// #[scalar(name = "example")] of what you wish to call your function with.
|
/// #[scalar(name = "example")] of what you wish to call your function with.
|
||||||
/// ```ignore
|
/// ```ignore
|
||||||
/// use limbo_ext::{scalar, Value};
|
/// use turso_ext::{scalar, Value};
|
||||||
/// #[scalar(name = "double", alias = "twice")] // you can provide an <optional> alias
|
/// #[scalar(name = "double", alias = "twice")] // you can provide an <optional> alias
|
||||||
/// fn double(args: &[Value]) -> Value {
|
/// fn double(args: &[Value]) -> Value {
|
||||||
/// let arg = args.get(0).unwrap();
|
/// let arg = args.get(0).unwrap();
|
||||||
|
@ -202,7 +202,7 @@ pub fn scalar(attr: TokenStream, input: TokenStream) -> TokenStream {
|
||||||
/// Define an aggregate function for your extension by deriving
|
/// Define an aggregate function for your extension by deriving
|
||||||
/// AggregateDerive on a struct that implements the AggFunc trait.
|
/// AggregateDerive on a struct that implements the AggFunc trait.
|
||||||
/// ```ignore
|
/// ```ignore
|
||||||
/// use limbo_ext::{register_extension, Value, AggregateDerive, AggFunc};
|
/// use turso_ext::{register_extension, Value, AggregateDerive, AggFunc};
|
||||||
///
|
///
|
||||||
///#[derive(AggregateDerive)]
|
///#[derive(AggregateDerive)]
|
||||||
///struct SumPlusOne;
|
///struct SumPlusOne;
|
||||||
|
@ -353,7 +353,7 @@ pub fn derive_vtab_module(input: TokenStream) -> TokenStream {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ```ignore
|
/// ```ignore
|
||||||
/// use limbo_ext::{ExtResult as Result, VfsDerive, VfsExtension, VfsFile};
|
/// use turso_ext::{ExtResult as Result, VfsDerive, VfsExtension, VfsFile};
|
||||||
///
|
///
|
||||||
/// // Your struct must also impl Default
|
/// // Your struct must also impl Default
|
||||||
/// #[derive(VfsDerive, Default)]
|
/// #[derive(VfsDerive, Default)]
|
||||||
|
|
26
perf/latency/limbo/Cargo.lock
generated
26
perf/latency/limbo/Cargo.lock
generated
|
@ -652,21 +652,12 @@ dependencies = [
|
||||||
"turso_core",
|
"turso_core",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "limbo_ext"
|
|
||||||
version = "0.1.0-pre.2"
|
|
||||||
dependencies = [
|
|
||||||
"chrono",
|
|
||||||
"getrandom 0.3.3",
|
|
||||||
"turso_macros",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "limbo_series"
|
name = "limbo_series"
|
||||||
version = "0.1.0-pre.2"
|
version = "0.1.0-pre.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"limbo_ext",
|
|
||||||
"mimalloc",
|
"mimalloc",
|
||||||
|
"turso_ext",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -693,19 +684,19 @@ name = "limbo_time"
|
||||||
version = "0.1.0-pre.2"
|
version = "0.1.0-pre.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"limbo_ext",
|
|
||||||
"mimalloc",
|
"mimalloc",
|
||||||
"strum",
|
"strum",
|
||||||
"strum_macros",
|
"strum_macros",
|
||||||
"thiserror 2.0.12",
|
"thiserror 2.0.12",
|
||||||
|
"turso_ext",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "limbo_uuid"
|
name = "limbo_uuid"
|
||||||
version = "0.1.0-pre.2"
|
version = "0.1.0-pre.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"limbo_ext",
|
|
||||||
"mimalloc",
|
"mimalloc",
|
||||||
|
"turso_ext",
|
||||||
"uuid",
|
"uuid",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1246,7 +1237,6 @@ dependencies = [
|
||||||
"julian_day_converter",
|
"julian_day_converter",
|
||||||
"libloading",
|
"libloading",
|
||||||
"libm",
|
"libm",
|
||||||
"limbo_ext",
|
|
||||||
"limbo_series",
|
"limbo_series",
|
||||||
"limbo_sqlite3_parser",
|
"limbo_sqlite3_parser",
|
||||||
"limbo_time",
|
"limbo_time",
|
||||||
|
@ -1265,10 +1255,20 @@ dependencies = [
|
||||||
"strum_macros",
|
"strum_macros",
|
||||||
"thiserror 1.0.63",
|
"thiserror 1.0.63",
|
||||||
"tracing",
|
"tracing",
|
||||||
|
"turso_ext",
|
||||||
"turso_macros",
|
"turso_macros",
|
||||||
"uncased",
|
"uncased",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "turso_ext"
|
||||||
|
version = "0.1.0-pre.2"
|
||||||
|
dependencies = [
|
||||||
|
"chrono",
|
||||||
|
"getrandom 0.3.3",
|
||||||
|
"turso_macros",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "turso_macros"
|
name = "turso_macros"
|
||||||
version = "0.1.0-pre.2"
|
version = "0.1.0-pre.2"
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
cargo publish -p turso_macros
|
cargo publish -p turso_macros
|
||||||
cargo publish -p limbo_ext
|
cargo publish -p turso_ext
|
||||||
cargo publish -p limbo_ext_tests
|
|
||||||
cargo publish -p limbo_completion
|
cargo publish -p limbo_completion
|
||||||
cargo publish -p limbo_crypto
|
cargo publish -p limbo_crypto
|
||||||
cargo publish -p limbo_csv
|
cargo publish -p limbo_csv
|
||||||
|
|
|
@ -338,7 +338,7 @@ def _test_series(limbo: TestLimboShell):
|
||||||
|
|
||||||
|
|
||||||
def test_kv():
|
def test_kv():
|
||||||
_test_kv(exec_name=None, ext_path="target/debug/liblimbo_ext_tests")
|
_test_kv(exec_name=None, ext_path="target/debug/libturso_ext_tests")
|
||||||
_test_kv(exec_name="sqlite3", ext_path="target/debug/liblimbo_sqlite_test_ext")
|
_test_kv(exec_name="sqlite3", ext_path="target/debug/liblimbo_sqlite_test_ext")
|
||||||
|
|
||||||
|
|
||||||
|
@ -505,7 +505,7 @@ def test_ipaddr():
|
||||||
|
|
||||||
def test_vfs():
|
def test_vfs():
|
||||||
limbo = TestLimboShell()
|
limbo = TestLimboShell()
|
||||||
ext_path = "target/debug/liblimbo_ext_tests"
|
ext_path = "target/debug/libturso_ext_tests"
|
||||||
limbo.run_test_fn(".vfslist", lambda x: "testvfs" not in x, "testvfs not loaded")
|
limbo.run_test_fn(".vfslist", lambda x: "testvfs" not in x, "testvfs not loaded")
|
||||||
limbo.execute_dot(f".load {ext_path}")
|
limbo.execute_dot(f".load {ext_path}")
|
||||||
limbo.run_test_fn(".vfslist", lambda res: "testvfs" in res, "testvfs extension loaded")
|
limbo.run_test_fn(".vfslist", lambda res: "testvfs" in res, "testvfs extension loaded")
|
||||||
|
@ -530,7 +530,7 @@ def test_vfs():
|
||||||
|
|
||||||
|
|
||||||
def test_drop_virtual_table():
|
def test_drop_virtual_table():
|
||||||
ext_path = "target/debug/liblimbo_ext_tests"
|
ext_path = "target/debug/libturso_ext_tests"
|
||||||
limbo = TestLimboShell()
|
limbo = TestLimboShell()
|
||||||
limbo.execute_dot(f".load {ext_path}")
|
limbo.execute_dot(f".load {ext_path}")
|
||||||
limbo.run_debug(
|
limbo.run_debug(
|
||||||
|
@ -585,7 +585,7 @@ def test_sqlite_vfs_compat():
|
||||||
|
|
||||||
|
|
||||||
def test_create_virtual_table():
|
def test_create_virtual_table():
|
||||||
ext_path = "target/debug/liblimbo_ext_tests"
|
ext_path = "target/debug/libturso_ext_tests"
|
||||||
|
|
||||||
limbo = TestLimboShell()
|
limbo = TestLimboShell()
|
||||||
limbo.execute_dot(f".load {ext_path}")
|
limbo.execute_dot(f".load {ext_path}")
|
||||||
|
@ -711,7 +711,7 @@ def cleanup():
|
||||||
|
|
||||||
|
|
||||||
def test_tablestats():
|
def test_tablestats():
|
||||||
ext_path = "target/debug/liblimbo_ext_tests"
|
ext_path = "target/debug/libturso_ext_tests"
|
||||||
limbo = TestLimboShell(use_testing_db=True)
|
limbo = TestLimboShell(use_testing_db=True)
|
||||||
limbo.execute_dot("CREATE TABLE people(id INTEGER PRIMARY KEY, name TEXT);")
|
limbo.execute_dot("CREATE TABLE people(id INTEGER PRIMARY KEY, name TEXT);")
|
||||||
limbo.execute_dot("INSERT INTO people(name) VALUES ('Ada'), ('Grace'), ('Linus');")
|
limbo.execute_dot("INSERT INTO people(name) VALUES ('Ada'), ('Grace'), ('Linus');")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue