1<!--$Id: env_set_app_dispatch.so,v 10.54 2004/08/13 03:38:57 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_ENV-&gt;set_app_dispatch</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;set_app_dispatch</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;set_app_dispatch(DB_ENV *dbenv,
26    int (*tx_recover)(DB_ENV *dbenv,
27    DBT *log_rec, DB_LSN *lsn, db_recops op));
28</pre></b>
29<hr size=1 noshade>
30<b>Description: DB_ENV-&gt;set_app_dispatch</b>
31<p>Declare a function to be called during transaction abort and recovery
32to process application-specific log records.</p>
33<p>The DB_ENV-&gt;set_app_dispatch method configures operations performed using the specified
34<a href="/api_c/env_class.html">DB_ENV</a> handle, not all operations performed on the underlying
35database environment.</p>
36<p>The DB_ENV-&gt;set_app_dispatch method may not be called after the <a href="/api_c/env_open.html">DB_ENV-&gt;open</a> method is
37called.
38If the database environment already exists when
39<a href="/api_c/env_open.html">DB_ENV-&gt;open</a> is called, the information specified to DB_ENV-&gt;set_app_dispatch
40must be consistent with the existing environment or corruption can
41occur.</p>
42<p>The DB_ENV-&gt;set_app_dispatch method
43returns a non-zero error value on failure
44and 0 on success.
45</p>
46<b>Parameters</b> <br>
47 <b>tx_recover</b><ul compact><li>The <b>tx_recover</b> parameter is the application's abort and recovery
48function.  The function takes four parameters:
49<br>
50<b><b>dbenv</b></b><ul compact><li>The <b>dbenv</b> parameter is the enclosing database environment handle.</ul>
51<b><b>log_rec</b></b><ul compact><li>The <b>log_rec</b> parameter is a log record.</ul>
52<b><b>lsn</b></b><ul compact><li>The <b>lsn</b> parameter is a log sequence number.</ul>
53<b><b>op</b></b><ul compact><li>The <b>op</b> parameter is one of the following values:</ul>
54<br>
55<b><a name="DB_TXN_BACKWARD_ROLL">DB_TXN_BACKWARD_ROLL</a></b><ul compact><li>The log is being read backward to determine which transactions have been
56committed and to abort those operations that were not; undo the operation
57described by the log record.</ul>
58<b><a name="DB_TXN_FORWARD_ROLL">DB_TXN_FORWARD_ROLL</a></b><ul compact><li>The log is being played forward; redo the operation described by the log
59record.</ul>
60<b><a name="DB_TXN_ABORT">DB_TXN_ABORT</a></b><ul compact><li>The log is being read backward during a transaction abort; undo the
61operation described by the log record.</ul>
62<b><a name="DB_TXN_APPLY">DB_TXN_APPLY</a></b><ul compact><li>The log is being applied on a replica site; redo the operation
63described by the log record.</ul>
64<b><a name="DB_TXN_PRINT">DB_TXN_PRINT</a></b><ul compact><li>The log is being printed for debugging purposes; print the contents of
65this log record in the desired format.</ul>
66<br>
67<p>The DB_TXN_FORWARD_ROLL and DB_TXN_APPLY operations
68frequently imply the same actions, redoing changes that appear in the
69log record, although if a recovery function is to be used on a
70replication client where reads may be taking place concurrently with the
71processing of incoming messages, DB_TXN_APPLY operations should
72also perform appropriate locking.  The macro DB_REDO(op) checks that the
73operation is one of DB_TXN_FORWARD_ROLL or DB_TXN_APPLY,
74and should be used in the recovery code to refer to the conditions under
75which operations should be redone. Similarly, the macro DB_UNDO(op)
76checks if the operation is one of DB_TXN_BACKWARD_ROLL or
77DB_TXN_ABORT.</p>
78<br>
79<p>The function must return 0 on success and either <b>errno</b> or a
80value outside of the Berkeley DB error name space on failure.</p></ul>
81<br>
82<br><b>Errors</b>
83<p>The DB_ENV-&gt;set_app_dispatch method
84may fail and return one of the following non-zero errors:</p>
85<br>
86<b>EINVAL</b><ul compact><li>If the method was called after <a href="/api_c/env_open.html">DB_ENV-&gt;open</a> was called; or if an
87invalid flag value or parameter was specified.</ul>
88<br>
89<hr size=1 noshade>
90<br><b>Class</b>
91<a href="/api_c/env_class.html">DB_ENV</a>, <a href="/api_c/txn_class.html">DB_TXN</a>
92<br><b>See Also</b>
93<a href="/api_c/txn_list.html">Transaction Subsystem and Related Methods</a>
94</tt>
95<table width="100%"><tr><td><br></td><td align=right>
96<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>
97</td></tr></table>
98<p><font size=1>Copyright (c) 1996,2008 Oracle.  All rights reserved.</font>
99</body>
100</html>
101