OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/history/url_database.h" | 5 #include "chrome/browser/history/url_database.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 if (!GetDB().Execute("CREATE TABLE keyword_search_terms (" | 399 if (!GetDB().Execute("CREATE TABLE keyword_search_terms (" |
400 "keyword_id INTEGER NOT NULL," // ID of the TemplateURL. | 400 "keyword_id INTEGER NOT NULL," // ID of the TemplateURL. |
401 "url_id INTEGER NOT NULL," // ID of the url. | 401 "url_id INTEGER NOT NULL," // ID of the url. |
402 "lower_term LONGVARCHAR NOT NULL," // The search term, in lower case. | 402 "lower_term LONGVARCHAR NOT NULL," // The search term, in lower case. |
403 "term LONGVARCHAR NOT NULL)")) // The actual search term. | 403 "term LONGVARCHAR NOT NULL)")) // The actual search term. |
404 return false; | 404 return false; |
405 } | 405 } |
406 return true; | 406 return true; |
407 } | 407 } |
408 | 408 |
409 void URLDatabase::CreateKeywordSearchTermsIndices() { | 409 bool URLDatabase::CreateKeywordSearchTermsIndices() { |
410 // For searching. | 410 // For searching. |
411 GetDB().Execute("CREATE INDEX keyword_search_terms_index1 ON " | 411 if (!GetDB().Execute( |
412 "keyword_search_terms (keyword_id, lower_term)"); | 412 "CREATE INDEX IF NOT EXISTS keyword_search_terms_index1 ON " |
| 413 "keyword_search_terms (keyword_id, lower_term)")) { |
| 414 return false; |
| 415 } |
413 | 416 |
414 // For deletion. | 417 // For deletion. |
415 GetDB().Execute("CREATE INDEX keyword_search_terms_index2 ON " | 418 if (!GetDB().Execute( |
416 "keyword_search_terms (url_id)"); | 419 "CREATE INDEX IF NOT EXISTS keyword_search_terms_index2 ON " |
| 420 "keyword_search_terms (url_id)")) { |
| 421 return false; |
| 422 } |
| 423 return true; |
417 } | 424 } |
418 | 425 |
419 bool URLDatabase::DropKeywordSearchTermsTable() { | 426 bool URLDatabase::DropKeywordSearchTermsTable() { |
420 // This will implicitly delete the indices over the table. | 427 // This will implicitly delete the indices over the table. |
421 return GetDB().Execute("DROP TABLE keyword_search_terms"); | 428 return GetDB().Execute("DROP TABLE keyword_search_terms"); |
422 } | 429 } |
423 | 430 |
424 bool URLDatabase::SetKeywordSearchTermsForURL(URLID url_id, | 431 bool URLDatabase::SetKeywordSearchTermsForURL(URLID url_id, |
425 TemplateURLID keyword_id, | 432 TemplateURLID keyword_id, |
426 const string16& term) { | 433 const string16& term) { |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 "title LONGVARCHAR," | 569 "title LONGVARCHAR," |
563 "visit_count INTEGER DEFAULT 0 NOT NULL," | 570 "visit_count INTEGER DEFAULT 0 NOT NULL," |
564 "typed_count INTEGER DEFAULT 0 NOT NULL," | 571 "typed_count INTEGER DEFAULT 0 NOT NULL," |
565 "last_visit_time INTEGER NOT NULL," | 572 "last_visit_time INTEGER NOT NULL," |
566 "hidden INTEGER DEFAULT 0 NOT NULL," | 573 "hidden INTEGER DEFAULT 0 NOT NULL," |
567 "favicon_id INTEGER DEFAULT 0 NOT NULL)"); // favicon_id is not used now. | 574 "favicon_id INTEGER DEFAULT 0 NOT NULL)"); // favicon_id is not used now. |
568 | 575 |
569 return GetDB().Execute(sql.c_str()); | 576 return GetDB().Execute(sql.c_str()); |
570 } | 577 } |
571 | 578 |
572 void URLDatabase::CreateMainURLIndex() { | 579 bool URLDatabase::CreateMainURLIndex() { |
573 // Index over URLs so we can quickly look up based on URL. Ignore errors as | 580 // Index over URLs so we can quickly look up based on URL. |
574 // this likely already exists (and the same below). | 581 return GetDB().Execute( |
575 GetDB().Execute("CREATE INDEX urls_url_index ON urls (url)"); | 582 "CREATE INDEX IF NOT EXISTS urls_url_index ON urls (url)"); |
576 } | 583 } |
577 | 584 |
578 } // namespace history | 585 } // namespace history |
OLD | NEW |