Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2402 from hyperledger/update/update-rusqlite
Browse files Browse the repository at this point in the history
Update Rusqlite to version 0.25.3
  • Loading branch information
Patrik-Stas authored Jun 23, 2021
2 parents 9fbbb79 + 7626a7f commit efb7215
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 39 deletions.
99 changes: 71 additions & 28 deletions libindy/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions libindy/indy-api-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ libc = "0.2.66"
log = "0.4.8"
openssl = {version = "0.10", optional = true}
rust-base58 = {version = "0.0.4", optional = true}
rusqlite = {version = "0.20", optional = true} # Make sure rusqlite for android is also bumped with this. Rusqlite for android is at the bottom of this document.
rusqlite = {version = "0.25.3", optional = true} # Make sure rusqlite for android is also bumped with this. Rusqlite for android is at the bottom of this document.
serde = "1.0.99"
serde_json = "1.0.40"
serde_derive = "1.0.99"
Expand All @@ -28,4 +28,4 @@ optional = true
features = ["logger"]

[target.'cfg(any(target_os = "android", target_os = "ios"))'.dependencies]
rusqlite = { version = "0.20", features=["bundled"], optional = true }
rusqlite = { version = "0.25.3", features=["bundled"], optional = true }
2 changes: 1 addition & 1 deletion libindy/indy-api-types/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ impl From<rusqlite::Error> for IndyError {
rusqlite::Error::SqliteFailure(
rusqlite::ffi::Error { code: rusqlite::ffi::ErrorCode::ConstraintViolation, .. }, _) =>
err.to_indy(IndyErrorKind::WalletItemAlreadyExists, "Wallet item already exists"),
rusqlite::Error::SqliteFailure(rusqlite::ffi::Error { code: rusqlite::ffi::ErrorCode::SystemIOFailure, .. }, _) =>
rusqlite::Error::SqliteFailure(rusqlite::ffi::Error { code: rusqlite::ffi::ErrorCode::SystemIoFailure, .. }, _) =>
err.to_indy(IndyErrorKind::IOError, "IO error during access sqlite database"),
_ => err.to_indy(IndyErrorKind::InvalidState, "Unexpected sqlite error"),
}
Expand Down
4 changes: 2 additions & 2 deletions libindy/indy-wallet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ libc = "*"
log = "0.4.8"
owning_ref = "0.4"
rmp-serde = "0.13.7"
rusqlite = "0.20" # Make sure rusqlite for android is also bumped with this. Rusqlite for android is at the bottom of this document.
rusqlite = "0.25.3" # Make sure rusqlite for android is also bumped with this. Rusqlite for android is at the bottom of this document.
rust-base58 = "0.0.4"
serde = "1.0.99"
serde_json = "1.0.40"
Expand All @@ -26,4 +26,4 @@ rand = "0.7.0"
lazy_static = "1.3"

[target.'cfg(any(target_os = "android", target_os = "ios"))'.dependencies]
rusqlite = { version = "0.20", features=["bundled"] }
rusqlite = { version = "0.25.3", features=["bundled"] }
8 changes: 4 additions & 4 deletions libindy/indy-wallet/src/storage/default/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ impl WalletStorage for SQLiteStorage {
fn get_storage_metadata(&self) -> IndyResult<Vec<u8>> {
self.conn.query_row(
"SELECT value FROM metadata",
rusqlite::NO_PARAMS,
[],
|row| { row.get(0) },
).map_err(IndyError::from)
}
Expand Down Expand Up @@ -534,7 +534,7 @@ impl WalletStorage for SQLiteStorage {

let res: Option<usize> = Option::from(self.conn.query_row(
&query_string,
&query_arguments,
&*query_arguments,
|row| {
let x: i64 = row.get(0)?;
Ok(x as usize)
Expand Down Expand Up @@ -727,14 +727,14 @@ impl WalletStorageType for SQLiteStorageType {
// set journal mode to WAL, because it provides better performance.
let journal_mode: String = conn.query_row(
"PRAGMA journal_mode = WAL",
rusqlite::NO_PARAMS,
[],
|row| { row.get(0) },
)?;

// if journal mode is set to WAL, set synchronous to FULL for safety reasons.
// (synchronous = NORMAL with journal_mode = WAL does not guaranties durability).
if journal_mode.to_lowercase() == "wal" {
conn.execute("PRAGMA synchronous = FULL", rusqlite::NO_PARAMS)?;
conn.execute("PRAGMA synchronous = FULL", [])?;
}

Ok(Box::new(SQLiteStorage { conn: Rc::new(conn) }))
Expand Down
5 changes: 3 additions & 2 deletions libindy/indy-wallet/src/storage/default/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ impl<'conn> Transaction<'conn> {
TransactionBehavior::Deferred => "BEGIN DEFERRED",
TransactionBehavior::Immediate => "BEGIN IMMEDIATE",
TransactionBehavior::Exclusive => "BEGIN EXCLUSIVE",
_ => ""
};
conn.execute_batch(query)
.map(move |_| {
Expand Down Expand Up @@ -75,8 +76,8 @@ impl<'conn> Transaction<'conn> {
DropBehavior::Commit => self.commit_(),
DropBehavior::Rollback => self.rollback_(),
DropBehavior::Ignore => Ok(()),
DropBehavior::Panic => {
panic!("drop behaviour is set to panic".to_string());
_ => {
panic!("internal error: unsupported drop behaviour");
}
}
}
Expand Down

0 comments on commit efb7215

Please sign in to comment.