[tracker] Removing the fulltext values from the FTS store
- From: Philip Van Hoof <pvanhoof src gnome org>
- To: svn-commits-list gnome org
- Subject: [tracker] Removing the fulltext values from the FTS store
- Date: Tue, 28 Jul 2009 11:57:37 +0000 (UTC)
commit 84fc83febb13737868f69084bd3d6b15942a8510
Author: Philip Van Hoof <philip codeminded be>
Date: Tue Jul 28 13:56:57 2009 +0200
Removing the fulltext values from the FTS store
src/libtracker-data/tracker-data-update.c | 133 +++++++++++++++++++++++++---
1 files changed, 118 insertions(+), 15 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-update.c b/src/libtracker-data/tracker-data-update.c
index 8ba679b..9869aef 100644
--- a/src/libtracker-data/tracker-data-update.c
+++ b/src/libtracker-data/tracker-data-update.c
@@ -743,6 +743,7 @@ tracker_data_delete_statement (const gchar *subject,
TrackerDBStatement *stmt;
TrackerDBResultSet *result_set;
TrackerProperty **properties, **prop;
+ GString *projection = NULL;
iface = tracker_db_manager_get_db_interface ();
@@ -771,8 +772,125 @@ tracker_data_delete_statement (const gchar *subject,
properties = tracker_ontology_get_properties ();
+ for (prop = properties; *prop; prop++) {
+
+ if (tracker_property_get_domain (*prop) != class) {
+ continue;
+ }
+
+ if (!tracker_property_get_multiple_values (*prop)) {
+
+ if (tracker_property_get_fulltext_indexed (*prop)) {
+ if (!projection) {
+ projection = g_string_new ("");
+ } else {
+ g_string_append_c (projection, ',');
+ }
+
+ g_string_append_c (projection, '\'');
+ g_string_append (projection, tracker_property_get_name (*prop));
+ g_string_append (projection, "',");
+ g_string_append_c (projection, '"');
+ g_string_append (projection, tracker_property_get_name (*prop));
+ g_string_append_c (projection, '"');
+ }
+ } else {
+
+ if (tracker_property_get_fulltext_indexed (*prop)) {
+
+ /* Removing all fulltext properties from fts for
+ * none nrl:maxCardinality */
+
+ stmt = tracker_db_interface_create_statement (iface, "SELECT \"%s\" FROM \"%s_%s\" WHERE ID = ?",
+ tracker_property_get_name (*prop),
+ tracker_class_get_name (class),
+ tracker_property_get_name (*prop));
+ tracker_db_statement_bind_int (stmt, 0, subject_id);
+ result_set = tracker_db_statement_execute (stmt, NULL);
+ g_object_unref (stmt);
+
+ if (result_set) {
+ gchar *prop_object = NULL;
+
+ tracker_db_result_set_get (result_set, 0, &prop_object, -1);
+ g_object_unref (result_set);
+
+ if (prop_object) {
+ stmt = tracker_db_interface_create_statement (iface,
+ "UPDATE \"fts\" SET \"%s\" = ?, \"fts\" = -1 WHERE rowid = ?",
+ tracker_property_get_name (*prop));
+ tracker_db_statement_bind_text (stmt, 0, prop_object);
+ tracker_db_statement_bind_int (stmt, 1, subject_id);
+
+ tracker_db_statement_execute (stmt, NULL);
+
+ g_free (prop_object);
+ g_object_unref (stmt);
+ }
+ }
+ }
+
+ /* multi-valued property, delete values from DB */
+ stmt = tracker_db_interface_create_statement (iface, "DELETE FROM \"%s_%s\" WHERE ID = ?",
+ tracker_class_get_name (class),
+ tracker_property_get_name (*prop));
+ tracker_db_statement_bind_int (stmt, 0, subject_id);
+ tracker_db_statement_execute (stmt, NULL);
+ g_object_unref (stmt);
+ }
+ }
+
/* delete single-valued properties for current class */
+ if (projection) {
+
+ /* Removing all fulltext properties from fts for
+ * nrl:maxCardinality 1 */
+
+ stmt = tracker_db_interface_create_statement (iface, "SELECT %s FROM \"%s\" WHERE ID = ?",
+ projection->str,
+ tracker_class_get_name (class));
+ g_string_free (projection, TRUE);
+
+ tracker_db_statement_bind_int (stmt, 0, subject_id);
+ result_set = tracker_db_statement_execute (stmt, NULL);
+ g_object_unref (stmt);
+
+ if (result_set) {
+ gchar *prop_object = NULL;
+ gchar *prop_name = NULL;
+ guint columns, c;
+
+ do {
+ columns = tracker_db_result_set_get_n_columns (result_set);
+ for (c = 0; c < columns; c += 2) {
+ tracker_db_result_set_get (result_set, c, &prop_name, -1);
+ tracker_db_result_set_get (result_set, c + 1, &prop_object, -1);
+
+ if (prop_object && prop_name) {
+ stmt = tracker_db_interface_create_statement (iface,
+ "UPDATE \"fts\" SET \"%s\" = ?, \"fts\" = -1 WHERE rowid = ?",
+ prop_name);
+ tracker_db_statement_bind_text (stmt, 0, prop_object);
+ tracker_db_statement_bind_int (stmt, 1, subject_id);
+
+ tracker_db_statement_execute (stmt, NULL);
+
+ g_object_unref (stmt);
+ }
+
+ g_free (prop_object);
+ prop_object = NULL;
+ g_free (prop_name);
+ prop_name = NULL;
+
+ }
+ } while (tracker_db_result_set_iter_next (result_set));
+
+ g_object_unref (result_set);
+ }
+ }
+
stmt = tracker_db_interface_create_statement (iface, "DELETE FROM \"%s\" WHERE ID = ?",
tracker_class_get_name (class));
tracker_db_statement_bind_int (stmt, 0, subject_id);
@@ -786,21 +904,6 @@ tracker_data_delete_statement (const gchar *subject,
g_object_unref (stmt);
}
- for (prop = properties; *prop; prop++) {
- if (tracker_property_get_domain (*prop) != class
- || !tracker_property_get_multiple_values (*prop)) {
- continue;
- }
-
- /* multi-valued property, delete values from DB */
- stmt = tracker_db_interface_create_statement (iface, "DELETE FROM \"%s_%s\" WHERE ID = ?",
- tracker_class_get_name (class),
- tracker_property_get_name (*prop));
- tracker_db_statement_bind_int (stmt, 0, subject_id);
- tracker_db_statement_execute (stmt, NULL);
- g_object_unref (stmt);
- }
-
/* delete rows from class tables */
delete_resource_type (subject_id, class);
} else {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]