Berkeley DB: txn_begin
Description: Berkeley DB: An embedded database programmatic toolkit.
Keywords: embedded,database,programmatic,toolkit,b+tree,btr ee,hash,hashing,transaction,transactions,locking,logging,access method,access me thods,java,C,C++

# txn_begin

`

###

    #include <db.h>

    int
    txn_begin(DB_TXNMGR *txnp, DB_TXN *pid, DB_TXN **tid);

# Description

The txn_begin method creates a new transaction in the transaction manager, copying a pointer to a DB_TXN that uniquely identifies it into the memory referenced by tid.

Note: transactions may not span threads, i.e., each transaction must begin and end in the same thread, and each transaction may only be used by a single thread.

Note: transactions may not span cursors, i.e., each transaction may only be used by a single cursor.

Note: transactions may not currently be nested. In a future revision of Berkeley DB, if the pid argument is non-NULL, the new transaction will be a nested transaction, with the transaction indicated by pid as its parent.

The txn_begin function returns the value of errno on failure, and 0 on success.

# Errors

If a fatal error occurs in Berkeley DB, the txn_begin function may fail and return DB_RUNRECOVERY, at which point all subsequent database calls will also return DB_RUNRECOVERY.

The txn_begin function may fail and return errno for any of the errors specified for the following Berkeley DB and C library functions: abort(3), fcntl(3), fflush(3), fprintf(3), free(3), fsync(3), getpid(3), log_put, lseek(3), memset(3), mmap(3), munmap(3), shmat(3), shmdt(3), strerror(3), vfprintf(3), vsnprintf(3), and write(3).

In addition, the txn_begin function may fail and return errno for the following conditions:

ENOSPC
  The maximum number of concurrent transactions has been reached.

# See Also

txn_abort, txn_begin, txn_checkpoint, txn_close, txn_commit, txn_id, txn_open, txn_prepare, txn_stat and txn_unlink.`