Debian Codegraph @

docs/api_reference/CXX/txnprepare.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::prepare()</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="txnid.html" title="DbTxn::id()" />
12 <link rel="next" href="txnset_name.html" title="DbTxn::set_name()" />
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::prepare()</th>
22 </tr>
23 <tr>
24 <td width="20%" align="left"><a accesskey="p" href="txnid.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="txnset_name.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="txnprepare"></a>DbTxn::prepare()</h2>
38 </div>
39 </div>
40 </div>
41 <pre class="programlisting">#include &lt;db_cxx.h&gt;
42
43 int
44 DbTxn::prepare(u_int8_t gid[DB_GID_SIZE]);</pre>
45 <p>
46 The <code class="methodname">DbTxn::prepare()</code> method initiates the beginning of a two-phase
47 commit.
48 </p>
49 <p>
50 In a distributed transaction environment, Berkeley DB can be used as a
51 local transaction manager. In this case, the distributed transaction
52 manager must send <span class="emphasis"><em>prepare</em></span> messages to each local
53 manager. The local manager must then issue a <code class="methodname">DbTxn::prepare()</code> and
54 await its successful return before responding to the distributed
55 transaction manager. Only after the distributed transaction manager
56 receives successful responses from all of its
57 <span class="emphasis"><em>prepare</em></span> messages should it issue any
58 <span class="emphasis"><em>commit</em></span> messages.
59 </p>
60 <p>
61 In the case of nested transactions, preparing the parent causes all
62 unresolved children of the parent transaction to be committed. Child
63 transactions should never be explicitly prepared. Their fate will be
64 resolved along with their parent's during global recovery.
65 </p>
66 <p>
67 All open cursors in the transaction are closed and the
68 first cursor close error will be returned.
69 </p>
70 <p>
71 The <code class="methodname">DbTxn::prepare()</code> <span>
72
73 <span>
74 method either returns a non-zero error value or throws an
75 exception that encapsulates a non-zero error value on
76 failure, and returns 0 on success.
77 </span>
78 </span>
79
80 The errors that this method returns include the error values of <code class="methodname">Dbc::close()</code> and the following:
81
82 </p>
83 <div class="sect3" lang="en" xml:lang="en">
84 <div class="titlepage">
85 <div>
86 <div>
87 <h4 class="title"><a id="idp10475640"></a><span>DbDeadlockException or </span>DB_LOCK_DEADLOCK</h4>
88 </div>
89 </div>
90 </div>
91 <p>
92 A transactional database environment operation was selected to resolve
93 a deadlock.
94 </p>
95 <p>
96 <a class="xref" href="dbdeadlock.html" title="DbDeadlockException">DbDeadlockException</a> is thrown if
97 your Berkeley DB API is configured to throw exceptions.
98 Otherwise, <code class="literal">DB_LOCK_DEADLOCK</code> is returned.
99 </p>
100 </div>
101 <div class="sect3" lang="en" xml:lang="en">
102 <div class="titlepage">
103 <div>
104 <div>
105 <h4 class="title"><a id="idp10481328"></a><span>DbLockNotGrantedException or </span>DB_LOCK_NOTGRANTED</h4>
106 </div>
107 </div>
108 </div>
109 <p>
110 A Berkeley DB Concurrent Data Store database environment configured
111 for lock timeouts was unable to grant a lock in the allowed time.
112 </p>
113 <p>
114 You attempted to open a database handle that is configured
115 for no waiting exclusive locking, but the exclusive lock could not be
116 immediately obtained. See
117 <a class="xref" href="dbset_lk_exclusive.html" title="Db::set_lk_exclusive()">Db::set_lk_exclusive()</a>
118 for more information.
119 </p>
120 <p>
121 <a class="xref" href="dblocknotgranted.html" title="DbLockNotGrantedException">DbLockNotGrantedException</a> is thrown if
122 your Berkeley DB API is configured to throw exceptions.
123 Otherwise, <code class="literal">DB_LOCK_NOTGRANTED</code> is returned.
124 </p>
125 </div>
126 <div class="sect3" lang="en" xml:lang="en">
127 <div class="titlepage">
128 <div>
129 <div>
130 <h4 class="title"><a id="idp10456168"></a>EINVAL</h4>
131 </div>
132 </div>
133 </div>
134 <p>
135 If the cursor is already closed; or if an invalid flag value or parameter was specified.
136 </p>
137 </div>
138 <div class="sect2" lang="en" xml:lang="en">
139 <div class="titlepage">
140 <div>
141 <div>
142 <h3 class="title"><a id="idp10509064"></a>Parameters</h3>
143 </div>
144 </div>
145 </div>
146 <div class="sect3" lang="en" xml:lang="en">
147 <div class="titlepage">
148 <div>
149 <div>
150 <h4 class="title"><a id="idp10509256"></a>gid</h4>
151 </div>
152 </div>
153 </div>
154 <p>
155 The <span class="bold"><strong>gid</strong></span> parameter specifies the
156 global transaction ID by which this transaction will be known. This
157 global transaction ID will be returned in calls
158 to <a class="xref" href="txnrecover.html" title="DbEnv::txn_recover()">DbEnv::txn_recover()</a>
159 telling the application which global transactions must be resolved.
160 </p>
161 </div>
162 </div>
163 <div class="sect2" lang="en" xml:lang="en">
164 <div class="titlepage">
165 <div>
166 <div>
167 <h3 class="title"><a id="idp10500888"></a>Class</h3>
168 </div>
169 </div>
170 </div>
171 <p>
172 <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>
173 </p>
174 </div>
175 <div class="sect2" lang="en" xml:lang="en">
176 <div class="titlepage">
177 <div>
178 <div>
179 <h3 class="title"><a id="idp10501488"></a>See Also</h3>
180 </div>
181 </div>
182 </div>
183 <p>
184 <a class="xref" href="txn.html#txnlist" title="Transaction Subsystem and Related Methods">Transaction Subsystem and Related Methods</a>
185 </p>
186 </div>
187 </div>
188 <div class="navfooter">
189 <hr />
190 <table width="100%" summary="Navigation footer">
191 <tr>
192 <td width="40%" align="left"><a accesskey="p" href="txnid.html">Prev</a> </td>
193 <td width="20%" align="center">
194 <a accesskey="u" href="txn.html">Up</a>
195 </td>
196 <td width="40%" align="right"> <a accesskey="n" href="txnset_name.html">Next</a></td>
197 </tr>
198 <tr>
199 <td width="40%" align="left" valign="top">DbTxn::id() </td>
200 <td width="20%" align="center">
201 <a accesskey="h" href="index.html">Home</a>
202 </td>
203 <td width="40%" align="right" valign="top"> DbTxn::set_name()</td>
204 </tr>
205 </table>
206 </div>
207 </body>
208 </html>