summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2017-10-06 03:50:30 +0200
committerNeels Hofmeyr <neels@hofmeyr.de>2017-10-11 22:32:19 +0200
commitd7d9697d85cba6bb18bcb767ebd0005b1ae73e1c (patch)
treebd8b3aed0a74eb29cb15f64bbf1d97ecc002a4f7 /src
parent985094601315c45c2e0a2ac8292df4c2f646c698 (diff)
less noise: simplify db_remove_reset()
db_remove_reset() needs to be called after each stmt run, whether it succeeded or not. In case sqlite3_clear_bindings() would fail to unbind a stmt, we would anyway be beyond recovery. There seem to be no plausible situations where such failure would occur, unless there have been no bindings in the first place. In case there was an SQL stmt failure, sqlite3_reset() will re-barf the same error message, we will always have logged it earlier already in the proper context. We are never evaluating the return value, nor would we know how to recover from non-success. The conclusions: - db_remove_reset() does not need to log any errors. - db_remove_reset() does not need to return success. Change-Id: I21678463e59f607f5f5c5732963e274392f0fffd
Diffstat (limited to 'src')
-rw-r--r--src/db.c16
-rw-r--r--src/db.h2
2 files changed, 4 insertions, 14 deletions
diff --git a/src/db.c b/src/db.c
index 7c25e63..179eba8 100644
--- a/src/db.c
+++ b/src/db.c
@@ -70,20 +70,10 @@ static void sql3_sql_log_cb(void *arg, sqlite3 *s3, const char *stmt, int type)
}
/* remove bindings and reset statement to be re-executed */
-bool db_remove_reset(sqlite3_stmt *stmt)
+void db_remove_reset(sqlite3_stmt *stmt)
{
- int rc = sqlite3_clear_bindings(stmt);
- if (rc != SQLITE_OK) {
- LOGP(DDB, LOGL_ERROR, "Error clerearing bindings: %d\n", rc);
- return false;
- }
-
- rc = sqlite3_reset(stmt);
- if (rc != SQLITE_OK) {
- LOGP(DDB, LOGL_ERROR, "Error in sqlite3_reset: %d\n", rc);
- return false;
- }
- return true;
+ sqlite3_clear_bindings(stmt);
+ sqlite3_reset(stmt);
}
/** bind text arg and do proper cleanup in case of failure. If param_name is
diff --git a/src/db.h b/src/db.h
index d7a8303..ee2d801 100644
--- a/src/db.h
+++ b/src/db.h
@@ -25,7 +25,7 @@ struct db_context {
sqlite3_stmt *stmt[_NUM_DB_STMT];
};
-bool db_remove_reset(sqlite3_stmt *stmt);
+void db_remove_reset(sqlite3_stmt *stmt);
bool db_bind_text(sqlite3_stmt *stmt, const char *param_name, const char *text);
bool db_bind_int(sqlite3_stmt *stmt, const char *param_name, int nr);
bool db_bind_int64(sqlite3_stmt *stmt, const char *param_name, int64_t nr);