2
<!--Copyright 1997-2002 by Sleepycat Software, Inc.-->
3
<!--All rights reserved.-->
4
<!--See the file LICENSE for redistribution information.-->
7
<title>Berkeley DB: DB->verify</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>DB->verify</h1>
18
<a href="../api_c/c_index.html"><img src="../images/api.gif" alt="API"></a><a href="../reftoc.html"><img src="../images/ref.gif" alt="Ref"></a>
26
DB->verify(DB *db, const char *file,
27
const char *database, FILE *outfile, u_int32_t flags);
30
<p>The DB->verify method verifies the integrity of all databases in the
31
file specified by the <b>file</b> argument, and optionally outputs the
32
databases' key/data pairs to the file stream specified by the
33
<b>outfile</b> argument.
34
<p>The <b>flags</b> value must be set to 0 or
37
<p><dt><a name="DB_SALVAGE">DB_SALVAGE</a><dd>Write the key/data pairs from all databases in the file to the file stream
39
the <b>outfile</b> argument. The output format is the same as that
40
specified for the <a href="../utility/db_dump.html">db_dump</a> utility, and can be used as input for
41
the <a href="../utility/db_load.html">db_load</a> utility.
42
<p>Because the key/data pairs are output in page order as opposed to the sort
43
order used by <a href="../utility/db_dump.html">db_dump</a>, using DB->verify to dump key/data
44
pairs normally produces less than optimal loads for Btree databases.
46
<p>In addition, the following flags may be set by bitwise inclusively <b>OR</b>'ing them into the
47
<b>flags</b> parameter:
49
<p><dt><a name="DB_AGGRESSIVE">DB_AGGRESSIVE</a><dd>Output <b>all</b> the key/data pairs in the file that can be found.
50
By default, DB->verify does not assume corruption. For example,
51
if a key/data pair on a page is marked as deleted, it is not then written
52
to the output file. When DB_AGGRESSIVE is specified, corruption
53
is assumed, and any key/data pair that can be found is written. In this
54
case, key/data pairs that are corrupted or have been deleted may appear
55
in the output (even if the file being salvaged is in no way corrupt), and
56
the output will almost certainly require editing before being loaded into
58
<p><dt><a name="DB_PRINTABLE">DB_PRINTABLE</a><dd>When using the DB_SALVAGE flag, if characters in either the key
59
or data items are printing characters (as defined by <b>isprint</b>(3)), use printing characters to represent them. This flag permits users
60
to use standard text editors and tools to modify the contents of
61
databases or selectively remove data from salvager output.
62
<p>Note: different systems may have different notions about what characters
63
are considered <i>printing characters</i>, and databases dumped in
64
this manner may be less portable to external systems.
65
<p><dt><a name="DB_NOORDERCHK">DB_NOORDERCHK</a><dd>Skip the database checks for btree and duplicate sort order and for
67
<p>The DB->verify method normally verifies that btree keys and duplicate
68
items are correctly sorted, and hash keys are correctly hashed. If the
69
file being verified contains multiple databases using differing sorting
70
or hashing algorithms, some of them must necessarily fail database
71
verification because only one sort order or hash function can be
72
specified before DB->verify is called. To verify files with
73
multiple databases having differing sorting orders or hashing functions,
74
first perform verification of the file as a whole by using the
75
DB_NOORDERCHK flag, and then individually verify the sort order
76
and hashing function for each database in the file using the
78
<p><dt><a name="DB_ORDERCHKONLY">DB_ORDERCHKONLY</a><dd>Perform the database checks for btree and duplicate sort order and for
79
hashing, skipped by DB_NOORDERCHK.
80
<p>When this flag is specified, a <b>database</b> argument should also be
81
specified, indicating the database in the physical file which is to be
82
checked. This flag is only safe to use on databases that have already
83
successfully been verified using DB->verify with the
84
DB_NOORDERCHK flag set.
86
<p>The database argument must be set to NULL except when the
87
DB_ORDERCHKONLY flag is set.
88
<p><b>The DB->verify method does not perform any locking, even in Berkeley DB
89
environments that are configured with a locking subsystem. As such, it
90
should only be used on files that are not being modified by another
91
thread of control.</b>
92
<p>The DB->verify interface may not be called after the <a href="../api_c/db_open.html">DB->open</a>
94
<a name="3"><!--meow--></a>
95
<p>The DB->verify method returns a non-zero error value on failure, 0 on success, and <a href="../ref/program/errorret.html#DB_VERIFY_BAD">DB_VERIFY_BAD</a> if a database is corrupted. When the
96
DB_SALVAGE flag is specified, the <a href="../ref/program/errorret.html#DB_VERIFY_BAD">DB_VERIFY_BAD</a> return
97
means that all key/data pairs in the file may not have been successfully
99
<p>The DB->verify method is the underlying interface used by the <a href="../utility/db_verify.html">db_verify</a> utility.
100
See the <a href="../utility/db_verify.html">db_verify</a> utility source code for an example of using DB->verify
101
in a IEEE/ANSI Std 1003.1 (POSIX) environment.
102
<h1>Environment Variables</h1>
104
<p><dt>DB_HOME<dd>If a <b>dbenv</b> argument to <a href="../api_c/db_create.html">db_create</a> was specified, the
105
environment variable <b>DB_HOME</b> may be used as the path of the
106
database environment home.
107
<p>DB->verify is affected by any database directory specified using the
108
<a href="../api_c/env_set_data_dir.html">DB_ENV->set_data_dir</a> method, or by setting the "set_data_dir" string
109
in the environment's <b>DB_CONFIG</b> file.
112
<p>The DB->verify method may fail and return a non-zero error for the following conditions:
114
<p><dt>EINVAL<dd>An invalid flag value or parameter was specified.
115
<p>DB->verify was called after <a href="../api_c/db_open.html">DB->open</a>.
117
<p>The DB->verify method may fail and return a non-zero error for errors specified for other Berkeley DB and C library or system functions.
118
If a catastrophic error has occurred, the DB->verify method may fail and
119
return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>,
120
in which case all subsequent Berkeley DB calls will fail in the same way.
122
<a href="../api_c/db_class.html">DB</a>
124
<a href="../api_c/db_list.html">Databases and Related Methods</a>
126
<table width="100%"><tr><td><br></td><td align=right>
127
<a href="../api_c/c_index.html"><img src="../images/api.gif" alt="API"></a><a href="../reftoc.html"><img src="../images/ref.gif" alt="Ref"></a>
129
<p><font size=1><a href="http://www.sleepycat.com">Copyright Sleepycat Software</a></font>