![]() |
OpenSWMM Engine
6.0.0-alpha.4
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.4)
|
Noncopyable best-effort transaction guard borrowing one SQLite connection. More...
#include <GpkgUtils.hpp>
Public Member Functions | |
| Transaction (sqlite3 *db) | |
| Borrow a connection and begin an immediate write transaction. | |
| void | commit () |
| Commit an unfinished transaction and mark the guard finished. | |
| void | rollback () |
| Best-effort reset all live statements and roll back an unfinished transaction. | |
| ~Transaction () | |
| Attempt best-effort rollback unless already committed/rolled back. | |
| Transaction (const Transaction &)=delete | |
| Disallow copying one transaction cleanup responsibility. | |
| Transaction & | operator= (const Transaction &)=delete |
| Disallow copy replacement of a transaction guard. | |
Noncopyable best-effort transaction guard borrowing one SQLite connection.
Commits explicitly and otherwise rolls back on destruction. This is not a rollback-success guarantee: rollback() marks completion after a bounded retry loop even if SQLite remains in a transaction.
|
inlineexplicit |
Borrow a connection and begin an immediate write transaction.
Connection must outlive the guard and have no incompatible active transaction. Constructor invokes exec(BEGIN IMMEDIATE), which can wait under the connection busy policy or throw GpkgError. Do not concurrently use transaction control on this connection.
| [in] | db | Non-null live SQLite connection borrowed for this call; caller serializes transaction/statement use. |
|
inline |
Attempt best-effort rollback unless already committed/rolled back.
Uses rollback() and therefore may reset every statement on the borrowed connection. Does not close the connection or report rollback refusal.
|
delete |
Disallow copying one transaction cleanup responsibility.
|
inline |
Commit an unfinished transaction and mark the guard finished.
Already-finished guard is a no-op. Failure throws GpkgError and leaves finished_ false so rollback remains possible; the guard does not begin a replacement transaction.
|
delete |
Disallow copy replacement of a transaction guard.
|
inline |
Best-effort reset all live statements and roll back an unfinished transaction.
Up to three attempts: resets EVERY statement on the borrowed connection, issues ROLLBACK, then checks autocommit. Marks finished even if all attempts fail; no failure status is returned. Can disrupt other statement cursors, so the guard requires exclusive connection control. Already-finished is a no-op.