[Xfce4-commits] <midori:master> Fix check whether we have the latest database structure
Christian Dywan
noreply at xfce.org
Thu Feb 4 22:18:01 CET 2010
Updating branch refs/heads/master
to d7f42c5d72f599e41862ed1e1349bda29fe6d749 (commit)
from 4461a16a79a202a9d3ef0796b108d46589ca915c (commit)
commit d7f42c5d72f599e41862ed1e1349bda29fe6d749
Author: Alexander Butenko <a.butenka at gmail.com>
Date: Thu Feb 4 22:16:01 2010 +0100
Fix check whether we have the latest database structure
midori/main.c | 17 ++++++++++-------
1 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/midori/main.c b/midori/main.c
index 353ace3..d0539d7 100644
--- a/midori/main.c
+++ b/midori/main.c
@@ -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;
}
More information about the Xfce4-commits
mailing list