diff options
author | shess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-10 00:55:00 +0000 |
---|---|---|
committer | shess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-10 00:55:00 +0000 |
commit | 473ad797b569c1ba5053f7a140af367aee4dcaca (patch) | |
tree | 4eaa95ee3af49da41002b0cd41deb0104e076e80 /sql | |
parent | 8392ccddddf7f355d57871a5e9af37750f7139f8 (diff) | |
download | chromium_src-473ad797b569c1ba5053f7a140af367aee4dcaca.zip chromium_src-473ad797b569c1ba5053f7a140af367aee4dcaca.tar.gz chromium_src-473ad797b569c1ba5053f7a140af367aee4dcaca.tar.bz2 |
Handle cookie-file corruption found during open.
KillDatabaseErrorDelegate cannot Raze() if the corruption is found
while opening the databse, because by the time the callback happens
the database has been closed. Add support for setting a flag for the
database-opening code to check.
Additionally, errors detected when executing or preparing statements
were not forwarded to the error delegate, which could let them sneak
by without notice.
BUG=159490
Review URL: https://chromiumcodereview.appspot.com/11358170
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@167023 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sql')
-rw-r--r-- | sql/connection.cc | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/sql/connection.cc b/sql/connection.cc index 93d0695a..1de9fc5 100644 --- a/sql/connection.cc +++ b/sql/connection.cc @@ -368,6 +368,9 @@ int Connection::ExecuteAndReturnErrorCode(const char* sql) { bool Connection::Execute(const char* sql) { int error = ExecuteAndReturnErrorCode(sql); + if (error != SQLITE_OK) + error = OnSqliteError(error, NULL); + // This needs to be a FATAL log because the error case of arriving here is // that there's a malformed SQL statement. This can arise in development if // a change alters the schema but not all queries adjust. @@ -417,9 +420,13 @@ scoped_refptr<Connection::StatementRef> Connection::GetUniqueStatement( return new StatementRef(); // Return inactive statement. sqlite3_stmt* stmt = NULL; - if (sqlite3_prepare_v2(db_, sql, -1, &stmt, NULL) != SQLITE_OK) { + int rc = sqlite3_prepare_v2(db_, sql, -1, &stmt, NULL); + if (rc != SQLITE_OK) { // This is evidence of a syntax error in the incoming SQL. DLOG(FATAL) << "SQL compile error " << GetErrorMessage(); + + // It could also be database corruption. + OnSqliteError(rc, NULL); return new StatementRef(); } return new StatementRef(this, stmt); |