|
|
@@ -202,8 +202,8 @@ int main (int argc, const char * argv[]) {
|
|
|
NSLog(@"Count of changes (should be 1): %d", [db changes]);
|
|
|
FMDBQuickCheck([db changes] == 1);
|
|
|
|
|
|
- int a = [db intForQuery:@"select a from t1 where a = ?", [NSNumber numberWithInt:5]];
|
|
|
- if (a != 5) {
|
|
|
+ int ia = [db intForQuery:@"select a from t1 where a = ?", [NSNumber numberWithInt:5]];
|
|
|
+ if (ia != 5) {
|
|
|
NSLog(@"intForQuery didn't work (a != 5)");
|
|
|
}
|
|
|
|
|
|
@@ -255,10 +255,10 @@ int main (int argc, const char * argv[]) {
|
|
|
|
|
|
rs = [db executeQuery:@"select * from t2"];
|
|
|
while ([rs next]) {
|
|
|
- NSString *a = [rs stringForColumnIndex:0];
|
|
|
+ NSString *aa = [rs stringForColumnIndex:0];
|
|
|
NSString *b = [rs stringForColumnIndex:1];
|
|
|
|
|
|
- if (a != nil) {
|
|
|
+ if (aa != nil) {
|
|
|
NSLog(@"%s:%d", __FUNCTION__, __LINE__);
|
|
|
NSLog(@"OH OH, PROBLEMO!");
|
|
|
return 10;
|
|
|
@@ -409,7 +409,7 @@ int main (int argc, const char * argv[]) {
|
|
|
|
|
|
while ([rs next]) {
|
|
|
|
|
|
- int i = [rs intForColumnIndex:2];
|
|
|
+ i = [rs intForColumnIndex:2];
|
|
|
|
|
|
if (i == 12) {
|
|
|
// it's the first row we inserted.
|
|
|
@@ -596,7 +596,6 @@ int main (int argc, const char * argv[]) {
|
|
|
|
|
|
|
|
|
{
|
|
|
- NSError *err;
|
|
|
FMDBQuickCheck(([db update:@"insert into t5 values (?, ?, ?, ?, ?)" withErrorAndBindings:&err, @"text", [NSNumber numberWithInt:42], @"BLOB", @"d", [NSNumber numberWithInt:0]]));
|
|
|
|
|
|
}
|
|
|
@@ -697,19 +696,19 @@ int main (int argc, const char * argv[]) {
|
|
|
FMDBQuickCheck(queue);
|
|
|
|
|
|
{
|
|
|
- [queue inDatabase:^(FMDatabase *db) {
|
|
|
+ [queue inDatabase:^(FMDatabase *adb) {
|
|
|
|
|
|
|
|
|
|
|
|
- [db executeUpdate:@"create table qfoo (foo text)"];
|
|
|
- [db executeUpdate:@"insert into qfoo values ('hi')"];
|
|
|
- [db executeUpdate:@"insert into qfoo values ('hello')"];
|
|
|
- [db executeUpdate:@"insert into qfoo values ('not')"];
|
|
|
+ [adb executeUpdate:@"create table qfoo (foo text)"];
|
|
|
+ [adb executeUpdate:@"insert into qfoo values ('hi')"];
|
|
|
+ [adb executeUpdate:@"insert into qfoo values ('hello')"];
|
|
|
+ [adb executeUpdate:@"insert into qfoo values ('not')"];
|
|
|
|
|
|
|
|
|
|
|
|
int count = 0;
|
|
|
- FMResultSet *rsl = [db executeQuery:@"select * from qfoo where foo like 'h%'"];
|
|
|
+ FMResultSet *rsl = [adb executeQuery:@"select * from qfoo where foo like 'h%'"];
|
|
|
while ([rsl next]) {
|
|
|
count++;
|
|
|
}
|
|
|
@@ -717,7 +716,7 @@ int main (int argc, const char * argv[]) {
|
|
|
FMDBQuickCheck(count == 2);
|
|
|
|
|
|
count = 0;
|
|
|
- rsl = [db executeQuery:@"select * from qfoo where foo like ?", @"h%"];
|
|
|
+ rsl = [adb executeQuery:@"select * from qfoo where foo like ?", @"h%"];
|
|
|
while ([rsl next]) {
|
|
|
count++;
|
|
|
}
|
|
|
@@ -730,7 +729,7 @@ int main (int argc, const char * argv[]) {
|
|
|
|
|
|
{
|
|
|
// You should see pairs of numbers show up in stdout for this stuff:
|
|
|
- int ops = 16;
|
|
|
+ size_t ops = 16;
|
|
|
|
|
|
dispatch_queue_t dqueue = dispatch_get_global_queue(0, DISPATCH_QUEUE_PRIORITY_HIGH);
|
|
|
|
|
|
@@ -740,10 +739,10 @@ int main (int argc, const char * argv[]) {
|
|
|
if (nby % 2 == 1) {
|
|
|
[NSThread sleepForTimeInterval:.1];
|
|
|
|
|
|
- [queue inTransaction:^(FMDatabase *db, BOOL *rollback) {
|
|
|
+ [queue inTransaction:^(FMDatabase *adb, BOOL *rollback) {
|
|
|
NSLog(@"Starting query %ld", nby);
|
|
|
|
|
|
- FMResultSet *rsl = [db executeQuery:@"select * from qfoo where foo like 'h%'"];
|
|
|
+ FMResultSet *rsl = [adb executeQuery:@"select * from qfoo where foo like 'h%'"];
|
|
|
while ([rsl next]) {
|
|
|
;// whatever.
|
|
|
}
|
|
|
@@ -757,33 +756,33 @@ int main (int argc, const char * argv[]) {
|
|
|
[NSThread sleepForTimeInterval:.1];
|
|
|
}
|
|
|
|
|
|
- [queue inTransaction:^(FMDatabase *db, BOOL *rollback) {
|
|
|
+ [queue inTransaction:^(FMDatabase *adb, BOOL *rollback) {
|
|
|
NSLog(@"Starting update %ld", nby);
|
|
|
- [db executeUpdate:@"insert into qfoo values ('1')"];
|
|
|
- [db executeUpdate:@"insert into qfoo values ('2')"];
|
|
|
- [db executeUpdate:@"insert into qfoo values ('3')"];
|
|
|
+ [adb executeUpdate:@"insert into qfoo values ('1')"];
|
|
|
+ [adb executeUpdate:@"insert into qfoo values ('2')"];
|
|
|
+ [adb executeUpdate:@"insert into qfoo values ('3')"];
|
|
|
NSLog(@"Ending update %ld", nby);
|
|
|
}];
|
|
|
});
|
|
|
|
|
|
[queue close];
|
|
|
|
|
|
- [queue inDatabase:^(FMDatabase *db) {
|
|
|
- FMDBQuickCheck([db executeUpdate:@"insert into qfoo values ('1')"]);
|
|
|
+ [queue inDatabase:^(FMDatabase *adb) {
|
|
|
+ FMDBQuickCheck([adb executeUpdate:@"insert into qfoo values ('1')"]);
|
|
|
}];
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
- [queue inDatabase:^(FMDatabase *db) {
|
|
|
- [db executeUpdate:@"create table transtest (a integer)"];
|
|
|
- FMDBQuickCheck([db executeUpdate:@"insert into transtest values (1)"]);
|
|
|
- FMDBQuickCheck([db executeUpdate:@"insert into transtest values (2)"]);
|
|
|
+ [queue inDatabase:^(FMDatabase *adb) {
|
|
|
+ [adb executeUpdate:@"create table transtest (a integer)"];
|
|
|
+ FMDBQuickCheck([adb executeUpdate:@"insert into transtest values (1)"]);
|
|
|
+ FMDBQuickCheck([adb executeUpdate:@"insert into transtest values (2)"]);
|
|
|
|
|
|
int rowCount = 0;
|
|
|
- FMResultSet *rs = [db executeQuery:@"select * from transtest"];
|
|
|
- while ([rs next]) {
|
|
|
+ FMResultSet *ars = [adb executeQuery:@"select * from transtest"];
|
|
|
+ while ([ars next]) {
|
|
|
rowCount++;
|
|
|
}
|
|
|
|
|
|
@@ -792,8 +791,8 @@ int main (int argc, const char * argv[]) {
|
|
|
|
|
|
|
|
|
|
|
|
- [queue inTransaction:^(FMDatabase *db, BOOL *rollback) {
|
|
|
- FMDBQuickCheck([db executeUpdate:@"insert into transtest values (3)"]);
|
|
|
+ [queue inTransaction:^(FMDatabase *adb, BOOL *rollback) {
|
|
|
+ FMDBQuickCheck([adb executeUpdate:@"insert into transtest values (3)"]);
|
|
|
|
|
|
if (YES) {
|
|
|
// uh oh!, something went wrong (not really, this is just a test
|
|
|
@@ -801,18 +800,18 @@ int main (int argc, const char * argv[]) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- FMDBQuickCheck([db executeUpdate:@"insert into transtest values (4)"]);
|
|
|
+ FMDBQuickCheck([adb executeUpdate:@"insert into transtest values (4)"]);
|
|
|
}];
|
|
|
|
|
|
- [queue inDatabase:^(FMDatabase *db) {
|
|
|
+ [queue inDatabase:^(FMDatabase *adb) {
|
|
|
|
|
|
int rowCount = 0;
|
|
|
- FMResultSet *rs = [db executeQuery:@"select * from transtest"];
|
|
|
- while ([rs next]) {
|
|
|
+ FMResultSet *ars = [adb executeQuery:@"select * from transtest"];
|
|
|
+ while ([ars next]) {
|
|
|
rowCount++;
|
|
|
}
|
|
|
|
|
|
- FMDBQuickCheck(![db hasOpenResultSets]);
|
|
|
+ FMDBQuickCheck(![adb hasOpenResultSets]);
|
|
|
|
|
|
NSLog(@"after rollback, rowCount is %d (should be 2)", rowCount);
|
|
|
|
|
|
@@ -822,20 +821,20 @@ int main (int argc, const char * argv[]) {
|
|
|
|
|
|
// hey, let's make a custom function!
|
|
|
|
|
|
- [queue inDatabase:^(FMDatabase *db) {
|
|
|
+ [queue inDatabase:^(FMDatabase *adb) {
|
|
|
|
|
|
- [db executeUpdate:@"create table ftest (foo text)"];
|
|
|
- [db executeUpdate:@"insert into ftest values ('hello')"];
|
|
|
- [db executeUpdate:@"insert into ftest values ('hi')"];
|
|
|
- [db executeUpdate:@"insert into ftest values ('not h!')"];
|
|
|
- [db executeUpdate:@"insert into ftest values ('definitely not h!')"];
|
|
|
+ [adb executeUpdate:@"create table ftest (foo text)"];
|
|
|
+ [adb executeUpdate:@"insert into ftest values ('hello')"];
|
|
|
+ [adb executeUpdate:@"insert into ftest values ('hi')"];
|
|
|
+ [adb executeUpdate:@"insert into ftest values ('not h!')"];
|
|
|
+ [adb executeUpdate:@"insert into ftest values ('definitely not h!')"];
|
|
|
|
|
|
- [db makeFunctionNamed:@"StringStartsWithH" maximumArguments:1 withBlock:^(sqlite3_context *context, int argc, sqlite3_value **argv) {
|
|
|
- if (sqlite3_value_type(argv[0]) == SQLITE_TEXT) {
|
|
|
+ [adb makeFunctionNamed:@"StringStartsWithH" maximumArguments:1 withBlock:^(sqlite3_context *context, int aargc, sqlite3_value **aargv) {
|
|
|
+ if (sqlite3_value_type(aargv[0]) == SQLITE_TEXT) {
|
|
|
|
|
|
@autoreleasepool {
|
|
|
|
|
|
- const char *c = (const char *)sqlite3_value_text(argv[0]);
|
|
|
+ const char *c = (const char *)sqlite3_value_text(aargv[0]);
|
|
|
|
|
|
NSString *s = [NSString stringWithUTF8String:c];
|
|
|
|
|
|
@@ -843,14 +842,14 @@ int main (int argc, const char * argv[]) {
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
- NSLog(@"Unknown formart for StringStartsWithH (%d) %s:%d", sqlite3_value_type(argv[0]), __FUNCTION__, __LINE__);
|
|
|
+ NSLog(@"Unknown formart for StringStartsWithH (%d) %s:%d", sqlite3_value_type(aargv[0]), __FUNCTION__, __LINE__);
|
|
|
sqlite3_result_null(context);
|
|
|
}
|
|
|
}];
|
|
|
|
|
|
int rowCount = 0;
|
|
|
- FMResultSet *rs = [db executeQuery:@"select * from ftest where StringStartsWithH(foo)"];
|
|
|
- while ([rs next]) {
|
|
|
+ FMResultSet *ars = [adb executeQuery:@"select * from ftest where StringStartsWithH(foo)"];
|
|
|
+ while ([ars next]) {
|
|
|
rowCount++;
|
|
|
|
|
|
NSLog(@"Does %@ start with 'h'?", [rs stringForColumnIndex:0]);
|
|
|
@@ -1042,9 +1041,9 @@ void testPool(NSString *dbPath) {
|
|
|
FMDBQuickCheck(![adb hadError]);
|
|
|
[adb executeUpdate:@"insert into easy values (?)", [NSNumber numberWithInt:1009]];
|
|
|
|
|
|
- [adb inSavePoint:^(BOOL *rollback) {
|
|
|
+ [adb inSavePoint:^(BOOL *arollback) {
|
|
|
FMDBQuickCheck(([adb executeUpdate:@"insert into easy values (?)", [NSNumber numberWithInt:1010]]));
|
|
|
- *rollback = YES;
|
|
|
+ *arollback = YES;
|
|
|
}];
|
|
|
}];
|
|
|
|
|
|
@@ -1095,7 +1094,7 @@ void testPool(NSString *dbPath) {
|
|
|
|
|
|
{
|
|
|
|
|
|
- int ops = 128;
|
|
|
+ size_t ops = 128;
|
|
|
|
|
|
dispatch_queue_t dqueue = dispatch_get_global_queue(0, DISPATCH_QUEUE_PRIORITY_HIGH);
|
|
|
|