txn_prepare.html   [plain text]


<!--$Id: txn_prepare.so,v 10.35 2004/08/13 03:39:03 bostic Exp $-->
<!--Copyright (c) 1997,2008 Oracle.  All rights reserved.-->
<!--See the file LICENSE for redistribution information.-->
<html>
<head>
<title>Berkeley DB: DB_TXN-&gt;prepare</title>
<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++">
</head>
<body bgcolor=white>
<table width="100%"><tr valign=top>
<td>
<b>DB_TXN-&gt;prepare</b>
</td>
<td align=right>
<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></td>
</tr></table>
<hr size=1 noshade>
<tt>
<b><pre>
#include &lt;db.h&gt;
<p>
int
DB_TXN-&gt;prepare(DB_TXN *tid, u_int8_t gid[DB_XIDDATASIZE]);
</pre></b>
<hr size=1 noshade>
<b>Description: DB_TXN-&gt;prepare</b>
<a name="2"><!--meow--></a>
<p>The DB_TXN-&gt;prepare method initiates the beginning of a two-phase commit.</p>
<p>In a distributed transaction environment, Berkeley DB can be used as a local
transaction manager.  In this case, the distributed transaction manager
must send <i>prepare</i> messages to each local manager.  The local
manager must then issue a DB_TXN-&gt;prepare and await its successful
return before responding to the distributed transaction manager.  Only
after the distributed transaction manager receives successful responses
from all of its <i>prepare</i> messages should it issue any
<i>commit</i> messages.</p>
<p>In the case of nested transactions, preparing the parent causes all
unresolved children of the parent transaction to be committed.  Child
transactions should never be explicitly prepared.  Their fate will be
resolved along with their parent's during global recovery.</p>
<p>The DB_TXN-&gt;prepare method
returns a non-zero error value on failure
and 0 on success.
</p>
<b>Parameters</b> <br>
 <b>gid</b><ul compact><li>The <b>gid</b> parameter specifies the global transaction ID by which this
transaction will be known.  This global transaction ID will be returned
in calls to <a href="../api_c/txn_recover.html">DB_ENV-&gt;txn_recover</a>, telling the application which global
transactions must be resolved.</ul>
<br>
<hr size=1 noshade>
<br><b>Class</b>
<a href="../api_c/env_class.html">DB_ENV</a>, <a href="../api_c/txn_class.html">DB_TXN</a>
<br><b>See Also</b>
<a href="../api_c/txn_list.html">Transaction Subsystem and Related Methods</a>
</tt>
<table width="100%"><tr><td><br></td><td align=right>
<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>
</td></tr></table>
<p><font size=1>Copyright (c) 1996,2008 Oracle.  All rights reserved.</font>
</body>
</html>