Debian Codegraph @

third_party/rust/rusqlite/tests/deny_single_threaded_sqlite_config.rs

raw
1 //! Ensure we reject connections when SQLite is in single-threaded mode, as it
2 //! would violate safety if multiple Rust threads tried to use connections.
3
4 #[cfg(not(feature = "loadable_extension"))]
5 #[test]
6 fn test_error_when_singlethread_mode() {
7 use rusqlite::ffi;
8 use rusqlite::Connection;
9 // put SQLite into single-threaded mode
10 unsafe {
11 // Note: macOS system SQLite seems to return an error if you attempt to
12 // reconfigure to single-threaded mode.
13 if ffi::sqlite3_config(ffi::SQLITE_CONFIG_SINGLETHREAD) != ffi::SQLITE_OK {
14 return;
15 }
16 assert_eq!(ffi::sqlite3_initialize(), ffi::SQLITE_OK);
17 }
18 let res = Connection::open_in_memory();
19 res.unwrap_err();
20 }