From 465c10ded3763e8772283cee01734e70f1e0fafe Mon Sep 17 00:00:00 2001 From: Julien BLACHE Date: Tue, 27 Apr 2010 20:48:46 +0200 Subject: [PATCH] Rework database version check to error out on newer databases --- src/db.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/db.c b/src/db.c index 5b52fbc8..1c3ddc1a 100644 --- a/src/db.c +++ b/src/db.c @@ -3916,14 +3916,14 @@ db_check_version(void) ret = db_blocking_prepare_v2(Q_VER, strlen(Q_VER) + 1, &stmt, NULL); if (ret != SQLITE_OK) { - DPRINTF(E_LOG, L_DB, "Could not prepare statement: %s %d\n", sqlite3_errmsg(hdl), ret); - return -1; + DPRINTF(E_LOG, L_DB, "Could not prepare statement: %s\n", sqlite3_errmsg(hdl)); + return 1; } ret = db_blocking_step(stmt); if (ret != SQLITE_ROW) { - DPRINTF(E_LOG, L_DB, "Could not step: %s %d\n", sqlite3_errmsg(hdl), ret); + DPRINTF(E_LOG, L_DB, "Could not step: %s\n", sqlite3_errmsg(hdl)); sqlite3_finalize(stmt); return -1; @@ -4061,6 +4061,13 @@ db_init(void) ret = db_check_version(); if (ret < 0) + { + DPRINTF(E_FATAL, L_DB, "Database version check errored out, incompatible database\n"); + + db_perthread_deinit(); + return -1; + } + else if (ret > 0) { DPRINTF(E_FATAL, L_DB, "Could not check database version, trying DB init\n");