[tracker/wip/carlosg/fts-delete] libtracker-data: Perform FTS deletes in a single query
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/fts-delete] libtracker-data: Perform FTS deletes in a single query
- Date: Sat, 7 Dec 2019 14:20:11 +0000 (UTC)
commit 574e546be4da1088eb0b1cf5a21113dd0b340609
Author: Carlos Garnacho <carlosg gnome org>
Date: Sat Dec 7 14:28:13 2019 +0100
libtracker-data: Perform FTS deletes in a single query
External content FTS5 tables have trouble with partial column updates,
possibly deeming the index corrupt afterwards. So perform deletes
just like updates, in a manner that a row is updated all at once.
As we were already doing the deletes for all FTS properties one by one
before proceeding with the insertion of new values, this is slightly
nicer in that we just make a single update now. Still quite a cumbersome
peculiarity.
src/libtracker-data/tracker-data-update.c | 24 +++++++++++++++++------
src/libtracker-data/tracker-db-interface-sqlite.c | 10 ++++++----
src/libtracker-data/tracker-db-interface-sqlite.h | 7 ++-----
3 files changed, 26 insertions(+), 15 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-update.c b/src/libtracker-data/tracker-data-update.c
index 65e9d8306..322d6c74a 100644
--- a/src/libtracker-data/tracker-data-update.c
+++ b/src/libtracker-data/tracker-data-update.c
@@ -1397,6 +1397,7 @@ get_old_property_values (TrackerData *data,
TrackerOntologies *ontologies;
guint i, n_props;
TrackerProperty **properties, *prop;
+ GPtrArray *fts_props, *fts_text;
/* first fulltext indexed property to be modified
* retrieve values of all fulltext indexed properties
@@ -1404,6 +1405,9 @@ get_old_property_values (TrackerData *data,
ontologies = tracker_data_manager_get_ontologies (data->manager);
properties = tracker_ontologies_get_properties (ontologies, &n_props);
+ fts_props = g_ptr_array_new ();
+ fts_text = g_ptr_array_new_with_free_func (g_free);
+
for (i = 0; i < n_props; i++) {
prop = properties[i];
@@ -1425,15 +1429,23 @@ get_old_property_values (TrackerData *data,
g_string_append (str, g_value_get_string (value));
}
- tracker_db_interface_sqlite_fts_delete_text (iface,
- database,
-
data->resource_buffer->id,
- property_name,
- str->str);
- g_string_free (str, TRUE);
+ g_ptr_array_add (fts_props, (gpointer) property_name);
+ g_ptr_array_add (fts_text, g_string_free (str, FALSE));
}
}
+ g_ptr_array_add (fts_props, NULL);
+ g_ptr_array_add (fts_text, NULL);
+
+ tracker_db_interface_sqlite_fts_delete_text (iface,
+ database,
+ data->resource_buffer->id,
+ (const gchar **)
fts_props->pdata,
+ (const gchar **)
fts_text->pdata);
+
+ g_ptr_array_unref (fts_props);
+ g_ptr_array_unref (fts_text);
+
data->update_buffer.fts_ever_updated = TRUE;
old_values = g_hash_table_lookup (data->resource_buffer->predicates,
property);
diff --git a/src/libtracker-data/tracker-db-interface-sqlite.c
b/src/libtracker-data/tracker-db-interface-sqlite.c
index 9bbb7b64f..92e72c7a8 100644
--- a/src/libtracker-data/tracker-db-interface-sqlite.c
+++ b/src/libtracker-data/tracker-db-interface-sqlite.c
@@ -2239,13 +2239,13 @@ gboolean
tracker_db_interface_sqlite_fts_delete_text (TrackerDBInterface *db_interface,
const gchar *database,
int rowid,
- const gchar *property,
- const gchar *old_text)
+ const gchar **properties,
+ const gchar **old_text)
{
TrackerDBStatement *stmt;
GError *error = NULL;
- const gchar *properties[] = { property, NULL };
gchar *query;
+ gint i;
query = tracker_db_interface_sqlite_fts_create_query (db_interface,
database,
@@ -2264,7 +2264,9 @@ tracker_db_interface_sqlite_fts_delete_text (TrackerDBInterface *db_interface,
}
tracker_db_statement_bind_int (stmt, 0, rowid);
- tracker_db_statement_bind_text (stmt, 1, old_text);
+ for (i = 0; old_text[i] != NULL; i++)
+ tracker_db_statement_bind_text (stmt, i + 1, old_text[i]);
+
tracker_db_statement_execute (stmt, &error);
g_object_unref (stmt);
diff --git a/src/libtracker-data/tracker-db-interface-sqlite.h
b/src/libtracker-data/tracker-db-interface-sqlite.h
index 81127539a..f8dc3c07b 100644
--- a/src/libtracker-data/tracker-db-interface-sqlite.h
+++ b/src/libtracker-data/tracker-db-interface-sqlite.h
@@ -79,14 +79,11 @@ gboolean tracker_db_interface_sqlite_fts_update_text (TrackerD
gboolean tracker_db_interface_sqlite_fts_delete_text (TrackerDBInterface *interface,
const gchar *database,
int rowid,
- const gchar *property,
- const gchar *old_text);
+ const gchar **properties,
+ const gchar **old_text);
gboolean tracker_db_interface_sqlite_fts_delete_id (TrackerDBInterface *interface,
const gchar *database,
int rowid);
-void tracker_db_interface_sqlite_fts_update_commit (TrackerDBInterface *interface);
-void tracker_db_interface_sqlite_fts_update_rollback (TrackerDBInterface *interface);
-
void tracker_db_interface_sqlite_fts_rebuild_tokens (TrackerDBInterface *interface,
const gchar *database);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]