Index: sql/connection.cc |
diff --git a/sql/connection.cc b/sql/connection.cc |
index f04eb3bd7ee3c135892fd9225043e59fdcaf6eed..b78322a3be0fb7c68a8995d74e7c2cdba812019f 100644 |
--- a/sql/connection.cc |
+++ b/sql/connection.cc |
@@ -237,7 +237,11 @@ void Connection::CloseInternal(bool forced) { |
// of the function. http://crbug.com/136655. |
AssertIOAllowed(); |
// TODO(shess): Histogram for failure. |
Scott Hess - ex-Googler
2013/07/22 17:57:40
Erp, removing this TODO.
|
- sqlite3_close(db_); |
+ int rc = sqlite3_close(db_); |
+ if (rc != SQLITE_OK) { |
+ UMA_HISTOGRAM_SPARSE_SLOWLY("Sqlite.CloseFailure", rc); |
+ DLOG(FATAL) << "sqlite3_close failed: " << GetErrorMessage(); |
+ } |
db_ = NULL; |
} |
} |
@@ -718,9 +722,13 @@ bool Connection::OpenInternal(const std::string& file_name) { |
int err = sqlite3_open(file_name.c_str(), &db_); |
if (err != SQLITE_OK) { |
+ // Extended error codes cannot be enabled until a handle is |
+ // available, fetch manually. |
+ err = sqlite3_extended_errcode(db_); |
+ |
// Histogram failures specific to initial open for debugging |
// purposes. |
- UMA_HISTOGRAM_ENUMERATION("Sqlite.OpenFailure", err & 0xff, 50); |
+ UMA_HISTOGRAM_SPARSE_SLOWLY("Sqlite.OpenFailure", err); |
OnSqliteError(err, NULL); |
Close(); |
@@ -735,6 +743,14 @@ bool Connection::OpenInternal(const std::string& file_name) { |
// statements are run. |
sqlite3_db_config(db_, SQLITE_DBCONFIG_LOOKASIDE, NULL, 0, 0); |
+ // Enable extended result codes to provide more color on I/O errors. |
+ // Not having extended result codes is not a fatal problem, as |
+ // Chromium code does not attempt to handle I/O errors anyhow. The |
+ // current implementation always returns SQLITE_OK, the DCHECK is to |
+ // quickly notify someone if SQLite changes. |
+ err = sqlite3_extended_result_codes(db_, 1); |
+ DCHECK_EQ(err, SQLITE_OK) << "Could not enable extended result codes"; |
+ |
// sqlite3_open() does not actually read the database file (unless a |
// hot journal is found). Successfully executing this pragma on an |
// existing database requires a valid header on page 1. |
@@ -743,15 +759,7 @@ bool Connection::OpenInternal(const std::string& file_name) { |
// be razed. |
err = ExecuteAndReturnErrorCode("PRAGMA auto_vacuum"); |
if (err != SQLITE_OK) |
- UMA_HISTOGRAM_ENUMERATION("Sqlite.OpenProbeFailure", err & 0xff, 50); |
- |
- // Enable extended result codes to provide more color on I/O errors. |
- // Not having extended result codes is not a fatal problem, as |
- // Chromium code does not attempt to handle I/O errors anyhow. The |
- // current implementation always returns SQLITE_OK, the DCHECK is to |
- // quickly notify someone if SQLite changes. |
- err = sqlite3_extended_result_codes(db_, 1); |
- DCHECK_EQ(err, SQLITE_OK) << "Could not enable extended result codes"; |
+ UMA_HISTOGRAM_SPARSE_SLOWLY("Sqlite.OpenProbeFailure", err); |
#if defined(OS_IOS) && defined(USE_SYSTEM_SQLITE) |
// The version of SQLite shipped with iOS doesn't enable ICU, which includes |