[tracker/wip/carlosg/sparql-parser-ng: 288/306] libtracker-data: Add INSERT/DELETE SILENT syntax back
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/sparql-parser-ng: 288/306] libtracker-data: Add INSERT/DELETE SILENT syntax back
- Date: Mon, 15 Oct 2018 21:23:51 +0000 (UTC)
commit 933fd8830490561a95c56d916f84ff442890a4eb
Author: Carlos Garnacho <carlosg gnome org>
Date: Sun Sep 2 11:34:35 2018 +0200
libtracker-data: Add INSERT/DELETE SILENT syntax back
This is a tracker extension to SPARQL.
src/libtracker-data/tracker-sparql-grammar.h | 12 +++++++++---
src/libtracker-data/tracker-sparql.c | 15 +++++++++++++--
2 files changed, 22 insertions(+), 5 deletions(-)
---
diff --git a/src/libtracker-data/tracker-sparql-grammar.h b/src/libtracker-data/tracker-sparql-grammar.h
index 28698af98..8e305b1fc 100644
--- a/src/libtracker-data/tracker-sparql-grammar.h
+++ b/src/libtracker-data/tracker-sparql-grammar.h
@@ -1228,15 +1228,21 @@ static const TrackerGrammarRule rule_UsingClause[] = { L(USING), OR(helper_Using
*
* TRACKER EXTENSION:
* Clause may start with:
- * 'INSERT' ('OR' 'REPLACE')?
+ * 'INSERT' ('OR' 'REPLACE')? ('SILENT')?
*/
static const TrackerGrammarRule helper_InsertClause_seq_1[] = { L(OR), L(REPLACE), NIL };
static const TrackerGrammarRule helper_InsertClause_opt_1[] = { S(helper_InsertClause_seq_1), NIL };
-static const TrackerGrammarRule rule_InsertClause[] = { L(INSERT), OPT(helper_InsertClause_opt_1),
R(QuadPattern), NIL };
+static const TrackerGrammarRule helper_InsertClause_opt_2[] = { L(SILENT), NIL };
+static const TrackerGrammarRule rule_InsertClause[] = { L(INSERT), OPT(helper_InsertClause_opt_1),
OPT(helper_InsertClause_opt_2), R(QuadPattern), NIL };
/* DeleteClause ::= 'DELETE' QuadPattern
+ *
+ * TRACKER EXTENSION:
+ * Clause may start too with:
+ * 'DELETE' 'SILENT'
*/
-static const TrackerGrammarRule rule_DeleteClause[] = { L(DELETE), R(QuadPattern), NIL };
+static const TrackerGrammarRule helper_DeleteClause_opt_1[] = { L(SILENT), NIL };
+static const TrackerGrammarRule rule_DeleteClause[] = { L(DELETE), OPT(helper_DeleteClause_opt_1),
R(QuadPattern), NIL };
/* Modify ::= ( 'WITH' iri )? ( DeleteClause InsertClause? | InsertClause ) UsingClause* 'WHERE'
GroupGraphPattern
*/
diff --git a/src/libtracker-data/tracker-sparql.c b/src/libtracker-data/tracker-sparql.c
index 68b4b7bc4..20538e030 100644
--- a/src/libtracker-data/tracker-sparql.c
+++ b/src/libtracker-data/tracker-sparql.c
@@ -112,6 +112,8 @@ struct _TrackerSparql
GVariantBuilder *blank_nodes;
GHashTable *solution_var_map;
+ gboolean silent;
+
struct {
TrackerContext *context;
TrackerContext *select_context;
@@ -2759,9 +2761,15 @@ translate_DeleteClause (TrackerSparql *sparql,
GError **error)
{
/* DeleteClause ::= 'DELETE' QuadPattern
+ *
+ * TRACKER EXTENSION:
+ * Clause may start too with:
+ * 'DELETE' 'SILENT'
*/
sparql->current_state.type = TRACKER_SPARQL_TYPE_DELETE;
_expect (sparql, RULE_TYPE_LITERAL, LITERAL_DELETE);
+ sparql->silent = _accept (sparql, RULE_TYPE_LITERAL, LITERAL_SILENT);
+
_call_rule (sparql, NAMED_RULE_QuadPattern, error);
return TRUE;
@@ -2775,7 +2783,7 @@ translate_InsertClause (TrackerSparql *sparql,
*
* TRACKER EXTENSION:
* Clause may start with:
- * 'INSERT' ('OR' 'REPLACE')?
+ * 'INSERT' ('OR' 'REPLACE')? ('SILENT')?
*/
sparql->current_state.blank_node_map =
g_hash_table_new_full (g_str_hash, g_str_equal,
@@ -2791,6 +2799,8 @@ translate_InsertClause (TrackerSparql *sparql,
sparql->current_state.type = TRACKER_SPARQL_TYPE_INSERT;
}
+ sparql->silent = _accept (sparql, RULE_TYPE_LITERAL, LITERAL_SILENT);
+
_call_rule (sparql, NAMED_RULE_QuadPattern, error);
if (sparql->blank_nodes) {
@@ -4218,10 +4228,11 @@ translate_GraphNode (TrackerSparql *sparql,
tracker_token_unset (&sparql->current_state.object);
- if (inner_error) {
+ if (inner_error && !sparql->silent) {
g_propagate_error (error, inner_error);
return FALSE;
} else {
+ g_clear_error (&inner_error);
return TRUE;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]