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>DbTxn::commit()</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="txn.html" title="Chapter��13.�� The DbTxn Handle" /> 11 <link rel="prev" href="txncheckpoint.html" title="DbEnv::txn_checkpoint()" /> 12 <link rel="next" href="txndiscard.html" title="DbTxn::discard()" /> 13 </head> 14 <body> 15 <div class="navheader"> 16 <table width="100%" summary="Navigation header"> 17 <tr> 18 <th colspan="3" align="center">DbTxn::commit()</th> 19 </tr> 20 <tr> 21 <td width="20%" align="left"><a accesskey="p" href="txncheckpoint.html">Prev</a>��</td> 22 <th width="60%" align="center">Chapter��13.�� 23 The DbTxn Handle 24 </th> 25 <td width="20%" align="right">��<a accesskey="n" href="txndiscard.html">Next</a></td> 26 </tr> 27 </table> 28 <hr /> 29 </div> 30 <div class="sect1" lang="en" xml:lang="en"> 31 <div class="titlepage"> 32 <div> 33 <div> 34 <h2 class="title" style="clear: both"><a id="txncommit"></a>DbTxn::commit()</h2> 35 </div> 36 </div> 37 </div> 38 <pre class="programlisting">#include <db_cxx.h> 39 40int 41DbTxn::commit(u_int32_t flags);</pre> 42 <p> 43 The <code class="methodname">DbTxn::commit()</code> method ends the transaction. 44 </p> 45 <p> 46 In the case of nested transactions, if the transaction is a parent 47 transaction, committing the parent transaction causes all unresolved 48 children of the parent to be committed. In the case of nested 49 transactions, if the transaction is a child transaction, its locks are 50 not released, but are acquired by its parent. Although the commit of 51 the child transaction will succeed, the actual resolution of the child 52 transaction is postponed until the parent transaction is committed or 53 aborted; that is, if its parent transaction commits, it will be 54 committed; and if its parent transaction aborts, it will be aborted. 55 </p> 56 <p> 57 All cursors opened within the transaction must be closed before the 58 transaction is committed. 59 </p> 60 <p> 61 After <code class="methodname">DbTxn::commit()</code> has been called, regardless of its return, the 62 <a class="link" href="txn.html" title="Chapter��13.�� The DbTxn Handle">DbTxn</a> handle may not be 63 accessed again. If <code class="methodname">DbTxn::commit()</code> encounters an error, the 64 transaction and all child transactions of the transaction are aborted. 65 </p> 66 <p> 67 The <code class="methodname">DbTxn::commit()</code> <span> 68 69 <span> 70 method either returns a non-zero error value or throws an 71 exception that encapsulates a non-zero error value on 72 failure, and returns 0 on success. 73 </span> 74 </span> 75 </p> 76 <div class="sect2" lang="en" xml:lang="en"> 77 <div class="titlepage"> 78 <div> 79 <div> 80 <h3 class="title"><a id="id1714196"></a>Parameters</h3> 81 </div> 82 </div> 83 </div> 84 <div class="sect3" lang="en" xml:lang="en"> 85 <div class="titlepage"> 86 <div> 87 <div> 88 <h4 class="title"><a id="id1714197"></a>flags</h4> 89 </div> 90 </div> 91 </div> 92 <p> 93 The <span class="bold"><strong>flags</strong></span> parameter must be set to 0 94 or one of the following values: 95 </p> 96 <div class="itemizedlist"> 97 <ul type="disc"> 98 <li> 99 <p> 100 <code class="literal">DB_TXN_NOSYNC</code> 101 </p> 102 <p> 103 Do not synchronously flush the log. This means the transaction will 104 exhibit the ACI (atomicity, consistency, and isolation) properties, 105 but not D (durability); that is, database integrity will be 106 maintained, but it is possible that this transaction may be undone 107 during recovery. 108 </p> 109 <p> 110 This behavior may be set for a Berkeley DB environment using the 111 <a class="xref" href="envset_flags.html" title="DbEnv::set_flags()">DbEnv::set_flags()</a> 112 method or for a single transaction using the 113 <a class="xref" href="txnbegin.html" title="DbEnv::txn_begin()">DbEnv::txn_begin()</a> method. 114 Any value specified to this method overrides both of those settings. 115 </p> 116 </li> 117 <li> 118 <p> 119 <code class="literal">DB_TXN_SYNC</code> 120 </p> 121 <p> 122 Synchronously flush the log. This means the transaction will exhibit 123 all of the ACID (atomicity, consistency, isolation, and durability) 124 properties. 125 </p> 126 <p> 127 This behavior is the default for Berkeley DB environments unless the 128 <a class="link" href="envset_flags.html#envset_flags_DB_TXN_NOSYNC">DB_TXN_NOSYNC</a> 129 flag was specified to the <a class="xref" href="envset_flags.html" title="DbEnv::set_flags()">DbEnv::set_flags()</a> method. 130 This behavior may also be set for a single transaction using the 131 <a class="xref" href="txnbegin.html" title="DbEnv::txn_begin()">DbEnv::txn_begin()</a> 132 method. Any value specified to this method overrides both of those 133 settings. 134 </p> 135 </li> 136 </ul> 137 </div> 138 </div> 139 </div> 140 <div class="sect2" lang="en" xml:lang="en"> 141 <div class="titlepage"> 142 <div> 143 <div> 144 <h3 class="title"><a id="id1714473"></a>Class</h3> 145 </div> 146 </div> 147 </div> 148 <p> 149 <a class="link" href="env.html" title="Chapter��5.�� The DbEnv Handle">DbEnv</a>, <a class="link" href="txn.html" title="Chapter��13.�� The DbTxn Handle">DbTxn</a> 150 </p> 151 </div> 152 <div class="sect2" lang="en" xml:lang="en"> 153 <div class="titlepage"> 154 <div> 155 <div> 156 <h3 class="title"><a id="id1714521"></a>See Also</h3> 157 </div> 158 </div> 159 </div> 160 <p> 161 <a class="xref" href="txn.html#txnlist" title="Transaction Subsystem and Related Methods">Transaction Subsystem and Related Methods</a> 162 </p> 163 </div> 164 </div> 165 <div class="navfooter"> 166 <hr /> 167 <table width="100%" summary="Navigation footer"> 168 <tr> 169 <td width="40%" align="left"><a accesskey="p" href="txncheckpoint.html">Prev</a>��</td> 170 <td width="20%" align="center"> 171 <a accesskey="u" href="txn.html">Up</a> 172 </td> 173 <td width="40%" align="right">��<a accesskey="n" href="txndiscard.html">Next</a></td> 174 </tr> 175 <tr> 176 <td width="40%" align="left" valign="top">DbEnv::txn_checkpoint()��</td> 177 <td width="20%" align="center"> 178 <a accesskey="h" href="index.html">Home</a> 179 </td> 180 <td width="40%" align="right" valign="top">��DbTxn::discard()</td> 181 </tr> 182 </table> 183 </div> 184 </body> 185</html> 186