1
0
Fork 0
mirror of https://github.com/DBD-SQLite/DBD-SQLite synced 2025-06-08 06:38:12 -04:00

DBD::SQLite: looks like the segfault is gone, but please wait for a while to see if this fix really *fix* the real problems. we need more teests

This commit is contained in:
Kenichi Ishigaki 2009-10-19 14:56:36 +00:00
parent e69a79ccff
commit 0dcc7ca72b

View file

@ -146,9 +146,7 @@ sqlite_db_disconnect(SV *dbh, imp_dbh_t *imp_dbh)
{ {
dTHX; dTHX;
int rc; int rc;
#if 0
sqlite3_stmt *pStmt; sqlite3_stmt *pStmt;
#endif
DBIc_ACTIVE_off(imp_dbh); DBIc_ACTIVE_off(imp_dbh);
if (DBIc_is(imp_dbh, DBIcf_AutoCommit) == FALSE) { if (DBIc_is(imp_dbh, DBIcf_AutoCommit) == FALSE) {
@ -157,9 +155,10 @@ sqlite_db_disconnect(SV *dbh, imp_dbh_t *imp_dbh)
#if 0 #if 0
/* /*
** This cause segfaults when we have virtual tables, as sqlite3 seems ** This cause segfaults when we have virtual tables, as sqlite3
** to try to finalize the statements for the tables (freed here) while ** seems to try to finalize the statements for the tables (freed
** closing. So we need to find other ways to do the right thing. ** here) while closing. So we need to find other ways to do the
** right thing.
*/ */
while ( (pStmt = sqlite3_next_stmt(imp_dbh->db, 0)) != NULL ) { while ( (pStmt = sqlite3_next_stmt(imp_dbh->db, 0)) != NULL ) {
sqlite3_finalize(pStmt); sqlite3_finalize(pStmt);
@ -169,14 +168,23 @@ sqlite_db_disconnect(SV *dbh, imp_dbh_t *imp_dbh)
rc = sqlite3_close(imp_dbh->db); rc = sqlite3_close(imp_dbh->db);
if (rc != SQLITE_OK) { if (rc != SQLITE_OK) {
/* /*
** "closing dbh with ..." message is not always true. ** Most probably we still have unfinalized statements.
** (SQLITE_BUSY may occur due to the unfinished backup operation) ** Let's try to close them.
** We may need to wait for a while if we get SQLITE_BUSY. ** TODO: We also need to deactivate statement handles somehow
** XXX: Putting "warn" here is just for the debugging purpose.
*/ */
warn((char*)sqlite3_errmsg(imp_dbh->db)); while ( (pStmt = sqlite3_next_stmt(imp_dbh->db, 0)) != NULL ) {
sqlite_error(dbh, (imp_xxh_t*)imp_dbh, rc, (char*)sqlite3_errmsg(imp_dbh->db)); sqlite3_finalize(pStmt);
/* warn("closing dbh with active statement handles"); */ }
rc = sqlite3_close(imp_dbh->db);
if (rc != SQLITE_OK) {
/*
** We still have problems. probably a backup operation
** is not finished. We may need to wait for a while if
** we get SQLITE_BUSY...
*/
sqlite_error(dbh, (imp_xxh_t*)imp_dbh, rc, (char*)sqlite3_errmsg(imp_dbh->db));
}
} }
imp_dbh->db = NULL; imp_dbh->db = NULL;