diff options
author | shess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-16 11:09:58 +0000 |
---|---|---|
committer | shess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-16 11:09:58 +0000 |
commit | 92cd00a38e3897077f365d222941eb97ebb9eac2 (patch) | |
tree | ff6933ca87707336026038fc23de64fed07c0bd5 /sql | |
parent | 9aadaa40cb4e67be82c18d832083c1ad699b753f (diff) | |
download | chromium_src-92cd00a38e3897077f365d222941eb97ebb9eac2.zip chromium_src-92cd00a38e3897077f365d222941eb97ebb9eac2.tar.gz chromium_src-92cd00a38e3897077f365d222941eb97ebb9eac2.tar.bz2 |
Refactor clearing thumbnail history.
Previously, ThumbnailDatabase exposed much internals knowledge. Push
most of that down into the class and remove the schema hacks which are
no longer necessary.
BUG=272519
TEST=Unit tests.
Review URL: https://chromiumcodereview.appspot.com/22898003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@217993 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sql')
-rw-r--r-- | sql/connection.cc | 23 | ||||
-rw-r--r-- | sql/connection.h | 5 |
2 files changed, 28 insertions, 0 deletions
diff --git a/sql/connection.cc b/sql/connection.cc index 3bc2545..097edd7 100644 --- a/sql/connection.cc +++ b/sql/connection.cc @@ -724,6 +724,29 @@ scoped_refptr<Connection::StatementRef> Connection::GetUntrackedStatement( return new StatementRef(NULL, stmt, true); } +std::string Connection::GetSchema() const { + // The ORDER BY should not be necessary, but relying on organic + // order for something like this is questionable. + const char* kSql = + "SELECT type, name, tbl_name, sql " + "FROM sqlite_master ORDER BY 1, 2, 3, 4"; + Statement statement(GetUntrackedStatement(kSql)); + + std::string schema; + while (statement.Step()) { + schema += statement.ColumnString(0); + schema += '|'; + schema += statement.ColumnString(1); + schema += '|'; + schema += statement.ColumnString(2); + schema += '|'; + schema += statement.ColumnString(3); + schema += '\n'; + } + + return schema; +} + bool Connection::IsSQLValid(const char* sql) { AssertIOAllowed(); if (!db_) { diff --git a/sql/connection.h b/sql/connection.h index 24f06de..7938606 100644 --- a/sql/connection.h +++ b/sql/connection.h @@ -389,6 +389,11 @@ class SQL_EXPORT Connection { // last sqlite operation. const char* GetErrorMessage() const; + // Return a reproducible representation of the schema equivalent to + // running the following statement at a sqlite3 command-line: + // SELECT type, name, tbl_name, sql FROM sqlite_master ORDER BY 1, 2, 3, 4; + std::string GetSchema() const; + private: // For recovery module. friend class Recovery; |