Debian Codegraph @

docs/api_reference/C/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>DB_TXN-&gt;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 12.  The DB_TXN Handle" />
11 <link rel="prev" href="txnid.html" title="DB_TXN-&gt;id()" />
12 <link rel="next" href="txnset_name.html" title="DB_TXN-&gt;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">DB_TXN-&gt;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 12. 
26 The DB_TXN 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>DB_TXN-&gt;prepare()</h2>
38 </div>
39 </div>
40 </div>
41 <pre class="programlisting">#include &lt;db.h&gt;
42
43 int
44 DB_TXN-&gt;prepare(DB_TXN *tid, u_int8_t gid[DB_GID_SIZE]); </pre>
45 <p>
46 The <code class="methodname">DB_TXN-&gt;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">DB_TXN-&gt;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">DB_TXN-&gt;prepare()</code> <span>
72 <span>
73 method returns a non-zero error value on failure and 0 on success.
74 </span>
75
76 </span>
77
78 The errors that this method returns include the error values of <code class="methodname">DBcursor-&gt;close()</code> and the following:
79
80 </p>
81 <div class="sect3" lang="en" xml:lang="en">
82 <div class="titlepage">
83 <div>
84 <div>
85 <h4 class="title"><a id="idp54977056"></a>DB_LOCK_DEADLOCK</h4>
86 </div>
87 </div>
88 </div>
89 <p>
90 A transactional database environment operation was selected to resolve
91 a deadlock.
92 </p>
93 </div>
94 <div class="sect3" lang="en" xml:lang="en">
95 <div class="titlepage">
96 <div>
97 <div>
98 <h4 class="title"><a id="idp54979288"></a>DB_LOCK_NOTGRANTED</h4>
99 </div>
100 </div>
101 </div>
102 <p>
103 A Berkeley DB Concurrent Data Store database environment configured
104 for lock timeouts was unable to grant a lock in the allowed time.
105 </p>
106 <p>
107 You attempted to open a database handle that is configured
108 for no waiting exclusive locking, but the exclusive lock could not be
109 immediately obtained. See
110 <a class="xref" href="dbset_lk_exclusive.html" title="DB-&gt;set_lk_exclusive()">DB-&gt;set_lk_exclusive()</a>
111 for more information.
112 </p>
113 </div>
114 <div class="sect3" lang="en" xml:lang="en">
115 <div class="titlepage">
116 <div>
117 <div>
118 <h4 class="title"><a id="idp54982024"></a>EINVAL</h4>
119 </div>
120 </div>
121 </div>
122 <p>
123 If the cursor is already closed; or if an invalid flag value or parameter was specified.
124 </p>
125 </div>
126 <div class="sect2" lang="en" xml:lang="en">
127 <div class="titlepage">
128 <div>
129 <div>
130 <h3 class="title"><a id="idp54993584"></a>Parameters</h3>
131 </div>
132 </div>
133 </div>
134 <div class="sect3" lang="en" xml:lang="en">
135 <div class="titlepage">
136 <div>
137 <div>
138 <h4 class="title"><a id="idp54993776"></a>gid</h4>
139 </div>
140 </div>
141 </div>
142 <p>
143 The <span class="bold"><strong>gid</strong></span> parameter specifies the
144 global transaction ID by which this transaction will be known. This
145 global transaction ID will be returned in calls
146 to <a class="xref" href="txnrecover.html" title="DB_ENV-&gt;txn_recover()">DB_ENV-&gt;txn_recover()</a>
147 telling the application which global transactions must be resolved.
148 </p>
149 </div>
150 </div>
151 <div class="sect2" lang="en" xml:lang="en">
152 <div class="titlepage">
153 <div>
154 <div>
155 <h3 class="title"><a id="idp54977672"></a>Class</h3>
156 </div>
157 </div>
158 </div>
159 <p>
160 <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>
161 </p>
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="idp54988152"></a>See Also</h3>
168 </div>
169 </div>
170 </div>
171 <p>
172 <a class="xref" href="txn.html#txnlist" title="Transaction Subsystem and Related Methods">Transaction Subsystem and Related Methods</a>
173 </p>
174 </div>
175 </div>
176 <div class="navfooter">
177 <hr />
178 <table width="100%" summary="Navigation footer">
179 <tr>
180 <td width="40%" align="left"><a accesskey="p" href="txnid.html">Prev</a> </td>
181 <td width="20%" align="center">
182 <a accesskey="u" href="txn.html">Up</a>
183 </td>
184 <td width="40%" align="right"> <a accesskey="n" href="txnset_name.html">Next</a></td>
185 </tr>
186 <tr>
187 <td width="40%" align="left" valign="top">DB_TXN-&gt;id() </td>
188 <td width="20%" align="center">
189 <a accesskey="h" href="index.html">Home</a>
190 </td>
191 <td width="40%" align="right" valign="top"> DB_TXN-&gt;set_name()</td>
192 </tr>
193 </table>
194 </div>
195 </body>
196 </html>