46 lines
2.2 KiB
Diff
46 lines
2.2 KiB
Diff
|
From 29a6650f698bbd449e11fc0481269cd8f0593f27 Mon Sep 17 00:00:00 2001
|
||
|
From: Carlos Garnacho <carlosg@gnome.org>
|
||
|
Date: Thu, 10 Dec 2020 03:55:08 +0100
|
||
|
Subject: [PATCH] libtracker-data: Avoid deletion of empty rows in FTS table
|
||
|
|
||
|
Starting with SQLite 3.34.0, this turns into a consistency error. Ensure
|
||
|
rows being deleted have actually some content before proceeding to deletion,
|
||
|
and ensure we don't process individual properties one by one in the course
|
||
|
of a whole rdfs:Resource deletion.
|
||
|
|
||
|
Fixes: https://bugs.archlinux.org/task/68903
|
||
|
---
|
||
|
src/libtracker-data/tracker-data-update.c | 1 +
|
||
|
src/libtracker-data/tracker-db-interface-sqlite.c | 3 ++-
|
||
|
2 files changed, 3 insertions(+), 1 deletion(-)
|
||
|
|
||
|
diff --git a/src/libtracker-data/tracker-data-update.c b/src/libtracker-data/tracker-data-update.c
|
||
|
index e2f46685e..19cae25f9 100644
|
||
|
--- a/src/libtracker-data/tracker-data-update.c
|
||
|
+++ b/src/libtracker-data/tracker-data-update.c
|
||
|
@@ -2244,6 +2244,7 @@ cache_delete_resource_type_full (TrackerData *data,
|
||
|
g_hash_table_size (data->resource_buffer->tables) == 0) {
|
||
|
#if HAVE_TRACKER_FTS
|
||
|
tracker_db_interface_sqlite_fts_delete_id (iface, data->resource_buffer->id);
|
||
|
+ data->resource_buffer->fts_updated = TRUE;
|
||
|
#endif
|
||
|
/* skip subclass query when deleting whole resource
|
||
|
to improve performance */
|
||
|
diff --git a/src/libtracker-data/tracker-db-interface-sqlite.c b/src/libtracker-data/tracker-db-interface-sqlite.c
|
||
|
index da88080ed..cdeb960e7 100644
|
||
|
--- a/src/libtracker-data/tracker-db-interface-sqlite.c
|
||
|
+++ b/src/libtracker-data/tracker-db-interface-sqlite.c
|
||
|
@@ -1770,7 +1770,8 @@ tracker_db_interface_sqlite_fts_create_delete_all_query (TrackerDBInterface *db_
|
||
|
g_string_append_printf (insert_str,
|
||
|
"INSERT INTO fts5 (fts5, rowid %s) "
|
||
|
"SELECT 'delete', rowid %s FROM fts_view "
|
||
|
- "WHERE rowid = ?",
|
||
|
+ "WHERE rowid = ? AND COALESCE(NULL %s) IS NOT NULL",
|
||
|
+ db_interface->fts_properties,
|
||
|
db_interface->fts_properties,
|
||
|
db_interface->fts_properties);
|
||
|
return g_string_free (insert_str, FALSE);
|
||
|
--
|
||
|
2.32.0
|
||
|
|