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 #ifndef SQL_RECOVERY_H_ | 5 #ifndef SQL_RECOVERY_H_ |
6 #define SQL_RECOVERY_H_ | 6 #define SQL_RECOVERY_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 | 157 |
158 // Attempt to recover the database by creating a new database with schema from | 158 // Attempt to recover the database by creating a new database with schema from |
159 // |db|, then copying over as much data as possible. After this call, the | 159 // |db|, then copying over as much data as possible. After this call, the |
160 // |db| handle will be poisoned (though technically remaining open) so that | 160 // |db| handle will be poisoned (though technically remaining open) so that |
161 // future calls will return errors until the handle is re-opened. | 161 // future calls will return errors until the handle is re-opened. |
162 // | 162 // |
163 // If a corrupt database contains tables without unique indices, the resulting | 163 // If a corrupt database contains tables without unique indices, the resulting |
164 // table may contain duplication. If this is not acceptable, the client | 164 // table may contain duplication. If this is not acceptable, the client |
165 // should use the manual process as described in the example at the top of the | 165 // should use the manual process as described in the example at the top of the |
166 // file, cleaning up data at the appropriate points. | 166 // file, cleaning up data at the appropriate points. |
| 167 // |
| 168 // In case of SQLITE_NOTADB, the database is deemed unrecoverable and deleted. |
167 static void RecoverDatabase(Connection* db, const base::FilePath& db_path); | 169 static void RecoverDatabase(Connection* db, const base::FilePath& db_path); |
168 | 170 |
169 // Returns true for SQLite errors which RecoverDatabase() can plausibly fix. | 171 // Returns true for SQLite errors which RecoverDatabase() can plausibly fix. |
170 // This does not guarantee that RecoverDatabase() will successfully recover | 172 // This does not guarantee that RecoverDatabase() will successfully recover |
171 // the database. | 173 // the database. |
172 static bool ShouldRecover(int extended_error); | 174 static bool ShouldRecover(int extended_error); |
173 | 175 |
174 private: | 176 private: |
175 explicit Recovery(Connection* connection); | 177 explicit Recovery(Connection* connection); |
176 | 178 |
(...skipping 15 matching lines...) Expand all Loading... |
192 | 194 |
193 Connection* db_; // Original database connection. | 195 Connection* db_; // Original database connection. |
194 Connection recover_db_; // Recovery connection. | 196 Connection recover_db_; // Recovery connection. |
195 | 197 |
196 DISALLOW_COPY_AND_ASSIGN(Recovery); | 198 DISALLOW_COPY_AND_ASSIGN(Recovery); |
197 }; | 199 }; |
198 | 200 |
199 } // namespace sql | 201 } // namespace sql |
200 | 202 |
201 #endif // SQL_RECOVERY_H_ | 203 #endif // SQL_RECOVERY_H_ |
OLD | NEW |