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

Side by Side Diff: sql/recovery_unittest.cc

Issue 1665913003: [sql] Use IGNORE conflict resolution in recovery. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@zzsql_recover_autorecover_review
Patch Set: Created 4 years, 10 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 unified diff | Download patch
« sql/recovery.cc ('K') | « sql/recovery.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "sql/recovery.h" 5 #include "sql/recovery.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 364
365 // Database handle has been poisoned. 365 // Database handle has been poisoned.
366 EXPECT_FALSE(db().IsSQLValid(kTrivialSql)); 366 EXPECT_FALSE(db().IsSQLValid(kTrivialSql));
367 367
368 ASSERT_TRUE(Reopen()); 368 ASSERT_TRUE(Reopen());
369 369
370 // The recovered table has consistency between the index and the table. 370 // The recovered table has consistency between the index and the table.
371 EXPECT_EQ("10", ExecuteWithResults(&db(), kCountSql, "|", ",")); 371 EXPECT_EQ("10", ExecuteWithResults(&db(), kCountSql, "|", ","));
372 EXPECT_EQ("10", ExecuteWithResults(&db(), kDistinctSql, "|", ",")); 372 EXPECT_EQ("10", ExecuteWithResults(&db(), kDistinctSql, "|", ","));
373 373
374 // The expected value was retained. 374 // Only one of the values is retained.
375 const char kSelectSql[] = "SELECT v FROM x WHERE id = 0"; 375 const char kSelectSql[] = "SELECT v FROM x WHERE id = 0";
376 EXPECT_EQ("100", ExecuteWithResults(&db(), kSelectSql, "|", ",")); 376 const std::string results = ExecuteWithResults(&db(), kSelectSql, "|", ",");
377 EXPECT_TRUE(results=="100" || results=="0") << "Actual results: " << results;
Scott Hess - ex-Googler 2016/02/03 22:37:20 REPLACE retained the last version encountered, IGN
377 } 378 }
378 379
379 TEST_F(SQLRecoveryTest, Meta) { 380 TEST_F(SQLRecoveryTest, Meta) {
380 const int kVersion = 3; 381 const int kVersion = 3;
381 const int kCompatibleVersion = 2; 382 const int kCompatibleVersion = 2;
382 383
383 { 384 {
384 sql::MetaTable meta; 385 sql::MetaTable meta;
385 EXPECT_TRUE(meta.Init(&db(), kVersion, kCompatibleVersion)); 386 EXPECT_TRUE(meta.Init(&db(), kVersion, kCompatibleVersion));
386 EXPECT_EQ(kVersion, meta.GetVersionNumber()); 387 EXPECT_EQ(kVersion, meta.GetVersionNumber());
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
744 scoped_ptr<sql::Recovery> recovery = sql::Recovery::Begin(&db(), db_path()); 745 scoped_ptr<sql::Recovery> recovery = sql::Recovery::Begin(&db(), db_path());
745 ASSERT_TRUE(recovery.get()); 746 ASSERT_TRUE(recovery.get());
746 747
747 // In the current implementation, the PRAGMA successfully runs with no result 748 // In the current implementation, the PRAGMA successfully runs with no result
748 // rows. Running with a single result of |0| is also acceptable. 749 // rows. Running with a single result of |0| is also acceptable.
749 sql::Statement s(recovery->db()->GetUniqueStatement("PRAGMA mmap_size")); 750 sql::Statement s(recovery->db()->GetUniqueStatement("PRAGMA mmap_size"));
750 EXPECT_TRUE(!s.Step() || !s.ColumnInt64(0)); 751 EXPECT_TRUE(!s.Step() || !s.ColumnInt64(0));
751 } 752 }
752 753
753 } // namespace 754 } // namespace
OLDNEW
« sql/recovery.cc ('K') | « sql/recovery.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698