Преглед изворни кода

Fix version number checks

I missed a few `SQLITE_VERSION_NUMBER` checks in the headers
Robert M. Ryan пре 10 година
родитељ
комит
66e492a6de

+ 0 - 4
src/fmdb/FMDatabaseAdditions.h

@@ -209,8 +209,6 @@
 - (BOOL)validateSQL:(NSString*)sql error:(NSError**)error;
 
 
-#if SQLITE_VERSION_NUMBER >= 3007017
-
 ///-----------------------------------
 /// @name Application identifier tasks
 ///-----------------------------------
@@ -254,8 +252,6 @@
 - (void)setApplicationIDString:(NSString*)string;
 #endif
 
-#endif
-
 ///-----------------------------------
 /// @name user version identifier tasks
 ///-----------------------------------

+ 4 - 4
src/fmdb/FMDatabaseAdditions.m

@@ -120,10 +120,9 @@ - (BOOL)columnExists:(NSString*)columnName inTableWithName:(NSString*)tableName
 }
 
 
-#if SQLITE_VERSION_NUMBER >= 3007017
-
 - (uint32_t)applicationID {
     
+#if SQLITE_VERSION_NUMBER >= 3007017
     uint32_t r = 0;
     
     FMResultSet *rs = [self executeQuery:@"pragma application_id"];
@@ -133,15 +132,18 @@ - (uint32_t)applicationID {
     }
     
     [rs close];
+#endif
     
     return r;
 }
 
 - (void)setApplicationID:(uint32_t)appID {
+#if SQLITE_VERSION_NUMBER >= 3007017
     NSString *query = [NSString stringWithFormat:@"pragma application_id=%d", appID];
     FMResultSet *rs = [self executeQuery:query];
     [rs next];
     [rs close];
+#endif
 }
 
 
@@ -167,10 +169,8 @@ - (void)setApplicationIDString:(NSString*)s {
     [self setApplicationID:NSHFSTypeCodeFromFileType([NSString stringWithFormat:@"'%@'", s])];
 }
 
-
 #endif
 
-#endif
 
 - (uint32_t)userVersion {
     uint32_t r = 0;

+ 0 - 3
src/fmdb/FMDatabasePool.h

@@ -155,8 +155,6 @@
 
 - (void)inDeferredTransaction:(void (^)(FMDatabase *db, BOOL *rollback))block;
 
-#if SQLITE_VERSION_NUMBER >= 3007000
-
 /** Synchronously perform database operations in pool using save point.
 
  @param block The code to be run on the `FMDatabasePool` pool.
@@ -167,7 +165,6 @@
 */
 
 - (NSError*)inSavePoint:(void (^)(FMDatabase *db, BOOL *rollback))block;
-#endif
 
 @end
 

+ 7 - 4
src/fmdb/FMDatabasePool.m

@@ -239,9 +239,13 @@ - (void)inDeferredTransaction:(void (^)(FMDatabase *db, BOOL *rollback))block {
 - (void)inTransaction:(void (^)(FMDatabase *db, BOOL *rollback))block {
     [self beginTransaction:NO withBlock:block];
 }
-#if SQLITE_VERSION_NUMBER >= 3007000
+
 - (NSError*)inSavePoint:(void (^)(FMDatabase *db, BOOL *rollback))block {
     
+    NSError *err = 0x00;
+
+#if SQLITE_VERSION_NUMBER >= 3007000
+
     static unsigned long savePointIdx = 0;
     
     NSString *name = [NSString stringWithFormat:@"savePoint%ld", savePointIdx++];
@@ -250,8 +254,6 @@ - (NSError*)inSavePoint:(void (^)(FMDatabase *db, BOOL *rollback))block {
     
     FMDatabase *db = [self db];
     
-    NSError *err = 0x00;
-    
     if (![db startSavePointWithName:name error:&err]) {
         [self pushDatabaseBackInPool:db];
         return err;
@@ -267,8 +269,9 @@ - (NSError*)inSavePoint:(void (^)(FMDatabase *db, BOOL *rollback))block {
     
     [self pushDatabaseBackInPool:db];
     
+#endif
+    
     return err;
 }
-#endif
 
 @end

+ 0 - 2
src/fmdb/FMDatabaseQueue.h

@@ -174,11 +174,9 @@
  @param block The code to be run on the queue of `FMDatabaseQueue`
  */
 
-#if SQLITE_VERSION_NUMBER >= 3007000
 // NOTE: you can not nest these, since calling it will pull another database out of the pool and you'll get a deadlock.
 // If you need to nest, use FMDatabase's startSavePointWithName:error: instead.
 - (NSError*)inSavePoint:(void (^)(FMDatabase *db, BOOL *rollback))block;
-#endif
 
 @end
 

+ 6 - 3
src/fmdb/FMDatabaseQueue.m

@@ -205,11 +205,13 @@ - (void)inTransaction:(void (^)(FMDatabase *db, BOOL *rollback))block {
     [self beginTransaction:NO withBlock:block];
 }
 
-#if SQLITE_VERSION_NUMBER >= 3007000
 - (NSError*)inSavePoint:(void (^)(FMDatabase *db, BOOL *rollback))block {
     
-    static unsigned long savePointIdx = 0;
     __block NSError *err = 0x00;
+
+#if SQLITE_VERSION_NUMBER >= 3007000
+
+    static unsigned long savePointIdx = 0;
     FMDBRetain(self);
     dispatch_sync(_queue, ^() { 
         
@@ -230,8 +232,9 @@ - (NSError*)inSavePoint:(void (^)(FMDatabase *db, BOOL *rollback))block {
         }
     });
     FMDBRelease(self);
+
+#endif
     return err;
 }
-#endif
 
 @end