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

Unified Diff: sql/test/test_helpers.h

Issue 50493012: [sql] Recover Favicons v5 databases, with more recovery automation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase, merge rows-recovered support. Created 7 years, 1 month 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/recovery_unittest.cc ('k') | sql/test/test_helpers.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sql/test/test_helpers.h
diff --git a/sql/test/test_helpers.h b/sql/test/test_helpers.h
index 330f59a25f2e7438320c37d7c93ce6569b5965db..b9d5e9b980ae12769040a8497ba99f489ea8010c 100644
--- a/sql/test/test_helpers.h
+++ b/sql/test/test_helpers.h
@@ -5,6 +5,8 @@
#ifndef SQL_TEST_TEST_HELPERS_H_
#define SQL_TEST_TEST_HELPERS_H_
+#include <string>
+
#include "base/basictypes.h"
#include "base/compiler_specific.h"
@@ -21,6 +23,16 @@ class Connection;
namespace sql {
namespace test {
+// SQLite stores the database size in the header, and if the actual
+// OS-derived size is smaller, the database is considered corrupt.
+// [This case is actually a common form of corruption in the wild.]
+// This helper sets the in-header size to one page larger than the
+// actual file size. The resulting file will return SQLITE_CORRUPT
+// for most operations unless PRAGMA writable_schema is turned ON.
+//
+// Returns false if any error occurs accessing the file.
+bool CorruptSizeInHeader(const base::FilePath& db_path) WARN_UNUSED_RESULT;
+
// Return the number of tables in sqlite_master.
size_t CountSQLTables(sql::Connection* db) WARN_UNUSED_RESULT;
@@ -43,6 +55,11 @@ bool CountTableRows(sql::Connection* db, const char* table, size_t* count);
bool CreateDatabaseFromSQL(const base::FilePath& db_path,
const base::FilePath& sql_path) WARN_UNUSED_RESULT;
+// Return the results of running "PRAGMA integrity_check" on |db|.
+// TODO(shess): sql::Connection::IntegrityCheck() is basically the
+// same, but not as convenient for testing. Maybe combine.
+std::string IntegrityCheck(sql::Connection* db) WARN_UNUSED_RESULT;
+
} // namespace test
} // namespace sql
« no previous file with comments | « sql/recovery_unittest.cc ('k') | sql/test/test_helpers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698