Re: corrupt coredata DB
Re: corrupt coredata DB
- Subject: Re: corrupt coredata DB
- From: Devon Ferns <email@hidden>
- Date: Wed, 08 Oct 2008 12:06:10 -0400
DELETE FROM zplayedtrack WHERE z_opt = null
I don't know much about CoreData but maybe you can't bind null
parameters in SQLite?
Devon
Marc Monguio wrote:
I have a coredata application that uses sqlite3 for persistence. One of
my users reported that his application was not responsive and showed the
spinning beach ball of death. If I debug the application using his
database it stops after executing this:
// objectId is the object we want to delete
NSManagedObject *managedObj = [[self managedObjectContext]
objectWithID:objectId];
[[self managedObjectContext] deleteObject:managedObj];
NSError *error;
[[self managedObjectContext] save:&error]
It never goes beyond the line above. The System halts at the save
command without fulfilling the error object. If I run the application
with the "-com.apple.CoreData.SQLDebug 5" argument and look at the
console I see the infinite loop that is freezing the application:
CoreData: sql: BEGIN EXCLUSIVE
CoreData: sql: DELETE FROM ZPLAYEDTRACK WHERE Z_PK = ? AND Z_OPT = ?
CoreData: details: SQLite bind[0] = (int64)660
CoreData: details: SQLite bind[1] = nil
CoreData: sql: SELECT Z_PK,Z_OPT FROM ZPLAYEDTRACK WHERE Z_PK IN (660)
ORDER BY Z_PK
CoreData: annotation: sql execution time: 0.0069s
CoreData: sql: ROLLBACK
CoreData: sql: BEGIN EXCLUSIVE
CoreData: sql: DELETE FROM ZPLAYEDTRACK WHERE Z_PK = ? AND Z_OPT = ?
CoreData: details: SQLite bind[0] = (int64)660
CoreData: details: SQLite bind[1] = nil
CoreData: sql: SELECT Z_PK,Z_OPT FROM ZPLAYEDTRACK WHERE Z_PK IN (660)
ORDER BY Z_PK
CoreData: annotation: sql execution time: 0.0056s
CoreData: sql: ROLLBACK
(...)
Looks like it's trying to delete the object repeatedly in the database
but it can't and then rolls back and tries again. By looking inside the
sqlite database directly through sqlite3 tool I see that the tuple that
coredata is trying to delete has Z_OPT equal to null:
sqlite> .schema ZPLAYEDTRACK
CREATE TABLE ZPLAYEDTRACK ( ZSKIP INTEGER, ZSHUFFLEMODE INTEGER, Z_OPT
INTEGER, Z_ENT INTEGER, Z_PK INTEGER PRIMARY KEY, ZEND FLOAT, ZBEGIN
FLOAT, ZTRACKNAME VARCHAR, ZLOCATION VARCHAR, ZALBUMNAME VARCHAR,
ZARTISTNAME VARCHAR, ZSOURCE VARCHAR, ZPLAYLISTNAME VARCHAR );
sqlite> select z_pk, z_ent, z_opt from zplayedtrack;
660|1|
661|1|
662|1|1
663|1|1
How can I delete the two tuples (660 and 661) that have Z_OPT equal to
NULL with coredata ?
Any idea why Coredata ended with those tuples with null Z_OPT ?
regards,
Marc
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden