[tracker/wip/carlosg/sparql1.1: 18/56] libtracker-data: Handle CREATE/DROP graph operations
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/sparql1.1: 18/56] libtracker-data: Handle CREATE/DROP graph operations
- Date: Thu, 6 Jun 2019 11:17:41 +0000 (UTC)
commit 04ba766267317c526f1c548e7ea488eecef11969
Author: Carlos Garnacho <carlosg gnome org>
Date: Sat Apr 20 16:31:40 2019 +0200
libtracker-data: Handle CREATE/DROP graph operations
src/libtracker-data/tracker-data-manager.h | 8 ++++
src/libtracker-data/tracker-sparql.c | 70 +++++++++++++++++++++++++++---
2 files changed, 73 insertions(+), 5 deletions(-)
---
diff --git a/src/libtracker-data/tracker-data-manager.h b/src/libtracker-data/tracker-data-manager.h
index 5dd81f38e..e250fb0ea 100644
--- a/src/libtracker-data/tracker-data-manager.h
+++ b/src/libtracker-data/tracker-data-manager.h
@@ -83,6 +83,14 @@ gboolean tracker_data_manager_init_fts (TrackerDBInterface *in
GHashTable * tracker_data_manager_get_namespaces (TrackerDataManager *manager);
+gboolean tracker_data_manager_create_graph (TrackerDataManager *manager,
+ const gchar *name,
+ GError **error);
+
+gboolean tracker_data_manager_drop_graph (TrackerDataManager *manager,
+ const gchar *name,
+ GError **error);
+
G_END_DECLS
#endif /* __LIBTRACKER_DATA_MANAGER_H__ */
diff --git a/src/libtracker-data/tracker-sparql.c b/src/libtracker-data/tracker-sparql.c
index 347960e53..b0228e727 100644
--- a/src/libtracker-data/tracker-sparql.c
+++ b/src/libtracker-data/tracker-sparql.c
@@ -2384,14 +2384,69 @@ static gboolean
translate_Drop (TrackerSparql *sparql,
GError **error)
{
- _unimplemented ("DROP");
+ gboolean silent = FALSE;
+ GError *inner_error = NULL;
+
+ _expect (sparql, RULE_TYPE_LITERAL, LITERAL_DROP);
+
+ if (_accept (sparql, RULE_TYPE_LITERAL, LITERAL_SILENT))
+ silent = TRUE;
+
+ _call_rule (sparql, NAMED_RULE_GraphRefAll, error);
+
+ if (!tracker_token_is_empty (sparql->current_state.graph)) {
+ const gchar *graph_name;
+
+ graph_name = tracker_token_get_idstring (&sparql->current_state.graph);
+ if (!tracker_data_manager_drop_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;
+ }
+ }
+ }
+
+ return TRUE;
}
static gboolean
translate_Create (TrackerSparql *sparql,
GError **error)
{
- _unimplemented ("CREATE");
+ gboolean silent = FALSE;
+ GError *inner_error = NULL;
+
+ _expect (sparql, RULE_TYPE_LITERAL, LITERAL_CREATE);
+
+ if (_accept (sparql, RULE_TYPE_LITERAL, LITERAL_SILENT))
+ silent = TRUE;
+
+ _call_rule (sparql, NAMED_RULE_GraphRef, error);
+
+ if (!tracker_token_is_empty (&sparql->current_state.graph)) {
+ const gchar *graph_name;
+
+ 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;
+ }
+ }
+ }
+
+ return TRUE;
}
static gboolean
@@ -2843,11 +2898,16 @@ translate_GraphRefAll (TrackerSparql *sparql,
{
/* GraphRefAll ::= GraphRef | 'DEFAULT' | 'NAMED' | 'ALL'
*/
- if (_accept (sparql, RULE_TYPE_LITERAL, LITERAL_DEFAULT) ||
- _accept (sparql, RULE_TYPE_LITERAL, LITERAL_NAMED) ||
- _accept (sparql, RULE_TYPE_LITERAL, LITERAL_ALL)) {
+ if (_accept (sparql, RULE_TYPE_LITERAL, LITERAL_DEFAULT)) {
+ _unimplemented ("DROP/CLEAR DEFAULT");
+ } else if (_accept (sparql, RULE_TYPE_LITERAL, LITERAL_NAMED)) {
+ _unimplemented ("DROP/CLEAR NAMED");
+ } else if (_accept (sparql, RULE_TYPE_LITERAL, LITERAL_ALL)) {
+ _unimplemented ("DROP/CLEAR ALL");
} else {
_call_rule (sparql, NAMED_RULE_GraphRef, error);
+ _init_token (&sparql->current_state.graph,
+ sparql->current_state.prev_node, sparql);
}
return TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]