Hey Jürg,

Check attached new patch for new review.

I tested with both multi and single value properties. It seems to work.

On Tue, 2009-07-28 at 09:27 +0200, Jürg Billeter wrote:
> On Mon, 2009-07-27 at 21:23 +0200, Philip Van Hoof wrote:
> > > +
> > > tracker_db_statement_bind_text (stmt, 0, object);
> > 
> > I just realize that the object here is probably wrong. As the object
> > holds the rdf:type's value, and not the value of the original. As is the
> > case in the else block of the function.
> 
> Yes, object is wrong here.
> 
> > I'll await your review to check if this is the right way to solve this
> > issue. We could for example first SELECT the value out of the fts table,
> > to feed it back during the UPDATE. Not sure ...
> 
> We need to retrieve the value from the decomposed table, the virtual fts
> table only stores the full-text index, it does not store the content in
> fields.
> 
> The remove_fts conditional inside the loop is wrong, we should always
> remove all property values with the right domain. The string comparison
> with "rdfs:Resource" is only relevant for deciding whether to delete the
> whole row, not for the individual properties.
> 
> The DELETE statement for the fts table should be kept, it just needs to
> be moved down after the property loop. The implementation in the
> tracker-fts module needs to be fixed as well - that's what is really
> responsible for the error messages in the log -, I'll take care of that.
> 
> Thanks.
> Jürg
> 
> 
-- 
Philip Van Hoof, freelance software developer
home: me at pvanhoof dot be 
gnome: pvanhoof at gnome dot org 
http://pvanhoof.be/blog
http://codeminded.be
diff --git a/data/ontologies/91-maemo.ontology b/data/ontologies/91-maemo.ontology
index 675c996..298feea 100644
--- a/data/ontologies/91-maemo.ontology
+++ b/data/ontologies/91-maemo.ontology
@@ -35,3 +35,9 @@ maemo:BrowserBookmarkFolder a nfo:BookmarkFolder .
 maemo:bookmarkThumbnail a rdf:Property ;
    rdfs:domain nfo:Bookmark ;
    rdfs:range  xsd:string .
+
+maemo:bookmarkTest a rdf:Property ;
+   rdfs:domain nfo:Bookmark ;
+   rdfs:range  xsd:string ;
+   tracker:fulltextIndexed true .
+
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 {
_______________________________________________
tracker-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/tracker-list

Reply via email to