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.6 2009/05/12 23:26:26 simon Exp $
--- dbdimp.c.orig	Thu Apr 23 12:12:05 2009
+++ dbdimp.c	Thu Apr 23 17:51:37 2009
@@ -169,8 +169,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;
 
