> On 14 Mar 2010, at 9:47 PM, mmalc Crawford wrote:
> 
>> On Mar 14, 2010, at 7:21 pm, Dave Fernandes wrote:
>> 
>>> So my question is - how do you detect this before loading the file? I'm 
>>> aware of the sqlite3 PRAGMA integrity_check, but there does not seem to be 
>>> a C API for this. Any pointers?
>>> 
>> <http://developer.apple.com/mac/library/documentation/Cocoa/Reference/CoreDataFramework/Classes/NSPersistentStoreCoordinator_Class/NSPersistentStoreCoordinator.html#//apple_ref/doc/c_ref/NSSQLitePragmasOption>
>> 
>> See 
>> <http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/CoreData/Articles/cdPersistentStores.html#//apple_ref/doc/uid/TP40002875>
>>  for an example.
> 
> My understanding may be incomplete, but it seems that the example shows the 
> use of pragmas (pragmata?) that set the state of the store at 
> addPersistentStore...: time, and have no significant return value. PRAGMA 
> integrity_check and PRAGMA quick_check return tables. 
> 
> Is there a way to collect the results of the integrity check? Would 
> addPersistentStore...: return nil and somehow populate the error return?

Yes, if it detects corruption you'll get an error back.  There isn't much 
useful in the "result" tables from those pragmas.

Running an integrity check can be useful if you have previously gotten a 
corrupt db error back from fetching or saving, or your app previously crashed, 
or you have some other active indicator it might be worthwhile.  However, it's 
quiet expensive in I/O and you should not do it on every app launch / document 
open.  Customers with account home directories on AFP, NFS or SMB servers will 
be very unhappy, and if your files become large enough so will people using 
local drives.

- Ben

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to