summaryrefslogtreecommitdiffstats
path: root/chrome/browser/history/url_database.cc
diff options
context:
space:
mode:
authorshess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-23 17:07:20 +0000
committershess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-23 17:07:20 +0000
commit9fe37555ac558799ab41508e8f654c87c704ba07 (patch)
treea3056f6d3bafbf830b6c4fd896338ebb5332e241 /chrome/browser/history/url_database.cc
parentb20ad84d73015b7b3fa6a3fd9051fbadd24a4281 (diff)
downloadchromium_src-9fe37555ac558799ab41508e8f654c87c704ba07.zip
chromium_src-9fe37555ac558799ab41508e8f654c87c704ba07.tar.gz
chromium_src-9fe37555ac558799ab41508e8f654c87c704ba07.tar.bz2
[sql] WARN_UNUSED_RESULT on Execute().
Goal is to encourage callers to handle errors, especially in cases like schema changes, where dropped errors can result in broken databases. Many CREATE INDEX calls where ignoring errors rather than checking if the index already existed before creating it. Recoded those to CREATE INDEX IF NOT EXISTS, which is for exactly this purpose. BUG=none TEST=none Review URL: http://codereview.chromium.org/9005036 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115725 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/history/url_database.cc')
-rw-r--r--chrome/browser/history/url_database.cc25
1 files changed, 16 insertions, 9 deletions
diff --git a/chrome/browser/history/url_database.cc b/chrome/browser/history/url_database.cc
index 834ece4..4a020b9 100644
--- a/chrome/browser/history/url_database.cc
+++ b/chrome/browser/history/url_database.cc
@@ -406,14 +406,21 @@ bool URLDatabase::InitKeywordSearchTermsTable() {
return true;
}
-void URLDatabase::CreateKeywordSearchTermsIndices() {
+bool URLDatabase::CreateKeywordSearchTermsIndices() {
// For searching.
- GetDB().Execute("CREATE INDEX keyword_search_terms_index1 ON "
- "keyword_search_terms (keyword_id, lower_term)");
+ if (!GetDB().Execute(
+ "CREATE INDEX IF NOT EXISTS keyword_search_terms_index1 ON "
+ "keyword_search_terms (keyword_id, lower_term)")) {
+ return false;
+ }
// For deletion.
- GetDB().Execute("CREATE INDEX keyword_search_terms_index2 ON "
- "keyword_search_terms (url_id)");
+ if (!GetDB().Execute(
+ "CREATE INDEX IF NOT EXISTS keyword_search_terms_index2 ON "
+ "keyword_search_terms (url_id)")) {
+ return false;
+ }
+ return true;
}
bool URLDatabase::DropKeywordSearchTermsTable() {
@@ -569,10 +576,10 @@ bool URLDatabase::CreateURLTable(bool is_temporary) {
return GetDB().Execute(sql.c_str());
}
-void URLDatabase::CreateMainURLIndex() {
- // Index over URLs so we can quickly look up based on URL. Ignore errors as
- // this likely already exists (and the same below).
- GetDB().Execute("CREATE INDEX urls_url_index ON urls (url)");
+bool URLDatabase::CreateMainURLIndex() {
+ // Index over URLs so we can quickly look up based on URL.
+ return GetDB().Execute(
+ "CREATE INDEX IF NOT EXISTS urls_url_index ON urls (url)");
}
} // namespace history