Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions Tests/FMDatabaseQueueTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -369,4 +369,24 @@ - (void)testClose
}];
}

- (void)testResultSetDealloc
{
[self.queue inDatabase:^(FMDatabase * _Nonnull db) {
[db executeUpdate:@"create table if not exists test (a text, b text, c text, d text)"];
for (int i = 0; i < 10; i++) {
[db executeUpdate:@"insert into test (a, b, c, d) values ('1', '1', '1','1')"];
}
}];

size_t ops = 10;

dispatch_queue_t dqueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);

dispatch_apply(ops, dqueue, ^(size_t nby) {
[self.queue inDatabase:^(FMDatabase *db) {
[db executeQuery:@"select * from test"];
}];
});
}

@end
1 change: 1 addition & 0 deletions src/fmdb/FMDatabaseQueue.m
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ - (void)inDatabase:(__attribute__((noescape)) void (^)(FMDatabase *db))block {

if ([db hasOpenResultSets]) {
NSLog(@"Warning: there is at least one open result set around after performing [FMDatabaseQueue inDatabase:]");
[db closeOpenResultSets];

#if defined(DEBUG) && DEBUG
NSSet *openSetCopy = FMDBReturnAutoreleased([[db valueForKey:@"_openResultSets"] copy]);
Expand Down