<!--$Id: scope.so,v 10.12 2007/06/14 17:41:59 bostic Exp $--> <!--Copyright (c) 1997,2007 Oracle. All rights reserved.--> <!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB Reference Guide: Berkeley DB handles</title> <meta name="description" content="Berkeley DB: An embedded database programmatic toolkit."> <meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++"> </head> <body bgcolor=white> <a name="2"><!--meow--></a><a name="3"><!--meow--></a> <table width="100%"><tr valign=top> <td><h3><dl><dt>Berkeley DB Reference Guide:<dd>Programmer Notes</dl></h3></td> <td align=right><a href="../program/mt.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../toc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../program/namespace.html"><img src="../../images/next.gif" alt="Next"></a> </td></tr></table> <p> <h3 align=center>Berkeley DB handles</h3> <p>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).</p> <dl compact> <dt><a href="../../api_c/env_class.html">DB_ENV</a><dd>The <a href="../../api_c/env_class.html">DB_ENV</a> handle, created by the <a href="../../api_c/env_class.html">db_env_create</a> method, refers to a Berkeley DB database environment -- a collection of Berkeley DB subsystems, log files and databases. <a href="../../api_c/env_class.html">DB_ENV</a> handles are free-threaded if the <a href="../../api_c/env_open.html#DB_THREAD">DB_THREAD</a> flag is specified to the <a href="../../api_c/env_open.html">DB_ENV->open</a> method 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, <a href="../../api_c/db_class.html">DB</a> or <a href="../../api_c/txn_class.html">DB_TXN</a>). Once either the <a href="../../api_c/env_close.html">DB_ENV->close</a> or <a href="../../api_c/env_remove.html">DB_ENV->remove</a> methods are called, the handle may not be accessed again, regardless of the method's return. <dt><a href="../../api_c/txn_class.html">DB_TXN</a><dd>The <a href="../../api_c/txn_class.html">DB_TXN</a> handle, created by the <a href="../../api_c/txn_begin.html">DB_ENV->txn_begin</a> method, refers to a single transaction. The handle is not free-threaded. Transactions may span threads, but only serially, that is, the application must serialize access to the <a href="../../api_c/txn_class.html">DB_TXN</a> handles. In the case of nested transactions, since all child transactions are part of the same parent transaction, they must observe the same constraints. That is, children may execute in different threads only if each child executes serially. <p>Once the <a href="../../api_c/txn_abort.html">DB_TXN->abort</a> or <a href="../../api_c/txn_commit.html">DB_TXN->commit</a> methods are called, the handle may not be accessed again, regardless of the method'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 <a href="../../api_c/txn_begin.html">DB_ENV->txn_begin</a>, <a href="../../api_c/txn_abort.html">DB_TXN->abort</a> and <a href="../../api_c/txn_commit.html">DB_TXN->commit</a>.</p> <dt><a href="../../api_c/logc_class.html">DB_LOGC</a><dd>The <a href="../../api_c/logc_class.html">DB_LOGC</a> handle refers to a cursor into the log files. The handle is not free-threaded. Once the <a href="../../api_c/logc_close.html">DB_LOGC->close</a> method is called, the handle may not be accessed again, regardless of the method's return. <dt><a href="../../api_c/mempfile_class.html">DB_MPOOLFILE</a><dd>The <a href="../../api_c/mempfile_class.html">DB_MPOOLFILE</a> handle refers to an open file in the shared memory buffer pool of the database environment. The handle is not free-threaded. Once the <a href="../../api_c/memp_fclose.html">DB_MPOOLFILE->close</a> method is called, the handle may not be accessed again, regardless of the method's return. <dt><a href="../../api_c/db_class.html">DB</a><dd>The <a href="../../api_c/db_class.html">DB</a> handle, created by the <a href="../../api_c/db_class.html">db_create</a> method, refers to a single Berkeley DB database, which may or may not be part of a database environment. <a href="../../api_c/db_class.html">DB</a> handles are free-threaded if the <a href="../../api_c/env_open.html#DB_THREAD">DB_THREAD</a> flag is specified to the <a href="../../api_c/db_open.html">DB->open</a> method 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 should be left open 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 <a href="../../api_c/db_close.html">DB->close</a>, <a href="../../api_c/db_remove.html">DB->remove</a>, or <a href="../../api_c/db_rename.html">DB->rename</a> methods are called, the handle may not be accessed again, regardless of the method's return. <dt><a href="../../api_c/dbc_class.html">DBC</a><dd>The <a href="../../api_c/dbc_class.html">DBC</a> handle refers to a cursor into a Berkeley DB database. The handle is not free-threaded. Cursors may span threads, but only serially, that is, the application must serialize access to the <a href="../../api_c/dbc_class.html">DBC</a> handles. 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 <a href="../../api_c/dbc_close.html">DBcursor->close</a> has been called, the handle may not be accessed again, regardless of the method's return. </dl> <table width="100%"><tr><td><br></td><td align=right><a href="../program/mt.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../toc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../program/namespace.html"><img src="../../images/next.gif" alt="Next"></a> </td></tr></table> <p><font size=1>Copyright (c) 1996,2007 Oracle. All rights reserved.</font> </body> </html>