Berkeley DB: txn_prepare
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_prepare

`

###

    #include <db.h>

    int
    txn_prepare(DB_TXN *tid);

# Description

The txn_prepare function initiates the beginning of a two-phase commit.

In a distributed transaction environment, Berkeley DB can be used as a local transaction manager. In this case, the distributed transaction manager must send prepare messages to each local manager. The local manager must then issue a txn_prepare and await its successful return before responding to the distributed transaction manager. Only after the distributed transaction manager receives successful responses from all of its prepare messages should it issue any commit messages.

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

# Errors

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

The txn_prepare 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), getpid(3), log_put, malloc(3), memcpy(3), memset(3), strerror(3), vfprintf(3), and vsnprintf(3).

# See Also

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