summaryrefslogtreecommitdiffstats
path: root/sql/test
diff options
context:
space:
mode:
authorshess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-08 02:19:17 +0000
committershess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-08 02:19:17 +0000
commitfe4e3de5276edc05c36979ee5383cddb425e35f1 (patch)
treef20c3e55a6f935b0b35fffe4cbaffe6eb38387b8 /sql/test
parentf8feb29903155d73053e7ea5cca63c523c2bd215 (diff)
downloadchromium_src-fe4e3de5276edc05c36979ee5383cddb425e35f1.zip
chromium_src-fe4e3de5276edc05c36979ee5383cddb425e35f1.tar.gz
chromium_src-fe4e3de5276edc05c36979ee5383cddb425e35f1.tar.bz2
Deprecate old Favicons database versions.
Histograms show a non-zero number of users with very old databases at startup. These old databases likely result from some sort of corruption or filesystem problem, and are unlikely to spontaneously progress forward. Since the number of databases involved is very low (<.03% of users), just delete them in hopes that that allows forward progress. Arbitrarily set a 2-year deprecation deadline for this database. This is a few weeks early, as version 5 landed on 2011-10-12. BUG=240396 Review URL: https://codereview.chromium.org/24443002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@227433 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sql/test')
-rw-r--r--sql/test/test_helpers.cc14
-rw-r--r--sql/test/test_helpers.h4
2 files changed, 18 insertions, 0 deletions
diff --git a/sql/test/test_helpers.cc b/sql/test/test_helpers.cc
index 607f146..20471dc 100644
--- a/sql/test/test_helpers.cc
+++ b/sql/test/test_helpers.cc
@@ -55,6 +55,20 @@ size_t CountTableColumns(sql::Connection* db, const char* table) {
return rows;
}
+bool CountTableRows(sql::Connection* db, const char* table, size_t* count) {
+ // TODO(shess): Table should probably be quoted with [] or "". See
+ // http://www.sqlite.org/lang_keywords.html . Meanwhile, odd names
+ // will throw an error.
+ std::string sql = "SELECT COUNT(*) FROM ";
+ sql += table;
+ sql::Statement s(db->GetUniqueStatement(sql.c_str()));
+ if (!s.Step())
+ return false;
+
+ *count = s.ColumnInt64(0);
+ return true;
+}
+
bool CreateDatabaseFromSQL(const base::FilePath& db_path,
const base::FilePath& sql_path) {
if (base::PathExists(db_path) || !base::PathExists(sql_path))
diff --git a/sql/test/test_helpers.h b/sql/test/test_helpers.h
index 2e01ecd..330f59a 100644
--- a/sql/test/test_helpers.h
+++ b/sql/test/test_helpers.h
@@ -32,6 +32,10 @@ size_t CountSQLIndices(sql::Connection* db) WARN_UNUSED_RESULT;
size_t CountTableColumns(sql::Connection* db, const char* table)
WARN_UNUSED_RESULT;
+// Sets |*count| to the number of rows in |table|. Returns false in
+// case of error, such as the table not existing.
+bool CountTableRows(sql::Connection* db, const char* table, size_t* count);
+
// Creates a SQLite database at |db_path| from the sqlite .dump output
// at |sql_path|. Returns false if |db_path| already exists, or if
// sql_path does not exist or cannot be read, or if there is an error