2
<!--Copyright 1997-2002 by Sleepycat Software, Inc.-->
3
<!--All rights reserved.-->
4
<!--See the file LICENSE for redistribution information.-->
7
<title>Berkeley DB: DbEnv::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>DbEnv::set_app_dispatch</h1>
18
<a href="../api_cxx/c_index.html"><img src="../images/api.gif" alt="API"></a><a href="../reftoc.html"><img src="../images/ref.gif" alt="Ref"></a>
23
#include <db_cxx.h>
26
DbEnv::set_app_dispatch(int (*)(DbEnv *dbenv,
27
Dbt *log_rec, DbLsn *lsn, db_recops op));
30
<p>Set the application's method to be called during transaction abort
31
and recovery. This method must return 0 on success and either
32
<b>errno</b> or a value outside of the Berkeley DB error name space on
33
failure. It takes four arguments:
35
<p><dt>dbenv <dd>A Berkeley DB environment.
36
<p><dt>log_rec<dd>A log record.
37
<p><dt>lsn<dd>A log sequence number.
38
<p><dt>op<dd>One of the following values:
40
<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
41
committed and to abort those operations that were not; undo the operation
42
described by the log record.
43
<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
45
<p><dt><a name="DB_TXN_ABORT">DB_TXN_ABORT</a><dd>The log is being read backward during a transaction abort; undo the
46
operation described by the log record.
47
<p><dt><a name="DB_TXN_APPLY">DB_TXN_APPLY</a><dd>The log is being applied on a replica site; redo the operation
48
described by the log record.
49
<p><dt><a name="DB_TXN_PRINT">DB_TXN_PRINT</a><dd>The log is being printed for debugging purposes; print the contents of
50
this log record in the desired format.
53
<p>The DB_TXN_FORWARD_ROLL and DB_TXN_APPLY operations
54
frequently imply the same actions, redoing changes that appear in the
55
log record, although if a recovery function is to be used on a
56
replication client where reads may be taking place concurrently with
57
the processing of incoming messages, DB_TXN_APPLY operations
58
should also perform appropriate locking. The macro DB_REDO(op) checks
59
that the operation is one of DB_TXN_FORWARD_ROLL or
60
DB_TXN_APPLY, and should be used in the recovery code to refer
61
to the conditions under which operations should be redone. Similarly,
62
the macro DB_UNDO(op) checks if the operation is one of
63
DB_TXN_BACKWARD_ROLL or DB_TXN_ABORT.
64
<p>The DbEnv::set_app_dispatch method configures operations performed using the specified
65
<a href="../api_cxx/env_class.html">DbEnv</a> handle, not all operations performed on the underlying
67
<p>The DbEnv::set_app_dispatch interface may not be called after the <a href="../api_cxx/env_open.html">DbEnv::open</a>
69
If the database environment already exists when
70
<a href="../api_cxx/env_open.html">DbEnv::open</a> is called, the information specified to DbEnv::set_app_dispatch
71
must be consistent with the existing environment or corruption can
73
<p>The DbEnv::set_app_dispatch method either returns a non-zero error value or throws an exception that
74
encapsulates a non-zero error value on failure, and returns 0 on success.
76
<p>The DbEnv::set_app_dispatch method may fail and throw an exception or 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_cxx/env_open.html">DbEnv::open</a> was called.
81
<p>The DbEnv::set_app_dispatch method may fail and throw an exception or return a non-zero error for errors specified for other Berkeley DB and C library or system methods.
82
If a catastrophic error has occurred, the DbEnv::set_app_dispatch method may fail and
83
either return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a> or throw a
84
<a href="../api_cxx/runrec_class.html">DbRunRecoveryException</a>,
85
in which case all subsequent Berkeley DB calls will fail in the same way.
87
<a href="../api_cxx/env_class.html">DbEnv</a>, <a href="../api_cxx/txn_class.html">DbTxn</a>
89
<a href="../api_cxx/txn_list.html">Transaction Subsystem and Related Methods</a>
91
<table width="100%"><tr><td><br></td><td align=right>
92
<a href="../api_cxx/c_index.html"><img src="../images/api.gif" alt="API"></a><a href="../reftoc.html"><img src="../images/ref.gif" alt="Ref"></a>
94
<p><font size=1><a href="http://www.sleepycat.com">Copyright Sleepycat Software</a></font>