1<!--$Id: txn_recover.so,v 10.28 2007/05/30 17:24:41 margo 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_ENV-&gt;txn_recover</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_ENV-&gt;txn_recover</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_ENV-&gt;txn_recover(DB_ENV *dbenv, DB_PREPLIST preplist[],
26    long count, long *retp, u_int32_t flags);
27</pre></b>
28<hr size=1 noshade>
29<b>Description: DB_ENV-&gt;txn_recover</b>
30<p>Database environment recovery restores transactions that were prepared,
31but not yet resolved at the time of the system shut down or crash, to
32their state prior to the shut down or crash, including any locks
33previously held.  The DB_ENV-&gt;txn_recover method returns a list of those
34prepared transactions.</p>
35<p>The DB_ENV-&gt;txn_recover method should only be called after the environment has
36been recovered.</p>
37<p>Multiple threads of control may call DB_ENV-&gt;txn_recover, but only one
38thread of control may resolve each returned transaction, that is, only
39one thread of control may call <a href="../api_c/txn_commit.html">DB_TXN-&gt;commit</a> or <a href="../api_c/txn_abort.html">DB_TXN-&gt;abort</a>
40on each returned transaction.  Callers of DB_ENV-&gt;txn_recover must call
41<a href="../api_c/txn_discard.html">DB_TXN-&gt;discard</a> to discard each transaction they do not resolve.</p>
42<p>On return from DB_ENV-&gt;txn_recover, the <b>preplist</b> parameter will
43be filled in with a list of transactions that must be resolved by the
44application (committed, aborted or discarded).  The <b>preplist</b>
45parameter is a structure of type DB_PREPLIST; the following DB_PREPLIST
46fields will be filled in:</p>
47<br>
48<b>DB_TXN * txn;</b><ul compact><li>The transaction handle for the transaction.</ul>
49<b>u_int8_t gid[DB_XIDDATASIZE];</b><ul compact><li>The global transaction ID for the transaction.  The global transaction
50ID is the one specified when the transaction was prepared.  The
51application is responsible for ensuring uniqueness among global
52transaction IDs.</ul>
53<br>
54<p>The DB_ENV-&gt;txn_recover method
55returns a non-zero error value on failure
56and 0 on success.
57</p>
58<b>Parameters</b> <br>
59 <b>count</b><ul compact><li>The <b>count</b> parameter specifies the number of available entries
60in the passed-in <b>preplist</b> array.  The <b>retp</b> parameter
61returns the number of entries DB_ENV-&gt;txn_recover has filled in, in the
62array.</ul>
63 <b>flags</b><ul compact><li>The <b>flags</b> parameter must be set to one of the following values:
64<br>
65<b><a name="DB_FIRST">DB_FIRST</a></b><ul compact><li>Begin returning a list of prepared, but not yet resolved transactions.
66Specifying this flag begins a new pass over all prepared, but not yet
67completed transactions, regardless of whether they have already been returned
68in previous calls to DB_ENV-&gt;txn_recover.
69Calls to DB_ENV-&gt;txn_recover from different threads of control should not
70be intermixed in the same environment.</ul>
71<b><a name="DB_NEXT">DB_NEXT</a></b><ul compact><li>Continue returning a list of prepared, but not yet resolved transactions,
72starting where the last call to DB_ENV-&gt;txn_recover left off.</ul>
73<br></ul>
74 <b>preplist</b><ul compact><li>The <b>preplist</b> parameter references memory into which
75 the list of transactions to be resolved by the application is copied.</ul> 
76<br>
77<hr size=1 noshade>
78<br><b>Class</b>
79<a href="../api_c/env_class.html">DB_ENV</a>, <a href="../api_c/txn_class.html">DB_TXN</a>
80<br><b>See Also</b>
81<a href="../api_c/txn_list.html">Transaction Subsystem and Related Methods</a>
82</tt>
83<table width="100%"><tr><td><br></td><td align=right>
84<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>
85</td></tr></table>
86<p><font size=1>Copyright (c) 1996,2008 Oracle.  All rights reserved.</font>
87</body>
88</html>
89