Subject: | Patch to fix "closing dbh with active statement handles" |
Hi,
i've seen those warnings numerous times, just like many other people:
closing dbh with active statement handles at test.pl line 24.
Now a friend proposed a workaround for another module where those
warnings were seen and i was fed up and started to investigate.
I found the solution in the SQLite documentation
<http://sqlite.org/c3ref/close.html> where a function is used that
occurred in version 3.6.0 of sqlite.
The fix itself is pretty small:
--- dbdimp.c.orig Fri Aug 24 04:51:25 2007
+++ dbdimp.c Sat Oct 25 22:31:04 2008
@@ -151,8 +151,13 @@ sqlite_db_disconnect (SV *dbh, imp_dbh_t *imp_dbh)
}
if (sqlite3_close(imp_dbh->db) == SQLITE_BUSY) {
+ sqlite3_stmt *pStmt;
/* active statements! */
- warn("closing dbh with active statement handles");
+
+ while ((pStmt = sqlite3_next_stmt(imp_dbh->db, NULL)) != NULL)
+ sqlite3_finalize(pStmt);
+
+ sqlite3_close(imp_dbh->db);
}
imp_dbh->db = NULL;
A greater problem was to get it working with a system-wide installed
sqlite library as the local header files get picked up instead of the
system-wide installed headers. Besides that the local version wouldn't
work anymore just with the above patch.
So i also had to update the local version of sqlite.
The resulting patch is obviously pretty big as it updates the whole
sqlite distribution coming with DBD::SQLite.
I really hope this can finally close this long standing bug.
Kind regards,
Simon
Subject: | DBD-SQLite-1.14.diff.gz |
Message body not shown because it is not plain text.
Subject: | patch-dbdimp_c.diff |
--- dbdimp.c.orig Fri Aug 24 04:51:25 2007
+++ dbdimp.c Sat Oct 25 22:31:04 2008
@@ -151,8 +151,13 @@ sqlite_db_disconnect (SV *dbh, imp_dbh_t *imp_dbh)
}
if (sqlite3_close(imp_dbh->db) == SQLITE_BUSY) {
+ sqlite3_stmt *pStmt;
/* active statements! */
- warn("closing dbh with active statement handles");
+
+ while ((pStmt = sqlite3_next_stmt(imp_dbh->db, NULL)) != NULL)
+ sqlite3_finalize(pStmt);
+
+ sqlite3_close(imp_dbh->db);
}
imp_dbh->db = NULL;