diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2019-08-23 13:26:08 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2019-08-23 13:26:08 +0200 |
commit | c678874604b1a48a9aa46276e001ed540a823c06 (patch) | |
tree | 56befd03009ed1190b5b2f1e97e0c2b4784c7bff | |
parent | 919f9823325064f4a6a579a0307775b97706d9ff (diff) |
Bump rusqlite to 0.19.
- 0.20 requires a newer rustc.
-rw-r--r-- | Cargo.lock | 27 | ||||
-rw-r--r-- | store/Cargo.toml | 2 | ||||
-rw-r--r-- | store/src/backend/log.rs | 30 | ||||
-rw-r--r-- | store/src/backend/mod.rs | 89 |
4 files changed, 89 insertions, 59 deletions
@@ -534,6 +534,16 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] +name = "fallible-iterator" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "fallible-streaming-iterator" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] name = "filetime" version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -832,7 +842,7 @@ dependencies = [ [[package]] name = "libsqlite3-sys" -version = "0.9.3" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "pkg-config 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1464,12 +1474,15 @@ dependencies = [ [[package]] name = "rusqlite" -version = "0.14.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "libsqlite3-sys 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", + "fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "fallible-streaming-iterator 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", + "libsqlite3-sys 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1739,7 +1752,7 @@ dependencies = [ "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "rusqlite 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rusqlite 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)", "sequoia-core 0.9.0", "sequoia-ipc 0.9.0", "sequoia-net 0.9.0", @@ -2385,6 +2398,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2" "checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1" "checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" +"checksum fallible-iterator 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" +"checksum fallible-streaming-iterator 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a" "checksum filetime 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "6bd7380b54ced79dda72ecc35cc4fbbd1da6bba54afaa37e96fd1c2a308cd469" "checksum fixedbitset 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "86d4de0081402f5e88cdac65c8dcdcc73118c1a7a465e2a05f0da05843a8ea33" "checksum flate2 1.0.11 (registry+https://github.com/rust-lang/crates.io-index)" = "2adaffba6388640136149e18ed080b77a78611c1e1d6de75aedcdf78df5d4682" @@ -2418,7 +2433,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bc5729f27f159ddd61f4df6228e827e86643d4d3e7c32183cb30a1c08f604a14" "checksum libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)" = "34fcd2c08d2f832f376f4173a231990fa5aef4e99fb569867318a227ef4c06ba" "checksum libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753" -"checksum libsqlite3-sys 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d3711dfd91a1081d2458ad2d06ea30a8755256e74038be2ad927d94e1c955ca8" +"checksum libsqlite3-sys 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "72b1e07fcc60484f42e246f0cf1f133940c98117c81b2cefcdf71be288069680" "checksum linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83" "checksum lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c" "checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" @@ -2492,7 +2507,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" "checksum rgb 0.8.14 (registry+https://github.com/rust-lang/crates.io-index)" = "2089e4031214d129e201f8c3c8c2fe97cd7322478a0d1cdf78e7029b0042efdb" "checksum rpassword 4.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f072d931f11a96546efd97642e1e75e807345aced86b947f9239102f262d0fcd" -"checksum rusqlite 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c9d9118f1ce84d8d0b67f9779936432fb42bb620cef2122409d786892cce9a3c" +"checksum rusqlite 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6ebca2e7e3deb7241b7fa5929c088548c590728b1b740c479594c23f813eb8a7" "checksum rust-argon2 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4ca4eaef519b494d1f2848fc602d18816fed808a981aedf4f1f00ceb7c9d32cf" "checksum rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" diff --git a/store/Cargo.toml b/store/Cargo.toml index c26d5cb1..71d5d5b0 100644 --- a/store/Cargo.toml +++ b/store/Cargo.toml @@ -36,7 +36,7 @@ capnp-rpc = "0.10" failure = "0.1.2" futures = "0.1.17" rand = { version = "0.6", default-features = false } -rusqlite = "0.14" +rusqlite = "0.19" time = "0.1.38" tokio-core = "0.1.10" tokio-io = "0.1.4" diff --git a/store/src/backend/log.rs b/store/src/backend/log.rs index fe06a4e5..a2ddcf4b 100644 --- a/store/src/backend/log.rs +++ b/store/src/backend/log.rs @@ -1,9 +1,9 @@ //! Logging for the backend. // XXX: Implement log levels and trim the log. - +use rusqlite::{Connection, types::ToSql}; use super::{ - ID, Timestamp, Connection, Rc, Result, node, + ID, Timestamp, Rc, Result, node, StoreServer, BindingServer, KeyServer, Promise, capnp, capnp_rpc }; @@ -61,7 +61,7 @@ fn log(c: &Rc<Connection>, refers: Refers, c.execute("INSERT INTO log (timestamp, level, store, binding, key, slug, message, error) VALUES (?1, 0, ?2, ?3, ?4, ?5, ?6, ?7)", - &[&Timestamp::now(), + &[&Timestamp::now() as &ToSql, &refers.store, &refers.binding, &refers.key, &slug, &message, &error])?; Ok(c.last_insert_rowid().into()) @@ -113,9 +113,9 @@ impl node::log_iter::Server for IterServer { WHERE id < ?1 ORDER BY id DESC LIMIT 1", &[&self.n], - |row| (row.get(0), row.get(1), - row.get(2), row.get(3), row.get(4), - row.get(5), row.get(6), row.get(7))), + |row| Ok((row.get(0)?, row.get(1)?, + row.get(2)?, row.get(3)?, row.get(4)?, + row.get(5)?, row.get(6)?, row.get(7)?))), Selector::Store(store) => self.c.query_row( @@ -129,9 +129,9 @@ impl node::log_iter::Server for IterServer { OR key IN (SELECT key FROM bindings WHERE store = ?2)) ORDER BY id DESC LIMIT 1", &[&self.n, &store], - |row| (row.get(0), row.get(1), - row.get(2), row.get(3), row.get(4), - row.get(5), row.get(6), row.get(7))), + |row| Ok((row.get(0)?, row.get(1)?, + row.get(2)?, row.get(3)?, row.get(4)?, + row.get(5)?, row.get(6)?, row.get(7)?))), Selector::Binding(binding) => self.c.query_row( @@ -144,9 +144,9 @@ impl node::log_iter::Server for IterServer { OR key IN (SELECT key FROM bindings WHERE id = ?2)) ORDER BY id DESC LIMIT 1", &[&self.n, &binding], - |row| (row.get(0), row.get(1), - row.get(2), row.get(3), row.get(4), - row.get(5), row.get(6), row.get(7))), + |row| Ok((row.get(0)?, row.get(1)?, + row.get(2)?, row.get(3)?, row.get(4)?, + row.get(5)?, row.get(6)?, row.get(7)?))), Selector::Key(key) => self.c.query_row( @@ -158,9 +158,9 @@ impl node::log_iter::Server for IterServer { AND key = ?2 ORDER BY id DESC LIMIT 1", &[&self.n, &key], - |row| (row.get(0), row.get(1), - row.get(2), row.get(3), row.get(4), - row.get(5), row.get(6), row.get(7))), + |row| Ok((row.get(0)?, row.get(1)?, + row.get(2)?, row.get(3)?, row.get(4)?, + row.get(5)?, row.get(6)?, row.get(7)?))), }); let mut entry = pry!(results.get().get_result()).init_ok(); diff --git a/store/src/backend/mod.rs b/store/src/backend/mod.rs index 6351a676..d9b3b62c 100644 --- a/store/src/backend/mod.rs +++ b/store/src/backend/mod.rs @@ -15,8 +15,12 @@ use futures::Future; use futures::future::{self, loop_fn, Loop}; use rand::distributions::{Distribution, Uniform}; use rand::thread_rng; -use rusqlite::Connection; -use rusqlite; +use rusqlite::{ + self, + Connection, + NO_PARAMS, + types::ToSql, +}; use tokio_core::reactor::{Handle, Timeout}; use tokio_core; use tokio_io::io::ReadHalf; @@ -119,7 +123,7 @@ impl NodeServer { fn init(&self) -> Result<()> { let v = self.c.query_row( "SELECT version FROM version WHERE id=1", - &[], |row| row.get(0)); + NO_PARAMS, |row| row.get(0)); if let Ok(v) = v { match v { @@ -278,8 +282,10 @@ impl Query for StoreServer { fn slug(&self) -> String { self.c.query_row( "SELECT realm, name FROM stores WHERE id = ?1", - &[&self.id], |row| -> String { - format!("{}:{}", row.get::<_, String>(0), row.get::<_, String>(1)) + &[&self.id], |row| -> rusqlite::Result<String> { + Ok(format!("{}:{}", + row.get::<_, String>(0)?, + row.get::<_, String>(1)?)) }) .unwrap_or( format!("{}::{}", Self::table_name(), self.id()) @@ -300,10 +306,11 @@ impl StoreServer { c.execute( "INSERT OR IGNORE INTO stores (realm, network_policy, name) VALUES (?1, ?2, ?3)", - &[&realm, &p, &name])?; + &[&realm as &ToSql, &p, &name])?; let (id, store_policy): (ID, i64) = c.query_row( "SELECT id, network_policy FROM stores WHERE realm = ?1 AND name = ?2", - &[&realm, &name], |row| (row.get(0), row.get(1)))?; + &[&realm, &name], + |row| Ok((row.get(0)?, row.get(1)?)))?; // We cannot implement FromSql and friends for // core::NetworkPolicy, hence we need to do it by foot. @@ -362,7 +369,7 @@ impl node::store::Server for StoreServer { let binding_id: ID = sry!( self.c.query_row( "SELECT id FROM bindings WHERE store = ?1 AND label = ?2", - &[&self.id, &label], |row| row.get(0))); + &[&self.id as &ToSql, &label], |row| row.get(0))); pry!(pry!(results.get().get_result()).set_ok( node::binding::ToClient::new( @@ -452,7 +459,11 @@ impl BindingServer { let key_id = KeyServer::lookup_or_create(c, fp)?; if let Ok((binding, key)) = c.query_row( "SELECT id, key FROM bindings WHERE store = ?1 AND label = ?2", - &[&store, &label], |row| -> (ID, ID) {(row.get(0), row.get(1))}) { + &[&store as &ToSql, &label], + |row| -> rusqlite::Result<(ID, ID)> { + Ok((row.get(0)?, row.get(1)?)) + }) + { if key == key_id { Ok((binding, key_id, false)) } else { @@ -462,7 +473,7 @@ impl BindingServer { let r = c.execute( "INSERT INTO bindings (store, label, key, created) VALUES (?, ?, ?, ?)", - &[&store, &label, &key_id, &Timestamp::now()]); + &[&store as &ToSql, &label, &key_id, &Timestamp::now()]); // Some other mutator might race us to the insertion. match r { @@ -471,7 +482,8 @@ impl BindingServer { rusqlite::ErrorCode::ConstraintViolation => { let (binding, key): (ID, ID) = c.query_row( "SELECT id, key FROM bindings WHERE store = ?1 AND label = ?2", - &[&store, &label], |row| (row.get(0), row.get(1)))?; + &[&store as &ToSql, &label], + |row| Ok((row.get(0)?, row.get(1)?)))?; if key == key_id { Ok((binding, key_id, false)) } else { @@ -504,7 +516,7 @@ impl Query for BindingServer { fn slug(&self) -> String { self.c.query_row( "SELECT label FROM bindings WHERE id = ?1", - &[&self.id], |row| -> String { + &[&self.id], |row| -> rusqlite::Result<String> { row.get(0) }) .unwrap_or( @@ -552,7 +564,7 @@ impl node::binding::Server for BindingServer { = sry!(self.c.query_row( "SELECT fingerprint, key FROM keys WHERE id = ?1", &[&key_id], - |row| (row.get(0), row.get_checked(1).ok()))); + |row| Ok((row.get(0)?, row.get(1).ok())))); // If we found one, convert it to TPK. let current = if let Some(current) = key { @@ -590,7 +602,7 @@ impl node::binding::Server for BindingServer { sry!(new.serialize(&mut blob)); sry!(self.c.execute("UPDATE keys SET key = ?1 WHERE id = ?2", - &[&blob, &key_id])); + &[&blob as &ToSql, &key_id])); sry!(KeyServer::reindex_subkeys(&self.c, key_id, &new)); pry!(pry!(results.get().get_result()).set_ok(&blob[..])); @@ -621,14 +633,14 @@ impl node::binding::Server for BindingServer { encryption_first = coalesce(encryption_first, ?2), encryption_last = ?2 WHERE id = ?1", - &[&self.id, &now])); + &[&self.id as &ToSql, &now])); sry!(self.c .execute("UPDATE keys SET encryption_count = encryption_count + 1, encryption_first = coalesce(encryption_first, ?2), encryption_last = ?2 WHERE id = ?1", - &[&key, &now])); + &[&key as &ToSql, &now])); sry!(self.query_stats( pry!(results.get().get_result()).init_ok())); Promise::ok(()) @@ -648,14 +660,14 @@ impl node::binding::Server for BindingServer { verification_first = coalesce(verification_first, ?2), verification_last = ?2 WHERE id = ?1", - &[&self.id, &now])); + &[&self.id as &ToSql, &now])); sry!(self.c .execute("UPDATE keys SET verification_count = verification_count + 1, verification_first = coalesce(verification_first, ?2), verification_last = ?2 WHERE id = ?1", - &[&key, &now])); + &[&key as &ToSql, &now])); sry!(self.query_stats( pry!(results.get().get_result()).init_ok())); Promise::ok(()) @@ -679,7 +691,7 @@ impl node::binding::Server for BindingServer { bind_results!(results); let label = sry!(self.c.query_row( "SELECT label FROM bindings WHERE id = ?1", - &[&self.id], |row| -> String { + &[&self.id], |row| -> rusqlite::Result<String> { row.get(0) })); @@ -733,7 +745,7 @@ impl KeyServer { } else { let r = c.execute( "INSERT INTO keys (fingerprint, created, update_at) VALUES (?1, ?2, ?2)", - &[&fp, &Timestamp::now()]); + &[&fp as &ToSql, &Timestamp::now()]); // Some other mutator might race us to the insertion. match r { @@ -763,7 +775,7 @@ impl KeyServer { = self.c.query_row( "SELECT fingerprint, key FROM keys WHERE id = ?1", &[&self.id], - |row| (row.get(0), row.get_checked(1).ok()))?; + |row| Ok((row.get(0)?, row.get(1).ok())))?; // If there was a key stored there, merge it. if let Some(current) = key { @@ -786,7 +798,7 @@ impl KeyServer { new.serialize(&mut blob)?; self.c.execute("UPDATE keys SET key = ?1 WHERE id = ?2", - &[&blob, &self.id])?; + &[&blob as &ToSql, &self.id])?; KeyServer::reindex_subkeys(&self.c, self.id, &new)?; Ok(blob) @@ -800,7 +812,7 @@ impl KeyServer { let r = c.execute( "INSERT INTO key_by_keyid (keyid, key) VALUES (?1, ?2)", - &[&(keyid as i64), &key_id]); + &[&(keyid as i64) as &ToSql, &key_id]); // The mapping might already be present. This is not an error. match r { @@ -825,7 +837,7 @@ impl KeyServer { self.c.execute("UPDATE keys SET updated = ?2, update_at = ?3 WHERE id = ?1", - &[&self.id, &Timestamp::now(), + &[&self.id as &ToSql, &Timestamp::now(), &(Timestamp::now() + next)])?; Ok(()) } @@ -837,7 +849,7 @@ impl KeyServer { self.c.execute("UPDATE keys SET update_at = ?2 WHERE id = ?1", - &[&self.id, + &[&self.id as &ToSql, &(Timestamp::now() + next)])?; Ok(()) } @@ -854,7 +866,9 @@ impl KeyServer { JOIN stores on stores.id = bindings.store WHERE stores.network_policy = ?1 ORDER BY keys.update_at LIMIT 1", - &[&network_policy_u8], |row| -> Timestamp {row.get(0)}).ok() + &[&network_policy_u8], |row| -> rusqlite::Result<Timestamp> { + row.get(0) + }).ok() } /// Returns the number of keys using the given policy. @@ -889,8 +903,8 @@ impl KeyServer { WHERE stores.network_policy >= ?1 AND keys.update_at < ?2 ORDER BY keys.update_at LIMIT 1", - &[&network_policy_u8, &Timestamp::now()], |row| (row.get(0), - row.get(1)))?; + &[&network_policy_u8 as &ToSql, &Timestamp::now()], + |row| Ok((row.get(0)?, row.get(1)?)))?; let fingerprint = openpgp::Fingerprint::from_hex(&fingerprint) .map_err(|_| node::Error::SystemError)?; @@ -990,7 +1004,7 @@ impl Query for KeyServer { fn slug(&self) -> String { self.c.query_row( "SELECT fingerprint FROM keys WHERE id = ?1", - &[&self.id], |row| -> String { row.get(0) }) + &[&self.id], |row| -> rusqlite::Result<String> { row.get(0) }) .ok() .and_then(|fp| Fingerprint::from_hex(&fp).ok()) .map(|fp| fp.to_keyid().to_string()) @@ -1019,7 +1033,7 @@ impl node::key::Server for KeyServer { self.c.query_row( "SELECT key FROM keys WHERE id = ?1", &[&self.id], - |row| row.get_checked(0).unwrap_or(vec![]))); + |row| Ok(row.get(0).unwrap_or(vec![])))); pry!(pry!(results.get().get_result()).set_ok(key.as_slice())); Promise::ok(()) } @@ -1080,9 +1094,10 @@ trait Query { verification_last FROM {0} WHERE id = ?1", Self::table_name()), - &[&self.id()], |row| (row.get(0), row.get(1), - row.get(2), row.get(3), row.get(4), - row.get(5), row.get(6), row.get(7)))?; + &[&self.id()], + |row| Ok((row.get(0)?, row.get(1)?, + row.get(2)?, row.get(3)?, row.get(4)?, + row.get(5)?, row.get(6)?, row.get(7)?)))?; macro_rules! set_some { ( $object: ident) => { macro_rules! set { @@ -1133,8 +1148,8 @@ impl node::store_iter::Server for StoreIterServer { "SELECT id, realm, name, network_policy FROM stores WHERE id > ?1 AND realm like ?2 ORDER BY id LIMIT 1", - &[&self.n, &self.prefix], - |row| (row.get(0), row.get(1), row.get(2), row.get(3)))); + &[&self.n as &ToSql, &self.prefix], + |row| Ok((row.get(0)?, row.get(1)?, row.get(2)?, row.get(3)?)))); // We cannot implement FromSql and friends for // core::NetworkPolicy, hence we need to do it by foot. @@ -1179,7 +1194,7 @@ impl node::binding_iter::Server for BindingIterServer { WHERE bindings.id > ?1 AND bindings.store = ?2 ORDER BY bindings.id LIMIT 1", &[&self.n, &self.store_id], - |row| (row.get(0), row.get(1), row.get(2)))); + |row| Ok((row.get(0)?, row.get(1)?, row.get(2)?)))); let mut entry = pry!(results.get().get_result()).init_ok(); entry.set_label(&label); @@ -1214,7 +1229,7 @@ impl node::key_iter::Server for KeyIterServer { WHERE keys.id > ?1 ORDER BY id LIMIT 1", &[&self.n], - |row| (row.get(0), row.get(1)))); + |row| Ok((row.get(0)?, row.get(1)?)))); let mut entry = pry!(results.get().get_result()).init_ok(); entry.set_fingerprint(&fingerprint); |