mirror of
https://github.com/tursodatabase/limbo.git
synced 2025-07-07 20:45:01 +00:00
Rename limbo_core
crate to turso_core
This commit is contained in:
parent
1c4b3de0f5
commit
53ba3ff926
63 changed files with 1345 additions and 866 deletions
2
.github/workflows/rust.yml
vendored
2
.github/workflows/rust.yml
vendored
|
@ -38,7 +38,7 @@ jobs:
|
||||||
run: cargo build --verbose
|
run: cargo build --verbose
|
||||||
- name: Test
|
- name: Test
|
||||||
env:
|
env:
|
||||||
RUST_LOG: ${{ runner.debug && 'limbo_core::storage=trace' || '' }}
|
RUST_LOG: ${{ runner.debug && 'turso_core::storage=trace' || '' }}
|
||||||
run: cargo test --verbose
|
run: cargo test --verbose
|
||||||
timeout-minutes: 20
|
timeout-minutes: 20
|
||||||
|
|
||||||
|
|
138
Cargo.lock
generated
138
Cargo.lock
generated
|
@ -520,7 +520,6 @@ dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"assert_cmd",
|
"assert_cmd",
|
||||||
"env_logger 0.10.2",
|
"env_logger 0.10.2",
|
||||||
"limbo_core",
|
|
||||||
"log",
|
"log",
|
||||||
"rand 0.9.0",
|
"rand 0.9.0",
|
||||||
"rand_chacha 0.9.0",
|
"rand_chacha 0.9.0",
|
||||||
|
@ -530,6 +529,7 @@ dependencies = [
|
||||||
"test-log",
|
"test-log",
|
||||||
"tracing",
|
"tracing",
|
||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
|
"turso_core",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1724,17 +1724,17 @@ dependencies = [
|
||||||
name = "limbo"
|
name = "limbo"
|
||||||
version = "0.1.0-pre.2"
|
version = "0.1.0-pre.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"limbo_core",
|
|
||||||
"tempfile",
|
"tempfile",
|
||||||
"thiserror 2.0.12",
|
"thiserror 2.0.12",
|
||||||
"tokio",
|
"tokio",
|
||||||
|
"turso_core",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "limbo-go"
|
name = "limbo-go"
|
||||||
version = "0.1.0-pre.2"
|
version = "0.1.0-pre.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"limbo_core",
|
"turso_core",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1742,8 +1742,8 @@ name = "limbo-java"
|
||||||
version = "0.1.0-pre.2"
|
version = "0.1.0-pre.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"jni",
|
"jni",
|
||||||
"limbo_core",
|
|
||||||
"thiserror 2.0.12",
|
"thiserror 2.0.12",
|
||||||
|
"turso_core",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1753,7 +1753,7 @@ dependencies = [
|
||||||
"console_error_panic_hook",
|
"console_error_panic_hook",
|
||||||
"getrandom 0.2.15",
|
"getrandom 0.2.15",
|
||||||
"js-sys",
|
"js-sys",
|
||||||
"limbo_core",
|
"turso_core",
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
"wasm-bindgen-futures",
|
"wasm-bindgen-futures",
|
||||||
"web-sys",
|
"web-sys",
|
||||||
|
@ -1767,65 +1767,6 @@ dependencies = [
|
||||||
"mimalloc",
|
"mimalloc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "limbo_core"
|
|
||||||
version = "0.1.0-pre.2"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags 2.9.0",
|
|
||||||
"built",
|
|
||||||
"cfg_block",
|
|
||||||
"chrono",
|
|
||||||
"criterion",
|
|
||||||
"crossbeam-skiplist",
|
|
||||||
"env_logger 0.11.7",
|
|
||||||
"fallible-iterator",
|
|
||||||
"getrandom 0.2.15",
|
|
||||||
"hex",
|
|
||||||
"io-uring",
|
|
||||||
"julian_day_converter",
|
|
||||||
"libc",
|
|
||||||
"libloading",
|
|
||||||
"libm",
|
|
||||||
"limbo_completion",
|
|
||||||
"limbo_crypto",
|
|
||||||
"limbo_csv",
|
|
||||||
"limbo_ext",
|
|
||||||
"limbo_ipaddr",
|
|
||||||
"limbo_macros",
|
|
||||||
"limbo_percentile",
|
|
||||||
"limbo_regexp",
|
|
||||||
"limbo_series",
|
|
||||||
"limbo_sqlite3_parser",
|
|
||||||
"limbo_time",
|
|
||||||
"limbo_uuid",
|
|
||||||
"lru",
|
|
||||||
"miette",
|
|
||||||
"mimalloc",
|
|
||||||
"parking_lot",
|
|
||||||
"paste",
|
|
||||||
"polling",
|
|
||||||
"pprof",
|
|
||||||
"quickcheck",
|
|
||||||
"quickcheck_macros",
|
|
||||||
"rand 0.8.5",
|
|
||||||
"rand_chacha 0.9.0",
|
|
||||||
"regex",
|
|
||||||
"regex-syntax 0.8.5",
|
|
||||||
"rstest",
|
|
||||||
"rusqlite",
|
|
||||||
"rustix 1.0.7",
|
|
||||||
"ryu",
|
|
||||||
"serde",
|
|
||||||
"sorted-vec",
|
|
||||||
"strum",
|
|
||||||
"strum_macros",
|
|
||||||
"tempfile",
|
|
||||||
"test-log",
|
|
||||||
"thiserror 1.0.69",
|
|
||||||
"tracing",
|
|
||||||
"uncased",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "limbo_crypto"
|
name = "limbo_crypto"
|
||||||
version = "0.1.0-pre.2"
|
version = "0.1.0-pre.2"
|
||||||
|
@ -1925,7 +1866,6 @@ dependencies = [
|
||||||
"dirs 6.0.0",
|
"dirs 6.0.0",
|
||||||
"env_logger 0.10.2",
|
"env_logger 0.10.2",
|
||||||
"hex",
|
"hex",
|
||||||
"limbo_core",
|
|
||||||
"limbo_sqlite3_parser",
|
"limbo_sqlite3_parser",
|
||||||
"log",
|
"log",
|
||||||
"notify",
|
"notify",
|
||||||
|
@ -1938,6 +1878,7 @@ dependencies = [
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"tracing",
|
"tracing",
|
||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
|
"turso_core",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1946,11 +1887,11 @@ version = "0.1.0-pre.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"env_logger 0.11.7",
|
"env_logger 0.11.7",
|
||||||
"libc",
|
"libc",
|
||||||
"limbo_core",
|
|
||||||
"tempfile",
|
"tempfile",
|
||||||
"tracing",
|
"tracing",
|
||||||
"tracing-appender",
|
"tracing-appender",
|
||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
|
"turso_core",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2679,9 +2620,9 @@ name = "py-turso"
|
||||||
version = "0.1.0-pre.2"
|
version = "0.1.0-pre.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"limbo_core",
|
|
||||||
"pyo3",
|
"pyo3",
|
||||||
"pyo3-build-config",
|
"pyo3-build-config",
|
||||||
|
"turso_core",
|
||||||
"version_check",
|
"version_check",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -3792,7 +3733,6 @@ dependencies = [
|
||||||
"dirs 5.0.1",
|
"dirs 5.0.1",
|
||||||
"env_logger 0.10.2",
|
"env_logger 0.10.2",
|
||||||
"libc",
|
"libc",
|
||||||
"limbo_core",
|
|
||||||
"miette",
|
"miette",
|
||||||
"nu-ansi-term 0.50.1",
|
"nu-ansi-term 0.50.1",
|
||||||
"rustyline",
|
"rustyline",
|
||||||
|
@ -3805,17 +3745,77 @@ dependencies = [
|
||||||
"tracing",
|
"tracing",
|
||||||
"tracing-appender",
|
"tracing-appender",
|
||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
|
"turso_core",
|
||||||
"validator",
|
"validator",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "turso_core"
|
||||||
|
version = "0.1.0-pre.2"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags 2.9.0",
|
||||||
|
"built",
|
||||||
|
"cfg_block",
|
||||||
|
"chrono",
|
||||||
|
"criterion",
|
||||||
|
"crossbeam-skiplist",
|
||||||
|
"env_logger 0.11.7",
|
||||||
|
"fallible-iterator",
|
||||||
|
"getrandom 0.2.15",
|
||||||
|
"hex",
|
||||||
|
"io-uring",
|
||||||
|
"julian_day_converter",
|
||||||
|
"libc",
|
||||||
|
"libloading",
|
||||||
|
"libm",
|
||||||
|
"limbo_completion",
|
||||||
|
"limbo_crypto",
|
||||||
|
"limbo_csv",
|
||||||
|
"limbo_ext",
|
||||||
|
"limbo_ipaddr",
|
||||||
|
"limbo_macros",
|
||||||
|
"limbo_percentile",
|
||||||
|
"limbo_regexp",
|
||||||
|
"limbo_series",
|
||||||
|
"limbo_sqlite3_parser",
|
||||||
|
"limbo_time",
|
||||||
|
"limbo_uuid",
|
||||||
|
"lru",
|
||||||
|
"miette",
|
||||||
|
"mimalloc",
|
||||||
|
"parking_lot",
|
||||||
|
"paste",
|
||||||
|
"polling",
|
||||||
|
"pprof",
|
||||||
|
"quickcheck",
|
||||||
|
"quickcheck_macros",
|
||||||
|
"rand 0.8.5",
|
||||||
|
"rand_chacha 0.9.0",
|
||||||
|
"regex",
|
||||||
|
"regex-syntax 0.8.5",
|
||||||
|
"rstest",
|
||||||
|
"rusqlite",
|
||||||
|
"rustix 1.0.7",
|
||||||
|
"ryu",
|
||||||
|
"serde",
|
||||||
|
"sorted-vec",
|
||||||
|
"strum",
|
||||||
|
"strum_macros",
|
||||||
|
"tempfile",
|
||||||
|
"test-log",
|
||||||
|
"thiserror 1.0.69",
|
||||||
|
"tracing",
|
||||||
|
"uncased",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "turso_node"
|
name = "turso_node"
|
||||||
version = "0.1.0-pre.2"
|
version = "0.1.0-pre.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"limbo_core",
|
|
||||||
"napi",
|
"napi",
|
||||||
"napi-build",
|
"napi-build",
|
||||||
"napi-derive",
|
"napi-derive",
|
||||||
|
"turso_core",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
@ -40,7 +40,7 @@ repository = "https://github.com/tursodatabase/limbo"
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
limbo_completion = { path = "extensions/completion", version = "0.1.0-pre.2" }
|
limbo_completion = { path = "extensions/completion", version = "0.1.0-pre.2" }
|
||||||
limbo_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" }
|
limbo_ext = { path = "extensions/core", version = "0.1.0-pre.2" }
|
||||||
|
|
|
@ -14,11 +14,11 @@ path = "rs_src/lib.rs"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["io_uring"]
|
default = ["io_uring"]
|
||||||
io_uring = ["limbo_core/io_uring"]
|
io_uring = ["turso_core/io_uring"]
|
||||||
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
limbo_core = { workspace = true }
|
turso_core = { workspace = true }
|
||||||
|
|
||||||
[target.'cfg(target_os = "linux")'.dependencies]
|
[target.'cfg(target_os = "linux")'.dependencies]
|
||||||
limbo_core = { workspace = true, features = ["io_uring"] }
|
turso_core = { workspace = true, features = ["io_uring"] }
|
||||||
|
|
|
@ -2,11 +2,11 @@ mod rows;
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
mod statement;
|
mod statement;
|
||||||
mod types;
|
mod types;
|
||||||
use limbo_core::{Connection, Database, LimboError, IO};
|
|
||||||
use std::{
|
use std::{
|
||||||
ffi::{c_char, c_void},
|
ffi::{c_char, c_void},
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
|
use turso_core::{Connection, Database, LimboError, IO};
|
||||||
|
|
||||||
/// # Safety
|
/// # Safety
|
||||||
/// Safe to be called from Go with null terminated DSN string.
|
/// Safe to be called from Go with null terminated DSN string.
|
||||||
|
@ -21,8 +21,8 @@ pub unsafe extern "C" fn db_open(path: *const c_char) -> *mut c_void {
|
||||||
let path = unsafe { std::ffi::CStr::from_ptr(path) };
|
let path = unsafe { std::ffi::CStr::from_ptr(path) };
|
||||||
let path = path.to_str().unwrap();
|
let path = path.to_str().unwrap();
|
||||||
let io: Arc<dyn IO> = match path {
|
let io: Arc<dyn IO> = match path {
|
||||||
p if p.contains(":memory:") => Arc::new(limbo_core::MemoryIO::new()),
|
p if p.contains(":memory:") => Arc::new(turso_core::MemoryIO::new()),
|
||||||
_ => Arc::new(limbo_core::PlatformIO::new().expect("Failed to create IO")),
|
_ => Arc::new(turso_core::PlatformIO::new().expect("Failed to create IO")),
|
||||||
};
|
};
|
||||||
let db = Database::open_file(io.clone(), path, false, false);
|
let db = Database::open_file(io.clone(), path, false, false);
|
||||||
match db {
|
match db {
|
||||||
|
@ -40,12 +40,12 @@ pub unsafe extern "C" fn db_open(path: *const c_char) -> *mut c_void {
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
struct LimboConn {
|
struct LimboConn {
|
||||||
conn: Arc<Connection>,
|
conn: Arc<Connection>,
|
||||||
io: Arc<dyn limbo_core::IO>,
|
io: Arc<dyn turso_core::IO>,
|
||||||
err: Option<LimboError>,
|
err: Option<LimboError>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LimboConn {
|
impl LimboConn {
|
||||||
fn new(conn: Arc<Connection>, io: Arc<dyn limbo_core::IO>) -> Self {
|
fn new(conn: Arc<Connection>, io: Arc<dyn turso_core::IO>) -> Self {
|
||||||
LimboConn {
|
LimboConn {
|
||||||
conn,
|
conn,
|
||||||
io,
|
io,
|
||||||
|
|
|
@ -2,8 +2,8 @@ use crate::{
|
||||||
types::{LimboValue, ResultCode},
|
types::{LimboValue, ResultCode},
|
||||||
LimboConn,
|
LimboConn,
|
||||||
};
|
};
|
||||||
use limbo_core::{LimboError, Statement, StepResult, Value};
|
|
||||||
use std::ffi::{c_char, c_void};
|
use std::ffi::{c_char, c_void};
|
||||||
|
use turso_core::{LimboError, Statement, StepResult, Value};
|
||||||
|
|
||||||
pub struct LimboRows<'conn> {
|
pub struct LimboRows<'conn> {
|
||||||
stmt: Box<Statement>,
|
stmt: Box<Statement>,
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
use crate::rows::LimboRows;
|
use crate::rows::LimboRows;
|
||||||
use crate::types::{AllocPool, LimboValue, ResultCode};
|
use crate::types::{AllocPool, LimboValue, ResultCode};
|
||||||
use crate::LimboConn;
|
use crate::LimboConn;
|
||||||
use limbo_core::{LimboError, Statement, StepResult};
|
|
||||||
use std::ffi::{c_char, c_void};
|
use std::ffi::{c_char, c_void};
|
||||||
use std::num::NonZero;
|
use std::num::NonZero;
|
||||||
|
use turso_core::{LimboError, Statement, StepResult};
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn db_prepare(ctx: *mut c_void, query: *const c_char) -> *mut c_void {
|
pub extern "C" fn db_prepare(ctx: *mut c_void, query: *const c_char) -> *mut c_void {
|
||||||
|
|
|
@ -174,62 +174,62 @@ impl LimboValue {
|
||||||
Box::into_raw(Box::new(self)) as *const c_void
|
Box::into_raw(Box::new(self)) as *const c_void
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_owned_value(value: &limbo_core::Value) -> Self {
|
pub fn from_owned_value(value: &turso_core::Value) -> Self {
|
||||||
match value {
|
match value {
|
||||||
limbo_core::Value::Integer(i) => {
|
turso_core::Value::Integer(i) => {
|
||||||
LimboValue::new(ValueType::Integer, ValueUnion::from_int(*i))
|
LimboValue::new(ValueType::Integer, ValueUnion::from_int(*i))
|
||||||
}
|
}
|
||||||
limbo_core::Value::Float(r) => {
|
turso_core::Value::Float(r) => {
|
||||||
LimboValue::new(ValueType::Real, ValueUnion::from_real(*r))
|
LimboValue::new(ValueType::Real, ValueUnion::from_real(*r))
|
||||||
}
|
}
|
||||||
limbo_core::Value::Text(s) => {
|
turso_core::Value::Text(s) => {
|
||||||
LimboValue::new(ValueType::Text, ValueUnion::from_str(s.as_str()))
|
LimboValue::new(ValueType::Text, ValueUnion::from_str(s.as_str()))
|
||||||
}
|
}
|
||||||
limbo_core::Value::Blob(b) => {
|
turso_core::Value::Blob(b) => {
|
||||||
LimboValue::new(ValueType::Blob, ValueUnion::from_bytes(b.as_slice()))
|
LimboValue::new(ValueType::Blob, ValueUnion::from_bytes(b.as_slice()))
|
||||||
}
|
}
|
||||||
limbo_core::Value::Null => LimboValue::new(ValueType::Null, ValueUnion::from_null()),
|
turso_core::Value::Null => LimboValue::new(ValueType::Null, ValueUnion::from_null()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The values we get from Go need to be temporarily owned by the statement until they are bound
|
// The values we get from Go need to be temporarily owned by the statement until they are bound
|
||||||
// then they can be cleaned up immediately afterwards
|
// then they can be cleaned up immediately afterwards
|
||||||
pub fn to_value(&self, pool: &mut AllocPool) -> limbo_core::Value {
|
pub fn to_value(&self, pool: &mut AllocPool) -> turso_core::Value {
|
||||||
match self.value_type {
|
match self.value_type {
|
||||||
ValueType::Integer => {
|
ValueType::Integer => {
|
||||||
if unsafe { self.value.int_val == 0 } {
|
if unsafe { self.value.int_val == 0 } {
|
||||||
return limbo_core::Value::Null;
|
return turso_core::Value::Null;
|
||||||
}
|
}
|
||||||
limbo_core::Value::Integer(unsafe { self.value.int_val })
|
turso_core::Value::Integer(unsafe { self.value.int_val })
|
||||||
}
|
}
|
||||||
ValueType::Real => {
|
ValueType::Real => {
|
||||||
if unsafe { self.value.real_val == 0.0 } {
|
if unsafe { self.value.real_val == 0.0 } {
|
||||||
return limbo_core::Value::Null;
|
return turso_core::Value::Null;
|
||||||
}
|
}
|
||||||
limbo_core::Value::Float(unsafe { self.value.real_val })
|
turso_core::Value::Float(unsafe { self.value.real_val })
|
||||||
}
|
}
|
||||||
ValueType::Text => {
|
ValueType::Text => {
|
||||||
if unsafe { self.value.text_ptr.is_null() } {
|
if unsafe { self.value.text_ptr.is_null() } {
|
||||||
return limbo_core::Value::Null;
|
return turso_core::Value::Null;
|
||||||
}
|
}
|
||||||
let cstr = unsafe { std::ffi::CStr::from_ptr(self.value.text_ptr) };
|
let cstr = unsafe { std::ffi::CStr::from_ptr(self.value.text_ptr) };
|
||||||
match cstr.to_str() {
|
match cstr.to_str() {
|
||||||
Ok(utf8_str) => {
|
Ok(utf8_str) => {
|
||||||
let owned = utf8_str.to_owned();
|
let owned = utf8_str.to_owned();
|
||||||
let borrowed = pool.add_string(owned);
|
let borrowed = pool.add_string(owned);
|
||||||
limbo_core::Value::build_text(borrowed)
|
turso_core::Value::build_text(borrowed)
|
||||||
}
|
}
|
||||||
Err(_) => limbo_core::Value::Null,
|
Err(_) => turso_core::Value::Null,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ValueType::Blob => {
|
ValueType::Blob => {
|
||||||
if unsafe { self.value.blob_ptr.is_null() } {
|
if unsafe { self.value.blob_ptr.is_null() } {
|
||||||
return limbo_core::Value::Null;
|
return turso_core::Value::Null;
|
||||||
}
|
}
|
||||||
let bytes = self.value.to_bytes();
|
let bytes = self.value.to_bytes();
|
||||||
limbo_core::Value::Blob(bytes.to_vec())
|
turso_core::Value::Blob(bytes.to_vec())
|
||||||
}
|
}
|
||||||
ValueType::Null => limbo_core::Value::Null,
|
ValueType::Null => turso_core::Value::Null,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,6 @@ crate-type = ["cdylib"]
|
||||||
path = "rs_src/lib.rs"
|
path = "rs_src/lib.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
limbo_core = { path = "../../core", features = ["io_uring"] }
|
turso_core = { path = "../../core", features = ["io_uring"] }
|
||||||
jni = "0.21.1"
|
jni = "0.21.1"
|
||||||
thiserror = "2.0.9"
|
thiserror = "2.0.9"
|
||||||
|
|
|
@ -16,8 +16,8 @@ pub enum LimboError {
|
||||||
JNIErrors(Error),
|
JNIErrors(Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<limbo_core::LimboError> for LimboError {
|
impl From<turso_core::LimboError> for LimboError {
|
||||||
fn from(_value: limbo_core::LimboError) -> Self {
|
fn from(_value: turso_core::LimboError) -> Self {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,17 +7,17 @@ use crate::utils::{set_err_msg_and_throw_exception, utf8_byte_arr_to_str};
|
||||||
use jni::objects::{JByteArray, JObject};
|
use jni::objects::{JByteArray, JObject};
|
||||||
use jni::sys::jlong;
|
use jni::sys::jlong;
|
||||||
use jni::JNIEnv;
|
use jni::JNIEnv;
|
||||||
use limbo_core::Connection;
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use turso_core::Connection;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct LimboConnection {
|
pub struct LimboConnection {
|
||||||
pub(crate) conn: Arc<Connection>,
|
pub(crate) conn: Arc<Connection>,
|
||||||
pub(crate) io: Arc<dyn limbo_core::IO>,
|
pub(crate) io: Arc<dyn turso_core::IO>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LimboConnection {
|
impl LimboConnection {
|
||||||
pub fn new(conn: Arc<Connection>, io: Arc<dyn limbo_core::IO>) -> Self {
|
pub fn new(conn: Arc<Connection>, io: Arc<dyn turso_core::IO>) -> Self {
|
||||||
LimboConnection { conn, io }
|
LimboConnection { conn, io }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,16 +4,16 @@ use crate::utils::set_err_msg_and_throw_exception;
|
||||||
use jni::objects::{JByteArray, JObject};
|
use jni::objects::{JByteArray, JObject};
|
||||||
use jni::sys::{jint, jlong};
|
use jni::sys::{jint, jlong};
|
||||||
use jni::JNIEnv;
|
use jni::JNIEnv;
|
||||||
use limbo_core::Database;
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use turso_core::Database;
|
||||||
|
|
||||||
struct LimboDB {
|
struct LimboDB {
|
||||||
db: Arc<Database>,
|
db: Arc<Database>,
|
||||||
io: Arc<dyn limbo_core::IO>,
|
io: Arc<dyn turso_core::IO>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LimboDB {
|
impl LimboDB {
|
||||||
pub fn new(db: Arc<Database>, io: Arc<dyn limbo_core::IO>) -> Self {
|
pub fn new(db: Arc<Database>, io: Arc<dyn turso_core::IO>) -> Self {
|
||||||
LimboDB { db, io }
|
LimboDB { db, io }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ pub extern "system" fn Java_tech_turso_core_LimboDB_openUtf8<'local>(
|
||||||
file_path_byte_arr: JByteArray<'local>,
|
file_path_byte_arr: JByteArray<'local>,
|
||||||
_open_flags: jint,
|
_open_flags: jint,
|
||||||
) -> jlong {
|
) -> jlong {
|
||||||
let io = match limbo_core::PlatformIO::new() {
|
let io = match turso_core::PlatformIO::new() {
|
||||||
Ok(io) => Arc::new(io),
|
Ok(io) => Arc::new(io),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
set_err_msg_and_throw_exception(&mut env, obj, LIMBO_ETC, e.to_string());
|
set_err_msg_and_throw_exception(&mut env, obj, LIMBO_ETC, e.to_string());
|
||||||
|
|
|
@ -5,8 +5,8 @@ use crate::utils::set_err_msg_and_throw_exception;
|
||||||
use jni::objects::{JByteArray, JObject, JObjectArray, JString, JValue};
|
use jni::objects::{JByteArray, JObject, JObjectArray, JString, JValue};
|
||||||
use jni::sys::{jdouble, jint, jlong};
|
use jni::sys::{jdouble, jint, jlong};
|
||||||
use jni::JNIEnv;
|
use jni::JNIEnv;
|
||||||
use limbo_core::{Statement, StepResult, Value};
|
|
||||||
use std::num::NonZero;
|
use std::num::NonZero;
|
||||||
|
use turso_core::{Statement, StepResult, Value};
|
||||||
|
|
||||||
pub const STEP_RESULT_ID_ROW: i32 = 10;
|
pub const STEP_RESULT_ID_ROW: i32 = 10;
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
|
@ -101,21 +101,21 @@ pub extern "system" fn Java_tech_turso_core_LimboStatement__1close<'local>(
|
||||||
|
|
||||||
fn row_to_obj_array<'local>(
|
fn row_to_obj_array<'local>(
|
||||||
env: &mut JNIEnv<'local>,
|
env: &mut JNIEnv<'local>,
|
||||||
row: &limbo_core::Row,
|
row: &turso_core::Row,
|
||||||
) -> Result<JObject<'local>> {
|
) -> Result<JObject<'local>> {
|
||||||
let obj_array = env.new_object_array(row.len() as i32, "java/lang/Object", JObject::null())?;
|
let obj_array = env.new_object_array(row.len() as i32, "java/lang/Object", JObject::null())?;
|
||||||
|
|
||||||
for (i, value) in row.get_values().enumerate() {
|
for (i, value) in row.get_values().enumerate() {
|
||||||
let obj = match value {
|
let obj = match value {
|
||||||
limbo_core::Value::Null => JObject::null(),
|
turso_core::Value::Null => JObject::null(),
|
||||||
limbo_core::Value::Integer(i) => {
|
turso_core::Value::Integer(i) => {
|
||||||
env.new_object("java/lang/Long", "(J)V", &[JValue::Long(*i)])?
|
env.new_object("java/lang/Long", "(J)V", &[JValue::Long(*i)])?
|
||||||
}
|
}
|
||||||
limbo_core::Value::Float(f) => {
|
turso_core::Value::Float(f) => {
|
||||||
env.new_object("java/lang/Double", "(D)V", &[JValue::Double(*f)])?
|
env.new_object("java/lang/Double", "(D)V", &[JValue::Double(*f)])?
|
||||||
}
|
}
|
||||||
limbo_core::Value::Text(s) => env.new_string(s.as_str())?.into(),
|
turso_core::Value::Text(s) => env.new_string(s.as_str())?.into(),
|
||||||
limbo_core::Value::Blob(b) => env.byte_array_from_slice(b.as_slice())?.into(),
|
turso_core::Value::Blob(b) => env.byte_array_from_slice(b.as_slice())?.into(),
|
||||||
};
|
};
|
||||||
if let Err(e) = env.set_object_array_element(&obj_array, i as i32, obj) {
|
if let Err(e) = env.set_object_array_element(&obj_array, i as i32, obj) {
|
||||||
eprintln!("Error on parsing row: {:?}", e);
|
eprintln!("Error on parsing row: {:?}", e);
|
||||||
|
|
|
@ -11,7 +11,7 @@ description = "The Turso database library Node bindings"
|
||||||
crate-type = ["cdylib"]
|
crate-type = ["cdylib"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
limbo_core = { workspace = true }
|
turso_core = { workspace = true }
|
||||||
napi = { version = "2.16.17", default-features = false, features = ["napi4"] }
|
napi = { version = "2.16.17", default-features = false, features = ["napi4"] }
|
||||||
napi-derive = { version = "2.16.13", default-features = false }
|
napi-derive = { version = "2.16.13", default-features = false }
|
||||||
|
|
||||||
|
|
|
@ -6,10 +6,10 @@ use std::num::NonZeroUsize;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use limbo_core::{LimboError, StepResult};
|
|
||||||
use napi::iterator::Generator;
|
use napi::iterator::Generator;
|
||||||
use napi::{bindgen_prelude::ObjectFinalize, Env, JsUnknown};
|
use napi::{bindgen_prelude::ObjectFinalize, Env, JsUnknown};
|
||||||
use napi_derive::napi;
|
use napi_derive::napi;
|
||||||
|
use turso_core::{LimboError, StepResult};
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
#[napi(object)]
|
#[napi(object)]
|
||||||
|
@ -39,9 +39,9 @@ pub struct Database {
|
||||||
// pub open: bool,
|
// pub open: bool,
|
||||||
#[napi(writable = false)]
|
#[napi(writable = false)]
|
||||||
pub name: String,
|
pub name: String,
|
||||||
_db: Arc<limbo_core::Database>,
|
_db: Arc<turso_core::Database>,
|
||||||
conn: Arc<limbo_core::Connection>,
|
conn: Arc<turso_core::Connection>,
|
||||||
io: Arc<dyn limbo_core::IO>,
|
io: Arc<dyn turso_core::IO>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ObjectFinalize for Database {
|
impl ObjectFinalize for Database {
|
||||||
|
@ -57,21 +57,21 @@ impl Database {
|
||||||
#[napi(constructor)]
|
#[napi(constructor)]
|
||||||
pub fn new(path: String, options: Option<OpenDatabaseOptions>) -> napi::Result<Self> {
|
pub fn new(path: String, options: Option<OpenDatabaseOptions>) -> napi::Result<Self> {
|
||||||
let memory = path == ":memory:";
|
let memory = path == ":memory:";
|
||||||
let io: Arc<dyn limbo_core::IO> = if memory {
|
let io: Arc<dyn turso_core::IO> = if memory {
|
||||||
Arc::new(limbo_core::MemoryIO::new())
|
Arc::new(turso_core::MemoryIO::new())
|
||||||
} else {
|
} else {
|
||||||
Arc::new(limbo_core::PlatformIO::new().map_err(into_napi_error)?)
|
Arc::new(turso_core::PlatformIO::new().map_err(into_napi_error)?)
|
||||||
};
|
};
|
||||||
let opts = options.unwrap_or_default();
|
let opts = options.unwrap_or_default();
|
||||||
let flag = if opts.readonly {
|
let flag = if opts.readonly {
|
||||||
limbo_core::OpenFlags::ReadOnly
|
turso_core::OpenFlags::ReadOnly
|
||||||
} else {
|
} else {
|
||||||
limbo_core::OpenFlags::Create
|
turso_core::OpenFlags::Create
|
||||||
};
|
};
|
||||||
let file = io.open_file(&path, flag, false).map_err(into_napi_error)?;
|
let file = io.open_file(&path, flag, false).map_err(into_napi_error)?;
|
||||||
|
|
||||||
let db_file = Arc::new(DatabaseFile::new(file));
|
let db_file = Arc::new(DatabaseFile::new(file));
|
||||||
let db = limbo_core::Database::open(io.clone(), &path, db_file, false, false)
|
let db = turso_core::Database::open(io.clone(), &path, db_file, false, false)
|
||||||
.map_err(into_napi_error)?;
|
.map_err(into_napi_error)?;
|
||||||
let conn = db.connect().map_err(into_napi_error)?;
|
let conn = db.connect().map_err(into_napi_error)?;
|
||||||
|
|
||||||
|
@ -105,19 +105,19 @@ impl Database {
|
||||||
let mut stmt = stmt.inner.borrow_mut();
|
let mut stmt = stmt.inner.borrow_mut();
|
||||||
loop {
|
loop {
|
||||||
match stmt.step().map_err(into_napi_error)? {
|
match stmt.step().map_err(into_napi_error)? {
|
||||||
limbo_core::StepResult::Row => {
|
turso_core::StepResult::Row => {
|
||||||
let row: Vec<_> = stmt.row().unwrap().get_values().cloned().collect();
|
let row: Vec<_> = stmt.row().unwrap().get_values().cloned().collect();
|
||||||
return to_js_value(&env, &row[0]);
|
return to_js_value(&env, &row[0]);
|
||||||
}
|
}
|
||||||
limbo_core::StepResult::Done => {
|
turso_core::StepResult::Done => {
|
||||||
return Ok(env.get_undefined()?.into_unknown())
|
return Ok(env.get_undefined()?.into_unknown())
|
||||||
}
|
}
|
||||||
limbo_core::StepResult::IO => {
|
turso_core::StepResult::IO => {
|
||||||
self.io.run_once().map_err(into_napi_error)?;
|
self.io.run_once().map_err(into_napi_error)?;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
step @ limbo_core::StepResult::Interrupt
|
step @ turso_core::StepResult::Interrupt
|
||||||
| step @ limbo_core::StepResult::Busy => {
|
| step @ turso_core::StepResult::Busy => {
|
||||||
return Err(napi::Error::new(
|
return Err(napi::Error::new(
|
||||||
napi::Status::GenericFailure,
|
napi::Status::GenericFailure,
|
||||||
format!("{:?}", step),
|
format!("{:?}", step),
|
||||||
|
@ -162,7 +162,7 @@ impl Database {
|
||||||
|
|
||||||
#[napi]
|
#[napi]
|
||||||
pub fn load_extension(&self, path: String) -> napi::Result<()> {
|
pub fn load_extension(&self, path: String) -> napi::Result<()> {
|
||||||
let ext_path = limbo_core::resolve_ext_path(path.as_str()).map_err(into_napi_error)?;
|
let ext_path = turso_core::resolve_ext_path(path.as_str()).map_err(into_napi_error)?;
|
||||||
self.conn
|
self.conn
|
||||||
.load_extension(ext_path)
|
.load_extension(ext_path)
|
||||||
.map_err(into_napi_error)?;
|
.map_err(into_napi_error)?;
|
||||||
|
@ -237,12 +237,12 @@ pub struct Statement {
|
||||||
database: Database,
|
database: Database,
|
||||||
presentation_mode: PresentationMode,
|
presentation_mode: PresentationMode,
|
||||||
binded: bool,
|
binded: bool,
|
||||||
inner: Rc<RefCell<limbo_core::Statement>>,
|
inner: Rc<RefCell<turso_core::Statement>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[napi]
|
#[napi]
|
||||||
impl Statement {
|
impl Statement {
|
||||||
pub fn new(inner: RefCell<limbo_core::Statement>, database: Database, source: String) -> Self {
|
pub fn new(inner: RefCell<turso_core::Statement>, database: Database, source: String) -> Self {
|
||||||
Self {
|
Self {
|
||||||
inner: Rc::new(inner),
|
inner: Rc::new(inner),
|
||||||
database,
|
database,
|
||||||
|
@ -259,7 +259,7 @@ impl Statement {
|
||||||
loop {
|
loop {
|
||||||
let step = stmt.step().map_err(into_napi_error)?;
|
let step = stmt.step().map_err(into_napi_error)?;
|
||||||
match step {
|
match step {
|
||||||
limbo_core::StepResult::Row => {
|
turso_core::StepResult::Row => {
|
||||||
let row = stmt.row().unwrap();
|
let row = stmt.row().unwrap();
|
||||||
|
|
||||||
match self.presentation_mode {
|
match self.presentation_mode {
|
||||||
|
@ -297,12 +297,12 @@ impl Statement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
limbo_core::StepResult::Done => return Ok(env.get_undefined()?.into_unknown()),
|
turso_core::StepResult::Done => return Ok(env.get_undefined()?.into_unknown()),
|
||||||
limbo_core::StepResult::IO => {
|
turso_core::StepResult::IO => {
|
||||||
self.database.io.run_once().map_err(into_napi_error)?;
|
self.database.io.run_once().map_err(into_napi_error)?;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
limbo_core::StepResult::Interrupt | limbo_core::StepResult::Busy => {
|
turso_core::StepResult::Interrupt | turso_core::StepResult::Busy => {
|
||||||
return Err(napi::Error::new(
|
return Err(napi::Error::new(
|
||||||
napi::Status::GenericFailure,
|
napi::Status::GenericFailure,
|
||||||
format!("{:?}", step),
|
format!("{:?}", step),
|
||||||
|
@ -345,13 +345,13 @@ impl Statement {
|
||||||
fn internal_all(
|
fn internal_all(
|
||||||
&self,
|
&self,
|
||||||
env: Env,
|
env: Env,
|
||||||
mut stmt: RefMut<'_, limbo_core::Statement>,
|
mut stmt: RefMut<'_, turso_core::Statement>,
|
||||||
) -> napi::Result<JsUnknown> {
|
) -> napi::Result<JsUnknown> {
|
||||||
let mut results = env.create_empty_array()?;
|
let mut results = env.create_empty_array()?;
|
||||||
let mut index = 0;
|
let mut index = 0;
|
||||||
loop {
|
loop {
|
||||||
match stmt.step().map_err(into_napi_error)? {
|
match stmt.step().map_err(into_napi_error)? {
|
||||||
limbo_core::StepResult::Row => {
|
turso_core::StepResult::Row => {
|
||||||
let row = stmt.row().unwrap();
|
let row = stmt.row().unwrap();
|
||||||
|
|
||||||
match self.presentation_mode {
|
match self.presentation_mode {
|
||||||
|
@ -388,13 +388,13 @@ impl Statement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
limbo_core::StepResult::Done => {
|
turso_core::StepResult::Done => {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
limbo_core::StepResult::IO => {
|
turso_core::StepResult::IO => {
|
||||||
self.database.io.run_once().map_err(into_napi_error)?;
|
self.database.io.run_once().map_err(into_napi_error)?;
|
||||||
}
|
}
|
||||||
limbo_core::StepResult::Interrupt | limbo_core::StepResult::Busy => {
|
turso_core::StepResult::Interrupt | turso_core::StepResult::Busy => {
|
||||||
return Err(napi::Error::new(
|
return Err(napi::Error::new(
|
||||||
napi::Status::GenericFailure,
|
napi::Status::GenericFailure,
|
||||||
format!("{:?}", stmt.step()),
|
format!("{:?}", stmt.step()),
|
||||||
|
@ -447,7 +447,7 @@ impl Statement {
|
||||||
fn check_and_bind(
|
fn check_and_bind(
|
||||||
&self,
|
&self,
|
||||||
args: Option<Vec<JsUnknown>>,
|
args: Option<Vec<JsUnknown>>,
|
||||||
) -> napi::Result<RefMut<'_, limbo_core::Statement>> {
|
) -> napi::Result<RefMut<'_, turso_core::Statement>> {
|
||||||
let mut stmt = self.inner.borrow_mut();
|
let mut stmt = self.inner.borrow_mut();
|
||||||
stmt.reset();
|
stmt.reset();
|
||||||
if let Some(args) = args {
|
if let Some(args) = args {
|
||||||
|
@ -470,7 +470,7 @@ impl Statement {
|
||||||
|
|
||||||
#[napi(iterator)]
|
#[napi(iterator)]
|
||||||
pub struct IteratorStatement {
|
pub struct IteratorStatement {
|
||||||
stmt: Rc<RefCell<limbo_core::Statement>>,
|
stmt: Rc<RefCell<turso_core::Statement>>,
|
||||||
database: Database,
|
database: Database,
|
||||||
env: Env,
|
env: Env,
|
||||||
presentation_mode: PresentationMode,
|
presentation_mode: PresentationMode,
|
||||||
|
@ -488,7 +488,7 @@ impl Generator for IteratorStatement {
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
match stmt.step().ok()? {
|
match stmt.step().ok()? {
|
||||||
limbo_core::StepResult::Row => {
|
turso_core::StepResult::Row => {
|
||||||
let row = stmt.row().unwrap();
|
let row = stmt.row().unwrap();
|
||||||
|
|
||||||
match self.presentation_mode {
|
match self.presentation_mode {
|
||||||
|
@ -517,47 +517,47 @@ impl Generator for IteratorStatement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
limbo_core::StepResult::Done => return None,
|
turso_core::StepResult::Done => return None,
|
||||||
limbo_core::StepResult::IO => {
|
turso_core::StepResult::IO => {
|
||||||
self.database.io.run_once().ok()?;
|
self.database.io.run_once().ok()?;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
limbo_core::StepResult::Interrupt | limbo_core::StepResult::Busy => return None,
|
turso_core::StepResult::Interrupt | turso_core::StepResult::Busy => return None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_js_value(env: &napi::Env, value: &limbo_core::Value) -> napi::Result<JsUnknown> {
|
fn to_js_value(env: &napi::Env, value: &turso_core::Value) -> napi::Result<JsUnknown> {
|
||||||
match value {
|
match value {
|
||||||
limbo_core::Value::Null => Ok(env.get_null()?.into_unknown()),
|
turso_core::Value::Null => Ok(env.get_null()?.into_unknown()),
|
||||||
limbo_core::Value::Integer(i) => Ok(env.create_int64(*i)?.into_unknown()),
|
turso_core::Value::Integer(i) => Ok(env.create_int64(*i)?.into_unknown()),
|
||||||
limbo_core::Value::Float(f) => Ok(env.create_double(*f)?.into_unknown()),
|
turso_core::Value::Float(f) => Ok(env.create_double(*f)?.into_unknown()),
|
||||||
limbo_core::Value::Text(s) => Ok(env.create_string(s.as_str())?.into_unknown()),
|
turso_core::Value::Text(s) => Ok(env.create_string(s.as_str())?.into_unknown()),
|
||||||
limbo_core::Value::Blob(b) => Ok(env.create_buffer_copy(b.as_slice())?.into_unknown()),
|
turso_core::Value::Blob(b) => Ok(env.create_buffer_copy(b.as_slice())?.into_unknown()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_js_value(value: JsUnknown) -> napi::Result<limbo_core::Value> {
|
fn from_js_value(value: JsUnknown) -> napi::Result<turso_core::Value> {
|
||||||
match value.get_type()? {
|
match value.get_type()? {
|
||||||
napi::ValueType::Undefined | napi::ValueType::Null | napi::ValueType::Unknown => {
|
napi::ValueType::Undefined | napi::ValueType::Null | napi::ValueType::Unknown => {
|
||||||
Ok(limbo_core::Value::Null)
|
Ok(turso_core::Value::Null)
|
||||||
}
|
}
|
||||||
napi::ValueType::Boolean => {
|
napi::ValueType::Boolean => {
|
||||||
let b = value.coerce_to_bool()?.get_value()?;
|
let b = value.coerce_to_bool()?.get_value()?;
|
||||||
Ok(limbo_core::Value::Integer(b as i64))
|
Ok(turso_core::Value::Integer(b as i64))
|
||||||
}
|
}
|
||||||
napi::ValueType::Number => {
|
napi::ValueType::Number => {
|
||||||
let num = value.coerce_to_number()?.get_double()?;
|
let num = value.coerce_to_number()?.get_double()?;
|
||||||
if num.fract() == 0.0 {
|
if num.fract() == 0.0 {
|
||||||
Ok(limbo_core::Value::Integer(num as i64))
|
Ok(turso_core::Value::Integer(num as i64))
|
||||||
} else {
|
} else {
|
||||||
Ok(limbo_core::Value::Float(num))
|
Ok(turso_core::Value::Float(num))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
napi::ValueType::String => {
|
napi::ValueType::String => {
|
||||||
let s = value.coerce_to_string()?;
|
let s = value.coerce_to_string()?;
|
||||||
Ok(limbo_core::Value::Text(s.into_utf8()?.as_str()?.into()))
|
Ok(turso_core::Value::Text(s.into_utf8()?.as_str()?.into()))
|
||||||
}
|
}
|
||||||
napi::ValueType::Symbol
|
napi::ValueType::Symbol
|
||||||
| napi::ValueType::Object
|
| napi::ValueType::Object
|
||||||
|
@ -570,28 +570,28 @@ fn from_js_value(value: JsUnknown) -> napi::Result<limbo_core::Value> {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct DatabaseFile {
|
struct DatabaseFile {
|
||||||
file: Arc<dyn limbo_core::File>,
|
file: Arc<dyn turso_core::File>,
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl Send for DatabaseFile {}
|
unsafe impl Send for DatabaseFile {}
|
||||||
unsafe impl Sync for DatabaseFile {}
|
unsafe impl Sync for DatabaseFile {}
|
||||||
|
|
||||||
impl DatabaseFile {
|
impl DatabaseFile {
|
||||||
pub fn new(file: Arc<dyn limbo_core::File>) -> Self {
|
pub fn new(file: Arc<dyn turso_core::File>) -> Self {
|
||||||
Self { file }
|
Self { file }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl limbo_core::DatabaseStorage for DatabaseFile {
|
impl turso_core::DatabaseStorage for DatabaseFile {
|
||||||
fn read_page(&self, page_idx: usize, c: limbo_core::Completion) -> limbo_core::Result<()> {
|
fn read_page(&self, page_idx: usize, c: turso_core::Completion) -> turso_core::Result<()> {
|
||||||
let r = match c.completion_type {
|
let r = match c.completion_type {
|
||||||
limbo_core::CompletionType::Read(ref r) => r,
|
turso_core::CompletionType::Read(ref r) => r,
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
};
|
};
|
||||||
let size = r.buf().len();
|
let size = r.buf().len();
|
||||||
assert!(page_idx > 0);
|
assert!(page_idx > 0);
|
||||||
if !(512..=65536).contains(&size) || size & (size - 1) != 0 {
|
if !(512..=65536).contains(&size) || size & (size - 1) != 0 {
|
||||||
return Err(limbo_core::LimboError::NotADB);
|
return Err(turso_core::LimboError::NotADB);
|
||||||
}
|
}
|
||||||
let pos = (page_idx - 1) * size;
|
let pos = (page_idx - 1) * size;
|
||||||
self.file.pread(pos, c)?;
|
self.file.pread(pos, c)?;
|
||||||
|
@ -601,21 +601,21 @@ impl limbo_core::DatabaseStorage for DatabaseFile {
|
||||||
fn write_page(
|
fn write_page(
|
||||||
&self,
|
&self,
|
||||||
page_idx: usize,
|
page_idx: usize,
|
||||||
buffer: Arc<std::cell::RefCell<limbo_core::Buffer>>,
|
buffer: Arc<std::cell::RefCell<turso_core::Buffer>>,
|
||||||
c: limbo_core::Completion,
|
c: turso_core::Completion,
|
||||||
) -> limbo_core::Result<()> {
|
) -> turso_core::Result<()> {
|
||||||
let size = buffer.borrow().len();
|
let size = buffer.borrow().len();
|
||||||
let pos = (page_idx - 1) * size;
|
let pos = (page_idx - 1) * size;
|
||||||
self.file.pwrite(pos, buffer, c)?;
|
self.file.pwrite(pos, buffer, c)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sync(&self, c: limbo_core::Completion) -> limbo_core::Result<()> {
|
fn sync(&self, c: turso_core::Completion) -> turso_core::Result<()> {
|
||||||
let _ = self.file.sync(c)?;
|
let _ = self.file.sync(c)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn size(&self) -> limbo_core::Result<u64> {
|
fn size(&self) -> turso_core::Result<u64> {
|
||||||
self.file.size()
|
self.file.size()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ extension-module = ["pyo3/extension-module"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
limbo_core = { path = "../../core", features = ["io_uring"] }
|
turso_core = { path = "../../core", features = ["io_uring"] }
|
||||||
pyo3 = { version = "0.24.1", features = ["anyhow"] }
|
pyo3 = { version = "0.24.1", features = ["anyhow"] }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use errors::*;
|
use errors::*;
|
||||||
use limbo_core::Value;
|
|
||||||
use pyo3::prelude::*;
|
use pyo3::prelude::*;
|
||||||
use pyo3::types::{PyBytes, PyList, PyTuple};
|
use pyo3::types::{PyBytes, PyList, PyTuple};
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::num::NonZeroUsize;
|
use std::num::NonZeroUsize;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use turso_core::Value;
|
||||||
|
|
||||||
mod errors;
|
mod errors;
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ pub struct Cursor {
|
||||||
#[pyo3(get)]
|
#[pyo3(get)]
|
||||||
rowcount: i64,
|
rowcount: i64,
|
||||||
|
|
||||||
smt: Option<Rc<RefCell<limbo_core::Statement>>>,
|
smt: Option<Rc<RefCell<turso_core::Statement>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused_variables, clippy::arc_with_non_send_sync)]
|
#[allow(unused_variables, clippy::arc_with_non_send_sync)]
|
||||||
|
@ -95,7 +95,7 @@ impl Cursor {
|
||||||
// For DDL and DML statements,
|
// For DDL and DML statements,
|
||||||
// we need to execute the statement immediately
|
// we need to execute the statement immediately
|
||||||
if stmt_is_ddl || stmt_is_dml {
|
if stmt_is_ddl || stmt_is_dml {
|
||||||
while let limbo_core::StepResult::IO = stmt
|
while let turso_core::StepResult::IO = stmt
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
.step()
|
.step()
|
||||||
.map_err(|e| PyErr::new::<OperationalError, _>(format!("Step error: {:?}", e)))?
|
.map_err(|e| PyErr::new::<OperationalError, _>(format!("Step error: {:?}", e)))?
|
||||||
|
@ -125,23 +125,23 @@ impl Cursor {
|
||||||
match stmt.step().map_err(|e| {
|
match stmt.step().map_err(|e| {
|
||||||
PyErr::new::<OperationalError, _>(format!("Step error: {:?}", e))
|
PyErr::new::<OperationalError, _>(format!("Step error: {:?}", e))
|
||||||
})? {
|
})? {
|
||||||
limbo_core::StepResult::Row => {
|
turso_core::StepResult::Row => {
|
||||||
let row = stmt.row().unwrap();
|
let row = stmt.row().unwrap();
|
||||||
let py_row = row_to_py(py, row)?;
|
let py_row = row_to_py(py, row)?;
|
||||||
return Ok(Some(py_row));
|
return Ok(Some(py_row));
|
||||||
}
|
}
|
||||||
limbo_core::StepResult::IO => {
|
turso_core::StepResult::IO => {
|
||||||
self.conn.io.run_once().map_err(|e| {
|
self.conn.io.run_once().map_err(|e| {
|
||||||
PyErr::new::<OperationalError, _>(format!("IO error: {:?}", e))
|
PyErr::new::<OperationalError, _>(format!("IO error: {:?}", e))
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
limbo_core::StepResult::Interrupt => {
|
turso_core::StepResult::Interrupt => {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
}
|
}
|
||||||
limbo_core::StepResult::Done => {
|
turso_core::StepResult::Done => {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
}
|
}
|
||||||
limbo_core::StepResult::Busy => {
|
turso_core::StepResult::Busy => {
|
||||||
return Err(
|
return Err(
|
||||||
PyErr::new::<OperationalError, _>("Busy error".to_string()).into()
|
PyErr::new::<OperationalError, _>("Busy error".to_string()).into()
|
||||||
);
|
);
|
||||||
|
@ -161,23 +161,23 @@ impl Cursor {
|
||||||
match stmt.step().map_err(|e| {
|
match stmt.step().map_err(|e| {
|
||||||
PyErr::new::<OperationalError, _>(format!("Step error: {:?}", e))
|
PyErr::new::<OperationalError, _>(format!("Step error: {:?}", e))
|
||||||
})? {
|
})? {
|
||||||
limbo_core::StepResult::Row => {
|
turso_core::StepResult::Row => {
|
||||||
let row = stmt.row().unwrap();
|
let row = stmt.row().unwrap();
|
||||||
let py_row = row_to_py(py, row)?;
|
let py_row = row_to_py(py, row)?;
|
||||||
results.push(py_row);
|
results.push(py_row);
|
||||||
}
|
}
|
||||||
limbo_core::StepResult::IO => {
|
turso_core::StepResult::IO => {
|
||||||
self.conn.io.run_once().map_err(|e| {
|
self.conn.io.run_once().map_err(|e| {
|
||||||
PyErr::new::<OperationalError, _>(format!("IO error: {:?}", e))
|
PyErr::new::<OperationalError, _>(format!("IO error: {:?}", e))
|
||||||
})?;
|
})?;
|
||||||
}
|
}
|
||||||
limbo_core::StepResult::Interrupt => {
|
turso_core::StepResult::Interrupt => {
|
||||||
return Ok(results);
|
return Ok(results);
|
||||||
}
|
}
|
||||||
limbo_core::StepResult::Done => {
|
turso_core::StepResult::Done => {
|
||||||
return Ok(results);
|
return Ok(results);
|
||||||
}
|
}
|
||||||
limbo_core::StepResult::Busy => {
|
turso_core::StepResult::Busy => {
|
||||||
return Err(
|
return Err(
|
||||||
PyErr::new::<OperationalError, _>("Busy error".to_string()).into()
|
PyErr::new::<OperationalError, _>("Busy error".to_string()).into()
|
||||||
);
|
);
|
||||||
|
@ -225,8 +225,8 @@ fn stmt_is_ddl(sql: &str) -> bool {
|
||||||
#[pyclass(unsendable)]
|
#[pyclass(unsendable)]
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Connection {
|
pub struct Connection {
|
||||||
conn: Arc<limbo_core::Connection>,
|
conn: Arc<turso_core::Connection>,
|
||||||
io: Arc<dyn limbo_core::IO>,
|
io: Arc<dyn turso_core::IO>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[pymethods]
|
#[pymethods]
|
||||||
|
@ -302,39 +302,39 @@ impl Drop for Connection {
|
||||||
pub fn connect(path: &str) -> Result<Connection> {
|
pub fn connect(path: &str) -> Result<Connection> {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn open_or(
|
fn open_or(
|
||||||
io: Arc<dyn limbo_core::IO>,
|
io: Arc<dyn turso_core::IO>,
|
||||||
path: &str,
|
path: &str,
|
||||||
) -> std::result::Result<Arc<limbo_core::Database>, PyErr> {
|
) -> std::result::Result<Arc<turso_core::Database>, PyErr> {
|
||||||
limbo_core::Database::open_file(io, path, false, false).map_err(|e| {
|
turso_core::Database::open_file(io, path, false, false).map_err(|e| {
|
||||||
PyErr::new::<DatabaseError, _>(format!("Failed to open database: {:?}", e))
|
PyErr::new::<DatabaseError, _>(format!("Failed to open database: {:?}", e))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
match path {
|
match path {
|
||||||
":memory:" => {
|
":memory:" => {
|
||||||
let io: Arc<dyn limbo_core::IO> = Arc::new(limbo_core::MemoryIO::new());
|
let io: Arc<dyn turso_core::IO> = Arc::new(turso_core::MemoryIO::new());
|
||||||
let db = open_or(io.clone(), path)?;
|
let db = open_or(io.clone(), path)?;
|
||||||
let conn: Arc<limbo_core::Connection> = db.connect().unwrap();
|
let conn: Arc<turso_core::Connection> = db.connect().unwrap();
|
||||||
Ok(Connection { conn, io })
|
Ok(Connection { conn, io })
|
||||||
}
|
}
|
||||||
path => {
|
path => {
|
||||||
let io: Arc<dyn limbo_core::IO> = Arc::new(limbo_core::PlatformIO::new()?);
|
let io: Arc<dyn turso_core::IO> = Arc::new(turso_core::PlatformIO::new()?);
|
||||||
let db = open_or(io.clone(), path)?;
|
let db = open_or(io.clone(), path)?;
|
||||||
let conn: Arc<limbo_core::Connection> = db.connect().unwrap();
|
let conn: Arc<turso_core::Connection> = db.connect().unwrap();
|
||||||
Ok(Connection { conn, io })
|
Ok(Connection { conn, io })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn row_to_py(py: Python, row: &limbo_core::Row) -> Result<PyObject> {
|
fn row_to_py(py: Python, row: &turso_core::Row) -> Result<PyObject> {
|
||||||
let mut py_values = Vec::new();
|
let mut py_values = Vec::new();
|
||||||
for value in row.get_values() {
|
for value in row.get_values() {
|
||||||
match value {
|
match value {
|
||||||
limbo_core::Value::Null => py_values.push(py.None()),
|
turso_core::Value::Null => py_values.push(py.None()),
|
||||||
limbo_core::Value::Integer(i) => py_values.push(i.into_pyobject(py)?.into()),
|
turso_core::Value::Integer(i) => py_values.push(i.into_pyobject(py)?.into()),
|
||||||
limbo_core::Value::Float(f) => py_values.push(f.into_pyobject(py)?.into()),
|
turso_core::Value::Float(f) => py_values.push(f.into_pyobject(py)?.into()),
|
||||||
limbo_core::Value::Text(s) => py_values.push(s.as_str().into_pyobject(py)?.into()),
|
turso_core::Value::Text(s) => py_values.push(s.as_str().into_pyobject(py)?.into()),
|
||||||
limbo_core::Value::Blob(b) => py_values.push(PyBytes::new(py, b.as_slice()).into()),
|
turso_core::Value::Blob(b) => py_values.push(PyBytes::new(py, b.as_slice()).into()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(PyTuple::new(py, &py_values)
|
Ok(PyTuple::new(py, &py_values)
|
||||||
|
@ -344,7 +344,7 @@ fn row_to_py(py: Python, row: &limbo_core::Row) -> Result<PyObject> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Converts a Python object to a Limbo Value
|
/// Converts a Python object to a Limbo Value
|
||||||
fn py_to_owned_value(obj: &Bound<PyAny>) -> Result<limbo_core::Value> {
|
fn py_to_owned_value(obj: &Bound<PyAny>) -> Result<turso_core::Value> {
|
||||||
if obj.is_none() {
|
if obj.is_none() {
|
||||||
Ok(Value::Null)
|
Ok(Value::Null)
|
||||||
} else if let Ok(integer) = obj.extract::<i64>() {
|
} else if let Ok(integer) = obj.extract::<i64>() {
|
||||||
|
|
|
@ -10,7 +10,7 @@ repository.workspace = true
|
||||||
description = "Limbo Rust API"
|
description = "Limbo Rust API"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
limbo_core = { workspace = true, features = ["io_uring"] }
|
turso_core = { workspace = true, features = ["io_uring"] }
|
||||||
thiserror = "2.0.9"
|
thiserror = "2.0.9"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
|
|
@ -54,8 +54,8 @@ pub enum Error {
|
||||||
SqlExecutionFailure(String),
|
SqlExecutionFailure(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<limbo_core::LimboError> for Error {
|
impl From<turso_core::LimboError> for Error {
|
||||||
fn from(err: limbo_core::LimboError) -> Self {
|
fn from(err: turso_core::LimboError) -> Self {
|
||||||
Error::SqlExecutionFailure(err.to_string())
|
Error::SqlExecutionFailure(err.to_string())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,13 +82,13 @@ impl Builder {
|
||||||
pub async fn build(self) -> Result<Database> {
|
pub async fn build(self) -> Result<Database> {
|
||||||
match self.path.as_str() {
|
match self.path.as_str() {
|
||||||
":memory:" => {
|
":memory:" => {
|
||||||
let io: Arc<dyn limbo_core::IO> = Arc::new(limbo_core::MemoryIO::new());
|
let io: Arc<dyn turso_core::IO> = Arc::new(turso_core::MemoryIO::new());
|
||||||
let db = limbo_core::Database::open_file(io, self.path.as_str(), false, false)?;
|
let db = turso_core::Database::open_file(io, self.path.as_str(), false, false)?;
|
||||||
Ok(Database { inner: db })
|
Ok(Database { inner: db })
|
||||||
}
|
}
|
||||||
path => {
|
path => {
|
||||||
let io: Arc<dyn limbo_core::IO> = Arc::new(limbo_core::PlatformIO::new()?);
|
let io: Arc<dyn turso_core::IO> = Arc::new(turso_core::PlatformIO::new()?);
|
||||||
let db = limbo_core::Database::open_file(io, path, false, false)?;
|
let db = turso_core::Database::open_file(io, path, false, false)?;
|
||||||
Ok(Database { inner: db })
|
Ok(Database { inner: db })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,7 @@ impl Builder {
|
||||||
/// The `Database` object points to a database and allows you to connect to it
|
/// The `Database` object points to a database and allows you to connect to it
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Database {
|
pub struct Database {
|
||||||
inner: Arc<limbo_core::Database>,
|
inner: Arc<turso_core::Database>,
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl Send for Database {}
|
unsafe impl Send for Database {}
|
||||||
|
@ -126,7 +126,7 @@ impl Database {
|
||||||
|
|
||||||
/// A database connection.
|
/// A database connection.
|
||||||
pub struct Connection {
|
pub struct Connection {
|
||||||
inner: Arc<Mutex<Arc<limbo_core::Connection>>>,
|
inner: Arc<Mutex<Arc<turso_core::Connection>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Clone for Connection {
|
impl Clone for Connection {
|
||||||
|
@ -172,7 +172,7 @@ impl Connection {
|
||||||
/// Query a pragma.
|
/// Query a pragma.
|
||||||
pub fn pragma_query<F>(&self, pragma_name: &str, mut f: F) -> Result<()>
|
pub fn pragma_query<F>(&self, pragma_name: &str, mut f: F) -> Result<()>
|
||||||
where
|
where
|
||||||
F: FnMut(&Row) -> limbo_core::Result<()>,
|
F: FnMut(&Row) -> turso_core::Result<()>,
|
||||||
{
|
{
|
||||||
let conn = self
|
let conn = self
|
||||||
.inner
|
.inner
|
||||||
|
@ -203,7 +203,7 @@ impl Debug for Connection {
|
||||||
|
|
||||||
/// A prepared statement.
|
/// A prepared statement.
|
||||||
pub struct Statement {
|
pub struct Statement {
|
||||||
inner: Arc<Mutex<limbo_core::Statement>>,
|
inner: Arc<Mutex<turso_core::Statement>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Clone for Statement {
|
impl Clone for Statement {
|
||||||
|
@ -270,21 +270,21 @@ impl Statement {
|
||||||
loop {
|
loop {
|
||||||
let mut stmt = self.inner.lock().unwrap();
|
let mut stmt = self.inner.lock().unwrap();
|
||||||
match stmt.step() {
|
match stmt.step() {
|
||||||
Ok(limbo_core::StepResult::Row) => {
|
Ok(turso_core::StepResult::Row) => {
|
||||||
// unexpected row during execution, error out.
|
// unexpected row during execution, error out.
|
||||||
return Ok(2);
|
return Ok(2);
|
||||||
}
|
}
|
||||||
Ok(limbo_core::StepResult::Done) => {
|
Ok(turso_core::StepResult::Done) => {
|
||||||
return Ok(0);
|
return Ok(0);
|
||||||
}
|
}
|
||||||
Ok(limbo_core::StepResult::IO) => {
|
Ok(turso_core::StepResult::IO) => {
|
||||||
let _ = stmt.run_once();
|
let _ = stmt.run_once();
|
||||||
//return Ok(1);
|
//return Ok(1);
|
||||||
}
|
}
|
||||||
Ok(limbo_core::StepResult::Busy) => {
|
Ok(turso_core::StepResult::Busy) => {
|
||||||
return Ok(4);
|
return Ok(4);
|
||||||
}
|
}
|
||||||
Ok(limbo_core::StepResult::Interrupt) => {
|
Ok(turso_core::StepResult::Interrupt) => {
|
||||||
return Ok(3);
|
return Ok(3);
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
@ -347,7 +347,7 @@ pub struct Transaction {}
|
||||||
|
|
||||||
/// Results of a prepared statement query.
|
/// Results of a prepared statement query.
|
||||||
pub struct Rows {
|
pub struct Rows {
|
||||||
inner: Arc<Mutex<limbo_core::Statement>>,
|
inner: Arc<Mutex<turso_core::Statement>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Clone for Rows {
|
impl Clone for Rows {
|
||||||
|
@ -370,21 +370,21 @@ impl Rows {
|
||||||
.lock()
|
.lock()
|
||||||
.map_err(|e| Error::MutexError(e.to_string()))?;
|
.map_err(|e| Error::MutexError(e.to_string()))?;
|
||||||
match stmt.step() {
|
match stmt.step() {
|
||||||
Ok(limbo_core::StepResult::Row) => {
|
Ok(turso_core::StepResult::Row) => {
|
||||||
let row = stmt.row().unwrap();
|
let row = stmt.row().unwrap();
|
||||||
return Ok(Some(Row {
|
return Ok(Some(Row {
|
||||||
values: row.get_values().map(|v| v.to_owned()).collect(),
|
values: row.get_values().map(|v| v.to_owned()).collect(),
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
Ok(limbo_core::StepResult::Done) => return Ok(None),
|
Ok(turso_core::StepResult::Done) => return Ok(None),
|
||||||
Ok(limbo_core::StepResult::IO) => {
|
Ok(turso_core::StepResult::IO) => {
|
||||||
if let Err(e) = stmt.run_once() {
|
if let Err(e) = stmt.run_once() {
|
||||||
return Err(e.into());
|
return Err(e.into());
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Ok(limbo_core::StepResult::Busy) => return Ok(None),
|
Ok(turso_core::StepResult::Busy) => return Ok(None),
|
||||||
Ok(limbo_core::StepResult::Interrupt) => return Ok(None),
|
Ok(turso_core::StepResult::Interrupt) => return Ok(None),
|
||||||
_ => return Ok(None),
|
_ => return Ok(None),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -394,7 +394,7 @@ impl Rows {
|
||||||
/// Query result row.
|
/// Query result row.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Row {
|
pub struct Row {
|
||||||
values: Vec<limbo_core::Value>,
|
values: Vec<turso_core::Value>,
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl Send for Row {}
|
unsafe impl Send for Row {}
|
||||||
|
@ -404,11 +404,11 @@ impl Row {
|
||||||
pub fn get_value(&self, index: usize) -> Result<Value> {
|
pub fn get_value(&self, index: usize) -> Result<Value> {
|
||||||
let value = &self.values[index];
|
let value = &self.values[index];
|
||||||
match value {
|
match value {
|
||||||
limbo_core::Value::Integer(i) => Ok(Value::Integer(*i)),
|
turso_core::Value::Integer(i) => Ok(Value::Integer(*i)),
|
||||||
limbo_core::Value::Null => Ok(Value::Null),
|
turso_core::Value::Null => Ok(Value::Null),
|
||||||
limbo_core::Value::Float(f) => Ok(Value::Real(*f)),
|
turso_core::Value::Float(f) => Ok(Value::Real(*f)),
|
||||||
limbo_core::Value::Text(text) => Ok(Value::Text(text.to_string())),
|
turso_core::Value::Text(text) => Ok(Value::Text(text.to_string())),
|
||||||
limbo_core::Value::Blob(items) => Ok(Value::Blob(items.to_vec())),
|
turso_core::Value::Blob(items) => Ok(Value::Blob(items.to_vec())),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -417,16 +417,16 @@ impl Row {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> FromIterator<&'a limbo_core::Value> for Row {
|
impl<'a> FromIterator<&'a turso_core::Value> for Row {
|
||||||
fn from_iter<T: IntoIterator<Item = &'a limbo_core::Value>>(iter: T) -> Self {
|
fn from_iter<T: IntoIterator<Item = &'a turso_core::Value>>(iter: T) -> Self {
|
||||||
let values = iter
|
let values = iter
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|v| match v {
|
.map(|v| match v {
|
||||||
limbo_core::Value::Integer(i) => limbo_core::Value::Integer(*i),
|
turso_core::Value::Integer(i) => turso_core::Value::Integer(*i),
|
||||||
limbo_core::Value::Null => limbo_core::Value::Null,
|
turso_core::Value::Null => turso_core::Value::Null,
|
||||||
limbo_core::Value::Float(f) => limbo_core::Value::Float(*f),
|
turso_core::Value::Float(f) => turso_core::Value::Float(*f),
|
||||||
limbo_core::Value::Text(s) => limbo_core::Value::Text(s.clone()),
|
turso_core::Value::Text(s) => turso_core::Value::Text(s.clone()),
|
||||||
limbo_core::Value::Blob(b) => limbo_core::Value::Blob(b.clone()),
|
turso_core::Value::Blob(b) => turso_core::Value::Blob(b.clone()),
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
|
|
|
@ -110,14 +110,14 @@ impl Value {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Value> for limbo_core::Value {
|
impl From<Value> for turso_core::Value {
|
||||||
fn from(val: Value) -> Self {
|
fn from(val: Value) -> Self {
|
||||||
match val {
|
match val {
|
||||||
Value::Null => limbo_core::Value::Null,
|
Value::Null => turso_core::Value::Null,
|
||||||
Value::Integer(n) => limbo_core::Value::Integer(n),
|
Value::Integer(n) => turso_core::Value::Integer(n),
|
||||||
Value::Real(n) => limbo_core::Value::Float(n),
|
Value::Real(n) => turso_core::Value::Float(n),
|
||||||
Value::Text(t) => limbo_core::Value::from_text(&t),
|
Value::Text(t) => turso_core::Value::from_text(&t),
|
||||||
Value::Blob(items) => limbo_core::Value::from_blob(items),
|
Value::Blob(items) => turso_core::Value::from_blob(items),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ path = "lib.rs"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
console_error_panic_hook = "0.1.7"
|
console_error_panic_hook = "0.1.7"
|
||||||
js-sys = "0.3.72"
|
js-sys = "0.3.72"
|
||||||
limbo_core = { path = "../../core", default-features = false }
|
turso_core = { path = "../../core", default-features = false }
|
||||||
wasm-bindgen = "0.2"
|
wasm-bindgen = "0.2"
|
||||||
wasm-bindgen-futures = "0.4"
|
wasm-bindgen-futures = "0.4"
|
||||||
web-sys = "0.3"
|
web-sys = "0.3"
|
||||||
|
|
|
@ -2,16 +2,16 @@
|
||||||
compile_error!("Features 'web' and 'nodejs' cannot be enabled at the same time");
|
compile_error!("Features 'web' and 'nodejs' cannot be enabled at the same time");
|
||||||
|
|
||||||
use js_sys::{Array, Object};
|
use js_sys::{Array, Object};
|
||||||
use limbo_core::{Clock, Instant, OpenFlags, Result};
|
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use turso_core::{Clock, Instant, OpenFlags, Result};
|
||||||
use wasm_bindgen::prelude::*;
|
use wasm_bindgen::prelude::*;
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
pub struct Database {
|
pub struct Database {
|
||||||
db: Arc<limbo_core::Database>,
|
db: Arc<turso_core::Database>,
|
||||||
conn: Arc<limbo_core::Connection>,
|
conn: Arc<turso_core::Connection>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::arc_with_non_send_sync)]
|
#[allow(clippy::arc_with_non_send_sync)]
|
||||||
|
@ -19,10 +19,10 @@ pub struct Database {
|
||||||
impl Database {
|
impl Database {
|
||||||
#[wasm_bindgen(constructor)]
|
#[wasm_bindgen(constructor)]
|
||||||
pub fn new(path: &str) -> Database {
|
pub fn new(path: &str) -> Database {
|
||||||
let io: Arc<dyn limbo_core::IO> = Arc::new(PlatformIO { vfs: VFS::new() });
|
let io: Arc<dyn turso_core::IO> = Arc::new(PlatformIO { vfs: VFS::new() });
|
||||||
let file = io.open_file(path, OpenFlags::Create, false).unwrap();
|
let file = io.open_file(path, OpenFlags::Create, false).unwrap();
|
||||||
let db_file = Arc::new(DatabaseFile::new(file));
|
let db_file = Arc::new(DatabaseFile::new(file));
|
||||||
let db = limbo_core::Database::open(io, path, db_file, false, false).unwrap();
|
let db = turso_core::Database::open(io, path, db_file, false, false).unwrap();
|
||||||
let conn = db.connect().unwrap();
|
let conn = db.connect().unwrap();
|
||||||
Database { db, conn }
|
Database { db, conn }
|
||||||
}
|
}
|
||||||
|
@ -41,12 +41,12 @@ impl Database {
|
||||||
|
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
pub struct RowIterator {
|
pub struct RowIterator {
|
||||||
inner: RefCell<limbo_core::Statement>,
|
inner: RefCell<turso_core::Statement>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
impl RowIterator {
|
impl RowIterator {
|
||||||
fn new(inner: RefCell<limbo_core::Statement>) -> Self {
|
fn new(inner: RefCell<turso_core::Statement>) -> Self {
|
||||||
Self { inner }
|
Self { inner }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ impl RowIterator {
|
||||||
pub fn next(&mut self) -> JsValue {
|
pub fn next(&mut self) -> JsValue {
|
||||||
let mut stmt = self.inner.borrow_mut();
|
let mut stmt = self.inner.borrow_mut();
|
||||||
match stmt.step() {
|
match stmt.step() {
|
||||||
Ok(limbo_core::StepResult::Row) => {
|
Ok(turso_core::StepResult::Row) => {
|
||||||
let row = stmt.row().unwrap();
|
let row = stmt.row().unwrap();
|
||||||
let row_array = Array::new();
|
let row_array = Array::new();
|
||||||
for value in row.get_values() {
|
for value in row.get_values() {
|
||||||
|
@ -64,11 +64,11 @@ impl RowIterator {
|
||||||
}
|
}
|
||||||
JsValue::from(row_array)
|
JsValue::from(row_array)
|
||||||
}
|
}
|
||||||
Ok(limbo_core::StepResult::IO) => JsValue::UNDEFINED,
|
Ok(turso_core::StepResult::IO) => JsValue::UNDEFINED,
|
||||||
Ok(limbo_core::StepResult::Done) | Ok(limbo_core::StepResult::Interrupt) => {
|
Ok(turso_core::StepResult::Done) | Ok(turso_core::StepResult::Interrupt) => {
|
||||||
JsValue::UNDEFINED
|
JsValue::UNDEFINED
|
||||||
}
|
}
|
||||||
Ok(limbo_core::StepResult::Busy) => JsValue::UNDEFINED,
|
Ok(turso_core::StepResult::Busy) => JsValue::UNDEFINED,
|
||||||
Err(e) => panic!("Error: {:?}", e),
|
Err(e) => panic!("Error: {:?}", e),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,13 +76,13 @@ impl RowIterator {
|
||||||
|
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
pub struct Statement {
|
pub struct Statement {
|
||||||
inner: RefCell<limbo_core::Statement>,
|
inner: RefCell<turso_core::Statement>,
|
||||||
raw: bool,
|
raw: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
impl Statement {
|
impl Statement {
|
||||||
fn new(inner: RefCell<limbo_core::Statement>, raw: bool) -> Self {
|
fn new(inner: RefCell<turso_core::Statement>, raw: bool) -> Self {
|
||||||
Self { inner, raw }
|
Self { inner, raw }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ impl Statement {
|
||||||
pub fn get(&self) -> JsValue {
|
pub fn get(&self) -> JsValue {
|
||||||
let mut stmt = self.inner.borrow_mut();
|
let mut stmt = self.inner.borrow_mut();
|
||||||
match stmt.step() {
|
match stmt.step() {
|
||||||
Ok(limbo_core::StepResult::Row) => {
|
Ok(turso_core::StepResult::Row) => {
|
||||||
let row = stmt.row().unwrap();
|
let row = stmt.row().unwrap();
|
||||||
let row_array = js_sys::Array::new();
|
let row_array = js_sys::Array::new();
|
||||||
for value in row.get_values() {
|
for value in row.get_values() {
|
||||||
|
@ -104,10 +104,10 @@ impl Statement {
|
||||||
}
|
}
|
||||||
JsValue::from(row_array)
|
JsValue::from(row_array)
|
||||||
}
|
}
|
||||||
Ok(limbo_core::StepResult::IO)
|
Ok(turso_core::StepResult::IO)
|
||||||
| Ok(limbo_core::StepResult::Done)
|
| Ok(turso_core::StepResult::Done)
|
||||||
| Ok(limbo_core::StepResult::Interrupt)
|
| Ok(turso_core::StepResult::Interrupt)
|
||||||
| Ok(limbo_core::StepResult::Busy) => JsValue::UNDEFINED,
|
| Ok(turso_core::StepResult::Busy) => JsValue::UNDEFINED,
|
||||||
Err(e) => panic!("Error: {:?}", e),
|
Err(e) => panic!("Error: {:?}", e),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,7 @@ impl Statement {
|
||||||
loop {
|
loop {
|
||||||
let mut stmt = self.inner.borrow_mut();
|
let mut stmt = self.inner.borrow_mut();
|
||||||
match stmt.step() {
|
match stmt.step() {
|
||||||
Ok(limbo_core::StepResult::Row) => {
|
Ok(turso_core::StepResult::Row) => {
|
||||||
let row = stmt.row().unwrap();
|
let row = stmt.row().unwrap();
|
||||||
let row_array = js_sys::Array::new();
|
let row_array = js_sys::Array::new();
|
||||||
for value in row.get_values() {
|
for value in row.get_values() {
|
||||||
|
@ -126,10 +126,10 @@ impl Statement {
|
||||||
}
|
}
|
||||||
array.push(&row_array);
|
array.push(&row_array);
|
||||||
}
|
}
|
||||||
Ok(limbo_core::StepResult::IO) => {}
|
Ok(turso_core::StepResult::IO) => {}
|
||||||
Ok(limbo_core::StepResult::Interrupt) => break,
|
Ok(turso_core::StepResult::Interrupt) => break,
|
||||||
Ok(limbo_core::StepResult::Done) => break,
|
Ok(turso_core::StepResult::Done) => break,
|
||||||
Ok(limbo_core::StepResult::Busy) => break,
|
Ok(turso_core::StepResult::Busy) => break,
|
||||||
Err(e) => panic!("Error: {:?}", e),
|
Err(e) => panic!("Error: {:?}", e),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -168,10 +168,10 @@ impl Statement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_js_value(value: &limbo_core::Value) -> JsValue {
|
fn to_js_value(value: &turso_core::Value) -> JsValue {
|
||||||
match value {
|
match value {
|
||||||
limbo_core::Value::Null => JsValue::null(),
|
turso_core::Value::Null => JsValue::null(),
|
||||||
limbo_core::Value::Integer(i) => {
|
turso_core::Value::Integer(i) => {
|
||||||
let i = *i;
|
let i = *i;
|
||||||
if i >= i32::MIN as i64 && i <= i32::MAX as i64 {
|
if i >= i32::MIN as i64 && i <= i32::MAX as i64 {
|
||||||
JsValue::from(i as i32)
|
JsValue::from(i as i32)
|
||||||
|
@ -179,9 +179,9 @@ fn to_js_value(value: &limbo_core::Value) -> JsValue {
|
||||||
JsValue::from(i)
|
JsValue::from(i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
limbo_core::Value::Float(f) => JsValue::from(*f),
|
turso_core::Value::Float(f) => JsValue::from(*f),
|
||||||
limbo_core::Value::Text(t) => JsValue::from_str(t.as_str()),
|
turso_core::Value::Text(t) => JsValue::from_str(t.as_str()),
|
||||||
limbo_core::Value::Blob(b) => js_sys::Uint8Array::from(b.as_slice()).into(),
|
turso_core::Value::Blob(b) => js_sys::Uint8Array::from(b.as_slice()).into(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,7 +200,7 @@ impl File {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl limbo_core::File for File {
|
impl turso_core::File for File {
|
||||||
fn lock_file(&self, _exclusive: bool) -> Result<()> {
|
fn lock_file(&self, _exclusive: bool) -> Result<()> {
|
||||||
// TODO
|
// TODO
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -211,9 +211,9 @@ impl limbo_core::File for File {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pread(&self, pos: usize, c: limbo_core::Completion) -> Result<Arc<limbo_core::Completion>> {
|
fn pread(&self, pos: usize, c: turso_core::Completion) -> Result<Arc<turso_core::Completion>> {
|
||||||
let r = match c.completion_type {
|
let r = match c.completion_type {
|
||||||
limbo_core::CompletionType::Read(ref r) => r,
|
turso_core::CompletionType::Read(ref r) => r,
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
};
|
};
|
||||||
{
|
{
|
||||||
|
@ -230,11 +230,11 @@ impl limbo_core::File for File {
|
||||||
fn pwrite(
|
fn pwrite(
|
||||||
&self,
|
&self,
|
||||||
pos: usize,
|
pos: usize,
|
||||||
buffer: Arc<std::cell::RefCell<limbo_core::Buffer>>,
|
buffer: Arc<std::cell::RefCell<turso_core::Buffer>>,
|
||||||
c: limbo_core::Completion,
|
c: turso_core::Completion,
|
||||||
) -> Result<Arc<limbo_core::Completion>> {
|
) -> Result<Arc<turso_core::Completion>> {
|
||||||
let w = match c.completion_type {
|
let w = match c.completion_type {
|
||||||
limbo_core::CompletionType::Write(ref w) => w,
|
turso_core::CompletionType::Write(ref w) => w,
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
};
|
};
|
||||||
let buf = buffer.borrow();
|
let buf = buffer.borrow();
|
||||||
|
@ -245,7 +245,7 @@ impl limbo_core::File for File {
|
||||||
Ok(Arc::new(c))
|
Ok(Arc::new(c))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sync(&self, c: limbo_core::Completion) -> Result<Arc<limbo_core::Completion>> {
|
fn sync(&self, c: turso_core::Completion) -> Result<Arc<turso_core::Completion>> {
|
||||||
self.vfs.sync(self.fd);
|
self.vfs.sync(self.fd);
|
||||||
c.complete(0);
|
c.complete(0);
|
||||||
#[allow(clippy::arc_with_non_send_sync)]
|
#[allow(clippy::arc_with_non_send_sync)]
|
||||||
|
@ -275,13 +275,13 @@ impl Clock for PlatformIO {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl limbo_core::IO for PlatformIO {
|
impl turso_core::IO for PlatformIO {
|
||||||
fn open_file(
|
fn open_file(
|
||||||
&self,
|
&self,
|
||||||
path: &str,
|
path: &str,
|
||||||
_flags: OpenFlags,
|
_flags: OpenFlags,
|
||||||
_direct: bool,
|
_direct: bool,
|
||||||
) -> Result<Arc<dyn limbo_core::File>> {
|
) -> Result<Arc<dyn turso_core::File>> {
|
||||||
let fd = self.vfs.open(path, "a+");
|
let fd = self.vfs.open(path, "a+");
|
||||||
Ok(Arc::new(File {
|
Ok(Arc::new(File {
|
||||||
vfs: VFS::new(),
|
vfs: VFS::new(),
|
||||||
|
@ -289,7 +289,7 @@ impl limbo_core::IO for PlatformIO {
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wait_for_completion(&self, c: Arc<limbo_core::Completion>) -> Result<()> {
|
fn wait_for_completion(&self, c: Arc<turso_core::Completion>) -> Result<()> {
|
||||||
while !c.is_completed() {
|
while !c.is_completed() {
|
||||||
self.run_once()?;
|
self.run_once()?;
|
||||||
}
|
}
|
||||||
|
@ -306,8 +306,8 @@ impl limbo_core::IO for PlatformIO {
|
||||||
i64::from_ne_bytes(buf)
|
i64::from_ne_bytes(buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_memory_io(&self) -> Arc<limbo_core::MemoryIO> {
|
fn get_memory_io(&self) -> Arc<turso_core::MemoryIO> {
|
||||||
Arc::new(limbo_core::MemoryIO::new())
|
Arc::new(turso_core::MemoryIO::new())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -326,28 +326,28 @@ extern "C" {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct DatabaseFile {
|
pub struct DatabaseFile {
|
||||||
file: Arc<dyn limbo_core::File>,
|
file: Arc<dyn turso_core::File>,
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl Send for DatabaseFile {}
|
unsafe impl Send for DatabaseFile {}
|
||||||
unsafe impl Sync for DatabaseFile {}
|
unsafe impl Sync for DatabaseFile {}
|
||||||
|
|
||||||
impl DatabaseFile {
|
impl DatabaseFile {
|
||||||
pub fn new(file: Arc<dyn limbo_core::File>) -> Self {
|
pub fn new(file: Arc<dyn turso_core::File>) -> Self {
|
||||||
Self { file }
|
Self { file }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl limbo_core::DatabaseStorage for DatabaseFile {
|
impl turso_core::DatabaseStorage for DatabaseFile {
|
||||||
fn read_page(&self, page_idx: usize, c: limbo_core::Completion) -> Result<()> {
|
fn read_page(&self, page_idx: usize, c: turso_core::Completion) -> Result<()> {
|
||||||
let r = match c.completion_type {
|
let r = match c.completion_type {
|
||||||
limbo_core::CompletionType::Read(ref r) => r,
|
turso_core::CompletionType::Read(ref r) => r,
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
};
|
};
|
||||||
let size = r.buf().len();
|
let size = r.buf().len();
|
||||||
assert!(page_idx > 0);
|
assert!(page_idx > 0);
|
||||||
if !(512..=65536).contains(&size) || size & (size - 1) != 0 {
|
if !(512..=65536).contains(&size) || size & (size - 1) != 0 {
|
||||||
return Err(limbo_core::LimboError::NotADB);
|
return Err(turso_core::LimboError::NotADB);
|
||||||
}
|
}
|
||||||
let pos = (page_idx - 1) * size;
|
let pos = (page_idx - 1) * size;
|
||||||
self.file.pread(pos, c)?;
|
self.file.pread(pos, c)?;
|
||||||
|
@ -357,8 +357,8 @@ impl limbo_core::DatabaseStorage for DatabaseFile {
|
||||||
fn write_page(
|
fn write_page(
|
||||||
&self,
|
&self,
|
||||||
page_idx: usize,
|
page_idx: usize,
|
||||||
buffer: Arc<std::cell::RefCell<limbo_core::Buffer>>,
|
buffer: Arc<std::cell::RefCell<turso_core::Buffer>>,
|
||||||
c: limbo_core::Completion,
|
c: turso_core::Completion,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let size = buffer.borrow().len();
|
let size = buffer.borrow().len();
|
||||||
let pos = (page_idx - 1) * size;
|
let pos = (page_idx - 1) * size;
|
||||||
|
@ -366,7 +366,7 @@ impl limbo_core::DatabaseStorage for DatabaseFile {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sync(&self, c: limbo_core::Completion) -> Result<()> {
|
fn sync(&self, c: turso_core::Completion) -> Result<()> {
|
||||||
let _ = self.file.sync(c)?;
|
let _ = self.file.sync(c)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ ctrlc = "3.4.4"
|
||||||
dirs = "5.0.1"
|
dirs = "5.0.1"
|
||||||
env_logger = "0.10.1"
|
env_logger = "0.10.1"
|
||||||
libc = "0.2.172"
|
libc = "0.2.172"
|
||||||
limbo_core = { path = "../core", default-features = true, features = [
|
turso_core = { path = "../core", default-features = true, features = [
|
||||||
"completion",
|
"completion",
|
||||||
] }
|
] }
|
||||||
miette = { version = "7.4.0", features = ["fancy"] }
|
miette = { version = "7.4.0", features = ["fancy"] }
|
||||||
|
@ -49,7 +49,7 @@ toml_edit = {version = "0.22.24", features = ["serde"]}
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["io_uring"]
|
default = ["io_uring"]
|
||||||
io_uring = ["limbo_core/io_uring"]
|
io_uring = ["turso_core/io_uring"]
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
syntect = { git = "https://github.com/trishume/syntect.git", rev = "64644ffe064457265cbcee12a0c1baf9485ba6ee" }
|
syntect = { git = "https://github.com/trishume/syntect.git", rev = "64644ffe064457265cbcee12a0c1baf9485ba6ee" }
|
||||||
|
|
14
cli/app.rs
14
cli/app.rs
|
@ -11,9 +11,9 @@ use crate::{
|
||||||
HISTORY_FILE,
|
HISTORY_FILE,
|
||||||
};
|
};
|
||||||
use comfy_table::{Attribute, Cell, CellAlignment, ContentArrangement, Row, Table};
|
use comfy_table::{Attribute, Cell, CellAlignment, ContentArrangement, Row, Table};
|
||||||
use limbo_core::{Database, LimboError, Statement, StepResult, Value};
|
|
||||||
use tracing_appender::non_blocking::WorkerGuard;
|
use tracing_appender::non_blocking::WorkerGuard;
|
||||||
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilter};
|
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilter};
|
||||||
|
use turso_core::{Database, LimboError, Statement, StepResult, Value};
|
||||||
|
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use rustyline::{error::ReadlineError, history::DefaultHistory, Editor};
|
use rustyline::{error::ReadlineError, history::DefaultHistory, Editor};
|
||||||
|
@ -67,9 +67,9 @@ const PROMPT: &str = "turso> ";
|
||||||
|
|
||||||
pub struct Limbo {
|
pub struct Limbo {
|
||||||
pub prompt: String,
|
pub prompt: String,
|
||||||
io: Arc<dyn limbo_core::IO>,
|
io: Arc<dyn turso_core::IO>,
|
||||||
writer: Box<dyn Write>,
|
writer: Box<dyn Write>,
|
||||||
conn: Arc<limbo_core::Connection>,
|
conn: Arc<turso_core::Connection>,
|
||||||
pub interrupt_count: Arc<AtomicUsize>,
|
pub interrupt_count: Arc<AtomicUsize>,
|
||||||
input_buff: String,
|
input_buff: String,
|
||||||
opts: Settings,
|
opts: Settings,
|
||||||
|
@ -222,7 +222,7 @@ impl Limbo {
|
||||||
|
|
||||||
#[cfg(not(target_family = "wasm"))]
|
#[cfg(not(target_family = "wasm"))]
|
||||||
fn handle_load_extension(&mut self, path: &str) -> Result<(), String> {
|
fn handle_load_extension(&mut self, path: &str) -> Result<(), String> {
|
||||||
let ext_path = limbo_core::resolve_ext_path(path).map_err(|e| e.to_string())?;
|
let ext_path = turso_core::resolve_ext_path(path).map_err(|e| e.to_string())?;
|
||||||
self.conn
|
self.conn
|
||||||
.load_extension(ext_path)
|
.load_extension(ext_path)
|
||||||
.map_err(|e| e.to_string())
|
.map_err(|e| e.to_string())
|
||||||
|
@ -235,7 +235,7 @@ impl Limbo {
|
||||||
query_internal!(
|
query_internal!(
|
||||||
self,
|
self,
|
||||||
query,
|
query,
|
||||||
|row: &limbo_core::Row| -> Result<(), LimboError> {
|
|row: &turso_core::Row| -> Result<(), LimboError> {
|
||||||
let name: &str = row.get::<&str>(1)?;
|
let name: &str = row.get::<&str>(1)?;
|
||||||
cols.push(name.to_string());
|
cols.push(name.to_string());
|
||||||
let value_type: &str = row.get::<&str>(2)?;
|
let value_type: &str = row.get::<&str>(2)?;
|
||||||
|
@ -251,7 +251,7 @@ impl Limbo {
|
||||||
query_internal!(
|
query_internal!(
|
||||||
self,
|
self,
|
||||||
select,
|
select,
|
||||||
|row: &limbo_core::Row| -> Result<(), LimboError> {
|
|row: &turso_core::Row| -> Result<(), LimboError> {
|
||||||
let values = row
|
let values = row
|
||||||
.get_values()
|
.get_values()
|
||||||
.zip(value_types.iter())
|
.zip(value_types.iter())
|
||||||
|
@ -302,7 +302,7 @@ impl Limbo {
|
||||||
let res = query_internal!(
|
let res = query_internal!(
|
||||||
self,
|
self,
|
||||||
query,
|
query,
|
||||||
|row: &limbo_core::Row| -> Result<(), LimboError> {
|
|row: &turso_core::Row| -> Result<(), LimboError> {
|
||||||
let sql: &str = row.get::<&str>(2)?;
|
let sql: &str = row.get::<&str>(2)?;
|
||||||
let name: &str = row.get::<&str>(0)?;
|
let name: &str = row.get::<&str>(0)?;
|
||||||
self.write_fmt(format_args!("{};", sql))?;
|
self.write_fmt(format_args!("{};", sql))?;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use clap::Args;
|
use clap::Args;
|
||||||
use clap_complete::{ArgValueCompleter, PathCompleter};
|
use clap_complete::{ArgValueCompleter, PathCompleter};
|
||||||
use limbo_core::Connection;
|
|
||||||
use std::{fs::File, io::Write, path::PathBuf, sync::Arc};
|
use std::{fs::File, io::Write, path::PathBuf, sync::Arc};
|
||||||
|
use turso_core::Connection;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Args)]
|
#[derive(Debug, Clone, Args)]
|
||||||
pub struct ImportArgs {
|
pub struct ImportArgs {
|
||||||
|
@ -21,14 +21,14 @@ pub struct ImportArgs {
|
||||||
|
|
||||||
pub struct ImportFile<'a> {
|
pub struct ImportFile<'a> {
|
||||||
conn: Arc<Connection>,
|
conn: Arc<Connection>,
|
||||||
io: Arc<dyn limbo_core::IO>,
|
io: Arc<dyn turso_core::IO>,
|
||||||
writer: &'a mut dyn Write,
|
writer: &'a mut dyn Write,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ImportFile<'a> {
|
impl<'a> ImportFile<'a> {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
conn: Arc<Connection>,
|
conn: Arc<Connection>,
|
||||||
io: Arc<dyn limbo_core::IO>,
|
io: Arc<dyn turso_core::IO>,
|
||||||
writer: &'a mut dyn Write,
|
writer: &'a mut dyn Write,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self { conn, io, writer }
|
Self { conn, io, writer }
|
||||||
|
@ -78,17 +78,17 @@ impl<'a> ImportFile<'a> {
|
||||||
if let Some(mut rows) = rows {
|
if let Some(mut rows) = rows {
|
||||||
while let Ok(x) = rows.step() {
|
while let Ok(x) = rows.step() {
|
||||||
match x {
|
match x {
|
||||||
limbo_core::StepResult::IO => {
|
turso_core::StepResult::IO => {
|
||||||
self.io.run_once().unwrap();
|
self.io.run_once().unwrap();
|
||||||
}
|
}
|
||||||
limbo_core::StepResult::Done => break,
|
turso_core::StepResult::Done => break,
|
||||||
limbo_core::StepResult::Interrupt => break,
|
turso_core::StepResult::Interrupt => break,
|
||||||
limbo_core::StepResult::Busy => {
|
turso_core::StepResult::Busy => {
|
||||||
let _ =
|
let _ =
|
||||||
self.writer.write_all("database is busy\n".as_bytes());
|
self.writer.write_all("database is busy\n".as_bytes());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
limbo_core::StepResult::Row => todo!(),
|
turso_core::StepResult::Row => todo!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use limbo_core::{Connection, StepResult};
|
|
||||||
use nu_ansi_term::{Color, Style};
|
use nu_ansi_term::{Color, Style};
|
||||||
use rustyline::completion::{extract_word, Completer, Pair};
|
use rustyline::completion::{extract_word, Completer, Pair};
|
||||||
use rustyline::highlight::Highlighter;
|
use rustyline::highlight::Highlighter;
|
||||||
|
@ -15,6 +14,7 @@ use syntect::easy::HighlightLines;
|
||||||
use syntect::highlighting::ThemeSet;
|
use syntect::highlighting::ThemeSet;
|
||||||
use syntect::parsing::{Scope, SyntaxSet};
|
use syntect::parsing::{Scope, SyntaxSet};
|
||||||
use syntect::util::{as_24_bit_terminal_escaped, LinesWithEndings};
|
use syntect::util::{as_24_bit_terminal_escaped, LinesWithEndings};
|
||||||
|
use turso_core::{Connection, StepResult};
|
||||||
|
|
||||||
use crate::commands::CommandParser;
|
use crate::commands::CommandParser;
|
||||||
use crate::config::{HighlightConfig, CONFIG_DIR};
|
use crate::config::{HighlightConfig, CONFIG_DIR};
|
||||||
|
@ -42,7 +42,7 @@ pub struct LimboHelper {
|
||||||
impl LimboHelper {
|
impl LimboHelper {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
conn: Arc<Connection>,
|
conn: Arc<Connection>,
|
||||||
io: Arc<dyn limbo_core::IO>,
|
io: Arc<dyn turso_core::IO>,
|
||||||
syntax_config: Option<HighlightConfig>,
|
syntax_config: Option<HighlightConfig>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
// Load only predefined syntax
|
// Load only predefined syntax
|
||||||
|
@ -141,7 +141,7 @@ impl Highlighter for LimboHelper {
|
||||||
|
|
||||||
pub struct SqlCompleter<C: Parser + Send + Sync + 'static> {
|
pub struct SqlCompleter<C: Parser + Send + Sync + 'static> {
|
||||||
conn: Arc<Connection>,
|
conn: Arc<Connection>,
|
||||||
io: Arc<dyn limbo_core::IO>,
|
io: Arc<dyn turso_core::IO>,
|
||||||
// Has to be a ref cell as Rustyline takes immutable reference to self
|
// Has to be a ref cell as Rustyline takes immutable reference to self
|
||||||
// This problem would be solved with Reedline as it uses &mut self for completions
|
// This problem would be solved with Reedline as it uses &mut self for completions
|
||||||
cmd: RefCell<clap::Command>,
|
cmd: RefCell<clap::Command>,
|
||||||
|
@ -149,7 +149,7 @@ pub struct SqlCompleter<C: Parser + Send + Sync + 'static> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: Parser + Send + Sync + 'static> SqlCompleter<C> {
|
impl<C: Parser + Send + Sync + 'static> SqlCompleter<C> {
|
||||||
pub fn new(conn: Arc<Connection>, io: Arc<dyn limbo_core::IO>) -> Self {
|
pub fn new(conn: Arc<Connection>, io: Arc<dyn turso_core::IO>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
conn,
|
conn,
|
||||||
io,
|
io,
|
||||||
|
|
14
cli/input.rs
14
cli/input.rs
|
@ -145,28 +145,28 @@ pub fn get_writer(output: &str) -> Box<dyn Write> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_io(db_location: DbLocation, io_choice: &str) -> anyhow::Result<Arc<dyn limbo_core::IO>> {
|
pub fn get_io(db_location: DbLocation, io_choice: &str) -> anyhow::Result<Arc<dyn turso_core::IO>> {
|
||||||
Ok(match db_location {
|
Ok(match db_location {
|
||||||
DbLocation::Memory => Arc::new(limbo_core::MemoryIO::new()),
|
DbLocation::Memory => Arc::new(turso_core::MemoryIO::new()),
|
||||||
DbLocation::Path => {
|
DbLocation::Path => {
|
||||||
match io_choice {
|
match io_choice {
|
||||||
"memory" => Arc::new(limbo_core::MemoryIO::new()),
|
"memory" => Arc::new(turso_core::MemoryIO::new()),
|
||||||
"syscall" => {
|
"syscall" => {
|
||||||
// We are building for Linux/macOS and syscall backend has been selected
|
// We are building for Linux/macOS and syscall backend has been selected
|
||||||
#[cfg(target_family = "unix")]
|
#[cfg(target_family = "unix")]
|
||||||
{
|
{
|
||||||
Arc::new(limbo_core::UnixIO::new()?)
|
Arc::new(turso_core::UnixIO::new()?)
|
||||||
}
|
}
|
||||||
// We are not building for Linux/macOS and syscall backend has been selected
|
// We are not building for Linux/macOS and syscall backend has been selected
|
||||||
#[cfg(not(target_family = "unix"))]
|
#[cfg(not(target_family = "unix"))]
|
||||||
{
|
{
|
||||||
Arc::new(limbo_core::PlatformIO::new()?)
|
Arc::new(turso_core::PlatformIO::new()?)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// We are building for Linux and io_uring backend has been selected
|
// We are building for Linux and io_uring backend has been selected
|
||||||
#[cfg(all(target_os = "linux", feature = "io_uring"))]
|
#[cfg(all(target_os = "linux", feature = "io_uring"))]
|
||||||
"io_uring" => Arc::new(limbo_core::UringIO::new()?),
|
"io_uring" => Arc::new(turso_core::UringIO::new()?),
|
||||||
_ => Arc::new(limbo_core::PlatformIO::new()?),
|
_ => Arc::new(turso_core::PlatformIO::new()?),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
# Copyright 2023 the Limbo authors. All rights reserved. MIT license.
|
# Copyright 2023-2025 the Turso authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
[package]
|
[package]
|
||||||
name = "limbo_core"
|
name = "turso_core"
|
||||||
version.workspace = true
|
version.workspace = true
|
||||||
authors.workspace = true
|
authors.workspace = true
|
||||||
edition.workspace = true
|
edition.workspace = true
|
||||||
license.workspace = true
|
license.workspace = true
|
||||||
repository.workspace = true
|
repository.workspace = true
|
||||||
description = "The Limbo database library"
|
description = "The Turso database library"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "limbo_core"
|
name = "turso_core"
|
||||||
path = "lib.rs"
|
path = "lib.rs"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion};
|
use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion};
|
||||||
use limbo_core::{Database, PlatformIO, IO};
|
|
||||||
use pprof::criterion::{Output, PProfProfiler};
|
use pprof::criterion::{Output, PProfProfiler};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use turso_core::{Database, PlatformIO, IO};
|
||||||
|
|
||||||
fn rusqlite_open() -> rusqlite::Connection {
|
fn rusqlite_open() -> rusqlite::Connection {
|
||||||
let sqlite_conn = rusqlite::Connection::open("../testing/testing.db").unwrap();
|
let sqlite_conn = rusqlite::Connection::open("../testing/testing.db").unwrap();
|
||||||
|
@ -83,16 +83,16 @@ fn bench_execute_select_rows(criterion: &mut Criterion) {
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
loop {
|
loop {
|
||||||
match stmt.step().unwrap() {
|
match stmt.step().unwrap() {
|
||||||
limbo_core::StepResult::Row => {
|
turso_core::StepResult::Row => {
|
||||||
black_box(stmt.row());
|
black_box(stmt.row());
|
||||||
}
|
}
|
||||||
limbo_core::StepResult::IO => {
|
turso_core::StepResult::IO => {
|
||||||
let _ = io.run_once();
|
let _ = io.run_once();
|
||||||
}
|
}
|
||||||
limbo_core::StepResult::Done => {
|
turso_core::StepResult::Done => {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
limbo_core::StepResult::Interrupt | limbo_core::StepResult::Busy => {
|
turso_core::StepResult::Interrupt | turso_core::StepResult::Busy => {
|
||||||
unreachable!();
|
unreachable!();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -145,16 +145,16 @@ fn bench_execute_select_1(criterion: &mut Criterion) {
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
loop {
|
loop {
|
||||||
match stmt.step().unwrap() {
|
match stmt.step().unwrap() {
|
||||||
limbo_core::StepResult::Row => {
|
turso_core::StepResult::Row => {
|
||||||
black_box(stmt.row());
|
black_box(stmt.row());
|
||||||
}
|
}
|
||||||
limbo_core::StepResult::IO => {
|
turso_core::StepResult::IO => {
|
||||||
let _ = io.run_once();
|
let _ = io.run_once();
|
||||||
}
|
}
|
||||||
limbo_core::StepResult::Done => {
|
turso_core::StepResult::Done => {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
limbo_core::StepResult::Interrupt | limbo_core::StepResult::Busy => {
|
turso_core::StepResult::Interrupt | turso_core::StepResult::Busy => {
|
||||||
unreachable!();
|
unreachable!();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -198,16 +198,16 @@ fn bench_execute_select_count(criterion: &mut Criterion) {
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
loop {
|
loop {
|
||||||
match stmt.step().unwrap() {
|
match stmt.step().unwrap() {
|
||||||
limbo_core::StepResult::Row => {
|
turso_core::StepResult::Row => {
|
||||||
black_box(stmt.row());
|
black_box(stmt.row());
|
||||||
}
|
}
|
||||||
limbo_core::StepResult::IO => {
|
turso_core::StepResult::IO => {
|
||||||
let _ = io.run_once();
|
let _ = io.run_once();
|
||||||
}
|
}
|
||||||
limbo_core::StepResult::Done => {
|
turso_core::StepResult::Done => {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
limbo_core::StepResult::Interrupt | limbo_core::StepResult::Busy => {
|
turso_core::StepResult::Interrupt | turso_core::StepResult::Busy => {
|
||||||
unreachable!();
|
unreachable!();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||||
use limbo_core::{Database, PlatformIO, IO};
|
|
||||||
use pprof::{
|
use pprof::{
|
||||||
criterion::{Output, PProfProfiler},
|
criterion::{Output, PProfProfiler},
|
||||||
flamegraph::Options,
|
flamegraph::Options,
|
||||||
};
|
};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use turso_core::{Database, PlatformIO, IO};
|
||||||
|
|
||||||
// Title: JSONB Function Benchmarking
|
// Title: JSONB Function Benchmarking
|
||||||
|
|
||||||
|
@ -451,14 +451,14 @@ fn bench(criterion: &mut Criterion) {
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
loop {
|
loop {
|
||||||
match stmt.step().unwrap() {
|
match stmt.step().unwrap() {
|
||||||
limbo_core::StepResult::Row => {}
|
turso_core::StepResult::Row => {}
|
||||||
limbo_core::StepResult::IO => {
|
turso_core::StepResult::IO => {
|
||||||
let _ = io.run_once();
|
let _ = io.run_once();
|
||||||
}
|
}
|
||||||
limbo_core::StepResult::Done => {
|
turso_core::StepResult::Done => {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
limbo_core::StepResult::Interrupt | limbo_core::StepResult::Busy => {
|
turso_core::StepResult::Interrupt | turso_core::StepResult::Busy => {
|
||||||
unreachable!();
|
unreachable!();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -610,14 +610,14 @@ fn bench_sequential_jsonb(criterion: &mut Criterion) {
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
loop {
|
loop {
|
||||||
match stmt.step().unwrap() {
|
match stmt.step().unwrap() {
|
||||||
limbo_core::StepResult::Row => {}
|
turso_core::StepResult::Row => {}
|
||||||
limbo_core::StepResult::IO => {
|
turso_core::StepResult::IO => {
|
||||||
let _ = io.run_once();
|
let _ = io.run_once();
|
||||||
}
|
}
|
||||||
limbo_core::StepResult::Done => {
|
turso_core::StepResult::Done => {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
limbo_core::StepResult::Interrupt | limbo_core::StepResult::Busy => {
|
turso_core::StepResult::Interrupt | turso_core::StepResult::Busy => {
|
||||||
unreachable!();
|
unreachable!();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -903,14 +903,14 @@ fn bench_json_patch(criterion: &mut Criterion) {
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
loop {
|
loop {
|
||||||
match stmt.step().unwrap() {
|
match stmt.step().unwrap() {
|
||||||
limbo_core::StepResult::Row => {}
|
turso_core::StepResult::Row => {}
|
||||||
limbo_core::StepResult::IO => {
|
turso_core::StepResult::IO => {
|
||||||
let _ = io.run_once();
|
let _ = io.run_once();
|
||||||
}
|
}
|
||||||
limbo_core::StepResult::Done => {
|
turso_core::StepResult::Done => {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
limbo_core::StepResult::Interrupt | limbo_core::StepResult::Busy => {
|
turso_core::StepResult::Interrupt | turso_core::StepResult::Busy => {
|
||||||
unreachable!();
|
unreachable!();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
use criterion::async_executor::FuturesExecutor;
|
use criterion::async_executor::FuturesExecutor;
|
||||||
use criterion::{criterion_group, criterion_main, Criterion, Throughput};
|
use criterion::{criterion_group, criterion_main, Criterion, Throughput};
|
||||||
use limbo_core::mvcc::clock::LocalClock;
|
|
||||||
use limbo_core::mvcc::database::{MvStore, Row, RowID};
|
|
||||||
use pprof::criterion::{Output, PProfProfiler};
|
use pprof::criterion::{Output, PProfProfiler};
|
||||||
|
use turso_core::mvcc::clock::LocalClock;
|
||||||
|
use turso_core::mvcc::database::{MvStore, Row, RowID};
|
||||||
|
|
||||||
fn bench_db() -> MvStore<LocalClock> {
|
fn bench_db() -> MvStore<LocalClock> {
|
||||||
let clock = LocalClock::default();
|
let clock = LocalClock::default();
|
||||||
let storage = limbo_core::mvcc::persistent_storage::Storage::new_noop();
|
let storage = turso_core::mvcc::persistent_storage::Storage::new_noop();
|
||||||
MvStore::new(clock, storage)
|
MvStore::new(clock, storage)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion, SamplingMode};
|
use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion, SamplingMode};
|
||||||
use limbo_core::{Database, PlatformIO, IO as _};
|
|
||||||
use pprof::criterion::{Output, PProfProfiler};
|
use pprof::criterion::{Output, PProfProfiler};
|
||||||
|
use turso_core::{Database, PlatformIO, IO as _};
|
||||||
|
|
||||||
const TPC_H_PATH: &str = "../perf/tpc-h/TPC-H.db";
|
const TPC_H_PATH: &str = "../perf/tpc-h/TPC-H.db";
|
||||||
|
|
||||||
|
@ -93,16 +93,16 @@ fn bench_tpc_h_queries(criterion: &mut Criterion) {
|
||||||
let mut stmt = limbo_conn.prepare(query).unwrap();
|
let mut stmt = limbo_conn.prepare(query).unwrap();
|
||||||
loop {
|
loop {
|
||||||
match stmt.step().unwrap() {
|
match stmt.step().unwrap() {
|
||||||
limbo_core::StepResult::Row => {
|
turso_core::StepResult::Row => {
|
||||||
black_box(stmt.row());
|
black_box(stmt.row());
|
||||||
}
|
}
|
||||||
limbo_core::StepResult::IO => {
|
turso_core::StepResult::IO => {
|
||||||
let _ = io.run_once();
|
let _ = io.run_once();
|
||||||
}
|
}
|
||||||
limbo_core::StepResult::Done => {
|
turso_core::StepResult::Done => {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
limbo_core::StepResult::Interrupt | limbo_core::StepResult::Busy => {
|
turso_core::StepResult::Interrupt | turso_core::StepResult::Busy => {
|
||||||
unreachable!();
|
unreachable!();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,10 +64,10 @@ Use these Python-based tests for validating:
|
||||||
If you wish to trace internal events during test execution, you can set the RUST_LOG environment variable before running the test. For example:
|
If you wish to trace internal events during test execution, you can set the RUST_LOG environment variable before running the test. For example:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
RUST_LOG=none,limbo_core=trace make test
|
RUST_LOG=none,turso_core=trace make test
|
||||||
```
|
```
|
||||||
|
|
||||||
This will enable trace-level logs for the limbo_core crate and disable logs elsewhere. Logging all internal traces to the `testing/test.log` file.
|
This will enable trace-level logs for the turso_core crate and disable logs elsewhere. Logging all internal traces to the `testing/test.log` file.
|
||||||
|
|
||||||
**Note:** trace logs can be very verbose—it's not uncommon for a single test run to generate megabytes of logs.
|
**Note:** trace logs can be very verbose—it's not uncommon for a single test run to generate megabytes of logs.
|
||||||
|
|
||||||
|
|
|
@ -419,7 +419,7 @@ Edit the workspace `Cargo.toml` to include your extension as a workspace depende
|
||||||
|
|
||||||
```diff
|
```diff
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
limbo_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" }
|
limbo_ext = { path = "extensions/core", version = "0.0.17" }
|
||||||
limbo_macros = { path = "macros", version = "0.0.17" }
|
limbo_macros = { path = "macros", version = "0.0.17" }
|
||||||
|
|
100
fuzz/Cargo.lock
generated
100
fuzz/Cargo.lock
generated
|
@ -560,49 +560,13 @@ version = "0.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"arbitrary",
|
"arbitrary",
|
||||||
"libfuzzer-sys",
|
"libfuzzer-sys",
|
||||||
"limbo_core",
|
|
||||||
"rusqlite",
|
"rusqlite",
|
||||||
]
|
"turso_core",
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "limbo_core"
|
|
||||||
version = "0.0.21"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags",
|
|
||||||
"built",
|
|
||||||
"cfg_block",
|
|
||||||
"chrono",
|
|
||||||
"crossbeam-skiplist",
|
|
||||||
"fallible-iterator",
|
|
||||||
"getrandom 0.2.15",
|
|
||||||
"hex",
|
|
||||||
"julian_day_converter",
|
|
||||||
"libloading",
|
|
||||||
"libm",
|
|
||||||
"limbo_ext",
|
|
||||||
"limbo_macros",
|
|
||||||
"limbo_sqlite3_parser",
|
|
||||||
"limbo_time",
|
|
||||||
"limbo_uuid",
|
|
||||||
"miette",
|
|
||||||
"mimalloc",
|
|
||||||
"parking_lot",
|
|
||||||
"polling",
|
|
||||||
"rand",
|
|
||||||
"regex",
|
|
||||||
"regex-syntax",
|
|
||||||
"rustix 1.0.7",
|
|
||||||
"ryu",
|
|
||||||
"strum",
|
|
||||||
"strum_macros",
|
|
||||||
"thiserror 1.0.69",
|
|
||||||
"tracing",
|
|
||||||
"uncased",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "limbo_ext"
|
name = "limbo_ext"
|
||||||
version = "0.0.21"
|
version = "0.1.0-pre.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"getrandom 0.3.1",
|
"getrandom 0.3.1",
|
||||||
|
@ -611,16 +575,24 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "limbo_macros"
|
name = "limbo_macros"
|
||||||
version = "0.0.21"
|
version = "0.1.0-pre.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "limbo_series"
|
||||||
|
version = "0.1.0-pre.2"
|
||||||
|
dependencies = [
|
||||||
|
"limbo_ext",
|
||||||
|
"mimalloc",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "limbo_sqlite3_parser"
|
name = "limbo_sqlite3_parser"
|
||||||
version = "0.0.21"
|
version = "0.1.0-pre.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"cc",
|
"cc",
|
||||||
|
@ -639,7 +611,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "limbo_time"
|
name = "limbo_time"
|
||||||
version = "0.0.21"
|
version = "0.1.0-pre.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"limbo_ext",
|
"limbo_ext",
|
||||||
|
@ -651,7 +623,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "limbo_uuid"
|
name = "limbo_uuid"
|
||||||
version = "0.0.21"
|
version = "0.1.0-pre.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"limbo_ext",
|
"limbo_ext",
|
||||||
"mimalloc",
|
"mimalloc",
|
||||||
|
@ -767,6 +739,12 @@ dependencies = [
|
||||||
"windows-targets",
|
"windows-targets",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "paste"
|
||||||
|
version = "1.0.15"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "percent-encoding"
|
name = "percent-encoding"
|
||||||
version = "2.3.1"
|
version = "2.3.1"
|
||||||
|
@ -1161,6 +1139,44 @@ dependencies = [
|
||||||
"once_cell",
|
"once_cell",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "turso_core"
|
||||||
|
version = "0.1.0-pre.2"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags",
|
||||||
|
"built",
|
||||||
|
"cfg_block",
|
||||||
|
"chrono",
|
||||||
|
"crossbeam-skiplist",
|
||||||
|
"fallible-iterator",
|
||||||
|
"getrandom 0.2.15",
|
||||||
|
"hex",
|
||||||
|
"julian_day_converter",
|
||||||
|
"libloading",
|
||||||
|
"libm",
|
||||||
|
"limbo_ext",
|
||||||
|
"limbo_macros",
|
||||||
|
"limbo_series",
|
||||||
|
"limbo_sqlite3_parser",
|
||||||
|
"limbo_time",
|
||||||
|
"limbo_uuid",
|
||||||
|
"miette",
|
||||||
|
"mimalloc",
|
||||||
|
"parking_lot",
|
||||||
|
"paste",
|
||||||
|
"polling",
|
||||||
|
"rand",
|
||||||
|
"regex",
|
||||||
|
"regex-syntax",
|
||||||
|
"rustix 1.0.7",
|
||||||
|
"ryu",
|
||||||
|
"strum",
|
||||||
|
"strum_macros",
|
||||||
|
"thiserror 1.0.69",
|
||||||
|
"tracing",
|
||||||
|
"uncased",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "uncased"
|
name = "uncased"
|
||||||
version = "0.9.10"
|
version = "0.9.10"
|
||||||
|
|
|
@ -11,7 +11,7 @@ cargo-fuzz = true
|
||||||
[dependencies]
|
[dependencies]
|
||||||
libfuzzer-sys = "0.4"
|
libfuzzer-sys = "0.4"
|
||||||
arbitrary = { version = "1.4.1", features = ["derive"] }
|
arbitrary = { version = "1.4.1", features = ["derive"] }
|
||||||
limbo_core = { path = "../core", features = ["fuzz"] }
|
turso_core = { path = "../core", features = ["fuzz"] }
|
||||||
rusqlite = { version = "0.34.0", features = ["bundled"] }
|
rusqlite = { version = "0.34.0", features = ["bundled"] }
|
||||||
|
|
||||||
# Prevent this from interfering with workspaces
|
# Prevent this from interfering with workspaces
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#![no_main]
|
#![no_main]
|
||||||
use libfuzzer_sys::{fuzz_target, Corpus};
|
use libfuzzer_sys::{fuzz_target, Corpus};
|
||||||
use limbo_core::numeric::StrToF64;
|
use turso_core::numeric::StrToF64;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
|
|
||||||
fn do_fuzz(text: String) -> Result<Corpus, Box<dyn Error>> {
|
fn do_fuzz(text: String) -> Result<Corpus, Box<dyn Error>> {
|
||||||
|
@ -11,7 +11,7 @@ fn do_fuzz(text: String) -> Result<Corpus, Box<dyn Error>> {
|
||||||
})?
|
})?
|
||||||
};
|
};
|
||||||
|
|
||||||
let actual = limbo_core::numeric::str_to_f64(&text)
|
let actual = turso_core::numeric::str_to_f64(&text)
|
||||||
.map(|v| {
|
.map(|v| {
|
||||||
let (StrToF64::Fractional(non_nan) | StrToF64::Decimal(non_nan)) = v;
|
let (StrToF64::Fractional(non_nan) | StrToF64::Decimal(non_nan)) = v;
|
||||||
f64::from(non_nan)
|
f64::from(non_nan)
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::{error::Error, num::NonZero, sync::Arc};
|
||||||
|
|
||||||
use arbitrary::Arbitrary;
|
use arbitrary::Arbitrary;
|
||||||
use libfuzzer_sys::{fuzz_target, Corpus};
|
use libfuzzer_sys::{fuzz_target, Corpus};
|
||||||
use limbo_core::{Value, IO as _};
|
use turso_core::{Value, IO as _};
|
||||||
|
|
||||||
macro_rules! str_enum {
|
macro_rules! str_enum {
|
||||||
($vis:vis enum $name:ident { $($variant:ident => $value:literal),*, }) => {
|
($vis:vis enum $name:ident { $($variant:ident => $value:literal),*, }) => {
|
||||||
|
@ -72,20 +72,20 @@ enum Value {
|
||||||
Blob(Vec<u8>),
|
Blob(Vec<u8>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Value> for limbo_core::Value {
|
impl From<Value> for turso_core::Value {
|
||||||
fn from(value: Value) -> limbo_core::Value {
|
fn from(value: Value) -> turso_core::Value {
|
||||||
match value {
|
match value {
|
||||||
Value::Null => limbo_core::Value::Null,
|
Value::Null => turso_core::Value::Null,
|
||||||
Value::Integer(v) => limbo_core::Value::Integer(v),
|
Value::Integer(v) => turso_core::Value::Integer(v),
|
||||||
Value::Real(v) => {
|
Value::Real(v) => {
|
||||||
if v.is_nan() {
|
if v.is_nan() {
|
||||||
limbo_core::Value::Null
|
turso_core::Value::Null
|
||||||
} else {
|
} else {
|
||||||
limbo_core::Value::Float(v)
|
turso_core::Value::Float(v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Value::Text(v) => limbo_core::Value::from_text(&v),
|
Value::Text(v) => turso_core::Value::from_text(&v),
|
||||||
Value::Blob(v) => limbo_core::Value::from_blob(v.to_owned()),
|
Value::Blob(v) => turso_core::Value::from_blob(v.to_owned()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -168,7 +168,7 @@ fn do_fuzz(expr: Expr) -> Result<Corpus, Box<dyn Error>> {
|
||||||
let expr = expr.lower();
|
let expr = expr.lower();
|
||||||
let sql = format!("SELECT {}", expr.query);
|
let sql = format!("SELECT {}", expr.query);
|
||||||
|
|
||||||
// FIX: `limbo_core::translate::expr::translate_expr` causes a overflow if this is any higher.
|
// FIX: `turso_core::translate::expr::translate_expr` causes a overflow if this is any higher.
|
||||||
if expr.depth > 140 {
|
if expr.depth > 140 {
|
||||||
return Ok(Corpus::Reject);
|
return Ok(Corpus::Reject);
|
||||||
}
|
}
|
||||||
|
@ -183,8 +183,8 @@ fn do_fuzz(expr: Expr) -> Result<Corpus, Box<dyn Error>> {
|
||||||
};
|
};
|
||||||
|
|
||||||
let found = 'value: {
|
let found = 'value: {
|
||||||
let io = Arc::new(limbo_core::MemoryIO::new());
|
let io = Arc::new(turso_core::MemoryIO::new());
|
||||||
let db = limbo_core::Database::open_file(io.clone(), ":memory:", false)?;
|
let db = turso_core::Database::open_file(io.clone(), ":memory:", false)?;
|
||||||
let conn = db.connect()?;
|
let conn = db.connect()?;
|
||||||
|
|
||||||
let mut stmt = conn.prepare(sql)?;
|
let mut stmt = conn.prepare(sql)?;
|
||||||
|
@ -192,7 +192,7 @@ fn do_fuzz(expr: Expr) -> Result<Corpus, Box<dyn Error>> {
|
||||||
stmt.bind_at(NonZero::new(idx + 1).unwrap(), value.clone().into())
|
stmt.bind_at(NonZero::new(idx + 1).unwrap(), value.clone().into())
|
||||||
}
|
}
|
||||||
loop {
|
loop {
|
||||||
use limbo_core::StepResult;
|
use turso_core::StepResult;
|
||||||
match stmt.step()? {
|
match stmt.step()? {
|
||||||
StepResult::IO => io.run_once()?,
|
StepResult::IO => io.run_once()?,
|
||||||
StepResult::Row => {
|
StepResult::Row => {
|
||||||
|
|
|
@ -337,8 +337,8 @@ impl<'a> Arbitrary<'a> for Ops {
|
||||||
fn do_fuzz(Ops(ops): Ops) -> Result<Corpus, Box<dyn Error>> {
|
fn do_fuzz(Ops(ops): Ops) -> Result<Corpus, Box<dyn Error>> {
|
||||||
let rusqlite_conn = rusqlite::Connection::open_in_memory()?;
|
let rusqlite_conn = rusqlite::Connection::open_in_memory()?;
|
||||||
|
|
||||||
let io = Arc::new(limbo_core::MemoryIO::new());
|
let io = Arc::new(turso_core::MemoryIO::new());
|
||||||
let db = limbo_core::Database::open_file(io.clone(), ":memory:", false)?;
|
let db = turso_core::Database::open_file(io.clone(), ":memory:", false)?;
|
||||||
let limbo_conn = db.connect()?;
|
let limbo_conn = db.connect()?;
|
||||||
|
|
||||||
for op in ops {
|
for op in ops {
|
||||||
|
|
1059
perf/latency/limbo/Cargo.lock
generated
1059
perf/latency/limbo/Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -7,7 +7,7 @@ edition = "2021"
|
||||||
clap = { version = "4.5", features = ["derive"] }
|
clap = { version = "4.5", features = ["derive"] }
|
||||||
env_logger = "0.11.0"
|
env_logger = "0.11.0"
|
||||||
hdrhistogram = "7.5.2"
|
hdrhistogram = "7.5.2"
|
||||||
limbo_core = { path = "../../../core" }
|
turso_core = { path = "../../../core" }
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
debug = true
|
debug = true
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use hdrhistogram::Histogram;
|
use hdrhistogram::Histogram;
|
||||||
use limbo_core::{Database, PlatformIO, IO};
|
use turso_core::{Database, PlatformIO, IO};
|
||||||
use std::ops::{Coroutine, CoroutineState};
|
use std::ops::{Coroutine, CoroutineState};
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
@ -38,12 +38,12 @@ fn main() {
|
||||||
loop {
|
loop {
|
||||||
let row = rows.step().unwrap();
|
let row = rows.step().unwrap();
|
||||||
match row {
|
match row {
|
||||||
limbo_core::StepResult::Row(_) => {
|
turso_core::StepResult::Row(_) => {
|
||||||
let row = statement.row();
|
let row = statement.row();
|
||||||
count += 1;
|
count += 1;
|
||||||
}
|
}
|
||||||
limbo_core::StepResult::IO => yield,
|
turso_core::StepResult::IO => yield,
|
||||||
limbo_core::StepResult::Done => break,
|
turso_core::StepResult::Done => break,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assert!(count == 100);
|
assert!(count == 100);
|
||||||
|
|
|
@ -13,5 +13,5 @@ cargo publish -p limbo_time
|
||||||
cargo publish -p limbo_uuid
|
cargo publish -p limbo_uuid
|
||||||
cargo publish -p limbo_ipaddr
|
cargo publish -p limbo_ipaddr
|
||||||
cargo publish -p limbo_sqlite3_parser
|
cargo publish -p limbo_sqlite3_parser
|
||||||
cargo publish -p limbo_core
|
cargo publish -p turso_core
|
||||||
cargo publish -p limbo
|
cargo publish -p limbo
|
||||||
|
|
|
@ -15,7 +15,7 @@ name = "limbo_sim"
|
||||||
path = "main.rs"
|
path = "main.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
limbo_core = { path = "../core", features = ["simulator"]}
|
turso_core = { path = "../core", features = ["simulator"]}
|
||||||
rand = "0.8.5"
|
rand = "0.8.5"
|
||||||
rand_chacha = "0.3.1"
|
rand_chacha = "0.3.1"
|
||||||
log = "0.4.20"
|
log = "0.4.20"
|
||||||
|
|
|
@ -6,8 +6,8 @@ use std::{
|
||||||
vec,
|
vec,
|
||||||
};
|
};
|
||||||
|
|
||||||
use limbo_core::{Connection, Result, StepResult, IO};
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
use turso_core::{Connection, Result, StepResult, IO};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
model::{
|
model::{
|
||||||
|
@ -564,10 +564,10 @@ impl Interaction {
|
||||||
let result = assertion.func.as_ref()(stack, env);
|
let result = assertion.func.as_ref()(stack, env);
|
||||||
match result {
|
match result {
|
||||||
Ok(true) => Ok(()),
|
Ok(true) => Ok(()),
|
||||||
Ok(false) => Err(limbo_core::LimboError::InternalError(
|
Ok(false) => Err(turso_core::LimboError::InternalError(
|
||||||
assertion.message.clone(),
|
assertion.message.clone(),
|
||||||
)),
|
)),
|
||||||
Err(err) => Err(limbo_core::LimboError::InternalError(format!(
|
Err(err) => Err(turso_core::LimboError::InternalError(format!(
|
||||||
"{}. Inner error: {}",
|
"{}. Inner error: {}",
|
||||||
assertion.message, err
|
assertion.message, err
|
||||||
))),
|
))),
|
||||||
|
@ -598,10 +598,10 @@ impl Interaction {
|
||||||
let result = assumption.func.as_ref()(stack, env);
|
let result = assumption.func.as_ref()(stack, env);
|
||||||
match result {
|
match result {
|
||||||
Ok(true) => Ok(()),
|
Ok(true) => Ok(()),
|
||||||
Ok(false) => Err(limbo_core::LimboError::InternalError(
|
Ok(false) => Err(turso_core::LimboError::InternalError(
|
||||||
assumption.message.clone(),
|
assumption.message.clone(),
|
||||||
)),
|
)),
|
||||||
Err(err) => Err(limbo_core::LimboError::InternalError(format!(
|
Err(err) => Err(turso_core::LimboError::InternalError(format!(
|
||||||
"{}. Inner error: {}",
|
"{}. Inner error: {}",
|
||||||
assumption.message, err
|
assumption.message, err
|
||||||
))),
|
))),
|
||||||
|
@ -630,7 +630,7 @@ impl Interaction {
|
||||||
if env.connections[conn_index].is_connected() {
|
if env.connections[conn_index].is_connected() {
|
||||||
env.connections[conn_index].disconnect();
|
env.connections[conn_index].disconnect();
|
||||||
} else {
|
} else {
|
||||||
return Err(limbo_core::LimboError::InternalError(
|
return Err(turso_core::LimboError::InternalError(
|
||||||
"connection already disconnected".into(),
|
"connection already disconnected".into(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -644,7 +644,7 @@ impl Interaction {
|
||||||
|
|
||||||
// 2. Re-open database
|
// 2. Re-open database
|
||||||
let db_path = env.db_path.clone();
|
let db_path = env.db_path.clone();
|
||||||
let db = match limbo_core::Database::open_file(
|
let db = match turso_core::Database::open_file(
|
||||||
env.io.clone(),
|
env.io.clone(),
|
||||||
&db_path,
|
&db_path,
|
||||||
false,
|
false,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use limbo_core::LimboError;
|
|
||||||
use limbo_sqlite3_parser::ast;
|
use limbo_sqlite3_parser::ast;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
use turso_core::LimboError;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
model::{
|
model::{
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
|
||||||
use limbo_core::Value;
|
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
|
use turso_core::Value;
|
||||||
|
|
||||||
use crate::generation::{gen_random_text, pick, readable_name_custom, Arbitrary, ArbitraryFrom};
|
use crate::generation::{gen_random_text, pick, readable_name_custom, Arbitrary, ArbitraryFrom};
|
||||||
use crate::model::table::{Column, ColumnType, Name, SimValue, Table};
|
use crate::model::table::{Column, ColumnType, Name, SimValue, Table};
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use std::{fmt::Display, hash::Hash, ops::Deref};
|
use std::{fmt::Display, hash::Hash, ops::Deref};
|
||||||
|
|
||||||
use limbo_core::{numeric::Numeric, types};
|
|
||||||
use limbo_sqlite3_parser::ast;
|
use limbo_sqlite3_parser::ast;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
use turso_core::{numeric::Numeric, types};
|
||||||
|
|
||||||
pub(crate) struct Name(pub(crate) String);
|
pub(crate) struct Name(pub(crate) String);
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, PartialOrd, Serialize, Deserialize)]
|
#[derive(Clone, Debug, PartialEq, PartialOrd, Serialize, Deserialize)]
|
||||||
pub(crate) struct SimValue(pub limbo_core::Value);
|
pub(crate) struct SimValue(pub turso_core::Value);
|
||||||
|
|
||||||
fn to_sqlite_blob(bytes: &[u8]) -> String {
|
fn to_sqlite_blob(bytes: &[u8]) -> String {
|
||||||
format!(
|
format!(
|
||||||
|
@ -116,7 +116,7 @@ impl SimValue {
|
||||||
/// TODO: forget collations for now
|
/// TODO: forget collations for now
|
||||||
/// TODO: have the [ast::Operator::Equals], [ast::Operator::NotEquals], [ast::Operator::Greater],
|
/// TODO: have the [ast::Operator::Equals], [ast::Operator::NotEquals], [ast::Operator::Greater],
|
||||||
/// [ast::Operator::GreaterEquals], [ast::Operator::Less], [ast::Operator::LessEquals] function to be extracted
|
/// [ast::Operator::GreaterEquals], [ast::Operator::Less], [ast::Operator::LessEquals] function to be extracted
|
||||||
/// into its functions in limbo_core so that it can be used here
|
/// into its functions in turso_core so that it can be used here
|
||||||
pub fn binary_compare(&self, other: &Self, operator: ast::Operator) -> SimValue {
|
pub fn binary_compare(&self, other: &Self, operator: ast::Operator) -> SimValue {
|
||||||
match operator {
|
match operator {
|
||||||
ast::Operator::Add => self.0.exec_add(&other.0).into(),
|
ast::Operator::Add => self.0.exec_add(&other.0).into(),
|
||||||
|
@ -290,26 +290,26 @@ impl From<bool> for SimValue {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<SimValue> for limbo_core::types::Value {
|
impl From<SimValue> for turso_core::types::Value {
|
||||||
fn from(value: SimValue) -> Self {
|
fn from(value: SimValue) -> Self {
|
||||||
value.0
|
value.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<&SimValue> for limbo_core::types::Value {
|
impl From<&SimValue> for turso_core::types::Value {
|
||||||
fn from(value: &SimValue) -> Self {
|
fn from(value: &SimValue) -> Self {
|
||||||
value.0.clone()
|
value.0.clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<limbo_core::types::Value> for SimValue {
|
impl From<turso_core::types::Value> for SimValue {
|
||||||
fn from(value: limbo_core::types::Value) -> Self {
|
fn from(value: turso_core::types::Value) -> Self {
|
||||||
Self(value)
|
Self(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<&limbo_core::types::Value> for SimValue {
|
impl From<&turso_core::types::Value> for SimValue {
|
||||||
fn from(value: &limbo_core::types::Value) -> Self {
|
fn from(value: &turso_core::types::Value) -> Self {
|
||||||
Self(value.clone())
|
Self(value.clone())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
use limbo_core::Value;
|
use turso_core::Value;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
generation::{
|
generation::{
|
||||||
|
@ -163,7 +163,7 @@ pub(crate) fn execute_plans(
|
||||||
if now.elapsed().as_secs() >= env.opts.max_time_simulation as u64 {
|
if now.elapsed().as_secs() >= env.opts.max_time_simulation as u64 {
|
||||||
return ExecutionResult::new(
|
return ExecutionResult::new(
|
||||||
history,
|
history,
|
||||||
Some(limbo_core::LimboError::InternalError(
|
Some(turso_core::LimboError::InternalError(
|
||||||
"maximum time for simulation reached".into(),
|
"maximum time for simulation reached".into(),
|
||||||
)),
|
)),
|
||||||
);
|
);
|
||||||
|
@ -181,7 +181,7 @@ fn execute_plan(
|
||||||
plans: &mut [InteractionPlan],
|
plans: &mut [InteractionPlan],
|
||||||
states: &mut [InteractionPlanState],
|
states: &mut [InteractionPlanState],
|
||||||
rusqlite_states: &mut [InteractionPlanState],
|
rusqlite_states: &mut [InteractionPlanState],
|
||||||
) -> limbo_core::Result<()> {
|
) -> turso_core::Result<()> {
|
||||||
let connection = &env.connections[connection_index];
|
let connection = &env.connections[connection_index];
|
||||||
let rusqlite_connection = &rusqlite_env.connections[connection_index];
|
let rusqlite_connection = &rusqlite_env.connections[connection_index];
|
||||||
let plan = &mut plans[connection_index];
|
let plan = &mut plans[connection_index];
|
||||||
|
@ -214,7 +214,7 @@ fn execute_plan(
|
||||||
(Ok(next_execution), Ok(next_execution_rusqlite)) => {
|
(Ok(next_execution), Ok(next_execution_rusqlite)) => {
|
||||||
if next_execution != next_execution_rusqlite {
|
if next_execution != next_execution_rusqlite {
|
||||||
tracing::error!("limbo and rusqlite results do not match");
|
tracing::error!("limbo and rusqlite results do not match");
|
||||||
return Err(limbo_core::LimboError::InternalError(
|
return Err(turso_core::LimboError::InternalError(
|
||||||
"limbo and rusqlite results do not match".into(),
|
"limbo and rusqlite results do not match".into(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -227,7 +227,7 @@ fn execute_plan(
|
||||||
(Ok(limbo_values), Ok(rusqlite_values)) => {
|
(Ok(limbo_values), Ok(rusqlite_values)) => {
|
||||||
if limbo_values != rusqlite_values {
|
if limbo_values != rusqlite_values {
|
||||||
tracing::error!("limbo and rusqlite results do not match");
|
tracing::error!("limbo and rusqlite results do not match");
|
||||||
return Err(limbo_core::LimboError::InternalError(
|
return Err(turso_core::LimboError::InternalError(
|
||||||
"limbo and rusqlite results do not match".into(),
|
"limbo and rusqlite results do not match".into(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -243,14 +243,14 @@ fn execute_plan(
|
||||||
tracing::error!("limbo and rusqlite results do not match");
|
tracing::error!("limbo and rusqlite results do not match");
|
||||||
tracing::error!("limbo values {:?}", limbo_result);
|
tracing::error!("limbo values {:?}", limbo_result);
|
||||||
tracing::error!("rusqlite error {}", rusqlite_err);
|
tracing::error!("rusqlite error {}", rusqlite_err);
|
||||||
return Err(limbo_core::LimboError::InternalError(
|
return Err(turso_core::LimboError::InternalError(
|
||||||
"limbo and rusqlite results do not match".into(),
|
"limbo and rusqlite results do not match".into(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
(Err(limbo_err), Ok(_)) => {
|
(Err(limbo_err), Ok(_)) => {
|
||||||
tracing::error!("limbo and rusqlite results do not match");
|
tracing::error!("limbo and rusqlite results do not match");
|
||||||
tracing::error!("limbo error {}", limbo_err);
|
tracing::error!("limbo error {}", limbo_err);
|
||||||
return Err(limbo_core::LimboError::InternalError(
|
return Err(turso_core::LimboError::InternalError(
|
||||||
"limbo and rusqlite results do not match".into(),
|
"limbo and rusqlite results do not match".into(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -259,7 +259,7 @@ fn execute_plan(
|
||||||
(None, None) => {}
|
(None, None) => {}
|
||||||
_ => {
|
_ => {
|
||||||
tracing::error!("limbo and rusqlite results do not match");
|
tracing::error!("limbo and rusqlite results do not match");
|
||||||
return Err(limbo_core::LimboError::InternalError(
|
return Err(turso_core::LimboError::InternalError(
|
||||||
"limbo and rusqlite results do not match".into(),
|
"limbo and rusqlite results do not match".into(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -316,7 +316,7 @@ fn execute_interaction_rusqlite(
|
||||||
connection_index: usize,
|
connection_index: usize,
|
||||||
interaction: &Interaction,
|
interaction: &Interaction,
|
||||||
stack: &mut Vec<ResultSet>,
|
stack: &mut Vec<ResultSet>,
|
||||||
) -> limbo_core::Result<ExecutionContinuation> {
|
) -> turso_core::Result<ExecutionContinuation> {
|
||||||
tracing::trace!(
|
tracing::trace!(
|
||||||
"execute_interaction_rusqlite(connection_index={}, interaction={})",
|
"execute_interaction_rusqlite(connection_index={}, interaction={})",
|
||||||
connection_index,
|
connection_index,
|
||||||
|
@ -332,7 +332,7 @@ fn execute_interaction_rusqlite(
|
||||||
|
|
||||||
tracing::debug!("{}", interaction);
|
tracing::debug!("{}", interaction);
|
||||||
let results = execute_query_rusqlite(conn, query).map_err(|e| {
|
let results = execute_query_rusqlite(conn, query).map_err(|e| {
|
||||||
limbo_core::LimboError::InternalError(format!("error executing query: {}", e))
|
turso_core::LimboError::InternalError(format!("error executing query: {}", e))
|
||||||
});
|
});
|
||||||
tracing::debug!("{:?}", results);
|
tracing::debug!("{:?}", results);
|
||||||
stack.push(results);
|
stack.push(results);
|
||||||
|
|
|
@ -3,9 +3,9 @@ use std::mem;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use limbo_core::Database;
|
|
||||||
use rand::{Rng, SeedableRng};
|
use rand::{Rng, SeedableRng};
|
||||||
use rand_chacha::ChaCha8Rng;
|
use rand_chacha::ChaCha8Rng;
|
||||||
|
use turso_core::Database;
|
||||||
|
|
||||||
use crate::model::table::Table;
|
use crate::model::table::Table;
|
||||||
|
|
||||||
|
@ -168,7 +168,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) enum SimConnection {
|
pub(crate) enum SimConnection {
|
||||||
LimboConnection(Arc<limbo_core::Connection>),
|
LimboConnection(Arc<turso_core::Connection>),
|
||||||
SQLiteConnection(rusqlite::Connection),
|
SQLiteConnection(rusqlite::Connection),
|
||||||
Disconnected,
|
Disconnected,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
use limbo_core::{Connection, LimboError, Result, StepResult};
|
|
||||||
use tracing::instrument;
|
use tracing::instrument;
|
||||||
|
use turso_core::{Connection, LimboError, Result, StepResult};
|
||||||
|
|
||||||
use crate::generation::{
|
use crate::generation::{
|
||||||
pick_index,
|
pick_index,
|
||||||
|
@ -227,7 +227,7 @@ fn limbo_integrity_check(conn: &mut Arc<Connection>) -> Result<()> {
|
||||||
let row = rows.row().unwrap();
|
let row = rows.row().unwrap();
|
||||||
|
|
||||||
let val = match row.get_value(0) {
|
let val = match row.get_value(0) {
|
||||||
limbo_core::Value::Text(text) => text.as_str().to_string(),
|
turso_core::Value::Text(text) => text.as_str().to_string(),
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
};
|
};
|
||||||
result.push(val);
|
result.push(val);
|
||||||
|
|
|
@ -3,10 +3,10 @@ use std::{
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
|
|
||||||
use limbo_core::{CompletionType, File, Result};
|
|
||||||
use rand::Rng as _;
|
use rand::Rng as _;
|
||||||
use rand_chacha::ChaCha8Rng;
|
use rand_chacha::ChaCha8Rng;
|
||||||
use tracing::{instrument, Level};
|
use tracing::{instrument, Level};
|
||||||
|
use turso_core::{CompletionType, File, Result};
|
||||||
pub(crate) struct SimulatorFile {
|
pub(crate) struct SimulatorFile {
|
||||||
pub(crate) inner: Arc<dyn File>,
|
pub(crate) inner: Arc<dyn File>,
|
||||||
pub(crate) fault: Cell<bool>,
|
pub(crate) fault: Cell<bool>,
|
||||||
|
@ -82,7 +82,7 @@ impl SimulatorFile {
|
||||||
impl File for SimulatorFile {
|
impl File for SimulatorFile {
|
||||||
fn lock_file(&self, exclusive: bool) -> Result<()> {
|
fn lock_file(&self, exclusive: bool) -> Result<()> {
|
||||||
if self.fault.get() {
|
if self.fault.get() {
|
||||||
return Err(limbo_core::LimboError::InternalError(
|
return Err(turso_core::LimboError::InternalError(
|
||||||
"Injected fault".into(),
|
"Injected fault".into(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ impl File for SimulatorFile {
|
||||||
|
|
||||||
fn unlock_file(&self) -> Result<()> {
|
fn unlock_file(&self) -> Result<()> {
|
||||||
if self.fault.get() {
|
if self.fault.get() {
|
||||||
return Err(limbo_core::LimboError::InternalError(
|
return Err(turso_core::LimboError::InternalError(
|
||||||
"Injected fault".into(),
|
"Injected fault".into(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -101,12 +101,12 @@ impl File for SimulatorFile {
|
||||||
fn pread(
|
fn pread(
|
||||||
&self,
|
&self,
|
||||||
pos: usize,
|
pos: usize,
|
||||||
mut c: limbo_core::Completion,
|
mut c: turso_core::Completion,
|
||||||
) -> Result<Arc<limbo_core::Completion>> {
|
) -> Result<Arc<turso_core::Completion>> {
|
||||||
self.nr_pread_calls.set(self.nr_pread_calls.get() + 1);
|
self.nr_pread_calls.set(self.nr_pread_calls.get() + 1);
|
||||||
if self.fault.get() {
|
if self.fault.get() {
|
||||||
self.nr_pread_faults.set(self.nr_pread_faults.get() + 1);
|
self.nr_pread_faults.set(self.nr_pread_faults.get() + 1);
|
||||||
return Err(limbo_core::LimboError::InternalError(
|
return Err(turso_core::LimboError::InternalError(
|
||||||
"Injected fault".into(),
|
"Injected fault".into(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -134,13 +134,13 @@ impl File for SimulatorFile {
|
||||||
fn pwrite(
|
fn pwrite(
|
||||||
&self,
|
&self,
|
||||||
pos: usize,
|
pos: usize,
|
||||||
buffer: Arc<RefCell<limbo_core::Buffer>>,
|
buffer: Arc<RefCell<turso_core::Buffer>>,
|
||||||
mut c: limbo_core::Completion,
|
mut c: turso_core::Completion,
|
||||||
) -> Result<Arc<limbo_core::Completion>> {
|
) -> Result<Arc<turso_core::Completion>> {
|
||||||
self.nr_pwrite_calls.set(self.nr_pwrite_calls.get() + 1);
|
self.nr_pwrite_calls.set(self.nr_pwrite_calls.get() + 1);
|
||||||
if self.fault.get() {
|
if self.fault.get() {
|
||||||
self.nr_pwrite_faults.set(self.nr_pwrite_faults.get() + 1);
|
self.nr_pwrite_faults.set(self.nr_pwrite_faults.get() + 1);
|
||||||
return Err(limbo_core::LimboError::InternalError(
|
return Err(turso_core::LimboError::InternalError(
|
||||||
"Injected fault".into(),
|
"Injected fault".into(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -165,7 +165,7 @@ impl File for SimulatorFile {
|
||||||
self.inner.pwrite(pos, buffer, c)
|
self.inner.pwrite(pos, buffer, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sync(&self, mut c: limbo_core::Completion) -> Result<Arc<limbo_core::Completion>> {
|
fn sync(&self, mut c: turso_core::Completion) -> Result<Arc<turso_core::Completion>> {
|
||||||
self.nr_sync_calls.set(self.nr_sync_calls.get() + 1);
|
self.nr_sync_calls.set(self.nr_sync_calls.get() + 1);
|
||||||
if let Some(latency) = self.generate_latency_duration() {
|
if let Some(latency) = self.generate_latency_duration() {
|
||||||
let CompletionType::Sync(sync_completion) = &mut c.completion_type else {
|
let CompletionType::Sync(sync_completion) = &mut c.completion_type else {
|
||||||
|
|
|
@ -3,9 +3,9 @@ use std::{
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
|
|
||||||
use limbo_core::{Clock, Instant, OpenFlags, PlatformIO, Result, IO};
|
|
||||||
use rand::{RngCore, SeedableRng};
|
use rand::{RngCore, SeedableRng};
|
||||||
use rand_chacha::ChaCha8Rng;
|
use rand_chacha::ChaCha8Rng;
|
||||||
|
use turso_core::{Clock, Instant, OpenFlags, PlatformIO, Result, IO};
|
||||||
|
|
||||||
use crate::runner::file::SimulatorFile;
|
use crate::runner::file::SimulatorFile;
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ impl IO for SimulatorIO {
|
||||||
path: &str,
|
path: &str,
|
||||||
flags: OpenFlags,
|
flags: OpenFlags,
|
||||||
_direct: bool,
|
_direct: bool,
|
||||||
) -> Result<Arc<dyn limbo_core::File>> {
|
) -> Result<Arc<dyn turso_core::File>> {
|
||||||
let inner = self.inner.open_file(path, flags, false)?;
|
let inner = self.inner.open_file(path, flags, false)?;
|
||||||
let file = Arc::new(SimulatorFile {
|
let file = Arc::new(SimulatorFile {
|
||||||
inner,
|
inner,
|
||||||
|
@ -90,7 +90,7 @@ impl IO for SimulatorIO {
|
||||||
Ok(file)
|
Ok(file)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wait_for_completion(&self, c: Arc<limbo_core::Completion>) -> Result<()> {
|
fn wait_for_completion(&self, c: Arc<turso_core::Completion>) -> Result<()> {
|
||||||
while !c.is_completed() {
|
while !c.is_completed() {
|
||||||
self.run_once()?;
|
self.run_once()?;
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ impl IO for SimulatorIO {
|
||||||
if self.fault.get() {
|
if self.fault.get() {
|
||||||
self.nr_run_once_faults
|
self.nr_run_once_faults
|
||||||
.replace(self.nr_run_once_faults.get() + 1);
|
.replace(self.nr_run_once_faults.get() + 1);
|
||||||
return Err(limbo_core::LimboError::InternalError(
|
return Err(turso_core::LimboError::InternalError(
|
||||||
"Injected fault".into(),
|
"Injected fault".into(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ impl IO for SimulatorIO {
|
||||||
self.rng.borrow_mut().next_u64() as i64
|
self.rng.borrow_mut().next_u64() as i64
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_memory_io(&self) -> Arc<limbo_core::MemoryIO> {
|
fn get_memory_io(&self) -> Arc<turso_core::MemoryIO> {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ pub(crate) fn execute_plans(
|
||||||
if now.elapsed().as_secs() >= env.opts.max_time_simulation as u64 {
|
if now.elapsed().as_secs() >= env.opts.max_time_simulation as u64 {
|
||||||
return ExecutionResult::new(
|
return ExecutionResult::new(
|
||||||
history,
|
history,
|
||||||
Some(limbo_core::LimboError::InternalError(
|
Some(turso_core::LimboError::InternalError(
|
||||||
"maximum time for simulation reached".into(),
|
"maximum time for simulation reached".into(),
|
||||||
)),
|
)),
|
||||||
);
|
);
|
||||||
|
@ -85,7 +85,7 @@ fn execute_plan(
|
||||||
connection_index: usize,
|
connection_index: usize,
|
||||||
plans: &mut [Vec<Vec<Interaction>>],
|
plans: &mut [Vec<Vec<Interaction>>],
|
||||||
states: &mut [InteractionPlanState],
|
states: &mut [InteractionPlanState],
|
||||||
) -> limbo_core::Result<()> {
|
) -> turso_core::Result<()> {
|
||||||
let connection = &env.connections[connection_index];
|
let connection = &env.connections[connection_index];
|
||||||
let plan = &mut plans[connection_index];
|
let plan = &mut plans[connection_index];
|
||||||
let state = &mut states[connection_index];
|
let state = &mut states[connection_index];
|
||||||
|
|
|
@ -24,7 +24,7 @@ crate-type = ["lib", "cdylib", "staticlib"]
|
||||||
[dependencies]
|
[dependencies]
|
||||||
env_logger = { version = "0.11.3", default-features = false }
|
env_logger = { version = "0.11.3", default-features = false }
|
||||||
libc = "0.2.169"
|
libc = "0.2.169"
|
||||||
limbo_core = { path = "../core" }
|
turso_core = { path = "../core" }
|
||||||
tracing = "0.1.41"
|
tracing = "0.1.41"
|
||||||
tracing-appender = "0.2.3"
|
tracing-appender = "0.2.3"
|
||||||
tracing-subscriber = { version = "0.3.19", features = ["env-filter"] }
|
tracing-subscriber = { version = "0.3.19", features = ["env-filter"] }
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#![allow(clippy::missing_safety_doc)]
|
#![allow(clippy::missing_safety_doc)]
|
||||||
#![allow(non_camel_case_types)]
|
#![allow(non_camel_case_types)]
|
||||||
|
|
||||||
use limbo_core::Value;
|
|
||||||
use std::ffi::{self, CStr, CString};
|
use std::ffi::{self, CStr, CString};
|
||||||
use tracing::trace;
|
use tracing::trace;
|
||||||
|
use turso_core::Value;
|
||||||
|
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
|
@ -39,9 +39,9 @@ pub struct sqlite3 {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct sqlite3Inner {
|
struct sqlite3Inner {
|
||||||
pub(crate) io: Arc<dyn limbo_core::IO>,
|
pub(crate) io: Arc<dyn turso_core::IO>,
|
||||||
pub(crate) _db: Arc<limbo_core::Database>,
|
pub(crate) _db: Arc<turso_core::Database>,
|
||||||
pub(crate) conn: Arc<limbo_core::Connection>,
|
pub(crate) conn: Arc<turso_core::Connection>,
|
||||||
pub(crate) err_code: ffi::c_int,
|
pub(crate) err_code: ffi::c_int,
|
||||||
pub(crate) err_mask: ffi::c_int,
|
pub(crate) err_mask: ffi::c_int,
|
||||||
pub(crate) malloc_failed: bool,
|
pub(crate) malloc_failed: bool,
|
||||||
|
@ -51,9 +51,9 @@ struct sqlite3Inner {
|
||||||
|
|
||||||
impl sqlite3 {
|
impl sqlite3 {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
io: Arc<dyn limbo_core::IO>,
|
io: Arc<dyn turso_core::IO>,
|
||||||
db: Arc<limbo_core::Database>,
|
db: Arc<turso_core::Database>,
|
||||||
conn: Arc<limbo_core::Connection>,
|
conn: Arc<turso_core::Connection>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let inner = sqlite3Inner {
|
let inner = sqlite3Inner {
|
||||||
io,
|
io,
|
||||||
|
@ -73,11 +73,11 @@ impl sqlite3 {
|
||||||
|
|
||||||
pub struct sqlite3_stmt {
|
pub struct sqlite3_stmt {
|
||||||
pub(crate) db: *mut sqlite3,
|
pub(crate) db: *mut sqlite3,
|
||||||
pub(crate) stmt: limbo_core::Statement,
|
pub(crate) stmt: turso_core::Statement,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl sqlite3_stmt {
|
impl sqlite3_stmt {
|
||||||
pub fn new(db: *mut sqlite3, stmt: limbo_core::Statement) -> Self {
|
pub fn new(db: *mut sqlite3, stmt: turso_core::Statement) -> Self {
|
||||||
Self { db, stmt }
|
Self { db, stmt }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,14 +119,14 @@ pub unsafe extern "C" fn sqlite3_open(
|
||||||
Ok(s) => s,
|
Ok(s) => s,
|
||||||
Err(_) => return SQLITE_MISUSE,
|
Err(_) => return SQLITE_MISUSE,
|
||||||
};
|
};
|
||||||
let io: Arc<dyn limbo_core::IO> = match filename {
|
let io: Arc<dyn turso_core::IO> = match filename {
|
||||||
":memory:" => Arc::new(limbo_core::MemoryIO::new()),
|
":memory:" => Arc::new(turso_core::MemoryIO::new()),
|
||||||
_ => match limbo_core::PlatformIO::new() {
|
_ => match turso_core::PlatformIO::new() {
|
||||||
Ok(io) => Arc::new(io),
|
Ok(io) => Arc::new(io),
|
||||||
Err(_) => return SQLITE_CANTOPEN,
|
Err(_) => return SQLITE_CANTOPEN,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
match limbo_core::Database::open_file(io.clone(), filename, false, false) {
|
match turso_core::Database::open_file(io.clone(), filename, false, false) {
|
||||||
Ok(db) => {
|
Ok(db) => {
|
||||||
let conn = db.connect().unwrap();
|
let conn = db.connect().unwrap();
|
||||||
*db_out = Box::leak(Box::new(sqlite3::new(io, db, conn)));
|
*db_out = Box::leak(Box::new(sqlite3::new(io, db, conn)));
|
||||||
|
@ -250,15 +250,15 @@ pub unsafe extern "C" fn sqlite3_step(stmt: *mut sqlite3_stmt) -> ffi::c_int {
|
||||||
let db = db.inner.lock().unwrap();
|
let db = db.inner.lock().unwrap();
|
||||||
if let Ok(result) = stmt.stmt.step() {
|
if let Ok(result) = stmt.stmt.step() {
|
||||||
match result {
|
match result {
|
||||||
limbo_core::StepResult::IO => {
|
turso_core::StepResult::IO => {
|
||||||
let io = db.io.clone();
|
let io = db.io.clone();
|
||||||
io.run_once().unwrap();
|
io.run_once().unwrap();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
limbo_core::StepResult::Done => return SQLITE_DONE,
|
turso_core::StepResult::Done => return SQLITE_DONE,
|
||||||
limbo_core::StepResult::Interrupt => return SQLITE_INTERRUPT,
|
turso_core::StepResult::Interrupt => return SQLITE_INTERRUPT,
|
||||||
limbo_core::StepResult::Row => return SQLITE_ROW,
|
turso_core::StepResult::Row => return SQLITE_ROW,
|
||||||
limbo_core::StepResult::Busy => return SQLITE_BUSY,
|
turso_core::StepResult::Busy => return SQLITE_BUSY,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return SQLITE_ERROR;
|
return SQLITE_ERROR;
|
||||||
|
@ -588,63 +588,63 @@ pub unsafe extern "C" fn sqlite3_column_bytes(
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn sqlite3_value_type(value: *mut ffi::c_void) -> ffi::c_int {
|
pub unsafe extern "C" fn sqlite3_value_type(value: *mut ffi::c_void) -> ffi::c_int {
|
||||||
let value = value as *mut limbo_core::Value;
|
let value = value as *mut turso_core::Value;
|
||||||
let value = &*value;
|
let value = &*value;
|
||||||
match value {
|
match value {
|
||||||
limbo_core::Value::Null => 0,
|
turso_core::Value::Null => 0,
|
||||||
limbo_core::Value::Integer(_) => 1,
|
turso_core::Value::Integer(_) => 1,
|
||||||
limbo_core::Value::Float(_) => 2,
|
turso_core::Value::Float(_) => 2,
|
||||||
limbo_core::Value::Text(_) => 3,
|
turso_core::Value::Text(_) => 3,
|
||||||
limbo_core::Value::Blob(_) => 4,
|
turso_core::Value::Blob(_) => 4,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn sqlite3_value_int64(value: *mut ffi::c_void) -> i64 {
|
pub unsafe extern "C" fn sqlite3_value_int64(value: *mut ffi::c_void) -> i64 {
|
||||||
let value = value as *mut limbo_core::Value;
|
let value = value as *mut turso_core::Value;
|
||||||
let value = &*value;
|
let value = &*value;
|
||||||
match value {
|
match value {
|
||||||
limbo_core::Value::Integer(i) => *i,
|
turso_core::Value::Integer(i) => *i,
|
||||||
_ => 0,
|
_ => 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn sqlite3_value_double(value: *mut ffi::c_void) -> f64 {
|
pub unsafe extern "C" fn sqlite3_value_double(value: *mut ffi::c_void) -> f64 {
|
||||||
let value = value as *mut limbo_core::Value;
|
let value = value as *mut turso_core::Value;
|
||||||
let value = &*value;
|
let value = &*value;
|
||||||
match value {
|
match value {
|
||||||
limbo_core::Value::Float(f) => *f,
|
turso_core::Value::Float(f) => *f,
|
||||||
_ => 0.0,
|
_ => 0.0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn sqlite3_value_text(value: *mut ffi::c_void) -> *const ffi::c_uchar {
|
pub unsafe extern "C" fn sqlite3_value_text(value: *mut ffi::c_void) -> *const ffi::c_uchar {
|
||||||
let value = value as *mut limbo_core::Value;
|
let value = value as *mut turso_core::Value;
|
||||||
let value = &*value;
|
let value = &*value;
|
||||||
match value {
|
match value {
|
||||||
limbo_core::Value::Text(text) => text.as_str().as_ptr(),
|
turso_core::Value::Text(text) => text.as_str().as_ptr(),
|
||||||
_ => std::ptr::null(),
|
_ => std::ptr::null(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn sqlite3_value_blob(value: *mut ffi::c_void) -> *const ffi::c_void {
|
pub unsafe extern "C" fn sqlite3_value_blob(value: *mut ffi::c_void) -> *const ffi::c_void {
|
||||||
let value = value as *mut limbo_core::Value;
|
let value = value as *mut turso_core::Value;
|
||||||
let value = &*value;
|
let value = &*value;
|
||||||
match value {
|
match value {
|
||||||
limbo_core::Value::Blob(blob) => blob.as_ptr() as *const ffi::c_void,
|
turso_core::Value::Blob(blob) => blob.as_ptr() as *const ffi::c_void,
|
||||||
_ => std::ptr::null(),
|
_ => std::ptr::null(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub unsafe extern "C" fn sqlite3_value_bytes(value: *mut ffi::c_void) -> ffi::c_int {
|
pub unsafe extern "C" fn sqlite3_value_bytes(value: *mut ffi::c_void) -> ffi::c_int {
|
||||||
let value = value as *mut limbo_core::Value;
|
let value = value as *mut turso_core::Value;
|
||||||
let value = &*value;
|
let value = &*value;
|
||||||
match value {
|
match value {
|
||||||
limbo_core::Value::Blob(blob) => blob.len() as ffi::c_int,
|
turso_core::Value::Blob(blob) => blob.len() as ffi::c_int,
|
||||||
_ => 0,
|
_ => 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -661,7 +661,7 @@ pub unsafe extern "C" fn sqlite3_column_text(
|
||||||
None => return std::ptr::null(),
|
None => return std::ptr::null(),
|
||||||
};
|
};
|
||||||
match row.get::<&Value>(idx as usize) {
|
match row.get::<&Value>(idx as usize) {
|
||||||
Ok(limbo_core::Value::Text(text)) => text.as_str().as_ptr(),
|
Ok(turso_core::Value::Text(text)) => text.as_str().as_ptr(),
|
||||||
_ => std::ptr::null(),
|
_ => std::ptr::null(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ path = "integration/mod.rs"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow.workspace = true
|
anyhow.workspace = true
|
||||||
env_logger = "0.10.1"
|
env_logger = "0.10.1"
|
||||||
limbo_core = { path = "../core" }
|
turso_core = { path = "../core" }
|
||||||
rusqlite = { version = "0.34", features = ["bundled"] }
|
rusqlite = { version = "0.34", features = ["bundled"] }
|
||||||
tempfile = "3.0.7"
|
tempfile = "3.0.7"
|
||||||
log = "0.4.22"
|
log = "0.4.22"
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
use limbo_core::{Connection, Database, PagerCacheflushStatus, IO};
|
|
||||||
use rand::{rng, RngCore};
|
use rand::{rng, RngCore};
|
||||||
use rusqlite::params;
|
use rusqlite::params;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
@ -7,6 +6,7 @@ use tempfile::TempDir;
|
||||||
use tracing_subscriber::layer::SubscriberExt;
|
use tracing_subscriber::layer::SubscriberExt;
|
||||||
use tracing_subscriber::util::SubscriberInitExt;
|
use tracing_subscriber::util::SubscriberInitExt;
|
||||||
use tracing_subscriber::EnvFilter;
|
use tracing_subscriber::EnvFilter;
|
||||||
|
use turso_core::{Connection, Database, PagerCacheflushStatus, IO};
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub struct TempDatabase {
|
pub struct TempDatabase {
|
||||||
|
@ -25,11 +25,11 @@ impl TempDatabase {
|
||||||
pub fn new(db_name: &str, enable_indexes: bool) -> Self {
|
pub fn new(db_name: &str, enable_indexes: bool) -> Self {
|
||||||
let mut path = TempDir::new().unwrap().keep();
|
let mut path = TempDir::new().unwrap().keep();
|
||||||
path.push(db_name);
|
path.push(db_name);
|
||||||
let io: Arc<dyn IO + Send> = Arc::new(limbo_core::PlatformIO::new().unwrap());
|
let io: Arc<dyn IO + Send> = Arc::new(turso_core::PlatformIO::new().unwrap());
|
||||||
let db = Database::open_file_with_flags(
|
let db = Database::open_file_with_flags(
|
||||||
io.clone(),
|
io.clone(),
|
||||||
path.to_str().unwrap(),
|
path.to_str().unwrap(),
|
||||||
limbo_core::OpenFlags::default(),
|
turso_core::OpenFlags::default(),
|
||||||
false,
|
false,
|
||||||
enable_indexes,
|
enable_indexes,
|
||||||
)
|
)
|
||||||
|
@ -40,17 +40,17 @@ impl TempDatabase {
|
||||||
pub fn new_with_existent(db_path: &Path, enable_indexes: bool) -> Self {
|
pub fn new_with_existent(db_path: &Path, enable_indexes: bool) -> Self {
|
||||||
Self::new_with_existent_with_flags(
|
Self::new_with_existent_with_flags(
|
||||||
db_path,
|
db_path,
|
||||||
limbo_core::OpenFlags::default(),
|
turso_core::OpenFlags::default(),
|
||||||
enable_indexes,
|
enable_indexes,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_with_existent_with_flags(
|
pub fn new_with_existent_with_flags(
|
||||||
db_path: &Path,
|
db_path: &Path,
|
||||||
flags: limbo_core::OpenFlags,
|
flags: turso_core::OpenFlags,
|
||||||
enable_indexes: bool,
|
enable_indexes: bool,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let io: Arc<dyn IO + Send> = Arc::new(limbo_core::PlatformIO::new().unwrap());
|
let io: Arc<dyn IO + Send> = Arc::new(turso_core::PlatformIO::new().unwrap());
|
||||||
let db = Database::open_file_with_flags(
|
let db = Database::open_file_with_flags(
|
||||||
io.clone(),
|
io.clone(),
|
||||||
db_path.to_str().unwrap(),
|
db_path.to_str().unwrap(),
|
||||||
|
@ -79,11 +79,11 @@ impl TempDatabase {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
connection.execute(table_sql, ()).unwrap();
|
connection.execute(table_sql, ()).unwrap();
|
||||||
}
|
}
|
||||||
let io: Arc<dyn limbo_core::IO> = Arc::new(limbo_core::PlatformIO::new().unwrap());
|
let io: Arc<dyn turso_core::IO> = Arc::new(turso_core::PlatformIO::new().unwrap());
|
||||||
let db = Database::open_file_with_flags(
|
let db = Database::open_file_with_flags(
|
||||||
io.clone(),
|
io.clone(),
|
||||||
path.to_str().unwrap(),
|
path.to_str().unwrap(),
|
||||||
limbo_core::OpenFlags::default(),
|
turso_core::OpenFlags::default(),
|
||||||
false,
|
false,
|
||||||
enable_indexes,
|
enable_indexes,
|
||||||
)
|
)
|
||||||
|
@ -92,7 +92,7 @@ impl TempDatabase {
|
||||||
Self { path, io, db }
|
Self { path, io, db }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn connect_limbo(&self) -> Arc<limbo_core::Connection> {
|
pub fn connect_limbo(&self) -> Arc<turso_core::Connection> {
|
||||||
log::debug!("conneting to limbo");
|
log::debug!("conneting to limbo");
|
||||||
|
|
||||||
let conn = self.db.connect().unwrap();
|
let conn = self.db.connect().unwrap();
|
||||||
|
@ -100,7 +100,7 @@ impl TempDatabase {
|
||||||
conn
|
conn
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn limbo_database(&self, enable_indexes: bool) -> Arc<limbo_core::Database> {
|
pub fn limbo_database(&self, enable_indexes: bool) -> Arc<turso_core::Database> {
|
||||||
log::debug!("conneting to limbo");
|
log::debug!("conneting to limbo");
|
||||||
Database::open_file(
|
Database::open_file(
|
||||||
self.io.clone(),
|
self.io.clone(),
|
||||||
|
@ -184,7 +184,7 @@ pub(crate) fn sqlite_exec_rows(
|
||||||
|
|
||||||
pub(crate) fn limbo_exec_rows(
|
pub(crate) fn limbo_exec_rows(
|
||||||
db: &TempDatabase,
|
db: &TempDatabase,
|
||||||
conn: &Arc<limbo_core::Connection>,
|
conn: &Arc<turso_core::Connection>,
|
||||||
query: &str,
|
query: &str,
|
||||||
) -> Vec<Vec<rusqlite::types::Value>> {
|
) -> Vec<Vec<rusqlite::types::Value>> {
|
||||||
let mut stmt = conn.prepare(query).unwrap();
|
let mut stmt = conn.prepare(query).unwrap();
|
||||||
|
@ -193,26 +193,26 @@ pub(crate) fn limbo_exec_rows(
|
||||||
let row = loop {
|
let row = loop {
|
||||||
let result = stmt.step().unwrap();
|
let result = stmt.step().unwrap();
|
||||||
match result {
|
match result {
|
||||||
limbo_core::StepResult::Row => {
|
turso_core::StepResult::Row => {
|
||||||
let row = stmt.row().unwrap();
|
let row = stmt.row().unwrap();
|
||||||
break row;
|
break row;
|
||||||
}
|
}
|
||||||
limbo_core::StepResult::IO => {
|
turso_core::StepResult::IO => {
|
||||||
db.io.run_once().unwrap();
|
db.io.run_once().unwrap();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
limbo_core::StepResult::Done => break 'outer,
|
turso_core::StepResult::Done => break 'outer,
|
||||||
r => panic!("unexpected result {:?}: expecting single row", r),
|
r => panic!("unexpected result {:?}: expecting single row", r),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let row = row
|
let row = row
|
||||||
.get_values()
|
.get_values()
|
||||||
.map(|x| match x {
|
.map(|x| match x {
|
||||||
limbo_core::Value::Null => rusqlite::types::Value::Null,
|
turso_core::Value::Null => rusqlite::types::Value::Null,
|
||||||
limbo_core::Value::Integer(x) => rusqlite::types::Value::Integer(*x),
|
turso_core::Value::Integer(x) => rusqlite::types::Value::Integer(*x),
|
||||||
limbo_core::Value::Float(x) => rusqlite::types::Value::Real(*x),
|
turso_core::Value::Float(x) => rusqlite::types::Value::Real(*x),
|
||||||
limbo_core::Value::Text(x) => rusqlite::types::Value::Text(x.as_str().to_string()),
|
turso_core::Value::Text(x) => rusqlite::types::Value::Text(x.as_str().to_string()),
|
||||||
limbo_core::Value::Blob(x) => rusqlite::types::Value::Blob(x.to_vec()),
|
turso_core::Value::Blob(x) => rusqlite::types::Value::Blob(x.to_vec()),
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
rows.push(row);
|
rows.push(row);
|
||||||
|
@ -222,18 +222,18 @@ pub(crate) fn limbo_exec_rows(
|
||||||
|
|
||||||
pub(crate) fn limbo_exec_rows_error(
|
pub(crate) fn limbo_exec_rows_error(
|
||||||
db: &TempDatabase,
|
db: &TempDatabase,
|
||||||
conn: &Arc<limbo_core::Connection>,
|
conn: &Arc<turso_core::Connection>,
|
||||||
query: &str,
|
query: &str,
|
||||||
) -> limbo_core::Result<()> {
|
) -> turso_core::Result<()> {
|
||||||
let mut stmt = conn.prepare(query)?;
|
let mut stmt = conn.prepare(query)?;
|
||||||
loop {
|
loop {
|
||||||
let result = stmt.step()?;
|
let result = stmt.step()?;
|
||||||
match result {
|
match result {
|
||||||
limbo_core::StepResult::IO => {
|
turso_core::StepResult::IO => {
|
||||||
db.io.run_once()?;
|
db.io.run_once()?;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
limbo_core::StepResult::Done => return Ok(()),
|
turso_core::StepResult::Done => return Ok(()),
|
||||||
r => panic!("unexpected result {:?}: expecting single row", r),
|
r => panic!("unexpected result {:?}: expecting single row", r),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -292,7 +292,7 @@ mod tests {
|
||||||
{
|
{
|
||||||
let db = TempDatabase::new_with_existent_with_flags(
|
let db = TempDatabase::new_with_existent_with_flags(
|
||||||
&path,
|
&path,
|
||||||
limbo_core::OpenFlags::default(),
|
turso_core::OpenFlags::default(),
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
let conn = db.connect_limbo();
|
let conn = db.connect_limbo();
|
||||||
|
@ -305,7 +305,7 @@ mod tests {
|
||||||
{
|
{
|
||||||
let db = TempDatabase::new_with_existent_with_flags(
|
let db = TempDatabase::new_with_existent_with_flags(
|
||||||
&path,
|
&path,
|
||||||
limbo_core::OpenFlags::default() | limbo_core::OpenFlags::ReadOnly,
|
turso_core::OpenFlags::default() | turso_core::OpenFlags::ReadOnly,
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
let conn = db.connect_limbo();
|
let conn = db.connect_limbo();
|
||||||
|
@ -313,7 +313,7 @@ mod tests {
|
||||||
assert_eq!(ret, vec![vec![Value::Integer(1)]]);
|
assert_eq!(ret, vec![vec![Value::Integer(1)]]);
|
||||||
|
|
||||||
let err = limbo_exec_rows_error(&db, &conn, "INSERT INTO t values (1)").unwrap_err();
|
let err = limbo_exec_rows_error(&db, &conn, "INSERT INTO t values (1)").unwrap_err();
|
||||||
assert!(matches!(err, limbo_core::LimboError::ReadOnly), "{:?}", err);
|
assert!(matches!(err, turso_core::LimboError::ReadOnly), "{:?}", err);
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::common::{do_flush, TempDatabase};
|
use crate::common::{do_flush, TempDatabase};
|
||||||
use limbo_core::StepResult;
|
use turso_core::StepResult;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_last_insert_rowid_basic() -> anyhow::Result<()> {
|
fn test_last_insert_rowid_basic() -> anyhow::Result<()> {
|
||||||
|
@ -31,7 +31,7 @@ fn test_last_insert_rowid_basic() -> anyhow::Result<()> {
|
||||||
match rows.step()? {
|
match rows.step()? {
|
||||||
StepResult::Row => {
|
StepResult::Row => {
|
||||||
let row = rows.row().unwrap();
|
let row = rows.row().unwrap();
|
||||||
if let limbo_core::Value::Integer(id) = row.get_value(0) {
|
if let turso_core::Value::Integer(id) = row.get_value(0) {
|
||||||
assert_eq!(*id, 1, "First insert should have rowid 1");
|
assert_eq!(*id, 1, "First insert should have rowid 1");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ fn test_last_insert_rowid_basic() -> anyhow::Result<()> {
|
||||||
match rows.step()? {
|
match rows.step()? {
|
||||||
StepResult::Row => {
|
StepResult::Row => {
|
||||||
let row = rows.row().unwrap();
|
let row = rows.row().unwrap();
|
||||||
if let limbo_core::Value::Integer(id) = row.get_value(0) {
|
if let turso_core::Value::Integer(id) = row.get_value(0) {
|
||||||
last_id = *id;
|
last_id = *id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ fn test_integer_primary_key() -> anyhow::Result<()> {
|
||||||
match select_query.step()? {
|
match select_query.step()? {
|
||||||
StepResult::Row => {
|
StepResult::Row => {
|
||||||
let row = select_query.row().unwrap();
|
let row = select_query.row().unwrap();
|
||||||
if let limbo_core::Value::Integer(id) = row.get_value(0) {
|
if let turso_core::Value::Integer(id) = row.get_value(0) {
|
||||||
rowids.push(*id);
|
rowids.push(*id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::common::TempDatabase;
|
use crate::common::TempDatabase;
|
||||||
use limbo_core::{StepResult, Value};
|
use turso_core::{StepResult, Value};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_statement_reset_bind() -> anyhow::Result<()> {
|
fn test_statement_reset_bind() -> anyhow::Result<()> {
|
||||||
|
@ -16,7 +16,7 @@ fn test_statement_reset_bind() -> anyhow::Result<()> {
|
||||||
let row = stmt.row().unwrap();
|
let row = stmt.row().unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
*row.get::<&Value>(0).unwrap(),
|
*row.get::<&Value>(0).unwrap(),
|
||||||
limbo_core::Value::Integer(1)
|
turso_core::Value::Integer(1)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
StepResult::IO => tmp_db.io.run_once()?,
|
StepResult::IO => tmp_db.io.run_once()?,
|
||||||
|
@ -34,7 +34,7 @@ fn test_statement_reset_bind() -> anyhow::Result<()> {
|
||||||
let row = stmt.row().unwrap();
|
let row = stmt.row().unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
*row.get::<&Value>(0).unwrap(),
|
*row.get::<&Value>(0).unwrap(),
|
||||||
limbo_core::Value::Integer(2)
|
turso_core::Value::Integer(2)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
StepResult::IO => tmp_db.io.run_once()?,
|
StepResult::IO => tmp_db.io.run_once()?,
|
||||||
|
@ -67,23 +67,23 @@ fn test_statement_bind() -> anyhow::Result<()> {
|
||||||
match stmt.step()? {
|
match stmt.step()? {
|
||||||
StepResult::Row => {
|
StepResult::Row => {
|
||||||
let row = stmt.row().unwrap();
|
let row = stmt.row().unwrap();
|
||||||
if let limbo_core::Value::Text(s) = row.get::<&Value>(0).unwrap() {
|
if let turso_core::Value::Text(s) = row.get::<&Value>(0).unwrap() {
|
||||||
assert_eq!(s.as_str(), "hello")
|
assert_eq!(s.as_str(), "hello")
|
||||||
}
|
}
|
||||||
|
|
||||||
if let limbo_core::Value::Text(s) = row.get::<&Value>(1).unwrap() {
|
if let turso_core::Value::Text(s) = row.get::<&Value>(1).unwrap() {
|
||||||
assert_eq!(s.as_str(), "hello")
|
assert_eq!(s.as_str(), "hello")
|
||||||
}
|
}
|
||||||
|
|
||||||
if let limbo_core::Value::Integer(i) = row.get::<&Value>(2).unwrap() {
|
if let turso_core::Value::Integer(i) = row.get::<&Value>(2).unwrap() {
|
||||||
assert_eq!(*i, 42)
|
assert_eq!(*i, 42)
|
||||||
}
|
}
|
||||||
|
|
||||||
if let limbo_core::Value::Blob(v) = row.get::<&Value>(3).unwrap() {
|
if let turso_core::Value::Blob(v) = row.get::<&Value>(3).unwrap() {
|
||||||
assert_eq!(v.as_slice(), &vec![0x1_u8, 0x2, 0x3])
|
assert_eq!(v.as_slice(), &vec![0x1_u8, 0x2, 0x3])
|
||||||
}
|
}
|
||||||
|
|
||||||
if let limbo_core::Value::Float(f) = row.get::<&Value>(4).unwrap() {
|
if let turso_core::Value::Float(f) = row.get::<&Value>(4).unwrap() {
|
||||||
assert_eq!(*f, 0.5)
|
assert_eq!(*f, 0.5)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
use crate::common::{self, maybe_setup_tracing};
|
use crate::common::{self, maybe_setup_tracing};
|
||||||
use crate::common::{compare_string, do_flush, TempDatabase};
|
use crate::common::{compare_string, do_flush, TempDatabase};
|
||||||
use limbo_core::{Connection, Row, Statement, StepResult, Value};
|
|
||||||
use log::debug;
|
use log::debug;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use turso_core::{Connection, Row, Statement, StepResult, Value};
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! change_state {
|
macro_rules! change_state {
|
||||||
|
@ -175,8 +175,8 @@ fn test_sequential_write() -> anyhow::Result<()> {
|
||||||
run_query_on_row(&tmp_db, &conn, list_query, |row: &Row| {
|
run_query_on_row(&tmp_db, &conn, list_query, |row: &Row| {
|
||||||
let first_value = row.get::<&Value>(0).expect("missing id");
|
let first_value = row.get::<&Value>(0).expect("missing id");
|
||||||
let id = match first_value {
|
let id = match first_value {
|
||||||
limbo_core::Value::Integer(i) => *i as i32,
|
turso_core::Value::Integer(i) => *i as i32,
|
||||||
limbo_core::Value::Float(f) => *f as i32,
|
turso_core::Value::Float(f) => *f as i32,
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
};
|
};
|
||||||
assert_eq!(current_read_index, id);
|
assert_eq!(current_read_index, id);
|
||||||
|
@ -239,7 +239,7 @@ fn test_statement_reset() -> anyhow::Result<()> {
|
||||||
let row = stmt.row().unwrap();
|
let row = stmt.row().unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
*row.get::<&Value>(0).unwrap(),
|
*row.get::<&Value>(0).unwrap(),
|
||||||
limbo_core::Value::Integer(1)
|
turso_core::Value::Integer(1)
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -256,7 +256,7 @@ fn test_statement_reset() -> anyhow::Result<()> {
|
||||||
let row = stmt.row().unwrap();
|
let row = stmt.row().unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
*row.get::<&Value>(0).unwrap(),
|
*row.get::<&Value>(0).unwrap(),
|
||||||
limbo_core::Value::Integer(1)
|
turso_core::Value::Integer(1)
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -381,8 +381,8 @@ fn test_write_delete_with_index() -> anyhow::Result<()> {
|
||||||
run_query_on_row(&tmp_db, &conn, list_query, |row: &Row| {
|
run_query_on_row(&tmp_db, &conn, list_query, |row: &Row| {
|
||||||
let first_value = row.get::<&Value>(0).expect("missing id");
|
let first_value = row.get::<&Value>(0).expect("missing id");
|
||||||
let id = match first_value {
|
let id = match first_value {
|
||||||
limbo_core::Value::Integer(i) => *i as i32,
|
turso_core::Value::Integer(i) => *i as i32,
|
||||||
limbo_core::Value::Float(f) => *f as i32,
|
turso_core::Value::Float(f) => *f as i32,
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
};
|
};
|
||||||
assert_eq!(current_read_index, id);
|
assert_eq!(current_read_index, id);
|
||||||
|
@ -397,8 +397,8 @@ fn test_write_delete_with_index() -> anyhow::Result<()> {
|
||||||
|row| {
|
|row| {
|
||||||
let first_value = row.get::<&Value>(0).expect("missing id");
|
let first_value = row.get::<&Value>(0).expect("missing id");
|
||||||
let id = match first_value {
|
let id = match first_value {
|
||||||
limbo_core::Value::Integer(i) => *i as i32,
|
turso_core::Value::Integer(i) => *i as i32,
|
||||||
limbo_core::Value::Float(f) => *f as i32,
|
turso_core::Value::Float(f) => *f as i32,
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
};
|
};
|
||||||
assert_eq!(i, id);
|
assert_eq!(i, id);
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
use crate::common::{do_flush, maybe_setup_tracing, TempDatabase};
|
use crate::common::{do_flush, maybe_setup_tracing, TempDatabase};
|
||||||
use limbo_core::{Connection, LimboError, Result, StepResult};
|
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
use turso_core::{Connection, LimboError, Result, StepResult};
|
||||||
|
|
||||||
#[allow(clippy::arc_with_non_send_sync)]
|
#[allow(clippy::arc_with_non_send_sync)]
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -154,7 +154,7 @@ pub(crate) fn execute_and_get_ints(
|
||||||
let row = stmt.row().unwrap();
|
let row = stmt.row().unwrap();
|
||||||
for value in row.get_values() {
|
for value in row.get_values() {
|
||||||
let out = match value {
|
let out = match value {
|
||||||
limbo_core::Value::Integer(i) => i,
|
turso_core::Value::Integer(i) => i,
|
||||||
_ => {
|
_ => {
|
||||||
return Err(LimboError::ConversionError(format!(
|
return Err(LimboError::ConversionError(format!(
|
||||||
"cannot convert {value} to int"
|
"cannot convert {value} to int"
|
||||||
|
|
|
@ -244,7 +244,7 @@ mod tests {
|
||||||
pub(crate) struct TestContext;
|
pub(crate) struct TestContext;
|
||||||
|
|
||||||
// Placeholders for compilation
|
// Placeholders for compilation
|
||||||
// Context only necessary parsing inside limbo_core or in the simulator
|
// Context only necessary parsing inside turso_core or in the simulator
|
||||||
impl ToSqlContext for TestContext {
|
impl ToSqlContext for TestContext {
|
||||||
fn get_column_name(&self, _table_id: crate::ast::TableInternalId, _col_idx: usize) -> &str {
|
fn get_column_name(&self, _table_id: crate::ast::TableInternalId, _col_idx: usize) -> &str {
|
||||||
todo!()
|
todo!()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue