Chromium Code Reviews| Index: components/history/core/browser/download_database.cc |
| diff --git a/components/history/core/browser/download_database.cc b/components/history/core/browser/download_database.cc |
| index 8430305ebeb002b339c298df8c3116f1bfbdc238..19f37ffb304821af3377cf9adc631452f44d1d45 100644 |
| --- a/components/history/core/browser/download_database.cc |
| +++ b/components/history/core/browser/download_database.cc |
| @@ -239,14 +239,16 @@ bool DownloadDatabase::MigrateHashHttpMethodAndGenerateGuids() { |
| // base::GenerateGUID() and are considered valid by all known consumers. Hence |
| // no additional migration logic is being introduced to fix those GUIDs. |
| const char kMigrateGuidsQuery[] = |
| - "UPDATE downloads SET guid = printf" |
| - "(\"%08X-%s-4%s-%01X%s-%s\"," |
| - " id," |
| - " hex(randomblob(2))," |
| - " substr(hex(randomblob(2)),2)," |
| - " (8 | (random() & 3))," |
| - " substr(hex(randomblob(2)),2)," |
| - " hex(randomblob(6)))"; |
| + "UPDATE downloads SET guid = " |
| + "substr(hex(char( id>>28) ),2) || substr(hex(char((id>>24)&15)),2) || " |
|
Scott Hess - ex-Googler
2016/04/21 02:32:55
Since SQLite integers are 64-bit, I'd throw in the
|
| + "substr(hex(char((id>>20)&15)),2) || substr(hex(char((id>>16)&15)),2) || " |
| + "substr(hex(char((id>>12)&15)),2) || substr(hex(char((id>> 8)&15)),2) || " |
| + "substr(hex(char((id>> 4)&15)),2) || substr(hex(char( id &15)),2) || " |
| + "'-' || hex(randomblob(2)) || " |
| + "'-4' || substr(hex(randomblob(2)),2) || " |
| + "'-' || substr('89AB',1+(random()&3),1) || " |
| + " substr(hex(randomblob(2)),2) || " |
| + "'-' || hex(randomblob(6))"; |
|
Scott Hess - ex-Googler
2016/04/21 02:32:55
Wow. I assume you have golden tests for this so y
|
| return GetDB().Execute(kMigrateGuidsQuery); |
| } |