| 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 "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 // NOTE(shess): Only call this when adding recovery support. In the | 108 // NOTE(shess): Only call this when adding recovery support. In the |
| 109 // steady state, all databases should progress to recovered or razed. | 109 // steady state, all databases should progress to recovered or razed. |
| 110 static void Rollback(scoped_ptr<Recovery> r); | 110 static void Rollback(scoped_ptr<Recovery> r); |
| 111 | 111 |
| 112 // Handle to the temporary recovery database. | 112 // Handle to the temporary recovery database. |
| 113 sql::Connection* db() { return &recover_db_; } | 113 sql::Connection* db() { return &recover_db_; } |
| 114 | 114 |
| 115 // Attempt to recover the named table from the corrupt database into | 115 // Attempt to recover the named table from the corrupt database into |
| 116 // the recovery database using a temporary recover virtual table. | 116 // the recovery database using a temporary recover virtual table. |
| 117 // The virtual table schema is derived from the named table's schema | 117 // The virtual table schema is derived from the named table's schema |
| 118 // in database [main]. Data is copied using INSERT OR REPLACE, so | 118 // in database [main]. Data is copied using INSERT OR IGNORE, so |
| 119 // duplicates overwrite each other. | 119 // duplicates are dropped. |
| 120 // | 120 // |
| 121 // If the source table has fewer columns than the target, the target | 121 // If the source table has fewer columns than the target, the target |
| 122 // DEFAULT value will be used for those columns. | 122 // DEFAULT value will be used for those columns. |
| 123 // | 123 // |
| 124 // Returns true if all operations succeeded, with the number of rows | 124 // Returns true if all operations succeeded, with the number of rows |
| 125 // recovered in |*rows_recovered|. | 125 // recovered in |*rows_recovered|. |
| 126 // | 126 // |
| 127 // NOTE(shess): Due to a flaw in the recovery virtual table, at this | 127 // NOTE(shess): Due to a flaw in the recovery virtual table, at this |
| 128 // time this code injects the DEFAULT value of the target table in | 128 // time this code injects the DEFAULT value of the target table in |
| 129 // locations where the recovery table returns NULL. This is not | 129 // locations where the recovery table returns NULL. This is not |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 | 170 |
| 171 Connection* db_; // Original database connection. | 171 Connection* db_; // Original database connection. |
| 172 Connection recover_db_; // Recovery connection. | 172 Connection recover_db_; // Recovery connection. |
| 173 | 173 |
| 174 DISALLOW_COPY_AND_ASSIGN(Recovery); | 174 DISALLOW_COPY_AND_ASSIGN(Recovery); |
| 175 }; | 175 }; |
| 176 | 176 |
| 177 } // namespace sql | 177 } // namespace sql |
| 178 | 178 |
| 179 #endif // SQL_RECOVERY_H_ | 179 #endif // SQL_RECOVERY_H_ |
| OLD | NEW |