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:
parent
e69a79ccff
commit
0dcc7ca72b
1 changed files with 20 additions and 12 deletions
32
dbdimp.c
32
dbdimp.c
|
@ -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;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue