mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-22 16:29:20 +08:00
Add Connection::release_memory
method
This is behind a new `release_memory` feature flag. It simply calls `sqlite3_db_release_memory` on the raw handle.
This commit is contained in:
parent
7fb2d378af
commit
4d06d2222f
@ -43,6 +43,8 @@ collation = []
|
||||
functions = ["libsqlite3-sys/min_sqlite_version_3_7_7"]
|
||||
# sqlite3_log: 3.6.23 (2010-03-09)
|
||||
trace = ["libsqlite3-sys/min_sqlite_version_3_6_23"]
|
||||
# sqlite3_db_release_memory: 3.7.10 (2012-01-16)
|
||||
release_memory = ["libsqlite3-sys/min_sqlite_version_3_7_16"]
|
||||
bundled = ["libsqlite3-sys/bundled", "modern_sqlite"]
|
||||
bundled-sqlcipher = ["libsqlite3-sys/bundled-sqlcipher", "bundled"]
|
||||
bundled-sqlcipher-vendored-openssl = ["libsqlite3-sys/bundled-sqlcipher-vendored-openssl", "bundled-sqlcipher"]
|
||||
|
15
src/lib.rs
15
src/lib.rs
@ -595,6 +595,21 @@ impl Connection {
|
||||
self.path.as_deref()
|
||||
}
|
||||
|
||||
/// Attempts to free as much heap memory as possible from the database
|
||||
/// connection.
|
||||
///
|
||||
/// This calls [`sqlite3_db_release_memory`](https://www.sqlite.org/c3ref/db_release_memory.html).
|
||||
#[inline]
|
||||
#[cfg(feature = "release_memory")]
|
||||
pub fn release_memory(&self) -> Result<()> {
|
||||
unsafe {
|
||||
match crate::ffi::sqlite3_db_release_memory(self.handle()) {
|
||||
ffi::SQLITE_OK => Ok(()),
|
||||
error => Err(error_from_sqlite_code(error)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Convenience method to prepare and execute a single SQL statement with
|
||||
/// named parameter(s).
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user