diff options
author | Torne (Richard Coles) <torne@google.com> | 2013-08-23 16:39:15 +0100 |
---|---|---|
committer | Torne (Richard Coles) <torne@google.com> | 2013-08-23 16:39:15 +0100 |
commit | 3551c9c881056c480085172ff9840cab31610854 (patch) | |
tree | 23660320f5f4c279966609cf9da7491b96d10ca8 /sql | |
parent | 4e9d9adbbb6cf287125ca44a0823791a570472f5 (diff) | |
download | chromium_org-3551c9c881056c480085172ff9840cab31610854.tar.gz |
Merge from Chromium at DEPS revision r219274
This commit was generated by merge_to_master.py.
Change-Id: Ibb7f41396cadf4071e89153e1913c986d126f65d
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 3bc2545854..097edd7a1e 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 24f06deaed..7938606422 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; |