| 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>Chapter 13. The DbTxn Handle</title> |
| 7 | <link rel="stylesheet" href="apiReference.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 C++ API Reference" /> |
| 10 | <link rel="up" href="index.html" title="Berkeley DB C++ API Reference" /> |
| 11 | <link rel="prev" href="seqstat_print.html" title="DbSequence::stat_print()" /> |
| 12 | <link rel="next" href="dbget_transactional.html" title="Db::get_transactional()" /> |
| 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">Chapter 13. |
| 22 | The DbTxn Handle |
| 23 | </th> |
| 24 | </tr> |
| 25 | <tr> |
| 26 | <td width="20%" align="left"><a accesskey="p" href="seqstat_print.html">Prev</a> </td> |
| 27 | <th width="60%" align="center"> </th> |
| 28 | <td width="20%" align="right"> <a accesskey="n" href="dbget_transactional.html">Next</a></td> |
| 29 | </tr> |
| 30 | </table> |
| 31 | <hr /> |
| 32 | </div> |
| 33 | <div class="chapter" lang="en" xml:lang="en"> |
| 34 | <div class="titlepage"> |
| 35 | <div> |
| 36 | <div> |
| 37 | <h2 class="title"><a id="txn"></a>Chapter 13. |
| 38 | The DbTxn Handle |
| 39 | </h2> |
| 40 | </div> |
| 41 | </div> |
| 42 | </div> |
| 43 | <pre class="programlisting">#include <db_cxx.h> |
| 44 | |
| 45 | class DbTxn { |
| 46 | public: |
| 47 | DB_TXN *DbTxn::get_DB_TXN(); |
| 48 | const DB_TXN *DbTxn::get_const_DB_TXN() const; |
| 49 | static DbTxn *DbTxn::get_DbTxn(DB_TXN *txn); |
| 50 | static const DbTxn *DbTxn::get_const_DbTxn(const DB_TXN *txn); |
| 51 | ... |
| 52 | |
| 53 | }; </pre> |
| 54 | <p> |
| 55 | The <code class="classname">DbTxn</code> object is the handle for a transaction. Methods of |
| 56 | the <code class="classname">DbTxn</code> handle are used to configure, abort and commit the |
| 57 | transaction. <code class="classname">DbTxn</code> handles are provided to |
| 58 | <a class="link" href="db.html" title="Chapter 2. The Db Handle">Db</a> methods in order |
| 59 | to transactionally protect those database operations. |
| 60 | </p> |
| 61 | <p> |
| 62 | <code class="classname">DbTxn</code> handles are not free-threaded; transactions handles |
| 63 | may be used by multiple threads, but only serially, that is, the application must |
| 64 | serialize access to the <code class="classname">DbTxn</code> handle. Once the |
| 65 | <a class="xref" href="txnabort.html" title="DbTxn::abort()">DbTxn::abort()</a> or |
| 66 | <a class="xref" href="txncommit.html" title="DbTxn::commit()">DbTxn::commit()</a> methods are called, the handle |
| 67 | may not be accessed again, regardless of the method's return. In addition, parent |
| 68 | transactions may not issue any Berkeley DB operations while they have active child |
| 69 | transactions (child transactions that have not yet been committed or aborted) except for |
| 70 | <a class="xref" href="txnbegin.html" title="DbEnv::txn_begin()">DbEnv::txn_begin()</a>, |
| 71 | <a class="xref" href="txnabort.html" title="DbTxn::abort()">DbTxn::abort()</a> and |
| 72 | <a class="xref" href="txncommit.html" title="DbTxn::commit()">DbTxn::commit()</a>. |
| 73 | </p> |
| 74 | <p> |
| 75 | Each <code class="classname">DbTxn</code> object has an associated |
| 76 | <code class="literal">DB_TXN</code> struct, which is used by the underlying |
| 77 | implementation of Berkeley DB and its |
| 78 | |
| 79 | <span>C++ language</span> |
| 80 | API. The <code class="methodname">DbTxn::get_DB_TXN()</code> method |
| 81 | returns a pointer to this struct. Given a const <code class="literal">DbTxn</code> object, |
| 82 | <code class="methodname">txnMget_const_DB_TXN()</code> |
| 83 | returns a const pointer to the same struct. |
| 84 | </p> |
| 85 | <p> |
| 86 | Given a <code class="literal">DB_TXN</code> struct, the <code class="methodname">DbTxn::get_DbTxn()</code> |
| 87 | method returns the corresponding <code class="classname">DbTxn</code> object, if there is |
| 88 | one. If the <code class="literal">DB_TXN</code> object was not associated with a |
| 89 | <code class="classname">DbTxn</code> (that is, it was not returned from a call to |
| 90 | <code class="methodname">DbTxn::get_DB_TXN()</code>), then the result of |
| 91 | <code class="methodname">DbTxn::get_DbTxn</code> is undefined. Given a const |
| 92 | <code class="literal">DB_TXN</code> struct, <code class="methodname">DbTxn::get_const_DbTxn()</code> |
| 93 | returns the associated const <code class="literal">DbTxn</code> object, if there is one. |
| 94 | </p> |
| 95 | <p> |
| 96 | These methods may be useful for Berkeley DB applications including both C and C++ |
| 97 | language software. It should not be necessary to use these calls in a purely C++ |
| 98 | application. |
| 99 | </p> |
| 100 | <div class="sect1" lang="en" xml:lang="en"> |
| 101 | <div class="titlepage"> |
| 102 | <div> |
| 103 | <div> |
| 104 | <h2 class="title" style="clear: both"><a id="txnlist"></a>Transaction Subsystem and Related Methods</h2> |
| 105 | </div> |
| 106 | </div> |
| 107 | </div> |
| 108 | <div class="navtable"> |
| 109 | <table border="1" width="80%"> |
| 110 | <thead> |
| 111 | <tr> |
| 112 | <th>Transaction Subsystem and Related Methods</th> |
| 113 | <th>Description</th> |
| 114 | </tr> |
| 115 | </thead> |
| 116 | <tbody> |
| 117 | <tr> |
| 118 | <td> |
| 119 | <a class="xref" href="txnrecover.html" title="DbEnv::txn_recover()">DbEnv::txn_recover()</a> |
| 120 | </td> |
| 121 | <td>Distributed transaction recovery</td> |
| 122 | </tr> |
| 123 | <tr> |
| 124 | <td> |
| 125 | <a class="xref" href="txncheckpoint.html" title="DbEnv::txn_checkpoint()">DbEnv::txn_checkpoint()</a> |
| 126 | </td> |
| 127 | <td>Checkpoint the transaction subsystem</td> |
| 128 | </tr> |
| 129 | <tr> |
| 130 | <td> |
| 131 | <a class="xref" href="txnstat.html" title="DbEnv::txn_stat()">DbEnv::txn_stat()</a> |
| 132 | </td> |
| 133 | <td>Return transaction subsystem statistics</td> |
| 134 | </tr> |
| 135 | <tr> |
| 136 | <td> |
| 137 | <a class="xref" href="txnstat_print.html" title="DbEnv::txn_stat_print()">DbEnv::txn_stat_print()</a> |
| 138 | </td> |
| 139 | <td>Print transaction subsystem statistics</td> |
| 140 | </tr> |
| 141 | <tr> |
| 142 | <td> |
| 143 | <a class="xref" href="txnset_timeout.html" title="DbTxn::set_timeout()">DbTxn::set_timeout()</a> |
| 144 | </td> |
| 145 | <td>Set transaction timeout</td> |
| 146 | </tr> |
| 147 | <tr> |
| 148 | <td colspan="2"> |
| 149 | <span class="bold"> |
| 150 | <strong>Transaction Subsystem Configuration</strong> |
| 151 | </span> |
| 152 | </td> |
| 153 | </tr> |
| 154 | <tr> |
| 155 | <td><a class="xref" href="envset_timeout.html" title="DbEnv::set_timeout()">DbEnv::set_timeout()</a>, <a class="xref" href="envget_timeout.html" title="DbEnv::get_timeout()">DbEnv::get_timeout()</a></td> |
| 156 | <td>Set/get lock and transaction timeout</td> |
| 157 | </tr> |
| 158 | <tr> |
| 159 | <td> |
| 160 | <a class="xref" href="dbget_transactional.html" title="Db::get_transactional()">Db::get_transactional()</a> |
| 161 | </td> |
| 162 | <td>Does the Db have transaction support</td> |
| 163 | </tr> |
| 164 | <tr> |
| 165 | <td> |
| 166 | <a class="xref" href="envcdsgroup_begin.html" title="DbEnv::cdsgroup_begin()">DbEnv::cdsgroup_begin()</a> |
| 167 | </td> |
| 168 | <td>Get a locker ID in Berkeley DB Concurrent Data Store</td> |
| 169 | </tr> |
| 170 | <tr> |
| 171 | <td><a class="xref" href="envset_tx_max.html" title="DbEnv::set_tx_max()">DbEnv::set_tx_max()</a>, <a class="xref" href="envget_tx_max.html" title="DbEnv::get_tx_max()">DbEnv::get_tx_max()</a></td> |
| 172 | <td>Set/get maximum number of transactions</td> |
| 173 | </tr> |
| 174 | <tr> |
| 175 | <td><a class="xref" href="envset_tx_timestamp.html" title="DbEnv::set_tx_timestamp()">DbEnv::set_tx_timestamp()</a>, <a class="xref" href="envget_tx_timestamp.html" title="DbEnv::get_tx_timestamp()">DbEnv::get_tx_timestamp()</a></td> |
| 176 | <td>Set/get recovery timestamp</td> |
| 177 | </tr> |
| 178 | <tr> |
| 179 | <td colspan="2"> |
| 180 | <span class="bold"> |
| 181 | <strong>Transaction Operations</strong> |
| 182 | </span> |
| 183 | </td> |
| 184 | </tr> |
| 185 | <tr> |
| 186 | <td> |
| 187 | <a class="xref" href="txnbegin.html" title="DbEnv::txn_begin()">DbEnv::txn_begin()</a> |
| 188 | </td> |
| 189 | <td>Begin a transaction</td> |
| 190 | </tr> |
| 191 | <tr> |
| 192 | <td> |
| 193 | <a class="xref" href="txnabort.html" title="DbTxn::abort()">DbTxn::abort()</a> |
| 194 | </td> |
| 195 | <td>Abort a transaction</td> |
| 196 | </tr> |
| 197 | <tr> |
| 198 | <td> |
| 199 | <a class="xref" href="txncommit.html" title="DbTxn::commit()">DbTxn::commit()</a> |
| 200 | </td> |
| 201 | <td>Commit a transaction</td> |
| 202 | </tr> |
| 203 | <tr> |
| 204 | <td> |
| 205 | <a class="xref" href="txndiscard.html" title="DbTxn::discard()">DbTxn::discard()</a> |
| 206 | </td> |
| 207 | <td>Discard a prepared but not resolved transaction handle</td> |
| 208 | </tr> |
| 209 | <tr> |
| 210 | <td> |
| 211 | <a class="xref" href="txnid.html" title="DbTxn::id()">DbTxn::id()</a> |
| 212 | </td> |
| 213 | <td>Return a transaction's ID</td> |
| 214 | </tr> |
| 215 | <tr> |
| 216 | <td> |
| 217 | <a class="xref" href="txnprepare.html" title="DbTxn::prepare()">DbTxn::prepare()</a> |
| 218 | </td> |
| 219 | <td>Prepare a transaction for commit</td> |
| 220 | </tr> |
| 221 | <tr> |
| 222 | <td><a class="xref" href="txnset_name.html" title="DbTxn::set_name()">DbTxn::set_name()</a>, <a class="xref" href="txnget_name.html" title="DbTxn::get_name()">DbTxn::get_name()</a></td> |
| 223 | <td>Associate a string with a transaction</td> |
| 224 | </tr> |
| 225 | <tr> |
| 226 | <td><a class="xref" href="txnset_priority.html" title="DbTxn::set_priority()">DbTxn::set_priority()</a>, <a class="xref" href="txnget_priority.html" title="DbTxn::get_priority()">DbTxn::get_priority()</a></td> |
| 227 | <td>Set/get transaction's priority</td> |
| 228 | </tr> |
| 229 | </tbody> |
| 230 | </table> |
| 231 | </div> |
| 232 | </div> |
| 233 | </div> |
| 234 | <div class="navfooter"> |
| 235 | <hr /> |
| 236 | <table width="100%" summary="Navigation footer"> |
| 237 | <tr> |
| 238 | <td width="40%" align="left"><a accesskey="p" href="seqstat_print.html">Prev</a> </td> |
| 239 | <td width="20%" align="center"> </td> |
| 240 | <td width="40%" align="right"> <a accesskey="n" href="dbget_transactional.html">Next</a></td> |
| 241 | </tr> |
| 242 | <tr> |
| 243 | <td width="40%" align="left" valign="top">DbSequence::stat_print() </td> |
| 244 | <td width="20%" align="center"> |
| 245 | <a accesskey="h" href="index.html">Home</a> |
| 246 | </td> |
| 247 | <td width="40%" align="right" valign="top"> Db::get_transactional()</td> |
| 248 | </tr> |
| 249 | </table> |
| 250 | </div> |
| 251 | </body> |
| 252 | </html> |