Debian Codegraph @

docs/api_reference/C/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>DB_TXN-&gt;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 12.  The DB_TXN Handle" />
11 <link rel="prev" href="txnabort.html" title="DB_TXN-&gt;abort()" />
12 <link rel="next" href="txndiscard.html" title="DB_TXN-&gt;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">DB_TXN-&gt;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 12. 
26 The DB_TXN 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>DB_TXN-&gt;commit()</h2>
38 </div>
39 </div>
40 </div>
41 <pre class="programlisting">#include &lt;db.h&gt;
42
43 int
44 DB_TXN-&gt;commit(DB_TXN *tid, u_int32_t flags); </pre>
45 <p>
46 The <code class="methodname">DB_TXN-&gt;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">DB_TXN-&gt;commit()</code> has been called, regardless of its return, the
70 <a class="link" href="txn.html" title="Chapter 12.  The DB_TXN Handle">DB_TXN</a> handle may not be
71 accessed again. If <code class="methodname">DB_TXN-&gt;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">DB_TXN-&gt;commit()</code> <span>
76 <span>
77 method returns a non-zero error value on failure and 0 on success.
78 </span>
79
80 </span>
81 The errors values that this method returns include the error values of the
82 <code class="methodname">DBcursor-&gt;close()</code> method and the following:
83
84 </p>
85 <div class="sect3" lang="en" xml:lang="en">
86 <div class="titlepage">
87 <div>
88 <div>
89 <h4 class="title"><a id="idp54914856"></a>DB_LOCK_DEADLOCK</h4>
90 </div>
91 </div>
92 </div>
93 <p>
94 A transactional database environment operation was selected to resolve
95 a deadlock.
96 </p>
97 </div>
98 <div class="sect3" lang="en" xml:lang="en">
99 <div class="titlepage">
100 <div>
101 <div>
102 <h4 class="title"><a id="idp54915352"></a>DB_LOCK_NOTGRANTED</h4>
103 </div>
104 </div>
105 </div>
106 <p>
107 A Berkeley DB Concurrent Data Store database environment configured
108 for lock timeouts was unable to grant a lock in the allowed time.
109 </p>
110 <p>
111 You attempted to open a database handle that is configured
112 for no waiting exclusive locking, but the exclusive lock could not be
113 immediately obtained. See
114 <a class="xref" href="dbset_lk_exclusive.html" title="DB-&gt;set_lk_exclusive()">DB-&gt;set_lk_exclusive()</a>
115 for more information.
116 </p>
117 </div>
118 <div class="sect3" lang="en" xml:lang="en">
119 <div class="titlepage">
120 <div>
121 <div>
122 <h4 class="title"><a id="idp54916144"></a>DB_REP_LEASE_EXPIRED</h4>
123 </div>
124 </div>
125 </div>
126 <p>
127 The operation failed because the site's replication master lease has expired.
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="idp54921960"></a>EINVAL</h4>
135 </div>
136 </div>
137 </div>
138 <p>
139 If the cursor is already closed; or if an invalid flag value or parameter was specified.
140 </p>
141 </div>
142 <div class="sect2" lang="en" xml:lang="en">
143 <div class="titlepage">
144 <div>
145 <div>
146 <h3 class="title"><a id="idp54938568"></a>Parameters</h3>
147 </div>
148 </div>
149 </div>
150 <div class="sect3" lang="en" xml:lang="en">
151 <div class="titlepage">
152 <div>
153 <div>
154 <h4 class="title"><a id="idp54938760"></a>flags</h4>
155 </div>
156 </div>
157 </div>
158 <p>
159 The <span class="bold"><strong>flags</strong></span> parameter must be set to 0
160 or one of the following values:
161 </p>
162 <div class="itemizedlist">
163 <ul type="disc">
164 <li>
165 <p>
166 <code class="literal">DB_TXN_NOSYNC</code>
167 </p>
168 <p>
169 Do not synchronously flush the log. This means the transaction will
170 exhibit the ACI (atomicity, consistency, and isolation) properties,
171 but not D (durability); that is, database integrity will be
172 maintained, but it is possible that this transaction may be undone
173 during recovery.
174 </p>
175 <p>
176 This behavior may be set for a Berkeley DB environment using the
177 <a class="xref" href="envset_flags.html" title="DB_ENV-&gt;set_flags()">DB_ENV-&gt;set_flags()</a>
178 method or for a single transaction using the
179 <a class="xref" href="txnbegin.html" title="DB_ENV-&gt;txn_begin()">DB_ENV-&gt;txn_begin()</a> method.
180 Any value specified to this method overrides both of those settings.
181 </p>
182 </li>
183 <li>
184 <p>
185 <code class="literal">DB_TXN_SYNC</code>
186 </p>
187 <p>
188 Synchronously flush the log. This means the transaction will exhibit
189 all of the ACID (atomicity, consistency, isolation, and durability)
190 properties.
191 </p>
192 <p>
193 This behavior is the default for Berkeley DB environments unless the
194 <a class="link" href="envset_flags.html#envset_flags_DB_TXN_NOSYNC">DB_TXN_NOSYNC</a>
195 flag was specified to the
196 <a class="xref" href="envset_flags.html" title="DB_ENV-&gt;set_flags()">DB_ENV-&gt;set_flags()</a> method.
197 This behavior may also be set for a single transaction using the
198 <a class="xref" href="txnbegin.html" title="DB_ENV-&gt;txn_begin()">DB_ENV-&gt;txn_begin()</a>
199 method. Any value specified to this method overrides both of those
200 settings.
201 </p>
202 </li>
203 <li>
204 <p>
205 <code class="literal">DB_TXN_WRITE_NOSYNC</code>
206 </p>
207 <p>
208 Write but do not synchronously flush the log on
209 transaction commit. This means that transactions
210 exhibit the ACI (atomicity, consistency, and
211 isolation) properties, but not D (durability); that
212 is, database integrity will be maintained, but if the
213 system fails, it is possible some number of the most
214 recently committed transactions may be undone during
215 recovery. The number of transactions at risk is
216 governed by how often the system flushes dirty
217 buffers to disk and how often the log is
218 checkpointed.
219 </p>
220 <p>
221 This form of commit protects you against application
222 crashes, but not against OS crashes. This method
223 offers less room for the possiblity of data loss than
224 does <code class="literal">DB_TXN_NOSYNC</code>.
225 </p>
226 <p>
227 This behavior may be set for a Berkeley DB environment using the
228 <a class="xref" href="envset_flags.html" title="DB_ENV-&gt;set_flags()">DB_ENV-&gt;set_flags()</a>
229 method or for a single transaction using the
230 <a class="xref" href="txnbegin.html" title="DB_ENV-&gt;txn_begin()">DB_ENV-&gt;txn_begin()</a> method.
231 Any value specified to this method overrides both of those settings.
232 </p>
233 </li>
234 </ul>
235 </div>
236 </div>
237 </div>
238 <div class="sect2" lang="en" xml:lang="en">
239 <div class="titlepage">
240 <div>
241 <div>
242 <h3 class="title"><a id="idp54942712"></a>Class</h3>
243 </div>
244 </div>
245 </div>
246 <p>
247 <a class="link" href="env.html" title="Chapter 5.  The DB_ENV Handle">DB_ENV</a>, <a class="link" href="txn.html" title="Chapter 12.  The DB_TXN Handle">DB_TXN</a>
248 </p>
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="idp54894160"></a>See Also</h3>
255 </div>
256 </div>
257 </div>
258 <p>
259 <a class="xref" href="txn.html#txnlist" title="Transaction Subsystem and Related Methods">Transaction Subsystem and Related Methods</a>
260 </p>
261 </div>
262 </div>
263 <div class="navfooter">
264 <hr />
265 <table width="100%" summary="Navigation footer">
266 <tr>
267 <td width="40%" align="left"><a accesskey="p" href="txnabort.html">Prev</a> </td>
268 <td width="20%" align="center">
269 <a accesskey="u" href="txn.html">Up</a>
270 </td>
271 <td width="40%" align="right"> <a accesskey="n" href="txndiscard.html">Next</a></td>
272 </tr>
273 <tr>
274 <td width="40%" align="left" valign="top">DB_TXN-&gt;abort() </td>
275 <td width="20%" align="center">
276 <a accesskey="h" href="index.html">Home</a>
277 </td>
278 <td width="40%" align="right" valign="top"> DB_TXN-&gt;discard()</td>
279 </tr>
280 </table>
281 </div>
282 </body>
283 </html>