fn compile_options() -> Vec<String> {
let conn = rusqlite::Connection::open_in_memory().expect("open in-memory connection");
let mut stmt = conn
.prepare("PRAGMA compile_options")
.expect("prepare compile_options");
stmt.query_map([], |row| row.get::<_, String>(0))
.expect("query compile_options")
.collect::<Result<Vec<_>, _>>()
.expect("read compile_options")
}
fn assert_bundled_build_is_visible(options: &[String]) {
assert!(
options.iter().any(|o| o == "ENABLE_FTS5"),
"compile_options did not list ENABLE_FTS5, so this read is not seeing the bundled SQLite: {options:?}"
);
}
#[test]
fn bundled_sqlite_keeps_no_global_memory_statistics() {
let options = compile_options();
assert_bundled_build_is_visible(&options);
assert!(
options.iter().any(|o| o == "DEFAULT_MEMSTATUS=0"),
"SQLite was built with memory statistics on, so every allocation takes one process-wide \
mutex; build with LIBSQLITE3_FLAGS containing -DSQLITE_DEFAULT_MEMSTATUS=0 as \
.cargo/config.toml sets it: {options:?}"
);
}
#[test]
fn bundled_sqlite_uses_per_connection_page_caches() {
let options = compile_options();
assert_bundled_build_is_visible(&options);
assert!(
!options.iter().any(|o| o == "ENABLE_MEMORY_MANAGEMENT"),
"SQLite was built with ENABLE_MEMORY_MANAGEMENT (one process-wide page cache behind one \
mutex); build with LIBSQLITE3_FLAGS containing -USQLITE_ENABLE_MEMORY_MANAGEMENT as \
.cargo/config.toml sets it: {options:?}"
);
}