[tracker/wip/carlosg/sparql-parser-ng: 287/306] libtracker-data: Add 'INSERT OR REPLACE' SPARQL extension back
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/sparql-parser-ng: 287/306] libtracker-data: Add 'INSERT OR REPLACE' SPARQL extension back
- Date: Mon, 15 Oct 2018 21:23:46 +0000 (UTC)
commit d65042c3baf5f8199cde81a6f7f035cceb890a4f
Author: Carlos Garnacho <carlosg gnome org>
Date: Sun Sep 2 11:01:30 2018 +0200
libtracker-data: Add 'INSERT OR REPLACE' SPARQL extension back
This is syntax traditionally allowed by Tracker.
src/libtracker-data/tracker-sparql-grammar.h | 8 +++++++-
src/libtracker-data/tracker-sparql.c | 12 ++++++++++++
2 files changed, 19 insertions(+), 1 deletion(-)
---
diff --git a/src/libtracker-data/tracker-sparql-grammar.h b/src/libtracker-data/tracker-sparql-grammar.h
index 2ade748de..28698af98 100644
--- a/src/libtracker-data/tracker-sparql-grammar.h
+++ b/src/libtracker-data/tracker-sparql-grammar.h
@@ -1225,8 +1225,14 @@ static const TrackerGrammarRule helper_UsingClause_or[] = { R(iri), S(helper_Usi
static const TrackerGrammarRule rule_UsingClause[] = { L(USING), OR(helper_UsingClause_or), NIL };
/* InsertClause ::= 'INSERT' QuadPattern
+ *
+ * TRACKER EXTENSION:
+ * Clause may start with:
+ * 'INSERT' ('OR' 'REPLACE')?
*/
-static const TrackerGrammarRule rule_InsertClause[] = { L(INSERT), R(QuadPattern), NIL };
+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 };
/* DeleteClause ::= 'DELETE' QuadPattern
*/
diff --git a/src/libtracker-data/tracker-sparql.c b/src/libtracker-data/tracker-sparql.c
index a7eac02e2..68b4b7bc4 100644
--- a/src/libtracker-data/tracker-sparql.c
+++ b/src/libtracker-data/tracker-sparql.c
@@ -2772,6 +2772,10 @@ translate_InsertClause (TrackerSparql *sparql,
GError **error)
{
/* InsertClause ::= 'INSERT' QuadPattern
+ *
+ * TRACKER EXTENSION:
+ * Clause may start with:
+ * 'INSERT' ('OR' 'REPLACE')?
*/
sparql->current_state.blank_node_map =
g_hash_table_new_full (g_str_hash, g_str_equal,
@@ -2779,6 +2783,14 @@ translate_InsertClause (TrackerSparql *sparql,
sparql->current_state.type = TRACKER_SPARQL_TYPE_INSERT;
_expect (sparql, RULE_TYPE_LITERAL, LITERAL_INSERT);
+
+ if (_accept (sparql, RULE_TYPE_LITERAL, LITERAL_OR)) {
+ _expect (sparql, RULE_TYPE_LITERAL, LITERAL_REPLACE);
+ sparql->current_state.type = TRACKER_SPARQL_TYPE_UPDATE;
+ } else {
+ sparql->current_state.type = TRACKER_SPARQL_TYPE_INSERT;
+ }
+
_call_rule (sparql, NAMED_RULE_QuadPattern, error);
if (sparql->blank_nodes) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]