summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Baptiste Queru <jbq@google.com>2010-10-11 07:33:48 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2010-10-11 07:33:48 -0700
commit6c767e7dc1a6fd9adc5ea8930ad1432a48b74b95 (patch)
treeecefa57ead3370f080d98dc45b91c0abe8029b1e
parent7bf3f38c493642b181f0c7ddf30b8214e50fea3b (diff)
parent6d25c81ef7ddfc6cbc36094388b2de987dd77dae (diff)
downloadpackages_apps_browser-6c767e7dc1a6fd9adc5ea8930ad1432a48b74b95.zip
packages_apps_browser-6c767e7dc1a6fd9adc5ea8930ad1432a48b74b95.tar.gz
packages_apps_browser-6c767e7dc1a6fd9adc5ea8930ad1432a48b74b95.tar.bz2
am 6d25c81e: Merge "Protection against bookmarks with url=null in the database"
Merge commit '6d25c81ef7ddfc6cbc36094388b2de987dd77dae' into gingerbread-plus-aosp * commit '6d25c81ef7ddfc6cbc36094388b2de987dd77dae': Protection against bookmarks with url=null in the database
-rw-r--r--src/com/android/browser/BrowserProvider.java26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/com/android/browser/BrowserProvider.java b/src/com/android/browser/BrowserProvider.java
index f8574ed..72ec819 100644
--- a/src/com/android/browser/BrowserProvider.java
+++ b/src/com/android/browser/BrowserProvider.java
@@ -152,7 +152,8 @@ public class BrowserProvider extends ContentProvider {
// 20 -> 21 Added touch_icon
// 21 -> 22 Remove "clientid"
// 22 -> 23 Added user_entered
- private static final int DATABASE_VERSION = 23;
+ // 23 -> 24 Url not allowed to be null anymore.
+ private static final int DATABASE_VERSION = 24;
// Regular expression which matches http://, followed by some stuff, followed by
// optionally a trailing slash, all matched as separate groups.
@@ -232,7 +233,7 @@ public class BrowserProvider extends ContentProvider {
db.execSQL("CREATE TABLE bookmarks (" +
"_id INTEGER PRIMARY KEY," +
"title TEXT," +
- "url TEXT," +
+ "url TEXT NOT NULL," +
"visits INTEGER," +
"date LONG," +
"created LONG," +
@@ -284,6 +285,27 @@ public class BrowserProvider extends ContentProvider {
}
if (oldVersion < 23) {
db.execSQL("ALTER TABLE bookmarks ADD COLUMN user_entered INTEGER;");
+ }
+ if (oldVersion < 24) {
+ /* SQLite does not support ALTER COLUMN, hence the lengthy code. */
+ db.execSQL("DELETE FROM bookmarks WHERE url IS NULL;");
+ db.execSQL("ALTER TABLE bookmarks RENAME TO bookmarks_temp;");
+ db.execSQL("CREATE TABLE bookmarks (" +
+ "_id INTEGER PRIMARY KEY," +
+ "title TEXT," +
+ "url TEXT NOT NULL," +
+ "visits INTEGER," +
+ "date LONG," +
+ "created LONG," +
+ "description TEXT," +
+ "bookmark INTEGER," +
+ "favicon BLOB DEFAULT NULL," +
+ "thumbnail BLOB DEFAULT NULL," +
+ "touch_icon BLOB DEFAULT NULL," +
+ "user_entered INTEGER" +
+ ");");
+ db.execSQL("INSERT INTO bookmarks SELECT * FROM bookmarks_temp;");
+ db.execSQL("DROP TABLE bookmarks_temp;");
} else {
db.execSQL("DROP TABLE IF EXISTS bookmarks");
db.execSQL("DROP TABLE IF EXISTS searches");