Skip to content

Commit 80b4e8f

Browse files
committed
Merge bitcoin/bitcoin#23112: wallet: enable SQLite extended result codes
90be29c 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 90be29c laanwj: Code review ACK 90be29c Tree-SHA512: 2b7a60860c206f2b5f8ff9d4a7698efdee897c9ad024621b8fd165b841c20746d9780da3cf46aaf448a777e229a5b3cdf3a4792e8ef82cda9c5d46e354a9a598
2 parents 81e7748 + 90be29c commit 80b4e8f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/wallet/sqlite.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,10 @@ void SQLiteDatabase::Open()
212212
if (ret != SQLITE_OK) {
213213
throw std::runtime_error(strprintf("SQLiteDatabase: Failed to open database: %s\n", sqlite3_errstr(ret)));
214214
}
215+
ret = sqlite3_extended_result_codes(m_db, 1);
216+
if (ret != SQLITE_OK) {
217+
throw std::runtime_error(strprintf("SQLiteDatabase: Failed to enable extended result codes: %s\n", sqlite3_errstr(ret)));
218+
}
215219
}
216220

217221
if (sqlite3_db_readonly(m_db, "main") != 0) {

0 commit comments

Comments
 (0)