mirror of
https://github.com/DBD-SQLite/DBD-SQLite
synced 2025-06-07 14:19:10 -04:00
DBD::SQLite: applied yet another patch to fix the "closing dbh with active statement handles" by TOKUHIROM (http://d.hatena.ne.jp/tokuhirom/20080727/1217140312)
This commit is contained in:
parent
dec1e584f4
commit
99dfbee4ba
1 changed files with 10 additions and 1 deletions
11
dbdimp.c
11
dbdimp.c
|
@ -144,12 +144,17 @@ int
|
||||||
sqlite_db_disconnect (SV *dbh, imp_dbh_t *imp_dbh)
|
sqlite_db_disconnect (SV *dbh, imp_dbh_t *imp_dbh)
|
||||||
{
|
{
|
||||||
dTHR;
|
dTHR;
|
||||||
|
sqlite3_stmt *pStmt;
|
||||||
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) {
|
||||||
sqlite_db_rollback(dbh, imp_dbh);
|
sqlite_db_rollback(dbh, imp_dbh);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while ( (pStmt = sqlite3_next_stmt(imp_dbh->db, 0))!=0 ) {
|
||||||
|
sqlite3_finalize(pStmt);
|
||||||
|
}
|
||||||
|
|
||||||
if (sqlite3_close(imp_dbh->db) == SQLITE_BUSY) {
|
if (sqlite3_close(imp_dbh->db) == SQLITE_BUSY) {
|
||||||
/* active statements! */
|
/* active statements! */
|
||||||
warn("closing dbh with active statement handles");
|
warn("closing dbh with active statement handles");
|
||||||
|
@ -606,9 +611,13 @@ sqlite_st_finish3 (SV *sth, imp_sth_t *imp_sth, int is_destroy)
|
||||||
void
|
void
|
||||||
sqlite_st_destroy (SV *sth, imp_sth_t *imp_sth)
|
sqlite_st_destroy (SV *sth, imp_sth_t *imp_sth)
|
||||||
{
|
{
|
||||||
|
D_imp_dbh_from_sth;
|
||||||
/* warn("destroy statement: %s\n", imp_sth->statement); */
|
/* warn("destroy statement: %s\n", imp_sth->statement); */
|
||||||
DBIc_ACTIVE_off(imp_sth);
|
DBIc_ACTIVE_off(imp_sth);
|
||||||
sqlite3_finalize(imp_sth->stmt);
|
if (DBIc_ACTIVE(imp_dbh)) {
|
||||||
|
/* finalize sth when active connection */
|
||||||
|
sqlite3_finalize(imp_sth->stmt);
|
||||||
|
}
|
||||||
Safefree(imp_sth->statement);
|
Safefree(imp_sth->statement);
|
||||||
SvREFCNT_dec((SV*)imp_sth->params);
|
SvREFCNT_dec((SV*)imp_sth->params);
|
||||||
SvREFCNT_dec((SV*)imp_sth->col_types);
|
SvREFCNT_dec((SV*)imp_sth->col_types);
|
||||||
|
|
Loading…
Add table
Reference in a new issue