Debian Codegraph @

docs/api_reference/CXX/txncommit.html

raw symbols SCIP
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="txnabort.html" title="DbTxn::abort()" />
12 <link rel="next" href="txndiscard.html" title="DbTxn::discard()" />
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">DbTxn::commit()</th>
22 </tr>
23 <tr>
24 <td width="20%" align="left"><a accesskey="p" href="txnabort.html">Prev</a> </td>
25 <th width="60%" align="center">Chapter 13. 
26 The DbTxn Handle
27 </th>
28 <td width="20%" align="right"> <a accesskey="n" href="txndiscard.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="txncommit"></a>DbTxn::commit()</h2>
38 </div>
39 </div>
40 </div>
41 <pre class="programlisting">#include &lt;db_cxx.h&gt;
42
43 int
44 DbTxn::commit(u_int32_t flags);</pre>
45 <p>
46 The <code class="methodname">DbTxn::commit()</code> method ends the transaction.
47 </p>
48 <p>
49 In the case of nested transactions, if the transaction is a parent
50 transaction, committing the parent transaction causes all unresolved
51 children of the parent to be committed. In the case of nested
52 transactions, if the transaction is a child transaction, its locks are
53 not released, but are acquired by its parent. Although the commit of
54 the child transaction will succeed, the actual resolution of the child
55 transaction is postponed until the parent transaction is committed or
56 aborted; that is, if its parent transaction commits, it will be
57 committed; and if its parent transaction aborts, it will be aborted.
58 </p>
59 <p>
60 All cursors opened within the transaction must be closed
61 before the transaction is committed. If they are not closed,
62 they will be closed by this function. When the close
63 operation for a cursor fails, the method returns a non-zero
64 error value for the first instance of such an error, closes
65 the rest of the cursors, and then aborts the transaction.
66
67 </p>
68 <p>
69 After <code class="methodname">DbTxn::commit()</code> has been called, regardless of its return, the
70 <a class="link" href="txn.html" title="Chapter 13.  The DbTxn Handle">DbTxn</a> handle may not be
71 accessed again. If <code class="methodname">DbTxn::commit()</code> encounters an error, the
72 transaction and all child transactions of the transaction are aborted.
73 </p>
74 <p>
75 The <code class="methodname">DbTxn::commit()</code> <span>
76
77 <span>
78 method either returns a non-zero error value or throws an
79 exception that encapsulates a non-zero error value on
80 failure, and returns 0 on success.
81 </span>
82 </span>
83 The errors values that this method returns include the error values of the
84 <code class="methodname">Dbc::close()</code> method and the following:
85
86 </p>
87 <div class="sect3" lang="en" xml:lang="en">
88 <div class="titlepage">
89 <div>
90 <div>
91 <h4 class="title"><a id="idp10419048"></a><span>DbDeadlockException or </span>DB_LOCK_DEADLOCK</h4>
92 </div>
93 </div>
94 </div>
95 <p>
96 A transactional database environment operation was selected to resolve
97 a deadlock.
98 </p>
99 <p>
100 <a class="xref" href="dbdeadlock.html" title="DbDeadlockException">DbDeadlockException</a> is thrown if
101 your Berkeley DB API is configured to throw exceptions.
102 Otherwise, <code class="literal">DB_LOCK_DEADLOCK</code> is returned.
103 </p>
104 </div>
105 <div class="sect3" lang="en" xml:lang="en">
106 <div class="titlepage">
107 <div>
108 <div>
109 <h4 class="title"><a id="idp10380272"></a><span>DbLockNotGrantedException or </span>DB_LOCK_NOTGRANTED</h4>
110 </div>
111 </div>
112 </div>
113 <p>
114 A Berkeley DB Concurrent Data Store database environment configured
115 for lock timeouts was unable to grant a lock in the allowed time.
116 </p>
117 <p>
118 You attempted to open a database handle that is configured
119 for no waiting exclusive locking, but the exclusive lock could not be
120 immediately obtained. See
121 <a class="xref" href="dbset_lk_exclusive.html" title="Db::set_lk_exclusive()">Db::set_lk_exclusive()</a>
122 for more information.
123 </p>
124 <p>
125 <a class="xref" href="dblocknotgranted.html" title="DbLockNotGrantedException">DbLockNotGrantedException</a> is thrown if
126 your Berkeley DB API is configured to throw exceptions.
127 Otherwise, <code class="literal">DB_LOCK_NOTGRANTED</code> is returned.
128 </p>
129 </div>
130 <div class="sect3" lang="en" xml:lang="en">
131 <div class="titlepage">
132 <div>
133 <div>
134 <h4 class="title"><a id="idp10427944"></a>DB_REP_LEASE_EXPIRED</h4>
135 </div>
136 </div>
137 </div>
138 <p>
139 The operation failed because the site's replication master lease has expired.
140 </p>
141 </div>
142 <div class="sect3" lang="en" xml:lang="en">
143 <div class="titlepage">
144 <div>
145 <div>
146 <h4 class="title"><a id="idp10377360"></a>EINVAL</h4>
147 </div>
148 </div>
149 </div>
150 <p>
151 If the cursor is already closed; or if an invalid flag value or parameter was specified.
152 </p>
153 </div>
154 <div class="sect2" lang="en" xml:lang="en">
155 <div class="titlepage">
156 <div>
157 <div>
158 <h3 class="title"><a id="idp10447448"></a>Parameters</h3>
159 </div>
160 </div>
161 </div>
162 <div class="sect3" lang="en" xml:lang="en">
163 <div class="titlepage">
164 <div>
165 <div>
166 <h4 class="title"><a id="idp10447640"></a>flags</h4>
167 </div>
168 </div>
169 </div>
170 <p>
171 The <span class="bold"><strong>flags</strong></span> parameter must be set to 0
172 or one of the following values:
173 </p>
174 <div class="itemizedlist">
175 <ul type="disc">
176 <li>
177 <p>
178 <code class="literal">DB_TXN_NOSYNC</code>
179 </p>
180 <p>
181 Do not synchronously flush the log. This means the transaction will
182 exhibit the ACI (atomicity, consistency, and isolation) properties,
183 but not D (durability); that is, database integrity will be
184 maintained, but it is possible that this transaction may be undone
185 during recovery.
186 </p>
187 <p>
188 This behavior may be set for a Berkeley DB environment using the
189 <a class="xref" href="envset_flags.html" title="DbEnv::set_flags()">DbEnv::set_flags()</a>
190 method or for a single transaction using the
191 <a class="xref" href="txnbegin.html" title="DbEnv::txn_begin()">DbEnv::txn_begin()</a> method.
192 Any value specified to this method overrides both of those settings.
193 </p>
194 </li>
195 <li>
196 <p>
197 <code class="literal">DB_TXN_SYNC</code>
198 </p>
199 <p>
200 Synchronously flush the log. This means the transaction will exhibit
201 all of the ACID (atomicity, consistency, isolation, and durability)
202 properties.
203 </p>
204 <p>
205 This behavior is the default for Berkeley DB environments unless the
206 <a class="link" href="envset_flags.html#envset_flags_DB_TXN_NOSYNC">DB_TXN_NOSYNC</a>
207 flag was specified to the
208 <a class="xref" href="envset_flags.html" title="DbEnv::set_flags()">DbEnv::set_flags()</a> method.
209 This behavior may also be set for a single transaction using the
210 <a class="xref" href="txnbegin.html" title="DbEnv::txn_begin()">DbEnv::txn_begin()</a>
211 method. Any value specified to this method overrides both of those
212 settings.
213 </p>
214 </li>
215 <li>
216 <p>
217 <code class="literal">DB_TXN_WRITE_NOSYNC</code>
218 </p>
219 <p>
220 Write but do not synchronously flush the log on
221 transaction commit. This means that transactions
222 exhibit the ACI (atomicity, consistency, and
223 isolation) properties, but not D (durability); that
224 is, database integrity will be maintained, but if the
225 system fails, it is possible some number of the most
226 recently committed transactions may be undone during
227 recovery. The number of transactions at risk is
228 governed by how often the system flushes dirty
229 buffers to disk and how often the log is
230 checkpointed.
231 </p>
232 <p>
233 This form of commit protects you against application
234 crashes, but not against OS crashes. This method
235 offers less room for the possiblity of data loss than
236 does <code class="literal">DB_TXN_NOSYNC</code>.
237 </p>
238 <p>
239 This behavior may be set for a Berkeley DB environment using the
240 <a class="xref" href="envset_flags.html" title="DbEnv::set_flags()">DbEnv::set_flags()</a>
241 method or for a single transaction using the
242 <a class="xref" href="txnbegin.html" title="DbEnv::txn_begin()">DbEnv::txn_begin()</a> method.
243 Any value specified to this method overrides both of those settings.
244 </p>
245 </li>
246 </ul>
247 </div>
248 </div>
249 </div>
250 <div class="sect2" lang="en" xml:lang="en">
251 <div class="titlepage">
252 <div>
253 <div>
254 <h3 class="title"><a id="idp10451536"></a>Class</h3>
255 </div>
256 </div>
257 </div>
258 <p>
259 <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>
260 </p>
261 </div>
262 <div class="sect2" lang="en" xml:lang="en">
263 <div class="titlepage">
264 <div>
265 <div>
266 <h3 class="title"><a id="idp10421704"></a>See Also</h3>
267 </div>
268 </div>
269 </div>
270 <p>
271 <a class="xref" href="txn.html#txnlist" title="Transaction Subsystem and Related Methods">Transaction Subsystem and Related Methods</a>
272 </p>
273 </div>
274 </div>
275 <div class="navfooter">
276 <hr />
277 <table width="100%" summary="Navigation footer">
278 <tr>
279 <td width="40%" align="left"><a accesskey="p" href="txnabort.html">Prev</a> </td>
280 <td width="20%" align="center">
281 <a accesskey="u" href="txn.html">Up</a>
282 </td>
283 <td width="40%" align="right"> <a accesskey="n" href="txndiscard.html">Next</a></td>
284 </tr>
285 <tr>
286 <td width="40%" align="left" valign="top">DbTxn::abort() </td>
287 <td width="20%" align="center">
288 <a accesskey="h" href="index.html">Home</a>
289 </td>
290 <td width="40%" align="right" valign="top"> DbTxn::discard()</td>
291 </tr>
292 </table>
293 </div>
294 </body>
295 </html>