1<?xml version="1.0" encoding="UTF-8" standalone="no"?> 2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 3<html xmlns="http://www.w3.org/1999/xhtml"> 4 <head> 5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 6 <title>DB_ENV->set_app_dispatch()</title> 7 <link rel="stylesheet" href="apiReference.css" type="text/css" /> 8 <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /> 9 <link rel="start" href="index.html" title="Berkeley DB C API Reference" /> 10 <link rel="up" href="env.html" title="Chapter��5.�� The DB_ENV Handle" /> 11 <link rel="prev" href="envset_alloc.html" title="DB_ENV->set_alloc()" /> 12 <link rel="next" href="envset_data_dir.html" title="DB_ENV->set_data_dir()" /> 13 </head> 14 <body> 15 <div class="navheader"> 16 <table width="100%" summary="Navigation header"> 17 <tr> 18 <th colspan="3" align="center">DB_ENV->set_app_dispatch()</th> 19 </tr> 20 <tr> 21 <td width="20%" align="left"><a accesskey="p" href="envset_alloc.html">Prev</a>��</td> 22 <th width="60%" align="center">Chapter��5.�� 23 The DB_ENV Handle 24 </th> 25 <td width="20%" align="right">��<a accesskey="n" href="envset_data_dir.html">Next</a></td> 26 </tr> 27 </table> 28 <hr /> 29 </div> 30 <div class="sect1" lang="en" xml:lang="en"> 31 <div class="titlepage"> 32 <div> 33 <div> 34 <h2 class="title" style="clear: both"><a id="envset_app_dispatch"></a>DB_ENV->set_app_dispatch()</h2> 35 </div> 36 </div> 37 </div> 38 <pre class="programlisting">#include <db.h> 39 40int 41DB_ENV->set_app_dispatch(DB_ENV *dbenv, 42 int (*tx_recover)(DB_ENV *dbenv, 43 DBT *log_rec, DB_LSN *lsn, db_recops op)); </pre> 44 <p> 45 Declare a function to be called during transaction abort and recovery 46 to process application-specific log records. 47 </p> 48 <p> 49 The <code class="methodname">DB_ENV->set_app_dispatch()</code> method configures operations performed 50 using the specified <a class="link" href="env.html" title="Chapter��5.�� The DB_ENV Handle">DB_ENV</a> handle, not all 51 operations performed on the underlying database environment. 52 </p> 53 <p> 54 The <code class="methodname">DB_ENV->set_app_dispatch()</code> method may not be called after the 55 <a class="xref" href="envopen.html" title="DB_ENV->open()">DB_ENV->open()</a> method is 56 called. If the database environment already exists when 57 <a class="xref" href="envopen.html" title="DB_ENV->open()">DB_ENV->open()</a> is called, the 58 information specified to <code class="methodname">DB_ENV->set_app_dispatch()</code> must be 59 consistent with the existing environment or corruption can occur. 60 </p> 61 <p> 62 The <code class="methodname">DB_ENV->set_app_dispatch()</code> method returns a non-zero error value 63 on failure and 0 on success. 64 </p> 65 <div class="sect2" lang="en" xml:lang="en"> 66 <div class="titlepage"> 67 <div> 68 <div> 69 <h3 class="title"><a id="id1666877"></a>Parameters</h3> 70 </div> 71 </div> 72 </div> 73 <div class="sect3" lang="en" xml:lang="en"> 74 <div class="titlepage"> 75 <div> 76 <div> 77 <h4 class="title"><a id="id1666931"></a>tx_recover</h4> 78 </div> 79 </div> 80 </div> 81 <p> 82 The <span class="bold"><strong>tx_recover</strong></span> parameter is the 83 application's abort and recovery function. The function takes four 84 parameters: 85 </p> 86 <div class="itemizedlist"> 87 <ul type="disc"> 88 <li> 89 <p> 90 <code class="literal">dbenv</code> 91 </p> 92 <p> 93 The <span class="bold"><strong>dbenv</strong></span> parameter is the enclosing 94 database environment handle. 95 </p> 96 </li> 97 <li> 98 <p> 99 <code class="literal">log_rec</code> 100 </p> 101 <p> 102 The <span class="bold"><strong>log_rec</strong></span> parameter is a log 103 record. 104 </p> 105 </li> 106 <li> 107 <p> 108 <code class="literal">lsn</code> 109 </p> 110 <p> 111 The <span class="bold"><strong>lsn</strong></span> parameter is a log sequence 112 number. 113 </p> 114 </li> 115 <li> 116 <p> 117 <code class="literal">op</code> 118 </p> 119 <p> 120 The <span class="bold"><strong>op</strong></span> parameter is one of the 121 following values: 122 </p> 123 <div class="itemizedlist"> 124 <ul type="circle"> 125 <li> 126 <p><a id="set_app_dispatch_DB_TXN_BACKWARD_ROLL"></a> 127 <code class="literal">DB_TXN_BACKWARD_ROLL</code> 128 </p> 129 <p> 130 The log is being read backward to determine which transactions have 131 been committed and to abort those operations that were not; undo the 132 operation described by the log record. 133 </p> 134 </li> 135 <li> 136 <p><a id="set_app_dispatch_DB_TXN_FORWARD_ROLL"></a> 137 <code class="literal">DB_TXN_FORWARD_ROLL</code> 138 </p> 139 <p> 140 The log is being played forward; redo the operation described by the 141 log record. 142 </p> 143 </li> 144 <li> 145 <p><a id="set_app_dispatch_DB_TXN_ABORT"></a> 146 <code class="literal">DB_TXN_ABORT</code> 147 </p> 148 <p> 149 The log is being read backward during a transaction abort; undo the 150 operation described by the log record. 151 </p> 152 </li> 153 <li> 154 <p><a id="set_app_dispatch_DB_TXN_APPLY"></a> 155 <code class="literal">DB_TXN_APPLY</code> 156 </p> 157 <p> 158 The log is being applied on a replica site; redo the operation 159 described by the log record. 160 </p> 161 </li> 162 <li> 163 <p><a id="set_app_dispatch_DB_TXN_PRINT"></a> 164 <code class="literal">DB_TXN_PRINT</code> 165 </p> 166 <p> 167 The log is being printed for debugging purposes; print the contents of 168 this log record in the desired format. 169 </p> 170 </li> 171 </ul> 172 </div> 173 <p> 174 The DB_TXN_FORWARD_ROLL and DB_TXN_APPLY operations frequently imply 175 the same actions, redoing changes that appear in the log record, 176 although if a recovery function is to be used on a replication client 177 where reads may be taking place concurrently with the processing of 178 incoming messages, DB_TXN_APPLY operations should also perform 179 appropriate locking. The macro DB_REDO(op) checks that the operation 180 is one of DB_TXN_FORWARD_ROLL or DB_TXN_APPLY, and should be used in 181 the recovery code to refer to the conditions under which operations 182 should be redone. Similarly, the macro DB_UNDO(op) checks if the 183 operation is one of DB_TXN_BACKWARD_ROLL or DB_TXN_ABORT. 184 </p> 185 </li> 186 </ul> 187 </div> 188 <p> 189 The function must return 0 on success and either <span class="bold"><strong>errno</strong></span> 190 or a value outside of the Berkeley DB error name space on failure. 191 </p> 192 </div> 193 </div> 194 <div class="sect2" lang="en" xml:lang="en"> 195 <div class="titlepage"> 196 <div> 197 <div> 198 <h3 class="title"><a id="id1667211"></a>Errors</h3> 199 </div> 200 </div> 201 </div> 202 <p> 203 The <code class="methodname">DB_ENV->set_app_dispatch()</code> <span> 204 <span> 205 method may fail and return one of the following non-zero errors: 206 </span> 207 208 </span> 209 </p> 210 <div class="sect3" lang="en" xml:lang="en"> 211 <div class="titlepage"> 212 <div> 213 <div> 214 <h4 class="title"><a id="id1667206"></a>EINVAL</h4> 215 </div> 216 </div> 217 </div> 218 <p> 219 If the method was called after <a class="xref" href="envopen.html" title="DB_ENV->open()">DB_ENV->open()</a> 220 was called; or if an invalid flag value or parameter was specified. 221 </p> 222 </div> 223 </div> 224 <div class="sect2" lang="en" xml:lang="en"> 225 <div class="titlepage"> 226 <div> 227 <div> 228 <h3 class="title"><a id="id1667055"></a>Class</h3> 229 </div> 230 </div> 231 </div> 232 <p> 233 <a class="link" href="env.html" title="Chapter��5.�� The DB_ENV Handle">DB_ENV</a>, <a class="link" href="txn.html" title="Chapter��12.�� The DB_TXN Handle">DB_TXN</a> 234 </p> 235 </div> 236 <div class="sect2" lang="en" xml:lang="en"> 237 <div class="titlepage"> 238 <div> 239 <div> 240 <h3 class="title"><a id="id1666928"></a>See Also</h3> 241 </div> 242 </div> 243 </div> 244 <p> 245 <a class="xref" href="txn.html#txnlist" title="Transaction Subsystem and Related Methods">Transaction Subsystem and Related Methods</a> 246 </p> 247 </div> 248 </div> 249 <div class="navfooter"> 250 <hr /> 251 <table width="100%" summary="Navigation footer"> 252 <tr> 253 <td width="40%" align="left"><a accesskey="p" href="envset_alloc.html">Prev</a>��</td> 254 <td width="20%" align="center"> 255 <a accesskey="u" href="env.html">Up</a> 256 </td> 257 <td width="40%" align="right">��<a accesskey="n" href="envset_data_dir.html">Next</a></td> 258 </tr> 259 <tr> 260 <td width="40%" align="left" valign="top">DB_ENV->set_alloc()��</td> 261 <td width="20%" align="center"> 262 <a accesskey="h" href="index.html">Home</a> 263 </td> 264 <td width="40%" align="right" valign="top">��DB_ENV->set_data_dir()</td> 265 </tr> 266 </table> 267 </div> 268 </body> 269</html> 270