Skip to content

Commit

Permalink
Enable only uuid by default, change tests back to account for this
Browse files Browse the repository at this point in the history
  • Loading branch information
PThorpe92 committed Jan 21, 2025
1 parent f13d035 commit 775d772
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 5 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ name = "limbo_core"
path = "lib.rs"

[features]
default = ["fs", "json", "uuid", "io_uring", "percentile"]
default = ["fs", "json", "uuid", "io_uring"]
fs = []
json = [
"dep:jsonb",
Expand All @@ -24,6 +24,7 @@ json = [
uuid = ["limbo_uuid/static"]
io_uring = ["dep:io-uring", "rustix/io_uring"]
percentile = ["limbo_percentile/static"]
regexp = ["limbo_regexp/static"]

[target.'cfg(target_os = "linux")'.dependencies]
io-uring = { version = "0.6.1", optional = true }
Expand Down Expand Up @@ -60,6 +61,7 @@ rand = "0.8.5"
bumpalo = { version = "3.16.0", features = ["collections", "boxed"] }
limbo_macros = { path = "../macros" }
limbo_uuid = { path = "../extensions/uuid", optional = true, features = ["static"] }
limbo_regexp = { path = "../extensions/regexp", optional = true, features = ["static"] }
limbo_percentile = { path = "../extensions/percentile", optional = true, features = ["static"] }
miette = "7.4.0"

Expand Down
10 changes: 10 additions & 0 deletions core/ext/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ impl Database {
self.register_uuid()?;
#[cfg(feature = "percentile")]
self.register_percentile()?;
#[cfg(feature = "regexp")]
self.register_regexp()?;
Ok(())
}

Expand All @@ -99,4 +101,12 @@ impl Database {
}
Ok(())
}
#[cfg(feature = "regexp")]
pub fn register_regexp(&self) -> Result<(), String> {
let ext_api = self.build_limbo_ext();
if unsafe { !limbo_regexp::register_extension_static(&ext_api).is_ok() } {
return Err("Failed to register regexp extension".to_string());
}
Ok(())
}
}
5 changes: 4 additions & 1 deletion extensions/regexp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ edition.workspace = true
license.workspace = true
repository.workspace = true

[features]
static = ["limbo_ext/static"]

[lib]
crate-type = ["cdylib", "lib"]


[dependencies]
limbo_ext = { path = "../core"}
limbo_ext = { path = "../core", features = ["static"] }
regex = "1.11.1"
log = "0.4.20"
17 changes: 14 additions & 3 deletions testing/extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ def assert_specific_time(result):

def test_uuid(pipe):
specific_time = "01945ca0-3189-76c0-9a8f-caf310fc8b8e"

# these are built into the binary, so we just test they work
run_test(
pipe,
Expand Down Expand Up @@ -210,7 +209,20 @@ def validate_percentile_disc(res):


def test_aggregates(pipe):
# also built-in
extension_path = "./target/debug/liblimbo_percentile.so"
# assert no function before extension loads
run_test(
pipe,
"SELECT median(1);",
returns_error,
"median agg function returns null when ext not loaded",
)
run_test(
pipe,
f".load {extension_path}",
returns_null,
"load extension command works properly",
)
run_test(
pipe,
"select median(value) from numbers;",
Expand Down Expand Up @@ -260,4 +272,3 @@ def main():

if __name__ == "__main__":
main()

0 comments on commit 775d772

Please sign in to comment.