[tracker/wip/carlosg/sparql1.1: 106/201] libtracker-data: Support ALL/DEFAULT/NAMED in DROP/CREATE
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/sparql1.1: 106/201] libtracker-data: Support ALL/DEFAULT/NAMED in DROP/CREATE
- Date: Mon, 9 Sep 2019 22:27:43 +0000 (UTC)
commit 370e3b17221caaa35a97202e9a88e74da8d15200
Author: Carlos Garnacho <carlosg gnome org>
Date: Sat Jun 8 18:06:00 2019 +0200
libtracker-data: Support ALL/DEFAULT/NAMED in DROP/CREATE
src/libtracker-data/tracker-sparql.c | 54 +++++++++++++++++++++++++++++-------
1 file changed, 44 insertions(+), 10 deletions(-)
---
diff --git a/src/libtracker-data/tracker-sparql.c b/src/libtracker-data/tracker-sparql.c
index 3855b3d63..a516cb946 100644
--- a/src/libtracker-data/tracker-sparql.c
+++ b/src/libtracker-data/tracker-sparql.c
@@ -47,6 +47,12 @@ enum {
TIME_FORMAT_HOURS
};
+enum {
+ GRAPH_OP_DEFAULT,
+ GRAPH_OP_NAMED,
+ GRAPH_OP_ALL
+};
+
static inline gboolean _call_rule_func (TrackerSparql *sparql,
TrackerGrammarNamedRule rule,
GError **error);
@@ -149,6 +155,7 @@ struct _TrackerSparql
const gchar *expression_list_separator;
TrackerPropertyType expression_type;
guint type;
+ guint graph_op;
gboolean convert_to_string;
} current_state;
@@ -2571,7 +2578,9 @@ handle_silent (gboolean silent,
GError *error_in,
GError **error)
{
- if (silent) {
+ if (!error_in) {
+ return TRUE;
+ } else if (silent) {
g_error_free (error_in);
return TRUE;
} else {
@@ -2641,7 +2650,11 @@ translate_Drop (TrackerSparql *sparql,
{
gboolean silent = FALSE;
GError *inner_error = NULL;
+ GList *graphs = NULL, *l;
+ const gchar *graph;
+ /* Drop ::= 'DROP' 'SILENT'? GraphRefAll
+ */
_expect (sparql, RULE_TYPE_LITERAL, LITERAL_DROP);
if (_accept (sparql, RULE_TYPE_LITERAL, LITERAL_SILENT))
@@ -2649,18 +2662,37 @@ translate_Drop (TrackerSparql *sparql,
_call_rule (sparql, NAMED_RULE_GraphRefAll, error);
- if (!tracker_token_is_empty (&sparql->current_state.graph)) {
- const gchar *graph;
+ if (tracker_token_is_empty (&sparql->current_state.graph)) {
+ if (sparql->current_state.graph_op == GRAPH_OP_DEFAULT ||
+ sparql->current_state.graph_op == GRAPH_OP_ALL) {
+ graphs = g_list_prepend (graphs, NULL);
+ }
+
+ if (sparql->current_state.graph_op == GRAPH_OP_ALL ||
+ sparql->current_state.graph_op == GRAPH_OP_NAMED) {
+ GHashTable *ht;
+ GHashTableIter iter;
+
+ ht = tracker_data_manager_get_graphs (sparql->data_manager);
+ g_hash_table_iter_init (&iter, ht);
+ while (g_hash_table_iter_next (&iter, (gpointer *) &graph, NULL))
+ graphs = g_list_prepend (graphs, (gpointer) graph);
+ }
+ } else {
graph = tracker_token_get_idstring (&sparql->current_state.graph);
+ graphs = g_list_prepend (graphs, (gpointer) graph);
+ }
+ for (l = graphs; l; l = l->next) {
if (!tracker_data_manager_drop_graph (sparql->data_manager,
- graph, &inner_error)) {
- return handle_silent (silent, inner_error, error);
- }
+ l->data, &inner_error))
+ break;
}
- return TRUE;
+ g_list_free (graphs);
+
+ return handle_silent (silent, inner_error, error);
}
static gboolean
@@ -2671,6 +2703,8 @@ translate_Create (TrackerSparql *sparql,
GError *inner_error = NULL;
const gchar *graph_name;
+ /* Create ::= 'CREATE' 'SILENT'? GraphRef
+ */
_expect (sparql, RULE_TYPE_LITERAL, LITERAL_CREATE);
if (_accept (sparql, RULE_TYPE_LITERAL, LITERAL_SILENT))
@@ -3333,11 +3367,11 @@ translate_GraphRefAll (TrackerSparql *sparql,
/* GraphRefAll ::= GraphRef | 'DEFAULT' | 'NAMED' | 'ALL'
*/
if (_accept (sparql, RULE_TYPE_LITERAL, LITERAL_DEFAULT)) {
- _unimplemented ("DROP/CLEAR DEFAULT");
+ sparql->current_state.graph_op = GRAPH_OP_DEFAULT;
} else if (_accept (sparql, RULE_TYPE_LITERAL, LITERAL_NAMED)) {
- _unimplemented ("DROP/CLEAR NAMED");
+ sparql->current_state.graph_op = GRAPH_OP_NAMED;
} else if (_accept (sparql, RULE_TYPE_LITERAL, LITERAL_ALL)) {
- _unimplemented ("DROP/CLEAR ALL");
+ sparql->current_state.graph_op = GRAPH_OP_ALL;
} else {
_call_rule (sparql, NAMED_RULE_GraphRef, error);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]