2
<!--Copyright 1997-2002 by Sleepycat Software, Inc.-->
3
<!--All rights reserved.-->
4
<!--See the file LICENSE for redistribution information.-->
7
<title>Berkeley DB: DB_ENV->set_app_dispatch</title>
8
<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
9
<meta name="keywords" content="embedded,database,programmatic,toolkit,b+tree,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,java,C,C++">
12
<a name="2"><!--meow--></a>
13
<table width="100%"><tr valign=top>
15
<h1>DB_ENV->set_app_dispatch</h1>
18
<a href="../api_c/c_index.html"><img src="../images/api.gif" alt="API"></a><a href="../reftoc.html"><img src="../images/ref.gif" alt="Ref"></a>
26
DB_ENV->set_app_dispatch(DB_ENV *dbenv,
27
int (*tx_recover)(DB_ENV *dbenv,
28
DBT *log_rec, DB_LSN *lsn, db_recops op));
31
<p>Set the application's function to be called during transaction abort
32
and recovery. This function must return 0 on success and either
33
<b>errno</b> or a value outside of the Berkeley DB error name space on
34
failure. It takes four arguments:
36
<p><dt>dbenv <dd>A Berkeley DB environment.
37
<p><dt>log_rec<dd>A log record.
38
<p><dt>lsn<dd>A log sequence number.
39
<p><dt>op<dd>One of the following values:
41
<p><dt><a name="DB_TXN_BACKWARD_ROLL">DB_TXN_BACKWARD_ROLL</a><dd>The log is being read backward to determine which transactions have been
42
committed and to abort those operations that were not; undo the operation
43
described by the log record.
44
<p><dt><a name="DB_TXN_FORWARD_ROLL">DB_TXN_FORWARD_ROLL</a><dd>The log is being played forward; redo the operation described by the log
46
<p><dt><a name="DB_TXN_ABORT">DB_TXN_ABORT</a><dd>The log is being read backward during a transaction abort; undo the
47
operation described by the log record.
48
<p><dt><a name="DB_TXN_APPLY">DB_TXN_APPLY</a><dd>The log is being applied on a replica site; redo the operation
49
described by the log record.
50
<p><dt><a name="DB_TXN_PRINT">DB_TXN_PRINT</a><dd>The log is being printed for debugging purposes; print the contents of
51
this log record in the desired format.
54
<p>The DB_TXN_FORWARD_ROLL and DB_TXN_APPLY operations
55
frequently imply the same actions, redoing changes that appear in the
56
log record, although if a recovery function is to be used on a
57
replication client where reads may be taking place concurrently with
58
the processing of incoming messages, DB_TXN_APPLY operations
59
should also perform appropriate locking. The macro DB_REDO(op) checks
60
that the operation is one of DB_TXN_FORWARD_ROLL or
61
DB_TXN_APPLY, and should be used in the recovery code to refer
62
to the conditions under which operations should be redone. Similarly,
63
the macro DB_UNDO(op) checks if the operation is one of
64
DB_TXN_BACKWARD_ROLL or DB_TXN_ABORT.
65
<p>The DB_ENV->set_app_dispatch method configures operations performed using the specified
66
<a href="../api_c/env_class.html">DB_ENV</a> handle, not all operations performed on the underlying
68
<p>The DB_ENV->set_app_dispatch interface may not be called after the <a href="../api_c/env_open.html">DB_ENV->open</a>
70
If the database environment already exists when
71
<a href="../api_c/env_open.html">DB_ENV->open</a> is called, the information specified to DB_ENV->set_app_dispatch
72
must be consistent with the existing environment or corruption can
74
<p>The DB_ENV->set_app_dispatch method returns a non-zero error value on failure and 0 on success.
76
<p>The DB_ENV->set_app_dispatch method may fail and return a non-zero error for the following conditions:
78
<p><dt>EINVAL<dd>An invalid flag value or parameter was specified.
79
<p>Called after <a href="../api_c/env_open.html">DB_ENV->open</a> was called.
81
<p>The DB_ENV->set_app_dispatch method may fail and return a non-zero error for errors specified for other Berkeley DB and C library or system functions.
82
If a catastrophic error has occurred, the DB_ENV->set_app_dispatch method may fail and
83
return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>,
84
in which case all subsequent Berkeley DB calls will fail in the same way.
86
<a href="../api_c/env_class.html">DB_ENV</a>, <a href="../api_c/txn_class.html">DB_TXN</a>
88
<a href="../api_c/txn_list.html">Transaction Subsystem and Related Methods</a>
90
<table width="100%"><tr><td><br></td><td align=right>
91
<a href="../api_c/c_index.html"><img src="../images/api.gif" alt="API"></a><a href="../reftoc.html"><img src="../images/ref.gif" alt="Ref"></a>
93
<p><font size=1><a href="http://www.sleepycat.com">Copyright Sleepycat Software</a></font>