SQLBOX_TRANS_COMMIT(3)

NAME
sqlbox_trans_commit, sqlbox_trans_rollback - end a database transaction

LIBRARY
sqlbox

SYNOPSIS
#include <stdint.h>
#include <sqlbox.h>
int
sqlbox_trans_commit(struct sqlbox *box, size_t srcid, size_t id);
int
sqlbox_trans_rollback(struct sqlbox *box, size_t srcid, size_t id);

DESCRIPTION
The sqlbox_trans_commit() and sqlbox_trans_rollback() 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 sqlbox_trans_commit() will commit all statements subsequent to beginning the transaction and sqlbox_trans_rollback() will discard them.

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

  SQLite3 Implementation
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.

RETURN VALUES
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).

SEE ALSO
sqlbox_open(3), sqlbox_ping(3)