mirror of
https://github.com/fluencelabs/sqlite-wasm-connector
synced 2025-04-22 15:42:14 +00:00
expose heap limits as global functions
This commit is contained in:
parent
7852fed264
commit
36291cd6e8
@ -55,10 +55,6 @@ impl Connection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_memory_limit(limit: i64) -> i64 {
|
|
||||||
unsafe { ffi::sqlite3_hard_heap_limit64(limit) }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Execute a statement without processing the resulting rows if any.
|
/// Execute a statement without processing the resulting rows if any.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn execute<T: AsRef<str>>(&self, statement: T) -> Result<()> {
|
pub fn execute<T: AsRef<str>>(&self, statement: T) -> Result<()> {
|
||||||
@ -93,6 +89,7 @@ impl Connection {
|
|||||||
|
|
||||||
/// Create a prepared statement.
|
/// Create a prepared statement.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
pub fn prepare<T: AsRef<str>>(&self, statement: T) -> Result<Statement> {
|
||||||
pub fn prepare<T: AsRef<str>>(&self, statement: T) -> Result<Statement> {
|
pub fn prepare<T: AsRef<str>>(&self, statement: T) -> Result<Statement> {
|
||||||
crate::statement::new(self.raw, statement)
|
crate::statement::new(self.raw, statement)
|
||||||
}
|
}
|
||||||
|
21
src/lib.rs
21
src/lib.rs
@ -304,3 +304,24 @@ fn last_error(raw: ffi::Sqlite3DbHandle) -> Option<Error> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// From the SQLite docs:
|
||||||
|
///
|
||||||
|
/// The sqlite3_soft_heap_limit64() interface sets and/or queries the soft limit on the amount of
|
||||||
|
/// heap memory that may be allocated by SQLite. SQLite strives to keep heap memory utilization
|
||||||
|
/// below the soft heap limit by reducing the number of pages held in the page cache as heap memory
|
||||||
|
/// usages approaches the limit. The soft heap limit is "soft" because even though SQLite strives
|
||||||
|
/// to stay below the limit, it will exceed the limit rather than generate an SQLITE_NOMEM error.
|
||||||
|
/// In other words, the soft heap limit is advisory only.
|
||||||
|
pub fn soft_heap_limit64(limit: i64) -> i64 {
|
||||||
|
unsafe { ffi::sqlite3_hard_heap_limit64(limit) }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// From the SQLite docs:
|
||||||
|
///
|
||||||
|
/// This interface sets a hard upper bound of N bytes on the amount of memory that will be
|
||||||
|
/// allocated. The set_hard_heap_limit64 interface is similar to soft_heap_limit64
|
||||||
|
/// except that memory allocations will fail when the hard heap limit is reached.
|
||||||
|
pub fn set_hard_heap_limit64(limit: i64) -> i64 {
|
||||||
|
unsafe { ffi::sqlite3_hard_heap_limit64(limit) }
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user