Berkeley DB Reference Guide:
Programmer Notes

PrevRefNext

Berkeley DB handles

The Berkeley DB library has a number of object handles. The following table lists those handles, their scope, and whether they are free-threaded (that is, whether multiple threads within a process can share them).

DB_ENV
The DB_ENV handle, created by the db_env_create function, refers to a Berkeley DB database environment -- a collection of Berkeley DB subsystems, log files and databases. DB_ENV handles are free-threaded if the DB_THREAD flag is specified to the DB_ENV->open function when the environment is opened. The handle should not be closed while any other handle remains open that is using it as a reference (for example, DB or DB_TXN). Once either the DB_ENV->close or DB_ENV->remove functions are called, the handle may not be accessed again, regardless of the function's return.

DB_TXN
The DB_TXN handle, created by the txn_begin function, refers to a single transaction. The handle is not free-threaded; and transactions may not span threads, nor may transactions be used by more than a single thread. Once the txn_abort or txn_commit functions are called, the handle may not be accessed again, regardless of the function's return. In addition, parent transactions may not issue any Berkeley DB operations while they have active child transactions (child transactions that have not yet been committed or aborted) except for txn_begin, txn_abort and txn_commit.

DB_MPOOLFILE
The DB_MPOOLFILE handle refers to an open file in the shared memory buffer pool of the database environment. The handle is not free-threaded. Once the memp_fclose function is called, the handle may not be accessed again, regardless of the function's return.

DB
The DB handle, created by the db_create function, refers to a single Berkeley DB database, which may or may not be part of a database environment. DB handles are free-threaded if the DB_THREAD flag is specified to the DB->open function when the database is opened or if the database environment in which the database is opened is free-threaded. The handle should not be closed while any other handle that refers to the database is in use; for example, database handles must not be closed while cursor handles into the database remain open, or transactions that include operations on the database have not yet been committed or aborted. Once the DB->close, DB->remove, or DB->rename functions are called, the handle may not be accessed again, regardless of the function's return.

DBC
The DBC handle refers to a cursor into a Berkeley DB database. The handle is not free-threaded, and cursors may not span threads; nor may cursors be used by more than a single thread. If the cursor is to be used to perform operations on behalf of a transaction, the cursor must be opened and closed within the context of that single transaction. Once DBcursor->c_close has been called, the handle may not be accessed again, regardless of the function's return.

PrevRefNext

Copyright Sleepycat Software