From be606b9953f90e9b8612809d3c729875ef63a3f5 Mon Sep 17 00:00:00 2001 From: Thom Chiovoloni Date: Fri, 10 Apr 2020 20:55:16 +0000 Subject: [PATCH] Bug 1628447 - Bump vendored rusqlite version to 0.22.0 r=lina This gets us off the prerelease. Differential Revision: https://phabricator.services.mozilla.com/D70434 --HG-- extra : moz-landing-system : lando --- Cargo.lock | 8 +- .../rust/libsqlite3-sys/.cargo-checksum.json | 2 +- third_party/rust/libsqlite3-sys/Cargo.toml | 2 +- third_party/rust/libsqlite3-sys/build.rs | 3 +- third_party/rust/libsqlite3-sys/src/error.rs | 1 + third_party/rust/libsqlite3-sys/src/lib.rs | 1 + .../rust/rusqlite/.cargo-checksum.json | 2 +- third_party/rust/rusqlite/Cargo.toml | 17 ++-- third_party/rust/rusqlite/README.md | 22 ++++- third_party/rust/rusqlite/benches/cache.rs | 18 ++++ third_party/rust/rusqlite/benches/lib.rs | 24 ----- third_party/rust/rusqlite/src/backup.rs | 8 +- third_party/rust/rusqlite/src/error.rs | 12 +-- third_party/rust/rusqlite/src/hooks.rs | 16 ++-- .../rust/rusqlite/src/inner_connection.rs | 66 ++++++-------- third_party/rust/rusqlite/src/lib.rs | 6 +- .../rust/rusqlite/src/raw_statement.rs | 6 +- third_party/rust/rusqlite/src/session.rs | 88 +++++++------------ third_party/rust/rusqlite/src/statement.rs | 4 +- third_party/rust/rusqlite/src/types/to_sql.rs | 37 ++++++-- .../rust/rusqlite/src/unlock_notify.rs | 22 +++-- third_party/rust/rusqlite/src/vtab/mod.rs | 3 +- toolkit/library/rust/shared/Cargo.toml | 2 +- 23 files changed, 191 insertions(+), 179 deletions(-) create mode 100644 third_party/rust/rusqlite/benches/cache.rs delete mode 100644 third_party/rust/rusqlite/benches/lib.rs diff --git a/Cargo.lock b/Cargo.lock index b4e0985c93c2..96b3abd119b1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2249,9 +2249,9 @@ dependencies = [ [[package]] name = "libsqlite3-sys" -version = "0.17.2" +version = "0.17.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38c4446f020dfbfab9f8a1ab605c15e6c03a8924c08522dcb67314acc8d2b523" +checksum = "56d90181c2904c287e5390186be820e5ef311a3c62edebb7d6ca3d6a48ce041d" dependencies = [ "pkg-config", "vcpkg", @@ -3705,9 +3705,9 @@ checksum = "5d79b4b604167921892e84afbbaad9d5ad74e091bf6c511d9dbfb0593f09fabd" [[package]] name = "rusqlite" -version = "0.22.0-beta.0" +version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5c02d0acf7e60bbf900bfc46c287a336473aedf6b7658039441b474289643de" +checksum = "57edf4c4cea4d7e0fab069acb5da9e8e8e5403c78abc81b1f37d83af02148ea5" dependencies = [ "bitflags", "fallible-iterator", diff --git a/third_party/rust/libsqlite3-sys/.cargo-checksum.json b/third_party/rust/libsqlite3-sys/.cargo-checksum.json index 7441d5bdce3c..14abbd730125 100644 --- a/third_party/rust/libsqlite3-sys/.cargo-checksum.json +++ b/third_party/rust/libsqlite3-sys/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"26fd709d367e0191effa2bc278ff3a8b46d861d239e656ea56da32f73f146e53","bindgen-bindings/bindgen_3.6.23.rs":"923457005065475fafe323ccfae5b66ce1a4920da76b3c95b4645ebf1297cef1","bindgen-bindings/bindgen_3.6.8.rs":"b753ddee60f0a29defc2c6ec763472080114f1fd8a0cddc014e0cbafeb1853a5","bindgen-bindings/bindgen_3.7.16.rs":"73099dae580b3c099d2847d04c4c84fecde44795a65bdab72e6640cfcd7b95ee","bindgen-bindings/bindgen_3.7.7.rs":"d1a2f0f4f842778f0eea0abfbd2f1a7d089a9ab946536a81af9029bbf5dda94b","build.rs":"4d12a7357c8b0f9e57bd2265a365c745b553c4d7363997db31caa3238b5590e3","sqlite3/bindgen_bundled_version.rs":"0ecb163cf9013b029694a2c8b4b307ffa89b774234b5c0fb25a696437e1e4840","sqlite3/sqlite3.c":"3340d6b1508b0035e0d8721d552001ed8000612006fe4db84dca96bc2a0b08b2","sqlite3/sqlite3.h":"ce9e08c10e16f06d73f44ff2638e5a562a517dfb284c1d0179dbb1ea64ea655f","sqlite3/sqlite3ext.h":"f394387f383e932d0bbb75b7809767287ba5333f52a2b68b2add4f1dac7f4d50","src/error.rs":"8feec722b66490d4313570b7956aec751b34bf99cb8755e2004da71219f33a7e","src/lib.rs":"91f72096cf588c02035963c55d262925fdcf6cbddc08338b8b1ee10ee740a0d3","upgrade.sh":"6cc0fbdab7edb27c0415f3ce40387dbcfcb675c5f8ea289a7f2907718cd74d67","wrapper.h":"b78f576f7eeabf316e183d476b0f16344b6897680b4df47628d3ce38c0aa979a"},"package":"38c4446f020dfbfab9f8a1ab605c15e6c03a8924c08522dcb67314acc8d2b523"} \ No newline at end of file +{"files":{"Cargo.toml":"7a953ee91fb12dc0bb2acfd214c184ae2826210b4cc4517c0ac6eb87ca3d2a5b","bindgen-bindings/bindgen_3.6.23.rs":"923457005065475fafe323ccfae5b66ce1a4920da76b3c95b4645ebf1297cef1","bindgen-bindings/bindgen_3.6.8.rs":"b753ddee60f0a29defc2c6ec763472080114f1fd8a0cddc014e0cbafeb1853a5","bindgen-bindings/bindgen_3.7.16.rs":"73099dae580b3c099d2847d04c4c84fecde44795a65bdab72e6640cfcd7b95ee","bindgen-bindings/bindgen_3.7.7.rs":"d1a2f0f4f842778f0eea0abfbd2f1a7d089a9ab946536a81af9029bbf5dda94b","build.rs":"6bc112359cf4bc24114b1ee99af7258637dbd260807cf566fa3f94ac85533626","sqlite3/bindgen_bundled_version.rs":"0ecb163cf9013b029694a2c8b4b307ffa89b774234b5c0fb25a696437e1e4840","sqlite3/sqlite3.c":"3340d6b1508b0035e0d8721d552001ed8000612006fe4db84dca96bc2a0b08b2","sqlite3/sqlite3.h":"ce9e08c10e16f06d73f44ff2638e5a562a517dfb284c1d0179dbb1ea64ea655f","sqlite3/sqlite3ext.h":"f394387f383e932d0bbb75b7809767287ba5333f52a2b68b2add4f1dac7f4d50","src/error.rs":"7be60a8c4fd8c83d9d8979415f3242d9007ceb4188c3b35caa3b06ad463649e2","src/lib.rs":"2d1fe7b7e19a92c9f7f5e697b209fde13322deb70c782b52e24bd920d9aa9583","upgrade.sh":"6cc0fbdab7edb27c0415f3ce40387dbcfcb675c5f8ea289a7f2907718cd74d67","wrapper.h":"b78f576f7eeabf316e183d476b0f16344b6897680b4df47628d3ce38c0aa979a"},"package":"56d90181c2904c287e5390186be820e5ef311a3c62edebb7d6ca3d6a48ce041d"} \ No newline at end of file diff --git a/third_party/rust/libsqlite3-sys/Cargo.toml b/third_party/rust/libsqlite3-sys/Cargo.toml index 9927e2dce3ed..ea84093344b4 100644 --- a/third_party/rust/libsqlite3-sys/Cargo.toml +++ b/third_party/rust/libsqlite3-sys/Cargo.toml @@ -13,7 +13,7 @@ [package] edition = "2018" name = "libsqlite3-sys" -version = "0.17.2" +version = "0.17.3" authors = ["John Gallagher "] build = "build.rs" links = "sqlite3" diff --git a/third_party/rust/libsqlite3-sys/build.rs b/third_party/rust/libsqlite3-sys/build.rs index bc957570723f..3f130caa5df3 100644 --- a/third_party/rust/libsqlite3-sys/build.rs +++ b/third_party/rust/libsqlite3-sys/build.rs @@ -78,7 +78,8 @@ mod build_bundled { .flag("-DSQLITE_SOUNDEX") .flag("-DSQLITE_THREADSAFE=1") .flag("-DSQLITE_USE_URI") - .flag("-DHAVE_USLEEP=1"); + .flag("-DHAVE_USLEEP=1") + .warnings(false); // Older versions of visual studio don't support c99 (including isnan), which // causes a build failure when the linker fails to find the `isnan` // function. `sqlite` provides its own implmentation, using the fact diff --git a/third_party/rust/libsqlite3-sys/src/error.rs b/third_party/rust/libsqlite3-sys/src/error.rs index 31eeacd8226b..ad952f6e85d9 100644 --- a/third_party/rust/libsqlite3-sys/src/error.rs +++ b/third_party/rust/libsqlite3-sys/src/error.rs @@ -4,6 +4,7 @@ use std::os::raw::c_int; /// Error Codes #[derive(Clone, Copy, Debug, PartialEq, Eq)] +#[non_exhaustive] pub enum ErrorCode { /// Internal logic error in SQLite InternalMalfunction, diff --git a/third_party/rust/libsqlite3-sys/src/lib.rs b/third_party/rust/libsqlite3-sys/src/lib.rs index 82fcc26193ad..be635d84597b 100644 --- a/third_party/rust/libsqlite3-sys/src/lib.rs +++ b/third_party/rust/libsqlite3-sys/src/lib.rs @@ -17,6 +17,7 @@ pub fn SQLITE_TRANSIENT() -> sqlite3_destructor_type { /// Run-Time Limit Categories #[repr(i32)] +#[non_exhaustive] pub enum Limit { /// The maximum size of any string or BLOB or table row, in bytes. SQLITE_LIMIT_LENGTH = SQLITE_LIMIT_LENGTH, diff --git a/third_party/rust/rusqlite/.cargo-checksum.json b/third_party/rust/rusqlite/.cargo-checksum.json index 689abedccc38..76bfdf388ff1 100644 --- a/third_party/rust/rusqlite/.cargo-checksum.json +++ b/third_party/rust/rusqlite/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"80a50abd20e22f24c5d096f1e31f673ec1a872b87f26b49c2fd32fcfa439ce8a","Changelog.md":"160abc7629d828e0a6db22d2d58274bbc8b72f2fdb252622a79c8674f0479ab4","LICENSE":"acf819aeb6d09017873bf75127c0f395cfd3016c90b8431d3b9a3e7f2336661b","README.md":"da8a0fb3622a302d6e734793ab08c63f924a8104a26200c246153028c7b848de","appveyor.yml":"0bcc97462ce19ea2d7018b5a0f322d4d0ffc085a31cd18abe540ede05c770ff2","benches/lib.rs":"3837206f4de397723be15c58968e13185bd3cddb08b3d699e4a0a9703a24b6e4","clippy.toml":"98f90bbe52849b3078daeccfbe87aec1c08d02b94a453a15149a1fcccb7cafd0","publish-ghp-docs.sh":"3e2c59e09ce377c46a62511aa17389e6bf824c17d2fc5a818409ede40ba64c23","src/backup.rs":"4fa7163d48329d94da670d437bd18a0b50f93e79a08c1305f0bd7280575c884d","src/blob.rs":"34da23c4db566eee51c43f386ebce47ad03e46345683e8b830950cd232574fa6","src/busy.rs":"0b9bdc85ad1e4dc8b7ad42dd175516ea9e76cc70e64d615b41e7d60ca967347b","src/cache.rs":"914c5823fe8a427b3a4aad09da05fd1788abecd1c7b05ceab5414646b908d618","src/collation.rs":"46dd1478f195421ef60dbf7718ac8aeae7e78060935c6567348344bff51232b4","src/column.rs":"e92e5e3c2f26280bb90b6da01928a32a03de78cc8c317ed9f302b7728bf54d81","src/config.rs":"29a73e56e68b65bb3e413162dfa463e7946f0e2c950669b63339710845884f85","src/context.rs":"811d7e5eb529a637c548be39724477173e2d9c967769d9a513f6863c3b26acd5","src/error.rs":"c4ee9aeebf786e313923bd25f89f585e1e17ee95de7ea3fe291877323d60bef0","src/functions.rs":"ce24e6171d8ce5234c21f6f0178b6e835caf09f281106161183c548b0d70455f","src/hooks.rs":"ca147e4d079af25cf5b9d9b97327ce4c35ccec7d292d39bc7f7a75bb80506d34","src/inner_connection.rs":"771f6f35fc9cec1909cbf37425bb88c22a14c3daf26f9d412a70785b802b2cba","src/lib.rs":"9bd957ca41c88f82ab17b63e50ed66095ebdb384a884b46f5149de46b9e28f14","src/limits.rs":"75d339cf1f21c744f42f339dcfccf44e149bd2d1294ad0fe412b0792d9c809ab","src/load_extension_guard.rs":"cd349613067410fa4be811d7522fc50004fbc48feb050c19f80a097ab919f9fb","src/pragma.rs":"4b7f5b129bb94c2a99909ca14550034d05f5394ae20838eac938cb9464f4507d","src/raw_statement.rs":"ab00bc4b58b293d39ad579614540909465a04622323aabae86c29337845d3eb9","src/row.rs":"cfb4c765e5b79b5dc42c37efe158c43524193a878797769619381afe1dc3aeeb","src/session.rs":"4cee8108b2ad4e1e7b99ce5b5be8fc4465a50e3d47a93f71c5ebac72b591a2f4","src/statement.rs":"8db19b7fd5a4701ffaf8291d11d41b7d7231c6a9387f64ea2d21aba0f9d5e1ae","src/trace.rs":"d764dfa98056b607634cae685d0b4b84693cfbe8d91208a649ba755ff23f1e53","src/transaction.rs":"c3305be85d5f5e18881154f0456883c317775b9fe8ccb1f939c39ee1f5ea700b","src/types/chrono.rs":"1d6aebb7b8efc6038ec30c95d91cee7a16c826bf5a78aca1bc75c86349e17c83","src/types/from_sql.rs":"d1adf2db5cf0051d9a3bd7e98f20a6cd91e9ac93b0961925adad42a9027951bd","src/types/mod.rs":"fc06c3ee27602088b1fe12519b584207c9a826280f631d3a630f5da91b8d5642","src/types/serde_json.rs":"a3f11fd63cf5f3ffc9e89134dd3d139ac275aff1948d315b1eb1673d81e8fe95","src/types/time.rs":"a26b008c86c76f639292b635d30603c6b3ef870d6009606222860dad3e7d4f74","src/types/to_sql.rs":"9c75c53b7da4f14166c4841979a68df84d094c2125900d62f9c41520d78815a7","src/types/url.rs":"b476ca2386a4cc4e8ac500f870993c0445abe91754d4e004bfd19a1b95b53816","src/types/value.rs":"ae803c1d4e6f3e50a59152f38e3d8d98eda32fecafd456214febd9645839bc4d","src/types/value_ref.rs":"f83c99443aa402003bd2437fe1fb199dba1e73711f18a897a1f7e92bf0b0c0e2","src/unlock_notify.rs":"4e2e2af5673af3009dbd9c3bbfd7d7db2d0163ccf6fec759c034d16b66d2fbf0","src/version.rs":"6df3d88ff62b1f4c46692b515a16d1f02ff27732a3e371788566e6a75d5c1d4d","src/vtab/array.rs":"db825b214e87badc07fb767a12ac13ae9858534b1b7b10cd00b289c702a6229f","src/vtab/csvtab.rs":"80d8716126b34979063122b8e42cc8bf70025a0d5520b17670f9a0de0cf4d300","src/vtab/mod.rs":"77f38ae8879087ff2050703a48987150ac901a194cc38ae6789094e881bc4850","src/vtab/series.rs":"3ada0d600031e55798c6d5a24e450fc8c863f9a197ddcac2df2c9d5a78240ca4","test.csv":"3f5649d7b9f80468999b80d4d0e747c6f4f1bba80ade792689eeb4359dc1834a","tests/config_log.rs":"e786bb1a0ca1b560788b24a2091e7d294753a7bee8a39f0e6037b435809267df","tests/deny_single_threaded_sqlite_config.rs":"586ee163d42d886d88ae319cb2184c021bdf9f6da9a8325d799ba10ddeadcbe0","tests/vtab.rs":"9d6376287598511fa43d34e0249159457a99ba47a72e937e08292d776c18b979"},"package":"d5c02d0acf7e60bbf900bfc46c287a336473aedf6b7658039441b474289643de"} \ No newline at end of file +{"files":{"Cargo.toml":"2fbb6309bee89812463013e7d2ade80e9da3fda1dfc158c302b5c21321d76e9c","Changelog.md":"160abc7629d828e0a6db22d2d58274bbc8b72f2fdb252622a79c8674f0479ab4","LICENSE":"acf819aeb6d09017873bf75127c0f395cfd3016c90b8431d3b9a3e7f2336661b","README.md":"1551434bfdc18c6de86aeaf8a6d2f048c87c37079f0b1d3ce7db7b0488821827","appveyor.yml":"0bcc97462ce19ea2d7018b5a0f322d4d0ffc085a31cd18abe540ede05c770ff2","benches/cache.rs":"30459d8d7f65dd684909a53590f9be32e2e545a0775cd93ee0ce85dd08410955","clippy.toml":"98f90bbe52849b3078daeccfbe87aec1c08d02b94a453a15149a1fcccb7cafd0","publish-ghp-docs.sh":"3e2c59e09ce377c46a62511aa17389e6bf824c17d2fc5a818409ede40ba64c23","src/backup.rs":"360ed194fee64f92ca66950a720d8855be7949700bd20c106ee09880453bf1d1","src/blob.rs":"34da23c4db566eee51c43f386ebce47ad03e46345683e8b830950cd232574fa6","src/busy.rs":"0b9bdc85ad1e4dc8b7ad42dd175516ea9e76cc70e64d615b41e7d60ca967347b","src/cache.rs":"914c5823fe8a427b3a4aad09da05fd1788abecd1c7b05ceab5414646b908d618","src/collation.rs":"46dd1478f195421ef60dbf7718ac8aeae7e78060935c6567348344bff51232b4","src/column.rs":"e92e5e3c2f26280bb90b6da01928a32a03de78cc8c317ed9f302b7728bf54d81","src/config.rs":"29a73e56e68b65bb3e413162dfa463e7946f0e2c950669b63339710845884f85","src/context.rs":"811d7e5eb529a637c548be39724477173e2d9c967769d9a513f6863c3b26acd5","src/error.rs":"96501aebaf239044170e1175fd6ca2035b4388772e9fb97790326ce6b6542fef","src/functions.rs":"ce24e6171d8ce5234c21f6f0178b6e835caf09f281106161183c548b0d70455f","src/hooks.rs":"83a4b6ee25b1094022d6eb518906e4c18e48da4a9b060f7a090a0b62d7751d1e","src/inner_connection.rs":"5fa580ae09cfac46903d2ce607070c432d3769ce7c59d41683bff43a72af9008","src/lib.rs":"e9556869e37162bfe1d638caf1bd0ea4467bbd2593255b3a247cb1e3243c97e1","src/limits.rs":"75d339cf1f21c744f42f339dcfccf44e149bd2d1294ad0fe412b0792d9c809ab","src/load_extension_guard.rs":"cd349613067410fa4be811d7522fc50004fbc48feb050c19f80a097ab919f9fb","src/pragma.rs":"4b7f5b129bb94c2a99909ca14550034d05f5394ae20838eac938cb9464f4507d","src/raw_statement.rs":"abe4635b8a473ede8cdef069deab390bed365dd918b8b4fbdac905e9d2c79377","src/row.rs":"cfb4c765e5b79b5dc42c37efe158c43524193a878797769619381afe1dc3aeeb","src/session.rs":"85167583278e4c6ee49ab4c77f30d33eec34e5bdaec71c1eb216b39b12ba32ee","src/statement.rs":"6d9857e72c7d09ae7a4df83ad7119d18c655ee8947bfa97f5dd737b4654456cb","src/trace.rs":"d764dfa98056b607634cae685d0b4b84693cfbe8d91208a649ba755ff23f1e53","src/transaction.rs":"c3305be85d5f5e18881154f0456883c317775b9fe8ccb1f939c39ee1f5ea700b","src/types/chrono.rs":"1d6aebb7b8efc6038ec30c95d91cee7a16c826bf5a78aca1bc75c86349e17c83","src/types/from_sql.rs":"d1adf2db5cf0051d9a3bd7e98f20a6cd91e9ac93b0961925adad42a9027951bd","src/types/mod.rs":"fc06c3ee27602088b1fe12519b584207c9a826280f631d3a630f5da91b8d5642","src/types/serde_json.rs":"a3f11fd63cf5f3ffc9e89134dd3d139ac275aff1948d315b1eb1673d81e8fe95","src/types/time.rs":"a26b008c86c76f639292b635d30603c6b3ef870d6009606222860dad3e7d4f74","src/types/to_sql.rs":"34093985551c23c32da1e124823348f7bfc299633b0a7b974d36eb9dbe4799b6","src/types/url.rs":"b476ca2386a4cc4e8ac500f870993c0445abe91754d4e004bfd19a1b95b53816","src/types/value.rs":"ae803c1d4e6f3e50a59152f38e3d8d98eda32fecafd456214febd9645839bc4d","src/types/value_ref.rs":"f83c99443aa402003bd2437fe1fb199dba1e73711f18a897a1f7e92bf0b0c0e2","src/unlock_notify.rs":"33747f10e4aa2ff8d11b295672d15f677117d2c23037f9361ffc931763796907","src/version.rs":"6df3d88ff62b1f4c46692b515a16d1f02ff27732a3e371788566e6a75d5c1d4d","src/vtab/array.rs":"db825b214e87badc07fb767a12ac13ae9858534b1b7b10cd00b289c702a6229f","src/vtab/csvtab.rs":"80d8716126b34979063122b8e42cc8bf70025a0d5520b17670f9a0de0cf4d300","src/vtab/mod.rs":"ce462dd1d691370bff06925b67cb16ca3ea76da83ed197f77706fe0c3583c749","src/vtab/series.rs":"3ada0d600031e55798c6d5a24e450fc8c863f9a197ddcac2df2c9d5a78240ca4","test.csv":"3f5649d7b9f80468999b80d4d0e747c6f4f1bba80ade792689eeb4359dc1834a","tests/config_log.rs":"e786bb1a0ca1b560788b24a2091e7d294753a7bee8a39f0e6037b435809267df","tests/deny_single_threaded_sqlite_config.rs":"586ee163d42d886d88ae319cb2184c021bdf9f6da9a8325d799ba10ddeadcbe0","tests/vtab.rs":"9d6376287598511fa43d34e0249159457a99ba47a72e937e08292d776c18b979"},"package":"57edf4c4cea4d7e0fab069acb5da9e8e8e5403c78abc81b1f37d83af02148ea5"} \ No newline at end of file diff --git a/third_party/rust/rusqlite/Cargo.toml b/third_party/rust/rusqlite/Cargo.toml index 14f22b235920..54a73ad0ac83 100644 --- a/third_party/rust/rusqlite/Cargo.toml +++ b/third_party/rust/rusqlite/Cargo.toml @@ -13,7 +13,7 @@ [package] edition = "2018" name = "rusqlite" -version = "0.22.0-beta.0" +version = "0.22.0" authors = ["John Gallagher "] description = "Ergonomic wrapper for SQLite" documentation = "http://docs.rs/rusqlite/" @@ -30,7 +30,7 @@ no-default-features = true [package.metadata.playground] all-features = false -features = ["array", "backup", "blob", "bundled", "chrono", "collation", "csvtab", "extra_check", "functions", "hooks", "i128_blob", "limits", "load_extension", "modern_sqlite", "serde_json", "series", "trace", "url", "vtab_v3", "vtab", "window"] +features = ["bundled-full"] [lib] name = "rusqlite" @@ -44,6 +44,10 @@ name = "deny_single_threaded_sqlite_config" [[test]] name = "vtab" + +[[bench]] +name = "cache" +harness = false [dependencies.bitflags] version = "1.0" @@ -71,7 +75,7 @@ version = "1.0" optional = true [dependencies.libsqlite3-sys] -version = "0.17.2" +version = "0.17.3" [dependencies.lru-cache] version = "0.1" @@ -93,6 +97,9 @@ optional = true [dependencies.uuid] version = "0.8" optional = true +[dev-dependencies.bencher] +version = "0.1" + [dev-dependencies.doc-comment] version = "0.3" @@ -118,6 +125,8 @@ backup = ["libsqlite3-sys/min_sqlite_version_3_6_23"] blob = ["libsqlite3-sys/min_sqlite_version_3_7_7"] buildtime_bindgen = ["libsqlite3-sys/buildtime_bindgen"] bundled = ["libsqlite3-sys/bundled", "modern_sqlite"] +bundled-full = ["array", "backup", "blob", "bundled", "chrono", "collation", "csvtab", "extra_check", "functions", "hooks", "i128_blob", "limits", "load_extension", "serde_json", "series", "trace", "unlock_notify", "url", "uuid", "vtab", "window"] +bundled-windows = ["libsqlite3-sys/bundled-windows"] collation = [] csvtab = ["csv", "vtab"] extra_check = [] @@ -133,9 +142,7 @@ session = ["libsqlite3-sys/session", "hooks"] sqlcipher = ["libsqlite3-sys/sqlcipher"] trace = ["libsqlite3-sys/min_sqlite_version_3_6_23"] unlock_notify = ["libsqlite3-sys/unlock_notify"] -unstable = [] vtab = ["libsqlite3-sys/min_sqlite_version_3_7_7", "lazy_static"] -vtab_v3 = ["vtab"] window = ["functions"] [badges.appveyor] repository = "jgallagher/rusqlite" diff --git a/third_party/rust/rusqlite/README.md b/third_party/rust/rusqlite/README.md index 49646cc6bd1e..43c1ec1987dd 100644 --- a/third_party/rust/rusqlite/README.md +++ b/third_party/rust/rusqlite/README.md @@ -101,7 +101,7 @@ features](https://doc.rust-lang.org/cargo/reference/manifest.html#the-features-s * [`array`](https://sqlite.org/carray.html), The `rarray()` Table-Valued Function. * `i128_blob` allows storing values of type `i128` type in SQLite databases. Internally, the data is stored as a 16 byte big-endian blob, with the most significant bit flipped, which allows ordering and comparison between different blobs storing i128s to work as expected. * `uuid` allows storing and retrieving `Uuid` values from the [`uuid`](https://docs.rs/uuid/) crate using blobs. -* [`session`](https://sqlite.org/sessionintro.html), Session module extension. +* [`session`](https://sqlite.org/sessionintro.html), Session module extension. Requires `buildtime_bindgen` feature. ## Notes on building rusqlite and libsqlite3-sys @@ -166,6 +166,26 @@ enabled if you turn this on, as otherwise you'll need to keep the version of SQLite you link with in sync with what rusqlite would have bundled, (usually the most recent release of sqlite). Failing to do this will cause a runtime error. +## Contributing + +Rusqlite has many features, and many of them impact the build configuration in +incompatible ways. This is unfortunate, and makes testing changes hard. + +To help here: you generally should ensure that you run tests/lint for +`--features bundled`, and `--features bundled-full session buildtime_bindgen`. + +If running bindgen is problematic for you, `--features bundled-full` enables +bundled and all features which don't require binding generation, and can be used +instead. + +### Checklist + +- Run `cargo fmt` to ensure your Rust code is correctly formatted. +- Ensure `cargo clippy --all-targets --workspace --features bundled` passes without warnings. +- Ensure `cargo test --all-targets --workspace --features bundled-full session buildtime_bindgen` reports no failures. +- Ensure `cargo test --all-targets --workspace --features bundled` reports no failures. +- Ensure `cargo test --all-targets --workspace --features bundled-full session buildtime_bindgen` reports no failures. + ## Author John Gallagher, johnkgallagher@gmail.com diff --git a/third_party/rust/rusqlite/benches/cache.rs b/third_party/rust/rusqlite/benches/cache.rs new file mode 100644 index 000000000000..dd3683ec7280 --- /dev/null +++ b/third_party/rust/rusqlite/benches/cache.rs @@ -0,0 +1,18 @@ +use bencher::{benchmark_group, benchmark_main, Bencher}; +use rusqlite::Connection; + +fn bench_no_cache(b: &mut Bencher) { + let db = Connection::open_in_memory().unwrap(); + db.set_prepared_statement_cache_capacity(0); + let sql = "SELECT 1, 'test', 3.14 UNION SELECT 2, 'exp', 2.71"; + b.iter(|| db.prepare(sql).unwrap()); +} + +fn bench_cache(b: &mut Bencher) { + let db = Connection::open_in_memory().unwrap(); + let sql = "SELECT 1, 'test', 3.14 UNION SELECT 2, 'exp', 2.71"; + b.iter(|| db.prepare_cached(sql).unwrap()); +} + +benchmark_group!(cache_benches, bench_no_cache, bench_cache); +benchmark_main!(cache_benches); diff --git a/third_party/rust/rusqlite/benches/lib.rs b/third_party/rust/rusqlite/benches/lib.rs deleted file mode 100644 index 2d799f46d1ec..000000000000 --- a/third_party/rust/rusqlite/benches/lib.rs +++ /dev/null @@ -1,24 +0,0 @@ -#![cfg_attr(feature = "unstable", feature(test))] - -#[cfg(feature = "unstable")] -mod bench { - extern crate test; - - use rusqlite::Connection; - use test::Bencher; - - #[bench] - fn bench_no_cache(b: &mut Bencher) { - let db = Connection::open_in_memory().unwrap(); - db.set_prepared_statement_cache_capacity(0); - let sql = "SELECT 1, 'test', 3.14 UNION SELECT 2, 'exp', 2.71"; - b.iter(|| db.prepare(sql).unwrap()); - } - - #[bench] - fn bench_cache(b: &mut Bencher) { - let db = Connection::open_in_memory().unwrap(); - let sql = "SELECT 1, 'test', 3.14 UNION SELECT 2, 'exp', 2.71"; - b.iter(|| db.prepare_cached(sql).unwrap()); - } -} diff --git a/third_party/rust/rusqlite/src/backup.rs b/third_party/rust/rusqlite/src/backup.rs index 1018ab6ca031..e0951464fc6f 100644 --- a/third_party/rust/rusqlite/src/backup.rs +++ b/third_party/rust/rusqlite/src/backup.rs @@ -77,8 +77,8 @@ impl Connection { match r { Done => Ok(()), - Busy => Err(error_from_handle(ptr::null_mut(), ffi::SQLITE_BUSY)), - Locked => Err(error_from_handle(ptr::null_mut(), ffi::SQLITE_LOCKED)), + Busy => Err(unsafe { error_from_handle(ptr::null_mut(), ffi::SQLITE_BUSY) }), + Locked => Err(unsafe { error_from_handle(ptr::null_mut(), ffi::SQLITE_LOCKED) }), More => unreachable!(), } } @@ -123,8 +123,8 @@ impl Connection { match r { Done => Ok(()), - Busy => Err(error_from_handle(ptr::null_mut(), ffi::SQLITE_BUSY)), - Locked => Err(error_from_handle(ptr::null_mut(), ffi::SQLITE_LOCKED)), + Busy => Err(unsafe { error_from_handle(ptr::null_mut(), ffi::SQLITE_BUSY) }), + Locked => Err(unsafe { error_from_handle(ptr::null_mut(), ffi::SQLITE_LOCKED) }), More => unreachable!(), } } diff --git a/third_party/rust/rusqlite/src/error.rs b/third_party/rust/rusqlite/src/error.rs index 4550f9f394b0..34d2ddc09bfb 100644 --- a/third_party/rust/rusqlite/src/error.rs +++ b/third_party/rust/rusqlite/src/error.rs @@ -21,7 +21,7 @@ pub enum Error { /// Error when the value of a particular column is requested, but it cannot /// be converted to the requested Rust type. - FromSqlConversionFailure(usize, Type, Box), + FromSqlConversionFailure(usize, Type, Box), /// Error when SQLite gives us an integral value outside the range of the /// requested type (e.g., trying to get the value 1000 into a `u8`). @@ -80,10 +80,10 @@ pub enum Error { /// `create_scalar_function`). #[cfg(feature = "functions")] #[allow(dead_code)] - UserFunctionError(Box), + UserFunctionError(Box), /// Error available for the implementors of the `ToSql` trait. - ToSqlConversionFailure(Box), + ToSqlConversionFailure(Box), /// Error when the SQL is not a `SELECT`, is not read-only. InvalidQuery, @@ -308,7 +308,7 @@ impl error::Error for Error { } } - fn cause(&self) -> Option<&dyn error::Error> { + fn source(&self) -> Option<&(dyn error::Error + 'static)> { match *self { Error::SqliteFailure(ref err, _) => Some(err), Error::Utf8Error(ref err) => Some(err), @@ -357,11 +357,11 @@ pub fn error_from_sqlite_code(code: c_int, message: Option) -> Error { Error::SqliteFailure(ffi::Error::new(code), message) } -pub fn error_from_handle(db: *mut ffi::sqlite3, code: c_int) -> Error { +pub unsafe fn error_from_handle(db: *mut ffi::sqlite3, code: c_int) -> Error { let message = if db.is_null() { None } else { - Some(unsafe { errmsg_to_string(ffi::sqlite3_errmsg(db)) }) + Some(errmsg_to_string(ffi::sqlite3_errmsg(db))) }; error_from_sqlite_code(code, message) } diff --git a/third_party/rust/rusqlite/src/hooks.rs b/third_party/rust/rusqlite/src/hooks.rs index 4b023f5002fe..0691f3135405 100644 --- a/third_party/rust/rusqlite/src/hooks.rs +++ b/third_party/rust/rusqlite/src/hooks.rs @@ -102,7 +102,7 @@ impl InnerConnection { // `sqlite3_commit_hook`. so we keep the `xDestroy` function in // `InnerConnection.free_boxed_hook`. let free_commit_hook = if hook.is_some() { - Some(free_boxed_hook:: as fn(*mut c_void)) + Some(free_boxed_hook:: as unsafe fn(*mut c_void)) } else { None }; @@ -122,7 +122,7 @@ impl InnerConnection { }; if !previous_hook.is_null() { if let Some(free_boxed_hook) = self.free_commit_hook { - free_boxed_hook(previous_hook); + unsafe { free_boxed_hook(previous_hook) }; } } self.free_commit_hook = free_commit_hook; @@ -143,7 +143,7 @@ impl InnerConnection { } let free_rollback_hook = if hook.is_some() { - Some(free_boxed_hook:: as fn(*mut c_void)) + Some(free_boxed_hook:: as unsafe fn(*mut c_void)) } else { None }; @@ -163,7 +163,7 @@ impl InnerConnection { }; if !previous_hook.is_null() { if let Some(free_boxed_hook) = self.free_rollback_hook { - free_boxed_hook(previous_hook); + unsafe { free_boxed_hook(previous_hook) }; } } self.free_rollback_hook = free_rollback_hook; @@ -202,7 +202,7 @@ impl InnerConnection { } let free_update_hook = if hook.is_some() { - Some(free_boxed_hook:: as fn(*mut c_void)) + Some(free_boxed_hook:: as unsafe fn(*mut c_void)) } else { None }; @@ -222,15 +222,15 @@ impl InnerConnection { }; if !previous_hook.is_null() { if let Some(free_boxed_hook) = self.free_update_hook { - free_boxed_hook(previous_hook); + unsafe { free_boxed_hook(previous_hook) }; } } self.free_update_hook = free_update_hook; } } -fn free_boxed_hook(p: *mut c_void) { - drop(unsafe { Box::from_raw(p as *mut F) }); +unsafe fn free_boxed_hook(p: *mut c_void) { + drop(Box::from_raw(p as *mut F)); } #[cfg(test)] diff --git a/third_party/rust/rusqlite/src/inner_connection.rs b/third_party/rust/rusqlite/src/inner_connection.rs index 775d2b9a3caa..2b5f4bb3004d 100644 --- a/third_party/rust/rusqlite/src/inner_connection.rs +++ b/third_party/rust/rusqlite/src/inner_connection.rs @@ -1,5 +1,4 @@ use std::ffi::CString; -use std::mem::MaybeUninit; use std::os::raw::{c_char, c_int}; #[cfg(feature = "load_extension")] use std::path::Path; @@ -27,33 +26,25 @@ pub struct InnerConnection { // interrupt would only acquire the lock after the query's completion. interrupt_lock: Arc>, #[cfg(feature = "hooks")] - pub free_commit_hook: Option, + pub free_commit_hook: Option, #[cfg(feature = "hooks")] - pub free_rollback_hook: Option, + pub free_rollback_hook: Option, #[cfg(feature = "hooks")] - pub free_update_hook: Option, + pub free_update_hook: Option, owned: bool, } impl InnerConnection { - #[cfg(not(feature = "hooks"))] #[allow(clippy::mutex_atomic)] - pub fn new(db: *mut ffi::sqlite3, owned: bool) -> InnerConnection { - InnerConnection { - db, - interrupt_lock: Arc::new(Mutex::new(db)), - owned, - } - } - - #[cfg(feature = "hooks")] - #[allow(clippy::mutex_atomic)] - pub fn new(db: *mut ffi::sqlite3, owned: bool) -> InnerConnection { + pub unsafe fn new(db: *mut ffi::sqlite3, owned: bool) -> InnerConnection { InnerConnection { db, interrupt_lock: Arc::new(Mutex::new(db)), + #[cfg(feature = "hooks")] free_commit_hook: None, + #[cfg(feature = "hooks")] free_rollback_hook: None, + #[cfg(feature = "hooks")] free_update_hook: None, owned, } @@ -89,9 +80,8 @@ impl InnerConnection { }; unsafe { - let mut db = MaybeUninit::uninit(); - let r = ffi::sqlite3_open_v2(c_path.as_ptr(), db.as_mut_ptr(), flags.bits(), z_vfs); - let db: *mut ffi::sqlite3 = db.assume_init(); + let mut db: *mut ffi::sqlite3 = ptr::null_mut(); + let r = ffi::sqlite3_open_v2(c_path.as_ptr(), &mut db, flags.bits(), z_vfs); if r != ffi::SQLITE_OK { let e = if db.is_null() { error_from_sqlite_code(r, Some(c_path.to_string_lossy().to_string())) @@ -135,10 +125,10 @@ impl InnerConnection { } pub fn decode_result(&mut self, code: c_int) -> Result<()> { - InnerConnection::decode_result_raw(self.db(), code) + unsafe { InnerConnection::decode_result_raw(self.db(), code) } } - fn decode_result_raw(db: *mut ffi::sqlite3, code: c_int) -> Result<()> { + unsafe fn decode_result_raw(db: *mut ffi::sqlite3, code: c_int) -> Result<()> { if code == ffi::SQLITE_OK { Ok(()) } else { @@ -204,28 +194,22 @@ impl InnerConnection { pub fn load_extension(&self, dylib_path: &Path, entry_point: Option<&str>) -> Result<()> { let dylib_str = super::path_to_cstring(dylib_path)?; unsafe { - let mut errmsg = MaybeUninit::uninit(); + let mut errmsg: *mut c_char = ptr::null_mut(); let r = if let Some(entry_point) = entry_point { let c_entry = str_to_cstring(entry_point)?; ffi::sqlite3_load_extension( self.db, dylib_str.as_ptr(), c_entry.as_ptr(), - errmsg.as_mut_ptr(), + &mut errmsg, ) } else { - ffi::sqlite3_load_extension( - self.db, - dylib_str.as_ptr(), - ptr::null(), - errmsg.as_mut_ptr(), - ) + ffi::sqlite3_load_extension(self.db, dylib_str.as_ptr(), ptr::null(), &mut errmsg) }; if r == ffi::SQLITE_OK { Ok(()) } else { - let errmsg: *mut c_char = errmsg.assume_init(); - let message = super::errmsg_to_string(&*errmsg); + let message = super::errmsg_to_string(errmsg); ffi::sqlite3_free(errmsg as *mut ::std::os::raw::c_void); Err(error_from_sqlite_code(r, Some(message))) } @@ -237,9 +221,9 @@ impl InnerConnection { } pub fn prepare<'a>(&mut self, conn: &'a Connection, sql: &str) -> Result> { - let mut c_stmt = MaybeUninit::uninit(); + let mut c_stmt = ptr::null_mut(); let (c_sql, len, _) = str_for_sqlite(sql.as_bytes())?; - let mut c_tail = MaybeUninit::uninit(); + let mut c_tail = ptr::null(); let r = unsafe { if cfg!(feature = "unlock_notify") { let mut rc; @@ -248,8 +232,8 @@ impl InnerConnection { self.db(), c_sql, len, - c_stmt.as_mut_ptr(), - c_tail.as_mut_ptr(), + &mut c_stmt as *mut *mut ffi::sqlite3_stmt, + &mut c_tail as *mut *const c_char, ); if !unlock_notify::is_locked(self.db, rc) { break; @@ -265,8 +249,8 @@ impl InnerConnection { self.db(), c_sql, len, - c_stmt.as_mut_ptr(), - c_tail.as_mut_ptr(), + &mut c_stmt as *mut *mut ffi::sqlite3_stmt, + &mut c_tail as *mut *const c_char, ) } }; @@ -274,11 +258,13 @@ impl InnerConnection { self.decode_result(r)?; // If the input text contains no SQL (if the input is an empty string or a // comment) then *ppStmt is set to NULL. - let c_stmt: *mut ffi::sqlite3_stmt = unsafe { c_stmt.assume_init() }; - let c_tail: *const c_char = unsafe { c_tail.assume_init() }; + let c_stmt: *mut ffi::sqlite3_stmt = c_stmt; + let c_tail: *const c_char = c_tail; // TODO ignore spaces, comments, ... at the end let tail = !c_tail.is_null() && unsafe { c_tail != c_sql.offset(len as isize) }; - Ok(Statement::new(conn, RawStatement::new(c_stmt, tail))) + Ok(Statement::new(conn, unsafe { + RawStatement::new(c_stmt, tail) + })) } pub fn changes(&mut self) -> usize { diff --git a/third_party/rust/rusqlite/src/lib.rs b/third_party/rust/rusqlite/src/lib.rs index a42866957a48..bb9382bbf777 100644 --- a/third_party/rust/rusqlite/src/lib.rs +++ b/third_party/rust/rusqlite/src/lib.rs @@ -1028,25 +1028,23 @@ mod test { // statement first. let raw_stmt = { use super::str_to_cstring; - use std::mem::MaybeUninit; use std::os::raw::c_int; use std::ptr; let raw_db = db.db.borrow_mut().db; let sql = "SELECT 1"; - let mut raw_stmt = MaybeUninit::uninit(); + let mut raw_stmt: *mut ffi::sqlite3_stmt = ptr::null_mut(); let cstring = str_to_cstring(sql).unwrap(); let rc = unsafe { ffi::sqlite3_prepare_v2( raw_db, cstring.as_ptr(), (sql.len() + 1) as c_int, - raw_stmt.as_mut_ptr(), + &mut raw_stmt, ptr::null_mut(), ) }; assert_eq!(rc, ffi::SQLITE_OK); - let raw_stmt: *mut ffi::sqlite3_stmt = unsafe { raw_stmt.assume_init() }; raw_stmt }; diff --git a/third_party/rust/rusqlite/src/raw_statement.rs b/third_party/rust/rusqlite/src/raw_statement.rs index 8d943baa5cf6..05634d640c38 100644 --- a/third_party/rust/rusqlite/src/raw_statement.rs +++ b/third_party/rust/rusqlite/src/raw_statement.rs @@ -10,7 +10,7 @@ use std::ptr; pub struct RawStatement(*mut ffi::sqlite3_stmt, bool); impl RawStatement { - pub fn new(stmt: *mut ffi::sqlite3_stmt, tail: bool) -> RawStatement { + pub unsafe fn new(stmt: *mut ffi::sqlite3_stmt, tail: bool) -> RawStatement { RawStatement(stmt, tail) } @@ -64,10 +64,10 @@ impl RawStatement { let mut rc; loop { rc = unsafe { ffi::sqlite3_step(self.0) }; - if !unlock_notify::is_locked(db, rc) { + if unsafe { !unlock_notify::is_locked(db, rc) } { break; } - rc = unlock_notify::wait_for_unlock_notify(db); + rc = unsafe { unlock_notify::wait_for_unlock_notify(db) }; if rc != ffi::SQLITE_OK { break; } diff --git a/third_party/rust/rusqlite/src/session.rs b/third_party/rust/rusqlite/src/session.rs index 479a2323d5e3..34a53f4438a6 100644 --- a/third_party/rust/rusqlite/src/session.rs +++ b/third_party/rust/rusqlite/src/session.rs @@ -4,7 +4,6 @@ use std::ffi::CStr; use std::io::{Read, Write}; use std::marker::PhantomData; -use std::mem::MaybeUninit; use std::os::raw::{c_char, c_int, c_uchar, c_void}; use std::panic::{catch_unwind, RefUnwindSafe}; use std::ptr; @@ -43,9 +42,8 @@ impl Session<'_> { let db = db.db.borrow_mut().db; - let mut s = MaybeUninit::uninit(); - check!(unsafe { ffi::sqlite3session_create(db, name.as_ptr(), s.as_mut_ptr()) }); - let s: *mut ffi::sqlite3_session = unsafe { s.assume_init() }; + let mut s: *mut ffi::sqlite3_session = ptr::null_mut(); + check!(unsafe { ffi::sqlite3session_create(db, name.as_ptr(), &mut s) }); Ok(Session { phantom: PhantomData, @@ -113,9 +111,8 @@ impl Session<'_> { /// Generate a Changeset pub fn changeset(&mut self) -> Result { let mut n = 0; - let mut cs = MaybeUninit::uninit(); - check!(unsafe { ffi::sqlite3session_changeset(self.s, &mut n, cs.as_mut_ptr()) }); - let cs: *mut c_void = unsafe { cs.assume_init() }; + let mut cs: *mut c_void = ptr::null_mut(); + check!(unsafe { ffi::sqlite3session_changeset(self.s, &mut n, &mut cs) }); Ok(Changeset { cs, n }) } @@ -135,9 +132,8 @@ impl Session<'_> { /// Generate a Patchset pub fn patchset(&mut self) -> Result { let mut n = 0; - let mut ps = MaybeUninit::uninit(); - check!(unsafe { ffi::sqlite3session_patchset(self.s, &mut n, ps.as_mut_ptr()) }); - let ps: *mut c_void = unsafe { ps.assume_init() }; + let mut ps: *mut c_void = ptr::null_mut(); + check!(unsafe { ffi::sqlite3session_patchset(self.s, &mut n, &mut ps) }); // TODO Validate: same struct Ok(Changeset { cs: ps, n }) } @@ -160,10 +156,11 @@ impl Session<'_> { let from = from.to_cstring()?; let table = str_to_cstring(table)?.as_ptr(); unsafe { - let mut errmsg = MaybeUninit::uninit(); - let r = ffi::sqlite3session_diff(self.s, from.as_ptr(), table, errmsg.as_mut_ptr()); + let mut errmsg = ptr::null_mut(); + let r = + ffi::sqlite3session_diff(self.s, from.as_ptr(), table, &mut errmsg as *mut *mut _); if r != ffi::SQLITE_OK { - let errmsg: *mut c_char = errmsg.assume_init(); + let errmsg: *mut c_char = errmsg; let message = errmsg_to_string(&*errmsg); ffi::sqlite3_free(errmsg as *mut ::std::os::raw::c_void); return Err(error_from_sqlite_code(r, Some(message))); @@ -258,17 +255,17 @@ impl Changeset { /// Invert a changeset pub fn invert(&self) -> Result { let mut n = 0; - let mut cs = MaybeUninit::uninit(); - check!(unsafe { ffi::sqlite3changeset_invert(self.n, self.cs, &mut n, cs.as_mut_ptr()) }); - let cs: *mut c_void = unsafe { cs.assume_init() }; + let mut cs = ptr::null_mut(); + check!(unsafe { + ffi::sqlite3changeset_invert(self.n, self.cs, &mut n, &mut cs as *mut *mut _) + }); Ok(Changeset { cs, n }) } /// Create an iterator to traverse a changeset pub fn iter(&self) -> Result> { - let mut it = MaybeUninit::uninit(); - check!(unsafe { ffi::sqlite3changeset_start(it.as_mut_ptr(), self.n, self.cs) }); - let it: *mut ffi::sqlite3_changeset_iter = unsafe { it.assume_init() }; + let mut it = ptr::null_mut(); + check!(unsafe { ffi::sqlite3changeset_start(&mut it as *mut *mut _, self.n, self.cs) }); Ok(ChangesetIter { phantom: PhantomData, it, @@ -279,11 +276,10 @@ impl Changeset { /// Concatenate two changeset objects pub fn concat(a: &Changeset, b: &Changeset) -> Result { let mut n = 0; - let mut cs = MaybeUninit::uninit(); + let mut cs = ptr::null_mut(); check!(unsafe { - ffi::sqlite3changeset_concat(a.n, a.cs, b.n, b.cs, &mut n, cs.as_mut_ptr()) + ffi::sqlite3changeset_concat(a.n, a.cs, b.n, b.cs, &mut n, &mut cs as *mut *mut _) }); - let cs: *mut c_void = unsafe { cs.assume_init() }; Ok(Changeset { cs, n }) } } @@ -307,15 +303,14 @@ pub struct ChangesetIter<'changeset> { impl ChangesetIter<'_> { /// Create an iterator on `input` pub fn start_strm<'input>(input: &&'input mut dyn Read) -> Result> { - let mut it = MaybeUninit::uninit(); + let mut it = ptr::null_mut(); check!(unsafe { ffi::sqlite3changeset_start_strm( - it.as_mut_ptr(), + &mut it as *mut *mut _, Some(x_input), input as *const &mut dyn Read as *mut c_void, ) }); - let it: *mut ffi::sqlite3_changeset_iter = unsafe { it.assume_init() }; Ok(ChangesetIter { phantom: PhantomData, it, @@ -396,13 +391,12 @@ impl ChangesetItem { /// `SQLITE_CHANGESET_CONFLICT` conflict handler callback. pub fn conflict(&self, col: usize) -> Result> { unsafe { - let mut p_value = MaybeUninit::uninit(); + let mut p_value: *mut ffi::sqlite3_value = ptr::null_mut(); check!(ffi::sqlite3changeset_conflict( self.it, col as i32, - p_value.as_mut_ptr() + &mut p_value, )); - let p_value: *mut ffi::sqlite3_value = p_value.assume_init(); Ok(ValueRef::from_value(p_value)) } } @@ -425,13 +419,8 @@ impl ChangesetItem { /// `SQLITE_INSERT`. pub fn new_value(&self, col: usize) -> Result> { unsafe { - let mut p_value = MaybeUninit::uninit(); - check!(ffi::sqlite3changeset_new( - self.it, - col as i32, - p_value.as_mut_ptr() - )); - let p_value: *mut ffi::sqlite3_value = p_value.assume_init(); + let mut p_value: *mut ffi::sqlite3_value = ptr::null_mut(); + check!(ffi::sqlite3changeset_new(self.it, col as i32, &mut p_value,)); Ok(ValueRef::from_value(p_value)) } } @@ -442,13 +431,8 @@ impl ChangesetItem { /// `SQLITE_UPDATE`. pub fn old_value(&self, col: usize) -> Result> { unsafe { - let mut p_value = MaybeUninit::uninit(); - check!(ffi::sqlite3changeset_old( - self.it, - col as i32, - p_value.as_mut_ptr() - )); - let p_value: *mut ffi::sqlite3_value = p_value.assume_init(); + let mut p_value: *mut ffi::sqlite3_value = ptr::null_mut(); + check!(ffi::sqlite3changeset_old(self.it, col as i32, &mut p_value,)); Ok(ValueRef::from_value(p_value)) } } @@ -459,15 +443,14 @@ impl ChangesetItem { let mut code = 0; let mut indirect = 0; let tab = unsafe { - let mut pz_tab = MaybeUninit::uninit(); + let mut pz_tab: *const c_char = ptr::null(); check!(ffi::sqlite3changeset_op( self.it, - pz_tab.as_mut_ptr(), + &mut pz_tab, &mut number_of_columns, &mut code, &mut indirect )); - let pz_tab: *const c_char = pz_tab.assume_init(); CStr::from_ptr(pz_tab) }; let table_name = tab.to_str()?; @@ -483,13 +466,12 @@ impl ChangesetItem { pub fn pk(&self) -> Result<&[u8]> { let mut number_of_columns = 0; unsafe { - let mut pks = MaybeUninit::uninit(); + let mut pks: *mut c_uchar = ptr::null_mut(); check!(ffi::sqlite3changeset_pk( self.it, - pks.as_mut_ptr(), + &mut pks, &mut number_of_columns )); - let pks: *mut c_uchar = pks.assume_init(); Ok(from_raw_parts(pks, number_of_columns as usize)) } } @@ -503,9 +485,8 @@ pub struct Changegroup { impl Changegroup { pub fn new() -> Result { - let mut cg = MaybeUninit::uninit(); - check!(unsafe { ffi::sqlite3changegroup_new(cg.as_mut_ptr()) }); - let cg: *mut ffi::sqlite3_changegroup = unsafe { cg.assume_init() }; + let mut cg = ptr::null_mut(); + check!(unsafe { ffi::sqlite3changegroup_new(&mut cg) }); Ok(Changegroup { cg }) } @@ -531,9 +512,8 @@ impl Changegroup { /// Obtain a composite Changeset pub fn output(&mut self) -> Result { let mut n = 0; - let mut output = MaybeUninit::uninit(); - check!(unsafe { ffi::sqlite3changegroup_output(self.cg, &mut n, output.as_mut_ptr()) }); - let output: *mut c_void = unsafe { output.assume_init() }; + let mut output: *mut c_void = ptr::null_mut(); + check!(unsafe { ffi::sqlite3changegroup_output(self.cg, &mut n, &mut output) }); Ok(Changeset { cs: output, n }) } diff --git a/third_party/rust/rusqlite/src/statement.rs b/third_party/rust/rusqlite/src/statement.rs index 942fbe944643..2c3c14e19214 100644 --- a/third_party/rust/rusqlite/src/statement.rs +++ b/third_party/rust/rusqlite/src/statement.rs @@ -619,7 +619,7 @@ impl Statement<'_> { } fn finalize_(&mut self) -> Result<()> { - let mut stmt = RawStatement::new(ptr::null_mut(), false); + let mut stmt = unsafe { RawStatement::new(ptr::null_mut(), false) }; mem::swap(&mut stmt, &mut self.stmt); self.conn.decode_result(stmt.finalize()) } @@ -710,7 +710,7 @@ impl Statement<'_> { impl Into for Statement<'_> { fn into(mut self) -> RawStatement { - let mut stmt = RawStatement::new(ptr::null_mut(), false); + let mut stmt = unsafe { RawStatement::new(ptr::null_mut(), false) }; mem::swap(&mut stmt, &mut self.stmt); stmt } diff --git a/third_party/rust/rusqlite/src/types/to_sql.rs b/third_party/rust/rusqlite/src/types/to_sql.rs index 597d7c62987d..bec53f81fff0 100644 --- a/third_party/rust/rusqlite/src/types/to_sql.rs +++ b/third_party/rust/rusqlite/src/types/to_sql.rs @@ -90,7 +90,7 @@ pub trait ToSql { fn to_sql(&self) -> Result>; } -impl ToSql for Cow<'_, T> { +impl ToSql for Cow<'_, T> { fn to_sql(&self) -> Result> { self.as_ref().to_sql() } @@ -223,17 +223,20 @@ mod test { fn test_cow_str() { use std::borrow::Cow; let s = "str"; - let cow = Cow::Borrowed(s); + let cow: Cow = Cow::Borrowed(s); let r = cow.to_sql(); assert!(r.is_ok()); - let cow = Cow::Owned::(String::from(s)); + let cow: Cow = Cow::Owned::(String::from(s)); let r = cow.to_sql(); assert!(r.is_ok()); + // Ensure this compiles. + let _p: &[&dyn ToSql] = crate::params![cow]; } #[test] fn test_box_dyn() { let s: Box = Box::new("Hello world!"); + let _s: &[&dyn ToSql] = crate::params![s]; let r = ToSql::to_sql(&s); assert!(r.is_ok()); @@ -242,6 +245,7 @@ mod test { #[test] fn test_box_deref() { let s: Box = "Hello world!".into(); + let _s: &[&dyn ToSql] = crate::params![s]; let r = s.to_sql(); assert!(r.is_ok()); @@ -250,6 +254,7 @@ mod test { #[test] fn test_box_direct() { let s: Box = "Hello world!".into(); + let _s: &[&dyn ToSql] = crate::params![s]; let r = ToSql::to_sql(&s); assert!(r.is_ok()); @@ -261,11 +266,33 @@ mod test { let source_str: Box = "Hello world!".into(); - let s: Rc<_> = Rc::new(source_str.clone()); + let s: Rc> = Rc::new(source_str.clone()); + let _s: &[&dyn ToSql] = crate::params![s]; let r = s.to_sql(); assert!(r.is_ok()); - let s: Arc<_> = Arc::new(source_str); + let s: Arc> = Arc::new(source_str.clone()); + let _s: &[&dyn ToSql] = crate::params![s]; + let r = s.to_sql(); + assert!(r.is_ok()); + + let s: Arc = Arc::from(&*source_str); + let _s: &[&dyn ToSql] = crate::params![s]; + let r = s.to_sql(); + assert!(r.is_ok()); + + let s: Arc = Arc::new(source_str.clone()); + let _s: &[&dyn ToSql] = crate::params![s]; + let r = s.to_sql(); + assert!(r.is_ok()); + + let s: Rc = Rc::from(&*source_str); + let _s: &[&dyn ToSql] = crate::params![s]; + let r = s.to_sql(); + assert!(r.is_ok()); + + let s: Rc = Rc::new(source_str); + let _s: &[&dyn ToSql] = crate::params![s]; let r = s.to_sql(); assert!(r.is_ok()); } diff --git a/third_party/rust/rusqlite/src/unlock_notify.rs b/third_party/rust/rusqlite/src/unlock_notify.rs index 8b3d0fcb0d9f..6f82ae2690d8 100644 --- a/third_party/rust/rusqlite/src/unlock_notify.rs +++ b/third_party/rust/rusqlite/src/unlock_notify.rs @@ -53,10 +53,10 @@ unsafe extern "C" fn unlock_notify_cb(ap_arg: *mut *mut c_void, n_arg: c_int) { } #[cfg(feature = "unlock_notify")] -pub fn is_locked(db: *mut ffi::sqlite3, rc: c_int) -> bool { +pub unsafe fn is_locked(db: *mut ffi::sqlite3, rc: c_int) -> bool { rc == ffi::SQLITE_LOCKED_SHAREDCACHE || (rc & 0xFF) == ffi::SQLITE_LOCKED - && unsafe { ffi::sqlite3_extended_errcode(db) } == ffi::SQLITE_LOCKED_SHAREDCACHE + && ffi::sqlite3_extended_errcode(db) == ffi::SQLITE_LOCKED_SHAREDCACHE } /// This function assumes that an SQLite API call (either `sqlite3_prepare_v2()` @@ -72,16 +72,14 @@ pub fn is_locked(db: *mut ffi::sqlite3, rc: c_int) -> bool { /// this case the caller should not retry the operation and should roll /// back the current transaction (if any). #[cfg(feature = "unlock_notify")] -pub fn wait_for_unlock_notify(db: *mut ffi::sqlite3) -> c_int { +pub unsafe fn wait_for_unlock_notify(db: *mut ffi::sqlite3) -> c_int { let mut un = UnlockNotification::new(); /* Register for an unlock-notify callback. */ - let rc = unsafe { - ffi::sqlite3_unlock_notify( - db, - Some(unlock_notify_cb), - &mut un as *mut UnlockNotification as *mut c_void, - ) - }; + let rc = ffi::sqlite3_unlock_notify( + db, + Some(unlock_notify_cb), + &mut un as *mut UnlockNotification as *mut c_void, + ); debug_assert!( rc == ffi::SQLITE_LOCKED || rc == ffi::SQLITE_LOCKED_SHAREDCACHE || rc == ffi::SQLITE_OK ); @@ -92,12 +90,12 @@ pub fn wait_for_unlock_notify(db: *mut ffi::sqlite3) -> c_int { } #[cfg(not(feature = "unlock_notify"))] -pub fn is_locked(_db: *mut ffi::sqlite3, _rc: c_int) -> bool { +pub unsafe fn is_locked(_db: *mut ffi::sqlite3, _rc: c_int) -> bool { unreachable!() } #[cfg(not(feature = "unlock_notify"))] -pub fn wait_for_unlock_notify(_db: *mut ffi::sqlite3) -> c_int { +pub unsafe fn wait_for_unlock_notify(_db: *mut ffi::sqlite3) -> c_int { unreachable!() } diff --git a/third_party/rust/rusqlite/src/vtab/mod.rs b/third_party/rust/rusqlite/src/vtab/mod.rs index aa07c3fb4179..97124b59470b 100644 --- a/third_party/rust/rusqlite/src/vtab/mod.rs +++ b/third_party/rust/rusqlite/src/vtab/mod.rs @@ -70,8 +70,7 @@ unsafe impl Send for Module {} unsafe impl Sync for Module {} // Used as a trailing initializer for sqlite3_module -- this way we avoid having -// the build fail if buildtime_bindgen is on, our bindings have -// `sqlite3_module::xShadowName`, but vtab_v3 wasn't specified. +// the build fail if buildtime_bindgen is on fn zeroed_module() -> ffi::sqlite3_module { // This is safe, as bindgen-generated structs are allowed to be zeroed. unsafe { std::mem::MaybeUninit::zeroed().assume_init() } diff --git a/toolkit/library/rust/shared/Cargo.toml b/toolkit/library/rust/shared/Cargo.toml index 52671b5c6034..02285730209e 100644 --- a/toolkit/library/rust/shared/Cargo.toml +++ b/toolkit/library/rust/shared/Cargo.toml @@ -58,7 +58,7 @@ fluent-langneg-ffi = { path = "../../../../intl/locale/rust/fluent-langneg-ffi" # version less than or equal to what we link to. This isn't a problem because we # tend to keep this up to date, but it needs to be taken into consideration when # changing this version. -rusqlite = { version = "=0.22.0-beta.0", features = ["modern_sqlite", "in_gecko"] } +rusqlite = { version = "0.22.0", features = ["modern_sqlite", "in_gecko"] } fluent = { version = "0.11" , features = ["fluent-pseudo"] } fluent-ffi = { path = "../../../../intl/l10n/rust/fluent-ffi" }