From 12131babae1e4ab0d94d8c5ed8718407e8d36829 Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Sun, 29 Jun 2025 14:47:11 +0300 Subject: [PATCH] Move UUID extension to core We want to bundle the UUID extension by default so move the code to core. --- Cargo.lock | 11 +---------- Cargo.toml | 1 - core/Cargo.toml | 4 ++-- core/ext/mod.rs | 4 +--- core/lib.rs | 2 ++ extensions/uuid/src/lib.rs => core/uuid.rs | 17 ++++++++++++++--- extensions/core/README.md | 1 - extensions/uuid/Cargo.toml | 21 --------------------- fuzz/Cargo.lock | 11 +---------- perf/latency/limbo/Cargo.lock | 11 +---------- scripts/publish-crates.sh | 1 - 11 files changed, 22 insertions(+), 62 deletions(-) rename extensions/uuid/src/lib.rs => core/uuid.rs (82%) delete mode 100644 extensions/uuid/Cargo.toml diff --git a/Cargo.lock b/Cargo.lock index 6d13648a9..f9af90d9b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1890,15 +1890,6 @@ dependencies = [ "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" @@ -3727,7 +3718,6 @@ dependencies = [ "limbo_regexp", "limbo_series", "limbo_time", - "limbo_uuid", "lru", "miette", "mimalloc", @@ -3757,6 +3747,7 @@ dependencies = [ "turso_macros", "turso_sqlite3_parser", "uncased", + "uuid", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index aba4ef0b5..bc3349523 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,6 @@ members = [ "extensions/series", "extensions/tests", "extensions/time", - "extensions/uuid", "macros", "simulator", "sqlite3", diff --git a/core/Cargo.toml b/core/Cargo.toml index 484d8b45d..47021165c 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -18,7 +18,7 @@ antithesis = ["dep:antithesis_sdk"] default = ["fs", "uuid", "time", "json", "static", "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"] @@ -63,7 +63,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"] } @@ -82,6 +81,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 } diff --git a/core/ext/mod.rs b/core/ext/mod.rs index 692d822d3..cb49e8078 100644 --- a/core/ext/mod.rs +++ b/core/ext/mod.rs @@ -173,9 +173,7 @@ 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()); - } + crate::uuid::register_extension(&mut ext_api); #[cfg(feature = "percentile")] if unsafe { !limbo_percentile::register_extension_static(&mut ext_api).is_ok() } { return Err("Failed to register percentile extension".to_string()); diff --git a/core/lib.rs b/core/lib.rs index 6ffef023c..04d29b767 100644 --- a/core/lib.rs +++ b/core/lib.rs @@ -21,6 +21,8 @@ mod translate; pub mod types; #[allow(dead_code)] mod util; +#[cfg(feature = "uuid")] +mod uuid; mod vdbe; mod vector; mod vtab; diff --git a/extensions/uuid/src/lib.rs b/core/uuid.rs similarity index 82% rename from extensions/uuid/src/lib.rs rename to core/uuid.rs index 31aeeae5b..56c0af647 100644 --- a/extensions/uuid/src/lib.rs +++ b/core/uuid.rs @@ -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")] diff --git a/extensions/core/README.md b/extensions/core/README.md index b4fe6414e..450113108 100644 --- a/extensions/core/README.md +++ b/extensions/core/README.md @@ -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" } diff --git a/extensions/uuid/Cargo.toml b/extensions/uuid/Cargo.toml deleted file mode 100644 index d94b241be..000000000 --- a/extensions/uuid/Cargo.toml +++ /dev/null @@ -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 } diff --git a/fuzz/Cargo.lock b/fuzz/Cargo.lock index e8a25f6a5..c9ea0ca83 100644 --- a/fuzz/Cargo.lock +++ b/fuzz/Cargo.lock @@ -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]] diff --git a/perf/latency/limbo/Cargo.lock b/perf/latency/limbo/Cargo.lock index cbd9013df..3e43e0125 100644 --- a/perf/latency/limbo/Cargo.lock +++ b/perf/latency/limbo/Cargo.lock @@ -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]] diff --git a/scripts/publish-crates.sh b/scripts/publish-crates.sh index ce539dfc4..6ad743c64 100755 --- a/scripts/publish-crates.sh +++ b/scripts/publish-crates.sh @@ -8,7 +8,6 @@ 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