| 1 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> |
| 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 3 | <html xmlns="http://www.w3.org/1999/xhtml"> |
| 4 | <head> |
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
| 6 | <title>Berkeley DB handles</title> |
| 7 | <link rel="stylesheet" href="gettingStarted.css" type="text/css" /> |
| 8 | <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /> |
| 9 | <link rel="start" href="index.html" title="Berkeley DB Programmer's Reference Guide" /> |
| 10 | <link rel="up" href="program.html" title="Chapter 15. Programmer Notes" /> |
| 11 | <link rel="prev" href="program_mt.html" title="Multithreaded applications" /> |
| 12 | <link rel="next" href="program_namespace.html" title="Name spaces" /> |
| 13 | </head> |
| 14 | <body> |
| 15 | <div xmlns="" class="navheader"> |
| 16 | <div class="libver"> |
| 17 | <p>Library Version 11.2.5.3</p> |
| 18 | </div> |
| 19 | <table width="100%" summary="Navigation header"> |
| 20 | <tr> |
| 21 | <th colspan="3" align="center">Berkeley DB handles</th> |
| 22 | </tr> |
| 23 | <tr> |
| 24 | <td width="20%" align="left"><a accesskey="p" href="program_mt.html">Prev</a> </td> |
| 25 | <th width="60%" align="center">Chapter 15. |
| 26 | Programmer Notes |
| 27 | </th> |
| 28 | <td width="20%" align="right"> <a accesskey="n" href="program_namespace.html">Next</a></td> |
| 29 | </tr> |
| 30 | </table> |
| 31 | <hr /> |
| 32 | </div> |
| 33 | <div class="sect1" lang="en" xml:lang="en"> |
| 34 | <div class="titlepage"> |
| 35 | <div> |
| 36 | <div> |
| 37 | <h2 class="title" style="clear: both"><a id="program_scope"></a>Berkeley DB handles</h2> |
| 38 | </div> |
| 39 | </div> |
| 40 | </div> |
| 41 | <p>The Berkeley DB library has a number of object handles. The following table |
| 42 | lists those handles, their scope, and whether they are free-threaded |
| 43 | (that is, whether multiple threads within a process can share them).</p> |
| 44 | <div class="variablelist"> |
| 45 | <dl> |
| 46 | <dt> |
| 47 | <span class="term"> |
| 48 | <a href="../api_reference/C/env.html" class="olink">DB_ENV</a> |
| 49 | </span> |
| 50 | </dt> |
| 51 | <dd> |
| 52 | <p> |
| 53 | The <a href="../api_reference/C/env.html" class="olink">DB_ENV</a> handle, created by the <a href="../api_reference/C/envcreate.html" class="olink">db_env_create()</a> method, refers |
| 54 | to a Berkeley DB database environment — a collection |
| 55 | of Berkeley DB subsystems, log files and databases. <a href="../api_reference/C/env.html" class="olink">DB_ENV</a> |
| 56 | handles are free-threaded if the <a href="../api_reference/C/envopen.html#envopen_DB_THREAD" class="olink">DB_THREAD</a> flag is specified |
| 57 | to the <a href="../api_reference/C/envopen.html" class="olink">DB_ENV->open()</a> method when the |
| 58 | environment is opened. The handle should not be closed |
| 59 | while any other handle remains open that is using it as a |
| 60 | reference (for example, <a href="../api_reference/C/db.html" class="olink">DB</a>, <a href="../api_reference/C/txn.html" class="olink">TXN</a>). Once either the |
| 61 | <a href="../api_reference/C/envclose.html" class="olink">DB_ENV->close()</a> or <a href="../api_reference/C/envremove.html" class="olink">DB_ENV->remove()</a> methods |
| 62 | are called, the handle may not be accessed again, |
| 63 | regardless of the method's return. |
| 64 | </p> |
| 65 | </dd> |
| 66 | <dt> |
| 67 | <span class="term"> |
| 68 | <a href="../api_reference/C/txn.html" class="olink">TXN</a> |
| 69 | </span> |
| 70 | </dt> |
| 71 | <dd> |
| 72 | <p> |
| 73 | The <a href="../api_reference/C/txn.html" class="olink">TXN</a> handle, created by the <a href="../api_reference/C/txnbegin.html" class="olink">DB_ENV->txn_begin()</a> method, refers to a |
| 74 | single transaction. The handle is not free-threaded. |
| 75 | Transactions may span threads, but only serially, that is, the |
| 76 | application must serialize access to the <a href="../api_reference/C/txn.html" class="olink">TXN</a> handles. In the |
| 77 | case of nested transactions, since all child transactions are |
| 78 | part of the same parent transaction, they must observe the same |
| 79 | constraints. That is, children may execute in different threads |
| 80 | only if each child executes serially. |
| 81 | </p> |
| 82 | <p> |
| 83 | Once the <a href="../api_reference/C/txnabort.html" class="olink">DB_TXN->abort()</a> or <a href="../api_reference/C/txncommit.html" class="olink">DB_TXN->commit()</a> methods are called, the |
| 84 | handle may not be accessed again, regardless of the method's |
| 85 | return. In addition, parent transactions may not issue any |
| 86 | Berkeley DB operations while they have active child |
| 87 | transactions (child transactions that have not yet been |
| 88 | committed or aborted) except for <a href="../api_reference/C/txnbegin.html" class="olink">DB_ENV->txn_begin()</a>, <a href="../api_reference/C/txnabort.html" class="olink">DB_TXN->abort()</a> and |
| 89 | <a href="../api_reference/C/txncommit.html" class="olink">DB_TXN->commit()</a>. |
| 90 | </p> |
| 91 | </dd> |
| 92 | <dt> |
| 93 | <span class="term"> |
| 94 | <a href="../api_reference/C/logc.html" class="olink">DB_LOGC</a> |
| 95 | </span> |
| 96 | </dt> |
| 97 | <dd> |
| 98 | <p> |
| 99 | The <a href="../api_reference/C/logc.html" class="olink">DB_LOGC</a> handle refers to a cursor into the log files. The |
| 100 | handle is not free-threaded. Once the <a href="../api_reference/C/logcclose.html" class="olink">DB_LOGC->close()</a> method is |
| 101 | called, the handle may not be accessed again, regardless of the |
| 102 | method's return. |
| 103 | </p> |
| 104 | </dd> |
| 105 | <dt> |
| 106 | <span class="term"> |
| 107 | <a href="../api_reference/C/memp.html" class="olink">DB_MPOOLFILE</a> |
| 108 | </span> |
| 109 | </dt> |
| 110 | <dd> |
| 111 | <p> |
| 112 | The <a href="../api_reference/C/memp.html" class="olink">DB_MPOOLFILE</a> handle refers to an open file in the shared memory |
| 113 | buffer pool of the database environment. The handle is not |
| 114 | free-threaded. Once the <a href="../api_reference/C/mempfclose.html" class="olink">DB_MPOOLFILE->close()</a> method is called, the |
| 115 | handle may not be accessed again, regardless of the method's |
| 116 | return. |
| 117 | </p> |
| 118 | </dd> |
| 119 | <dt> |
| 120 | <span class="term"> |
| 121 | <a href="../api_reference/C/db.html" class="olink">DB</a> |
| 122 | </span> |
| 123 | </dt> |
| 124 | <dd> |
| 125 | <p> |
| 126 | The <a href="../api_reference/C/db.html" class="olink">DB</a> handle, created by the <a href="../api_reference/C/dbcreate.html" class="olink">db_create()</a> method, refers to a |
| 127 | single Berkeley DB database, which may or may not be part of a |
| 128 | database environment. <a href="../api_reference/C/db.html" class="olink">DB</a> handles are free-threaded if the |
| 129 | <a href="../api_reference/C/dbopen.html#open_DB_THREAD" class="olink">DB_THREAD</a> flag is specified to the <a href="../api_reference/C/dbopen.html" class="olink">DB->open()</a> method when the |
| 130 | database is opened or if the database environment in which the |
| 131 | database is opened is free-threaded. The handle should not be |
| 132 | closed while any other handle that refers to the database is in |
| 133 | use; for example, database handles should be left open while |
| 134 | cursor handles into the database remain open, or transactions |
| 135 | that include operations on the database have not yet been |
| 136 | committed or aborted. Once the <a href="../api_reference/C/dbclose.html" class="olink">DB->close()</a>, <a href="../api_reference/C/dbremove.html" class="olink">DB->remove()</a> or |
| 137 | <a href="../api_reference/C/dbrename.html" class="olink">DB->rename()</a> methods are called, the handle may not be accessed |
| 138 | again, regardless of the method's return. |
| 139 | </p> |
| 140 | </dd> |
| 141 | <dt> |
| 142 | <span class="term"> |
| 143 | <a href="../api_reference/C/dbc.html" class="olink">DBC</a> |
| 144 | </span> |
| 145 | </dt> |
| 146 | <dd> |
| 147 | <p> |
| 148 | The <a href="../api_reference/C/dbc.html" class="olink">DBC</a> handle refers to a cursor into a Berkeley DB |
| 149 | database. The handle is not free-threaded. Cursors may span |
| 150 | threads, but only serially, that is, the application must |
| 151 | serialize access to the <a href="../api_reference/C/dbc.html" class="olink">DBC</a> handles. If the cursor is to be |
| 152 | used to perform operations on behalf of a transaction, the |
| 153 | cursor must be opened and closed within the context of that |
| 154 | single transaction. Once <a href="../api_reference/C/dbcclose.html" class="olink">DBC->close()</a> has been called, the |
| 155 | handle may not be accessed again, regardless of the method's |
| 156 | return. |
| 157 | </p> |
| 158 | </dd> |
| 159 | </dl> |
| 160 | </div> |
| 161 | </div> |
| 162 | <div class="navfooter"> |
| 163 | <hr /> |
| 164 | <table width="100%" summary="Navigation footer"> |
| 165 | <tr> |
| 166 | <td width="40%" align="left"><a accesskey="p" href="program_mt.html">Prev</a> </td> |
| 167 | <td width="20%" align="center"> |
| 168 | <a accesskey="u" href="program.html">Up</a> |
| 169 | </td> |
| 170 | <td width="40%" align="right"> <a accesskey="n" href="program_namespace.html">Next</a></td> |
| 171 | </tr> |
| 172 | <tr> |
| 173 | <td width="40%" align="left" valign="top">Multithreaded applications </td> |
| 174 | <td width="20%" align="center"> |
| 175 | <a accesskey="h" href="index.html">Home</a> |
| 176 | </td> |
| 177 | <td width="40%" align="right" valign="top"> Name spaces</td> |
| 178 | </tr> |
| 179 | </table> |
| 180 | </div> |
| 181 | </body> |
| 182 | </html> |