]> spindle.queued.net Git - midori/commitdiff
Fix check whether we have the latest database structure
authorAlexander Butenko <a.butenka@gmail.com>
Thu, 4 Feb 2010 21:16:01 +0000 (22:16 +0100)
committerChristian Dywan <christian@twotoasts.de>
Thu, 4 Feb 2010 21:16:01 +0000 (22:16 +0100)
midori/main.c

index 353ace3caedd659e1eaa43bae93317f69b8272c7..d0539d79d2f81bbd56580a8d520d9e5246ad2126 100644 (file)
@@ -359,6 +359,8 @@ midori_history_initialize (KatzeArray*  array,
 {
     sqlite3* db;
     gboolean has_day;
+    sqlite3_stmt* stmt;
+    gint result;
 
     has_day = FALSE;
 
@@ -377,11 +379,14 @@ midori_history_initialize (KatzeArray*  array,
                   NULL, NULL, errmsg) != SQLITE_OK)
         return NULL;
 
-    if (sqlite3_exec (db, "SELECT day FROM history LIMIT 1", NULL, NULL,
-                      errmsg) != SQLITE_OK)
-        return NULL;
+    sqlite3_prepare_v2 (db, "SELECT day FROM history LIMIT 1", -1, &stmt, NULL);
+    result = sqlite3_step (stmt);
+    if (result == SQLITE_ROW)
+        has_day = TRUE;
+    sqlite3_finalize (stmt);
 
-    if (!has_day && sqlite3_exec (db,
+    if (!has_day)
+        sqlite3_exec (db,
                       "BEGIN TRANSACTION;"
                       "CREATE TEMPORARY TABLE backup (uri text, title text, date integer);"
                       "INSERT INTO backup SELECT uri,title,date FROM history;"
@@ -393,9 +398,7 @@ midori_history_initialize (KatzeArray*  array,
                       "FROM backup;"
                       "DROP TABLE backup;"
                       "COMMIT;",
-                      NULL, NULL, errmsg) != SQLITE_OK)
-        return NULL;
-
+                      NULL, NULL, errmsg);
     return db;
 }