Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Unified Diff: sql/connection.cc

Issue 24638002: [sql] Log tag with sqlite errors. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Log the sql statement, too. Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sql/connection.h ('k') | sql/statement.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sql/connection.cc
diff --git a/sql/connection.cc b/sql/connection.cc
index 097edd7a1ea2f57350869b2c4eaedb12db6b6bc1..14071e220c547c3f9c9567ec038db0c4b1e518f5 100644
--- a/sql/connection.cc
+++ b/sql/connection.cc
@@ -641,7 +641,7 @@ bool Connection::Execute(const char* sql) {
int error = ExecuteAndReturnErrorCode(sql);
if (error != SQLITE_OK)
- error = OnSqliteError(error, NULL);
+ error = OnSqliteError(error, NULL, sql);
// 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
@@ -702,7 +702,7 @@ scoped_refptr<Connection::StatementRef> Connection::GetUniqueStatement(
DLOG(FATAL) << "SQL compile error " << GetErrorMessage();
// It could also be database corruption.
- OnSqliteError(rc, NULL);
+ OnSqliteError(rc, NULL, sql);
return new StatementRef(NULL, NULL, false);
}
return new StatementRef(this, stmt, true);
@@ -864,7 +864,7 @@ bool Connection::OpenInternal(const std::string& file_name,
// purposes.
UMA_HISTOGRAM_SPARSE_SLOWLY("Sqlite.OpenFailure", err);
- OnSqliteError(err, NULL);
+ OnSqliteError(err, NULL, "-- sqlite3_open()");
bool was_poisoned = poisoned_;
Close();
@@ -1022,15 +1022,21 @@ void Connection::AddTaggedHistogram(const std::string& name,
histogram->Add(sample);
}
-int Connection::OnSqliteError(int err, sql::Statement *stmt) {
+int Connection::OnSqliteError(int err, sql::Statement *stmt, const char* sql) {
UMA_HISTOGRAM_SPARSE_SLOWLY("Sqlite.Error", err);
AddTaggedHistogram("Sqlite.Error", err);
// Always log the error.
- LOG(ERROR) << "sqlite error " << err
+ LOG(ERROR) << histogram_tag_ << " sqlite error " << err
<< ", errno " << GetLastErrno()
<< ": " << GetErrorMessage();
+ // Also log the relevant sql statement, if possible.
+ if (!sql && stmt)
+ sql = stmt->GetSQLStatement();
+ if (sql)
+ LOG(ERROR) << "sql: " << sql;
Greg Spencer (Chromium) 2013/09/25 20:01:18 nits: You might want to also output "sqlite error"
Scott Hess - ex-Googler 2013/09/25 20:22:36 I'm moving it up to the same line, just to be safe
+
if (!error_callback_.is_null()) {
// Fire from a copy of the callback in case of reentry into
// re/set_error_callback().
« no previous file with comments | « sql/connection.h ('k') | sql/statement.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698