From 90e56e5ad56a14ebc5a262ebcbe7e0c72259c310 Mon Sep 17 00:00:00 2001 From: Lucille Date: Tue, 26 Oct 2021 12:28:49 +0100 Subject: [PATCH 1/3] Add support for serialized threading mode --- sqlx-core/src/sqlite/connection/establish.rs | 10 +++++++--- sqlx-core/src/sqlite/options/mod.rs | 12 ++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/sqlx-core/src/sqlite/connection/establish.rs b/sqlx-core/src/sqlite/connection/establish.rs index 401a673c16..ce8105a652 100644 --- a/sqlx-core/src/sqlite/connection/establish.rs +++ b/sqlx-core/src/sqlite/connection/establish.rs @@ -7,8 +7,8 @@ use crate::{ }; use libsqlite3_sys::{ sqlite3_busy_timeout, sqlite3_extended_result_codes, sqlite3_open_v2, SQLITE_OK, - SQLITE_OPEN_CREATE, SQLITE_OPEN_MEMORY, SQLITE_OPEN_NOMUTEX, SQLITE_OPEN_PRIVATECACHE, - SQLITE_OPEN_READONLY, SQLITE_OPEN_READWRITE, SQLITE_OPEN_SHAREDCACHE, + SQLITE_OPEN_CREATE, SQLITE_OPEN_FULLMUTEX, SQLITE_OPEN_MEMORY, SQLITE_OPEN_NOMUTEX, + SQLITE_OPEN_PRIVATECACHE, SQLITE_OPEN_READONLY, SQLITE_OPEN_READWRITE, SQLITE_OPEN_SHAREDCACHE, }; use sqlx_rt::blocking; use std::io; @@ -33,7 +33,11 @@ pub(crate) async fn establish(options: &SqliteConnectOptions) -> Result, Cow<'static, str>>, + pub(crate) serialized: bool, } impl Default for SqliteConnectOptions { @@ -109,6 +110,7 @@ impl SqliteConnectOptions { log_settings: Default::default(), immutable: false, pragmas, + serialized: false, } } @@ -234,4 +236,14 @@ impl SqliteConnectOptions { self.immutable = immutable; self } + + /// Sets the [threading mode](https://www.sqlite.org/threadsafe.html) for the database connection. + /// + /// The default setting if `false`, corersponding to using `OPEN_NOMUTEX`, if `true` then `OPEN_FULLMUTEX`. + /// + /// See [open](https://www.sqlite.org/c3ref/open.html) for more details. + pub fn serialized(mut self, serialized: bool) -> Self { + self.serialized = serialized; + serialized + } } From c9d12f3a6350eac3cdd9a4ed7b345ead48abcccd Mon Sep 17 00:00:00 2001 From: Lucille Date: Tue, 26 Oct 2021 12:35:11 +0100 Subject: [PATCH 2/3] Typos --- sqlx-core/src/sqlite/options/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sqlx-core/src/sqlite/options/mod.rs b/sqlx-core/src/sqlite/options/mod.rs index c62494480b..0afdf1afe6 100644 --- a/sqlx-core/src/sqlite/options/mod.rs +++ b/sqlx-core/src/sqlite/options/mod.rs @@ -239,7 +239,7 @@ impl SqliteConnectOptions { /// Sets the [threading mode](https://www.sqlite.org/threadsafe.html) for the database connection. /// - /// The default setting if `false`, corersponding to using `OPEN_NOMUTEX`, if `true` then `OPEN_FULLMUTEX`. + /// The default setting is `false` corersponding to using `OPEN_NOMUTEX`, if `true` then `OPEN_FULLMUTEX`. /// /// See [open](https://www.sqlite.org/c3ref/open.html) for more details. pub fn serialized(mut self, serialized: bool) -> Self { From 2cb9fd79b1156cdb8e38d8ae029187ca6ef0ad1f Mon Sep 17 00:00:00 2001 From: Lucille Date: Tue, 26 Oct 2021 12:49:43 +0100 Subject: [PATCH 3/3] Fix build --- sqlx-core/src/sqlite/options/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sqlx-core/src/sqlite/options/mod.rs b/sqlx-core/src/sqlite/options/mod.rs index 0afdf1afe6..9db122f355 100644 --- a/sqlx-core/src/sqlite/options/mod.rs +++ b/sqlx-core/src/sqlite/options/mod.rs @@ -244,6 +244,6 @@ impl SqliteConnectOptions { /// See [open](https://www.sqlite.org/c3ref/open.html) for more details. pub fn serialized(mut self, serialized: bool) -> Self { self.serialized = serialized; - serialized + self } }