Skip to content

Commit f0d73fd

Browse files
committed
sql: enable shared cache
1 parent 1394b1b commit f0d73fd

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

Cargo.lock

Lines changed: 4 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ serde = { version = "1.0", features = ["derive"] }
6060
sha-1 = "0.9.3"
6161
sha2 = "0.9.0"
6262
smallvec = "1.0.0"
63-
sqlx = { version = "0.5.2", features = ["runtime-async-std-native-tls", "sqlite"] }
63+
sqlx = { git = "https://github.com/deltachat/sqlx", branch = "master", features = ["runtime-async-std-native-tls", "sqlite"] }
6464
# keep in sync with sqlx
6565
libsqlite3-sys = { version = "0.22.0", default-features = false, features = [ "pkg-config", "vcpkg", "bundled" ] }
6666
stop-token = { version = "0.1.1", features = ["unstable"] }

src/sql/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ impl Sql {
8686
.read_only(false)
8787
.busy_timeout(Duration::from_secs(100))
8888
.create_if_missing(true)
89+
.shared_cache(true)
8990
.synchronous(SqliteSynchronous::Normal);
9091

9192
PoolOptions::<Sqlite>::new()
@@ -112,6 +113,7 @@ PRAGMA temp_store=memory; -- Avoid SQLITE_IOERR_GETTEMPPATH errors on Android
112113
.journal_mode(SqliteJournalMode::Wal)
113114
.filename(dbfile.as_ref())
114115
.read_only(readonly)
116+
.shared_cache(true)
115117
.busy_timeout(Duration::from_secs(100))
116118
.synchronous(SqliteSynchronous::Normal);
117119

@@ -122,6 +124,7 @@ PRAGMA temp_store=memory; -- Avoid SQLITE_IOERR_GETTEMPPATH errors on Android
122124
let q = r#"
123125
PRAGMA temp_store=memory; -- Avoid SQLITE_IOERR_GETTEMPPATH errors on Android
124126
PRAGMA query_only=1; -- Protect against writes even in read-write mode
127+
PRAGMA read_uncommitted = true; -- This helps avoid "table locked" errors in shared cache mode
125128
"#;
126129

127130
conn.execute_many(sqlx::query(q))

0 commit comments

Comments
 (0)