From 158910484191dee013b299d130f48078f376119b Mon Sep 17 00:00:00 2001 From: Grisha Kruglov Date: Wed, 20 Dec 2017 01:52:09 -0500 Subject: [PATCH] Force SQLite temp files to be stored in memory (#505) r=rnewman (#506) * Force SQLite temp files to be stored in memory (#505) r=rnewman --- db/src/db.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/db/src/db.rs b/db/src/db.rs index 8b430548..ccdfc7d9 100644 --- a/db/src/db.rs +++ b/db/src/db.rs @@ -69,12 +69,19 @@ pub fn new_connection(uri: T) -> rusqlite::Result where _ => rusqlite::Connection::open(uri)?, }; + /// See https://github.com/mozilla/mentat/issues/505 for details on temp_store + /// pragma and how it might interact together with consumers such as Firefox. + /// temp_store=2 is currently present to force SQLite to store temp files in memory. + /// Some of the platforms we support do not have a tmp partition (e.g. Android) + /// necessary to store temp files on disk. Ideally, consumers should be able to + /// override this behaviour (see issue 505). conn.execute_batch(" PRAGMA page_size=32768; PRAGMA journal_mode=wal; PRAGMA wal_autocheckpoint=32; PRAGMA journal_size_limit=3145728; PRAGMA foreign_keys=ON; + PRAGMA temp_store=2; ")?; Ok(conn)