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: DbEnv::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>DbEnv::set_app_dispatch</b> 14</td> 15<td align=right> 16<a href="../api_cxx/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 <db_cxx.h> 23<p> 24int 25DbEnv::set_app_dispatch(int (*tx_recover)(DbEnv *dbenv, 26 Dbt *log_rec, DbLsn *lsn, db_recops op)); 27</pre></b> 28<hr size=1 noshade> 29<b>Description: DbEnv::set_app_dispatch</b> 30<p>Declare a function to be called during transaction abort and recovery 31to process application-specific log records.</p> 32<p>The DbEnv::set_app_dispatch method configures operations performed using the specified 33<a href="../api_cxx/env_class.html">DbEnv</a> handle, not all operations performed on the underlying 34database environment.</p> 35<p>The DbEnv::set_app_dispatch method may not be called after the <a href="../api_cxx/env_open.html">DbEnv::open</a> method is 36called. 37If the database environment already exists when 38<a href="../api_cxx/env_open.html">DbEnv::open</a> is called, the information specified to DbEnv::set_app_dispatch 39must be consistent with the existing environment or corruption can 40occur.</p> 41<p>The DbEnv::set_app_dispatch method 42either returns a non-zero error value 43or throws an exception that encapsulates a non-zero error value on 44failure, and returns 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 DbEnv::set_app_dispatch method 84may fail and throw 85<a href="../api_cxx/except_class.html">DbException</a>, 86encapsulating one of the following non-zero errors, or return one of 87the following non-zero errors:</p> 88<br> 89<b>EINVAL</b><ul compact><li>If the method was called after <a href="../api_cxx/env_open.html">DbEnv::open</a> was called; or if an 90invalid flag value or parameter was specified.</ul> 91<br> 92<hr size=1 noshade> 93<br><b>Class</b> 94<a href="../api_cxx/env_class.html">DbEnv</a>, <a href="../api_cxx/txn_class.html">DbTxn</a> 95<br><b>See Also</b> 96<a href="../api_cxx/txn_list.html">Transaction Subsystem and Related Methods</a> 97</tt> 98<table width="100%"><tr><td><br></td><td align=right> 99<a href="../api_cxx/api_core.html"><img src="../images/api.gif" alt="API"></a><a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a> 100</td></tr></table> 101<p><font size=1>Copyright (c) 1996,2008 Oracle. All rights reserved.</font> 102</body> 103</html> 104