From 9bb7c81046923757a8791f30b1e6973cd44e50d8 Mon Sep 17 00:00:00 2001 From: Ben Dean-Kawamura Date: Thu, 27 Jun 2024 21:01:58 +0000 Subject: [PATCH] Bug 1904437 - Vendor application-services 128.1, a=dmeehan This brings in the suggest reingestion performance change, which should fix the restart hang. Original Revision: https://phabricator.services.mozilla.com/D215148 Differential Revision: https://phabricator.services.mozilla.com/D215167 --- .cargo/config.toml.in | 4 +- Cargo.lock | 28 +++++------ Cargo.toml | 16 +++--- .../rust/sql-support/.cargo-checksum.json | 2 +- .../rust/sql-support/src/open_database.rs | 40 ++++++++++++++- third_party/rust/suggest/.cargo-checksum.json | 2 +- third_party/rust/suggest/src/db.rs | 12 +++++ third_party/rust/suggest/src/schema.rs | 49 ++++++++++++++++--- 8 files changed, 120 insertions(+), 33 deletions(-) diff --git a/.cargo/config.toml.in b/.cargo/config.toml.in index 00ad675c8dc4..4b320cf64210 100644 --- a/.cargo/config.toml.in +++ b/.cargo/config.toml.in @@ -60,9 +60,9 @@ git = "https://github.com/mozilla-spidermonkey/jsparagus" rev = "61f399c53a641ebd3077c1f39f054f6d396a633c" replace-with = "vendored-sources" -[source."git+https://github.com/mozilla/application-services?rev=3ca067683c7546e34bc8cdbe820fbe8e4089939a"] +[source."git+https://github.com/mozilla/application-services?rev=7c275b9088557abcbc8f3c2834f9aaa9064ca5e4"] git = "https://github.com/mozilla/application-services" -rev = "3ca067683c7546e34bc8cdbe820fbe8e4089939a" +rev = "7c275b9088557abcbc8f3c2834f9aaa9064ca5e4" replace-with = "vendored-sources" [source."git+https://github.com/mozilla/audioipc?rev=3495905752a4263827f5d43737f9ca3ed0243ce0"] diff --git a/Cargo.lock b/Cargo.lock index 8cb706a43f48..409b94693d58 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1698,7 +1698,7 @@ dependencies = [ [[package]] name = "error-support" version = "0.1.0" -source = "git+https://github.com/mozilla/application-services?rev=3ca067683c7546e34bc8cdbe820fbe8e4089939a#3ca067683c7546e34bc8cdbe820fbe8e4089939a" +source = "git+https://github.com/mozilla/application-services?rev=7c275b9088557abcbc8f3c2834f9aaa9064ca5e4#7c275b9088557abcbc8f3c2834f9aaa9064ca5e4" dependencies = [ "error-support-macros", "lazy_static", @@ -1710,7 +1710,7 @@ dependencies = [ [[package]] name = "error-support-macros" version = "0.1.0" -source = "git+https://github.com/mozilla/application-services?rev=3ca067683c7546e34bc8cdbe820fbe8e4089939a#3ca067683c7546e34bc8cdbe820fbe8e4089939a" +source = "git+https://github.com/mozilla/application-services?rev=7c275b9088557abcbc8f3c2834f9aaa9064ca5e4#7c275b9088557abcbc8f3c2834f9aaa9064ca5e4" dependencies = [ "proc-macro2", "quote", @@ -2966,7 +2966,7 @@ dependencies = [ [[package]] name = "interrupt-support" version = "0.1.0" -source = "git+https://github.com/mozilla/application-services?rev=3ca067683c7546e34bc8cdbe820fbe8e4089939a#3ca067683c7546e34bc8cdbe820fbe8e4089939a" +source = "git+https://github.com/mozilla/application-services?rev=7c275b9088557abcbc8f3c2834f9aaa9064ca5e4#7c275b9088557abcbc8f3c2834f9aaa9064ca5e4" dependencies = [ "lazy_static", "parking_lot", @@ -4157,7 +4157,7 @@ dependencies = [ [[package]] name = "nss_build_common" version = "0.1.0" -source = "git+https://github.com/mozilla/application-services?rev=3ca067683c7546e34bc8cdbe820fbe8e4089939a#3ca067683c7546e34bc8cdbe820fbe8e4089939a" +source = "git+https://github.com/mozilla/application-services?rev=7c275b9088557abcbc8f3c2834f9aaa9064ca5e4#7c275b9088557abcbc8f3c2834f9aaa9064ca5e4" [[package]] name = "nsstring" @@ -4837,7 +4837,7 @@ checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" [[package]] name = "relevancy" version = "0.1.0" -source = "git+https://github.com/mozilla/application-services?rev=3ca067683c7546e34bc8cdbe820fbe8e4089939a#3ca067683c7546e34bc8cdbe820fbe8e4089939a" +source = "git+https://github.com/mozilla/application-services?rev=7c275b9088557abcbc8f3c2834f9aaa9064ca5e4#7c275b9088557abcbc8f3c2834f9aaa9064ca5e4" dependencies = [ "anyhow", "base64 0.21.3", @@ -4860,7 +4860,7 @@ dependencies = [ [[package]] name = "remote_settings" version = "0.1.0" -source = "git+https://github.com/mozilla/application-services?rev=3ca067683c7546e34bc8cdbe820fbe8e4089939a#3ca067683c7546e34bc8cdbe820fbe8e4089939a" +source = "git+https://github.com/mozilla/application-services?rev=7c275b9088557abcbc8f3c2834f9aaa9064ca5e4#7c275b9088557abcbc8f3c2834f9aaa9064ca5e4" dependencies = [ "parking_lot", "serde", @@ -5395,7 +5395,7 @@ dependencies = [ [[package]] name = "sql-support" version = "0.1.0" -source = "git+https://github.com/mozilla/application-services?rev=3ca067683c7546e34bc8cdbe820fbe8e4089939a#3ca067683c7546e34bc8cdbe820fbe8e4089939a" +source = "git+https://github.com/mozilla/application-services?rev=7c275b9088557abcbc8f3c2834f9aaa9064ca5e4#7c275b9088557abcbc8f3c2834f9aaa9064ca5e4" dependencies = [ "ffi-support", "interrupt-support", @@ -5577,7 +5577,7 @@ checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" [[package]] name = "suggest" version = "0.1.0" -source = "git+https://github.com/mozilla/application-services?rev=3ca067683c7546e34bc8cdbe820fbe8e4089939a#3ca067683c7546e34bc8cdbe820fbe8e4089939a" +source = "git+https://github.com/mozilla/application-services?rev=7c275b9088557abcbc8f3c2834f9aaa9064ca5e4#7c275b9088557abcbc8f3c2834f9aaa9064ca5e4" dependencies = [ "anyhow", "chrono", @@ -5626,7 +5626,7 @@ dependencies = [ [[package]] name = "sync-guid" version = "0.1.0" -source = "git+https://github.com/mozilla/application-services?rev=3ca067683c7546e34bc8cdbe820fbe8e4089939a#3ca067683c7546e34bc8cdbe820fbe8e4089939a" +source = "git+https://github.com/mozilla/application-services?rev=7c275b9088557abcbc8f3c2834f9aaa9064ca5e4#7c275b9088557abcbc8f3c2834f9aaa9064ca5e4" dependencies = [ "base64 0.21.3", "rand", @@ -5637,7 +5637,7 @@ dependencies = [ [[package]] name = "sync15" version = "0.1.0" -source = "git+https://github.com/mozilla/application-services?rev=3ca067683c7546e34bc8cdbe820fbe8e4089939a#3ca067683c7546e34bc8cdbe820fbe8e4089939a" +source = "git+https://github.com/mozilla/application-services?rev=7c275b9088557abcbc8f3c2834f9aaa9064ca5e4#7c275b9088557abcbc8f3c2834f9aaa9064ca5e4" dependencies = [ "anyhow", "error-support", @@ -5668,7 +5668,7 @@ dependencies = [ [[package]] name = "tabs" version = "0.1.0" -source = "git+https://github.com/mozilla/application-services?rev=3ca067683c7546e34bc8cdbe820fbe8e4089939a#3ca067683c7546e34bc8cdbe820fbe8e4089939a" +source = "git+https://github.com/mozilla/application-services?rev=7c275b9088557abcbc8f3c2834f9aaa9064ca5e4#7c275b9088557abcbc8f3c2834f9aaa9064ca5e4" dependencies = [ "anyhow", "error-support", @@ -6004,7 +6004,7 @@ checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" [[package]] name = "types" version = "0.1.0" -source = "git+https://github.com/mozilla/application-services?rev=3ca067683c7546e34bc8cdbe820fbe8e4089939a#3ca067683c7546e34bc8cdbe820fbe8e4089939a" +source = "git+https://github.com/mozilla/application-services?rev=7c275b9088557abcbc8f3c2834f9aaa9064ca5e4#7c275b9088557abcbc8f3c2834f9aaa9064ca5e4" dependencies = [ "rusqlite", "serde", @@ -6381,7 +6381,7 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "viaduct" version = "0.1.0" -source = "git+https://github.com/mozilla/application-services?rev=3ca067683c7546e34bc8cdbe820fbe8e4089939a#3ca067683c7546e34bc8cdbe820fbe8e4089939a" +source = "git+https://github.com/mozilla/application-services?rev=7c275b9088557abcbc8f3c2834f9aaa9064ca5e4#7c275b9088557abcbc8f3c2834f9aaa9064ca5e4" dependencies = [ "ffi-support", "log", @@ -6529,7 +6529,7 @@ dependencies = [ [[package]] name = "webext-storage" version = "0.1.0" -source = "git+https://github.com/mozilla/application-services?rev=3ca067683c7546e34bc8cdbe820fbe8e4089939a#3ca067683c7546e34bc8cdbe820fbe8e4089939a" +source = "git+https://github.com/mozilla/application-services?rev=7c275b9088557abcbc8f3c2834f9aaa9064ca5e4#7c275b9088557abcbc8f3c2834f9aaa9064ca5e4" dependencies = [ "anyhow", "error-support", diff --git a/Cargo.toml b/Cargo.toml index de45b8f9eea9..bfca80a98b43 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -221,14 +221,14 @@ warp = { git = "https://github.com/seanmonstar/warp", rev = "9d081461ae1167eb321 malloc_size_of_derive = { path = "xpcom/rust/malloc_size_of_derive" } # application-services overrides to make updating them all simpler. -interrupt-support = { git = "https://github.com/mozilla/application-services", rev = "3ca067683c7546e34bc8cdbe820fbe8e4089939a" } -relevancy = { git = "https://github.com/mozilla/application-services", rev = "3ca067683c7546e34bc8cdbe820fbe8e4089939a" } -sql-support = { git = "https://github.com/mozilla/application-services", rev = "3ca067683c7546e34bc8cdbe820fbe8e4089939a" } -suggest = { git = "https://github.com/mozilla/application-services", rev = "3ca067683c7546e34bc8cdbe820fbe8e4089939a" } -sync15 = { git = "https://github.com/mozilla/application-services", rev = "3ca067683c7546e34bc8cdbe820fbe8e4089939a" } -tabs = { git = "https://github.com/mozilla/application-services", rev = "3ca067683c7546e34bc8cdbe820fbe8e4089939a" } -viaduct = { git = "https://github.com/mozilla/application-services", rev = "3ca067683c7546e34bc8cdbe820fbe8e4089939a" } -webext-storage = { git = "https://github.com/mozilla/application-services", rev = "3ca067683c7546e34bc8cdbe820fbe8e4089939a" } +interrupt-support = { git = "https://github.com/mozilla/application-services", rev = "7c275b9088557abcbc8f3c2834f9aaa9064ca5e4" } +relevancy = { git = "https://github.com/mozilla/application-services", rev = "7c275b9088557abcbc8f3c2834f9aaa9064ca5e4" } +sql-support = { git = "https://github.com/mozilla/application-services", rev = "7c275b9088557abcbc8f3c2834f9aaa9064ca5e4" } +suggest = { git = "https://github.com/mozilla/application-services", rev = "7c275b9088557abcbc8f3c2834f9aaa9064ca5e4" } +sync15 = { git = "https://github.com/mozilla/application-services", rev = "7c275b9088557abcbc8f3c2834f9aaa9064ca5e4" } +tabs = { git = "https://github.com/mozilla/application-services", rev = "7c275b9088557abcbc8f3c2834f9aaa9064ca5e4" } +viaduct = { git = "https://github.com/mozilla/application-services", rev = "7c275b9088557abcbc8f3c2834f9aaa9064ca5e4" } +webext-storage = { git = "https://github.com/mozilla/application-services", rev = "7c275b9088557abcbc8f3c2834f9aaa9064ca5e4" } # Patch mio 0.8.8 to use windows-sys 0.52 (backport https://github.com/tokio-rs/mio/commit/eea9e3e0c469480e5c59c01e6c3c7e5fd88f0848) mio_0_8 = { package = "mio", git = "https://github.com/glandium/mio", rev = "9a2ef335c366044ffe73b1c4acabe50a1daefe05" } diff --git a/third_party/rust/sql-support/.cargo-checksum.json b/third_party/rust/sql-support/.cargo-checksum.json index 0633954ed265..d10f9a159e3c 100644 --- a/third_party/rust/sql-support/.cargo-checksum.json +++ b/third_party/rust/sql-support/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"6765229acc1f06326b3ede93379d78d119aa78679567baf0bf7bdb5ec310522f","src/conn_ext.rs":"d4eddf906ecf5d45b8cf9e858751cc22e644e652f04560237f8de748a33d56f6","src/debug_tools.rs":"bece2bc3d35379b81ea2f942a0a3e909e0ab0553656505904745548eacaf402a","src/each_chunk.rs":"e900a4ebadad31b0a87cb8d7c3ed5aeb7325d4d380ae1d9174eff62c78facdcc","src/lazy.rs":"a96b4f4ec572538b49cdfa8fee981dcf5143a5f51163fb8a573d3ac128df70f9","src/lib.rs":"b2c120db4928c3e4abdd96405fd4c1016255699bdbc38c8cd60dbd3431fc0a12","src/maybe_cached.rs":"0b18425595055883a98807fbd62ff27a79c18af34e7cb3439f8c3438463ef2dd","src/open_database.rs":"1de254e20df724f74be6c6d3bd54c77c9dd8eb009ef0a33c2e0a15da8f5c2aa3","src/repeat.rs":"b4c5ff5d083afba7f9f153f54aba2e6859b78b85c82d48dbd6bd58f67da9e6b9"},"package":null} \ No newline at end of file +{"files":{"Cargo.toml":"6765229acc1f06326b3ede93379d78d119aa78679567baf0bf7bdb5ec310522f","src/conn_ext.rs":"d4eddf906ecf5d45b8cf9e858751cc22e644e652f04560237f8de748a33d56f6","src/debug_tools.rs":"bece2bc3d35379b81ea2f942a0a3e909e0ab0553656505904745548eacaf402a","src/each_chunk.rs":"e900a4ebadad31b0a87cb8d7c3ed5aeb7325d4d380ae1d9174eff62c78facdcc","src/lazy.rs":"a96b4f4ec572538b49cdfa8fee981dcf5143a5f51163fb8a573d3ac128df70f9","src/lib.rs":"b2c120db4928c3e4abdd96405fd4c1016255699bdbc38c8cd60dbd3431fc0a12","src/maybe_cached.rs":"0b18425595055883a98807fbd62ff27a79c18af34e7cb3439f8c3438463ef2dd","src/open_database.rs":"c8e46d682da499e1b9ab0fd7f8a21f6140d1f9520b40b21cb7bd3f542e3d5f3e","src/repeat.rs":"b4c5ff5d083afba7f9f153f54aba2e6859b78b85c82d48dbd6bd58f67da9e6b9"},"package":null} \ No newline at end of file diff --git a/third_party/rust/sql-support/src/open_database.rs b/third_party/rust/sql-support/src/open_database.rs index ab81ae9f97af..6c0da516df5c 100644 --- a/third_party/rust/sql-support/src/open_database.rs +++ b/third_party/rust/sql-support/src/open_database.rs @@ -423,6 +423,7 @@ pub mod test_utils { pub fn assert_schema_matches_new_database(&self) { let db = self.open(); let new_db = open_memory_database(&self.connection_initializer).unwrap(); + let table_names = get_table_names(&db); let new_db_table_names = get_table_names(&new_db); let extra_tables = Vec::from_iter(table_names.difference(&new_db_table_names)); @@ -433,7 +434,6 @@ pub mod test_utils { if !new_db_extra_tables.is_empty() { panic!("Extra tables only present in new database: {new_db_extra_tables:?}"); } - for table_name in table_names { assert_eq!( get_table_sql(&db, &table_name), @@ -441,6 +441,24 @@ pub mod test_utils { "sql differs for table: {table_name}", ); } + + let index_names = get_index_names(&db); + let new_db_index_names = get_index_names(&new_db); + let extra_index = Vec::from_iter(index_names.difference(&new_db_index_names)); + if !extra_index.is_empty() { + panic!("Extra indexes not present in new database: {extra_index:?}"); + } + let new_db_extra_index = Vec::from_iter(new_db_index_names.difference(&index_names)); + if !new_db_extra_index.is_empty() { + panic!("Extra indexes only present in new database: {new_db_extra_index:?}"); + } + for index_name in index_names { + assert_eq!( + get_index_sql(&db, &index_name), + get_index_sql(&new_db, &index_name), + "sql differs for index: {index_name}", + ); + } } pub fn open(&self) -> Connection { @@ -467,6 +485,26 @@ pub mod test_utils { ) .unwrap() } + + fn get_index_names(conn: &Connection) -> HashSet { + conn.query_rows_and_then( + "SELECT name FROM sqlite_master WHERE type='index'", + (), + |row| row.get(0), + ) + .unwrap() + .into_iter() + .collect() + } + + fn get_index_sql(conn: &Connection, index_name: &str) -> String { + conn.query_row_and_then( + "SELECT sql FROM sqlite_master WHERE name = ? AND type='index'", + (&index_name,), + |row| row.get::<_, String>(0), + ) + .unwrap() + } } #[cfg(test)] diff --git a/third_party/rust/suggest/.cargo-checksum.json b/third_party/rust/suggest/.cargo-checksum.json index 2b13858e6d42..e03da84199f8 100644 --- a/third_party/rust/suggest/.cargo-checksum.json +++ b/third_party/rust/suggest/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"b2d2fb29d7408dd736650935a89627490c25ef813a5244ecd1bd9dad30e32b78","README.md":"dd0c0d3fc180f2021d81ea5804895f661cb4fe45b87fe5b1ebf8aa756988e867","benches/benchmark_all.rs":"c2343c9197b6d9ccb0798d7701b1b0d2569d494dd31a975d21d7ec6f26e32879","build.rs":"78780c5cccfe22c3ff4198624b9e188559c437c3e6fa1c8bb66548eee6aa66bf","src/benchmarks/README.md":"ccee8dbddba8762d0453fa855bd6984137b224b8c019f3dd8e86a3c303f51d71","src/benchmarks/client.rs":"b65f3d53323c827ca55cc02442b63a137c783530cc93225a90b02bc4e9790d0f","src/benchmarks/ingest.rs":"8cce7a9162bc1080e58e7f18a27c64f74cb45598fa33d3c2579f30e9b0414d50","src/benchmarks/mod.rs":"fe1898ba4d783213525da10d92858ee84cebfd22749bad7aeb461d338fe5504a","src/bin/debug_ingestion_sizes.rs":"ce6e810be7b3fc19e826d75b622b82cfab5a1a99397a6d0833c2c4eebff2d364","src/config.rs":"d40c6e83d8b5faa32c66110803ca9e78611d43507e9d3f1e191a93a7773c37b3","src/db.rs":"f2c986a8255e8359ddabd70b3dbab50713d092f3e5dfe85581a60f24655c1686","src/error.rs":"d5e0ec57aefc19d3e0230bb8832ca6fa603a18feabfc3a3e0f06ac940cc4e45e","src/keyword.rs":"988d0ab021c0df19cfd3c519df7d37f606bf984cd14d0efca4e5a7aff88344dd","src/lib.rs":"73887af023e223188f874d43ddf601784c93e9388a7adece79818d559a3366a1","src/pocket.rs":"1316668840ec9b4ea886223921dc9d3b5a1731d1a5206c0b1089f2a6c45c1b7b","src/provider.rs":"92eb1a9fa7d6814efe47fc3e7447e46bf6c0320d6fbef0d9170c46eab0e272ab","src/query.rs":"1084548b9dc0587322f08741e07db9413e9fa231166593bdbf47e562d31799a3","src/rs.rs":"0eabd6108fd1316265def15f9d232b2f70a72126019891bf4f52f5a8c6f72d1a","src/schema.rs":"88ff3ae6b652fa5a5cff4dc504d11a7fc33f1b2ee9716b970f646d9f9ca90ab7","src/store.rs":"f47de3b4da2677bdca8edd1b017f1580b9985f36d2d86b904e1058893c9f3445","src/suggest.udl":"4bfd70767a204dc58081be5d70ca96480b04b9acb741e6d2d8394362677f119d","src/suggestion.rs":"f31227779d13d1b03a622e08a417ceba4afb161885a01c2bc87a6a652b5e8be5","src/testing/client.rs":"855c14a2a5c5d9a33521c44dbb0d89f5ff531c5d125fb62d6491190c4c887df0","src/testing/data.rs":"dcd24d24997fe4f8c472f5b754a9a2b90b83e2632b4f13a77499e23441a6dea1","src/testing/mod.rs":"308c9e0f479b3d8ca6c206853842e42ce07721161f3dcc23b7018a7e4d687b03","src/yelp.rs":"bc036ff71b438d53ce8811acd8d650d83ef03faeea476f5b659b403c1e64ff2b","uniffi.toml":"f26317442ddb5b3281245bef6e60ffcb78bb95d29fe4a351a56dbb88d4ec8aab"},"package":null} \ No newline at end of file +{"files":{"Cargo.toml":"b2d2fb29d7408dd736650935a89627490c25ef813a5244ecd1bd9dad30e32b78","README.md":"dd0c0d3fc180f2021d81ea5804895f661cb4fe45b87fe5b1ebf8aa756988e867","benches/benchmark_all.rs":"c2343c9197b6d9ccb0798d7701b1b0d2569d494dd31a975d21d7ec6f26e32879","build.rs":"78780c5cccfe22c3ff4198624b9e188559c437c3e6fa1c8bb66548eee6aa66bf","src/benchmarks/README.md":"ccee8dbddba8762d0453fa855bd6984137b224b8c019f3dd8e86a3c303f51d71","src/benchmarks/client.rs":"b65f3d53323c827ca55cc02442b63a137c783530cc93225a90b02bc4e9790d0f","src/benchmarks/ingest.rs":"8cce7a9162bc1080e58e7f18a27c64f74cb45598fa33d3c2579f30e9b0414d50","src/benchmarks/mod.rs":"fe1898ba4d783213525da10d92858ee84cebfd22749bad7aeb461d338fe5504a","src/bin/debug_ingestion_sizes.rs":"ce6e810be7b3fc19e826d75b622b82cfab5a1a99397a6d0833c2c4eebff2d364","src/config.rs":"d40c6e83d8b5faa32c66110803ca9e78611d43507e9d3f1e191a93a7773c37b3","src/db.rs":"a8bb454995543bf7f02bfca938c3da2dec5131c2388af7312cdf6068fa042592","src/error.rs":"d5e0ec57aefc19d3e0230bb8832ca6fa603a18feabfc3a3e0f06ac940cc4e45e","src/keyword.rs":"988d0ab021c0df19cfd3c519df7d37f606bf984cd14d0efca4e5a7aff88344dd","src/lib.rs":"73887af023e223188f874d43ddf601784c93e9388a7adece79818d559a3366a1","src/pocket.rs":"1316668840ec9b4ea886223921dc9d3b5a1731d1a5206c0b1089f2a6c45c1b7b","src/provider.rs":"92eb1a9fa7d6814efe47fc3e7447e46bf6c0320d6fbef0d9170c46eab0e272ab","src/query.rs":"1084548b9dc0587322f08741e07db9413e9fa231166593bdbf47e562d31799a3","src/rs.rs":"0eabd6108fd1316265def15f9d232b2f70a72126019891bf4f52f5a8c6f72d1a","src/schema.rs":"8c963db3e047828c81619128430c47a4beee3a48fd5b72700f364e90dc2e96d1","src/store.rs":"f47de3b4da2677bdca8edd1b017f1580b9985f36d2d86b904e1058893c9f3445","src/suggest.udl":"4bfd70767a204dc58081be5d70ca96480b04b9acb741e6d2d8394362677f119d","src/suggestion.rs":"f31227779d13d1b03a622e08a417ceba4afb161885a01c2bc87a6a652b5e8be5","src/testing/client.rs":"855c14a2a5c5d9a33521c44dbb0d89f5ff531c5d125fb62d6491190c4c887df0","src/testing/data.rs":"dcd24d24997fe4f8c472f5b754a9a2b90b83e2632b4f13a77499e23441a6dea1","src/testing/mod.rs":"308c9e0f479b3d8ca6c206853842e42ce07721161f3dcc23b7018a7e4d687b03","src/yelp.rs":"bc036ff71b438d53ce8811acd8d650d83ef03faeea476f5b659b403c1e64ff2b","uniffi.toml":"f26317442ddb5b3281245bef6e60ffcb78bb95d29fe4a351a56dbb88d4ec8aab"},"package":null} \ No newline at end of file diff --git a/third_party/rust/suggest/src/db.rs b/third_party/rust/suggest/src/db.rs index 4e12a87969eb..65bac9f2c8d6 100644 --- a/third_party/rust/suggest/src/db.rs +++ b/third_party/rust/suggest/src/db.rs @@ -1026,6 +1026,18 @@ impl<'a> SuggestDao<'a> { /// Deletes all suggestions associated with a Remote Settings record from /// the database. pub fn drop_suggestions(&mut self, record_id: &SuggestRecordId) -> Result<()> { + self.conn.execute_cached( + "DELETE FROM keywords WHERE suggestion_id IN (SELECT id from suggestions WHERE record_id = :record_id)", + named_params! { ":record_id": record_id.as_str() }, + )?; + self.conn.execute_cached( + "DELETE FROM full_keywords WHERE suggestion_id IN (SELECT id from suggestions WHERE record_id = :record_id)", + named_params! { ":record_id": record_id.as_str() }, + )?; + self.conn.execute_cached( + "DELETE FROM prefix_keywords WHERE suggestion_id IN (SELECT id from suggestions WHERE record_id = :record_id)", + named_params! { ":record_id": record_id.as_str() }, + )?; self.conn.execute_cached( "DELETE FROM suggestions WHERE record_id = :record_id", named_params! { ":record_id": record_id.as_str() }, diff --git a/third_party/rust/suggest/src/schema.rs b/third_party/rust/suggest/src/schema.rs index 76a0deed3979..1fd9ac97ef85 100644 --- a/third_party/rust/suggest/src/schema.rs +++ b/third_party/rust/suggest/src/schema.rs @@ -15,7 +15,7 @@ use sql_support::open_database::{self, ConnectionInitializer}; /// [`SuggestConnectionInitializer::upgrade_from`]. /// a. If suggestions should be re-ingested after the migration, call `clear_database()` inside /// the migration. -pub const VERSION: u32 = 19; +pub const VERSION: u32 = 20; /// The current Suggest database schema. pub const SQL: &str = " @@ -26,17 +26,16 @@ CREATE TABLE meta( CREATE TABLE keywords( keyword TEXT NOT NULL, - suggestion_id INTEGER NOT NULL REFERENCES suggestions(id) ON DELETE CASCADE, - full_keyword_id INTEGER NULL REFERENCES full_keywords(id) ON DELETE SET NULL, + suggestion_id INTEGER NOT NULL, + full_keyword_id INTEGER NULL, rank INTEGER NOT NULL, PRIMARY KEY (keyword, suggestion_id) ) WITHOUT ROWID; -- full keywords are what we display to the user when a (partial) keyword matches --- The FK to suggestion_id makes it so full keywords get deleted when the parent suggestion is deleted. CREATE TABLE full_keywords( id INTEGER PRIMARY KEY, - suggestion_id INTEGER NOT NULL REFERENCES suggestions(id) ON DELETE CASCADE, + suggestion_id INTEGER NOT NULL, full_keyword TEXT NOT NULL ); @@ -45,7 +44,7 @@ CREATE TABLE prefix_keywords( keyword_suffix TEXT NOT NULL DEFAULT '', confidence INTEGER NOT NULL DEFAULT 0, rank INTEGER NOT NULL, - suggestion_id INTEGER NOT NULL REFERENCES suggestions(id) ON DELETE CASCADE, + suggestion_id INTEGER NOT NULL, PRIMARY KEY (keyword_prefix, keyword_suffix, suggestion_id) ) WITHOUT ROWID; @@ -193,6 +192,41 @@ CREATE TABLE IF NOT EXISTS dismissed_suggestions ( )?; Ok(()) } + 19 => { + // Clear the database since we're going to be dropping the keywords table and + // re-creating it + clear_database(tx)?; + tx.execute_batch( + " +-- Recreate the various keywords table to drop the foreign keys. +DROP TABLE keywords; +DROP TABLE full_keywords; +DROP TABLE prefix_keywords; +CREATE TABLE keywords( + keyword TEXT NOT NULL, + suggestion_id INTEGER NOT NULL, + full_keyword_id INTEGER NULL, + rank INTEGER NOT NULL, + PRIMARY KEY (keyword, suggestion_id) +) WITHOUT ROWID; +CREATE TABLE full_keywords( + id INTEGER PRIMARY KEY, + suggestion_id INTEGER NOT NULL, + full_keyword TEXT NOT NULL +); +CREATE TABLE prefix_keywords( + keyword_prefix TEXT NOT NULL, + keyword_suffix TEXT NOT NULL DEFAULT '', + confidence INTEGER NOT NULL DEFAULT 0, + rank INTEGER NOT NULL, + suggestion_id INTEGER NOT NULL, + PRIMARY KEY (keyword_prefix, keyword_suffix, suggestion_id) +) WITHOUT ROWID; +CREATE UNIQUE INDEX keywords_suggestion_id_rank ON keywords(suggestion_id, rank); + ", + )?; + Ok(()) + } _ => Err(open_database::Error::IncompatibleVersion(version)), } } @@ -203,6 +237,9 @@ pub fn clear_database(db: &Connection) -> rusqlite::Result<()> { db.execute_batch( " DELETE FROM meta; + DELETE FROM keywords; + DELETE FROM full_keywords; + DELETE FROM prefix_keywords; DELETE FROM suggestions; DELETE FROM icons; DELETE FROM yelp_subjects;