mirror of
https://github.com/tursodatabase/limbo.git
synced 2025-07-07 12:35:00 +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
|
||||
- name: Test
|
||||
env:
|
||||
RUST_LOG: ${{ runner.debug && 'limbo_core::storage=trace' || '' }}
|
||||
RUST_LOG: ${{ runner.debug && 'turso_core::storage=trace' || '' }}
|
||||
run: cargo test --verbose
|
||||
timeout-minutes: 20
|
||||
|
||||
|
|
138
Cargo.lock
generated
138
Cargo.lock
generated
|
@ -520,7 +520,6 @@ dependencies = [
|
|||
"anyhow",
|
||||
"assert_cmd",
|
||||
"env_logger 0.10.2",
|
||||
"limbo_core",
|
||||
"log",
|
||||
"rand 0.9.0",
|
||||
"rand_chacha 0.9.0",
|
||||
|
@ -530,6 +529,7 @@ dependencies = [
|
|||
"test-log",
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
"turso_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1724,17 +1724,17 @@ dependencies = [
|
|||
name = "limbo"
|
||||
version = "0.1.0-pre.2"
|
||||
dependencies = [
|
||||
"limbo_core",
|
||||
"tempfile",
|
||||
"thiserror 2.0.12",
|
||||
"tokio",
|
||||
"turso_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "limbo-go"
|
||||
version = "0.1.0-pre.2"
|
||||
dependencies = [
|
||||
"limbo_core",
|
||||
"turso_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1742,8 +1742,8 @@ name = "limbo-java"
|
|||
version = "0.1.0-pre.2"
|
||||
dependencies = [
|
||||
"jni",
|
||||
"limbo_core",
|
||||
"thiserror 2.0.12",
|
||||
"turso_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1753,7 +1753,7 @@ dependencies = [
|
|||
"console_error_panic_hook",
|
||||
"getrandom 0.2.15",
|
||||
"js-sys",
|
||||
"limbo_core",
|
||||
"turso_core",
|
||||
"wasm-bindgen",
|
||||
"wasm-bindgen-futures",
|
||||
"web-sys",
|
||||
|
@ -1767,65 +1767,6 @@ dependencies = [
|
|||
"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]]
|
||||
name = "limbo_crypto"
|
||||
version = "0.1.0-pre.2"
|
||||
|
@ -1925,7 +1866,6 @@ dependencies = [
|
|||
"dirs 6.0.0",
|
||||
"env_logger 0.10.2",
|
||||
"hex",
|
||||
"limbo_core",
|
||||
"limbo_sqlite3_parser",
|
||||
"log",
|
||||
"notify",
|
||||
|
@ -1938,6 +1878,7 @@ dependencies = [
|
|||
"serde_json",
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
"turso_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1946,11 +1887,11 @@ version = "0.1.0-pre.2"
|
|||
dependencies = [
|
||||
"env_logger 0.11.7",
|
||||
"libc",
|
||||
"limbo_core",
|
||||
"tempfile",
|
||||
"tracing",
|
||||
"tracing-appender",
|
||||
"tracing-subscriber",
|
||||
"turso_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -2679,9 +2620,9 @@ name = "py-turso"
|
|||
version = "0.1.0-pre.2"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"limbo_core",
|
||||
"pyo3",
|
||||
"pyo3-build-config",
|
||||
"turso_core",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
|
@ -3792,7 +3733,6 @@ dependencies = [
|
|||
"dirs 5.0.1",
|
||||
"env_logger 0.10.2",
|
||||
"libc",
|
||||
"limbo_core",
|
||||
"miette",
|
||||
"nu-ansi-term 0.50.1",
|
||||
"rustyline",
|
||||
|
@ -3805,17 +3745,77 @@ dependencies = [
|
|||
"tracing",
|
||||
"tracing-appender",
|
||||
"tracing-subscriber",
|
||||
"turso_core",
|
||||
"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]]
|
||||
name = "turso_node"
|
||||
version = "0.1.0-pre.2"
|
||||
dependencies = [
|
||||
"limbo_core",
|
||||
"napi",
|
||||
"napi-build",
|
||||
"napi-derive",
|
||||
"turso_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
|
@ -40,7 +40,7 @@ repository = "https://github.com/tursodatabase/limbo"
|
|||
|
||||
[workspace.dependencies]
|
||||
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_csv = { path = "extensions/csv", 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]
|
||||
default = ["io_uring"]
|
||||
io_uring = ["limbo_core/io_uring"]
|
||||
io_uring = ["turso_core/io_uring"]
|
||||
|
||||
|
||||
[dependencies]
|
||||
limbo_core = { workspace = true }
|
||||
turso_core = { workspace = true }
|
||||
|
||||
[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)]
|
||||
mod statement;
|
||||
mod types;
|
||||
use limbo_core::{Connection, Database, LimboError, IO};
|
||||
use std::{
|
||||
ffi::{c_char, c_void},
|
||||
sync::Arc,
|
||||
};
|
||||
use turso_core::{Connection, Database, LimboError, IO};
|
||||
|
||||
/// # Safety
|
||||
/// 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 = path.to_str().unwrap();
|
||||
let io: Arc<dyn IO> = match path {
|
||||
p if p.contains(":memory:") => Arc::new(limbo_core::MemoryIO::new()),
|
||||
_ => Arc::new(limbo_core::PlatformIO::new().expect("Failed to create IO")),
|
||||
p if p.contains(":memory:") => Arc::new(turso_core::MemoryIO::new()),
|
||||
_ => Arc::new(turso_core::PlatformIO::new().expect("Failed to create IO")),
|
||||
};
|
||||
let db = Database::open_file(io.clone(), path, false, false);
|
||||
match db {
|
||||
|
@ -40,12 +40,12 @@ pub unsafe extern "C" fn db_open(path: *const c_char) -> *mut c_void {
|
|||
#[allow(dead_code)]
|
||||
struct LimboConn {
|
||||
conn: Arc<Connection>,
|
||||
io: Arc<dyn limbo_core::IO>,
|
||||
io: Arc<dyn turso_core::IO>,
|
||||
err: Option<LimboError>,
|
||||
}
|
||||
|
||||
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 {
|
||||
conn,
|
||||
io,
|
||||
|
|
|
@ -2,8 +2,8 @@ use crate::{
|
|||
types::{LimboValue, ResultCode},
|
||||
LimboConn,
|
||||
};
|
||||
use limbo_core::{LimboError, Statement, StepResult, Value};
|
||||
use std::ffi::{c_char, c_void};
|
||||
use turso_core::{LimboError, Statement, StepResult, Value};
|
||||
|
||||
pub struct LimboRows<'conn> {
|
||||
stmt: Box<Statement>,
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use crate::rows::LimboRows;
|
||||
use crate::types::{AllocPool, LimboValue, ResultCode};
|
||||
use crate::LimboConn;
|
||||
use limbo_core::{LimboError, Statement, StepResult};
|
||||
use std::ffi::{c_char, c_void};
|
||||
use std::num::NonZero;
|
||||
use turso_core::{LimboError, Statement, StepResult};
|
||||
|
||||
#[no_mangle]
|
||||
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
|
||||
}
|
||||
|
||||
pub fn from_owned_value(value: &limbo_core::Value) -> Self {
|
||||
pub fn from_owned_value(value: &turso_core::Value) -> Self {
|
||||
match value {
|
||||
limbo_core::Value::Integer(i) => {
|
||||
turso_core::Value::Integer(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))
|
||||
}
|
||||
limbo_core::Value::Text(s) => {
|
||||
turso_core::Value::Text(s) => {
|
||||
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()))
|
||||
}
|
||||
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
|
||||
// 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 {
|
||||
ValueType::Integer => {
|
||||
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 => {
|
||||
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 => {
|
||||
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) };
|
||||
match cstr.to_str() {
|
||||
Ok(utf8_str) => {
|
||||
let owned = utf8_str.to_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 => {
|
||||
if unsafe { self.value.blob_ptr.is_null() } {
|
||||
return limbo_core::Value::Null;
|
||||
return turso_core::Value::Null;
|
||||
}
|
||||
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"
|
||||
|
||||
[dependencies]
|
||||
limbo_core = { path = "../../core", features = ["io_uring"] }
|
||||
turso_core = { path = "../../core", features = ["io_uring"] }
|
||||
jni = "0.21.1"
|
||||
thiserror = "2.0.9"
|
||||
|
|
|
@ -16,8 +16,8 @@ pub enum LimboError {
|
|||
JNIErrors(Error),
|
||||
}
|
||||
|
||||
impl From<limbo_core::LimboError> for LimboError {
|
||||
fn from(_value: limbo_core::LimboError) -> Self {
|
||||
impl From<turso_core::LimboError> for LimboError {
|
||||
fn from(_value: turso_core::LimboError) -> Self {
|
||||
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::sys::jlong;
|
||||
use jni::JNIEnv;
|
||||
use limbo_core::Connection;
|
||||
use std::sync::Arc;
|
||||
use turso_core::Connection;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct LimboConnection {
|
||||
pub(crate) conn: Arc<Connection>,
|
||||
pub(crate) io: Arc<dyn limbo_core::IO>,
|
||||
pub(crate) io: Arc<dyn turso_core::IO>,
|
||||
}
|
||||
|
||||
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 }
|
||||
}
|
||||
|
||||
|
|
|
@ -4,16 +4,16 @@ use crate::utils::set_err_msg_and_throw_exception;
|
|||
use jni::objects::{JByteArray, JObject};
|
||||
use jni::sys::{jint, jlong};
|
||||
use jni::JNIEnv;
|
||||
use limbo_core::Database;
|
||||
use std::sync::Arc;
|
||||
use turso_core::Database;
|
||||
|
||||
struct LimboDB {
|
||||
db: Arc<Database>,
|
||||
io: Arc<dyn limbo_core::IO>,
|
||||
io: Arc<dyn turso_core::IO>,
|
||||
}
|
||||
|
||||
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 }
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ pub extern "system" fn Java_tech_turso_core_LimboDB_openUtf8<'local>(
|
|||
file_path_byte_arr: JByteArray<'local>,
|
||||
_open_flags: jint,
|
||||
) -> jlong {
|
||||
let io = match limbo_core::PlatformIO::new() {
|
||||
let io = match turso_core::PlatformIO::new() {
|
||||
Ok(io) => Arc::new(io),
|
||||
Err(e) => {
|
||||
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::sys::{jdouble, jint, jlong};
|
||||
use jni::JNIEnv;
|
||||
use limbo_core::{Statement, StepResult, Value};
|
||||
use std::num::NonZero;
|
||||
use turso_core::{Statement, StepResult, Value};
|
||||
|
||||
pub const STEP_RESULT_ID_ROW: i32 = 10;
|
||||
#[allow(dead_code)]
|
||||
|
@ -101,21 +101,21 @@ pub extern "system" fn Java_tech_turso_core_LimboStatement__1close<'local>(
|
|||
|
||||
fn row_to_obj_array<'local>(
|
||||
env: &mut JNIEnv<'local>,
|
||||
row: &limbo_core::Row,
|
||||
row: &turso_core::Row,
|
||||
) -> Result<JObject<'local>> {
|
||||
let obj_array = env.new_object_array(row.len() as i32, "java/lang/Object", JObject::null())?;
|
||||
|
||||
for (i, value) in row.get_values().enumerate() {
|
||||
let obj = match value {
|
||||
limbo_core::Value::Null => JObject::null(),
|
||||
limbo_core::Value::Integer(i) => {
|
||||
turso_core::Value::Null => JObject::null(),
|
||||
turso_core::Value::Integer(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)])?
|
||||
}
|
||||
limbo_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::Text(s) => env.new_string(s.as_str())?.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) {
|
||||
eprintln!("Error on parsing row: {:?}", e);
|
||||
|
|
|
@ -11,7 +11,7 @@ description = "The Turso database library Node bindings"
|
|||
crate-type = ["cdylib"]
|
||||
|
||||
[dependencies]
|
||||
limbo_core = { workspace = true }
|
||||
turso_core = { workspace = true }
|
||||
napi = { version = "2.16.17", default-features = false, features = ["napi4"] }
|
||||
napi-derive = { version = "2.16.13", default-features = false }
|
||||
|
||||
|
|
|
@ -6,10 +6,10 @@ use std::num::NonZeroUsize;
|
|||
use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
|
||||
use limbo_core::{LimboError, StepResult};
|
||||
use napi::iterator::Generator;
|
||||
use napi::{bindgen_prelude::ObjectFinalize, Env, JsUnknown};
|
||||
use napi_derive::napi;
|
||||
use turso_core::{LimboError, StepResult};
|
||||
|
||||
#[derive(Default)]
|
||||
#[napi(object)]
|
||||
|
@ -39,9 +39,9 @@ pub struct Database {
|
|||
// pub open: bool,
|
||||
#[napi(writable = false)]
|
||||
pub name: String,
|
||||
_db: Arc<limbo_core::Database>,
|
||||
conn: Arc<limbo_core::Connection>,
|
||||
io: Arc<dyn limbo_core::IO>,
|
||||
_db: Arc<turso_core::Database>,
|
||||
conn: Arc<turso_core::Connection>,
|
||||
io: Arc<dyn turso_core::IO>,
|
||||
}
|
||||
|
||||
impl ObjectFinalize for Database {
|
||||
|
@ -57,21 +57,21 @@ impl Database {
|
|||
#[napi(constructor)]
|
||||
pub fn new(path: String, options: Option<OpenDatabaseOptions>) -> napi::Result<Self> {
|
||||
let memory = path == ":memory:";
|
||||
let io: Arc<dyn limbo_core::IO> = if memory {
|
||||
Arc::new(limbo_core::MemoryIO::new())
|
||||
let io: Arc<dyn turso_core::IO> = if memory {
|
||||
Arc::new(turso_core::MemoryIO::new())
|
||||
} 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 flag = if opts.readonly {
|
||||
limbo_core::OpenFlags::ReadOnly
|
||||
turso_core::OpenFlags::ReadOnly
|
||||
} else {
|
||||
limbo_core::OpenFlags::Create
|
||||
turso_core::OpenFlags::Create
|
||||
};
|
||||
let file = io.open_file(&path, flag, false).map_err(into_napi_error)?;
|
||||
|
||||
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)?;
|
||||
let conn = db.connect().map_err(into_napi_error)?;
|
||||
|
||||
|
@ -105,19 +105,19 @@ impl Database {
|
|||
let mut stmt = stmt.inner.borrow_mut();
|
||||
loop {
|
||||
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();
|
||||
return to_js_value(&env, &row[0]);
|
||||
}
|
||||
limbo_core::StepResult::Done => {
|
||||
turso_core::StepResult::Done => {
|
||||
return Ok(env.get_undefined()?.into_unknown())
|
||||
}
|
||||
limbo_core::StepResult::IO => {
|
||||
turso_core::StepResult::IO => {
|
||||
self.io.run_once().map_err(into_napi_error)?;
|
||||
continue;
|
||||
}
|
||||
step @ limbo_core::StepResult::Interrupt
|
||||
| step @ limbo_core::StepResult::Busy => {
|
||||
step @ turso_core::StepResult::Interrupt
|
||||
| step @ turso_core::StepResult::Busy => {
|
||||
return Err(napi::Error::new(
|
||||
napi::Status::GenericFailure,
|
||||
format!("{:?}", step),
|
||||
|
@ -162,7 +162,7 @@ impl Database {
|
|||
|
||||
#[napi]
|
||||
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
|
||||
.load_extension(ext_path)
|
||||
.map_err(into_napi_error)?;
|
||||
|
@ -237,12 +237,12 @@ pub struct Statement {
|
|||
database: Database,
|
||||
presentation_mode: PresentationMode,
|
||||
binded: bool,
|
||||
inner: Rc<RefCell<limbo_core::Statement>>,
|
||||
inner: Rc<RefCell<turso_core::Statement>>,
|
||||
}
|
||||
|
||||
#[napi]
|
||||
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 {
|
||||
inner: Rc::new(inner),
|
||||
database,
|
||||
|
@ -259,7 +259,7 @@ impl Statement {
|
|||
loop {
|
||||
let step = stmt.step().map_err(into_napi_error)?;
|
||||
match step {
|
||||
limbo_core::StepResult::Row => {
|
||||
turso_core::StepResult::Row => {
|
||||
let row = stmt.row().unwrap();
|
||||
|
||||
match self.presentation_mode {
|
||||
|
@ -297,12 +297,12 @@ impl Statement {
|
|||
}
|
||||
}
|
||||
}
|
||||
limbo_core::StepResult::Done => return Ok(env.get_undefined()?.into_unknown()),
|
||||
limbo_core::StepResult::IO => {
|
||||
turso_core::StepResult::Done => return Ok(env.get_undefined()?.into_unknown()),
|
||||
turso_core::StepResult::IO => {
|
||||
self.database.io.run_once().map_err(into_napi_error)?;
|
||||
continue;
|
||||
}
|
||||
limbo_core::StepResult::Interrupt | limbo_core::StepResult::Busy => {
|
||||
turso_core::StepResult::Interrupt | turso_core::StepResult::Busy => {
|
||||
return Err(napi::Error::new(
|
||||
napi::Status::GenericFailure,
|
||||
format!("{:?}", step),
|
||||
|
@ -345,13 +345,13 @@ impl Statement {
|
|||
fn internal_all(
|
||||
&self,
|
||||
env: Env,
|
||||
mut stmt: RefMut<'_, limbo_core::Statement>,
|
||||
mut stmt: RefMut<'_, turso_core::Statement>,
|
||||
) -> napi::Result<JsUnknown> {
|
||||
let mut results = env.create_empty_array()?;
|
||||
let mut index = 0;
|
||||
loop {
|
||||
match stmt.step().map_err(into_napi_error)? {
|
||||
limbo_core::StepResult::Row => {
|
||||
turso_core::StepResult::Row => {
|
||||
let row = stmt.row().unwrap();
|
||||
|
||||
match self.presentation_mode {
|
||||
|
@ -388,13 +388,13 @@ impl Statement {
|
|||
}
|
||||
}
|
||||
}
|
||||
limbo_core::StepResult::Done => {
|
||||
turso_core::StepResult::Done => {
|
||||
break;
|
||||
}
|
||||
limbo_core::StepResult::IO => {
|
||||
turso_core::StepResult::IO => {
|
||||
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(
|
||||
napi::Status::GenericFailure,
|
||||
format!("{:?}", stmt.step()),
|
||||
|
@ -447,7 +447,7 @@ impl Statement {
|
|||
fn check_and_bind(
|
||||
&self,
|
||||
args: Option<Vec<JsUnknown>>,
|
||||
) -> napi::Result<RefMut<'_, limbo_core::Statement>> {
|
||||
) -> napi::Result<RefMut<'_, turso_core::Statement>> {
|
||||
let mut stmt = self.inner.borrow_mut();
|
||||
stmt.reset();
|
||||
if let Some(args) = args {
|
||||
|
@ -470,7 +470,7 @@ impl Statement {
|
|||
|
||||
#[napi(iterator)]
|
||||
pub struct IteratorStatement {
|
||||
stmt: Rc<RefCell<limbo_core::Statement>>,
|
||||
stmt: Rc<RefCell<turso_core::Statement>>,
|
||||
database: Database,
|
||||
env: Env,
|
||||
presentation_mode: PresentationMode,
|
||||
|
@ -488,7 +488,7 @@ impl Generator for IteratorStatement {
|
|||
|
||||
loop {
|
||||
match stmt.step().ok()? {
|
||||
limbo_core::StepResult::Row => {
|
||||
turso_core::StepResult::Row => {
|
||||
let row = stmt.row().unwrap();
|
||||
|
||||
match self.presentation_mode {
|
||||
|
@ -517,47 +517,47 @@ impl Generator for IteratorStatement {
|
|||
}
|
||||
}
|
||||
}
|
||||
limbo_core::StepResult::Done => return None,
|
||||
limbo_core::StepResult::IO => {
|
||||
turso_core::StepResult::Done => return None,
|
||||
turso_core::StepResult::IO => {
|
||||
self.database.io.run_once().ok()?;
|
||||
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 {
|
||||
limbo_core::Value::Null => Ok(env.get_null()?.into_unknown()),
|
||||
limbo_core::Value::Integer(i) => Ok(env.create_int64(*i)?.into_unknown()),
|
||||
limbo_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()),
|
||||
limbo_core::Value::Blob(b) => Ok(env.create_buffer_copy(b.as_slice())?.into_unknown()),
|
||||
turso_core::Value::Null => Ok(env.get_null()?.into_unknown()),
|
||||
turso_core::Value::Integer(i) => Ok(env.create_int64(*i)?.into_unknown()),
|
||||
turso_core::Value::Float(f) => Ok(env.create_double(*f)?.into_unknown()),
|
||||
turso_core::Value::Text(s) => Ok(env.create_string(s.as_str())?.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()? {
|
||||
napi::ValueType::Undefined | napi::ValueType::Null | napi::ValueType::Unknown => {
|
||||
Ok(limbo_core::Value::Null)
|
||||
Ok(turso_core::Value::Null)
|
||||
}
|
||||
napi::ValueType::Boolean => {
|
||||
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 => {
|
||||
let num = value.coerce_to_number()?.get_double()?;
|
||||
if num.fract() == 0.0 {
|
||||
Ok(limbo_core::Value::Integer(num as i64))
|
||||
Ok(turso_core::Value::Integer(num as i64))
|
||||
} else {
|
||||
Ok(limbo_core::Value::Float(num))
|
||||
Ok(turso_core::Value::Float(num))
|
||||
}
|
||||
}
|
||||
napi::ValueType::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::Object
|
||||
|
@ -570,28 +570,28 @@ fn from_js_value(value: JsUnknown) -> napi::Result<limbo_core::Value> {
|
|||
}
|
||||
|
||||
struct DatabaseFile {
|
||||
file: Arc<dyn limbo_core::File>,
|
||||
file: Arc<dyn turso_core::File>,
|
||||
}
|
||||
|
||||
unsafe impl Send for DatabaseFile {}
|
||||
unsafe impl Sync for 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 }
|
||||
}
|
||||
}
|
||||
|
||||
impl limbo_core::DatabaseStorage for DatabaseFile {
|
||||
fn read_page(&self, page_idx: usize, c: limbo_core::Completion) -> limbo_core::Result<()> {
|
||||
impl turso_core::DatabaseStorage for DatabaseFile {
|
||||
fn read_page(&self, page_idx: usize, c: turso_core::Completion) -> turso_core::Result<()> {
|
||||
let r = match c.completion_type {
|
||||
limbo_core::CompletionType::Read(ref r) => r,
|
||||
turso_core::CompletionType::Read(ref r) => r,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
let size = r.buf().len();
|
||||
assert!(page_idx > 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;
|
||||
self.file.pread(pos, c)?;
|
||||
|
@ -601,21 +601,21 @@ impl limbo_core::DatabaseStorage for DatabaseFile {
|
|||
fn write_page(
|
||||
&self,
|
||||
page_idx: usize,
|
||||
buffer: Arc<std::cell::RefCell<limbo_core::Buffer>>,
|
||||
c: limbo_core::Completion,
|
||||
) -> limbo_core::Result<()> {
|
||||
buffer: Arc<std::cell::RefCell<turso_core::Buffer>>,
|
||||
c: turso_core::Completion,
|
||||
) -> turso_core::Result<()> {
|
||||
let size = buffer.borrow().len();
|
||||
let pos = (page_idx - 1) * size;
|
||||
self.file.pwrite(pos, buffer, c)?;
|
||||
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)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn size(&self) -> limbo_core::Result<u64> {
|
||||
fn size(&self) -> turso_core::Result<u64> {
|
||||
self.file.size()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ extension-module = ["pyo3/extension-module"]
|
|||
|
||||
[dependencies]
|
||||
anyhow = "1.0"
|
||||
limbo_core = { path = "../../core", features = ["io_uring"] }
|
||||
turso_core = { path = "../../core", features = ["io_uring"] }
|
||||
pyo3 = { version = "0.24.1", features = ["anyhow"] }
|
||||
|
||||
[build-dependencies]
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use anyhow::Result;
|
||||
use errors::*;
|
||||
use limbo_core::Value;
|
||||
use pyo3::prelude::*;
|
||||
use pyo3::types::{PyBytes, PyList, PyTuple};
|
||||
use std::cell::RefCell;
|
||||
use std::num::NonZeroUsize;
|
||||
use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
use turso_core::Value;
|
||||
|
||||
mod errors;
|
||||
|
||||
|
@ -61,7 +61,7 @@ pub struct Cursor {
|
|||
#[pyo3(get)]
|
||||
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)]
|
||||
|
@ -95,7 +95,7 @@ impl Cursor {
|
|||
// For DDL and DML statements,
|
||||
// we need to execute the statement immediately
|
||||
if stmt_is_ddl || stmt_is_dml {
|
||||
while let limbo_core::StepResult::IO = stmt
|
||||
while let turso_core::StepResult::IO = stmt
|
||||
.borrow_mut()
|
||||
.step()
|
||||
.map_err(|e| PyErr::new::<OperationalError, _>(format!("Step error: {:?}", e)))?
|
||||
|
@ -125,23 +125,23 @@ impl Cursor {
|
|||
match stmt.step().map_err(|e| {
|
||||
PyErr::new::<OperationalError, _>(format!("Step error: {:?}", e))
|
||||
})? {
|
||||
limbo_core::StepResult::Row => {
|
||||
turso_core::StepResult::Row => {
|
||||
let row = stmt.row().unwrap();
|
||||
let py_row = row_to_py(py, row)?;
|
||||
return Ok(Some(py_row));
|
||||
}
|
||||
limbo_core::StepResult::IO => {
|
||||
turso_core::StepResult::IO => {
|
||||
self.conn.io.run_once().map_err(|e| {
|
||||
PyErr::new::<OperationalError, _>(format!("IO error: {:?}", e))
|
||||
})?;
|
||||
}
|
||||
limbo_core::StepResult::Interrupt => {
|
||||
turso_core::StepResult::Interrupt => {
|
||||
return Ok(None);
|
||||
}
|
||||
limbo_core::StepResult::Done => {
|
||||
turso_core::StepResult::Done => {
|
||||
return Ok(None);
|
||||
}
|
||||
limbo_core::StepResult::Busy => {
|
||||
turso_core::StepResult::Busy => {
|
||||
return Err(
|
||||
PyErr::new::<OperationalError, _>("Busy error".to_string()).into()
|
||||
);
|
||||
|
@ -161,23 +161,23 @@ impl Cursor {
|
|||
match stmt.step().map_err(|e| {
|
||||
PyErr::new::<OperationalError, _>(format!("Step error: {:?}", e))
|
||||
})? {
|
||||
limbo_core::StepResult::Row => {
|
||||
turso_core::StepResult::Row => {
|
||||
let row = stmt.row().unwrap();
|
||||
let py_row = row_to_py(py, row)?;
|
||||
results.push(py_row);
|
||||
}
|
||||
limbo_core::StepResult::IO => {
|
||||
turso_core::StepResult::IO => {
|
||||
self.conn.io.run_once().map_err(|e| {
|
||||
PyErr::new::<OperationalError, _>(format!("IO error: {:?}", e))
|
||||
})?;
|
||||
}
|
||||
limbo_core::StepResult::Interrupt => {
|
||||
turso_core::StepResult::Interrupt => {
|
||||
return Ok(results);
|
||||
}
|
||||
limbo_core::StepResult::Done => {
|
||||
turso_core::StepResult::Done => {
|
||||
return Ok(results);
|
||||
}
|
||||
limbo_core::StepResult::Busy => {
|
||||
turso_core::StepResult::Busy => {
|
||||
return Err(
|
||||
PyErr::new::<OperationalError, _>("Busy error".to_string()).into()
|
||||
);
|
||||
|
@ -225,8 +225,8 @@ fn stmt_is_ddl(sql: &str) -> bool {
|
|||
#[pyclass(unsendable)]
|
||||
#[derive(Clone)]
|
||||
pub struct Connection {
|
||||
conn: Arc<limbo_core::Connection>,
|
||||
io: Arc<dyn limbo_core::IO>,
|
||||
conn: Arc<turso_core::Connection>,
|
||||
io: Arc<dyn turso_core::IO>,
|
||||
}
|
||||
|
||||
#[pymethods]
|
||||
|
@ -302,39 +302,39 @@ impl Drop for Connection {
|
|||
pub fn connect(path: &str) -> Result<Connection> {
|
||||
#[inline(always)]
|
||||
fn open_or(
|
||||
io: Arc<dyn limbo_core::IO>,
|
||||
io: Arc<dyn turso_core::IO>,
|
||||
path: &str,
|
||||
) -> std::result::Result<Arc<limbo_core::Database>, PyErr> {
|
||||
limbo_core::Database::open_file(io, path, false, false).map_err(|e| {
|
||||
) -> std::result::Result<Arc<turso_core::Database>, PyErr> {
|
||||
turso_core::Database::open_file(io, path, false, false).map_err(|e| {
|
||||
PyErr::new::<DatabaseError, _>(format!("Failed to open database: {:?}", e))
|
||||
})
|
||||
}
|
||||
|
||||
match path {
|
||||
":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 conn: Arc<limbo_core::Connection> = db.connect().unwrap();
|
||||
let conn: Arc<turso_core::Connection> = db.connect().unwrap();
|
||||
Ok(Connection { conn, io })
|
||||
}
|
||||
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 conn: Arc<limbo_core::Connection> = db.connect().unwrap();
|
||||
let conn: Arc<turso_core::Connection> = db.connect().unwrap();
|
||||
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();
|
||||
for value in row.get_values() {
|
||||
match value {
|
||||
limbo_core::Value::Null => py_values.push(py.None()),
|
||||
limbo_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()),
|
||||
limbo_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::Null => py_values.push(py.None()),
|
||||
turso_core::Value::Integer(i) => py_values.push(i.into_pyobject(py)?.into()),
|
||||
turso_core::Value::Float(f) => py_values.push(f.into_pyobject(py)?.into()),
|
||||
turso_core::Value::Text(s) => py_values.push(s.as_str().into_pyobject(py)?.into()),
|
||||
turso_core::Value::Blob(b) => py_values.push(PyBytes::new(py, b.as_slice()).into()),
|
||||
}
|
||||
}
|
||||
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
|
||||
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() {
|
||||
Ok(Value::Null)
|
||||
} else if let Ok(integer) = obj.extract::<i64>() {
|
||||
|
|
|
@ -10,7 +10,7 @@ repository.workspace = true
|
|||
description = "Limbo Rust API"
|
||||
|
||||
[dependencies]
|
||||
limbo_core = { workspace = true, features = ["io_uring"] }
|
||||
turso_core = { workspace = true, features = ["io_uring"] }
|
||||
thiserror = "2.0.9"
|
||||
|
||||
[dev-dependencies]
|
||||
|
|
|
@ -54,8 +54,8 @@ pub enum Error {
|
|||
SqlExecutionFailure(String),
|
||||
}
|
||||
|
||||
impl From<limbo_core::LimboError> for Error {
|
||||
fn from(err: limbo_core::LimboError) -> Self {
|
||||
impl From<turso_core::LimboError> for Error {
|
||||
fn from(err: turso_core::LimboError) -> Self {
|
||||
Error::SqlExecutionFailure(err.to_string())
|
||||
}
|
||||
}
|
||||
|
@ -82,13 +82,13 @@ impl Builder {
|
|||
pub async fn build(self) -> Result<Database> {
|
||||
match self.path.as_str() {
|
||||
":memory:" => {
|
||||
let io: Arc<dyn limbo_core::IO> = Arc::new(limbo_core::MemoryIO::new());
|
||||
let db = limbo_core::Database::open_file(io, self.path.as_str(), false, false)?;
|
||||
let io: Arc<dyn turso_core::IO> = Arc::new(turso_core::MemoryIO::new());
|
||||
let db = turso_core::Database::open_file(io, self.path.as_str(), false, false)?;
|
||||
Ok(Database { inner: db })
|
||||
}
|
||||
path => {
|
||||
let io: Arc<dyn limbo_core::IO> = Arc::new(limbo_core::PlatformIO::new()?);
|
||||
let db = limbo_core::Database::open_file(io, path, false, false)?;
|
||||
let io: Arc<dyn turso_core::IO> = Arc::new(turso_core::PlatformIO::new()?);
|
||||
let db = turso_core::Database::open_file(io, path, false, false)?;
|
||||
Ok(Database { inner: db })
|
||||
}
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ impl Builder {
|
|||
/// The `Database` object points to a database and allows you to connect to it
|
||||
#[derive(Clone)]
|
||||
pub struct Database {
|
||||
inner: Arc<limbo_core::Database>,
|
||||
inner: Arc<turso_core::Database>,
|
||||
}
|
||||
|
||||
unsafe impl Send for Database {}
|
||||
|
@ -126,7 +126,7 @@ impl Database {
|
|||
|
||||
/// A database connection.
|
||||
pub struct Connection {
|
||||
inner: Arc<Mutex<Arc<limbo_core::Connection>>>,
|
||||
inner: Arc<Mutex<Arc<turso_core::Connection>>>,
|
||||
}
|
||||
|
||||
impl Clone for Connection {
|
||||
|
@ -172,7 +172,7 @@ impl Connection {
|
|||
/// Query a pragma.
|
||||
pub fn pragma_query<F>(&self, pragma_name: &str, mut f: F) -> Result<()>
|
||||
where
|
||||
F: FnMut(&Row) -> limbo_core::Result<()>,
|
||||
F: FnMut(&Row) -> turso_core::Result<()>,
|
||||
{
|
||||
let conn = self
|
||||
.inner
|
||||
|
@ -203,7 +203,7 @@ impl Debug for Connection {
|
|||
|
||||
/// A prepared statement.
|
||||
pub struct Statement {
|
||||
inner: Arc<Mutex<limbo_core::Statement>>,
|
||||
inner: Arc<Mutex<turso_core::Statement>>,
|
||||
}
|
||||
|
||||
impl Clone for Statement {
|
||||
|
@ -270,21 +270,21 @@ impl Statement {
|
|||
loop {
|
||||
let mut stmt = self.inner.lock().unwrap();
|
||||
match stmt.step() {
|
||||
Ok(limbo_core::StepResult::Row) => {
|
||||
Ok(turso_core::StepResult::Row) => {
|
||||
// unexpected row during execution, error out.
|
||||
return Ok(2);
|
||||
}
|
||||
Ok(limbo_core::StepResult::Done) => {
|
||||
Ok(turso_core::StepResult::Done) => {
|
||||
return Ok(0);
|
||||
}
|
||||
Ok(limbo_core::StepResult::IO) => {
|
||||
Ok(turso_core::StepResult::IO) => {
|
||||
let _ = stmt.run_once();
|
||||
//return Ok(1);
|
||||
}
|
||||
Ok(limbo_core::StepResult::Busy) => {
|
||||
Ok(turso_core::StepResult::Busy) => {
|
||||
return Ok(4);
|
||||
}
|
||||
Ok(limbo_core::StepResult::Interrupt) => {
|
||||
Ok(turso_core::StepResult::Interrupt) => {
|
||||
return Ok(3);
|
||||
}
|
||||
Err(err) => {
|
||||
|
@ -347,7 +347,7 @@ pub struct Transaction {}
|
|||
|
||||
/// Results of a prepared statement query.
|
||||
pub struct Rows {
|
||||
inner: Arc<Mutex<limbo_core::Statement>>,
|
||||
inner: Arc<Mutex<turso_core::Statement>>,
|
||||
}
|
||||
|
||||
impl Clone for Rows {
|
||||
|
@ -370,21 +370,21 @@ impl Rows {
|
|||
.lock()
|
||||
.map_err(|e| Error::MutexError(e.to_string()))?;
|
||||
match stmt.step() {
|
||||
Ok(limbo_core::StepResult::Row) => {
|
||||
Ok(turso_core::StepResult::Row) => {
|
||||
let row = stmt.row().unwrap();
|
||||
return Ok(Some(Row {
|
||||
values: row.get_values().map(|v| v.to_owned()).collect(),
|
||||
}));
|
||||
}
|
||||
Ok(limbo_core::StepResult::Done) => return Ok(None),
|
||||
Ok(limbo_core::StepResult::IO) => {
|
||||
Ok(turso_core::StepResult::Done) => return Ok(None),
|
||||
Ok(turso_core::StepResult::IO) => {
|
||||
if let Err(e) = stmt.run_once() {
|
||||
return Err(e.into());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
Ok(limbo_core::StepResult::Busy) => return Ok(None),
|
||||
Ok(limbo_core::StepResult::Interrupt) => return Ok(None),
|
||||
Ok(turso_core::StepResult::Busy) => return Ok(None),
|
||||
Ok(turso_core::StepResult::Interrupt) => return Ok(None),
|
||||
_ => return Ok(None),
|
||||
}
|
||||
}
|
||||
|
@ -394,7 +394,7 @@ impl Rows {
|
|||
/// Query result row.
|
||||
#[derive(Debug)]
|
||||
pub struct Row {
|
||||
values: Vec<limbo_core::Value>,
|
||||
values: Vec<turso_core::Value>,
|
||||
}
|
||||
|
||||
unsafe impl Send for Row {}
|
||||
|
@ -404,11 +404,11 @@ impl Row {
|
|||
pub fn get_value(&self, index: usize) -> Result<Value> {
|
||||
let value = &self.values[index];
|
||||
match value {
|
||||
limbo_core::Value::Integer(i) => Ok(Value::Integer(*i)),
|
||||
limbo_core::Value::Null => Ok(Value::Null),
|
||||
limbo_core::Value::Float(f) => Ok(Value::Real(*f)),
|
||||
limbo_core::Value::Text(text) => Ok(Value::Text(text.to_string())),
|
||||
limbo_core::Value::Blob(items) => Ok(Value::Blob(items.to_vec())),
|
||||
turso_core::Value::Integer(i) => Ok(Value::Integer(*i)),
|
||||
turso_core::Value::Null => Ok(Value::Null),
|
||||
turso_core::Value::Float(f) => Ok(Value::Real(*f)),
|
||||
turso_core::Value::Text(text) => Ok(Value::Text(text.to_string())),
|
||||
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 {
|
||||
fn from_iter<T: IntoIterator<Item = &'a limbo_core::Value>>(iter: T) -> Self {
|
||||
impl<'a> FromIterator<&'a turso_core::Value> for Row {
|
||||
fn from_iter<T: IntoIterator<Item = &'a turso_core::Value>>(iter: T) -> Self {
|
||||
let values = iter
|
||||
.into_iter()
|
||||
.map(|v| match v {
|
||||
limbo_core::Value::Integer(i) => limbo_core::Value::Integer(*i),
|
||||
limbo_core::Value::Null => limbo_core::Value::Null,
|
||||
limbo_core::Value::Float(f) => limbo_core::Value::Float(*f),
|
||||
limbo_core::Value::Text(s) => limbo_core::Value::Text(s.clone()),
|
||||
limbo_core::Value::Blob(b) => limbo_core::Value::Blob(b.clone()),
|
||||
turso_core::Value::Integer(i) => turso_core::Value::Integer(*i),
|
||||
turso_core::Value::Null => turso_core::Value::Null,
|
||||
turso_core::Value::Float(f) => turso_core::Value::Float(*f),
|
||||
turso_core::Value::Text(s) => turso_core::Value::Text(s.clone()),
|
||||
turso_core::Value::Blob(b) => turso_core::Value::Blob(b.clone()),
|
||||
})
|
||||
.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 {
|
||||
match val {
|
||||
Value::Null => limbo_core::Value::Null,
|
||||
Value::Integer(n) => limbo_core::Value::Integer(n),
|
||||
Value::Real(n) => limbo_core::Value::Float(n),
|
||||
Value::Text(t) => limbo_core::Value::from_text(&t),
|
||||
Value::Blob(items) => limbo_core::Value::from_blob(items),
|
||||
Value::Null => turso_core::Value::Null,
|
||||
Value::Integer(n) => turso_core::Value::Integer(n),
|
||||
Value::Real(n) => turso_core::Value::Float(n),
|
||||
Value::Text(t) => turso_core::Value::from_text(&t),
|
||||
Value::Blob(items) => turso_core::Value::from_blob(items),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ path = "lib.rs"
|
|||
[dependencies]
|
||||
console_error_panic_hook = "0.1.7"
|
||||
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-futures = "0.4"
|
||||
web-sys = "0.3"
|
||||
|
|
|
@ -2,16 +2,16 @@
|
|||
compile_error!("Features 'web' and 'nodejs' cannot be enabled at the same time");
|
||||
|
||||
use js_sys::{Array, Object};
|
||||
use limbo_core::{Clock, Instant, OpenFlags, Result};
|
||||
use std::cell::RefCell;
|
||||
use std::sync::Arc;
|
||||
use turso_core::{Clock, Instant, OpenFlags, Result};
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[wasm_bindgen]
|
||||
pub struct Database {
|
||||
db: Arc<limbo_core::Database>,
|
||||
conn: Arc<limbo_core::Connection>,
|
||||
db: Arc<turso_core::Database>,
|
||||
conn: Arc<turso_core::Connection>,
|
||||
}
|
||||
|
||||
#[allow(clippy::arc_with_non_send_sync)]
|
||||
|
@ -19,10 +19,10 @@ pub struct Database {
|
|||
impl Database {
|
||||
#[wasm_bindgen(constructor)]
|
||||
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 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();
|
||||
Database { db, conn }
|
||||
}
|
||||
|
@ -41,12 +41,12 @@ impl Database {
|
|||
|
||||
#[wasm_bindgen]
|
||||
pub struct RowIterator {
|
||||
inner: RefCell<limbo_core::Statement>,
|
||||
inner: RefCell<turso_core::Statement>,
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
impl RowIterator {
|
||||
fn new(inner: RefCell<limbo_core::Statement>) -> Self {
|
||||
fn new(inner: RefCell<turso_core::Statement>) -> Self {
|
||||
Self { inner }
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ impl RowIterator {
|
|||
pub fn next(&mut self) -> JsValue {
|
||||
let mut stmt = self.inner.borrow_mut();
|
||||
match stmt.step() {
|
||||
Ok(limbo_core::StepResult::Row) => {
|
||||
Ok(turso_core::StepResult::Row) => {
|
||||
let row = stmt.row().unwrap();
|
||||
let row_array = Array::new();
|
||||
for value in row.get_values() {
|
||||
|
@ -64,11 +64,11 @@ impl RowIterator {
|
|||
}
|
||||
JsValue::from(row_array)
|
||||
}
|
||||
Ok(limbo_core::StepResult::IO) => JsValue::UNDEFINED,
|
||||
Ok(limbo_core::StepResult::Done) | Ok(limbo_core::StepResult::Interrupt) => {
|
||||
Ok(turso_core::StepResult::IO) => JsValue::UNDEFINED,
|
||||
Ok(turso_core::StepResult::Done) | Ok(turso_core::StepResult::Interrupt) => {
|
||||
JsValue::UNDEFINED
|
||||
}
|
||||
Ok(limbo_core::StepResult::Busy) => JsValue::UNDEFINED,
|
||||
Ok(turso_core::StepResult::Busy) => JsValue::UNDEFINED,
|
||||
Err(e) => panic!("Error: {:?}", e),
|
||||
}
|
||||
}
|
||||
|
@ -76,13 +76,13 @@ impl RowIterator {
|
|||
|
||||
#[wasm_bindgen]
|
||||
pub struct Statement {
|
||||
inner: RefCell<limbo_core::Statement>,
|
||||
inner: RefCell<turso_core::Statement>,
|
||||
raw: bool,
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
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 }
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ impl Statement {
|
|||
pub fn get(&self) -> JsValue {
|
||||
let mut stmt = self.inner.borrow_mut();
|
||||
match stmt.step() {
|
||||
Ok(limbo_core::StepResult::Row) => {
|
||||
Ok(turso_core::StepResult::Row) => {
|
||||
let row = stmt.row().unwrap();
|
||||
let row_array = js_sys::Array::new();
|
||||
for value in row.get_values() {
|
||||
|
@ -104,10 +104,10 @@ impl Statement {
|
|||
}
|
||||
JsValue::from(row_array)
|
||||
}
|
||||
Ok(limbo_core::StepResult::IO)
|
||||
| Ok(limbo_core::StepResult::Done)
|
||||
| Ok(limbo_core::StepResult::Interrupt)
|
||||
| Ok(limbo_core::StepResult::Busy) => JsValue::UNDEFINED,
|
||||
Ok(turso_core::StepResult::IO)
|
||||
| Ok(turso_core::StepResult::Done)
|
||||
| Ok(turso_core::StepResult::Interrupt)
|
||||
| Ok(turso_core::StepResult::Busy) => JsValue::UNDEFINED,
|
||||
Err(e) => panic!("Error: {:?}", e),
|
||||
}
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ impl Statement {
|
|||
loop {
|
||||
let mut stmt = self.inner.borrow_mut();
|
||||
match stmt.step() {
|
||||
Ok(limbo_core::StepResult::Row) => {
|
||||
Ok(turso_core::StepResult::Row) => {
|
||||
let row = stmt.row().unwrap();
|
||||
let row_array = js_sys::Array::new();
|
||||
for value in row.get_values() {
|
||||
|
@ -126,10 +126,10 @@ impl Statement {
|
|||
}
|
||||
array.push(&row_array);
|
||||
}
|
||||
Ok(limbo_core::StepResult::IO) => {}
|
||||
Ok(limbo_core::StepResult::Interrupt) => break,
|
||||
Ok(limbo_core::StepResult::Done) => break,
|
||||
Ok(limbo_core::StepResult::Busy) => break,
|
||||
Ok(turso_core::StepResult::IO) => {}
|
||||
Ok(turso_core::StepResult::Interrupt) => break,
|
||||
Ok(turso_core::StepResult::Done) => break,
|
||||
Ok(turso_core::StepResult::Busy) => break,
|
||||
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 {
|
||||
limbo_core::Value::Null => JsValue::null(),
|
||||
limbo_core::Value::Integer(i) => {
|
||||
turso_core::Value::Null => JsValue::null(),
|
||||
turso_core::Value::Integer(i) => {
|
||||
let i = *i;
|
||||
if i >= i32::MIN as i64 && i <= i32::MAX as i64 {
|
||||
JsValue::from(i as i32)
|
||||
|
@ -179,9 +179,9 @@ fn to_js_value(value: &limbo_core::Value) -> JsValue {
|
|||
JsValue::from(i)
|
||||
}
|
||||
}
|
||||
limbo_core::Value::Float(f) => JsValue::from(*f),
|
||||
limbo_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::Float(f) => JsValue::from(*f),
|
||||
turso_core::Value::Text(t) => JsValue::from_str(t.as_str()),
|
||||
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<()> {
|
||||
// TODO
|
||||
Ok(())
|
||||
|
@ -211,9 +211,9 @@ impl limbo_core::File for File {
|
|||
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 {
|
||||
limbo_core::CompletionType::Read(ref r) => r,
|
||||
turso_core::CompletionType::Read(ref r) => r,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
{
|
||||
|
@ -230,11 +230,11 @@ impl limbo_core::File for File {
|
|||
fn pwrite(
|
||||
&self,
|
||||
pos: usize,
|
||||
buffer: Arc<std::cell::RefCell<limbo_core::Buffer>>,
|
||||
c: limbo_core::Completion,
|
||||
) -> Result<Arc<limbo_core::Completion>> {
|
||||
buffer: Arc<std::cell::RefCell<turso_core::Buffer>>,
|
||||
c: turso_core::Completion,
|
||||
) -> Result<Arc<turso_core::Completion>> {
|
||||
let w = match c.completion_type {
|
||||
limbo_core::CompletionType::Write(ref w) => w,
|
||||
turso_core::CompletionType::Write(ref w) => w,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
let buf = buffer.borrow();
|
||||
|
@ -245,7 +245,7 @@ impl limbo_core::File for File {
|
|||
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);
|
||||
c.complete(0);
|
||||
#[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(
|
||||
&self,
|
||||
path: &str,
|
||||
_flags: OpenFlags,
|
||||
_direct: bool,
|
||||
) -> Result<Arc<dyn limbo_core::File>> {
|
||||
) -> Result<Arc<dyn turso_core::File>> {
|
||||
let fd = self.vfs.open(path, "a+");
|
||||
Ok(Arc::new(File {
|
||||
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() {
|
||||
self.run_once()?;
|
||||
}
|
||||
|
@ -306,8 +306,8 @@ impl limbo_core::IO for PlatformIO {
|
|||
i64::from_ne_bytes(buf)
|
||||
}
|
||||
|
||||
fn get_memory_io(&self) -> Arc<limbo_core::MemoryIO> {
|
||||
Arc::new(limbo_core::MemoryIO::new())
|
||||
fn get_memory_io(&self) -> Arc<turso_core::MemoryIO> {
|
||||
Arc::new(turso_core::MemoryIO::new())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -326,28 +326,28 @@ extern "C" {
|
|||
}
|
||||
|
||||
pub struct DatabaseFile {
|
||||
file: Arc<dyn limbo_core::File>,
|
||||
file: Arc<dyn turso_core::File>,
|
||||
}
|
||||
|
||||
unsafe impl Send for DatabaseFile {}
|
||||
unsafe impl Sync for 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 }
|
||||
}
|
||||
}
|
||||
|
||||
impl limbo_core::DatabaseStorage for DatabaseFile {
|
||||
fn read_page(&self, page_idx: usize, c: limbo_core::Completion) -> Result<()> {
|
||||
impl turso_core::DatabaseStorage for DatabaseFile {
|
||||
fn read_page(&self, page_idx: usize, c: turso_core::Completion) -> Result<()> {
|
||||
let r = match c.completion_type {
|
||||
limbo_core::CompletionType::Read(ref r) => r,
|
||||
turso_core::CompletionType::Read(ref r) => r,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
let size = r.buf().len();
|
||||
assert!(page_idx > 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;
|
||||
self.file.pread(pos, c)?;
|
||||
|
@ -357,8 +357,8 @@ impl limbo_core::DatabaseStorage for DatabaseFile {
|
|||
fn write_page(
|
||||
&self,
|
||||
page_idx: usize,
|
||||
buffer: Arc<std::cell::RefCell<limbo_core::Buffer>>,
|
||||
c: limbo_core::Completion,
|
||||
buffer: Arc<std::cell::RefCell<turso_core::Buffer>>,
|
||||
c: turso_core::Completion,
|
||||
) -> Result<()> {
|
||||
let size = buffer.borrow().len();
|
||||
let pos = (page_idx - 1) * size;
|
||||
|
@ -366,7 +366,7 @@ impl limbo_core::DatabaseStorage for DatabaseFile {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn sync(&self, c: limbo_core::Completion) -> Result<()> {
|
||||
fn sync(&self, c: turso_core::Completion) -> Result<()> {
|
||||
let _ = self.file.sync(c)?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ ctrlc = "3.4.4"
|
|||
dirs = "5.0.1"
|
||||
env_logger = "0.10.1"
|
||||
libc = "0.2.172"
|
||||
limbo_core = { path = "../core", default-features = true, features = [
|
||||
turso_core = { path = "../core", default-features = true, features = [
|
||||
"completion",
|
||||
] }
|
||||
miette = { version = "7.4.0", features = ["fancy"] }
|
||||
|
@ -49,7 +49,7 @@ toml_edit = {version = "0.22.24", features = ["serde"]}
|
|||
|
||||
[features]
|
||||
default = ["io_uring"]
|
||||
io_uring = ["limbo_core/io_uring"]
|
||||
io_uring = ["turso_core/io_uring"]
|
||||
|
||||
[build-dependencies]
|
||||
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,
|
||||
};
|
||||
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_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, EnvFilter};
|
||||
use turso_core::{Database, LimboError, Statement, StepResult, Value};
|
||||
|
||||
use clap::Parser;
|
||||
use rustyline::{error::ReadlineError, history::DefaultHistory, Editor};
|
||||
|
@ -67,9 +67,9 @@ const PROMPT: &str = "turso> ";
|
|||
|
||||
pub struct Limbo {
|
||||
pub prompt: String,
|
||||
io: Arc<dyn limbo_core::IO>,
|
||||
io: Arc<dyn turso_core::IO>,
|
||||
writer: Box<dyn Write>,
|
||||
conn: Arc<limbo_core::Connection>,
|
||||
conn: Arc<turso_core::Connection>,
|
||||
pub interrupt_count: Arc<AtomicUsize>,
|
||||
input_buff: String,
|
||||
opts: Settings,
|
||||
|
@ -222,7 +222,7 @@ impl Limbo {
|
|||
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
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
|
||||
.load_extension(ext_path)
|
||||
.map_err(|e| e.to_string())
|
||||
|
@ -235,7 +235,7 @@ impl Limbo {
|
|||
query_internal!(
|
||||
self,
|
||||
query,
|
||||
|row: &limbo_core::Row| -> Result<(), LimboError> {
|
||||
|row: &turso_core::Row| -> Result<(), LimboError> {
|
||||
let name: &str = row.get::<&str>(1)?;
|
||||
cols.push(name.to_string());
|
||||
let value_type: &str = row.get::<&str>(2)?;
|
||||
|
@ -251,7 +251,7 @@ impl Limbo {
|
|||
query_internal!(
|
||||
self,
|
||||
select,
|
||||
|row: &limbo_core::Row| -> Result<(), LimboError> {
|
||||
|row: &turso_core::Row| -> Result<(), LimboError> {
|
||||
let values = row
|
||||
.get_values()
|
||||
.zip(value_types.iter())
|
||||
|
@ -302,7 +302,7 @@ impl Limbo {
|
|||
let res = query_internal!(
|
||||
self,
|
||||
query,
|
||||
|row: &limbo_core::Row| -> Result<(), LimboError> {
|
||||
|row: &turso_core::Row| -> Result<(), LimboError> {
|
||||
let sql: &str = row.get::<&str>(2)?;
|
||||
let name: &str = row.get::<&str>(0)?;
|
||||
self.write_fmt(format_args!("{};", sql))?;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use clap::Args;
|
||||
use clap_complete::{ArgValueCompleter, PathCompleter};
|
||||
use limbo_core::Connection;
|
||||
use std::{fs::File, io::Write, path::PathBuf, sync::Arc};
|
||||
use turso_core::Connection;
|
||||
|
||||
#[derive(Debug, Clone, Args)]
|
||||
pub struct ImportArgs {
|
||||
|
@ -21,14 +21,14 @@ pub struct ImportArgs {
|
|||
|
||||
pub struct ImportFile<'a> {
|
||||
conn: Arc<Connection>,
|
||||
io: Arc<dyn limbo_core::IO>,
|
||||
io: Arc<dyn turso_core::IO>,
|
||||
writer: &'a mut dyn Write,
|
||||
}
|
||||
|
||||
impl<'a> ImportFile<'a> {
|
||||
pub fn new(
|
||||
conn: Arc<Connection>,
|
||||
io: Arc<dyn limbo_core::IO>,
|
||||
io: Arc<dyn turso_core::IO>,
|
||||
writer: &'a mut dyn Write,
|
||||
) -> Self {
|
||||
Self { conn, io, writer }
|
||||
|
@ -78,17 +78,17 @@ impl<'a> ImportFile<'a> {
|
|||
if let Some(mut rows) = rows {
|
||||
while let Ok(x) = rows.step() {
|
||||
match x {
|
||||
limbo_core::StepResult::IO => {
|
||||
turso_core::StepResult::IO => {
|
||||
self.io.run_once().unwrap();
|
||||
}
|
||||
limbo_core::StepResult::Done => break,
|
||||
limbo_core::StepResult::Interrupt => break,
|
||||
limbo_core::StepResult::Busy => {
|
||||
turso_core::StepResult::Done => break,
|
||||
turso_core::StepResult::Interrupt => break,
|
||||
turso_core::StepResult::Busy => {
|
||||
let _ =
|
||||
self.writer.write_all("database is busy\n".as_bytes());
|
||||
break;
|
||||
}
|
||||
limbo_core::StepResult::Row => todo!(),
|
||||
turso_core::StepResult::Row => todo!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
use clap::Parser;
|
||||
use limbo_core::{Connection, StepResult};
|
||||
use nu_ansi_term::{Color, Style};
|
||||
use rustyline::completion::{extract_word, Completer, Pair};
|
||||
use rustyline::highlight::Highlighter;
|
||||
|
@ -15,6 +14,7 @@ use syntect::easy::HighlightLines;
|
|||
use syntect::highlighting::ThemeSet;
|
||||
use syntect::parsing::{Scope, SyntaxSet};
|
||||
use syntect::util::{as_24_bit_terminal_escaped, LinesWithEndings};
|
||||
use turso_core::{Connection, StepResult};
|
||||
|
||||
use crate::commands::CommandParser;
|
||||
use crate::config::{HighlightConfig, CONFIG_DIR};
|
||||
|
@ -42,7 +42,7 @@ pub struct LimboHelper {
|
|||
impl LimboHelper {
|
||||
pub fn new(
|
||||
conn: Arc<Connection>,
|
||||
io: Arc<dyn limbo_core::IO>,
|
||||
io: Arc<dyn turso_core::IO>,
|
||||
syntax_config: Option<HighlightConfig>,
|
||||
) -> Self {
|
||||
// Load only predefined syntax
|
||||
|
@ -141,7 +141,7 @@ impl Highlighter for LimboHelper {
|
|||
|
||||
pub struct SqlCompleter<C: Parser + Send + Sync + 'static> {
|
||||
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
|
||||
// This problem would be solved with Reedline as it uses &mut self for completions
|
||||
cmd: RefCell<clap::Command>,
|
||||
|
@ -149,7 +149,7 @@ pub struct SqlCompleter<C: Parser + Send + Sync + 'static> {
|
|||
}
|
||||
|
||||
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 {
|
||||
conn,
|
||||
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 {
|
||||
DbLocation::Memory => Arc::new(limbo_core::MemoryIO::new()),
|
||||
DbLocation::Memory => Arc::new(turso_core::MemoryIO::new()),
|
||||
DbLocation::Path => {
|
||||
match io_choice {
|
||||
"memory" => Arc::new(limbo_core::MemoryIO::new()),
|
||||
"memory" => Arc::new(turso_core::MemoryIO::new()),
|
||||
"syscall" => {
|
||||
// We are building for Linux/macOS and syscall backend has been selected
|
||||
#[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
|
||||
#[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
|
||||
#[cfg(all(target_os = "linux", feature = "io_uring"))]
|
||||
"io_uring" => Arc::new(limbo_core::UringIO::new()?),
|
||||
_ => Arc::new(limbo_core::PlatformIO::new()?),
|
||||
"io_uring" => Arc::new(turso_core::UringIO::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]
|
||||
name = "limbo_core"
|
||||
name = "turso_core"
|
||||
version.workspace = true
|
||||
authors.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
repository.workspace = true
|
||||
description = "The Limbo database library"
|
||||
description = "The Turso database library"
|
||||
|
||||
[lib]
|
||||
name = "limbo_core"
|
||||
name = "turso_core"
|
||||
path = "lib.rs"
|
||||
|
||||
[features]
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion};
|
||||
use limbo_core::{Database, PlatformIO, IO};
|
||||
use pprof::criterion::{Output, PProfProfiler};
|
||||
use std::sync::Arc;
|
||||
use turso_core::{Database, PlatformIO, IO};
|
||||
|
||||
fn rusqlite_open() -> rusqlite::Connection {
|
||||
let sqlite_conn = rusqlite::Connection::open("../testing/testing.db").unwrap();
|
||||
|
@ -83,16 +83,16 @@ fn bench_execute_select_rows(criterion: &mut Criterion) {
|
|||
b.iter(|| {
|
||||
loop {
|
||||
match stmt.step().unwrap() {
|
||||
limbo_core::StepResult::Row => {
|
||||
turso_core::StepResult::Row => {
|
||||
black_box(stmt.row());
|
||||
}
|
||||
limbo_core::StepResult::IO => {
|
||||
turso_core::StepResult::IO => {
|
||||
let _ = io.run_once();
|
||||
}
|
||||
limbo_core::StepResult::Done => {
|
||||
turso_core::StepResult::Done => {
|
||||
break;
|
||||
}
|
||||
limbo_core::StepResult::Interrupt | limbo_core::StepResult::Busy => {
|
||||
turso_core::StepResult::Interrupt | turso_core::StepResult::Busy => {
|
||||
unreachable!();
|
||||
}
|
||||
}
|
||||
|
@ -145,16 +145,16 @@ fn bench_execute_select_1(criterion: &mut Criterion) {
|
|||
b.iter(|| {
|
||||
loop {
|
||||
match stmt.step().unwrap() {
|
||||
limbo_core::StepResult::Row => {
|
||||
turso_core::StepResult::Row => {
|
||||
black_box(stmt.row());
|
||||
}
|
||||
limbo_core::StepResult::IO => {
|
||||
turso_core::StepResult::IO => {
|
||||
let _ = io.run_once();
|
||||
}
|
||||
limbo_core::StepResult::Done => {
|
||||
turso_core::StepResult::Done => {
|
||||
break;
|
||||
}
|
||||
limbo_core::StepResult::Interrupt | limbo_core::StepResult::Busy => {
|
||||
turso_core::StepResult::Interrupt | turso_core::StepResult::Busy => {
|
||||
unreachable!();
|
||||
}
|
||||
}
|
||||
|
@ -198,16 +198,16 @@ fn bench_execute_select_count(criterion: &mut Criterion) {
|
|||
b.iter(|| {
|
||||
loop {
|
||||
match stmt.step().unwrap() {
|
||||
limbo_core::StepResult::Row => {
|
||||
turso_core::StepResult::Row => {
|
||||
black_box(stmt.row());
|
||||
}
|
||||
limbo_core::StepResult::IO => {
|
||||
turso_core::StepResult::IO => {
|
||||
let _ = io.run_once();
|
||||
}
|
||||
limbo_core::StepResult::Done => {
|
||||
turso_core::StepResult::Done => {
|
||||
break;
|
||||
}
|
||||
limbo_core::StepResult::Interrupt | limbo_core::StepResult::Busy => {
|
||||
turso_core::StepResult::Interrupt | turso_core::StepResult::Busy => {
|
||||
unreachable!();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||
use limbo_core::{Database, PlatformIO, IO};
|
||||
use pprof::{
|
||||
criterion::{Output, PProfProfiler},
|
||||
flamegraph::Options,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
use turso_core::{Database, PlatformIO, IO};
|
||||
|
||||
// Title: JSONB Function Benchmarking
|
||||
|
||||
|
@ -451,14 +451,14 @@ fn bench(criterion: &mut Criterion) {
|
|||
b.iter(|| {
|
||||
loop {
|
||||
match stmt.step().unwrap() {
|
||||
limbo_core::StepResult::Row => {}
|
||||
limbo_core::StepResult::IO => {
|
||||
turso_core::StepResult::Row => {}
|
||||
turso_core::StepResult::IO => {
|
||||
let _ = io.run_once();
|
||||
}
|
||||
limbo_core::StepResult::Done => {
|
||||
turso_core::StepResult::Done => {
|
||||
break;
|
||||
}
|
||||
limbo_core::StepResult::Interrupt | limbo_core::StepResult::Busy => {
|
||||
turso_core::StepResult::Interrupt | turso_core::StepResult::Busy => {
|
||||
unreachable!();
|
||||
}
|
||||
}
|
||||
|
@ -610,14 +610,14 @@ fn bench_sequential_jsonb(criterion: &mut Criterion) {
|
|||
b.iter(|| {
|
||||
loop {
|
||||
match stmt.step().unwrap() {
|
||||
limbo_core::StepResult::Row => {}
|
||||
limbo_core::StepResult::IO => {
|
||||
turso_core::StepResult::Row => {}
|
||||
turso_core::StepResult::IO => {
|
||||
let _ = io.run_once();
|
||||
}
|
||||
limbo_core::StepResult::Done => {
|
||||
turso_core::StepResult::Done => {
|
||||
break;
|
||||
}
|
||||
limbo_core::StepResult::Interrupt | limbo_core::StepResult::Busy => {
|
||||
turso_core::StepResult::Interrupt | turso_core::StepResult::Busy => {
|
||||
unreachable!();
|
||||
}
|
||||
}
|
||||
|
@ -903,14 +903,14 @@ fn bench_json_patch(criterion: &mut Criterion) {
|
|||
b.iter(|| {
|
||||
loop {
|
||||
match stmt.step().unwrap() {
|
||||
limbo_core::StepResult::Row => {}
|
||||
limbo_core::StepResult::IO => {
|
||||
turso_core::StepResult::Row => {}
|
||||
turso_core::StepResult::IO => {
|
||||
let _ = io.run_once();
|
||||
}
|
||||
limbo_core::StepResult::Done => {
|
||||
turso_core::StepResult::Done => {
|
||||
break;
|
||||
}
|
||||
limbo_core::StepResult::Interrupt | limbo_core::StepResult::Busy => {
|
||||
turso_core::StepResult::Interrupt | turso_core::StepResult::Busy => {
|
||||
unreachable!();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
use criterion::async_executor::FuturesExecutor;
|
||||
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 turso_core::mvcc::clock::LocalClock;
|
||||
use turso_core::mvcc::database::{MvStore, Row, RowID};
|
||||
|
||||
fn bench_db() -> MvStore<LocalClock> {
|
||||
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)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use criterion::{black_box, criterion_group, criterion_main, BenchmarkId, Criterion, SamplingMode};
|
||||
use limbo_core::{Database, PlatformIO, IO as _};
|
||||
use pprof::criterion::{Output, PProfProfiler};
|
||||
use turso_core::{Database, PlatformIO, IO as _};
|
||||
|
||||
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();
|
||||
loop {
|
||||
match stmt.step().unwrap() {
|
||||
limbo_core::StepResult::Row => {
|
||||
turso_core::StepResult::Row => {
|
||||
black_box(stmt.row());
|
||||
}
|
||||
limbo_core::StepResult::IO => {
|
||||
turso_core::StepResult::IO => {
|
||||
let _ = io.run_once();
|
||||
}
|
||||
limbo_core::StepResult::Done => {
|
||||
turso_core::StepResult::Done => {
|
||||
break;
|
||||
}
|
||||
limbo_core::StepResult::Interrupt | limbo_core::StepResult::Busy => {
|
||||
turso_core::StepResult::Interrupt | turso_core::StepResult::Busy => {
|
||||
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:
|
||||
|
||||
```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.
|
||||
|
||||
|
|
|
@ -419,7 +419,7 @@ Edit the workspace `Cargo.toml` to include your extension as a workspace depende
|
|||
|
||||
```diff
|
||||
[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_ext = { path = "extensions/core", 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 = [
|
||||
"arbitrary",
|
||||
"libfuzzer-sys",
|
||||
"limbo_core",
|
||||
"rusqlite",
|
||||
]
|
||||
|
||||
[[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",
|
||||
"turso_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "limbo_ext"
|
||||
version = "0.0.21"
|
||||
version = "0.1.0-pre.2"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"getrandom 0.3.1",
|
||||
|
@ -611,16 +575,24 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "limbo_macros"
|
||||
version = "0.0.21"
|
||||
version = "0.1.0-pre.2"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "limbo_series"
|
||||
version = "0.1.0-pre.2"
|
||||
dependencies = [
|
||||
"limbo_ext",
|
||||
"mimalloc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "limbo_sqlite3_parser"
|
||||
version = "0.0.21"
|
||||
version = "0.1.0-pre.2"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cc",
|
||||
|
@ -639,7 +611,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "limbo_time"
|
||||
version = "0.0.21"
|
||||
version = "0.1.0-pre.2"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"limbo_ext",
|
||||
|
@ -651,7 +623,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "limbo_uuid"
|
||||
version = "0.0.21"
|
||||
version = "0.1.0-pre.2"
|
||||
dependencies = [
|
||||
"limbo_ext",
|
||||
"mimalloc",
|
||||
|
@ -767,6 +739,12 @@ dependencies = [
|
|||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "paste"
|
||||
version = "1.0.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
|
||||
|
||||
[[package]]
|
||||
name = "percent-encoding"
|
||||
version = "2.3.1"
|
||||
|
@ -1161,6 +1139,44 @@ dependencies = [
|
|||
"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]]
|
||||
name = "uncased"
|
||||
version = "0.9.10"
|
||||
|
|
|
@ -11,7 +11,7 @@ cargo-fuzz = true
|
|||
[dependencies]
|
||||
libfuzzer-sys = "0.4"
|
||||
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"] }
|
||||
|
||||
# Prevent this from interfering with workspaces
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#![no_main]
|
||||
use libfuzzer_sys::{fuzz_target, Corpus};
|
||||
use limbo_core::numeric::StrToF64;
|
||||
use turso_core::numeric::StrToF64;
|
||||
use std::error::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| {
|
||||
let (StrToF64::Fractional(non_nan) | StrToF64::Decimal(non_nan)) = v;
|
||||
f64::from(non_nan)
|
||||
|
|
|
@ -4,7 +4,7 @@ use std::{error::Error, num::NonZero, sync::Arc};
|
|||
|
||||
use arbitrary::Arbitrary;
|
||||
use libfuzzer_sys::{fuzz_target, Corpus};
|
||||
use limbo_core::{Value, IO as _};
|
||||
use turso_core::{Value, IO as _};
|
||||
|
||||
macro_rules! str_enum {
|
||||
($vis:vis enum $name:ident { $($variant:ident => $value:literal),*, }) => {
|
||||
|
@ -72,20 +72,20 @@ enum Value {
|
|||
Blob(Vec<u8>),
|
||||
}
|
||||
|
||||
impl From<Value> for limbo_core::Value {
|
||||
fn from(value: Value) -> limbo_core::Value {
|
||||
impl From<Value> for turso_core::Value {
|
||||
fn from(value: Value) -> turso_core::Value {
|
||||
match value {
|
||||
Value::Null => limbo_core::Value::Null,
|
||||
Value::Integer(v) => limbo_core::Value::Integer(v),
|
||||
Value::Null => turso_core::Value::Null,
|
||||
Value::Integer(v) => turso_core::Value::Integer(v),
|
||||
Value::Real(v) => {
|
||||
if v.is_nan() {
|
||||
limbo_core::Value::Null
|
||||
turso_core::Value::Null
|
||||
} else {
|
||||
limbo_core::Value::Float(v)
|
||||
turso_core::Value::Float(v)
|
||||
}
|
||||
}
|
||||
Value::Text(v) => limbo_core::Value::from_text(&v),
|
||||
Value::Blob(v) => limbo_core::Value::from_blob(v.to_owned()),
|
||||
Value::Text(v) => turso_core::Value::from_text(&v),
|
||||
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 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 {
|
||||
return Ok(Corpus::Reject);
|
||||
}
|
||||
|
@ -183,8 +183,8 @@ fn do_fuzz(expr: Expr) -> Result<Corpus, Box<dyn Error>> {
|
|||
};
|
||||
|
||||
let found = 'value: {
|
||||
let io = Arc::new(limbo_core::MemoryIO::new());
|
||||
let db = limbo_core::Database::open_file(io.clone(), ":memory:", false)?;
|
||||
let io = Arc::new(turso_core::MemoryIO::new());
|
||||
let db = turso_core::Database::open_file(io.clone(), ":memory:", false)?;
|
||||
let conn = db.connect()?;
|
||||
|
||||
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())
|
||||
}
|
||||
loop {
|
||||
use limbo_core::StepResult;
|
||||
use turso_core::StepResult;
|
||||
match stmt.step()? {
|
||||
StepResult::IO => io.run_once()?,
|
||||
StepResult::Row => {
|
||||
|
|
|
@ -337,8 +337,8 @@ impl<'a> Arbitrary<'a> for Ops {
|
|||
fn do_fuzz(Ops(ops): Ops) -> Result<Corpus, Box<dyn Error>> {
|
||||
let rusqlite_conn = rusqlite::Connection::open_in_memory()?;
|
||||
|
||||
let io = Arc::new(limbo_core::MemoryIO::new());
|
||||
let db = limbo_core::Database::open_file(io.clone(), ":memory:", false)?;
|
||||
let io = Arc::new(turso_core::MemoryIO::new());
|
||||
let db = turso_core::Database::open_file(io.clone(), ":memory:", false)?;
|
||||
let limbo_conn = db.connect()?;
|
||||
|
||||
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"] }
|
||||
env_logger = "0.11.0"
|
||||
hdrhistogram = "7.5.2"
|
||||
limbo_core = { path = "../../../core" }
|
||||
turso_core = { path = "../../../core" }
|
||||
|
||||
[profile.release]
|
||||
debug = true
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
use clap::Parser;
|
||||
use hdrhistogram::Histogram;
|
||||
use limbo_core::{Database, PlatformIO, IO};
|
||||
use turso_core::{Database, PlatformIO, IO};
|
||||
use std::ops::{Coroutine, CoroutineState};
|
||||
use std::pin::Pin;
|
||||
use std::sync::Arc;
|
||||
|
@ -38,12 +38,12 @@ fn main() {
|
|||
loop {
|
||||
let row = rows.step().unwrap();
|
||||
match row {
|
||||
limbo_core::StepResult::Row(_) => {
|
||||
turso_core::StepResult::Row(_) => {
|
||||
let row = statement.row();
|
||||
count += 1;
|
||||
}
|
||||
limbo_core::StepResult::IO => yield,
|
||||
limbo_core::StepResult::Done => break,
|
||||
turso_core::StepResult::IO => yield,
|
||||
turso_core::StepResult::Done => break,
|
||||
}
|
||||
}
|
||||
assert!(count == 100);
|
||||
|
|
|
@ -13,5 +13,5 @@ cargo publish -p limbo_time
|
|||
cargo publish -p limbo_uuid
|
||||
cargo publish -p limbo_ipaddr
|
||||
cargo publish -p limbo_sqlite3_parser
|
||||
cargo publish -p limbo_core
|
||||
cargo publish -p turso_core
|
||||
cargo publish -p limbo
|
||||
|
|
|
@ -15,7 +15,7 @@ name = "limbo_sim"
|
|||
path = "main.rs"
|
||||
|
||||
[dependencies]
|
||||
limbo_core = { path = "../core", features = ["simulator"]}
|
||||
turso_core = { path = "../core", features = ["simulator"]}
|
||||
rand = "0.8.5"
|
||||
rand_chacha = "0.3.1"
|
||||
log = "0.4.20"
|
||||
|
|
|
@ -6,8 +6,8 @@ use std::{
|
|||
vec,
|
||||
};
|
||||
|
||||
use limbo_core::{Connection, Result, StepResult, IO};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use turso_core::{Connection, Result, StepResult, IO};
|
||||
|
||||
use crate::{
|
||||
model::{
|
||||
|
@ -564,10 +564,10 @@ impl Interaction {
|
|||
let result = assertion.func.as_ref()(stack, env);
|
||||
match result {
|
||||
Ok(true) => Ok(()),
|
||||
Ok(false) => Err(limbo_core::LimboError::InternalError(
|
||||
Ok(false) => Err(turso_core::LimboError::InternalError(
|
||||
assertion.message.clone(),
|
||||
)),
|
||||
Err(err) => Err(limbo_core::LimboError::InternalError(format!(
|
||||
Err(err) => Err(turso_core::LimboError::InternalError(format!(
|
||||
"{}. Inner error: {}",
|
||||
assertion.message, err
|
||||
))),
|
||||
|
@ -598,10 +598,10 @@ impl Interaction {
|
|||
let result = assumption.func.as_ref()(stack, env);
|
||||
match result {
|
||||
Ok(true) => Ok(()),
|
||||
Ok(false) => Err(limbo_core::LimboError::InternalError(
|
||||
Ok(false) => Err(turso_core::LimboError::InternalError(
|
||||
assumption.message.clone(),
|
||||
)),
|
||||
Err(err) => Err(limbo_core::LimboError::InternalError(format!(
|
||||
Err(err) => Err(turso_core::LimboError::InternalError(format!(
|
||||
"{}. Inner error: {}",
|
||||
assumption.message, err
|
||||
))),
|
||||
|
@ -630,7 +630,7 @@ impl Interaction {
|
|||
if env.connections[conn_index].is_connected() {
|
||||
env.connections[conn_index].disconnect();
|
||||
} else {
|
||||
return Err(limbo_core::LimboError::InternalError(
|
||||
return Err(turso_core::LimboError::InternalError(
|
||||
"connection already disconnected".into(),
|
||||
));
|
||||
}
|
||||
|
@ -644,7 +644,7 @@ impl Interaction {
|
|||
|
||||
// 2. Re-open database
|
||||
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(),
|
||||
&db_path,
|
||||
false,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use limbo_core::LimboError;
|
||||
use limbo_sqlite3_parser::ast;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use turso_core::LimboError;
|
||||
|
||||
use crate::{
|
||||
model::{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use std::collections::HashSet;
|
||||
|
||||
use limbo_core::Value;
|
||||
use rand::Rng;
|
||||
use turso_core::Value;
|
||||
|
||||
use crate::generation::{gen_random_text, pick, readable_name_custom, Arbitrary, ArbitraryFrom};
|
||||
use crate::model::table::{Column, ColumnType, Name, SimValue, Table};
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use std::{fmt::Display, hash::Hash, ops::Deref};
|
||||
|
||||
use limbo_core::{numeric::Numeric, types};
|
||||
use limbo_sqlite3_parser::ast;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use turso_core::{numeric::Numeric, types};
|
||||
|
||||
pub(crate) struct Name(pub(crate) String);
|
||||
|
||||
|
@ -79,7 +79,7 @@ where
|
|||
}
|
||||
|
||||
#[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 {
|
||||
format!(
|
||||
|
@ -116,7 +116,7 @@ impl SimValue {
|
|||
/// TODO: forget collations for now
|
||||
/// 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
|
||||
/// 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 {
|
||||
match operator {
|
||||
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 {
|
||||
value.0
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&SimValue> for limbo_core::types::Value {
|
||||
impl From<&SimValue> for turso_core::types::Value {
|
||||
fn from(value: &SimValue) -> Self {
|
||||
value.0.clone()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<limbo_core::types::Value> for SimValue {
|
||||
fn from(value: limbo_core::types::Value) -> Self {
|
||||
impl From<turso_core::types::Value> for SimValue {
|
||||
fn from(value: turso_core::types::Value) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&limbo_core::types::Value> for SimValue {
|
||||
fn from(value: &limbo_core::types::Value) -> Self {
|
||||
impl From<&turso_core::types::Value> for SimValue {
|
||||
fn from(value: &turso_core::types::Value) -> Self {
|
||||
Self(value.clone())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use limbo_core::Value;
|
||||
use turso_core::Value;
|
||||
|
||||
use crate::{
|
||||
generation::{
|
||||
|
@ -163,7 +163,7 @@ pub(crate) fn execute_plans(
|
|||
if now.elapsed().as_secs() >= env.opts.max_time_simulation as u64 {
|
||||
return ExecutionResult::new(
|
||||
history,
|
||||
Some(limbo_core::LimboError::InternalError(
|
||||
Some(turso_core::LimboError::InternalError(
|
||||
"maximum time for simulation reached".into(),
|
||||
)),
|
||||
);
|
||||
|
@ -181,7 +181,7 @@ fn execute_plan(
|
|||
plans: &mut [InteractionPlan],
|
||||
states: &mut [InteractionPlanState],
|
||||
rusqlite_states: &mut [InteractionPlanState],
|
||||
) -> limbo_core::Result<()> {
|
||||
) -> turso_core::Result<()> {
|
||||
let connection = &env.connections[connection_index];
|
||||
let rusqlite_connection = &rusqlite_env.connections[connection_index];
|
||||
let plan = &mut plans[connection_index];
|
||||
|
@ -214,7 +214,7 @@ fn execute_plan(
|
|||
(Ok(next_execution), Ok(next_execution_rusqlite)) => {
|
||||
if next_execution != next_execution_rusqlite {
|
||||
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(),
|
||||
));
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ fn execute_plan(
|
|||
(Ok(limbo_values), Ok(rusqlite_values)) => {
|
||||
if limbo_values != rusqlite_values {
|
||||
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(),
|
||||
));
|
||||
}
|
||||
|
@ -243,14 +243,14 @@ fn execute_plan(
|
|||
tracing::error!("limbo and rusqlite results do not match");
|
||||
tracing::error!("limbo values {:?}", limbo_result);
|
||||
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(),
|
||||
));
|
||||
}
|
||||
(Err(limbo_err), Ok(_)) => {
|
||||
tracing::error!("limbo and rusqlite results do not match");
|
||||
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(),
|
||||
));
|
||||
}
|
||||
|
@ -259,7 +259,7 @@ fn execute_plan(
|
|||
(None, None) => {}
|
||||
_ => {
|
||||
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(),
|
||||
));
|
||||
}
|
||||
|
@ -316,7 +316,7 @@ fn execute_interaction_rusqlite(
|
|||
connection_index: usize,
|
||||
interaction: &Interaction,
|
||||
stack: &mut Vec<ResultSet>,
|
||||
) -> limbo_core::Result<ExecutionContinuation> {
|
||||
) -> turso_core::Result<ExecutionContinuation> {
|
||||
tracing::trace!(
|
||||
"execute_interaction_rusqlite(connection_index={}, interaction={})",
|
||||
connection_index,
|
||||
|
@ -332,7 +332,7 @@ fn execute_interaction_rusqlite(
|
|||
|
||||
tracing::debug!("{}", interaction);
|
||||
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);
|
||||
stack.push(results);
|
||||
|
|
|
@ -3,9 +3,9 @@ use std::mem;
|
|||
use std::path::Path;
|
||||
use std::sync::Arc;
|
||||
|
||||
use limbo_core::Database;
|
||||
use rand::{Rng, SeedableRng};
|
||||
use rand_chacha::ChaCha8Rng;
|
||||
use turso_core::Database;
|
||||
|
||||
use crate::model::table::Table;
|
||||
|
||||
|
@ -168,7 +168,7 @@ where
|
|||
}
|
||||
|
||||
pub(crate) enum SimConnection {
|
||||
LimboConnection(Arc<limbo_core::Connection>),
|
||||
LimboConnection(Arc<turso_core::Connection>),
|
||||
SQLiteConnection(rusqlite::Connection),
|
||||
Disconnected,
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use limbo_core::{Connection, LimboError, Result, StepResult};
|
||||
use tracing::instrument;
|
||||
use turso_core::{Connection, LimboError, Result, StepResult};
|
||||
|
||||
use crate::generation::{
|
||||
pick_index,
|
||||
|
@ -227,7 +227,7 @@ fn limbo_integrity_check(conn: &mut Arc<Connection>) -> Result<()> {
|
|||
let row = rows.row().unwrap();
|
||||
|
||||
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!(),
|
||||
};
|
||||
result.push(val);
|
||||
|
|
|
@ -3,10 +3,10 @@ use std::{
|
|||
sync::Arc,
|
||||
};
|
||||
|
||||
use limbo_core::{CompletionType, File, Result};
|
||||
use rand::Rng as _;
|
||||
use rand_chacha::ChaCha8Rng;
|
||||
use tracing::{instrument, Level};
|
||||
use turso_core::{CompletionType, File, Result};
|
||||
pub(crate) struct SimulatorFile {
|
||||
pub(crate) inner: Arc<dyn File>,
|
||||
pub(crate) fault: Cell<bool>,
|
||||
|
@ -82,7 +82,7 @@ impl SimulatorFile {
|
|||
impl File for SimulatorFile {
|
||||
fn lock_file(&self, exclusive: bool) -> Result<()> {
|
||||
if self.fault.get() {
|
||||
return Err(limbo_core::LimboError::InternalError(
|
||||
return Err(turso_core::LimboError::InternalError(
|
||||
"Injected fault".into(),
|
||||
));
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ impl File for SimulatorFile {
|
|||
|
||||
fn unlock_file(&self) -> Result<()> {
|
||||
if self.fault.get() {
|
||||
return Err(limbo_core::LimboError::InternalError(
|
||||
return Err(turso_core::LimboError::InternalError(
|
||||
"Injected fault".into(),
|
||||
));
|
||||
}
|
||||
|
@ -101,12 +101,12 @@ impl File for SimulatorFile {
|
|||
fn pread(
|
||||
&self,
|
||||
pos: usize,
|
||||
mut c: limbo_core::Completion,
|
||||
) -> Result<Arc<limbo_core::Completion>> {
|
||||
mut c: turso_core::Completion,
|
||||
) -> Result<Arc<turso_core::Completion>> {
|
||||
self.nr_pread_calls.set(self.nr_pread_calls.get() + 1);
|
||||
if self.fault.get() {
|
||||
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(),
|
||||
));
|
||||
}
|
||||
|
@ -134,13 +134,13 @@ impl File for SimulatorFile {
|
|||
fn pwrite(
|
||||
&self,
|
||||
pos: usize,
|
||||
buffer: Arc<RefCell<limbo_core::Buffer>>,
|
||||
mut c: limbo_core::Completion,
|
||||
) -> Result<Arc<limbo_core::Completion>> {
|
||||
buffer: Arc<RefCell<turso_core::Buffer>>,
|
||||
mut c: turso_core::Completion,
|
||||
) -> Result<Arc<turso_core::Completion>> {
|
||||
self.nr_pwrite_calls.set(self.nr_pwrite_calls.get() + 1);
|
||||
if self.fault.get() {
|
||||
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(),
|
||||
));
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ impl File for SimulatorFile {
|
|||
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);
|
||||
if let Some(latency) = self.generate_latency_duration() {
|
||||
let CompletionType::Sync(sync_completion) = &mut c.completion_type else {
|
||||
|
|
|
@ -3,9 +3,9 @@ use std::{
|
|||
sync::Arc,
|
||||
};
|
||||
|
||||
use limbo_core::{Clock, Instant, OpenFlags, PlatformIO, Result, IO};
|
||||
use rand::{RngCore, SeedableRng};
|
||||
use rand_chacha::ChaCha8Rng;
|
||||
use turso_core::{Clock, Instant, OpenFlags, PlatformIO, Result, IO};
|
||||
|
||||
use crate::runner::file::SimulatorFile;
|
||||
|
||||
|
@ -72,7 +72,7 @@ impl IO for SimulatorIO {
|
|||
path: &str,
|
||||
flags: OpenFlags,
|
||||
_direct: bool,
|
||||
) -> Result<Arc<dyn limbo_core::File>> {
|
||||
) -> Result<Arc<dyn turso_core::File>> {
|
||||
let inner = self.inner.open_file(path, flags, false)?;
|
||||
let file = Arc::new(SimulatorFile {
|
||||
inner,
|
||||
|
@ -90,7 +90,7 @@ impl IO for SimulatorIO {
|
|||
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() {
|
||||
self.run_once()?;
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ impl IO for SimulatorIO {
|
|||
if self.fault.get() {
|
||||
self.nr_run_once_faults
|
||||
.replace(self.nr_run_once_faults.get() + 1);
|
||||
return Err(limbo_core::LimboError::InternalError(
|
||||
return Err(turso_core::LimboError::InternalError(
|
||||
"Injected fault".into(),
|
||||
));
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ impl IO for SimulatorIO {
|
|||
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!()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ pub(crate) fn execute_plans(
|
|||
if now.elapsed().as_secs() >= env.opts.max_time_simulation as u64 {
|
||||
return ExecutionResult::new(
|
||||
history,
|
||||
Some(limbo_core::LimboError::InternalError(
|
||||
Some(turso_core::LimboError::InternalError(
|
||||
"maximum time for simulation reached".into(),
|
||||
)),
|
||||
);
|
||||
|
@ -85,7 +85,7 @@ fn execute_plan(
|
|||
connection_index: usize,
|
||||
plans: &mut [Vec<Vec<Interaction>>],
|
||||
states: &mut [InteractionPlanState],
|
||||
) -> limbo_core::Result<()> {
|
||||
) -> turso_core::Result<()> {
|
||||
let connection = &env.connections[connection_index];
|
||||
let plan = &mut plans[connection_index];
|
||||
let state = &mut states[connection_index];
|
||||
|
|
|
@ -24,7 +24,7 @@ crate-type = ["lib", "cdylib", "staticlib"]
|
|||
[dependencies]
|
||||
env_logger = { version = "0.11.3", default-features = false }
|
||||
libc = "0.2.169"
|
||||
limbo_core = { path = "../core" }
|
||||
turso_core = { path = "../core" }
|
||||
tracing = "0.1.41"
|
||||
tracing-appender = "0.2.3"
|
||||
tracing-subscriber = { version = "0.3.19", features = ["env-filter"] }
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#![allow(clippy::missing_safety_doc)]
|
||||
#![allow(non_camel_case_types)]
|
||||
|
||||
use limbo_core::Value;
|
||||
use std::ffi::{self, CStr, CString};
|
||||
use tracing::trace;
|
||||
use turso_core::Value;
|
||||
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
|
@ -39,9 +39,9 @@ pub struct sqlite3 {
|
|||
}
|
||||
|
||||
struct sqlite3Inner {
|
||||
pub(crate) io: Arc<dyn limbo_core::IO>,
|
||||
pub(crate) _db: Arc<limbo_core::Database>,
|
||||
pub(crate) conn: Arc<limbo_core::Connection>,
|
||||
pub(crate) io: Arc<dyn turso_core::IO>,
|
||||
pub(crate) _db: Arc<turso_core::Database>,
|
||||
pub(crate) conn: Arc<turso_core::Connection>,
|
||||
pub(crate) err_code: ffi::c_int,
|
||||
pub(crate) err_mask: ffi::c_int,
|
||||
pub(crate) malloc_failed: bool,
|
||||
|
@ -51,9 +51,9 @@ struct sqlite3Inner {
|
|||
|
||||
impl sqlite3 {
|
||||
pub fn new(
|
||||
io: Arc<dyn limbo_core::IO>,
|
||||
db: Arc<limbo_core::Database>,
|
||||
conn: Arc<limbo_core::Connection>,
|
||||
io: Arc<dyn turso_core::IO>,
|
||||
db: Arc<turso_core::Database>,
|
||||
conn: Arc<turso_core::Connection>,
|
||||
) -> Self {
|
||||
let inner = sqlite3Inner {
|
||||
io,
|
||||
|
@ -73,11 +73,11 @@ impl sqlite3 {
|
|||
|
||||
pub struct sqlite3_stmt {
|
||||
pub(crate) db: *mut sqlite3,
|
||||
pub(crate) stmt: limbo_core::Statement,
|
||||
pub(crate) stmt: turso_core::Statement,
|
||||
}
|
||||
|
||||
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 }
|
||||
}
|
||||
}
|
||||
|
@ -119,14 +119,14 @@ pub unsafe extern "C" fn sqlite3_open(
|
|||
Ok(s) => s,
|
||||
Err(_) => return SQLITE_MISUSE,
|
||||
};
|
||||
let io: Arc<dyn limbo_core::IO> = match filename {
|
||||
":memory:" => Arc::new(limbo_core::MemoryIO::new()),
|
||||
_ => match limbo_core::PlatformIO::new() {
|
||||
let io: Arc<dyn turso_core::IO> = match filename {
|
||||
":memory:" => Arc::new(turso_core::MemoryIO::new()),
|
||||
_ => match turso_core::PlatformIO::new() {
|
||||
Ok(io) => Arc::new(io),
|
||||
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) => {
|
||||
let conn = db.connect().unwrap();
|
||||
*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();
|
||||
if let Ok(result) = stmt.stmt.step() {
|
||||
match result {
|
||||
limbo_core::StepResult::IO => {
|
||||
turso_core::StepResult::IO => {
|
||||
let io = db.io.clone();
|
||||
io.run_once().unwrap();
|
||||
continue;
|
||||
}
|
||||
limbo_core::StepResult::Done => return SQLITE_DONE,
|
||||
limbo_core::StepResult::Interrupt => return SQLITE_INTERRUPT,
|
||||
limbo_core::StepResult::Row => return SQLITE_ROW,
|
||||
limbo_core::StepResult::Busy => return SQLITE_BUSY,
|
||||
turso_core::StepResult::Done => return SQLITE_DONE,
|
||||
turso_core::StepResult::Interrupt => return SQLITE_INTERRUPT,
|
||||
turso_core::StepResult::Row => return SQLITE_ROW,
|
||||
turso_core::StepResult::Busy => return SQLITE_BUSY,
|
||||
}
|
||||
} else {
|
||||
return SQLITE_ERROR;
|
||||
|
@ -588,63 +588,63 @@ pub unsafe extern "C" fn sqlite3_column_bytes(
|
|||
|
||||
#[no_mangle]
|
||||
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;
|
||||
match value {
|
||||
limbo_core::Value::Null => 0,
|
||||
limbo_core::Value::Integer(_) => 1,
|
||||
limbo_core::Value::Float(_) => 2,
|
||||
limbo_core::Value::Text(_) => 3,
|
||||
limbo_core::Value::Blob(_) => 4,
|
||||
turso_core::Value::Null => 0,
|
||||
turso_core::Value::Integer(_) => 1,
|
||||
turso_core::Value::Float(_) => 2,
|
||||
turso_core::Value::Text(_) => 3,
|
||||
turso_core::Value::Blob(_) => 4,
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
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;
|
||||
match value {
|
||||
limbo_core::Value::Integer(i) => *i,
|
||||
turso_core::Value::Integer(i) => *i,
|
||||
_ => 0,
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
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;
|
||||
match value {
|
||||
limbo_core::Value::Float(f) => *f,
|
||||
turso_core::Value::Float(f) => *f,
|
||||
_ => 0.0,
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
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;
|
||||
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(),
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
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;
|
||||
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(),
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
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;
|
||||
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,
|
||||
}
|
||||
}
|
||||
|
@ -661,7 +661,7 @@ pub unsafe extern "C" fn sqlite3_column_text(
|
|||
None => return std::ptr::null(),
|
||||
};
|
||||
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(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ path = "integration/mod.rs"
|
|||
[dependencies]
|
||||
anyhow.workspace = true
|
||||
env_logger = "0.10.1"
|
||||
limbo_core = { path = "../core" }
|
||||
turso_core = { path = "../core" }
|
||||
rusqlite = { version = "0.34", features = ["bundled"] }
|
||||
tempfile = "3.0.7"
|
||||
log = "0.4.22"
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
use limbo_core::{Connection, Database, PagerCacheflushStatus, IO};
|
||||
use rand::{rng, RngCore};
|
||||
use rusqlite::params;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
@ -7,6 +6,7 @@ use tempfile::TempDir;
|
|||
use tracing_subscriber::layer::SubscriberExt;
|
||||
use tracing_subscriber::util::SubscriberInitExt;
|
||||
use tracing_subscriber::EnvFilter;
|
||||
use turso_core::{Connection, Database, PagerCacheflushStatus, IO};
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub struct TempDatabase {
|
||||
|
@ -25,11 +25,11 @@ impl TempDatabase {
|
|||
pub fn new(db_name: &str, enable_indexes: bool) -> Self {
|
||||
let mut path = TempDir::new().unwrap().keep();
|
||||
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(
|
||||
io.clone(),
|
||||
path.to_str().unwrap(),
|
||||
limbo_core::OpenFlags::default(),
|
||||
turso_core::OpenFlags::default(),
|
||||
false,
|
||||
enable_indexes,
|
||||
)
|
||||
|
@ -40,17 +40,17 @@ impl TempDatabase {
|
|||
pub fn new_with_existent(db_path: &Path, enable_indexes: bool) -> Self {
|
||||
Self::new_with_existent_with_flags(
|
||||
db_path,
|
||||
limbo_core::OpenFlags::default(),
|
||||
turso_core::OpenFlags::default(),
|
||||
enable_indexes,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn new_with_existent_with_flags(
|
||||
db_path: &Path,
|
||||
flags: limbo_core::OpenFlags,
|
||||
flags: turso_core::OpenFlags,
|
||||
enable_indexes: bool,
|
||||
) -> 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(
|
||||
io.clone(),
|
||||
db_path.to_str().unwrap(),
|
||||
|
@ -79,11 +79,11 @@ impl TempDatabase {
|
|||
.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(
|
||||
io.clone(),
|
||||
path.to_str().unwrap(),
|
||||
limbo_core::OpenFlags::default(),
|
||||
turso_core::OpenFlags::default(),
|
||||
false,
|
||||
enable_indexes,
|
||||
)
|
||||
|
@ -92,7 +92,7 @@ impl TempDatabase {
|
|||
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");
|
||||
|
||||
let conn = self.db.connect().unwrap();
|
||||
|
@ -100,7 +100,7 @@ impl TempDatabase {
|
|||
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");
|
||||
Database::open_file(
|
||||
self.io.clone(),
|
||||
|
@ -184,7 +184,7 @@ pub(crate) fn sqlite_exec_rows(
|
|||
|
||||
pub(crate) fn limbo_exec_rows(
|
||||
db: &TempDatabase,
|
||||
conn: &Arc<limbo_core::Connection>,
|
||||
conn: &Arc<turso_core::Connection>,
|
||||
query: &str,
|
||||
) -> Vec<Vec<rusqlite::types::Value>> {
|
||||
let mut stmt = conn.prepare(query).unwrap();
|
||||
|
@ -193,26 +193,26 @@ pub(crate) fn limbo_exec_rows(
|
|||
let row = loop {
|
||||
let result = stmt.step().unwrap();
|
||||
match result {
|
||||
limbo_core::StepResult::Row => {
|
||||
turso_core::StepResult::Row => {
|
||||
let row = stmt.row().unwrap();
|
||||
break row;
|
||||
}
|
||||
limbo_core::StepResult::IO => {
|
||||
turso_core::StepResult::IO => {
|
||||
db.io.run_once().unwrap();
|
||||
continue;
|
||||
}
|
||||
limbo_core::StepResult::Done => break 'outer,
|
||||
turso_core::StepResult::Done => break 'outer,
|
||||
r => panic!("unexpected result {:?}: expecting single row", r),
|
||||
}
|
||||
};
|
||||
let row = row
|
||||
.get_values()
|
||||
.map(|x| match x {
|
||||
limbo_core::Value::Null => rusqlite::types::Value::Null,
|
||||
limbo_core::Value::Integer(x) => rusqlite::types::Value::Integer(*x),
|
||||
limbo_core::Value::Float(x) => rusqlite::types::Value::Real(*x),
|
||||
limbo_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::Null => rusqlite::types::Value::Null,
|
||||
turso_core::Value::Integer(x) => rusqlite::types::Value::Integer(*x),
|
||||
turso_core::Value::Float(x) => rusqlite::types::Value::Real(*x),
|
||||
turso_core::Value::Text(x) => rusqlite::types::Value::Text(x.as_str().to_string()),
|
||||
turso_core::Value::Blob(x) => rusqlite::types::Value::Blob(x.to_vec()),
|
||||
})
|
||||
.collect();
|
||||
rows.push(row);
|
||||
|
@ -222,18 +222,18 @@ pub(crate) fn limbo_exec_rows(
|
|||
|
||||
pub(crate) fn limbo_exec_rows_error(
|
||||
db: &TempDatabase,
|
||||
conn: &Arc<limbo_core::Connection>,
|
||||
conn: &Arc<turso_core::Connection>,
|
||||
query: &str,
|
||||
) -> limbo_core::Result<()> {
|
||||
) -> turso_core::Result<()> {
|
||||
let mut stmt = conn.prepare(query)?;
|
||||
loop {
|
||||
let result = stmt.step()?;
|
||||
match result {
|
||||
limbo_core::StepResult::IO => {
|
||||
turso_core::StepResult::IO => {
|
||||
db.io.run_once()?;
|
||||
continue;
|
||||
}
|
||||
limbo_core::StepResult::Done => return Ok(()),
|
||||
turso_core::StepResult::Done => return Ok(()),
|
||||
r => panic!("unexpected result {:?}: expecting single row", r),
|
||||
}
|
||||
}
|
||||
|
@ -292,7 +292,7 @@ mod tests {
|
|||
{
|
||||
let db = TempDatabase::new_with_existent_with_flags(
|
||||
&path,
|
||||
limbo_core::OpenFlags::default(),
|
||||
turso_core::OpenFlags::default(),
|
||||
false,
|
||||
);
|
||||
let conn = db.connect_limbo();
|
||||
|
@ -305,7 +305,7 @@ mod tests {
|
|||
{
|
||||
let db = TempDatabase::new_with_existent_with_flags(
|
||||
&path,
|
||||
limbo_core::OpenFlags::default() | limbo_core::OpenFlags::ReadOnly,
|
||||
turso_core::OpenFlags::default() | turso_core::OpenFlags::ReadOnly,
|
||||
false,
|
||||
);
|
||||
let conn = db.connect_limbo();
|
||||
|
@ -313,7 +313,7 @@ mod tests {
|
|||
assert_eq!(ret, vec![vec![Value::Integer(1)]]);
|
||||
|
||||
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(())
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::common::{do_flush, TempDatabase};
|
||||
use limbo_core::StepResult;
|
||||
use turso_core::StepResult;
|
||||
|
||||
#[test]
|
||||
fn test_last_insert_rowid_basic() -> anyhow::Result<()> {
|
||||
|
@ -31,7 +31,7 @@ fn test_last_insert_rowid_basic() -> anyhow::Result<()> {
|
|||
match rows.step()? {
|
||||
StepResult::Row => {
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ fn test_last_insert_rowid_basic() -> anyhow::Result<()> {
|
|||
match rows.step()? {
|
||||
StepResult::Row => {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ fn test_integer_primary_key() -> anyhow::Result<()> {
|
|||
match select_query.step()? {
|
||||
StepResult::Row => {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use crate::common::TempDatabase;
|
||||
use limbo_core::{StepResult, Value};
|
||||
use turso_core::{StepResult, Value};
|
||||
|
||||
#[test]
|
||||
fn test_statement_reset_bind() -> anyhow::Result<()> {
|
||||
|
@ -16,7 +16,7 @@ fn test_statement_reset_bind() -> anyhow::Result<()> {
|
|||
let row = stmt.row().unwrap();
|
||||
assert_eq!(
|
||||
*row.get::<&Value>(0).unwrap(),
|
||||
limbo_core::Value::Integer(1)
|
||||
turso_core::Value::Integer(1)
|
||||
);
|
||||
}
|
||||
StepResult::IO => tmp_db.io.run_once()?,
|
||||
|
@ -34,7 +34,7 @@ fn test_statement_reset_bind() -> anyhow::Result<()> {
|
|||
let row = stmt.row().unwrap();
|
||||
assert_eq!(
|
||||
*row.get::<&Value>(0).unwrap(),
|
||||
limbo_core::Value::Integer(2)
|
||||
turso_core::Value::Integer(2)
|
||||
);
|
||||
}
|
||||
StepResult::IO => tmp_db.io.run_once()?,
|
||||
|
@ -67,23 +67,23 @@ fn test_statement_bind() -> anyhow::Result<()> {
|
|||
match stmt.step()? {
|
||||
StepResult::Row => {
|
||||
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")
|
||||
}
|
||||
|
||||
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")
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
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])
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use crate::common::{self, maybe_setup_tracing};
|
||||
use crate::common::{compare_string, do_flush, TempDatabase};
|
||||
use limbo_core::{Connection, Row, Statement, StepResult, Value};
|
||||
use log::debug;
|
||||
use std::sync::Arc;
|
||||
use turso_core::{Connection, Row, Statement, StepResult, Value};
|
||||
|
||||
#[macro_export]
|
||||
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| {
|
||||
let first_value = row.get::<&Value>(0).expect("missing id");
|
||||
let id = match first_value {
|
||||
limbo_core::Value::Integer(i) => *i as i32,
|
||||
limbo_core::Value::Float(f) => *f as i32,
|
||||
turso_core::Value::Integer(i) => *i as i32,
|
||||
turso_core::Value::Float(f) => *f as i32,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
assert_eq!(current_read_index, id);
|
||||
|
@ -239,7 +239,7 @@ fn test_statement_reset() -> anyhow::Result<()> {
|
|||
let row = stmt.row().unwrap();
|
||||
assert_eq!(
|
||||
*row.get::<&Value>(0).unwrap(),
|
||||
limbo_core::Value::Integer(1)
|
||||
turso_core::Value::Integer(1)
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
@ -256,7 +256,7 @@ fn test_statement_reset() -> anyhow::Result<()> {
|
|||
let row = stmt.row().unwrap();
|
||||
assert_eq!(
|
||||
*row.get::<&Value>(0).unwrap(),
|
||||
limbo_core::Value::Integer(1)
|
||||
turso_core::Value::Integer(1)
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
@ -381,8 +381,8 @@ fn test_write_delete_with_index() -> anyhow::Result<()> {
|
|||
run_query_on_row(&tmp_db, &conn, list_query, |row: &Row| {
|
||||
let first_value = row.get::<&Value>(0).expect("missing id");
|
||||
let id = match first_value {
|
||||
limbo_core::Value::Integer(i) => *i as i32,
|
||||
limbo_core::Value::Float(f) => *f as i32,
|
||||
turso_core::Value::Integer(i) => *i as i32,
|
||||
turso_core::Value::Float(f) => *f as i32,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
assert_eq!(current_read_index, id);
|
||||
|
@ -397,8 +397,8 @@ fn test_write_delete_with_index() -> anyhow::Result<()> {
|
|||
|row| {
|
||||
let first_value = row.get::<&Value>(0).expect("missing id");
|
||||
let id = match first_value {
|
||||
limbo_core::Value::Integer(i) => *i as i32,
|
||||
limbo_core::Value::Float(f) => *f as i32,
|
||||
turso_core::Value::Integer(i) => *i as i32,
|
||||
turso_core::Value::Float(f) => *f as i32,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
assert_eq!(i, id);
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use crate::common::{do_flush, maybe_setup_tracing, TempDatabase};
|
||||
use limbo_core::{Connection, LimboError, Result, StepResult};
|
||||
use std::cell::RefCell;
|
||||
use std::ops::Deref;
|
||||
use std::rc::Rc;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use turso_core::{Connection, LimboError, Result, StepResult};
|
||||
|
||||
#[allow(clippy::arc_with_non_send_sync)]
|
||||
#[test]
|
||||
|
@ -154,7 +154,7 @@ pub(crate) fn execute_and_get_ints(
|
|||
let row = stmt.row().unwrap();
|
||||
for value in row.get_values() {
|
||||
let out = match value {
|
||||
limbo_core::Value::Integer(i) => i,
|
||||
turso_core::Value::Integer(i) => i,
|
||||
_ => {
|
||||
return Err(LimboError::ConversionError(format!(
|
||||
"cannot convert {value} to int"
|
||||
|
|
|
@ -244,7 +244,7 @@ mod tests {
|
|||
pub(crate) struct TestContext;
|
||||
|
||||
// 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 {
|
||||
fn get_column_name(&self, _table_id: crate::ast::TableInternalId, _col_idx: usize) -> &str {
|
||||
todo!()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue