Skip to content

Commit

Permalink
added support for savepoints (a kind of nested transaction)
Browse files Browse the repository at this point in the history
  • Loading branch information
ccgus committed Jun 24, 2011
1 parent 3ec98ec commit e2120a6
Show file tree
Hide file tree
Showing 7 changed files with 244 additions and 49 deletions.
2 changes: 1 addition & 1 deletion README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ Starting a transaction will keep the db from going back into the pool automatica

There is also a block based transaction approach:

[dbPool useTransaction:^(FMDatabase *db, BOOL *rollback) {
[dbPool inTransaction:^(FMDatabase *db, BOOL *rollback) {
[db executeUpdate:@"INSERT INTO myTable VALUES (?)", [NSNumber numberWithInt:1]];
[db executeUpdate:@"INSERT INTO myTable VALUES (?)", [NSNumber numberWithInt:2]];
[db executeUpdate:@"INSERT INTO myTable VALUES (?)", [NSNumber numberWithInt:3]];
Expand Down
1 change: 1 addition & 0 deletions fmdb.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@
1DEB927508733DD40010E9CD /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_FIX_AND_CONTINUE = YES;
Expand Down
18 changes: 12 additions & 6 deletions src/FMDatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@
NSString* _databasePath;
BOOL _logsErrors;
BOOL _crashOnErrors;
BOOL _inTransaction;
BOOL _traceExecution;
BOOL _checkedOut;
BOOL _shouldCacheStatements;
BOOL _inUse;
BOOL _isExecutingStatement;
BOOL _inTransaction;
int _busyRetryTimeout;



NSMutableDictionary *_cachedStatements;
NSMutableSet *_openResultSets;

Expand All @@ -26,7 +24,6 @@
}


@property (assign) BOOL inTransaction;
@property (assign) BOOL traceExecution;
@property (assign) BOOL checkedOut;
@property (assign) int busyRetryTimeout;
Expand Down Expand Up @@ -58,6 +55,8 @@

- (int)lastErrorCode;
- (BOOL)hadError;
- (NSError*)lastError;

- (sqlite_int64)lastInsertRowId;

- (sqlite3*)sqliteHandle;
Expand All @@ -77,10 +76,17 @@
- (BOOL)commit;
- (BOOL)beginTransaction;
- (BOOL)beginDeferredTransaction;

- (BOOL)inTransaction;
- (BOOL)shouldCacheStatements;
- (void)setShouldCacheStatements:(BOOL)value;

#if SQLITE_VERSION_NUMBER >= 3007000
- (BOOL)startSavePointWithName:(NSString*)name error:(NSError**)outErr;
- (BOOL)releaseSavePointWithName:(NSString*)name error:(NSError**)outErr;
- (BOOL)rollbackToSavePointWithName:(NSString*)name error:(NSError**)outErr;
- (NSError*)inSavePoint:(void (^)(BOOL *rollback))block;
#endif

+ (BOOL)isSQLiteThreadSafe;
+ (NSString*)sqliteLibVersion;

Expand Down
Loading

0 comments on commit e2120a6

Please sign in to comment.