Cannot close database (iphone sdk)

19 views
Skip to first unread message

yakbuttercandle

unread,
Sep 2, 2008, 4:54:00 PM9/2/08
to pldatabase
Can someone tell me the likely causes of an exception when closing the
database - "Database at <path> can not be closed, as the
implementation has leaked prepared statements"

Landon Fuller

unread,
Sep 2, 2008, 4:55:27 PM9/2/08
to pldat...@googlegroups.com

What version of PLDatabase are you using?

Thanks,
Landon

PGP.sig

yakbuttercandle

unread,
Sep 2, 2008, 5:01:57 PM9/2/08
to pldatabase
3.0.8.6 I think - it came with the SDK
>  PGP.sig
> < 1KViewDownload

Landon Fuller

unread,
Sep 2, 2008, 5:06:18 PM9/2/08
to pldat...@googlegroups.com

Also --

The only way I know for this to occur is either:
1) An implementation bug, where PLSqlitePreparedStatement fails to
retain a reference to the database
2) Over-release of the PLDatabase instance by the API client, such
that deallocation occurs before all prepared statements have been
released.

See also:
http://code.google.com/p/pldatabase/source/browse/branches/pldatabase-1.1/Classes/PLSqlitePreparedStatement.m


Cheers,
Landon

PGP.sig

yakbuttercandle

unread,
Sep 2, 2008, 6:20:33 PM9/2/08
to pldatabase
Simple test case reproduces problem. Can you tell me if I'm not doing
this correctly

- (void) testSimpleInsert {

NSString *pathToDb = [DBUtil pathToDb];
PLSqliteDatabase *db = [[PLSqliteDatabase alloc]
initWithPath:pathToDb];
[db open];
NSObject<PLPreparedStatement> *stmt = [db prepareStatement:@"INSERT
INTO VM_CATEGORY (category, domain) VALUES(:category, :domain)"];
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
[dict setObject:@"test category" forKey:@"category"];
[dict setObject:@"test domain" forKey:@"domain"];
[stmt bindParameterDictionary:dict];
[db beginTransaction];
STAssertTrue([stmt executeUpdate], @"INSERT failed");
[db commitTransaction];
[stmt close];
[db close];
[db release];
>        http://code.google.com/p/pldatabase/source/browse/branches/pldatabase...
>
> Cheers,
> Landon
>
>  PGP.sig
> < 1KViewDownload

Landon Fuller

unread,
Sep 3, 2008, 4:26:11 AM9/3/08
to pldat...@googlegroups.com

On Sep 2, 2008, at 3:20 PM, yakbuttercandle wrote:

>
> Simple test case reproduces problem. Can you tell me if I'm not doing
> this correctly

At a glance it looks like a library bug, but I'm afraid I'm up against
a tight deadline and won't be able to look into it until next week.

-landonf

PGP.sig

Landon Fuller

unread,
Sep 8, 2008, 2:29:49 PM9/8/08
to pldat...@googlegroups.com

On Sep 2, 2008, at 3:20 PM, yakbuttercandle wrote:

>
> Simple test case reproduces problem. Can you tell me if I'm not doing
> this correctly

Thanks for this. I added bug #6 to track the issue, and fixed the bug
in trunk as of r225:
http://code.google.com/p/pldatabase/issues/detail?id=6

-landonf

PGP.sig
Reply all
Reply to author
Forward
0 new messages