1
0
Fork 0
mirror of https://github.com/DBD-SQLite/DBD-SQLite synced 2025-06-07 22:28:47 -04:00

DBD::SQLite: cosmetics and squash a warning

This commit is contained in:
Kenichi Ishigaki 2009-10-19 07:19:25 +00:00
parent 1dcd2489c0
commit bcdce2f1fc

View file

@ -99,8 +99,7 @@ sqlite_db_login(SV *dbh, imp_dbh_t *imp_dbh, char *dbname, char *user, char *pas
if ( rc != SQLITE_OK ) { if ( rc != SQLITE_OK ) {
/* warn("failed to set pragma: %s\n", errmsg); */ /* warn("failed to set pragma: %s\n", errmsg); */
sqlite_error(dbh, (imp_xxh_t*)imp_dbh, rc, errmsg); sqlite_error(dbh, (imp_xxh_t*)imp_dbh, rc, errmsg);
if (errmsg) if (errmsg) sqlite3_free(errmsg);
sqlite3_free(errmsg);
sqlite3_close(imp_dbh->db); /* we don't use this handle */ sqlite3_close(imp_dbh->db); /* we don't use this handle */
return FALSE; /* -> undef in lib/DBD/SQLite.pm */ return FALSE; /* -> undef in lib/DBD/SQLite.pm */
} }
@ -109,8 +108,7 @@ sqlite_db_login(SV *dbh, imp_dbh_t *imp_dbh, char *dbname, char *user, char *pas
if ( rc != SQLITE_OK ) { if ( rc != SQLITE_OK ) {
/* warn("failed to set pragma: %s\n", errmsg); */ /* warn("failed to set pragma: %s\n", errmsg); */
sqlite_error(dbh, (imp_xxh_t*)imp_dbh, rc, errmsg); sqlite_error(dbh, (imp_xxh_t*)imp_dbh, rc, errmsg);
if (errmsg) if (errmsg) sqlite3_free(errmsg);
sqlite3_free(errmsg);
sqlite3_close(imp_dbh->db); /* we don't use this handle */ sqlite3_close(imp_dbh->db); /* we don't use this handle */
return FALSE; /* -> undef in lib/DBD/SQLite.pm */ return FALSE; /* -> undef in lib/DBD/SQLite.pm */
} }
@ -175,7 +173,7 @@ sqlite_db_disconnect(SV *dbh, imp_dbh_t *imp_dbh)
** XXX: Putting "warn" here is just for the debugging purpose. ** XXX: Putting "warn" here is just for the debugging purpose.
*/ */
warn((char*)sqlite3_errmsg(imp_dbh->db)); warn((char*)sqlite3_errmsg(imp_dbh->db));
sqlite_error(dbh, imp_dbh, rc, (char*)sqlite3_errmsg(imp_dbh->db)); sqlite_error(dbh, (imp_xxh_t*)imp_dbh, rc, (char*)sqlite3_errmsg(imp_dbh->db));
/* warn("closing dbh with active statement handles"); */ /* warn("closing dbh with active statement handles"); */
} }
imp_dbh->db = NULL; imp_dbh->db = NULL;
@ -229,8 +227,7 @@ sqlite_db_rollback(SV *dbh, imp_dbh_t *imp_dbh)
rc = sqlite3_exec(imp_dbh->db, "ROLLBACK TRANSACTION", NULL, NULL, &errmsg); rc = sqlite3_exec(imp_dbh->db, "ROLLBACK TRANSACTION", NULL, NULL, &errmsg);
if (rc != SQLITE_OK) { if (rc != SQLITE_OK) {
sqlite_error(dbh, (imp_xxh_t*)imp_dbh, rc, errmsg); sqlite_error(dbh, (imp_xxh_t*)imp_dbh, rc, errmsg);
if (errmsg) if (errmsg) sqlite3_free(errmsg);
sqlite3_free(errmsg);
return FALSE; /* -> &sv_no in SQLite.xsi */ return FALSE; /* -> &sv_no in SQLite.xsi */
} }
} }
@ -261,8 +258,7 @@ sqlite_db_commit(SV *dbh, imp_dbh_t *imp_dbh)
rc = sqlite3_exec(imp_dbh->db, "COMMIT TRANSACTION", NULL, NULL, &errmsg); rc = sqlite3_exec(imp_dbh->db, "COMMIT TRANSACTION", NULL, NULL, &errmsg);
if (rc != SQLITE_OK) { if (rc != SQLITE_OK) {
sqlite_error(dbh, (imp_xxh_t*)imp_dbh, rc, errmsg); sqlite_error(dbh, (imp_xxh_t*)imp_dbh, rc, errmsg);
if (errmsg) if (errmsg) sqlite3_free(errmsg);
sqlite3_free(errmsg);
return FALSE; /* -> &sv_no in SQLite.xsi */ return FALSE; /* -> &sv_no in SQLite.xsi */
} }
} }
@ -332,7 +328,7 @@ sqlite_st_prepare(SV *sth, imp_sth_t *imp_sth, char *statement, SV *attribs)
} }
int int
sqlite_st_execute (SV *sth, imp_sth_t *imp_sth) sqlite_st_execute(SV *sth, imp_sth_t *imp_sth)
{ {
dTHX; dTHX;
D_imp_dbh_from_sth; D_imp_dbh_from_sth;
@ -428,8 +424,7 @@ sqlite_st_execute (SV *sth, imp_sth_t *imp_sth)
rc = sqlite3_exec(imp_dbh->db, "BEGIN TRANSACTION", NULL, NULL, &errmsg); rc = sqlite3_exec(imp_dbh->db, "BEGIN TRANSACTION", NULL, NULL, &errmsg);
if (rc != SQLITE_OK) { if (rc != SQLITE_OK) {
sqlite_error(sth, (imp_xxh_t*)imp_sth, rc, errmsg); sqlite_error(sth, (imp_xxh_t*)imp_sth, rc, errmsg);
if (errmsg) if (errmsg) sqlite3_free(errmsg);
sqlite3_free(errmsg);
return -2; /* -> undef in SQLite.xsi */ return -2; /* -> undef in SQLite.xsi */
} }
} }
@ -663,13 +658,17 @@ void
sqlite_st_destroy(SV *sth, imp_sth_t *imp_sth) sqlite_st_destroy(SV *sth, imp_sth_t *imp_sth)
{ {
dTHX; dTHX;
int rc;
D_imp_dbh_from_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);
if (DBIc_ACTIVE(imp_dbh)) { if (DBIc_ACTIVE(imp_dbh)) {
/* finalize sth when active connection */ /* finalize sth when active connection */
sqlite3_finalize(imp_sth->stmt); rc = sqlite3_finalize(imp_sth->stmt);
if (rc != SQLITE_OK) {
sqlite_error(sth, (imp_xxh_t*)imp_sth, rc, (char*)sqlite3_errmsg(imp_dbh->db));
}
} }
Safefree(imp_sth->statement); Safefree(imp_sth->statement);
SvREFCNT_dec((SV*)imp_sth->params); SvREFCNT_dec((SV*)imp_sth->params);
@ -700,8 +699,7 @@ sqlite_db_STORE_attrib(SV *dbh, imp_dbh_t *imp_dbh, SV *keysv, SV *valuesv)
rc = sqlite3_exec(imp_dbh->db, "COMMIT TRANSACTION", NULL, NULL, &errmsg); rc = sqlite3_exec(imp_dbh->db, "COMMIT TRANSACTION", NULL, NULL, &errmsg);
if (rc != SQLITE_OK) { if (rc != SQLITE_OK) {
sqlite_error(dbh, (imp_xxh_t*)imp_dbh, rc, errmsg); sqlite_error(dbh, (imp_xxh_t*)imp_dbh, rc, errmsg);
if (errmsg) if (errmsg) sqlite3_free(errmsg);
sqlite3_free(errmsg);
return TRUE; /* XXX: is this correct? */ return TRUE; /* XXX: is this correct? */
} }
} }