2023-07-14 17:07:59 +08:00
|
|
|
//! Ensure loadable_extension.rs works.
|
|
|
|
|
|
|
|
use rusqlite::{Connection, Result};
|
|
|
|
|
|
|
|
fn main() -> Result<()> {
|
|
|
|
let db = Connection::open_in_memory()?;
|
|
|
|
|
|
|
|
unsafe {
|
|
|
|
db.load_extension_enable()?;
|
2023-07-18 23:45:28 +08:00
|
|
|
#[cfg(not(windows))]
|
2023-07-14 17:07:59 +08:00
|
|
|
db.load_extension("target/debug/examples/libloadable_extension", None)?;
|
2023-07-18 23:45:28 +08:00
|
|
|
#[cfg(windows)]
|
|
|
|
db.load_extension("target/debug/examples/loadable_extension", None)?;
|
2023-07-14 17:07:59 +08:00
|
|
|
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(())
|
|
|
|
}
|