)I<Berkeley DB: Berkeley DB Database Environment[P)

Berkeley DB Database Environment


EThe database access methods make calls to the other subsystems in theBerkeley DB libraryjbased on the dbenv argument to db_open which is a pointer toFa structure of type DB_ENV. Applications normally use the same DB_ENVkstructure (initialized by db_appinit) as an argument to all of*the subsystems in the Berkeley DB package.

OReferences to the DB_ENV structure are maintained by Berkeley DB, so it may notDbe discarded until the last close function, corresponding to an open?function for which it was an argument, has returned. To ensureKcompatibility with future releases of Berkeley DB, all fields of the DB_ENVGstructure that are not explicitly set should be initialized to 0 beforeIthe first time the structure is used. Do this by declaring the structure?external or static, or by calling one of the C library routines$bzero(3) or memset(3).

nThe fields of the DB_ENV structure used by db_open are described below.CIf dbenv is NULL or any of its fields are set to 0, defaults3appropriate for the system are used where possible.

FThe following fields in the DB_ENV structure may be initialized before7calling db_open:

Z

DB_LOG *lg_info;
If modifications to the file being opened should be logged, the>lg_info field contains a return value from the function3log_open.PIf lg_info is NULL, no logging is done by the Berkeley DB access methods._

DB_LOCKTAB *lk_info;
If locking is required for the file being opened (as is the caseDwhen multiple processes or threads are accessing the same file), the>lk_info field contains a return value from the function8lock_open.PIf lk_info is NULL, no locking is done by the Berkeley DB access methods.

@If both locking and transactions are being performed (i.e., both@lk_info and tx_info are non-NULL), the transaction!ID will be used as the locker ID.aIf only locking is being performed, db_open will acquire ailocker ID from lock_id and will use it for all locks requiredDfor this instance of db_open.d

DB_MPOOL *mp_info;
If the cache for the file being opened should be maintained in a sharedFbuffer pool, the mp_info field contains a return value from the?function memp_open.MIf mp_info is NULL, a memory pool may still be created by Berkeley DB,Nbut it will be private to the application and entirely managed by Berkeley DB.g

DB_TXNMGR *tx_info;
If the accesses to the file being opened should take place in the contextLof transactions (providing atomicity and error recovery), the tx_info/field contains a return value from the function6txn_open.HIf transactions are specified, the application is responsible for makingƒsuitable calls to txn_begin, txn_abort andjtxn_commit. If tx_info is NULL, no transaction support*is done by the Berkeley DB access methods.

BWhen the access methods are used in conjunction with transactions,gthe application must abort the transaction (using txn_abort)>if any of the transaction protected access method calls (i.e.,4any calls other than open, close and sync) returns a:system error'(e.g., deadlock, which returns EAGAIN).


ÿÿ