Fix check whether we have the latest database structure
This commit is contained in:
parent
4461a16a79
commit
d7f42c5d72
1 changed files with 10 additions and 7 deletions
|
@ -359,6 +359,8 @@ midori_history_initialize (KatzeArray* array,
|
||||||
{
|
{
|
||||||
sqlite3* db;
|
sqlite3* db;
|
||||||
gboolean has_day;
|
gboolean has_day;
|
||||||
|
sqlite3_stmt* stmt;
|
||||||
|
gint result;
|
||||||
|
|
||||||
has_day = FALSE;
|
has_day = FALSE;
|
||||||
|
|
||||||
|
@ -377,11 +379,14 @@ midori_history_initialize (KatzeArray* array,
|
||||||
NULL, NULL, errmsg) != SQLITE_OK)
|
NULL, NULL, errmsg) != SQLITE_OK)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (sqlite3_exec (db, "SELECT day FROM history LIMIT 1", NULL, NULL,
|
sqlite3_prepare_v2 (db, "SELECT day FROM history LIMIT 1", -1, &stmt, NULL);
|
||||||
errmsg) != SQLITE_OK)
|
result = sqlite3_step (stmt);
|
||||||
return NULL;
|
if (result == SQLITE_ROW)
|
||||||
|
has_day = TRUE;
|
||||||
|
sqlite3_finalize (stmt);
|
||||||
|
|
||||||
if (!has_day && sqlite3_exec (db,
|
if (!has_day)
|
||||||
|
sqlite3_exec (db,
|
||||||
"BEGIN TRANSACTION;"
|
"BEGIN TRANSACTION;"
|
||||||
"CREATE TEMPORARY TABLE backup (uri text, title text, date integer);"
|
"CREATE TEMPORARY TABLE backup (uri text, title text, date integer);"
|
||||||
"INSERT INTO backup SELECT uri,title,date FROM history;"
|
"INSERT INTO backup SELECT uri,title,date FROM history;"
|
||||||
|
@ -393,9 +398,7 @@ midori_history_initialize (KatzeArray* array,
|
||||||
"FROM backup;"
|
"FROM backup;"
|
||||||
"DROP TABLE backup;"
|
"DROP TABLE backup;"
|
||||||
"COMMIT;",
|
"COMMIT;",
|
||||||
NULL, NULL, errmsg) != SQLITE_OK)
|
NULL, NULL, errmsg);
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return db;
|
return db;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue