mirror of
https://github.com/chatmail/core.git
synced 2026-04-17 21:46:35 +03:00
Update rusqlite from 0.24 to 0.25
This commit is contained in:
@@ -2,13 +2,13 @@
|
|||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
- switch back from `sqlx` to `rusqlite` due to performance regressions #2380 #2381
|
- switch back from `sqlx` to `rusqlite` due to performance regressions #2380 #2381 #2385
|
||||||
|
|
||||||
- global search performance improvement #2364 #2365 #2366
|
- global search performance improvement #2364 #2365 #2366
|
||||||
|
|
||||||
- improve SQLite performance with `PRAGMA synchronous=normal` #2382
|
- improve SQLite performance with `PRAGMA synchronous=normal` #2382
|
||||||
|
|
||||||
- python: fix building of bindings against system-wide install of `libdeltachat` #2383
|
- python: fix building of bindings against system-wide install of `libdeltachat` #2383 #2385
|
||||||
|
|
||||||
- fix creation of many delete jobs when being offline #2372
|
- fix creation of many delete jobs when being offline #2372
|
||||||
|
|
||||||
|
|||||||
12
Cargo.lock
generated
12
Cargo.lock
generated
@@ -2089,9 +2089,9 @@ checksum = "c7d73b3f436185384286bd8098d17ec07c9a7d2388a6599f824d8502b529702a"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libsqlite3-sys"
|
name = "libsqlite3-sys"
|
||||||
version = "0.20.1"
|
version = "0.22.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "64d31059f22935e6c31830db5249ba2b7ecd54fd73a9909286f0a67aa55c2fbd"
|
checksum = "19cb1effde5f834799ac5e5ef0e40d45027cd74f271b1de786ba8abb30e2164d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cc",
|
"cc",
|
||||||
"pkg-config",
|
"pkg-config",
|
||||||
@@ -2813,9 +2813,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "r2d2_sqlite"
|
name = "r2d2_sqlite"
|
||||||
version = "0.17.0"
|
version = "0.18.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "227ab35ff4cbb01fa76da8f062590fe677b93c8d9e8415eb5fa981f2c1dba9d8"
|
checksum = "9d24607049214c5e42d3df53ac1d8a23c34cc6a5eefe3122acb2c72174719959"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"r2d2",
|
"r2d2",
|
||||||
"rusqlite",
|
"rusqlite",
|
||||||
@@ -3064,9 +3064,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rusqlite"
|
name = "rusqlite"
|
||||||
version = "0.24.2"
|
version = "0.25.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d5f38ee71cbab2c827ec0ac24e76f82eca723cee92c509a65f67dee393c25112"
|
checksum = "fbc783b7ddae608338003bac1fa00b6786a75a9675fbd8e87243ecfdea3f6ed2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"fallible-iterator",
|
"fallible-iterator",
|
||||||
|
|||||||
@@ -52,11 +52,11 @@ percent-encoding = "2.0"
|
|||||||
pgp = { version = "0.7.0", default-features = false }
|
pgp = { version = "0.7.0", default-features = false }
|
||||||
pretty_env_logger = { version = "0.4.0", optional = true }
|
pretty_env_logger = { version = "0.4.0", optional = true }
|
||||||
quick-xml = "0.18.1"
|
quick-xml = "0.18.1"
|
||||||
r2d2 = "0.8.5"
|
r2d2 = "0.8.9"
|
||||||
r2d2_sqlite = "0.17.0"
|
r2d2_sqlite = "0.18.0"
|
||||||
rand = "0.7.0"
|
rand = "0.7.0"
|
||||||
regex = "1.1.6"
|
regex = "1.1.6"
|
||||||
rusqlite = { version = "0.24", features = ["bundled"] }
|
rusqlite = { version = "0.25", features = ["bundled"] }
|
||||||
rust-hsluv = "0.1.4"
|
rust-hsluv = "0.1.4"
|
||||||
rustyline = { version = "4.1.0", optional = true }
|
rustyline = { version = "4.1.0", optional = true }
|
||||||
sanitize-filename = "0.3.0"
|
sanitize-filename = "0.3.0"
|
||||||
|
|||||||
14
src/chat.rs
14
src/chat.rs
@@ -441,14 +441,14 @@ impl ChatId {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn get_draft_msg_id(self, context: &Context) -> Result<Option<MsgId>, Error> {
|
async fn get_draft_msg_id(self, context: &Context) -> Result<Option<MsgId>, Error> {
|
||||||
context
|
let msg_id: Option<MsgId> = context
|
||||||
.sql
|
.sql
|
||||||
.query_get_value::<MsgId>(
|
.query_get_value(
|
||||||
"SELECT id FROM msgs WHERE chat_id=? AND state=?;",
|
"SELECT id FROM msgs WHERE chat_id=? AND state=?;",
|
||||||
paramsv![self, MessageState::OutDraft],
|
paramsv![self, MessageState::OutDraft],
|
||||||
)
|
)
|
||||||
.await
|
.await?;
|
||||||
.map_err(Into::into)
|
Ok(msg_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn get_draft(self, context: &Context) -> Result<Option<Message>, Error> {
|
pub async fn get_draft(self, context: &Context) -> Result<Option<Message>, Error> {
|
||||||
@@ -2371,9 +2371,9 @@ pub(crate) async fn reset_gossiped_timestamp(
|
|||||||
/// Get timestamp of the last gossip sent in the chat.
|
/// Get timestamp of the last gossip sent in the chat.
|
||||||
/// Zero return value means that gossip was never sent.
|
/// Zero return value means that gossip was never sent.
|
||||||
pub async fn get_gossiped_timestamp(context: &Context, chat_id: ChatId) -> Result<i64, Error> {
|
pub async fn get_gossiped_timestamp(context: &Context, chat_id: ChatId) -> Result<i64, Error> {
|
||||||
let timestamp = context
|
let timestamp: Option<i64> = context
|
||||||
.sql
|
.sql
|
||||||
.query_get_value::<i64>(
|
.query_get_value(
|
||||||
"SELECT gossiped_timestamp FROM chats WHERE id=?;",
|
"SELECT gossiped_timestamp FROM chats WHERE id=?;",
|
||||||
paramsv![chat_id],
|
paramsv![chat_id],
|
||||||
)
|
)
|
||||||
@@ -2762,7 +2762,7 @@ pub async fn forward_msgs(
|
|||||||
"SELECT id FROM msgs WHERE id IN({}) ORDER BY timestamp,id",
|
"SELECT id FROM msgs WHERE id IN({}) ORDER BY timestamp,id",
|
||||||
msg_ids.iter().map(|_| "?").join(",")
|
msg_ids.iter().map(|_| "?").join(",")
|
||||||
),
|
),
|
||||||
msg_ids.iter().map(|v| v as &dyn crate::ToSql).collect(),
|
rusqlite::params_from_iter(msg_ids),
|
||||||
|row| row.get::<_, MsgId>(0),
|
|row| row.get::<_, MsgId>(0),
|
||||||
|ids| ids.collect::<Result<Vec<_>, _>>().map_err(Into::into),
|
|ids| ids.collect::<Result<Vec<_>, _>>().map_err(Into::into),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -499,7 +499,7 @@ impl Contact {
|
|||||||
if update_name {
|
if update_name {
|
||||||
// Update the contact name also if it is used as a group name.
|
// Update the contact name also if it is used as a group name.
|
||||||
// This is one of the few duplicated data, however, getting the chat list is easier this way.
|
// This is one of the few duplicated data, however, getting the chat list is easier this way.
|
||||||
let chat_id = context.sql.query_get_value::<i32>(
|
let chat_id: Option<i32> = context.sql.query_get_value(
|
||||||
"SELECT id FROM chats WHERE type=? AND id IN(SELECT chat_id FROM chats_contacts WHERE contact_id=?)",
|
"SELECT id FROM chats WHERE type=? AND id IN(SELECT chat_id FROM chats_contacts WHERE contact_id=?)",
|
||||||
paramsv![Chattype::Single, isize::try_from(row_id)?]
|
paramsv![Chattype::Single, isize::try_from(row_id)?]
|
||||||
).await?;
|
).await?;
|
||||||
|
|||||||
@@ -853,7 +853,7 @@ async fn kill_ids(context: &Context, job_ids: &[u32]) -> sql::Result<()> {
|
|||||||
);
|
);
|
||||||
context
|
context
|
||||||
.sql
|
.sql
|
||||||
.execute(q, job_ids.iter().map(|i| i as &dyn crate::ToSql).collect())
|
.execute(q, rusqlite::params_from_iter(job_ids))
|
||||||
.await?;
|
.await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -382,7 +382,7 @@ impl Message {
|
|||||||
),
|
),
|
||||||
paramsv![id],
|
paramsv![id],
|
||||||
|row| {
|
|row| {
|
||||||
let text = match row.get_raw("txt") {
|
let text = match row.get_ref("txt")? {
|
||||||
rusqlite::types::ValueRef::Text(buf) => {
|
rusqlite::types::ValueRef::Text(buf) => {
|
||||||
match String::from_utf8(buf.to_vec()) {
|
match String::from_utf8(buf.to_vec()) {
|
||||||
Ok(t) => t,
|
Ok(t) => t,
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ impl Peerstate {
|
|||||||
async fn from_stmt(
|
async fn from_stmt(
|
||||||
context: &Context,
|
context: &Context,
|
||||||
query: &str,
|
query: &str,
|
||||||
params: Vec<&dyn crate::ToSql>,
|
params: impl rusqlite::Params,
|
||||||
) -> Result<Option<Peerstate>> {
|
) -> Result<Option<Peerstate>> {
|
||||||
let peerstate = context
|
let peerstate = context
|
||||||
.sql
|
.sql
|
||||||
|
|||||||
22
src/sql.rs
22
src/sql.rs
@@ -25,10 +25,10 @@ use crate::stock_str;
|
|||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! paramsv {
|
macro_rules! paramsv {
|
||||||
() => {
|
() => {
|
||||||
Vec::new()
|
rusqlite::params_from_iter(Vec::<&dyn $crate::ToSql>::new())
|
||||||
};
|
};
|
||||||
($($param:expr),+ $(,)?) => {
|
($($param:expr),+ $(,)?) => {
|
||||||
vec![$(&$param as &dyn $crate::ToSql),+]
|
rusqlite::params_from_iter(vec![$(&$param as &dyn $crate::ToSql),+])
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,7 +194,7 @@ impl Sql {
|
|||||||
pub async fn execute(
|
pub async fn execute(
|
||||||
&self,
|
&self,
|
||||||
query: impl AsRef<str>,
|
query: impl AsRef<str>,
|
||||||
params: Vec<&dyn crate::ToSql>,
|
params: impl rusqlite::Params,
|
||||||
) -> Result<usize> {
|
) -> Result<usize> {
|
||||||
let conn = self.get_conn().await?;
|
let conn = self.get_conn().await?;
|
||||||
let res = conn.execute(query.as_ref(), params)?;
|
let res = conn.execute(query.as_ref(), params)?;
|
||||||
@@ -205,7 +205,7 @@ impl Sql {
|
|||||||
pub async fn insert(
|
pub async fn insert(
|
||||||
&self,
|
&self,
|
||||||
query: impl AsRef<str>,
|
query: impl AsRef<str>,
|
||||||
params: Vec<&dyn crate::ToSql>,
|
params: impl rusqlite::Params,
|
||||||
) -> anyhow::Result<usize> {
|
) -> anyhow::Result<usize> {
|
||||||
let conn = self.get_conn().await?;
|
let conn = self.get_conn().await?;
|
||||||
conn.execute(query.as_ref(), params)?;
|
conn.execute(query.as_ref(), params)?;
|
||||||
@@ -218,7 +218,7 @@ impl Sql {
|
|||||||
pub async fn query_map<T, F, G, H>(
|
pub async fn query_map<T, F, G, H>(
|
||||||
&self,
|
&self,
|
||||||
sql: impl AsRef<str>,
|
sql: impl AsRef<str>,
|
||||||
params: Vec<&dyn crate::ToSql>,
|
params: impl rusqlite::Params,
|
||||||
f: F,
|
f: F,
|
||||||
mut g: G,
|
mut g: G,
|
||||||
) -> Result<H>
|
) -> Result<H>
|
||||||
@@ -230,7 +230,7 @@ impl Sql {
|
|||||||
|
|
||||||
let conn = self.get_conn().await?;
|
let conn = self.get_conn().await?;
|
||||||
let mut stmt = conn.prepare(sql)?;
|
let mut stmt = conn.prepare(sql)?;
|
||||||
let res = stmt.query_map(¶ms, f)?;
|
let res = stmt.query_map(params, f)?;
|
||||||
g(res)
|
g(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,7 +276,7 @@ impl Sql {
|
|||||||
pub async fn count(
|
pub async fn count(
|
||||||
&self,
|
&self,
|
||||||
query: impl AsRef<str>,
|
query: impl AsRef<str>,
|
||||||
params: Vec<&dyn crate::ToSql>,
|
params: impl rusqlite::Params,
|
||||||
) -> anyhow::Result<usize> {
|
) -> anyhow::Result<usize> {
|
||||||
let count: isize = self.query_row(query, params, |row| row.get(0)).await?;
|
let count: isize = self.query_row(query, params, |row| row.get(0)).await?;
|
||||||
Ok(usize::try_from(count)?)
|
Ok(usize::try_from(count)?)
|
||||||
@@ -284,7 +284,7 @@ impl Sql {
|
|||||||
|
|
||||||
/// Used for executing `SELECT COUNT` statements only. Returns `true`, if the count is at least
|
/// Used for executing `SELECT COUNT` statements only. Returns `true`, if the count is at least
|
||||||
/// one, `false` otherwise.
|
/// one, `false` otherwise.
|
||||||
pub async fn exists(&self, sql: &str, params: Vec<&dyn crate::ToSql>) -> Result<bool> {
|
pub async fn exists(&self, sql: &str, params: impl rusqlite::Params) -> Result<bool> {
|
||||||
let count = self.count(sql, params).await?;
|
let count = self.count(sql, params).await?;
|
||||||
Ok(count > 0)
|
Ok(count > 0)
|
||||||
}
|
}
|
||||||
@@ -293,7 +293,7 @@ impl Sql {
|
|||||||
pub async fn query_row<T, F>(
|
pub async fn query_row<T, F>(
|
||||||
&self,
|
&self,
|
||||||
query: impl AsRef<str>,
|
query: impl AsRef<str>,
|
||||||
params: Vec<&dyn crate::ToSql>,
|
params: impl rusqlite::Params,
|
||||||
f: F,
|
f: F,
|
||||||
) -> Result<T>
|
) -> Result<T>
|
||||||
where
|
where
|
||||||
@@ -377,7 +377,7 @@ impl Sql {
|
|||||||
pub async fn query_row_optional<T, F>(
|
pub async fn query_row_optional<T, F>(
|
||||||
&self,
|
&self,
|
||||||
sql: impl AsRef<str>,
|
sql: impl AsRef<str>,
|
||||||
params: Vec<&dyn crate::ToSql>,
|
params: impl rusqlite::Params,
|
||||||
f: F,
|
f: F,
|
||||||
) -> anyhow::Result<Option<T>>
|
) -> anyhow::Result<Option<T>>
|
||||||
where
|
where
|
||||||
@@ -402,7 +402,7 @@ impl Sql {
|
|||||||
pub async fn query_get_value<T>(
|
pub async fn query_get_value<T>(
|
||||||
&self,
|
&self,
|
||||||
query: &str,
|
query: &str,
|
||||||
params: Vec<&dyn crate::ToSql>,
|
params: impl rusqlite::Params,
|
||||||
) -> anyhow::Result<Option<T>>
|
) -> anyhow::Result<Option<T>>
|
||||||
where
|
where
|
||||||
T: rusqlite::types::FromSql,
|
T: rusqlite::types::FromSql,
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ pub async fn lookup(
|
|||||||
Some(chat_id) => {
|
Some(chat_id) => {
|
||||||
context
|
context
|
||||||
.sql
|
.sql
|
||||||
.query_get_value::<String>(
|
.query_get_value(
|
||||||
"SELECT token FROM tokens WHERE namespc=? AND foreign_id=?;",
|
"SELECT token FROM tokens WHERE namespc=? AND foreign_id=?;",
|
||||||
paramsv![namespace, chat_id],
|
paramsv![namespace, chat_id],
|
||||||
)
|
)
|
||||||
@@ -73,7 +73,7 @@ pub async fn lookup(
|
|||||||
None => {
|
None => {
|
||||||
context
|
context
|
||||||
.sql
|
.sql
|
||||||
.query_get_value::<String>(
|
.query_get_value(
|
||||||
"SELECT token FROM tokens WHERE namespc=? AND foreign_id=0;",
|
"SELECT token FROM tokens WHERE namespc=? AND foreign_id=0;",
|
||||||
paramsv![namespace],
|
paramsv![namespace],
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user