m4_comment([$Id: txn_begin.so,v 10.80 2006/12/13 18:09:09 bostic Exp $]) define(M4PAGELOCAL, [txn_begin, DB_READ_COMMITTED, DB_READ_UNCOMMITTED, DB_TXN_NOSYNC, DB_TXN_NOWAIT, DB_TXN_NOWAIT, DB_TXN_SNAPSHOT, DB_TXN_SYNC, DB_TXN_WAIT, DB_TXN_WRITE_NOSYNC]) include(m4/m4.seealso) m4_pf_header(m4_ref(txn_begin), ifelse(M4API, C_API, [dnl int DB_ENV-__GT__txn_begin(DB_ENV *env, DB_TXN *parent, DB_TXN **tid, u_int32_t flags); ]) ifelse(M4API, CXX_API, [dnl int DbEnv::txn_begin(DbTxn *parent, DbTxn **tid, u_int32_t flags); ])) m4_p([dnl The m4_ref(txn_begin) method creates a new transaction in the environment and copies a pointer to a m4_ref(DbTxn) that uniquely identifies it into the memory to which m4_arg(tid) refers. Calling the m4_ref(txn_abort), m4_ref(txn_commit) or m4_refT(txn_discard)s will discard the returned handle.]) m4_p([m4_bold([dnl Note: Transactions may only span threads if they do so serially; that is, each transaction must be active in only a single thread of control at a time. This restriction holds for parents of nested transactions as well; no two children may be concurrently active in more than one thread of control at any one time.])]) m4_p([m4_bold([dnl Note: Cursors may not span transactions; that is, each cursor must be opened and closed within a single transaction.])]) m4_p([m4_bold([dnl Note: A parent transaction may not issue any m4_db operations -- except for m4_ref(txn_begin), m4_ref(txn_abort) and m4_ref(txn_commit) -- while it has active child transactions (child transactions that have not yet been committed or aborted).])]) m4_return(txn_begin, std) m4_parambegin m4_param(flags, [dnl m4_sf_or_may m4_tagbegin m4_tag(m4_idef(DB_READ_COMMITTED), [dnl This transaction will have degree 2 isolation. This provides for cursor stability but not repeatable reads. Data items which have been previously read by this transaction may be deleted or modified by other transactions before this transaction completes.]) m4_tag(m4_idef(DB_READ_UNCOMMITTED), [dnl This transaction will have degree 1 isolation. Read operations performed by the transaction may read modified but not yet committed data. Silently ignored if the m4_ref(DB_READ_UNCOMMITTED) flag was not specified when the underlying database was opened.]) m4_tag(m4_idef(DB_TXN_NOSYNC), [dnl Do not synchronously flush the log when this transaction commits or prepares. This means the transaction will exhibit the ACI (atomicity, consistency, and isolation) properties, but not D (durability); that is, database integrity will be maintained but it is possible that this transaction may be undone during recovery. m4_p([dnl This behavior may be set for a m4_db environment using the m4_refT(dbenv_set_flags). Any value specified to this method overrides that setting.])]) m4_tag(m4_idef(DB_TXN_NOWAIT), [dnl If a lock is unavailable for any m4_db operation performed in the context of this transaction, cause the operation to ifelse(M4EXCEPT, return_only, [dnl return m4_ref(DB_LOCK_DEADLOCK) (or m4_ref(DB_LOCK_NOTGRANTED) if the database environment has been configured using the m4_ref(DB_TIME_NOTGRANTED) flag).],[dnl either return m4_ref(DB_LOCK_DEADLOCK) or throw a m4_ref(DbDeadlockException) exception (or return m4_ref(DB_LOCK_NOTGRANTED) or throw a m4_ref(DbLockNotGrantedException) exception if the database environment has been configured using the m4_ref(DB_TIME_NOTGRANTED) flag).]) m4_p([dnl This behavior may be set for a m4_db environment using the m4_refT(dbenv_set_flags). Any value specified to this method overrides that setting.])]) m4_tag(m4_idef(DB_TXN_SNAPSHOT), [dnl This transaction will execute with m4_link(M4RELDIR/ref/transapp/read, snapshot isolation). For databases with the m4_ref(DB_MULTIVERSION) flag set, data values will be read as they are when the transaction begins, without taking read locks. Silently ignored for operations on databases with m4_ref(DB_MULTIVERSION) not set on the underlying database (read locks are acquired). m4_p([dnl The error m4_idef(DB_LOCK_DEADLOCK) will be returned from update operations if a snapshot transaction attempts to update data which was modified after the snapshot transaction read it.])]) m4_tag(m4_idef(DB_TXN_SYNC), [dnl Synchronously flush the log when this transaction commits or prepares. This means the transaction will exhibit all of the ACID (atomicity, consistency, isolation, and durability) properties. m4_p([dnl This behavior is the default for m4_db environments unless the m4_ref(DB_TXN_NOSYNC) flag was specified to the m4_refT(dbenv_set_flags). Any value specified to this method overrides that setting.])]) m4_tag(m4_idef(DB_TXN_WAIT), [dnl If a lock is unavailable for any m4_db operation performed in the context of this transaction, wait for the lock. m4_p([dnl This behavior is the default for m4_db environments unless the m4_ref(DB_TXN_NOWAIT) flag was specified to the m4_refT(dbenv_set_flags). Any value specified to this method overrides that setting.])]) m4_tag(m4_idef(DB_TXN_WRITE_NOSYNC), [dnl Write, but do not synchronously flush, the log when this transaction commits. This means the transaction will exhibit the ACI (atomicity, consistency, and isolation) properties, but not D (durability); that is, database integrity will be maintained, but if the system fails, it is possible some number of the most recently committed transactions may be undone during recovery. The number of transactions at risk is governed by how often the system flushes dirty buffers to disk and how often the log is flushed or checkpointed. m4_p([dnl This behavior may be set for a m4_db environment using the m4_refT(dbenv_set_flags). Any value specified to this method overrides that setting.])]) m4_tagend]) m4_param(parent, [dnl If the m4_arg(parent) parameter is non-NULL, the new transaction will be a nested transaction, with the transaction indicated by m4_arg(parent) as its parent. Transactions may be nested to any level. In the presence of distributed transactions and two-phase commit, only the parental transaction, that is a transaction without a m4_arg(parent) specified, should be passed as an parameter to m4_ref(txn_prepare).]) m4_paramend m4_err(txn_begin, memory, [maximum number of concurrent transactions has been reached]) m4_seealso(DbTxn) m4_page_footer