Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Unified Diff: components/offline_pages/offline_page_metadata_store_sql.cc

Issue 2019333008: [Offline Pages] Fix crash due to table inconsistency. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/offline_pages/offline_page_metadata_store_sql.cc
diff --git a/components/offline_pages/offline_page_metadata_store_sql.cc b/components/offline_pages/offline_page_metadata_store_sql.cc
index 93afcb30ad5c8c13231e1147ff692f840bbfbba1..3bddc6537a6c08d86612484a94e0ab014ca9f05f 100644
--- a/components/offline_pages/offline_page_metadata_store_sql.cc
+++ b/components/offline_pages/offline_page_metadata_store_sql.cc
@@ -38,7 +38,7 @@ const char kOfflinePagesColumns[] =
// later use. We will treat NULL as "Unknown" in any subsequent queries
// for user_initiated values.
" user_initiated INTEGER," // this is actually a boolean
- " expiration_time INTEGER NOT NULL,"
+ " expiration_time INTEGER NOT NULL DEFAULT 0,"
" client_namespace VARCHAR NOT NULL,"
" client_id VARCHAR NOT NULL,"
" online_url VARCHAR NOT NULL,"
@@ -87,8 +87,14 @@ bool CreateSchema(sql::Connection* db) {
sql::Transaction transaction(db);
if (!transaction.Begin())
return false;
- if (db->DoesTableExist(kOfflinePagesTable.table_name))
+ if (db->DoesTableExist(kOfflinePagesTable.table_name)) {
+ if (!db->DoesColumnExist(OFFLINE_PAGES_TABLE_NAME, "expiration_time")) {
+ return db->Execute(
+ "ALTER TABLE" OFFLINE_PAGES_TABLE_NAME
fgorski 2016/06/01 16:52:03 I think you need a space after TABLE
+ "ADD COLUMN expiration_time INTEGER NOT NULL DEFAULT 0");
fgorski 2016/06/01 16:52:04 and before ADD
+ }
return true;
+ }
if (!CreateTable(db, kOfflinePagesTable))
return false;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698