## Transaction Commands

Transactions are used in a manner similar to the other subsystems. We create a handle to the transaction and then use it for a variety of operations. Some of the transaction commands use the environment instead. Those are presented first. The transaction command handle returned is the handle used by the various commands that can be transaction protected, such as cursors.

> <env> txn_checkpoint [-kbyte kb] [-min min]

This command causes a checkpoint of the transaction region. It is a direct translation of the txn_checkpoint function. It returns either a 0 (for success), a DB error message or it throws a Tcl error with a system message. The arguments are:

- -kbyte causes the checkpoint to occur only if kb kilobytes of log data has been written since the last checkpoint
- -min causes the checkpoint to occur only if min minutes have passed since the last checkpoint

> <env> txn_stat

This command returns transaction statistics. It is a direct translation of the txn_stat function. It will return a list of name/value pairs that correspond to the DB_TXN_STAT structure.

> <txn> id

This command returns the transaction id. It is a direct call to the txn_id function. The typical use of this identifier is as the locker value for the lock_get and lock_vec calls.

> <txn> prepare

This command initiates a two-phase commit. It is a direct call to the txn_prepare function. It returns either a 0 (for success), a DB error message or it throws a Tcl error with a system message.