Permalink
Browse files

Got the order of things wrong with transactions + a pool.

  • Loading branch information...
1 parent 793c6ef commit a010ef4f26d3e3609bc393ee4c576054ca81c8fa @ccgus ccgus committed Jun 23, 2011
Showing with 19 additions and 9 deletions.
  1. +17 −9 src/FMDatabase.m
  2. +2 −0 src/fmdb.m
View
@@ -845,40 +845,48 @@ - (BOOL)rollback {
BOOL b = [self executeUpdate:@"ROLLBACK TRANSACTION;"];
if (b) {
_inTransaction = NO;
- [self pushInPoolIfClose];
}
+
+ [self pushInPoolIfClose];
+
return b;
}
- (BOOL)commit {
BOOL b = [self executeUpdate:@"COMMIT TRANSACTION;"];
if (b) {
_inTransaction = NO;
- [self pushInPoolIfClose];
}
+
+ [self pushInPoolIfClose];
+
return b;
}
- (BOOL)beginDeferredTransaction {
+
+ if (_pool) {
+ [self pullFromPool];
+ }
+
BOOL b = [self executeUpdate:@"BEGIN DEFERRED TRANSACTION;"];
if (b) {
_inTransaction = YES;
-
- if (_pool) {
- [self pullFromPool];
- }
}
+
return b;
}
- (BOOL)beginTransaction {
+
+ if (_pool) {
+ [self pullFromPool];
+ }
+
BOOL b = [self executeUpdate:@"BEGIN EXCLUSIVE TRANSACTION;"];
if (b) {
_inTransaction = YES;
- if (_pool) {
- [self pullFromPool];
- }
}
return b;
View
@@ -635,6 +635,8 @@ int main (int argc, const char * argv[]) {
[db commit];
+ [db executeUpdate:@"insert into easy values (?)", [NSNumber numberWithInt:3]];
+
FMDBQuickCheck([dbPool countOfOpenDatabases] == 1);

0 comments on commit a010ef4

Please sign in to comment.