sql: set PRAGMA temp_store=memory

On Android, there is to /tmp directory, so SQLite may throw
SQLITE_IOERR_GETTEMPPATH when trying to find a place for temporary
files. Storing temporary files in memory is a workaround that always
works (until out of memory).

See https://github.com/mozilla/mentat/issues/505 for discussion of a
similar issue.
This commit is contained in:
Alexander Krotov
2020-09-18 21:13:01 +03:00
committed by link2xt
parent efcdb45301
commit 238c4bb792

View File

@@ -678,7 +678,10 @@ async fn open(
.with_flags(open_flags)
.with_init(|c| {
c.execute_batch(&format!(
"PRAGMA secure_delete=on; PRAGMA busy_timeout = {};",
"PRAGMA secure_delete=on;
PRAGMA busy_timeout = {};
PRAGMA temp_store=memory; -- Avoid SQLITE_IOERR_GETTEMPPATH errors on Android
",
Duration::from_secs(10).as_millis()
))?;
Ok(())