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

Unified Diff: sql/recovery_unittest.cc

Issue 355093003: [sql] Test recovery of corrupt golden file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add sql.isolate Created 6 years, 5 months 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/BUILD.gn ('k') | sql/sql.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sql/recovery_unittest.cc
diff --git a/sql/recovery_unittest.cc b/sql/recovery_unittest.cc
index ce3884bbc08013e3936a6784d606369c72400bce..201966d0811eed7a999ccb2af1615d7dbbf19f3c 100644
--- a/sql/recovery_unittest.cc
+++ b/sql/recovery_unittest.cc
@@ -5,13 +5,16 @@
#include <string>
#include "base/bind.h"
+#include "base/file_util.h"
#include "base/files/file_path.h"
#include "base/files/scoped_temp_dir.h"
+#include "base/path_service.h"
#include "base/strings/string_number_conversions.h"
#include "sql/connection.h"
#include "sql/meta_table.h"
#include "sql/recovery.h"
#include "sql/statement.h"
+#include "sql/test/paths.h"
#include "sql/test/scoped_error_ignorer.h"
#include "sql/test/test_helpers.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -683,6 +686,35 @@ TEST_F(SQLRecoveryTest, AutoRecoverTableExtendColumns) {
ASSERT_EQ(orig_schema, GetSchema(&db()));
ASSERT_EQ(orig_data, ExecuteWithResults(&db(), kXSql, "|", "\n"));
}
+
+// Recover a golden file where an interior page has been manually modified so
+// that the number of cells is greater than will fit on a single page. This
+// case happened in <http://crbug.com/387868>.
+TEST_F(SQLRecoveryTest, Bug387868) {
+ base::FilePath golden_path;
+ ASSERT_TRUE(PathService::Get(sql::test::DIR_TEST_DATA, &golden_path));
+ golden_path = golden_path.AppendASCII("recovery_387868");
+ db().Close();
+ ASSERT_TRUE(base::CopyFile(golden_path, db_path()));
+ ASSERT_TRUE(Reopen());
+
+ {
+ scoped_ptr<sql::Recovery> recovery = sql::Recovery::Begin(&db(), db_path());
+ ASSERT_TRUE(recovery.get());
+
+ // Create the new version of the table.
+ const char kCreateSql[] =
+ "CREATE TABLE x (id INTEGER PRIMARY KEY, t0 TEXT)";
+ ASSERT_TRUE(recovery->db()->Execute(kCreateSql));
+
+ size_t rows = 0;
+ EXPECT_TRUE(recovery->AutoRecoverTable("x", 0, &rows));
+ EXPECT_EQ(43u, rows);
+
+ // Successfully recovered.
+ EXPECT_TRUE(sql::Recovery::Recovered(recovery.Pass()));
+ }
+}
#endif // !defined(USE_SYSTEM_SQLITE)
} // namespace
« no previous file with comments | « sql/BUILD.gn ('k') | sql/sql.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698