[tracker/wip/carlosg/anonymous-nodes: 12/24] libtracker-data: Deal with triple subjects as int64 ROWIDs




commit 3cb76b3da8f7eb125c7fb27b1daca9c5e49a4504
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sat Sep 25 12:52:29 2021 +0200

    libtracker-data: Deal with triple subjects as int64 ROWIDs
    
    Make the deepmost tracker_data_insert/delete_statement()
    (and it's ugly tracker_data_update_statement() brother) handle
    triple subjects as ROWIDs, instead of URI strings.
    
    This makes the caller responsible for transforming these URI
    strings to ROWIDs (maybe creating a new entry in the Resource
    table if necessary), but makes this internal machinery agnostic
    of the resource URIs themselves.
    
    This will be useful to minimize URI<->ID transformations, and
    deal with truly blank nodes.

 src/libtracker-data/tracker-data-manager.c |  44 +++++++++--
 src/libtracker-data/tracker-data-update.c  | 123 ++++++++++++-----------------
 src/libtracker-data/tracker-data-update.h  |   6 +-
 src/libtracker-data/tracker-sparql.c       |  16 +++-
 4 files changed, 104 insertions(+), 85 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index 2eeb144c1..d94e8bb7e 100644
--- a/src/libtracker-data/tracker-data-manager.c
+++ b/src/libtracker-data/tracker-data-manager.c
@@ -568,6 +568,7 @@ update_property_value (TrackerDataManager  *manager,
 
                                if (!unsup_onto_err) {
                                        GValue value = G_VALUE_INIT;
+                                       gint64 subject_id = 0;
 
                                        tracker_data_query_string_to_value (manager,
                                                                            str, NULL,
@@ -575,7 +576,12 @@ update_property_value (TrackerDataManager  *manager,
                                                                            &value, &error);
 
                                        if (!error)
-                                               tracker_data_delete_statement (manager->data_update, NULL, 
subject, pred, &value, &error);
+                                               subject_id = tracker_data_update_ensure_resource 
(manager->data_update,
+                                                                                                 subject,
+                                                                                                 &error);
+
+                                       if (!error)
+                                               tracker_data_delete_statement (manager->data_update, NULL, 
subject_id, pred, &value, &error);
                                        g_value_unset (&value);
 
                                        if (!error)
@@ -601,6 +607,7 @@ update_property_value (TrackerDataManager  *manager,
 
        if (!error && needed && object) {
                GValue value = G_VALUE_INIT;
+               gint64 subject_id = 0;
 
                tracker_data_query_string_to_value (manager,
                                                    object, NULL,
@@ -608,7 +615,12 @@ update_property_value (TrackerDataManager  *manager,
                                                    &value, &error);
 
                if (!error)
-                       tracker_data_insert_statement (manager->data_update, NULL, subject,
+                       subject_id = tracker_data_update_ensure_resource (manager->data_update,
+                                                                         subject,
+                                                                         &error);
+
+               if (!error)
+                       tracker_data_insert_statement (manager->data_update, NULL, subject_id,
                                                       pred, &value,
                                                       &error);
                g_value_unset (&value);
@@ -1537,6 +1549,7 @@ check_for_deleted_domain_index (TrackerDataManager *manager,
                        TrackerProperty *prop = l->data;
                        const gchar *uri;
                        GValue value = G_VALUE_INIT;
+                       gint64 class_id = 0;
 
                        TRACKER_NOTE (ONTOLOGY_CHANGES,
                                      g_message ("Ontology change: deleting nrl:domainIndex: %s",
@@ -1550,8 +1563,14 @@ check_for_deleted_domain_index (TrackerDataManager *manager,
                                                                uri, NULL,
                                                                tracker_property_get_data_type (property),
                                                                &value, error)) {
+                               class_id = tracker_data_update_ensure_resource (manager->data_update,
+                                                                               tracker_class_get_uri (class),
+                                                                               error);
+                       }
+
+                       if (class_id != 0) {
                                tracker_data_delete_statement (manager->data_update, NULL,
-                                                              tracker_class_get_uri (class),
+                                                              class_id,
                                                               property,
                                                               &value,
                                                               error);
@@ -1721,6 +1740,7 @@ check_for_deleted_super_properties (TrackerDataManager  *manager,
                        const gchar *object = tracker_property_get_uri (prop_to_remove);
                        const gchar *subject = tracker_property_get_uri (property);
                        GValue value = G_VALUE_INIT;
+                       gint64 subject_id;
 
                        property = tracker_ontologies_get_property_by_uri (ontologies,
                                                                           TRACKER_PREFIX_RDFS 
"subPropertyOf");
@@ -1740,7 +1760,12 @@ check_for_deleted_super_properties (TrackerDataManager  *manager,
                                                            &value, &n_error);
 
                        if (!n_error)
-                               tracker_data_delete_statement (manager->data_update, NULL, subject,
+                               subject_id = tracker_data_update_ensure_resource (manager->data_update,
+                                                                                 subject,
+                                                                                 &n_error);
+
+                       if (!n_error)
+                               tracker_data_delete_statement (manager->data_update, NULL, subject_id,
                                                               property, &value, &n_error);
                        g_value_unset (&value);
 
@@ -2194,6 +2219,7 @@ tracker_data_ontology_process_statement (TrackerDataManager *manager,
 {
        TrackerProperty *property;
        GValue value = G_VALUE_INIT;
+       gint64 subject_id = 0;
 
        if (g_strcmp0 (predicate, RDF_TYPE) == 0) {
                if (g_strcmp0 (object, RDFS_CLASS) == 0) {
@@ -2284,14 +2310,20 @@ tracker_data_ontology_process_statement (TrackerDataManager *manager,
                                                 &value, error))
                goto out;
 
+       subject_id = tracker_data_update_ensure_resource (manager->data_update,
+                                                         subject,
+                                                         error);
+       if (subject_id == 0)
+               goto out;
+
        if (tracker_property_get_is_new (property) ||
            tracker_property_get_multiple_values (property)) {
                tracker_data_insert_statement (manager->data_update, NULL,
-                                              subject, property, &value,
+                                              subject_id, property, &value,
                                               error);
        } else {
                tracker_data_update_statement (manager->data_update, NULL,
-                                              subject, property, &value,
+                                              subject_id, property, &value,
                                               error);
        }
 
diff --git a/src/libtracker-data/tracker-data-update.c b/src/libtracker-data/tracker-data-update.c
index 99d422d64..9bf38e806 100644
--- a/src/libtracker-data/tracker-data-update.c
+++ b/src/libtracker-data/tracker-data-update.c
@@ -69,7 +69,6 @@ struct _TrackerDataUpdateBufferGraph {
 
 struct _TrackerDataUpdateBufferResource {
        const TrackerDataUpdateBufferGraph *graph;
-       const gchar *subject;
        gint64 id;
        gboolean create;
        gboolean modified;
@@ -153,10 +152,6 @@ static gboolean     delete_metadata_decomposed (TrackerData      *data,
                                                 TrackerProperty  *property,
                                                 const GValue     *object,
                                                 GError          **error);
-static gboolean     resource_buffer_switch     (TrackerData  *data,
-                                                const gchar  *graph,
-                                                const gchar  *subject,
-                                                GError      **error);
 static gboolean update_resource_single (TrackerData      *data,
                                         const gchar      *graph,
                                         TrackerResource  *resource,
@@ -166,13 +161,13 @@ static gboolean update_resource_single (TrackerData      *data,
 
 void tracker_data_insert_statement_with_uri    (TrackerData      *data,
                                                 const gchar      *graph,
-                                                const gchar      *subject,
+                                                gint64            subject,
                                                 TrackerProperty  *predicate,
                                                 const GValue     *object,
                                                 GError          **error);
 void tracker_data_insert_statement_with_string (TrackerData      *data,
                                                 const gchar      *graph,
-                                                const gchar      *subject,
+                                                gint64            subject,
                                                 TrackerProperty  *predicate,
                                                 const GValue     *object,
                                                 GError          **error);
@@ -1218,7 +1213,6 @@ static void resource_buffer_free (TrackerDataUpdateBufferResource *resource)
 {
        g_hash_table_unref (resource->predicates);
        g_hash_table_unref (resource->tables);
-       resource->subject = NULL;
 
        g_ptr_array_free (resource->types, TRUE);
        resource->types = NULL;
@@ -1676,7 +1670,7 @@ get_old_property_values (TrackerData      *data,
        return old_values;
 }
 
-static const gchar *
+static gint64
 get_bnode_for_resource (GHashTable       *bnodes,
                         TrackerData      *data,
                         TrackerResource  *resource,
@@ -1689,16 +1683,16 @@ get_bnode_for_resource (GHashTable       *bnodes,
        identifier = tracker_resource_get_identifier (resource);
        bnode = g_hash_table_lookup (bnodes, identifier);
        if (bnode)
-               return bnode;
+               return query_resource_id (data, bnode, error);
 
        iface = tracker_data_manager_get_writable_db_interface (data->manager);
        bnode = tracker_data_update_ensure_new_bnode (data, iface, error);
        if (!bnode)
-               return NULL;
+               return 0;
 
        g_hash_table_insert (bnodes, g_strdup (identifier), bnode);
 
-       return bnode;
+       return query_resource_id (data, bnode, error);
 }
 
 static gboolean
@@ -2123,7 +2117,7 @@ ensure_graph_buffer (TrackerDataUpdateBuffer  *buffer,
        }
 
        graph_buffer->resources =
-               g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
+               g_hash_table_new_full (g_int64_hash, g_int64_equal, NULL,
                                       (GDestroyNotify) resource_buffer_free);
        g_ptr_array_add (buffer->graphs, graph_buffer);
 
@@ -2133,7 +2127,7 @@ ensure_graph_buffer (TrackerDataUpdateBuffer  *buffer,
 static gboolean
 resource_buffer_switch (TrackerData  *data,
                         const gchar  *graph,
-                        const gchar  *subject,
+                        gint64        subject,
                         GError      **error)
 {
        TrackerDataUpdateBufferGraph *graph_buffer;
@@ -2141,7 +2135,7 @@ resource_buffer_switch (TrackerData  *data,
 
        if (data->resource_buffer != NULL &&
            g_strcmp0 (data->resource_buffer->graph->graph, graph) == 0 &&
-           strcmp (data->resource_buffer->subject, subject) == 0) {
+           data->resource_buffer->id == subject) {
                /* Resource buffer stays the same */
                return TRUE;
        }
@@ -2160,28 +2154,19 @@ resource_buffer_switch (TrackerData  *data,
                return FALSE;
 
        data->resource_buffer =
-               g_hash_table_lookup (graph_buffer->resources, subject);
+               g_hash_table_lookup (graph_buffer->resources, &subject);
 
        if (data->resource_buffer == NULL) {
                TrackerDataUpdateBufferResource *resource_buffer;
-               gchar *subject_dup;
-               gint64 resource_id;
                gboolean create;
                GPtrArray *rdf_types;
 
-               /* subject not yet in cache, retrieve or create ID */
-               resource_id = tracker_data_update_ensure_resource (data,
-                                                                  subject,
-                                                                  error);
-               if (resource_id == 0)
-                       return FALSE;
-
                create = g_hash_table_contains (data->update_buffer.new_resources,
-                                               subject);
+                                               &subject);
                if (!create) {
                        rdf_types = tracker_data_query_rdf_type (data->manager,
                                                                 graph,
-                                                                resource_id,
+                                                                subject,
                                                                 &inner_error);
                        if (!rdf_types) {
                                g_propagate_error (error, inner_error);
@@ -2190,9 +2175,7 @@ resource_buffer_switch (TrackerData  *data,
                }
 
                resource_buffer = g_slice_new0 (TrackerDataUpdateBufferResource);
-               resource_buffer->id = resource_id;
-               subject_dup = g_strdup (subject);
-               resource_buffer->subject = subject_dup;
+               resource_buffer->id = subject;
                resource_buffer->create = create;
 
                resource_buffer->fts_updated = FALSE;
@@ -2205,7 +2188,7 @@ resource_buffer_switch (TrackerData  *data,
                resource_buffer->tables = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, 
(GDestroyNotify) cache_table_free);
                resource_buffer->graph = graph_buffer;
 
-               g_hash_table_insert (graph_buffer->resources, subject_dup, resource_buffer);
+               g_hash_table_insert (graph_buffer->resources, &resource_buffer->id, resource_buffer);
 
                data->resource_buffer = resource_buffer;
        }
@@ -2216,28 +2199,20 @@ resource_buffer_switch (TrackerData  *data,
 void
 tracker_data_delete_statement (TrackerData      *data,
                                const gchar      *graph,
-                               const gchar      *subject,
+                               gint64            subject,
                                TrackerProperty  *predicate,
                                const GValue     *object,
                                GError          **error)
 {
        TrackerClass       *class;
-       gint64              subject_id = 0;
        gboolean            change = FALSE;
        TrackerOntologies  *ontologies;
 
-       g_return_if_fail (subject != NULL);
+       g_return_if_fail (subject != 0);
        g_return_if_fail (predicate != NULL);
        g_return_if_fail (object != NULL);
        g_return_if_fail (data->in_transaction);
 
-       subject_id = query_resource_id (data, subject, error);
-
-       if (subject_id == 0) {
-               /* subject not in database */
-               return;
-       }
-
        if (!resource_buffer_switch (data, graph, subject, error))
                return;
 
@@ -2275,7 +2250,7 @@ tracker_data_delete_statement (TrackerData      *data,
 static gboolean
 delete_all_helper (TrackerData      *data,
                    const gchar      *graph,
-                   const gchar      *subject,
+                   gint64            subject,
                    TrackerProperty  *subproperty,
                    TrackerProperty  *property,
                    GArray           *old_values,
@@ -2350,27 +2325,19 @@ delete_all_helper (TrackerData      *data,
 static gboolean
 tracker_data_delete_all (TrackerData  *data,
                          const gchar  *graph,
-                         const gchar  *subject,
+                         gint64        subject,
                          const gchar  *predicate,
                          GError      **error)
 {
-       gint64 subject_id = 0;
        TrackerOntologies *ontologies;
        TrackerProperty *property;
        GArray *old_values;
        GError *inner_error = NULL;
 
-       g_return_val_if_fail (subject != NULL, FALSE);
+       g_return_val_if_fail (subject != 0, FALSE);
        g_return_val_if_fail (predicate != NULL, FALSE);
        g_return_val_if_fail (data->in_transaction, FALSE);
 
-       subject_id = query_resource_id (data, subject, error);
-
-       if (subject_id == 0) {
-               /* subject not in database */
-               return FALSE;
-       }
-
        if (!resource_buffer_switch (data, graph, subject, error))
                return FALSE;
 
@@ -2393,7 +2360,7 @@ tracker_data_delete_all (TrackerData  *data,
 static gboolean
 delete_single_valued (TrackerData      *data,
                       const gchar      *graph,
-                      const gchar      *subject,
+                      gint64            subject,
                       TrackerProperty  *predicate,
                       gboolean          super_is_single_valued,
                       GError          **error)
@@ -2451,12 +2418,12 @@ delete_single_valued (TrackerData      *data,
 void
 tracker_data_insert_statement (TrackerData      *data,
                                const gchar      *graph,
-                               const gchar      *subject,
+                               gint64            subject,
                                TrackerProperty  *predicate,
                                const GValue     *object,
                                GError          **error)
 {
-       g_return_if_fail (subject != NULL);
+       g_return_if_fail (subject != 0);
        g_return_if_fail (predicate != NULL);
        g_return_if_fail (object != NULL);
        g_return_if_fail (data->in_transaction);
@@ -2471,7 +2438,7 @@ tracker_data_insert_statement (TrackerData      *data,
 void
 tracker_data_insert_statement_with_uri (TrackerData      *data,
                                         const gchar      *graph,
-                                        const gchar      *subject,
+                                        gint64            subject,
                                         TrackerProperty  *predicate,
                                         const GValue     *object,
                                         GError          **error)
@@ -2482,7 +2449,7 @@ tracker_data_insert_statement_with_uri (TrackerData      *data,
        gboolean change = FALSE;
        TrackerOntologies *ontologies;
 
-       g_return_if_fail (subject != NULL);
+       g_return_if_fail (subject != 0);
        g_return_if_fail (predicate != NULL);
        g_return_if_fail (object != NULL);
        g_return_if_fail (data->in_transaction);
@@ -2544,7 +2511,7 @@ tracker_data_insert_statement_with_uri (TrackerData      *data,
 void
 tracker_data_insert_statement_with_string (TrackerData      *data,
                                            const gchar      *graph,
-                                           const gchar      *subject,
+                                           gint64            subject,
                                            TrackerProperty  *predicate,
                                            const GValue     *object,
                                            GError          **error)
@@ -2553,7 +2520,7 @@ tracker_data_insert_statement_with_string (TrackerData      *data,
        gboolean         change;
        gint64           pred_id = 0;
 
-       g_return_if_fail (subject != NULL);
+       g_return_if_fail (subject != 0);
        g_return_if_fail (predicate != NULL);
        g_return_if_fail (object != NULL);
        g_return_if_fail (data->in_transaction);
@@ -2585,7 +2552,7 @@ tracker_data_insert_statement_with_string (TrackerData      *data,
 void
 tracker_data_update_statement (TrackerData      *data,
                                const gchar      *graph,
-                               const gchar      *subject,
+                               gint64            subject,
                                TrackerProperty  *predicate,
                                const GValue     *object,
                                GError          **error)
@@ -2593,7 +2560,7 @@ tracker_data_update_statement (TrackerData      *data,
        TrackerOntologies *ontologies;
        GError *new_error = NULL;
 
-       g_return_if_fail (subject != NULL);
+       g_return_if_fail (subject != 0);
        g_return_if_fail (predicate != NULL);
        g_return_if_fail (data->in_transaction);
 
@@ -2852,7 +2819,7 @@ tracker_data_load_turtle_file (TrackerData  *data,
        TrackerTurtleReader *reader = NULL;
        TrackerOntologies *ontologies;
        GError *inner_error = NULL;
-       const gchar *subject, *predicate_str, *object_str, *langtag;
+       const gchar *subject_str, *predicate_str, *object_str, *langtag;
        gboolean object_is_uri;
        goffset last_parsed_line_no, last_parsed_column_no;
        gchar *ontology_uri = g_file_get_uri (file);
@@ -2864,7 +2831,7 @@ tracker_data_load_turtle_file (TrackerData  *data,
        ontologies = tracker_data_manager_get_ontologies (data->manager);
 
        while (tracker_turtle_reader_next (reader,
-                                          &subject,
+                                          &subject_str,
                                           &predicate_str,
                                           &object_str,
                                           &langtag,
@@ -2874,6 +2841,7 @@ tracker_data_load_turtle_file (TrackerData  *data,
                                           &inner_error)) {
                TrackerProperty *predicate;
                GValue object = G_VALUE_INIT;
+               gint64 subject;
 
                predicate = tracker_ontologies_get_property_by_uri (ontologies, predicate_str);
                if (predicate == NULL) {
@@ -2892,6 +2860,12 @@ tracker_data_load_turtle_file (TrackerData  *data,
                                                         &inner_error))
                        goto failed;
 
+               subject = tracker_data_update_ensure_resource (data,
+                                                              subject_str,
+                                                              &inner_error);
+               if (inner_error)
+                       goto failed;
+
                if (object_is_uri) {
                        tracker_data_insert_statement_with_uri (data, graph,
                                                                subject, predicate, &object,
@@ -2987,23 +2961,23 @@ static gboolean
 resource_maybe_reset_property (TrackerData      *data,
                                const gchar      *graph,
                                TrackerResource  *resource,
-                               const gchar      *subject_uri,
+                               gint64            subject,
                                const gchar      *property_uri,
                                GHashTable       *bnodes,
                                GError          **error)
 {
        GError *inner_error = NULL;
-       const gchar *subject;
+       const gchar *subject_name;
 
        /* If the subject is a blank node, this is a whole new insertion.
         * We don't need deleting anything then.
         */
-       subject = tracker_resource_get_identifier (resource);
-       if (g_str_has_prefix (subject, "_:"))
+       subject_name = tracker_resource_get_identifier (resource);
+       if (g_str_has_prefix (subject_name, "_:"))
                return TRUE;
 
        if (!tracker_data_delete_all (data,
-                                     graph, subject_uri, property_uri,
+                                     graph, subject, property_uri,
                                      &inner_error)) {
                if (inner_error)
                        g_propagate_error (error, inner_error);
@@ -3018,7 +2992,7 @@ static gboolean
 update_resource_property (TrackerData      *data,
                           const gchar      *graph_uri,
                           TrackerResource  *resource,
-                          const gchar      *subject,
+                          gint64            subject,
                           const gchar      *property,
                           GHashTable       *visited,
                           GHashTable       *bnodes,
@@ -3087,7 +3061,8 @@ update_resource_single (TrackerData      *data,
 {
        GList *properties, *l;
        GError *inner_error = NULL;
-       const gchar *subject;
+       const gchar *subject_str;
+       gint64 subject;
        gchar *graph_uri = NULL;
        gboolean is_bnode = FALSE;
 
@@ -3098,12 +3073,16 @@ update_resource_single (TrackerData      *data,
 
        properties = tracker_resource_get_properties (resource);
 
-       subject = tracker_resource_get_identifier (resource);
-       if (!subject || g_str_has_prefix (subject, "_:")) {
+       subject_str = tracker_resource_get_identifier (resource);
+       if (!subject_str || g_str_has_prefix (subject_str, "_:")) {
                is_bnode = TRUE;
                subject = get_bnode_for_resource (bnodes, data, resource, error);
                if (!subject)
                        return FALSE;
+       } else {
+               subject = tracker_data_update_ensure_resource (data, subject_str, error);
+               if (subject == 0)
+                       return FALSE;
        }
 
        if (graph) {
diff --git a/src/libtracker-data/tracker-data-update.h b/src/libtracker-data/tracker-data-update.h
index 97428b5a6..123dbf532 100644
--- a/src/libtracker-data/tracker-data-update.h
+++ b/src/libtracker-data/tracker-data-update.h
@@ -59,19 +59,19 @@ GQuark   tracker_data_error_quark                   (void);
 /* Metadata */
 void     tracker_data_delete_statement              (TrackerData               *data,
                                                      const gchar               *graph,
-                                                     const gchar               *subject,
+                                                     gint64                     subject,
                                                      TrackerProperty           *predicate,
                                                      const GValue              *object,
                                                      GError                   **error);
 void     tracker_data_insert_statement              (TrackerData               *data,
                                                      const gchar               *graph,
-                                                     const gchar               *subject,
+                                                     gint64                     subject,
                                                      TrackerProperty           *predicate,
                                                      const GValue              *object,
                                                      GError                   **error);
 void     tracker_data_update_statement              (TrackerData               *data,
                                                      const gchar               *graph,
-                                                     const gchar               *subject,
+                                                     gint64                     subject,
                                                      TrackerProperty           *predicate,
                                                      const GValue              *object,
                                                      GError                   **error);
diff --git a/src/libtracker-data/tracker-sparql.c b/src/libtracker-data/tracker-sparql.c
index d3e2b0bb5..3a3a06c04 100644
--- a/src/libtracker-data/tracker-sparql.c
+++ b/src/libtracker-data/tracker-sparql.c
@@ -2072,6 +2072,7 @@ tracker_sparql_apply_quad (TrackerSparql  *sparql,
        GError *inner_error = NULL;
        TrackerProperty *predicate = NULL;
        GValue object = G_VALUE_INIT;
+       gint64 subject = 0;
 
        if ((tracker_token_is_empty (&sparql->current_state->graph) &&
             sparql->policy.filter_unnamed_graph) ||
@@ -2086,7 +2087,7 @@ tracker_sparql_apply_quad (TrackerSparql  *sparql,
            sparql->current_state->type == TRACKER_SPARQL_TYPE_DELETE ||
            sparql->current_state->type == TRACKER_SPARQL_TYPE_UPDATE) {
                TrackerOntologies *ontologies;
-               const gchar *property;
+               const gchar *property, *subject_str;
 
                ontologies = tracker_data_manager_get_ontologies (sparql->data_manager);
                property = tracker_token_get_idstring (&sparql->current_state->predicate);
@@ -2109,6 +2110,13 @@ tracker_sparql_apply_quad (TrackerSparql  *sparql,
                        g_propagate_error (error, inner_error);
                        return FALSE;
                }
+
+               subject_str = tracker_token_get_idstring (&sparql->current_state->subject);
+               subject = tracker_data_update_ensure_resource (tracker_data_manager_get_data 
(sparql->data_manager),
+                                                              subject_str,
+                                                              error);
+               if (subject == 0)
+                       return FALSE;
        }
 
        switch (sparql->current_state->type) {
@@ -2131,7 +2139,7 @@ tracker_sparql_apply_quad (TrackerSparql  *sparql,
        case TRACKER_SPARQL_TYPE_INSERT:
                tracker_data_insert_statement (tracker_data_manager_get_data (sparql->data_manager),
                                               tracker_token_get_idstring (&sparql->current_state->graph),
-                                              tracker_token_get_idstring (&sparql->current_state->subject),
+                                              subject,
                                               predicate,
                                               &object,
                                               &inner_error);
@@ -2139,7 +2147,7 @@ tracker_sparql_apply_quad (TrackerSparql  *sparql,
        case TRACKER_SPARQL_TYPE_DELETE:
                tracker_data_delete_statement (tracker_data_manager_get_data (sparql->data_manager),
                                               tracker_token_get_idstring (&sparql->current_state->graph),
-                                              tracker_token_get_idstring (&sparql->current_state->subject),
+                                              subject,
                                               predicate,
                                               &object,
                                               &inner_error);
@@ -2147,7 +2155,7 @@ tracker_sparql_apply_quad (TrackerSparql  *sparql,
        case TRACKER_SPARQL_TYPE_UPDATE:
                tracker_data_update_statement (tracker_data_manager_get_data (sparql->data_manager),
                                               tracker_token_get_idstring (&sparql->current_state->graph),
-                                              tracker_token_get_idstring (&sparql->current_state->subject),
+                                              subject,
                                               predicate,
                                               &object,
                                               &inner_error);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]