MCPcopy Create free account
hub / github.com/ElementsProject/elements / ReadPragmaInteger

Function ReadPragmaInteger

src/wallet/sqlite.cpp:40–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38}
39
40static std::optional<int> ReadPragmaInteger(sqlite3* db, const std::string& key, const std::string& description, bilingual_str& error)
41{
42 std::string stmt_text = strprintf("PRAGMA %s", key);
43 sqlite3_stmt* pragma_read_stmt{nullptr};
44 int ret = sqlite3_prepare_v2(db, stmt_text.c_str(), -1, &pragma_read_stmt, nullptr);
45 if (ret != SQLITE_OK) {
46 sqlite3_finalize(pragma_read_stmt);
47 error = Untranslated(strprintf("SQLiteDatabase: Failed to prepare the statement to fetch %s: %s", description, sqlite3_errstr(ret)));
48 return std::nullopt;
49 }
50 ret = sqlite3_step(pragma_read_stmt);
51 if (ret != SQLITE_ROW) {
52 sqlite3_finalize(pragma_read_stmt);
53 error = Untranslated(strprintf("SQLiteDatabase: Failed to fetch %s: %s", description, sqlite3_errstr(ret)));
54 return std::nullopt;
55 }
56 int result = sqlite3_column_int(pragma_read_stmt, 0);
57 sqlite3_finalize(pragma_read_stmt);
58 return result;
59}
60
61static void SetPragma(sqlite3* db, const std::string& key, const std::string& value, const std::string& err_msg)
62{

Callers 1

VerifyMethod · 0.85

Calls 1

UntranslatedFunction · 0.85

Tested by

no test coverage detected