sqlbox_trans_commit, sqlbox_trans_rollbackend a database transaction

library “sqlbox”

#include <stdint.h>
#include <sqlbox.h>

sqlbox_trans_commit(struct sqlbox *box, size_t srcid, size_t id);

sqlbox_trans_rollback(struct sqlbox *box, size_t srcid, size_t id);

The () and () functions close a transaction identified as non-zero id previously opened with the sqlbox_trans_immediate(3) family on source srcid as returned by sqlbox_open(3). If srcid is zero, the last-opened database is used.

These functions differ in that () will commit all statements subsequent to beginning the transaction and () will discard them.

It is an error to sqlbox_close(3) a database without first rolling back or committing open transactions.

Runs sqlite3_exec(3) using the COMMIT or ROLLBACK statements with the type depending on the invocation. Randomly backs off on return of SQLITE_BUSY, SQLITE_LOCKED, or SQLITE_PROTOCOL, and returns failure on anything else other than SQLITE_OK.

Returns zero if communication with box fails. Otherwise, returns non-zero.

If ending the transaction fails (not open, different transaction already open, source not found, database errors, id or srcid are zero), subsequent box access will fail. Use sqlbox_ping(3) to check explicitly.

If these functions fail, box is no longer accessible beyond sqlbox_ping(3) and sqlbox_free(3).

sqlbox_open(3), sqlbox_ping(3)

December 2, 2023 OpenBSD 7.4