summaryrefslogtreecommitdiffstats
path: root/sql/recovery.h
diff options
context:
space:
mode:
authorshess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-16 01:52:04 +0000
committershess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-16 01:52:04 +0000
commit4f4076506d184e959de70c3bcb18b73c3b68e859 (patch)
treeab7bbf7a94a183616df4a669d42df8c23fe7af73 /sql/recovery.h
parent739d3030848f2cf9f9408d68122b03c813373bef (diff)
downloadchromium_src-4f4076506d184e959de70c3bcb18b73c3b68e859.zip
chromium_src-4f4076506d184e959de70c3bcb18b73c3b68e859.tar.gz
chromium_src-4f4076506d184e959de70c3bcb18b73c3b68e859.tar.bz2
[sql] Recover Favicons v5 databases, with more recovery automation.
An entirely automated recovery system runs afoul of questions about whether the corrupt database's schema can be trusted. sql::Recovery::AutoRecoverTable() uses a schema created by the caller to construct the recovery virtual table and then copies the data over. sql::Recovery::SetupMeta() and GetMetaVersionNumber() simplify accessing meta-table info in the corrupt database. sql::test::IntegrityCheck() and CorruptSizeInHeader() helpers to simplify common testing operations. Rewrite ThumbnailDatabase v6 and v7 recovery code and tests using these changes, and add a v5 recovery path. Additionally handle deprecated versions. BUG=240396,109482 Review URL: https://codereview.chromium.org/50493012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@235492 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sql/recovery.h')
-rw-r--r--sql/recovery.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/sql/recovery.h b/sql/recovery.h
index be23e97..2475b0f 100644
--- a/sql/recovery.h
+++ b/sql/recovery.h
@@ -93,6 +93,46 @@ class SQL_EXPORT Recovery {
// Handle to the temporary recovery database.
sql::Connection* db() { return &recover_db_; }
+ // Attempt to recover the named table from the corrupt database into
+ // the recovery database using a temporary recover virtual table.
+ // The virtual table schema is derived from the named table's schema
+ // in database [main]. Data is copied using INSERT OR REPLACE, so
+ // duplicates overwrite each other.
+ //
+ // |extend_columns| allows recovering tables which have excess
+ // columns relative to the target schema. The recover virtual table
+ // treats more data than specified as a sign of corruption.
+ //
+ // Returns true if all operations succeeded, with the number of rows
+ // recovered in |*rows_recovered|.
+ //
+ // NOTE(shess): Due to a flaw in the recovery virtual table, at this
+ // time this code injects the DEFAULT value of the target table in
+ // locations where the recovery table returns NULL. This is not
+ // entirely correct, because it happens both when there is a short
+ // row (correct) but also where there is an actual NULL value
+ // (incorrect).
+ //
+ // TODO(shess): Flag for INSERT OR REPLACE vs IGNORE.
+ // TODO(shess): Handle extended table names.
+ bool AutoRecoverTable(const char* table_name,
+ size_t extend_columns,
+ size_t* rows_recovered);
+
+ // Setup a recover virtual table at temp.recover_meta, reading from
+ // corrupt.meta. Returns true if created.
+ // TODO(shess): Perhaps integrate into Begin().
+ // TODO(shess): Add helpers to fetch additional items from the meta
+ // table as needed.
+ bool SetupMeta();
+
+ // Fetch the version number from temp.recover_meta. Returns false
+ // if the query fails, or if there is no version row. Otherwise
+ // returns true, with the version in |*version_number|.
+ //
+ // Only valid to call after successful SetupMeta().
+ bool GetMetaVersionNumber(int* version_number);
+
private:
explicit Recovery(Connection* connection);