summaryrefslogtreecommitdiffstats
path: root/sql/connection_unittest.cc
diff options
context:
space:
mode:
authorkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-18 04:18:47 +0000
committerkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-18 04:18:47 +0000
commita8848a7685d5f673b30bc1f5336e6f9eba44fc41 (patch)
treedc1888152353c034340059cb229810ba3f4aab54 /sql/connection_unittest.cc
parent2a4ee00d34865b2486e84eaf001c0e18358c901d (diff)
downloadchromium_src-a8848a7685d5f673b30bc1f5336e6f9eba44fc41.zip
chromium_src-a8848a7685d5f673b30bc1f5336e6f9eba44fc41.tar.gz
chromium_src-a8848a7685d5f673b30bc1f5336e6f9eba44fc41.tar.bz2
Revert 235595 "Revert 235492 "[sql] Recover Favicons v5 database..."
> Revert 235492 "[sql] Recover Favicons v5 databases, with more re..." > > Speculative revert to find the cause for Mac size regression > (will revert this revert later) > > > [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 > > TBR=shess@chromium.org > > Review URL: https://codereview.chromium.org/74933002 TBR=kinuko@chromium.org Review URL: https://codereview.chromium.org/74953002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@235604 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sql/connection_unittest.cc')
-rw-r--r--sql/connection_unittest.cc23
1 files changed, 3 insertions, 20 deletions
diff --git a/sql/connection_unittest.cc b/sql/connection_unittest.cc
index 445db34..5ffc26a 100644
--- a/sql/connection_unittest.cc
+++ b/sql/connection_unittest.cc
@@ -11,6 +11,7 @@
#include "sql/statement.h"
#include "sql/test/error_callback_support.h"
#include "sql/test/scoped_error_ignorer.h"
+#include "sql/test/test_helpers.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/sqlite/sqlite3.h"
@@ -502,32 +503,14 @@ TEST_F(SQLConnectionTest, RazeNOTADB2) {
// essential for cases where the Open() can fail entirely, so the
// Raze() cannot happen later. Additionally test that when the
// callback does this during Open(), the open is retried and succeeds.
-//
-// Most corruptions seen in the wild seem to happen when two pages in
-// the database were not written transactionally (the transaction
-// changed both, but one wasn't successfully written for some reason).
-// A special case of that is when the header indicates that the
-// database contains more pages than are in the file. This breaks
-// things at a very basic level, verify that Raze() can handle it.
TEST_F(SQLConnectionTest, RazeCallbackReopen) {
const char* kCreateSql = "CREATE TABLE foo (id INTEGER PRIMARY KEY, value)";
ASSERT_TRUE(db().Execute(kCreateSql));
ASSERT_EQ(1, SqliteMasterCount(&db()));
- int page_size = 0;
- {
- sql::Statement s(db().GetUniqueStatement("PRAGMA page_size"));
- ASSERT_TRUE(s.Step());
- page_size = s.ColumnInt(0);
- }
db().Close();
- // Trim a single page from the end of the file.
- {
- file_util::ScopedFILE file(file_util::OpenFile(db_path(), "rb+"));
- ASSERT_TRUE(file.get() != NULL);
- ASSERT_EQ(0, fseek(file.get(), -page_size, SEEK_END));
- ASSERT_TRUE(file_util::TruncateFile(file.get()));
- }
+ // Corrupt the database so that nothing works, including PRAGMAs.
+ ASSERT_TRUE(sql::test::CorruptSizeInHeader(db_path()));
// Open() will succeed, even though the PRAGMA calls within will
// fail with SQLITE_CORRUPT, as will this PRAGMA.