OLD | NEW |
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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 | 321 |
322 // TODO(shess): Figure out a query which causes SQLite to notice | 322 // TODO(shess): Figure out a query which causes SQLite to notice |
323 // this organically. Meanwhile, just handle it manually. | 323 // this organically. Meanwhile, just handle it manually. |
324 | 324 |
325 ASSERT_TRUE(Reopen()); | 325 ASSERT_TRUE(Reopen()); |
326 | 326 |
327 // Index shows one less than originally inserted. | 327 // Index shows one less than originally inserted. |
328 const char kCountSql[] = "SELECT COUNT (*) FROM x"; | 328 const char kCountSql[] = "SELECT COUNT (*) FROM x"; |
329 EXPECT_EQ("9", ExecuteWithResults(&db(), kCountSql, "|", ",")); | 329 EXPECT_EQ("9", ExecuteWithResults(&db(), kCountSql, "|", ",")); |
330 | 330 |
331 // A full table scan shows all of the original data. | 331 // A full table scan shows all of the original data. Using column [v] to |
332 const char kDistinctSql[] = "SELECT DISTINCT COUNT (id) FROM x"; | 332 // force use of the table rather than the index. |
| 333 const char kDistinctSql[] = "SELECT DISTINCT COUNT (v) FROM x"; |
333 EXPECT_EQ("10", ExecuteWithResults(&db(), kDistinctSql, "|", ",")); | 334 EXPECT_EQ("10", ExecuteWithResults(&db(), kDistinctSql, "|", ",")); |
334 | 335 |
335 // Insert id 0 again. Since it is not in the index, the insert | 336 // Insert id 0 again. Since it is not in the index, the insert |
336 // succeeds, but results in a duplicate value in the table. | 337 // succeeds, but results in a duplicate value in the table. |
337 const char kInsertSql[] = "INSERT INTO x (id, v) VALUES (0, 100)"; | 338 const char kInsertSql[] = "INSERT INTO x (id, v) VALUES (0, 100)"; |
338 ASSERT_TRUE(db().Execute(kInsertSql)); | 339 ASSERT_TRUE(db().Execute(kInsertSql)); |
339 | 340 |
340 // Duplication is visible. | 341 // Duplication is visible. |
341 EXPECT_EQ("10", ExecuteWithResults(&db(), kCountSql, "|", ",")); | 342 EXPECT_EQ("10", ExecuteWithResults(&db(), kCountSql, "|", ",")); |
342 EXPECT_EQ("11", ExecuteWithResults(&db(), kDistinctSql, "|", ",")); | 343 EXPECT_EQ("11", ExecuteWithResults(&db(), kDistinctSql, "|", ",")); |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 EXPECT_TRUE(recovery->AutoRecoverTable("x", 0, &rows)); | 710 EXPECT_TRUE(recovery->AutoRecoverTable("x", 0, &rows)); |
710 EXPECT_EQ(43u, rows); | 711 EXPECT_EQ(43u, rows); |
711 | 712 |
712 // Successfully recovered. | 713 // Successfully recovered. |
713 EXPECT_TRUE(sql::Recovery::Recovered(recovery.Pass())); | 714 EXPECT_TRUE(sql::Recovery::Recovered(recovery.Pass())); |
714 } | 715 } |
715 } | 716 } |
716 #endif // !defined(USE_SYSTEM_SQLITE) | 717 #endif // !defined(USE_SYSTEM_SQLITE) |
717 | 718 |
718 } // namespace | 719 } // namespace |
OLD | NEW |