<p>The template_file will contain a template for a recovery function. The
recovery function is called on each record read from the log during
system recovery, transaction abort, or the application of log records
on a replication client, and is expected to redo or undo the operations
described by that record. The details of the recovery function will be
specific to the record being logged and need to be written manually, but
the template provides a good starting point. (See ex_apprec_template
and ex_apprec_rec.c for an example of both the template produced and the
resulting recovery function.)</p>
<p>The template file should be copied to a source file in the application
(but not the automatically generated source_file, as that will get
overwritten each time gen_rec.awk is run) and fully developed there.
The recovery function takes the following parameters:</p>
<divclass="blockquote">
<blockquoteclass="blockquote">
<divclass="variablelist">
<dl>
<dt>
<spanclass="term">dbenv</span>
</dt>
<dd>The environment in which recovery is running.</dd>
<dt>
<spanclass="term">rec</span>
</dt>
<dd>The record being recovered.</dd>
<dt>
<spanclass="term">lsn</span>
</dt>
<dd>The log sequence number of the record being recovered. The
prev_lsn field, automatically included in every auto-generated log
record, should be returned through this argument. The prev_lsn field
is used to chain log records together to allow transaction aborts;
because the recovery function is the only place that a log record gets
parsed, the responsibility for returning this value lies with the
recovery function writer.</dd>
<dt>
<spanclass="term">op</span>
</dt>
<dd>A parameter of type db_recops, which indicates what operation is being
run (<ahref="../api_reference/C/envset_app_dispatch.html#set_app_dispatch_DB_TXN_ABORT"class="olink">DB_TXN_ABORT</a>, <ahref="../api_reference/C/envset_app_dispatch.html#set_app_dispatch_DB_TXN_APPLY"class="olink">DB_TXN_APPLY</a>, <ahref="../api_reference/C/envset_app_dispatch.html#set_app_dispatch_DB_TXN_BACKWARD_ROLL"class="olink">DB_TXN_BACKWARD_ROLL</a>,
<ahref="../api_reference/C/envset_app_dispatch.html#set_app_dispatch_DB_TXN_FORWARD_ROLL"class="olink">DB_TXN_FORWARD_ROLL</a> or <ahref="../api_reference/C/envset_app_dispatch.html#set_app_dispatch_DB_TXN_PRINT"class="olink">DB_TXN_PRINT</a>).
</dd>
</dl>
</div>
</blockquote>
</div>
<p>In addition to the header_file and template_file, a source_file is
created, containing a log, read, recovery, and print function for each
record type.</p>
<p>The log function marshalls the parameters into a buffer, and calls
<ahref="../api_reference/C/logput.html"class="olink">DB_ENV->log_put()</a> on that buffer returning 0 on success and non-zero on
failure. The log function takes the following parameters:</p>
<divclass="blockquote">
<blockquoteclass="blockquote">
<divclass="variablelist">
<dl>
<dt>
<spanclass="term">dbenv</span>
</dt>
<dd>The environment in which recovery is running.</dd>
<dt>
<spanclass="term">txnid</span>
</dt>
<dd>The transaction identifier for the transaction handle returned by