1<!--$Id: txn_prepare.so,v 10.35 2004/08/13 03:39:03 bostic Exp $-->
2<!--Copyright (c) 1997,2008 Oracle.  All rights reserved.-->
3<!--See the file LICENSE for redistribution information.-->
4<html>
5<head>
6<title>Berkeley DB: DB_TXN-&gt;prepare</title>
7<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
8<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++">
9</head>
10<body bgcolor=white>
11<table width="100%"><tr valign=top>
12<td>
13<b>DB_TXN-&gt;prepare</b>
14</td>
15<td align=right>
16<a href="../api_c/api_core.html"><img src="../images/api.gif" alt="API"></a>
17<a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a></td>
18</tr></table>
19<hr size=1 noshade>
20<tt>
21<b><pre>
22#include &lt;db.h&gt;
23<p>
24int
25DB_TXN-&gt;prepare(DB_TXN *tid, u_int8_t gid[DB_XIDDATASIZE]);
26</pre></b>
27<hr size=1 noshade>
28<b>Description: DB_TXN-&gt;prepare</b>
29<a name="2"><!--meow--></a>
30<p>The DB_TXN-&gt;prepare method initiates the beginning of a two-phase commit.</p>
31<p>In a distributed transaction environment, Berkeley DB can be used as a local
32transaction manager.  In this case, the distributed transaction manager
33must send <i>prepare</i> messages to each local manager.  The local
34manager must then issue a DB_TXN-&gt;prepare and await its successful
35return before responding to the distributed transaction manager.  Only
36after the distributed transaction manager receives successful responses
37from all of its <i>prepare</i> messages should it issue any
38<i>commit</i> messages.</p>
39<p>In the case of nested transactions, preparing the parent causes all
40unresolved children of the parent transaction to be committed.  Child
41transactions should never be explicitly prepared.  Their fate will be
42resolved along with their parent's during global recovery.</p>
43<p>The DB_TXN-&gt;prepare method
44returns a non-zero error value on failure
45and 0 on success.
46</p>
47<b>Parameters</b> <br>
48 <b>gid</b><ul compact><li>The <b>gid</b> parameter specifies the global transaction ID by which this
49transaction will be known.  This global transaction ID will be returned
50in calls to <a href="../api_c/txn_recover.html">DB_ENV-&gt;txn_recover</a>, telling the application which global
51transactions must be resolved.</ul>
52<br>
53<hr size=1 noshade>
54<br><b>Class</b>
55<a href="../api_c/env_class.html">DB_ENV</a>, <a href="../api_c/txn_class.html">DB_TXN</a>
56<br><b>See Also</b>
57<a href="../api_c/txn_list.html">Transaction Subsystem and Related Methods</a>
58</tt>
59<table width="100%"><tr><td><br></td><td align=right>
60<a href="../api_c/api_core.html"><img src="../images/api.gif" alt="API"></a><a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a>
61</td></tr></table>
62<p><font size=1>Copyright (c) 1996,2008 Oracle.  All rights reserved.</font>
63</body>
64</html>
65