openbsd-ports/databases/p5-DBD-SQLite/patches/patch-dbdimp_c
simon 076fd8c72b Fix "closing dbh with active statement handles" issue caused by prepared
statements which weren't finalized by $dbh->disconnect().

Since version 3.6.0 of sqlite one can use the new sqlite3_next_stmt()
function to get all open statements and call sqlite3_finalize() on them.
This patch implements that behaviour.

Problem brought to my attention again by bernd@ at p2k8 and i had it in
my tree since then without any issues.
Testing and ok by bernd@ and pea@, thanks!

Bug filed upstream at http://rt.cpan.org/Public/Bug/Display.html?id=40383
2009-01-24 17:42:22 +00:00

23 lines
762 B
Plaintext

This patch makes sure that prepared statements get closed when
$dbh->disconnect() is called. Ticket created upstream at
http://rt.cpan.org/Public/Bug/Display.html?id=40383
$OpenBSD: patch-dbdimp_c,v 1.5 2009/01/24 17:42:22 simon Exp $
--- 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;