src/db.c: don't ignore the result of db_bootstrap()

Change-Id: I0de3d4c4355c4dee8b832faae347586d1e1b3516
This commit is contained in:
Vadim Yanitskiy 2018-07-30 20:48:19 +07:00
parent dc17e05e28
commit 050eb1d803
1 changed files with 9 additions and 4 deletions

View File

@ -202,7 +202,7 @@ static int db_bootstrap(struct db_context *dbc)
if (rc != SQLITE_OK) {
LOGP(DDB, LOGL_ERROR, "Unable to prepare SQL statement '%s'\n",
stmt_bootstrap_sql[i]);
return -1;
return rc;
}
/* execute the statement */
@ -214,10 +214,10 @@ static int db_bootstrap(struct db_context *dbc)
" during stmt '%s'",
rc, sqlite3_errmsg(dbc->db),
stmt_bootstrap_sql[i]);
return -1;
return rc;
}
}
return 0;
return SQLITE_OK;
}
struct db_context *db_open(void *ctx, const char *fname, bool enable_sqlite_logging)
@ -274,7 +274,12 @@ struct db_context *db_open(void *ctx, const char *fname, bool enable_sqlite_logg
LOGP(DDB, LOGL_ERROR, "Unable to set Write-Ahead Logging: %s\n",
err_msg);
db_bootstrap(dbc);
rc = db_bootstrap(dbc);
if (rc != SQLITE_OK) {
LOGP(DDB, LOGL_ERROR, "Failed to bootstrap DB: (rc=%d) %s\n",
rc, sqlite3_errmsg(dbc->db));
goto out_free;
}
/* prepare all SQL statements */
for (i = 0; i < ARRAY_SIZE(dbc->stmt); i++) {