summaryrefslogtreecommitdiffstats
path: root/sql/test/test_helpers.h
diff options
context:
space:
mode:
authorshess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-16 01:52:04 +0000
committershess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-16 01:52:04 +0000
commit4f4076506d184e959de70c3bcb18b73c3b68e859 (patch)
treeab7bbf7a94a183616df4a669d42df8c23fe7af73 /sql/test/test_helpers.h
parent739d3030848f2cf9f9408d68122b03c813373bef (diff)
downloadchromium_src-4f4076506d184e959de70c3bcb18b73c3b68e859.zip
chromium_src-4f4076506d184e959de70c3bcb18b73c3b68e859.tar.gz
chromium_src-4f4076506d184e959de70c3bcb18b73c3b68e859.tar.bz2
[sql] Recover Favicons v5 databases, with more recovery automation.
An entirely automated recovery system runs afoul of questions about whether the corrupt database's schema can be trusted. sql::Recovery::AutoRecoverTable() uses a schema created by the caller to construct the recovery virtual table and then copies the data over. sql::Recovery::SetupMeta() and GetMetaVersionNumber() simplify accessing meta-table info in the corrupt database. sql::test::IntegrityCheck() and CorruptSizeInHeader() helpers to simplify common testing operations. Rewrite ThumbnailDatabase v6 and v7 recovery code and tests using these changes, and add a v5 recovery path. Additionally handle deprecated versions. BUG=240396,109482 Review URL: https://codereview.chromium.org/50493012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@235492 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sql/test/test_helpers.h')
-rw-r--r--sql/test/test_helpers.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/sql/test/test_helpers.h b/sql/test/test_helpers.h
index 330f59a..b9d5e9b 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