[tracker/wip/carlosg/sparql1.1: 16/80] libtracker-data: Add support for SERVICE{} syntax



commit 86993643f5e4ba8f2bc49567aa03411cf284bf95
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu May 30 13:55:58 2019 +0200

    libtracker-data: Add support for SERVICE{} syntax

 src/libtracker-data/tracker-db-interface-sqlite.c |  2 ++
 src/libtracker-data/tracker-sparql.c              | 37 ++++++++++++++---------
 2 files changed, 24 insertions(+), 15 deletions(-)
---
diff --git a/src/libtracker-data/tracker-db-interface-sqlite.c 
b/src/libtracker-data/tracker-db-interface-sqlite.c
index 52eca4a9f..e1c797815 100644
--- a/src/libtracker-data/tracker-db-interface-sqlite.c
+++ b/src/libtracker-data/tracker-db-interface-sqlite.c
@@ -56,6 +56,7 @@
 #include "tracker-db-manager.h"
 #include "tracker-data-enum-types.h"
 #include "tracker-uuid.h"
+#include "tracker-vtab-service.h"
 #include "tracker-vtab-triples.h"
 
 typedef struct {
@@ -3171,6 +3172,7 @@ tracker_db_interface_init_vtabs (TrackerDBInterface *db_interface,
                                  TrackerOntologies  *ontologies)
 {
        tracker_vtab_triples_init (db_interface->db, ontologies);
+       tracker_vtab_service_init (db_interface->db, ontologies);
        return TRUE;
 }
 
diff --git a/src/libtracker-data/tracker-sparql.c b/src/libtracker-data/tracker-sparql.c
index d457a7603..ce730465a 100644
--- a/src/libtracker-data/tracker-sparql.c
+++ b/src/libtracker-data/tracker-sparql.c
@@ -2423,26 +2423,33 @@ translate_Create (TrackerSparql  *sparql,
                silent = TRUE;
 
        _call_rule (sparql, NAMED_RULE_GraphRef, error);
+       g_assert (!tracker_token_is_empty (&sparql->current_state.graph));
 
-       if (!tracker_token_is_empty (&sparql->current_state.graph)) {
-               const gchar *graph_name;
+       graph_name = tracker_token_get_idstring (&sparql->current_state.graph);
 
-               graph_name = tracker_token_get_idstring (&sparql->current_state.graph);
-
-               if (!tracker_data_manager_create_graph (sparql->data_manager,
-                                                       graph_name,
-                                                       &inner_error)) {
-                       if (silent) {
-                               g_error_free (inner_error);
-                               return TRUE;
-                       } else {
-                               g_propagate_error (error, inner_error);
-                               return FALSE;
-                       }
-               }
+       if (tracker_data_manager_find_graph (sparql->data_manager, graph_name) != 0) {
+               inner_error = g_error_new (TRACKER_SPARQL_ERROR,
+                                          TRACKER_SPARQL_ERROR_CONSTRAINT,
+                                          "Graph '%s' already exists",
+                                          graph_name);
+               goto error;
        }
 
+       if (!tracker_data_manager_create_graph (sparql->data_manager,
+                                               graph_name,
+                                               &inner_error))
+               goto error;
+
        return TRUE;
+
+error:
+       if (silent) {
+               g_error_free (inner_error);
+               return TRUE;
+       } else {
+               g_propagate_error (error, inner_error);
+               return FALSE;
+       }
 }
 
 static gboolean


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