[tracker/wip/carlosg/sparql-parser-ng: 297/306] libtracker-data: Add back 'NULL' literal handling for INSERT OR REPLACE
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/sparql-parser-ng: 297/306] libtracker-data: Add back 'NULL' literal handling for INSERT OR REPLACE
- Date: Mon, 15 Oct 2018 21:24:36 +0000 (UTC)
commit 535e91faab525193ab66ee993002461ebe98e740
Author: Carlos Garnacho <carlosg gnome org>
Date: Sun Sep 23 12:39:07 2018 +0200
libtracker-data: Add back 'NULL' literal handling for INSERT OR REPLACE
This is a tracker extension that allows INSERT OR REPLACE to also delete
values.
src/libtracker-data/tracker-sparql-grammar.h | 8 +++++++-
src/libtracker-data/tracker-sparql.c | 8 ++++++++
2 files changed, 15 insertions(+), 1 deletion(-)
---
diff --git a/src/libtracker-data/tracker-sparql-grammar.h b/src/libtracker-data/tracker-sparql-grammar.h
index d6baf45f9..fc03a0d1e 100644
--- a/src/libtracker-data/tracker-sparql-grammar.h
+++ b/src/libtracker-data/tracker-sparql-grammar.h
@@ -243,6 +243,7 @@ typedef enum {
LITERAL_NAMED,
LITERAL_NOT,
LITERAL_NOW,
+ LITERAL_NULL, /* TRACKER EXTENSION */
LITERAL_OFFSET,
LITERAL_OP_AND,
LITERAL_OP_EQ,
@@ -392,6 +393,7 @@ static const gchar literals[][N_LITERALS] = {
"named", /* LITERAL_NAMED */
"not", /* LITERAL_NOT */
"now", /* LITERAL_NOW */
+ "null", /* LITERAL_NULL (TRACKER EXTENSION) */
"offset", /* LITERAL_OFFSET */
"&&", /* LITERAL_OP_AND */
"=", /* LITERAL_OP_EQ */
@@ -891,8 +893,12 @@ static const TrackerGrammarRule helper_GraphNodePath_or[] = { R(VarOrTerm), R(Tr
static const TrackerGrammarRule rule_GraphNodePath[] = { OR(helper_GraphNodePath_or), NIL };
/* GraphNode ::= VarOrTerm | TriplesNode
+ *
+ * TRACKER EXTENSION:
+ * Literal 'NULL' is also accepted, rule is effectively:
+ * VarOrTerm | TriplesNode | 'NULL'
*/
-static const TrackerGrammarRule helper_GraphNode_or[] = { R(VarOrTerm), R(TriplesNode), NIL };
+static const TrackerGrammarRule helper_GraphNode_or[] = { R(VarOrTerm), R(TriplesNode), L(NULL), NIL };
static const TrackerGrammarRule rule_GraphNode[] = { OR(helper_GraphNode_or), NIL };
/* CollectionPath ::= '(' GraphNodePath+ ')'
diff --git a/src/libtracker-data/tracker-sparql.c b/src/libtracker-data/tracker-sparql.c
index a962bb439..011b5ab5e 100644
--- a/src/libtracker-data/tracker-sparql.c
+++ b/src/libtracker-data/tracker-sparql.c
@@ -4204,6 +4204,10 @@ translate_GraphNode (TrackerSparql *sparql,
GError *inner_error = NULL;
/* GraphNode ::= VarOrTerm | TriplesNode
+ *
+ * TRACKER EXTENSION:
+ * Literal 'NULL' is also accepted, rule is effectively:
+ * VarOrTerm | TriplesNode | 'NULL'
*/
if (_check_in_rule (sparql, NAMED_RULE_VarOrTerm)) {
sparql->current_state.token = &sparql->current_state.object;
@@ -4213,6 +4217,10 @@ translate_GraphNode (TrackerSparql *sparql,
sparql->current_state.token = &sparql->current_state.object;
_call_rule (sparql, NAMED_RULE_TriplesNode, error);
g_assert (!tracker_token_is_empty (&sparql->current_state.object));
+ } else if (_accept (sparql, RULE_TYPE_LITERAL, LITERAL_NULL)) {
+ if (sparql->current_state.type != TRACKER_SPARQL_TYPE_UPDATE)
+ _raise (PARSE, "«NULL» literal is not allowed in this mode", "NULL");
+ /* Object token is left unset on purpose */
} else {
g_assert_not_reached ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]