| 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 "sql/recovery.h" | 5 #include "sql/recovery.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/format_macros.h" | 8 #include "base/format_macros.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 // execute in case of conflicts. | 449 // execute in case of conflicts. |
| 450 for (size_t i = 0; i < extend_columns; ++i) { | 450 for (size_t i = 0; i < extend_columns; ++i) { |
| 451 create_column_decls.push_back( | 451 create_column_decls.push_back( |
| 452 base::StringPrintf("ignore%" PRIuS " ANY", i)); | 452 base::StringPrintf("ignore%" PRIuS " ANY", i)); |
| 453 } | 453 } |
| 454 | 454 |
| 455 std::string recover_create(base::StringPrintf( | 455 std::string recover_create(base::StringPrintf( |
| 456 "CREATE VIRTUAL TABLE temp.recover_%s USING recover(corrupt.%s, %s)", | 456 "CREATE VIRTUAL TABLE temp.recover_%s USING recover(corrupt.%s, %s)", |
| 457 table_name, | 457 table_name, |
| 458 table_name, | 458 table_name, |
| 459 base::JoinString(create_column_decls, ",").c_str())); | 459 JoinString(create_column_decls, ',').c_str())); |
| 460 | 460 |
| 461 std::string recover_insert(base::StringPrintf( | 461 std::string recover_insert(base::StringPrintf( |
| 462 "INSERT OR REPLACE INTO main.%s SELECT %s FROM temp.recover_%s", | 462 "INSERT OR REPLACE INTO main.%s SELECT %s FROM temp.recover_%s", |
| 463 table_name, | 463 table_name, |
| 464 base::JoinString(insert_columns, ",").c_str(), | 464 JoinString(insert_columns, ',').c_str(), |
| 465 table_name)); | 465 table_name)); |
| 466 | 466 |
| 467 std::string recover_drop(base::StringPrintf( | 467 std::string recover_drop(base::StringPrintf( |
| 468 "DROP TABLE temp.recover_%s", table_name)); | 468 "DROP TABLE temp.recover_%s", table_name)); |
| 469 | 469 |
| 470 if (!db()->Execute(recover_create.c_str())) { | 470 if (!db()->Execute(recover_create.c_str())) { |
| 471 RecordRecoveryEvent(RECOVERY_FAILED_AUTORECOVER_CREATE); | 471 RecordRecoveryEvent(RECOVERY_FAILED_AUTORECOVER_CREATE); |
| 472 return false; | 472 return false; |
| 473 } | 473 } |
| 474 | 474 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 } | 522 } |
| 523 return false; | 523 return false; |
| 524 } | 524 } |
| 525 | 525 |
| 526 RecordRecoveryEvent(RECOVERY_SUCCESS_META_VERSION); | 526 RecordRecoveryEvent(RECOVERY_SUCCESS_META_VERSION); |
| 527 *version = recovery_version.ColumnInt(0); | 527 *version = recovery_version.ColumnInt(0); |
| 528 return true; | 528 return true; |
| 529 } | 529 } |
| 530 | 530 |
| 531 } // namespace sql | 531 } // namespace sql |
| OLD | NEW |