aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorW. J. van der Laan <laanwj@protonmail.com>2021-09-30 11:55:50 +0200
committerW. J. van der Laan <laanwj@protonmail.com>2021-09-30 12:11:00 +0200
commit80b4e8fb87a24c20ad9decaf55f73e22e54b8b34 (patch)
treef663fa0a786f4aed3a33bf24ed32f9e8bdef5125 /src
parent81e7748bc18aef167a6aed07c96d85bf00c5929e (diff)
parent90be29c5b52e68b5de8a3282cd83172fbf9acf1b (diff)
downloadbitcoin-80b4e8fb87a24c20ad9decaf55f73e22e54b8b34.tar.xz
Merge bitcoin/bitcoin#23112: wallet: enable SQLite extended result codes
90be29c5b52e68b5de8a3282cd83172fbf9acf1b wallet: enable SQLite extended result codes (Sebastian Falbesoner) Pull request description: 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. See the SQLite documentation https://www.sqlite.org/c3ref/extended_result_codes.html https://www.sqlite.org/c3ref/c_abort_rollback.html > In its default configuration, SQLite API routines return one of 30 integer result codes. However, experience has shown that many of these result codes are too coarse-grained. They do not provide as much information about problems as programmers might like. In an effort to address this, newer versions of SQLite (version 3.3.8 2006-10-09 and later) include support for additional result codes that provide more detailed information about errors. ACKs for top commit: Sjors: utACK 90be29c achow101: ACK 90be29c5b52e68b5de8a3282cd83172fbf9acf1b laanwj: Code review ACK 90be29c5b52e68b5de8a3282cd83172fbf9acf1b Tree-SHA512: 2b7a60860c206f2b5f8ff9d4a7698efdee897c9ad024621b8fd165b841c20746d9780da3cf46aaf448a777e229a5b3cdf3a4792e8ef82cda9c5d46e354a9a598
Diffstat (limited to 'src')
-rw-r--r--src/wallet/sqlite.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/wallet/sqlite.cpp b/src/wallet/sqlite.cpp
index 2e60aca017..815d17967c 100644
--- a/src/wallet/sqlite.cpp
+++ b/src/wallet/sqlite.cpp
@@ -212,6 +212,10 @@ void SQLiteDatabase::Open()
if (ret != SQLITE_OK) {
throw std::runtime_error(strprintf("SQLiteDatabase: Failed to open database: %s\n", sqlite3_errstr(ret)));
}
+ ret = sqlite3_extended_result_codes(m_db, 1);
+ if (ret != SQLITE_OK) {
+ throw std::runtime_error(strprintf("SQLiteDatabase: Failed to enable extended result codes: %s\n", sqlite3_errstr(ret)));
+ }
}
if (sqlite3_db_readonly(m_db, "main") != 0) {