Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/search_engines/keyword_table.h" | 5 #include "components/search_engines/keyword_table.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 columns.push_back("image_url"); | 74 columns.push_back("image_url"); |
| 75 columns.push_back("search_url_post_params"); | 75 columns.push_back("search_url_post_params"); |
| 76 columns.push_back("suggest_url_post_params"); | 76 columns.push_back("suggest_url_post_params"); |
| 77 columns.push_back("instant_url_post_params"); | 77 columns.push_back("instant_url_post_params"); |
| 78 columns.push_back("image_url_post_params"); | 78 columns.push_back("image_url_post_params"); |
| 79 } | 79 } |
| 80 if (version >= 53) { | 80 if (version >= 53) { |
| 81 // Column added in version 53. | 81 // Column added in version 53. |
| 82 columns.push_back("new_tab_url"); | 82 columns.push_back("new_tab_url"); |
| 83 } | 83 } |
| 84 if (version >= 68) { | |
| 85 // Remove column "show_in_default_list" | |
| 86 columns.erase(columns.begin() + 10); | |
|
Peter Kasting
2016/11/10 06:41:07
Don't erase things like this -- doing so is fragil
ltian
2016/11/11 03:52:13
Done.
| |
| 87 } | |
| 84 | 88 |
| 85 return base::JoinString(columns, std::string(concatenated ? " || " : ", ")); | 89 return base::JoinString(columns, std::string(concatenated ? " || " : ", ")); |
| 86 } | 90 } |
| 87 | 91 |
| 88 | 92 |
| 89 // Inserts the data from |data| into |s|. |s| is assumed to have slots for all | 93 // Inserts the data from |data| into |s|. |s| is assumed to have slots for all |
| 90 // the columns in the keyword table. |id_column| is the slot number to bind | 94 // the columns in the keyword table. |id_column| is the slot number to bind |
| 91 // |data|'s |id| to; |starting_column| is the slot number of the first of a | 95 // |data|'s |id| to; |starting_column| is the slot number of the first of a |
| 92 // contiguous set of slots to bind all the other fields to. | 96 // contiguous set of slots to bind all the other fields to. |
| 93 void BindURLToStatement(const TemplateURLData& data, | 97 void BindURLToStatement(const TemplateURLData& data, |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 112 std::string()); | 116 std::string()); |
| 113 s->BindString(starting_column + 3, data.url()); | 117 s->BindString(starting_column + 3, data.url()); |
| 114 s->BindBool(starting_column + 4, data.safe_for_autoreplace); | 118 s->BindBool(starting_column + 4, data.safe_for_autoreplace); |
| 115 s->BindString(starting_column + 5, data.originating_url.is_valid() ? | 119 s->BindString(starting_column + 5, data.originating_url.is_valid() ? |
| 116 history::URLDatabase::GURLToDatabaseURL(data.originating_url) : | 120 history::URLDatabase::GURLToDatabaseURL(data.originating_url) : |
| 117 std::string()); | 121 std::string()); |
| 118 s->BindInt64(starting_column + 6, data.date_created.ToTimeT()); | 122 s->BindInt64(starting_column + 6, data.date_created.ToTimeT()); |
| 119 s->BindInt(starting_column + 7, data.usage_count); | 123 s->BindInt(starting_column + 7, data.usage_count); |
| 120 s->BindString(starting_column + 8, | 124 s->BindString(starting_column + 8, |
| 121 base::JoinString(data.input_encodings, ";")); | 125 base::JoinString(data.input_encodings, ";")); |
| 122 s->BindBool(starting_column + 9, data.show_in_default_list); | 126 s->BindString(starting_column + 9, data.suggestions_url); |
| 123 s->BindString(starting_column + 10, data.suggestions_url); | 127 s->BindInt(starting_column + 10, data.prepopulate_id); |
| 124 s->BindInt(starting_column + 11, data.prepopulate_id); | 128 s->BindBool(starting_column + 11, data.created_by_policy); |
| 125 s->BindBool(starting_column + 12, data.created_by_policy); | 129 s->BindString(starting_column + 12, data.instant_url); |
| 126 s->BindString(starting_column + 13, data.instant_url); | 130 s->BindInt64(starting_column + 13, data.last_modified.ToTimeT()); |
| 127 s->BindInt64(starting_column + 14, data.last_modified.ToTimeT()); | 131 s->BindString(starting_column + 14, data.sync_guid); |
| 128 s->BindString(starting_column + 15, data.sync_guid); | 132 s->BindString(starting_column + 15, alternate_urls); |
| 129 s->BindString(starting_column + 16, alternate_urls); | 133 s->BindString(starting_column + 16, data.search_terms_replacement_key); |
| 130 s->BindString(starting_column + 17, data.search_terms_replacement_key); | 134 s->BindString(starting_column + 17, data.image_url); |
| 131 s->BindString(starting_column + 18, data.image_url); | 135 s->BindString(starting_column + 18, data.search_url_post_params); |
| 132 s->BindString(starting_column + 19, data.search_url_post_params); | 136 s->BindString(starting_column + 19, data.suggestions_url_post_params); |
| 133 s->BindString(starting_column + 20, data.suggestions_url_post_params); | 137 s->BindString(starting_column + 20, data.instant_url_post_params); |
| 134 s->BindString(starting_column + 21, data.instant_url_post_params); | 138 s->BindString(starting_column + 21, data.image_url_post_params); |
| 135 s->BindString(starting_column + 22, data.image_url_post_params); | 139 s->BindString(starting_column + 22, data.new_tab_url); |
| 136 s->BindString(starting_column + 23, data.new_tab_url); | |
| 137 } | 140 } |
| 138 | 141 |
| 139 WebDatabaseTable::TypeKey GetKey() { | 142 WebDatabaseTable::TypeKey GetKey() { |
| 140 // We just need a unique constant. Use the address of a static that | 143 // We just need a unique constant. Use the address of a static that |
| 141 // COMDAT folding won't touch in an optimizing linker. | 144 // COMDAT folding won't touch in an optimizing linker. |
| 142 static int table_key = 0; | 145 static int table_key = 0; |
| 143 return reinterpret_cast<void*>(&table_key); | 146 return reinterpret_cast<void*>(&table_key); |
| 144 } | 147 } |
| 145 | 148 |
| 146 } // namespace | 149 } // namespace |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 164 "id INTEGER PRIMARY KEY," | 167 "id INTEGER PRIMARY KEY," |
| 165 "short_name VARCHAR NOT NULL," | 168 "short_name VARCHAR NOT NULL," |
| 166 "keyword VARCHAR NOT NULL," | 169 "keyword VARCHAR NOT NULL," |
| 167 "favicon_url VARCHAR NOT NULL," | 170 "favicon_url VARCHAR NOT NULL," |
| 168 "url VARCHAR NOT NULL," | 171 "url VARCHAR NOT NULL," |
| 169 "safe_for_autoreplace INTEGER," | 172 "safe_for_autoreplace INTEGER," |
| 170 "originating_url VARCHAR," | 173 "originating_url VARCHAR," |
| 171 "date_created INTEGER DEFAULT 0," | 174 "date_created INTEGER DEFAULT 0," |
| 172 "usage_count INTEGER DEFAULT 0," | 175 "usage_count INTEGER DEFAULT 0," |
| 173 "input_encodings VARCHAR," | 176 "input_encodings VARCHAR," |
| 174 "show_in_default_list INTEGER," | |
| 175 "suggest_url VARCHAR," | 177 "suggest_url VARCHAR," |
| 176 "prepopulate_id INTEGER DEFAULT 0," | 178 "prepopulate_id INTEGER DEFAULT 0," |
| 177 "created_by_policy INTEGER DEFAULT 0," | 179 "created_by_policy INTEGER DEFAULT 0," |
| 178 "instant_url VARCHAR," | 180 "instant_url VARCHAR," |
| 179 "last_modified INTEGER DEFAULT 0," | 181 "last_modified INTEGER DEFAULT 0," |
| 180 "sync_guid VARCHAR," | 182 "sync_guid VARCHAR," |
| 181 "alternate_urls VARCHAR," | 183 "alternate_urls VARCHAR," |
| 182 "search_terms_replacement_key VARCHAR," | 184 "search_terms_replacement_key VARCHAR," |
| 183 "image_url VARCHAR," | 185 "image_url VARCHAR," |
| 184 "search_url_post_params VARCHAR," | 186 "search_url_post_params VARCHAR," |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 195 bool KeywordTable::MigrateToVersion(int version, | 197 bool KeywordTable::MigrateToVersion(int version, |
| 196 bool* update_compatible_version) { | 198 bool* update_compatible_version) { |
| 197 // Migrate if necessary. | 199 // Migrate if necessary. |
| 198 switch (version) { | 200 switch (version) { |
| 199 case 53: | 201 case 53: |
| 200 *update_compatible_version = true; | 202 *update_compatible_version = true; |
| 201 return MigrateToVersion53AddNewTabURLColumn(); | 203 return MigrateToVersion53AddNewTabURLColumn(); |
| 202 case 59: | 204 case 59: |
| 203 *update_compatible_version = true; | 205 *update_compatible_version = true; |
| 204 return MigrateToVersion59RemoveExtensionKeywords(); | 206 return MigrateToVersion59RemoveExtensionKeywords(); |
| 207 case 68: | |
| 208 *update_compatible_version = true; | |
| 209 return MigrateToVersion68RemoveShowInDefaultListColumn(); | |
| 205 } | 210 } |
| 206 | 211 |
| 207 return true; | 212 return true; |
| 208 } | 213 } |
| 209 | 214 |
| 210 bool KeywordTable::PerformOperations(const Operations& operations) { | 215 bool KeywordTable::PerformOperations(const Operations& operations) { |
| 211 sql::Transaction transaction(db_); | 216 sql::Transaction transaction(db_); |
| 212 if (!transaction.Begin()) | 217 if (!transaction.Begin()) |
| 213 return false; | 218 return false; |
| 214 | 219 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 282 bool KeywordTable::MigrateToVersion53AddNewTabURLColumn() { | 287 bool KeywordTable::MigrateToVersion53AddNewTabURLColumn() { |
| 283 return db_->Execute("ALTER TABLE keywords ADD COLUMN new_tab_url " | 288 return db_->Execute("ALTER TABLE keywords ADD COLUMN new_tab_url " |
| 284 "VARCHAR DEFAULT ''"); | 289 "VARCHAR DEFAULT ''"); |
| 285 } | 290 } |
| 286 | 291 |
| 287 bool KeywordTable::MigrateToVersion59RemoveExtensionKeywords() { | 292 bool KeywordTable::MigrateToVersion59RemoveExtensionKeywords() { |
| 288 return db_->Execute("DELETE FROM keywords " | 293 return db_->Execute("DELETE FROM keywords " |
| 289 "WHERE url LIKE 'chrome-extension://%'"); | 294 "WHERE url LIKE 'chrome-extension://%'"); |
| 290 } | 295 } |
| 291 | 296 |
| 297 // SQLite does not support DROP COLUM operation, follows the instructions from | |
|
Peter Kasting
2016/11/10 06:41:07
Nit: COLUMN
ltian
2016/11/11 03:52:13
Done.
| |
| 298 // https://www.sqlite.org/lang_altertable.html#otheralter. A new table is | |
| 299 // created | |
|
Ian Wen
2016/11/09 19:58:52
1. The comment block is not formatted correctly.
2
ltian
2016/11/11 03:52:13
Done.
| |
| 300 // without the show_in_default_list column. Data from all but the dropped column | |
| 301 // from the old table are copied into it. After that, the new table is renamed | |
| 302 // to | |
| 303 // the current one. | |
| 304 bool KeywordTable::MigrateToVersion68RemoveShowInDefaultListColumn() { | |
| 305 if (!db_->Execute("CREATE TABLE temp_keywords (" | |
|
Ian Wen
2016/11/09 19:58:52
Do you mean:
return db->Execute() && db->Execute(
ltian
2016/11/11 03:52:13
Yes, it is. Thank you for pointing it out.
| |
| 306 "id INTEGER PRIMARY KEY," | |
| 307 "short_name VARCHAR NOT NULL," | |
| 308 "keyword VARCHAR NOT NULL," | |
| 309 "favicon_url VARCHAR NOT NULL," | |
| 310 "url VARCHAR NOT NULL," | |
| 311 "safe_for_autoreplace INTEGER," | |
| 312 "originating_url VARCHAR," | |
| 313 "date_created INTEGER DEFAULT 0," | |
| 314 "usage_count INTEGER DEFAULT 0," | |
| 315 "input_encodings VARCHAR," | |
| 316 "suggest_url VARCHAR," | |
| 317 "prepopulate_id INTEGER DEFAULT 0," | |
| 318 "created_by_policy INTEGER DEFAULT 0," | |
| 319 "instant_url VARCHAR," | |
| 320 "last_modified INTEGER DEFAULT 0," | |
| 321 "sync_guid VARCHAR," | |
| 322 "alternate_urls VARCHAR," | |
| 323 "search_terms_replacement_key VARCHAR," | |
| 324 "image_url VARCHAR," | |
| 325 "search_url_post_params VARCHAR," | |
| 326 "suggest_url_post_params VARCHAR," | |
| 327 "instant_url_post_params VARCHAR," | |
| 328 "image_url_post_params VARCHAR," | |
| 329 "new_tab_url VARCHAR)") || | |
| 330 !db_->Execute("INSERT OR REPLACE INTO temp_keywords SELECT " | |
|
Peter Kasting
2016/11/10 06:41:06
No need for OR REPLACE.
ltian
2016/11/11 03:52:13
Done.
| |
| 331 "id, short_name, keyword, favicon_url, url, " | |
| 332 "safe_for_autoreplace, originating_url, " | |
| 333 "date_created, usage_count, input_encodings, " | |
| 334 "suggest_url, prepopulate_id, created_by_policy, " | |
| 335 "instant_url, last_modified, sync_guid, " | |
| 336 "alternate_urls, search_terms_replacement_key, " | |
| 337 "image_url, search_url_post_params, " | |
| 338 "suggest_url_post_params, instant_url_post_params," | |
| 339 "image_url_post_params, new_tab_url FROM keywords") || | |
| 340 !db_->Execute("DROP TABLE keywords") || | |
| 341 !db_->Execute("ALTER TABLE temp_keywords RENAME TO keywords")) { | |
| 342 return false; | |
| 343 } | |
| 344 return true; | |
|
Peter Kasting
2016/11/10 06:41:06
Everything above should be wrapped in a transactio
ltian
2016/11/11 03:52:13
I noticed that when I modified this but I was also
Peter Kasting
2016/11/11 06:13:08
They only have one statement to execute, so it wil
| |
| 345 } | |
| 346 | |
| 292 // static | 347 // static |
| 293 bool KeywordTable::GetKeywordDataFromStatement(const sql::Statement& s, | 348 bool KeywordTable::GetKeywordDataFromStatement(const sql::Statement& s, |
| 294 TemplateURLData* data) { | 349 TemplateURLData* data) { |
| 295 DCHECK(data); | 350 DCHECK(data); |
| 296 | 351 |
| 297 data->SetShortName(s.ColumnString16(1)); | 352 data->SetShortName(s.ColumnString16(1)); |
| 298 data->SetKeyword(s.ColumnString16(2)); | 353 data->SetKeyword(s.ColumnString16(2)); |
| 299 // Due to past bugs, we might have persisted entries with empty URLs. Avoid | 354 // Due to past bugs, we might have persisted entries with empty URLs. Avoid |
| 300 // reading these out. (GetKeywords() will delete these entries on return.) | 355 // reading these out. (GetKeywords() will delete these entries on return.) |
| 301 // NOTE: This code should only be needed as long as we might be reading such | 356 // NOTE: This code should only be needed as long as we might be reading such |
| 302 // potentially-old data and can be removed afterward. | 357 // potentially-old data and can be removed afterward. |
| 303 if (s.ColumnString(4).empty()) | 358 if (s.ColumnString(4).empty()) |
| 304 return false; | 359 return false; |
| 305 data->SetURL(s.ColumnString(4)); | 360 data->SetURL(s.ColumnString(4)); |
| 306 data->suggestions_url = s.ColumnString(11); | 361 data->suggestions_url = s.ColumnString(10); |
| 307 data->instant_url = s.ColumnString(14); | 362 data->instant_url = s.ColumnString(13); |
| 308 data->image_url = s.ColumnString(19); | 363 data->image_url = s.ColumnString(18); |
| 309 data->new_tab_url = s.ColumnString(24); | 364 data->new_tab_url = s.ColumnString(23); |
| 310 data->search_url_post_params = s.ColumnString(20); | 365 data->search_url_post_params = s.ColumnString(19); |
| 311 data->suggestions_url_post_params = s.ColumnString(21); | 366 data->suggestions_url_post_params = s.ColumnString(20); |
| 312 data->instant_url_post_params = s.ColumnString(22); | 367 data->instant_url_post_params = s.ColumnString(21); |
| 313 data->image_url_post_params = s.ColumnString(23); | 368 data->image_url_post_params = s.ColumnString(22); |
| 314 data->favicon_url = GURL(s.ColumnString(3)); | 369 data->favicon_url = GURL(s.ColumnString(3)); |
| 315 data->originating_url = GURL(s.ColumnString(6)); | 370 data->originating_url = GURL(s.ColumnString(6)); |
| 316 data->show_in_default_list = s.ColumnBool(10); | |
| 317 data->safe_for_autoreplace = s.ColumnBool(5); | 371 data->safe_for_autoreplace = s.ColumnBool(5); |
| 318 data->input_encodings = base::SplitString( | 372 data->input_encodings = base::SplitString( |
| 319 s.ColumnString(9), ";", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 373 s.ColumnString(9), ";", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| 320 data->id = s.ColumnInt64(0); | 374 data->id = s.ColumnInt64(0); |
| 321 data->date_created = Time::FromTimeT(s.ColumnInt64(7)); | 375 data->date_created = Time::FromTimeT(s.ColumnInt64(7)); |
| 322 data->last_modified = Time::FromTimeT(s.ColumnInt64(15)); | 376 data->last_modified = Time::FromTimeT(s.ColumnInt64(14)); |
| 323 data->created_by_policy = s.ColumnBool(13); | 377 data->created_by_policy = s.ColumnBool(12); |
| 324 data->usage_count = s.ColumnInt(8); | 378 data->usage_count = s.ColumnInt(8); |
| 325 data->prepopulate_id = s.ColumnInt(12); | 379 data->prepopulate_id = s.ColumnInt(11); |
| 326 data->sync_guid = s.ColumnString(16); | 380 data->sync_guid = s.ColumnString(15); |
| 327 | 381 |
| 328 data->alternate_urls.clear(); | 382 data->alternate_urls.clear(); |
| 329 base::JSONReader json_reader; | 383 base::JSONReader json_reader; |
| 330 std::unique_ptr<base::Value> value( | 384 std::unique_ptr<base::Value> value( |
| 331 json_reader.ReadToValue(s.ColumnString(17))); | 385 json_reader.ReadToValue(s.ColumnString(16))); |
| 332 base::ListValue* alternate_urls_value; | 386 base::ListValue* alternate_urls_value; |
| 333 if (value.get() && value->GetAsList(&alternate_urls_value)) { | 387 if (value.get() && value->GetAsList(&alternate_urls_value)) { |
| 334 std::string alternate_url; | 388 std::string alternate_url; |
| 335 for (size_t i = 0; i < alternate_urls_value->GetSize(); ++i) { | 389 for (size_t i = 0; i < alternate_urls_value->GetSize(); ++i) { |
| 336 if (alternate_urls_value->GetString(i, &alternate_url)) | 390 if (alternate_urls_value->GetString(i, &alternate_url)) |
| 337 data->alternate_urls.push_back(alternate_url); | 391 data->alternate_urls.push_back(alternate_url); |
| 338 } | 392 } |
| 339 } | 393 } |
| 340 | 394 |
| 341 data->search_terms_replacement_key = s.ColumnString(18); | 395 data->search_terms_replacement_key = s.ColumnString(17); |
| 342 | 396 |
| 343 return true; | 397 return true; |
| 344 } | 398 } |
| 345 | 399 |
| 346 bool KeywordTable::AddKeyword(const TemplateURLData& data) { | 400 bool KeywordTable::AddKeyword(const TemplateURLData& data) { |
| 347 DCHECK(data.id); | 401 DCHECK(data.id); |
| 348 std::string query("INSERT INTO keywords (" + GetKeywordColumns() + ") " | 402 std::string query("INSERT INTO keywords (" + GetKeywordColumns() + |
| 349 "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?," | 403 ") " |
|
Ian Wen
2016/11/09 19:58:52
Merge #402 with #403.
ltian
2016/11/11 03:52:13
Done.
| |
| 404 "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?," | |
| 350 " ?)"); | 405 " ?)"); |
| 351 sql::Statement s(db_->GetCachedStatement(SQL_FROM_HERE, query.c_str())); | 406 sql::Statement s(db_->GetCachedStatement(SQL_FROM_HERE, query.c_str())); |
| 352 BindURLToStatement(data, &s, 0, 1); | 407 BindURLToStatement(data, &s, 0, 1); |
| 353 | 408 |
| 354 return s.Run(); | 409 return s.Run(); |
| 355 } | 410 } |
| 356 | 411 |
| 357 bool KeywordTable::RemoveKeyword(TemplateURLID id) { | 412 bool KeywordTable::RemoveKeyword(TemplateURLID id) { |
| 358 DCHECK(id); | 413 DCHECK(id); |
| 359 sql::Statement s(db_->GetCachedStatement( | 414 sql::Statement s(db_->GetCachedStatement( |
| 360 SQL_FROM_HERE, "DELETE FROM keywords WHERE id = ?")); | 415 SQL_FROM_HERE, "DELETE FROM keywords WHERE id = ?")); |
| 361 s.BindInt64(0, id); | 416 s.BindInt64(0, id); |
| 362 | 417 |
| 363 return s.Run(); | 418 return s.Run(); |
| 364 } | 419 } |
| 365 | 420 |
| 366 bool KeywordTable::UpdateKeyword(const TemplateURLData& data) { | 421 bool KeywordTable::UpdateKeyword(const TemplateURLData& data) { |
| 367 DCHECK(data.id); | 422 DCHECK(data.id); |
| 368 sql::Statement s(db_->GetCachedStatement( | 423 sql::Statement s(db_->GetCachedStatement( |
| 369 SQL_FROM_HERE, | 424 SQL_FROM_HERE, |
| 370 "UPDATE keywords SET short_name=?, keyword=?, favicon_url=?, url=?, " | 425 "UPDATE keywords SET short_name=?, keyword=?, favicon_url=?, url=?, " |
| 371 "safe_for_autoreplace=?, originating_url=?, date_created=?, " | 426 "safe_for_autoreplace=?, originating_url=?, date_created=?, " |
| 372 "usage_count=?, input_encodings=?, show_in_default_list=?, " | 427 "usage_count=?, input_encodings=?, suggest_url=?, " |
| 373 "suggest_url=?, prepopulate_id=?, created_by_policy=?, instant_url=?, " | 428 "prepopulate_id=?, created_by_policy=?, instant_url=?, " |
| 374 "last_modified=?, sync_guid=?, alternate_urls=?, " | 429 "last_modified=?, sync_guid=?, alternate_urls=?, " |
| 375 "search_terms_replacement_key=?, image_url=?, search_url_post_params=?, " | 430 "search_terms_replacement_key=?, image_url=?, search_url_post_params=?, " |
| 376 "suggest_url_post_params=?, instant_url_post_params=?, " | 431 "suggest_url_post_params=?, instant_url_post_params=?, " |
| 377 "image_url_post_params=?, new_tab_url=? WHERE id=?")); | 432 "image_url_post_params=?, new_tab_url=? WHERE id=?")); |
| 378 BindURLToStatement(data, &s, 24, 0); // "24" binds id() as the last item. | 433 BindURLToStatement(data, &s, 23, 0); // "23" binds id() as the last item. |
| 379 | 434 |
| 380 return s.Run(); | 435 return s.Run(); |
| 381 } | 436 } |
| 382 | 437 |
| 383 bool KeywordTable::GetKeywordAsString(TemplateURLID id, | 438 bool KeywordTable::GetKeywordAsString(TemplateURLID id, |
| 384 const std::string& table_name, | 439 const std::string& table_name, |
| 385 std::string* result) { | 440 std::string* result) { |
| 386 std::string query("SELECT " + | 441 std::string query("SELECT " + |
| 387 ColumnsForVersion(WebDatabase::kCurrentVersionNumber, true) + | 442 ColumnsForVersion(WebDatabase::kCurrentVersionNumber, true) + |
| 388 " FROM " + table_name + " WHERE id=?"); | 443 " FROM " + table_name + " WHERE id=?"); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 478 } | 533 } |
| 479 } | 534 } |
| 480 | 535 |
| 481 // Replace the old table with the new one. | 536 // Replace the old table with the new one. |
| 482 sql = "DROP TABLE " + name; | 537 sql = "DROP TABLE " + name; |
| 483 if (!db_->Execute(sql.c_str())) | 538 if (!db_->Execute(sql.c_str())) |
| 484 return false; | 539 return false; |
| 485 sql = "ALTER TABLE keywords_temp RENAME TO " + name; | 540 sql = "ALTER TABLE keywords_temp RENAME TO " + name; |
| 486 return db_->Execute(sql.c_str()); | 541 return db_->Execute(sql.c_str()); |
| 487 } | 542 } |
| OLD | NEW |