Index: trunk/src/sql/test/test_helpers.h |
=================================================================== |
--- trunk/src/sql/test/test_helpers.h (revision 235603) |
+++ trunk/src/sql/test/test_helpers.h (working copy) |
@@ -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 @@ |
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 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 |