MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / BindBlobToStatement

Function BindBlobToStatement

src/wallet/sqlite.cpp:61–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59}
60
61static bool BindBlobToStatement(sqlite3_stmt* stmt,
62 int index,
63 std::span<const std::byte> blob,
64 const std::string& description)
65{
66 // Pass a pointer to the empty string "" below instead of passing the
67 // blob.data() pointer if the blob.data() pointer is null. Passing a null
68 // data pointer to bind_blob would cause sqlite to bind the SQL NULL value
69 // instead of the empty blob value X'', which would mess up SQL comparisons.
70 int res = sqlite3_bind_blob(stmt, index, blob.data() ? static_cast<const void*>(blob.data()) : "", blob.size(), SQLITE_STATIC);
71 if (res != SQLITE_OK) {
72 LogWarning("Unable to bind %s to statement: %s", description, sqlite3_errstr(res));
73 sqlite3_clear_bindings(stmt);
74 sqlite3_reset(stmt);
75 return false;
76 }
77
78 return true;
79}
80
81static std::optional<int> ReadPragmaInteger(sqlite3* db, const std::string& key, const std::string& description, bilingual_str& error)
82{

Callers 5

ReadKeyMethod · 0.85
WriteKeyMethod · 0.85
ExecStatementMethod · 0.85
HasKeyMethod · 0.85
GetNewPrefixCursorMethod · 0.85

Calls 2

dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected