Merge 'Eliminate core extension dependencies' from Pekka Enberg

Bundle UUID and time extensions and drop the dependency to other
extensions so that we don't have to publish every crate.

Reviewed-by: Preston Thorpe (@PThorpe92)

Closes #1886
This commit is contained in:
Pekka Enberg
2025-06-30 10:59:18 +03:00
17 changed files with 99 additions and 265 deletions

52
Cargo.lock generated
View File

@@ -852,16 +852,6 @@ dependencies = [
"regex",
]
[[package]]
name = "env_logger"
version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a19187fea3ac7e84da7dacf48de0c45d63c6a76f9490dae389aead16c243fce3"
dependencies = [
"log",
"regex",
]
[[package]]
name = "env_logger"
version = "0.10.2"
@@ -1806,16 +1796,6 @@ dependencies = [
"turso_ext",
]
[[package]]
name = "limbo_series"
version = "0.1.0-pre.2"
dependencies = [
"mimalloc",
"quickcheck",
"quickcheck_macros",
"turso_ext",
]
[[package]]
name = "limbo_sim"
version = "0.1.0-pre.2"
@@ -1878,27 +1858,6 @@ dependencies = [
"turso",
]
[[package]]
name = "limbo_time"
version = "0.1.0-pre.2"
dependencies = [
"chrono",
"mimalloc",
"strum",
"strum_macros",
"thiserror 2.0.12",
"turso_ext",
]
[[package]]
name = "limbo_uuid"
version = "0.1.0-pre.2"
dependencies = [
"mimalloc",
"turso_ext",
"uuid",
]
[[package]]
name = "linked-hash-map"
version = "0.5.6"
@@ -2654,8 +2613,6 @@ version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "588f6378e4dd99458b60ec275b4477add41ce4fa9f64dcba6f15adccb19b50d6"
dependencies = [
"env_logger 0.8.4",
"log",
"rand 0.8.5",
]
@@ -3720,14 +3677,6 @@ dependencies = [
"libc",
"libloading",
"libm",
"limbo_crypto",
"limbo_csv",
"limbo_ipaddr",
"limbo_percentile",
"limbo_regexp",
"limbo_series",
"limbo_time",
"limbo_uuid",
"lru",
"miette",
"mimalloc",
@@ -3757,6 +3706,7 @@ dependencies = [
"turso_macros",
"turso_sqlite3_parser",
"uncased",
"uuid",
]
[[package]]

View File

@@ -15,12 +15,10 @@ members = [
"extensions/core",
"extensions/crypto",
"extensions/csv",
"extensions/ipaddr",
"extensions/percentile",
"extensions/regexp",
"extensions/series",
"extensions/tests",
"extensions/time",
"extensions/uuid",
"macros",
"simulator",
"sqlite3",
@@ -49,9 +47,7 @@ limbo_ipaddr = { path = "extensions/ipaddr", version = "0.1.0-pre.2" }
turso_macros = { path = "macros", version = "0.1.0-pre.2" }
limbo_percentile = { path = "extensions/percentile", version = "0.1.0-pre.2" }
limbo_regexp = { path = "extensions/regexp", version = "0.1.0-pre.2" }
limbo_series = { path = "extensions/series", version = "0.1.0-pre.2" }
turso_sqlite3_parser = { path = "vendored/sqlite3-parser", version = "0.1.0-pre.2" }
limbo_time = { path = "extensions/time", version = "0.1.0-pre.2" }
limbo_uuid = { path = "extensions/uuid", version = "0.1.0-pre.2" }
strum = { version = "0.26", features = ["derive"] }
strum_macros = "0.26"

View File

@@ -15,23 +15,17 @@ path = "lib.rs"
[features]
antithesis = ["dep:antithesis_sdk"]
default = ["fs", "uuid", "time", "json", "static", "series"]
default = ["fs", "uuid", "time", "json", "series"]
fs = ["turso_ext/vfs"]
json = []
uuid = ["limbo_uuid/static"]
uuid = ["dep:uuid"]
io_uring = ["dep:io-uring", "rustix/io_uring", "dep:libc"]
percentile = ["limbo_percentile/static"]
regexp = ["limbo_regexp/static"]
time = ["limbo_time/static"]
crypto = ["limbo_crypto/static"]
series = ["limbo_series/static"]
ipaddr = ["limbo_ipaddr/static"]
static = ["turso_ext/static"]
time = []
fuzz = []
csv = ["limbo_csv/static"]
omit_autovacuum = []
simulator = ["fuzz", "serde"]
serde = ["dep:serde"]
series = []
[target.'cfg(target_os = "linux")'.dependencies]
io-uring = { version = "0.7.5", optional = true }
@@ -63,14 +57,6 @@ julian_day_converter = "0.4.5"
rand = "0.8.5"
libm = "0.2"
turso_macros = { workspace = true }
limbo_uuid = { workspace = true, optional = true, features = ["static"] }
limbo_regexp = { workspace = true, optional = true, features = ["static"] }
limbo_percentile = { workspace = true, optional = true, features = ["static"] }
limbo_time = { workspace = true, optional = true, features = ["static"] }
limbo_crypto = { workspace = true, optional = true, features = ["static"] }
limbo_series = { workspace = true, optional = true, features = ["static"] }
limbo_ipaddr = { workspace = true, optional = true, features = ["static"] }
limbo_csv = { workspace = true, optional = true, features = ["static"] }
miette = "7.6.0"
strum = { workspace = true }
parking_lot = "0.12.3"
@@ -82,6 +68,7 @@ strum_macros = { workspace = true }
bitflags = "2.9.0"
serde = { workspace = true , optional = true, features = ["derive"] }
paste = "1.0.15"
uuid = { version = "1.11.0", features = ["v4", "v7"], optional = true }
[build-dependencies]
chrono = { version = "0.4.38", default-features = false }

View File

@@ -173,37 +173,9 @@ impl Connection {
#[allow(unused_variables)]
let mut ext_api = self.build_turso_ext();
#[cfg(feature = "uuid")]
if unsafe { !limbo_uuid::register_extension_static(&mut ext_api).is_ok() } {
return Err("Failed to register uuid extension".to_string());
}
#[cfg(feature = "percentile")]
if unsafe { !limbo_percentile::register_extension_static(&mut ext_api).is_ok() } {
return Err("Failed to register percentile extension".to_string());
}
#[cfg(feature = "regexp")]
if unsafe { !limbo_regexp::register_extension_static(&mut ext_api).is_ok() } {
return Err("Failed to register regexp extension".to_string());
}
#[cfg(feature = "time")]
if unsafe { !limbo_time::register_extension_static(&mut ext_api).is_ok() } {
return Err("Failed to register time extension".to_string());
}
#[cfg(feature = "crypto")]
if unsafe { !limbo_crypto::register_extension_static(&mut ext_api).is_ok() } {
return Err("Failed to register crypto extension".to_string());
}
crate::uuid::register_extension(&mut ext_api);
#[cfg(feature = "series")]
if unsafe { !limbo_series::register_extension_static(&mut ext_api).is_ok() } {
return Err("Failed to register series extension".to_string());
}
#[cfg(feature = "ipaddr")]
if unsafe { !limbo_ipaddr::register_extension_static(&mut ext_api).is_ok() } {
return Err("Failed to register ipaddr extension".to_string());
}
#[cfg(feature = "csv")]
if unsafe { !limbo_csv::register_extension_static(&mut ext_api).is_ok() } {
return Err("Failed to register csv extension".to_string());
}
crate::series::register_extension(&mut ext_api);
#[cfg(feature = "fs")]
{
let vfslist = add_builtin_vfs_extensions(Some(ext_api)).map_err(|e| e.to_string())?;

View File

@@ -16,11 +16,17 @@ mod pragma;
mod pseudo;
pub mod result;
mod schema;
#[cfg(feature = "series")]
mod series;
mod storage;
#[allow(dead_code)]
#[cfg(feature = "time")]
mod time;
mod translate;
pub mod types;
#[allow(dead_code)]
mod util;
#[cfg(feature = "uuid")]
mod uuid;
mod vdbe;
mod vector;
mod vtab;

View File

@@ -1,12 +1,15 @@
use std::sync::Arc;
use turso_ext::{
register_extension, Connection, ResultCode, VTabCursor, VTabKind, VTabModule, VTabModuleDerive,
Connection, ExtensionApi, ResultCode, VTabCursor, VTabKind, VTabModule, VTabModuleDerive,
VTable, Value,
};
register_extension! {
vtabs: { GenerateSeriesVTabModule }
pub fn register_extension(ext_api: &mut ExtensionApi) {
// FIXME: Add macro magic to register functions automatically.
unsafe {
GenerateSeriesVTabModule::register_GenerateSeriesVTabModule(ext_api);
}
}
macro_rules! try_option {

View File

@@ -5,7 +5,7 @@ use chrono::{prelude::*, DurationRound};
use turso_ext::Value;
use crate::{Result, TimeError};
use crate::time::{Result, TimeError};
const DAYS_BEFORE_EPOCH: i64 = 719162;
const TIME_BLOB_SIZE: usize = 13;

View File

@@ -3,64 +3,68 @@ use std::str::FromStr as _;
use chrono::prelude::*;
use core::cmp::Ordering;
use thiserror::Error;
use turso_ext::ValueType;
use turso_ext::{register_extension, scalar, ResultCode, Value};
use crate::ext::register_scalar_function;
use turso_ext::{scalar, ExtensionApi, ResultCode, Value, ValueType};
mod time;
mod internal;
use time::*;
use internal::*;
register_extension! {
scalars: {
time_now,
time_date,
make_date,
make_timestamp,
time_get,
time_get_year,
time_get_month,
time_get_day,
time_get_hour,
time_get_minute,
time_get_second,
time_get_nano,
time_get_weekday,
time_get_yearday,
time_get_isoyear,
time_get_isoweek,
time_unix,
to_timestamp,
time_milli,
time_micro,
time_nano,
time_to_unix,
time_to_milli,
time_to_micro,
time_to_nano,
time_after,
time_before,
time_compare,
time_equal,
dur_ns,
dur_us,
dur_ms,
dur_s,
dur_m,
dur_h,
time_add,
time_add_date,
time_sub,
time_since,
time_until,
time_trunc,
time_round,
time_fmt_iso,
time_fmt_datetime,
time_fmt_date,
time_fmt_time,
time_parse,
},
pub fn register_extension(ext_api: &mut ExtensionApi) {
unsafe {
register_scalar_function(ext_api.ctx, c"time_now".as_ptr(), time_now);
register_scalar_function(ext_api.ctx, c"time_date".as_ptr(), time_date);
register_scalar_function(ext_api.ctx, c"make_date".as_ptr(), make_date);
register_scalar_function(ext_api.ctx, c"make_timestamp".as_ptr(), make_timestamp);
register_scalar_function(ext_api.ctx, c"time_get".as_ptr(), time_get);
register_scalar_function(ext_api.ctx, c"time_get_year".as_ptr(), time_get_year);
register_scalar_function(ext_api.ctx, c"time_get_month".as_ptr(), time_get_month);
register_scalar_function(ext_api.ctx, c"time_get_day".as_ptr(), time_get_day);
register_scalar_function(ext_api.ctx, c"time_get_hour".as_ptr(), time_get_hour);
register_scalar_function(ext_api.ctx, c"time_get_minute".as_ptr(), time_get_minute);
register_scalar_function(ext_api.ctx, c"time_get_second".as_ptr(), time_get_second);
register_scalar_function(ext_api.ctx, c"time_get_nano".as_ptr(), time_get_nano);
register_scalar_function(ext_api.ctx, c"time_get_weekday".as_ptr(), time_get_weekday);
register_scalar_function(ext_api.ctx, c"time_get_yearday".as_ptr(), time_get_yearday);
register_scalar_function(ext_api.ctx, c"time_get_isoyear".as_ptr(), time_get_isoyear);
register_scalar_function(ext_api.ctx, c"time_get_isoweek".as_ptr(), time_get_isoweek);
register_scalar_function(ext_api.ctx, c"time_unix".as_ptr(), time_unix);
register_scalar_function(ext_api.ctx, c"to_timestamp".as_ptr(), to_timestamp);
register_scalar_function(ext_api.ctx, c"time_milli".as_ptr(), time_milli);
register_scalar_function(ext_api.ctx, c"time_micro".as_ptr(), time_micro);
register_scalar_function(ext_api.ctx, c"time_nano".as_ptr(), time_nano);
register_scalar_function(ext_api.ctx, c"time_to_unix".as_ptr(), time_to_unix);
register_scalar_function(ext_api.ctx, c"time_to_milli".as_ptr(), time_to_milli);
register_scalar_function(ext_api.ctx, c"time_to_micro".as_ptr(), time_to_micro);
register_scalar_function(ext_api.ctx, c"time_to_nano".as_ptr(), time_to_nano);
register_scalar_function(ext_api.ctx, c"time_after".as_ptr(), time_after);
register_scalar_function(ext_api.ctx, c"time_before".as_ptr(), time_before);
register_scalar_function(ext_api.ctx, c"time_compare".as_ptr(), time_compare);
register_scalar_function(ext_api.ctx, c"time_equal".as_ptr(), time_equal);
register_scalar_function(ext_api.ctx, c"dur_ns".as_ptr(), dur_ns);
register_scalar_function(ext_api.ctx, c"dur_us".as_ptr(), dur_us);
register_scalar_function(ext_api.ctx, c"dur_ms".as_ptr(), dur_ms);
register_scalar_function(ext_api.ctx, c"dur_s".as_ptr(), dur_s);
register_scalar_function(ext_api.ctx, c"dur_m".as_ptr(), dur_m);
register_scalar_function(ext_api.ctx, c"dur_h".as_ptr(), dur_h);
register_scalar_function(ext_api.ctx, c"time_add".as_ptr(), time_add);
register_scalar_function(ext_api.ctx, c"time_add_date".as_ptr(), time_add_date);
register_scalar_function(ext_api.ctx, c"time_sub".as_ptr(), time_sub);
register_scalar_function(ext_api.ctx, c"time_since".as_ptr(), time_since);
register_scalar_function(ext_api.ctx, c"time_until".as_ptr(), time_until);
register_scalar_function(ext_api.ctx, c"time_trunc".as_ptr(), time_trunc);
register_scalar_function(ext_api.ctx, c"time_round".as_ptr(), time_round);
register_scalar_function(ext_api.ctx, c"time_fmt_iso".as_ptr(), time_fmt_iso);
register_scalar_function(
ext_api.ctx,
c"time_fmt_datetime".as_ptr(),
time_fmt_datetime,
);
register_scalar_function(ext_api.ctx, c"time_fmt_date".as_ptr(), time_fmt_date);
register_scalar_function(ext_api.ctx, c"time_fmt_time".as_ptr(), time_fmt_time);
register_scalar_function(ext_api.ctx, c"time_parse".as_ptr(), time_parse);
}
}
macro_rules! ok_tri {

View File

@@ -670,6 +670,7 @@ impl OpenMode {
))),
}
}
#[allow(dead_code)]
pub fn get_flags(&self) -> OpenFlags {
match self {
OpenMode::ReadWriteCreate => OpenFlags::Create,
@@ -705,6 +706,7 @@ fn normalize_windows_path(path: &str) -> String {
}
/// Parses a SQLite URI, handling Windows and Unix paths separately.
#[allow(dead_code)]
pub fn parse_sqlite_uri(uri: &str) -> Result<OpenOptions> {
if !uri.starts_with("file:") {
return Ok(OpenOptions {

View File

@@ -1,7 +1,18 @@
use turso_ext::{register_extension, scalar, ResultCode, Value, ValueType};
use crate::ext::register_scalar_function;
use turso_ext::{scalar, ExtensionApi, ResultCode, Value, ValueType};
register_extension! {
scalars: {uuid4_str, uuid4_blob, uuid7_str, uuid7, uuid7_ts, uuid_str, uuid_blob },
pub fn register_extension(ext_api: &mut ExtensionApi) {
// FIXME: Add macro magic to register functions automatically.
unsafe {
register_scalar_function(ext_api.ctx, c"uuid4_str".as_ptr(), uuid4_str);
register_scalar_function(ext_api.ctx, c"gen_random_uuid".as_ptr(), uuid4_str);
register_scalar_function(ext_api.ctx, c"uuid4".as_ptr(), uuid4_blob);
register_scalar_function(ext_api.ctx, c"uuid7_str".as_ptr(), uuid7_str);
register_scalar_function(ext_api.ctx, c"uuid7".as_ptr(), uuid7);
register_scalar_function(ext_api.ctx, c"uuid7_timestamp_ms".as_ptr(), uuid7_ts);
register_scalar_function(ext_api.ctx, c"uuid_str".as_ptr(), uuid_str);
register_scalar_function(ext_api.ctx, c"uuid_blob".as_ptr(), uuid_blob);
}
}
#[scalar(name = "uuid4_str", alias = "gen_random_uuid")]

View File

@@ -423,7 +423,6 @@ turso_core = { path = "core", version = "0.0.17" }
limbo_crypto = { path = "extensions/crypto", version = "0.0.17" }
turso_ext = { path = "extensions/core", version = "0.0.17" }
limbo_macros = { path = "macros", version = "0.0.17" }
limbo_uuid = { path = "extensions/uuid", version = "0.0.17" }
...
+limbo_csv = { path = "extensions/csv", version = "0.0.17" }

View File

@@ -1,25 +0,0 @@
[package]
name = "limbo_series"
version.workspace = true
authors.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true
description = "Limbo series extension"
[features]
static = ["turso_ext/static"]
[lib]
crate-type = ["cdylib", "lib"]
[dependencies]
turso_ext = { workspace = true, features = ["static"] }
[target.'cfg(not(target_family = "wasm"))'.dependencies]
mimalloc = { version = "0.1", default-features = false }
[dev-dependencies]
quickcheck = "1.0.3"
quickcheck_macros = "1.0.0"

View File

@@ -1,24 +0,0 @@
[package]
authors.workspace = true
edition.workspace = true
license.workspace = true
name = "limbo_time"
repository.workspace = true
version.workspace = true
description = "Limbo time extension"
[lib]
crate-type = ["cdylib", "lib"]
[features]
static = ["turso_ext/static"]
[target.'cfg(not(target_family = "wasm"))'.dependencies]
mimalloc = { version = "0.1", default-features = false }
[dependencies]
chrono = "0.4.39"
turso_ext = { workspace = true, features = ["static"] }
strum = "0.26.3"
strum_macros = "0.26.3"
thiserror = "2.0.11"

View File

@@ -1,21 +0,0 @@
[package]
name = "limbo_uuid"
version.workspace = true
authors.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true
description = "Limbo UUID extension"
[lib]
crate-type = ["cdylib", "lib"]
[features]
static= [ "turso_ext/static" ]
[dependencies]
turso_ext = { workspace = true, features = ["static"] }
uuid = { version = "1.11.0", features = ["v4", "v7"] }
[target.'cfg(not(target_family = "wasm"))'.dependencies]
mimalloc = { version = "0.1", default-features = false }

11
fuzz/Cargo.lock generated
View File

@@ -584,15 +584,6 @@ dependencies = [
"turso_ext",
]
[[package]]
name = "limbo_uuid"
version = "0.1.0-pre.2"
dependencies = [
"mimalloc",
"turso_ext",
"uuid",
]
[[package]]
name = "linux-raw-sys"
version = "0.4.15"
@@ -1119,7 +1110,6 @@ dependencies = [
"libm",
"limbo_series",
"limbo_time",
"limbo_uuid",
"miette",
"mimalloc",
"parking_lot",
@@ -1138,6 +1128,7 @@ dependencies = [
"turso_macros",
"turso_sqlite3_parser",
"uncased",
"uuid",
]
[[package]]

View File

@@ -672,15 +672,6 @@ dependencies = [
"turso_ext",
]
[[package]]
name = "limbo_uuid"
version = "0.1.0-pre.2"
dependencies = [
"mimalloc",
"turso_ext",
"uuid",
]
[[package]]
name = "linux-raw-sys"
version = "0.9.4"
@@ -1220,7 +1211,6 @@ dependencies = [
"libm",
"limbo_series",
"limbo_time",
"limbo_uuid",
"miette",
"mimalloc",
"parking_lot",
@@ -1239,6 +1229,7 @@ dependencies = [
"turso_macros",
"turso_sqlite3_parser",
"uncased",
"uuid",
]
[[package]]

View File

@@ -2,14 +2,6 @@
cargo publish -p turso_macros
cargo publish -p turso_ext
cargo publish -p limbo_crypto
cargo publish -p limbo_csv
cargo publish -p limbo_percentile
cargo publish -p limbo_regexp
cargo publish -p limbo_series
cargo publish -p limbo_time
cargo publish -p limbo_uuid
cargo publish -p limbo_ipaddr
cargo publish -p turso_sqlite3_parser
cargo publish -p turso_core
cargo publish -p limbo