[tracker] rasqal: Support multiple updates in single query
- From: Jürg Billeter <juergbi src gnome org>
- To: svn-commits-list gnome org
- Subject: [tracker] rasqal: Support multiple updates in single query
- Date: Wed, 29 Apr 2009 04:30:07 -0400 (EDT)
commit bdf1492d5540bcb51aae58b61101659ed5077f6f
Author: Jürg Billeter <j bitron ch>
Date: Wed Apr 29 10:20:27 2009 +0200
rasqal: Support multiple updates in single query
---
src/rasqal/rasqal.h | 3 ++
src/rasqal/rasqal.vapi | 1 +
src/rasqal/rasqal_internal.h | 3 ++
src/rasqal/rasqal_query.c | 12 +++++++++-
src/rasqal/sparql_parser.y | 48 ++++++++++++++++++++++++++++++++++++++++-
5 files changed, 64 insertions(+), 3 deletions(-)
diff --git a/src/rasqal/rasqal.h b/src/rasqal/rasqal.h
index 324c330..5a10a4d 100644
--- a/src/rasqal/rasqal.h
+++ b/src/rasqal/rasqal.h
@@ -850,6 +850,9 @@ void* rasqal_query_get_user_data(rasqal_query* query);
RASQAL_API
void rasqal_query_set_user_data(rasqal_query* query, void *user_data);
+RASQAL_API
+rasqal_query* rasqal_query_next(rasqal_query* query);
+
/* query results */
RASQAL_API
void rasqal_free_query_results(rasqal_query_results *query_results);
diff --git a/src/rasqal/rasqal.vapi b/src/rasqal/rasqal.vapi
index 4e8f050..c5fc5e9 100644
--- a/src/rasqal/rasqal.vapi
+++ b/src/rasqal/rasqal.vapi
@@ -177,6 +177,7 @@ namespace Rasqal {
public void set_fatal_error_handler ([CCode (delegate_target_pos = 0.9)] Raptor.MessageHandler handler);
public void set_generate_bnodeid_handler ([CCode (delegate_target_pos = 0.9)] GenerateBnodeidHandler handler);
public void set_warning_handler ([CCode (delegate_target_pos = 0.9)] Raptor.MessageHandler handler);
+ public unowned Query next ();
}
public enum QueryVerb {
diff --git a/src/rasqal/rasqal_internal.h b/src/rasqal/rasqal_internal.h
index 82ad445..e331d58 100644
--- a/src/rasqal/rasqal_internal.h
+++ b/src/rasqal/rasqal_internal.h
@@ -363,6 +363,9 @@ struct rasqal_query_s {
/* INTERNAL for now: non-0 to store results otherwise lazy eval results */
int store_results;
+
+ /* next operation in the query, only valid for updates */
+ rasqal_query* next;
};
diff --git a/src/rasqal/rasqal_query.c b/src/rasqal/rasqal_query.c
index ba9a37d..dcc709a 100644
--- a/src/rasqal/rasqal_query.c
+++ b/src/rasqal/rasqal_query.c
@@ -189,7 +189,10 @@ rasqal_free_query(rasqal_query* query)
if(--query->usage)
return;
-
+
+ if (query->next)
+ rasqal_free_query (query->next);
+
if(query->factory)
query->factory->terminate(query);
@@ -1441,6 +1444,13 @@ rasqal_query_set_user_data(rasqal_query* query, void *user_data)
}
+rasqal_query*
+rasqal_query_next(rasqal_query* query)
+{
+ return query->next;
+}
+
+
/**
* rasqal_query_get_verb:
* @query: #rasqal_query
diff --git a/src/rasqal/sparql_parser.y b/src/rasqal/sparql_parser.y
index ab83e58..adb1ff2 100644
--- a/src/rasqal/sparql_parser.y
+++ b/src/rasqal/sparql_parser.y
@@ -194,7 +194,8 @@ static void sparql_query_error_full(rasqal_query *rq, const char *message, ...)
%token <name> IDENTIFIER "identifier"
-%type <seq> SelectQuery ConstructQuery DescribeQuery DeleteQuery InsertQuery
+%type <seq> SelectQuery ConstructQuery DescribeQuery
+%type <seq> Update UpdateQuery DeleteQuery InsertQuery
%type <seq> SelectExpressionList VarOrIRIrefList ArgList ConstructTriplesOpt
%type <seq> ConstructTemplate OrderConditionList
%type <seq> GraphNodeListNotEmpty SelectExpressionListTail
@@ -367,7 +368,50 @@ ReportFormat: SelectQuery
{
((rasqal_query*)rq)->verb=RASQAL_QUERY_VERB_ASK;
}
-| DeleteQuery
+| Update
+{
+}
+;
+
+
+Update: UpdateQuery
+{
+}
+| Update
+{
+ /* multiple updates in a single query */
+ rasqal_query* query=((rasqal_query*)rq);
+ query->next=rasqal_new_query(query->world, "laqrs", NULL);
+
+ /* copy prefixes */
+ if(query->prefixes) {
+ int idx;
+ for (idx = 0; idx < raptor_sequence_size(query->prefixes); idx++) {
+ rasqal_prefix* p = raptor_sequence_get_at(query->prefixes, idx);
+
+ unsigned char *prefix_string_copy = (unsigned char*)RASQAL_MALLOC(cstring, strlen(p->prefix));
+ strcpy((char*)prefix_string_copy, (const char*)p->prefix);
+
+ rasqal_query_add_prefix(query->next, rasqal_new_prefix(query->world, prefix_string_copy, raptor_uri_copy(p->uri)));
+ }
+ rasqal_query_declare_prefixes(query->next);
+ }
+
+ query->next->generate_bnodeid_handler_user_data = query->generate_bnodeid_handler_user_data;
+ query->next->generate_bnodeid_handler = query->generate_bnodeid_handler;
+
+ query->next->context = query->context;
+ query->context = NULL;
+
+ rq = query->next;
+}
+UpdateQuery
+{
+}
+;
+
+
+UpdateQuery: DeleteQuery
{
((rasqal_query*)rq)->constructs=$1;
((rasqal_query*)rq)->verb=RASQAL_QUERY_VERB_DELETE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]