[tracker] SPARQL: Ensure that transactions are not left open on errors
- From: JÃrg Billeter <juergbi src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [tracker] SPARQL: Ensure that transactions are not left open on errors
- Date: Wed, 29 Jul 2009 11:09:07 +0000 (UTC)
commit 4d873143e3fdeccecee208c780b3698724ba47bc
Author: Jürg Billeter <j bitron ch>
Date: Wed Jul 29 13:08:34 2009 +0200
SPARQL: Ensure that transactions are not left open on errors
src/libtracker-data/tracker-sparql-query.vala | 29 +++++++++++++------------
1 files changed, 15 insertions(+), 14 deletions(-)
---
diff --git a/src/libtracker-data/tracker-sparql-query.vala b/src/libtracker-data/tracker-sparql-query.vala
index 1b5ff50..0ed3ed2 100644
--- a/src/libtracker-data/tracker-sparql-query.vala
+++ b/src/libtracker-data/tracker-sparql-query.vala
@@ -348,23 +348,24 @@ public class Tracker.SparqlQuery : Object {
// all updates should be committed in one transaction
Data.begin_transaction ();
- unowned Rasqal.Query operation = query;
- while (operation != null) {
- if (operation.get_verb () == Rasqal.QueryVerb.INSERT) {
- execute_insert (operation);
- } else if (operation.get_verb () == Rasqal.QueryVerb.DELETE) {
- execute_delete (operation);
- } else if (operation.get_verb () == Rasqal.QueryVerb.DROP) {
- Data.delete_resource_description (operation.get_data_graph (0).name_uri.as_string ());
- } else {
- Data.commit_transaction ();
- throw new SparqlError.PARSE ("SELECT, CONSTRUCT, DESCRIBE, and ASK are not supported in update mode");
+ try {
+ unowned Rasqal.Query operation = query;
+ while (operation != null) {
+ if (operation.get_verb () == Rasqal.QueryVerb.INSERT) {
+ execute_insert (operation);
+ } else if (operation.get_verb () == Rasqal.QueryVerb.DELETE) {
+ execute_delete (operation);
+ } else if (operation.get_verb () == Rasqal.QueryVerb.DROP) {
+ Data.delete_resource_description (operation.get_data_graph (0).name_uri.as_string ());
+ } else {
+ throw new SparqlError.PARSE ("SELECT, CONSTRUCT, DESCRIBE, and ASK are not supported in update mode");
+ }
+ operation = operation.next ();
}
- operation = operation.next ();
+ } finally {
+ Data.commit_transaction ();
}
- Data.commit_transaction ();
-
return null;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]