Software: Apache/2.0.54 (Fedora). PHP/5.0.4 uname -a: Linux mina-info.me 2.6.17-1.2142_FC4smp #1 SMP Tue Jul 11 22:57:02 EDT 2006 i686 uid=48(apache) gid=48(apache) groups=48(apache) Safe-mode: OFF (not secure) /usr/share/doc/db4-devel-4.3.27/ref/apprec/ drwxr-xr-x |
Viewing file: Select action/file-type:
Automatically generated functionsThe XXX.src file is processed using the gen_rec.awk script included in the dist directory of the Berkeley DB distribution. This is an awk script that is executed from with the following command line: awk -f gen_rec.awk \ -v source_file=C_FILE \ -v header_file=H_FILE \ -v template_file=TMP_FILE < XXX.src where C_FILE is the name of the file into which to place the automatically generated C code, H_FILE is the name of the file into which to place the automatically generated data structures and declarations, and TMP_FILE is the name of the file into which to place a template for the recovery routines. Because the gen_rec.awk script uses sources files located relative to the Berkeley DB dist directory, it must be run from the dist directory. For example, in building the Berkeley DB logging and recovery routines for ex_apprec, the following script is used to rebuild the automatically generated files: E=../examples_c/ex_apprec For each log record description found in the XXX.src file, the following structure declarations and #defines will be created in the file header_file: #define DB_PREFIX_RECORD_TYPE /* Integer ID number */ Thus, the auto-generated ex_apprec_mkdir_args structure looks as follows: typedef struct _ex_apprec_mkdir_args { u_int32_t type; DB_TXN *txnid; DB_LSN prev_lsn; DBT dirname; } ex_apprec_mkdir_args; 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. (Note that the template assumes that the record is manipulating the internals of a Berkeley DB database and sets up database handles, page structures, and such for convenience. Many application-specific log records will not need these, and may simply delete much of the template. See ex_apprec_template and ex_apprec_rec.c for an example.) 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:
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. The log function marshalls the parameters into a buffer, and calls DB_ENV->log_put on that buffer returning 0 on success and non-zero on failure. The log function takes the following parameters:
The read function takes a buffer and unmarshalls its contents into a structure of the appropriate type. It returns 0 on success and non-zero on error. After the fields of the structure have been used, the pointer returned from the read function should be freed. The read function takes the following parameters:
The print function displays the contents of the record. The print function takes the same parameters as the recovery function described previously. Although some of the parameters are unused by the print function, taking the same parameters allows a single dispatch loop to dispatch to a variety of functions. The print function takes the following parameters:
Finally, the source file will contain a function (named XXX_init_print, where XXX is replaced by the prefix) which should be added to the initialization part of the standalone db_printlog utility code so that utility can be used to display application-specific log records.
Copyright (c) 1996-2004 Sleepycat Software, Inc. - All rights reserved. |
:: Command execute :: | |
--[ c99shell v. 1.0 pre-release build #16 powered by Captain Crunch Security Team | http://ccteam.ru | Generation time: 0.0042 ]-- |