10 class set_to_null_when_done {
12 explicit set_to_null_when_done(
sqlite3*& db) noexcept : db_{db} {}
13 ~set_to_null_when_done() noexcept { db_ =
nullptr; }
23 int const rc{sqlite3_exec(db_,
"BEGIN;",
nullptr,
nullptr,
nullptr)};
24 if (
rc != SQLITE_OK) {
26 <<
"Failed to start SQLite transaction due to status code " <<
rc <<
":\n" 27 << sqlite3_errmsg(db_) <<
'\n';
36 sqlite3_exec(db_,
"ROLLBACK;",
nullptr,
nullptr,
nullptr);
37 std::cerr <<
"Transaction d'tor called before commit was called.\n";
45 set_to_null_when_done sentry{db_};
46 int const rc{sqlite3_exec(db_,
"COMMIT;",
nullptr,
nullptr,
nullptr)};
47 if (
rc != SQLITE_OK) {
49 <<
"Failed to commit SQLite transaction due to status code " <<
rc 51 << sqlite3_errmsg(db_) <<
'\n';
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Transaction(sqlite3 *db) noexcept(false)
void commit() noexcept(false)