Skip Menu |

This queue is for tickets about the DBD-SQLite CPAN distribution.

Report information
The Basics
Id: 9643
Status: resolved
Priority: 0/
Queue: DBD-SQLite

People
Owner: Nobody in particular
Requestors: michael [...] schweisguth.com
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.07
Fixed in: (no value)



Subject: prepared statement not finalized in sqlite_st_finish
Hello, I have an SQLite program that manages about 256 Sqlite databases. Now, I tried to close them with disconnect but that didn't work. I went to the proc filesystem and noticed that the number of file handles was growing! So, I went to the source and found out that sqlite3_close was returning a "5" and the sqlite3.h file noted that it was probably because a prepared handle wasn't being finalized. That rang a bell since I was using prepared statements! So I checked the source and, as far as I could tell, if you use "prepare" and don't fetch all the rows, then the prepared statement isn't finalized in sqlite_st_finish. That rang a bell too since I was bailing out after I found the row I wanted! So I hacked the code a bit and added a DBIc_ACTIVE_on(imp_sth) in the sqlite_st_prepare function. My problems went away. I haven't analyzed the code enough to know if this is a bad thing, somehow... This is the change I made to dbdimp.c (I added only one line): DBIc_ACTIVE_on(imp_sth); DBIc_NUM_PARAMS(imp_sth) = sqlite3_bind_parameter_count(imp_sth->stmt); DBIc_NUM_FIELDS(imp_sth) = sqlite3_column_count(imp_sth->stmt); DBIc_IMPSET_on(imp_sth); I hope you find this useful! I attached my modified dbdimp.c file.

Message body is not shown because it is too large.

Subject: DBD::Sqlite doesn't close databases
I attached the files with the patches I made to the PERL sqlite dbdimp.c file and include a test case, the output and the updated file. Essentially, before I made the patch, the prepared statements weren't being finalized, and so, sqlite wouldn't close the database. My patch makes the prepared statement active so it is a candidate for finalization. Ultimately, this means that the database will be closed!
Download sqlite_patches.tar.gz
application/x-gzip-compressed 6.4k

Message body not shown because it is not plain text.

[MSERGEANT - Mon Feb 21 18:03:41 2005]: Show quoted text
> I cannot replicate this with the current CVS code, so I'm closing it > as resolved. New 1.08 will > be out today and may fix this...
Never mind - managed to replicate it after all.
Cleaner fix found, and applied.
[MSERGEANT - Mon Feb 21 18:14:08 2005]: Show quoted text
> Cleaner fix found, and applied.
Any news on this? It's still broken.
From: Jörg Mensmann
Somehow related, I was getting "closing dbh with active statement handles", when preparing a statement but not using it. The following code spits out that warning: use DBI; $dbh = DBI->connect("dbi:SQLite:dbname=test.db", "", ""); $dbh->do("CREATE TEMP TABLE test (a INTEGER, b INTEGER)"); $sth = $dbh->prepare("INSERT INTO test VALUES(?,?)"); As a workaround I added $sth->{Active} = 1; $sth->finish; which makes the warning disappear.
[guest - Wed May 4 07:31:39 2005]: Show quoted text
> [MSERGEANT - Mon Feb 21 18:14:08 2005]: >
> > Cleaner fix found, and applied.
> > Any news on this? It's still broken.
I just got bitten by this one with 1.0.9. (edwin@mavetju.org)
Marking as fixed in 1.13. Please re-open if that release doesn't fix your bug(s).