Skip to content

Commit

Permalink
db: enable SQLite extended result codes
Browse files Browse the repository at this point in the history
With this change, we get more fine-grained error messages if something
goes wrong in the course of communicating with the SQLite database. To
pick some random examples, the error codes SQLITE_IOERR_NOMEM,
SQLITE_IOERR_CORRUPTFS or SQLITE_IOERR_FSYNC are way more specific
than just a plain SQLITE_IOERR, and the corresponding error messages
generated by sqlite3_errstr() will hence give a better hint to the
user (or also to the developers, if an error report is sent) what the
cause for a failure is.

Changelog-None
  • Loading branch information
theStack authored and rustyrussell committed Feb 7, 2022
1 parent 9ebdb71 commit 8309a04
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions wallet/db_sqlite3.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ static bool db_sqlite3_setup(struct db *db)
}
wrapper->conn = sql;

err = sqlite3_extended_result_codes(wrapper->conn, 1);
if (err != SQLITE_OK) {
db_fatal("failed to enable extended result codes: %s",
sqlite3_errstr(err));
}

if (!backup_filename)
wrapper->backup_conn = NULL;
else {
Expand Down

0 comments on commit 8309a04

Please sign in to comment.