| 59 | } |
| 60 | |
| 61 | static 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 | |
| 81 | static std::optional<int> ReadPragmaInteger(sqlite3* db, const std::string& key, const std::string& description, bilingual_str& error) |
| 82 | { |
no test coverage detected