static int __check_integrity(sqlite3 *handle)
{
sqlite3_stmt *stmt = NULL;
+ int ret = 0;
if (handle == 0) {
TRACE_ERROR("failed to check handle");
}
TRACE_INFO("");
- int ret = sqlite3_prepare_v2(handle, "PRAGMA integrity_check", -1, &stmt, NULL);
- if (ret != SQLITE_OK && ret != SQLITE_BUSY) {
+ int errorcode = sqlite3_prepare_v2(handle, "PRAGMA integrity_check", -1, &stmt, NULL);
+ if (errorcode != SQLITE_OK && errorcode != SQLITE_BUSY) {
TRACE_ERROR("failed to check integrity:%s", sqlite3_errmsg(handle));
- return -1;
+ ret = -1;
} else {
- ret = sqlite3_step(stmt);
- if (ret == SQLITE_ROW) {
+ errorcode = sqlite3_step(stmt);
+ if (errorcode == SQLITE_ROW) {
const char *ret_val = (const char *)sqlite3_column_text(stmt, 0);
TRACE_INFO("ret_val: %s", ret_val);
- if (ret_val && strcmp(ret_val, "ok") == 0) {
- return 0;
- } else {
+ if (!ret_val || strcmp(ret_val, "ok") != 0) {
TRACE_ERROR("failed to check integrity");
- return -1;
+ ret = -1;
}
- } else {
- return 0;
}
}
- return 0;
+ __dp_finalize(stmt);
+ return ret;
}
static int __check_table(sqlite3 *handle, char *table)