[darwinbuild-changes] [21] trunk/darwinxref/DBDataStore.c

source_changes at macosforge.org source_changes at macosforge.org
Wed Oct 4 01:37:41 PDT 2006


Revision: 21
          http://trac.macosforge.org/projects/darwinbuild/changeset/21
Author:   kevin
Date:     2006-10-04 01:37:41 -0700 (Wed, 04 Oct 2006)

Log Message:
-----------
- allow nested transactions

Modified Paths:
--------------
    trunk/darwinxref/DBDataStore.c

Modified: trunk/darwinxref/DBDataStore.c
===================================================================
--- trunk/darwinxref/DBDataStore.c	2005-06-19 01:32:45 UTC (rev 20)
+++ trunk/darwinxref/DBDataStore.c	2006-10-04 08:37:41 UTC (rev 21)
@@ -40,6 +40,7 @@
 // We currently operate under the assumption that there is only
 // one thread, with no plugin re-entrancy.
 //////
+int __nestedTransactions = 0;
 void* __DBDataStore;
 void* _DBPluginGetDataStorePtr() {
 	return __DBDataStore;
@@ -563,14 +564,28 @@
 }
 
 
+// NOT THREAD SAFE
 int DBBeginTransaction() {
-	return SQL("BEGIN");
+	++__nestedTransactions;
+	if (__nestedTransactions == 1) {
+		return SQL("BEGIN");
+	} else {
+		return SQLITE_OK;
+	}
 }
+// NOT THREAD SAFE
 int DBRollbackTransaction() {
+	__nestedTransactions = 0;
 	return SQL("ROLLBACK");
 }
+// NOT THREAD SAFE
 int DBCommitTransaction() {
-	return SQL("COMMIT");
+	--__nestedTransactions;
+	if (__nestedTransactions == 0) {
+		return SQL("COMMIT");
+	} else {
+		return SQLITE_OK;
+	}
 }
 
 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/darwinbuild-changes/attachments/20061004/a5f23620/attachment.html


More information about the darwinbuild-changes mailing list