• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: CoreData - sqlite - statement is still active
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CoreData - sqlite - statement is still active


  • Subject: Re: CoreData - sqlite - statement is still active
  • From: Terrence Talbot <email@hidden>
  • Date: Fri, 7 Oct 2005 13:57:10 -0700


On Oct 6, 2005, at 3:30 PM, Bill Bumgarner wrote:

On Oct 6, 2005, at 12:03 PM, Terrence Talbot wrote:

No, that's the thing: this should be a very straightforward exercise. Single document, single context, single thread. The only diddling I've done is a .dump (and now some selects, see below) of the document on the command-line to make sure the rows for these objects are there. They are...


Hmmm... I'm still missing something because I don't understand why it wouldn't work.



I don't either. Let me try asking this a different way:

Is there some way, given a single-threaded app, to get an executeFetchRequest: going before another one returns? Is there a way I could block, in addition to whatever CoreData is doing, to test this?

Here's a run from a newly created document this morning. Note the log statements. It starts a fetch for Cathedral *before* the fetch for 151 returns! (It then asks to fetch in a relationship for an object, Aqua, that was previously fetched successfully and dies. The fetch for Cathedral does not appear to return.)

I rejiggered my code so that all fetches go through the same category method on NSManagedObjectContext. I'll paste the method below just to show the sequence of the log statements. I would have expected each fetch/return log to be paired and, up until one before the crash, they are. And it's not always the same object being fetched that causes the problem.

The only pattern I can see, though in previous fetches it's ok, is that the problem *seems* to occur after consecutively fetching the same object first by name, then by uniqueID (both String attributes). For example, Aqua and 151 are the same object, below.

I'm stumped as to what to try next.

- Terrence

--
[snip] fetch: (entity: Media; predicate: name LIKE "Aqua";)
[snip] one object returned for (entity: Media; predicate: name LIKE "Aqua";)


[snip] asking for KTMediaURLProtocol dataWithResourceSpecifier: 151
[snip] fetch: (entity: Media; predicate: uniqueID LIKE "151";)
[snip] asking for KTMedia objectWithName: Cathedral
[snip] fetch: (entity: Media; predicate: name LIKE "Cathedral";)
[snip] one object returned for (entity: Media; predicate: uniqueID LIKE "151";)


[snip] asking for mediaData.contents for Aqua
[snip] An uncaught exception was raised
[snip] statement is still active
[snip] *** Uncaught exception: <NSInternalInconsistencyException> statement is still active
Program received signal: "EXC_BAD_ACCESS".
--
- (NSArray *)objectsWithEntityName:(NSString *)anEntityName
predicate:(NSPredicate *)aPredicate
error:(NSError **)anError
{
NSAssert((nil != anEntityName), @"anEntityName cannot be nil");


    NSArray *fetchedObjects = nil;
    NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
    NSError *localError = nil;

@try
{
[fetchRequest setEntity:[NSEntityDescription entityForName:anEntityName
inManagedObjectContext:self]];
if ( nil != aPredicate )
{
[fetchRequest setPredicate:aPredicate];
}


        // LOG fetchRequest
        LOG((@"fetch: %@", [fetchRequest shortDescription]));

fetchedObjects = [self executeFetchRequest:fetchRequest error:&localError];

// LOG result
if ( (nil != fetchedObjects) && [fetchedObjects count] == 0 )
{
LOG((@"no objects returned for %@\n\n", [fetchRequest shortDescription]));
}
else if ( (nil != fetchedObjects) && [fetchedObjects count] == 1 )
{
LOG((@"one object returned for %@\n\n", [fetchRequest shortDescription]));
}
else if ( (nil != fetchedObjects) && [fetchedObjects count] > 1 )
{
LOG((@"multiple objects returned for %@\n\n", [fetchRequest shortDescription]));
}
}
@finally
{
if ( nil != localError )
{
LOG((@"error: %@", localError));
anError = &localError;
}
[fetchRequest release];
}


if ( nil == fetchedObjects )
{
LOG((@"nil returned for %@\n\n", [fetchRequest shortDescription]));
}


    return fetchedObjects;
}

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >CoreData - sqlite - statement is still active (From: Terrence Talbot <email@hidden>)
 >Re: CoreData - sqlite - statement is still active (From: Bill Bumgarner <email@hidden>)
 >Re: CoreData - sqlite - statement is still active (From: Terrence Talbot <email@hidden>)
 >Re: CoreData - sqlite - statement is still active (From: Bill Bumgarner <email@hidden>)

  • Prev by Date: Re: Stop screensaver blanking
  • Next by Date: Re: Hiding the disclosure triangle in NSOutlineView
  • Previous by thread: Re: CoreData - sqlite - statement is still active
  • Next by thread: Re: CoreData - sqlite - statement is still active
  • Index(es):
    • Date
    • Thread