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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 | 233 |
234 // Turn on |SQLITE_RecoveryMode| for the handle, which allows | 234 // Turn on |SQLITE_RecoveryMode| for the handle, which allows |
235 // reading certain broken databases. | 235 // reading certain broken databases. |
236 if (!recover_db_.Execute("PRAGMA writable_schema=1")) { | 236 if (!recover_db_.Execute("PRAGMA writable_schema=1")) { |
237 RecordRecoveryEvent(RECOVERY_FAILED_WRITABLE_SCHEMA); | 237 RecordRecoveryEvent(RECOVERY_FAILED_WRITABLE_SCHEMA); |
238 return false; | 238 return false; |
239 } | 239 } |
240 | 240 |
241 if (!recover_db_.AttachDatabase(db_path, "corrupt")) { | 241 if (!recover_db_.AttachDatabase(db_path, "corrupt")) { |
242 RecordRecoveryEvent(RECOVERY_FAILED_ATTACH); | 242 RecordRecoveryEvent(RECOVERY_FAILED_ATTACH); |
| 243 UMA_HISTOGRAM_SPARSE_SLOWLY("Sqlite.RecoveryAttachError", |
| 244 recover_db_.GetErrorCode()); |
243 return false; | 245 return false; |
244 } | 246 } |
245 | 247 |
246 RecordRecoveryEvent(RECOVERY_SUCCESS_INIT); | 248 RecordRecoveryEvent(RECOVERY_SUCCESS_INIT); |
247 return true; | 249 return true; |
248 } | 250 } |
249 | 251 |
250 bool Recovery::Backup() { | 252 bool Recovery::Backup() { |
251 CHECK(db_); | 253 CHECK(db_); |
252 CHECK(recover_db_.is_open()); | 254 CHECK(recover_db_.is_open()); |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
704 // - SQLITE_READONLY - permissions could be fixed. | 706 // - SQLITE_READONLY - permissions could be fixed. |
705 // - SQLITE_IOERR - rewrite using new blocks. | 707 // - SQLITE_IOERR - rewrite using new blocks. |
706 // - SQLITE_FULL - recover in memory and rewrite subset of data. | 708 // - SQLITE_FULL - recover in memory and rewrite subset of data. |
707 | 709 |
708 default: | 710 default: |
709 return false; | 711 return false; |
710 } | 712 } |
711 } | 713 } |
712 | 714 |
713 } // namespace sql | 715 } // namespace sql |
OLD | NEW |