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

Unified Diff: components/history/core/browser/download_database.cc

Issue 1897153005: Make SQL in DownloadDatabase SQLite pre 3.8.3 compatible (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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/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);
}
« 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