Add example loading extension

This commit is contained in:
gwenn 2023-07-14 11:07:59 +02:00
parent 8051b048db
commit d7f2d55bfb
3 changed files with 24 additions and 0 deletions

View File

@ -67,6 +67,7 @@ jobs:
- name: loadable extension
run: cargo build --example loadable_extension --features "loadable_extension modern_sqlite functions vtab trace"
run: cargo run --example load_extension --features "load_extension bundled functions vtab trace"
# TODO: move into own action for better caching
- name: Static build

View File

@ -162,6 +162,10 @@ name = "loadable_extension"
crate-type = ["cdylib"]
required-features = ["loadable_extension", "modern_sqlite", "functions", "vtab", "trace"]
[[example]]
name = "load_extension"
required-features = ["load_extension", "bundled", "functions", "vtab", "trace"]
[package.metadata.docs.rs]
features = ["modern-full"]
all-features = false

View File

@ -0,0 +1,19 @@
//! Ensure loadable_extension.rs works.
use rusqlite::{Connection, Result};
fn main() -> Result<()> {
let db = Connection::open_in_memory()?;
unsafe {
db.load_extension_enable()?;
db.load_extension("target/debug/examples/libloadable_extension", None)?;
db.load_extension_disable()?;
}
let str = db.query_row("SELECT rusqlite_test_function()", [], |row| {
row.get::<_, String>(0)
})?;
assert_eq!(&str, "Rusqlite extension loaded correctly!");
Ok(())
}