summaryrefslogtreecommitdiffstats
path: root/sql/connection.cc
diff options
context:
space:
mode:
authorshess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-22 12:42:42 +0000
committershess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-22 12:42:42 +0000
commit80abf155a940e0276c58e7b29f9c7d293dca4847 (patch)
tree5c698b843dd6aa6c9f7b3b19ff46a5be4ac5ff2d /sql/connection.cc
parent8812e3d07c527b8fd43e4bb27b6a4c886bb888b5 (diff)
downloadchromium_src-80abf155a940e0276c58e7b29f9c7d293dca4847.zip
chromium_src-80abf155a940e0276c58e7b29f9c7d293dca4847.tar.gz
chromium_src-80abf155a940e0276c58e7b29f9c7d293dca4847.tar.bz2
Post integrity_check data for corrupt thumbnail databases.
Analyzing the results from DatabaseErrorCallback() show a lot of SQLITE_CORRUPT opening the database and setting up the meta table. Add additional diagnostic information for these cases to direct future development, and also dial down the amount of data uploaded to allow finding other cases more easily. For SQLITE_CORRUPT and SQLITE_READONLY, only give the chance to report on first encounter. Cross-platform results are inconsistent. On OSX, almost all of the SQLITE_CORRUPT cases are in initialization, whereas on Windows there are more in code which updates the database. For these errors, it is reasonable to expect any future call to return the error again, so it is pointless to let it get multiple attempts. BUG=240396 Review URL: https://chromiumcodereview.appspot.com/15327004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@201494 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sql/connection.cc')
-rw-r--r--sql/connection.cc19
1 files changed, 19 insertions, 0 deletions
diff --git a/sql/connection.cc b/sql/connection.cc
index b3af75e..09d8195 100644
--- a/sql/connection.cc
+++ b/sql/connection.cc
@@ -13,6 +13,7 @@
#include "base/metrics/sparse_histogram.h"
#include "base/string_util.h"
#include "base/stringprintf.h"
+#include "base/strings/string_split.h"
#include "base/utf_string_conversions.h"
#include "sql/statement.h"
#include "third_party/sqlite/sqlite3.h"
@@ -766,4 +767,22 @@ int Connection::OnSqliteError(int err, sql::Statement *stmt) {
return err;
}
+// TODO(shess): Allow specifying integrity_check versus quick_check.
+// TODO(shess): Allow specifying maximum results (default 100 lines).
+bool Connection::IntegrityCheck(std::vector<std::string>* messages) {
+ const char kSql[] = "PRAGMA integrity_check";
+ sql::Statement stmt(GetUniqueStatement(kSql));
+
+ messages->clear();
+
+ // The pragma appears to return all results (up to 100 by default)
+ // as a single string. This doesn't appear to be an API contract,
+ // it could return separate lines, so loop _and_ split.
+ while (stmt.Step()) {
+ std::string result(stmt.ColumnString(0));
+ base::SplitString(result, '\n', messages);
+ }
+ return stmt.Succeeded();
+}
+
} // namespace sql