From d6af16bea5b5daa05cbef2e978c83742ae587776 Mon Sep 17 00:00:00 2001 From: Kenichi Ishigaki Date: Tue, 6 Oct 2009 04:29:05 +0000 Subject: [PATCH] DBD-SQLite: Tweaked not to hide a real error by a "not an error" issued by another sqlite3 function between the failed sqlite3 function and the sqlite_error to report. Note that this change makes some failures issue two relevant errors at a time. --- Changes | 16 ++++++++++++---- dbdimp.c | 20 +++++++++++++------- t/07_error.t | 2 +- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/Changes b/Changes index 647771e..759c74e 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,14 @@ Changes for Perl extension DBD-SQLite 1.26_04 to be released + *** CHANGES THAT MAY POSSIBLY BREAK YOUR OLD APPLICATIONS *** + - Resolved #49716: Fixed $dbh->column_info to work according to + the spec in DBI and added support for attached databases. (VLYON) + - Tweaked not to hide a real error by a "not an error" issued + by another sqlite3 function between the failed sqlite3 function + and the sqlite_error to report. Note that this change makes + some failures issue two relevant errors at a time. (ISHIGAKI) + - Updated to SQLite 3.6.18 (DUNCAND) - Resolved #48393: previous effort was not enough; BegunWork should also be handled properly (ISHIGAKI) @@ -9,8 +17,6 @@ Changes for Perl extension DBD-SQLite under a very, very slow (virtual) machine. (ISHIGAKI) - Added a code to look for a compiler from Module::Install::Can. (ISHIGAKI) - - Resolved #49716: Fixed $dbh->column_info to work according to - the spec in DBI and added support for attached databases. (VLYON) - Added documentation and an 'Escape' attribute for $sth->table_info. (VLYON) - Fixed $sth->primary_key_info to work according to the spec in DBI @@ -40,6 +46,10 @@ Changes for Perl extension DBD-SQLite (incorrect) PREREQ_PM values by ExtUtils::MakeMaker (ADAMK) 1.26_02 Fri 19 Jun 2009 + *** CHANGES THAT MAY POSSIBLY BREAK YOUR OLD APPLICATIONS *** + - Resolved #46831: table_info schema is incorrect and doesn't + work with attached databases (VLYON/ISHIGAKI) + - Updated to SQLite 3.6.15 (DUNCAND) - Resolved #44882: Use of $h->func() should be deprecated and replaced with calls to driver-private 'installed methods' @@ -49,8 +59,6 @@ Changes for Perl extension DBD-SQLite - Now private methods/functions return true after successful calls (#44871) (ISHIGAKI) - Removed all of the "croak"s (#44871) (ISHIGAKI) - - Resolved #46831: table_info schema is incorrect and doesn't - work with attached databases (VLYON/ISHIGAKI) 1.26_01 Tue 5 May 2009 - Added ORDINAL_POSITION support for $dbh->column_info (ADAMK) diff --git a/dbdimp.c b/dbdimp.c index 65dace6..f10ffeb 100644 --- a/dbdimp.c +++ b/dbdimp.c @@ -296,10 +296,12 @@ sqlite_st_prepare (SV *sth, imp_sth_t *imp_sth, if ((retval = sqlite3_prepare_v2(imp_dbh->db, statement, -1, &(imp_sth->stmt), &extra)) != SQLITE_OK) { - if (imp_sth->stmt) { - sqlite3_finalize(imp_sth->stmt); - } sqlite_error(sth, (imp_xxh_t*)imp_sth, retval, (char*)sqlite3_errmsg(imp_dbh->db)); + if (imp_sth->stmt) { + if ((retval = sqlite3_finalize(imp_sth->stmt)) != SQLITE_OK) { + sqlite_error(sth, (imp_xxh_t*)imp_sth, retval, (char*)sqlite3_errmsg(imp_dbh->db)); + } + } return FALSE; /* -> undef in lib/DBD/SQLite.pm */ } @@ -436,8 +438,10 @@ sqlite_st_execute (SV *sth, imp_sth_t *imp_sth) if (imp_sth->retval == SQLITE_ROW) { continue; } - sqlite3_reset(imp_sth->stmt); sqlite_error(sth, (imp_xxh_t*)imp_sth, imp_sth->retval, (char*)sqlite3_errmsg(imp_dbh->db)); + if (sqlite3_reset(imp_sth->stmt) != SQLITE_OK) { + sqlite_error(sth, (imp_xxh_t*)imp_sth, imp_sth->retval, (char*)sqlite3_errmsg(imp_dbh->db)); + } return -5; /* -> undef in SQLite.xsi */ } /* warn("Finalize\n"); */ @@ -455,9 +459,11 @@ sqlite_st_execute (SV *sth, imp_sth_t *imp_sth) case SQLITE_DONE: DBIc_ACTIVE_on(imp_sth); sqlite_trace(sth, (imp_xxh_t*)imp_sth, 5, "exec ok - %d rows, %d cols\n", imp_sth->nrow, DBIc_NUM_FIELDS(imp_sth)); return 0; /* -> '0E0' in SQLite.xsi */ - default: sqlite3_reset(imp_sth->stmt); + default: sqlite_error(sth, (imp_xxh_t*)imp_sth, imp_sth->retval, (char*)sqlite3_errmsg(imp_dbh->db)); + if (sqlite3_reset(imp_sth->stmt) != SQLITE_OK) { + sqlite_error(sth, (imp_xxh_t*)imp_sth, imp_sth->retval, (char*)sqlite3_errmsg(imp_dbh->db)); + } imp_sth->stmt = NULL; - sqlite_error(sth, (imp_xxh_t*)imp_sth, imp_sth->retval, (char*)sqlite3_errmsg(imp_dbh->db)); return -6; /* -> undef in SQLite.xsi */ } } @@ -549,8 +555,8 @@ sqlite_st_fetch (SV *sth, imp_sth_t *imp_sth) if (imp_sth->retval != SQLITE_ROW) { /* error */ - sqlite_st_finish(sth, imp_sth); sqlite_error(sth, (imp_xxh_t*)imp_sth, imp_sth->retval, (char*)sqlite3_errmsg(imp_dbh->db)); + sqlite_st_finish(sth, imp_sth); return Nullav; /* -> undef in SQLite.xsi */ } diff --git a/t/07_error.t b/t/07_error.t index d69c2e5..68ea9ca 100644 --- a/t/07_error.t +++ b/t/07_error.t @@ -28,4 +28,4 @@ eval { }; ok($@, 'Statement 2 generated an error'); is( $DBI::err, 19, '$DBI::err ok' ); -is( $DBI::errstr, 'column a is not unique', '$DBI::errstr ok' ); +like( $DBI::errstr, qr/column a is not unique/, '$DBI::errstr ok' );