[tracker/tracker-store: 3/11] rasqal: Support DROP GRAPH queries



commit e63aaf4ed2be15425086178c24d14f88112a58c0
Author: Jürg Billeter <j bitron ch>
Date:   Wed Apr 29 11:14:14 2009 +0200

    rasqal: Support DROP GRAPH queries
---
 src/rasqal/rasqal.h        |    4 +++-
 src/rasqal/rasqal.vapi     |   12 +++++++++++-
 src/rasqal/sparql_lexer.l  |    1 +
 src/rasqal/sparql_parser.y |   11 ++++++++++-
 4 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/src/rasqal/rasqal.h b/src/rasqal/rasqal.h
index 5a10a4d..5e68b13 100644
--- a/src/rasqal/rasqal.h
+++ b/src/rasqal/rasqal.h
@@ -596,6 +596,7 @@ typedef unsigned char* (*rasqal_generate_bnodeid_handler)(rasqal_query* query, v
  * @RASQAL_QUERY_VERB_ASK: SPARQL query ask verb.
  * @RASQAL_QUERY_VERB_DELETE: LAQRS query delete verb.
  * @RASQAL_QUERY_VERB_INSERT: LAQRS query insert verb.
+ * @RASQAL_QUERY_VERB_DROP: LAQRS query drop verb.
  * @RASQAL_QUERY_VERB_UNKNOWN: Internal
  * @RASQAL_QUERY_VERB_LAST: Internal
  *
@@ -611,9 +612,10 @@ typedef enum {
   RASQAL_QUERY_VERB_ASK       = 4,
   RASQAL_QUERY_VERB_DELETE    = 5,
   RASQAL_QUERY_VERB_INSERT    = 6,
+  RASQAL_QUERY_VERB_DROP      = 7,
 
   /* internal */
-  RASQAL_QUERY_VERB_LAST=RASQAL_QUERY_VERB_INSERT
+  RASQAL_QUERY_VERB_LAST=RASQAL_QUERY_VERB_DROP
 } rasqal_query_verb;
 
 
diff --git a/src/rasqal/rasqal.vapi b/src/rasqal/rasqal.vapi
index c5fc5e9..7e9e355 100644
--- a/src/rasqal/rasqal.vapi
+++ b/src/rasqal/rasqal.vapi
@@ -36,6 +36,7 @@ namespace Raptor {
 	public class Uri {
 		[CCode (cname = "raptor_new_uri")]
 		public Uri (string uri_string);
+		public unowned string as_string ();
 	}
 
 	[CCode (cname = "raptor_message_handler", instance_pos = 0)]
@@ -167,6 +168,7 @@ namespace Rasqal {
 		public int get_limit ();
 		public int get_offset ();
 		public QueryVerb get_verb ();
+		public weak DataGraph? get_data_graph (int idx);
 		public weak Expression? get_group_condition (int idx);
 		public weak Expression? get_order_condition (int idx);
 		public weak GraphPattern get_query_graph_pattern ();
@@ -186,7 +188,8 @@ namespace Rasqal {
 		DESCRIBE,
 		ASK,
 		DELETE,
-		INSERT
+		INSERT,
+		DROP
 	}
 
 	[Compact]
@@ -208,6 +211,13 @@ namespace Rasqal {
 	}
 
 	[Compact]
+	[CCode (cname = "rasqal_data_graph", free_function = "rasqal_free_data_graph")]
+	public class DataGraph {
+		public Raptor.Uri uri;
+		public Raptor.Uri name_uri;
+	}
+
+	[Compact]
 	[CCode (cname = "rasqal_world", free_function = "rasqal_free_world")]
 	public class World {
 		[CCode (cname = "rasqal_new_world")]
diff --git a/src/rasqal/sparql_lexer.l b/src/rasqal/sparql_lexer.l
index 68dee58..ebea6db 100644
--- a/src/rasqal/sparql_lexer.l
+++ b/src/rasqal/sparql_lexer.l
@@ -360,6 +360,7 @@ EXPONENT [eE][+-]?[0-9]+
 [Aa][Ss] { BEGIN(SPID); return AS; }
 [Dd][Ee][Ll][Ee][Tt][Ee]  { return DELETE; }
 [Ii][Nn][Ss][Ee][Rr][Tt]  { return INSERT; }
+[Dd][Rr][Oo][Pp] { return DROP; }
 [Ss][Aa][Mm][Ee][Tt][Ee][Rr][Mm] { return SAMETERM; }
 
 "a" { return A; }
diff --git a/src/rasqal/sparql_parser.y b/src/rasqal/sparql_parser.y
index b3d600b..39d2d77 100644
--- a/src/rasqal/sparql_parser.y
+++ b/src/rasqal/sparql_parser.y
@@ -146,7 +146,7 @@ static void sparql_query_error_full(rasqal_query *rq, const char *message, ...)
 %token SAMETERM "sameTerm"
 /* LAQRS */
 %token EXPLAIN GROUP COUNT SUM AVERAGE MINIMUM MAXIMUM AS
-%token DELETE INSERT
+%token DELETE INSERT DROP
 
 
 /* expression delimiters */
@@ -420,6 +420,15 @@ UpdateQuery: DeleteQuery
   ((rasqal_query*)rq)->constructs=$1;
   ((rasqal_query*)rq)->verb=RASQAL_QUERY_VERB_INSERT;
 }
+| DROP GRAPH IRIref
+{
+  raptor_uri* uri=rasqal_literal_as_uri($3);
+  rasqal_query_add_data_graph((rasqal_query*)rq, uri, uri,
+                              RASQAL_DATA_GRAPH_NAMED);
+  rasqal_free_literal($3);
+
+  ((rasqal_query*)rq)->verb=RASQAL_QUERY_VERB_DROP;
+}
 ;
 
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]