From 8309a049eb7e6c0b622dfc7f0100f65a4c08ba40 Mon Sep 17 00:00:00 2001 From: Sebastian Falbesoner Date: Fri, 4 Feb 2022 21:16:23 +0100 Subject: [PATCH] db: enable SQLite extended result codes 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 --- wallet/db_sqlite3.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/wallet/db_sqlite3.c b/wallet/db_sqlite3.c index 4459e6b2e..ad81bc20b 100644 --- a/wallet/db_sqlite3.c +++ b/wallet/db_sqlite3.c @@ -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 {