Passing integrity_check PRAGMA option to NSPersistentStoreCoordinator when adding a store has no effect
| Originator: | kevin.lord | ||
| Number: | rdar://16649888 | Date Originated: | 17-Apr-2014 |
| Status: | Open | Resolved: | |
| Product: | iOS SDK | Product Version: | 7.1 |
| Classification: | Reproducible: | Yes |
We recently ran into a case where we were experiencing an edge case where our Core Data SQLite database would become corrupted. As a workaround, we wanted to try to pass the 'integrity_check' SQLite PRAGMA statement to our NSPersistentStoreCoordinator when adding our SQLite store so that we could detect corruption and reset the store if needed. Unfortunately we found that passing this option had no effect and did not execute the integrity check as desired, as evidenced by enabling the '-com.apple.CoreData.SQLDebug' launch option. In contrast, opening the SQLite database directly and executing the PRAGMA statement as an SQL statement ran the integrity check, detected the corruption, and achieved the desired result.
Steps to Reproduce:
NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"TestModel" withExtension:@"momd"];
NSManagedObjectModel *model = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];
NSPersistentStoreCoordinator *coordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:model];
NSMutableDictionary *storeOptions = [NSMutableDictionary dictionary];
storeOptions[NSSQLitePragmasOption] = @{@"integrity_check" : @100};
NSURL *storeURL = [[NSFileManager documentsDirectoryURL] URLByAppendingPathComponent:@"TestDB.sqlite"];
NSError *coreDataError;
NSPersistentStore *sqliteStore = [coordinator addPersistentStoreWithType: NSSQLiteStoreType
configuration:@"Default"
URL:storeURL
options:storeOptions
error:&coreDataError];
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!