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->verify()</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="db.html" title="Chapter��2.�� The DB Handle" /> 11 <link rel="prev" href="dbupgrade.html" title="DB->upgrade()" /> 12 <link rel="next" href="dbc.html" title="Chapter��3.�� The DBcursor Handle" /> 13 </head> 14 <body> 15 <div class="navheader"> 16 <table width="100%" summary="Navigation header"> 17 <tr> 18 <th colspan="3" align="center">DB->verify()</th> 19 </tr> 20 <tr> 21 <td width="20%" align="left"><a accesskey="p" href="dbupgrade.html">Prev</a>��</td> 22 <th width="60%" align="center">Chapter��2.�� 23 The DB Handle 24 </th> 25 <td width="20%" align="right">��<a accesskey="n" href="dbc.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="dbverify"></a>DB->verify()</h2> 35 </div> 36 </div> 37 </div> 38 <pre class="programlisting">#include <db.h> 39 40int 41DB->verify(DB *db, const char *file, 42 const char *database, FILE *outfile, u_int32_t flags); </pre> 43 <p> 44 The <code class="methodname">DB->verify()</code> method verifies the integrity of all databases in 45 the file specified by the <span class="bold"><strong>file</strong></span> 46 parameter, and optionally outputs the databases' key/data pairs to the 47 file stream specified by the <span class="bold"><strong>outfile</strong></span> 48 parameter. 49 </p> 50 <p> 51 <span class="bold"><strong>The <code class="methodname">DB->verify()</code> method does not perform any 52 locking, even in Berkeley DB environments that are configured with a 53 locking subsystem. As such, it should only be used on files that are 54 not being modified by another thread of control.</strong></span> 55 </p> 56 <p> 57 The <code class="methodname">DB->verify()</code> method may not be called after the 58 <a class="xref" href="dbopen.html" title="DB->open()">DB->open()</a> method is called. 59 </p> 60 <p> 61 The <a class="link" href="db.html" title="Chapter��2.�� The DB Handle">DB</a> handle may not be 62 accessed again after <code class="methodname">DB->verify()</code> is called, regardless of its 63 return. 64 </p> 65 <p> 66 The <code class="methodname">DB->verify()</code> method is the underlying method used by the <a class="link" href="db_verify.html" title="db_verify">db_verify</a> utility. See the 67 <a class="link" href="db_verify.html" title="db_verify">db_verify</a> utility 68 source code for an example of using <code class="methodname">DB->verify()</code> in a IEEE/ANSI Std 69 1003.1 (POSIX) environment. 70 </p> 71 <p> 72 The <code class="methodname">DB->verify()</code> method will return DB_VERIFY_BAD if a database is 73 corrupted. When the DB_SALVAGE flag is specified, the DB_VERIFY_BAD 74 return means that all key/data pairs in the file may not have been 75 successfully output. Unless otherwise specified, the <code class="methodname">DB->verify()</code> 76 <span> 77 <span> 78 method returns a non-zero error value on failure and 0 on success. 79 </span> 80 81 </span> 82 </p> 83 <div class="sect2" lang="en" xml:lang="en"> 84 <div class="titlepage"> 85 <div> 86 <div> 87 <h3 class="title"><a id="id1652773"></a>Parameters</h3> 88 </div> 89 </div> 90 </div> 91 <div class="sect3" lang="en" xml:lang="en"> 92 <div class="titlepage"> 93 <div> 94 <div> 95 <h4 class="title"><a id="id1652642"></a>database</h4> 96 </div> 97 </div> 98 </div> 99 <p> 100 The <span class="bold"><strong>database</strong></span> parameter is the 101 database in <span class="bold"><strong>file</strong></span> on which the 102 database checks for btree and duplicate sort order and for hashing are 103 to be performed. See the DB_ORDERCHKONLY flag for more information. 104 </p> 105 <p> 106 The database parameter must be set to NULL except when the 107 DB_ORDERCHKONLY flag is set. 108 </p> 109 </div> 110 <div class="sect3" lang="en" xml:lang="en"> 111 <div class="titlepage"> 112 <div> 113 <div> 114 <h4 class="title"><a id="id1652927"></a>file</h4> 115 </div> 116 </div> 117 </div> 118 <p> 119 The <span class="bold"><strong>file</strong></span> parameter is the physical 120 file in which the databases to be verified are found. 121 </p> 122 </div> 123 <div class="sect3" lang="en" xml:lang="en"> 124 <div class="titlepage"> 125 <div> 126 <div> 127 <h4 class="title"><a id="id1652950"></a>flags</h4> 128 </div> 129 </div> 130 </div> 131 <p> 132 The <span class="bold"><strong>flags</strong></span> parameter must be set to 0 133 or the following value: 134 </p> 135 <div class="itemizedlist"> 136 <ul type="disc"> 137 <li> 138 <p><a id="verify_DB_SALVAGE"></a> 139 <code class="literal">DB_SALVAGE</code> 140 </p> 141 <p> 142 Write the key/data pairs from all databases in the file to the file 143 stream named in the <span class="bold"><strong>outfile</strong></span> 144 parameter. Key values are written for Btree, Hash and Queue 145 databases, but not for Recno databases. 146 </p> 147 <p> 148 The output format is the same as that specified for the <a class="link" href="db_dump.html" title="db_dump">db_dump</a> utility, and can be used 149 as input for the <a class="link" href="db_load.html" title="db_load">db_load</a> 150 utility. 151 </p> 152 <p> 153 Because the key/data pairs are output in page order as opposed to the 154 sort order used by <a class="link" href="db_dump.html" title="db_dump">db_dump</a>, using <code class="methodname">DB->verify()</code> to 155 dump key/data pairs normally produces less than optimal loads for 156 Btree databases. 157 </p> 158 </li> 159 </ul> 160 </div> 161 <p> 162 In addition, the following flags may be set by bitwise inclusively 163 <span class="bold"><strong>OR</strong></span>'ing them into the <span class="bold"><strong>flags</strong></span> parameter: 164 </p> 165 <div class="itemizedlist"> 166 <ul type="disc"> 167 <li> 168 <p><a id="verify_DB_AGGRESSIVE"></a> 169 <code class="literal">DB_AGGRESSIVE</code> 170 </p> 171 <p> 172 Output <span class="bold"><strong>all</strong></span> the key/data pairs in the 173 file that can be found. By default, <code class="methodname">DB->verify()</code> does not assume 174 corruption. For example, if a key/data pair on a page is marked as 175 deleted, it is not then written to the output file. When 176 DB_AGGRESSIVE is specified, corruption is assumed, and any key/data 177 pair that can be found is written. In this case, key/data pairs that 178 are corrupted or have been deleted may appear in the output (even if 179 the file being salvaged is in no way corrupt), and the output will 180 almost certainly require editing before being loaded into a database. 181 </p> 182 </li> 183 <li> 184 <p><a id="verify_DB_PRINTABLE"></a> 185 <code class="literal">DB_PRINTABLE</code> 186 </p> 187 <p> 188 When using the DB_SALVAGE flag, if characters in either the key or 189 data items are printing characters (as defined by <span class="bold"><strong>isprint</strong></span>(3)), use printing characters to 190 represent them. This flag permits users to use standard text editors 191 and tools to modify the contents of databases or selectively remove 192 data from salvager output. 193 </p> 194 <p> 195 Note: different systems may have different notions about what 196 characters are considered <span class="emphasis"><em>printing characters</em></span>, 197 and databases dumped in this manner may be less portable to external 198 systems. 199 </p> 200 </li> 201 <li> 202 <p><a id="verify_DB_NOORDERCHK"></a> 203 <code class="literal">DB_NOORDERCHK</code> 204 </p> 205 <p> 206 Skip the database checks for btree and duplicate sort order and for 207 hashing. 208 </p> 209 <p> 210 The <code class="methodname">DB->verify()</code> method normally verifies that btree keys and 211 duplicate items are correctly sorted, and hash keys are correctly 212 hashed. If the file being verified contains multiple databases using 213 differing sorting or hashing algorithms, some of them must necessarily 214 fail database verification because only one sort order or hash 215 function can be specified before <code class="methodname">DB->verify()</code> is called. To verify 216 files with multiple databases having differing sorting orders or 217 hashing functions, first perform verification of the file as a whole 218 by using the DB_NOORDERCHK flag, and then individually verify the sort 219 order and hashing function for each database in the file using the 220 DB_ORDERCHKONLY flag. 221 </p> 222 </li> 223 <li> 224 <p><a id="verify_DB_ORDERCHKONLY"></a> 225 <code class="literal">DB_ORDERCHKONLY</code> 226 </p> 227 <p> 228 Perform the database checks for btree and duplicate sort order and for 229 hashing, skipped by DB_NOORDERCHK. 230 </p> 231 <p> 232 When this flag is specified, a <span class="bold"><strong>database</strong></span> parameter should also be specified, 233 indicating the database in the physical file which is to be checked. 234 This flag is only safe to use on databases that have already 235 successfully been verified using <code class="methodname">DB->verify()</code> with the DB_NOORDERCHK 236 flag set. 237 </p> 238 </li> 239 </ul> 240 </div> 241 </div> 242 <div class="sect3" lang="en" xml:lang="en"> 243 <div class="titlepage"> 244 <div> 245 <div> 246 <h4 class="title"><a id="id1652963"></a>outfile</h4> 247 </div> 248 </div> 249 </div> 250 <p> 251 The <span class="bold"><strong>outfile</strong></span> parameter is an optional 252 file stream to which the databases' key/data pairs are written. 253 </p> 254 </div> 255 </div> 256 <div class="sect2" lang="en" xml:lang="en"> 257 <div class="titlepage"> 258 <div> 259 <div> 260 <h3 class="title"><a id="id1653290"></a>Environment Variables</h3> 261 </div> 262 </div> 263 </div> 264 <p> 265 If the database was opened within a database environment, the 266 environment variable <code class="literal">DB_HOME</code> may be used as the path of the 267 database environment home. 268 </p> 269 <p> 270 <code class="methodname">DB->verify()</code> is affected by any database directory specified using the 271 <a class="xref" href="envset_data_dir.html" title="DB_ENV->set_data_dir()">DB_ENV->set_data_dir()</a> 272 method, or by setting the "set_data_dir" string in the environment's 273 <a href="../../programmer_reference/env_db_config.html#env_db_config.DB_CONFIG" class="olink">DB_CONFIG</a> 274 file. 275 </p> 276 </div> 277 <div class="sect2" lang="en" xml:lang="en"> 278 <div class="titlepage"> 279 <div> 280 <div> 281 <h3 class="title"><a id="id1653115"></a>Errors</h3> 282 </div> 283 </div> 284 </div> 285 <p> 286 The <code class="methodname">DB->verify()</code> <span> 287 <span> 288 method may fail and return one of the following non-zero errors: 289 </span> 290 291 </span> 292 </p> 293 <div class="sect3" lang="en" xml:lang="en"> 294 <div class="titlepage"> 295 <div> 296 <div> 297 <h4 class="title"><a id="id1653134"></a>EINVAL</h4> 298 </div> 299 </div> 300 </div> 301 <p> 302 If the method was called after <a class="xref" href="dbopen.html" title="DB->open()">DB->open()</a> 303 was called; or if an invalid flag value or parameter was specified. 304 </p> 305 </div> 306 <div class="sect3" lang="en" xml:lang="en"> 307 <div class="titlepage"> 308 <div> 309 <div> 310 <h4 class="title"><a id="id1652638"></a>ENOENT</h4> 311 </div> 312 </div> 313 </div> 314 <p> 315 The file or directory does not exist. 316 </p> 317 </div> 318 </div> 319 <div class="sect2" lang="en" xml:lang="en"> 320 <div class="titlepage"> 321 <div> 322 <div> 323 <h3 class="title"><a id="id1652725"></a>Class</h3> 324 </div> 325 </div> 326 </div> 327 <p> 328 <a class="link" href="db.html" title="Chapter��2.�� The DB Handle">DB</a> 329 </p> 330 </div> 331 <div class="sect2" lang="en" xml:lang="en"> 332 <div class="titlepage"> 333 <div> 334 <div> 335 <h3 class="title"><a id="id1652829"></a>See Also</h3> 336 </div> 337 </div> 338 </div> 339 <p> 340 <a class="xref" href="db.html#dblist" title="Database and Related Methods">Database and Related Methods</a> 341 </p> 342 </div> 343 </div> 344 <div class="navfooter"> 345 <hr /> 346 <table width="100%" summary="Navigation footer"> 347 <tr> 348 <td width="40%" align="left"><a accesskey="p" href="dbupgrade.html">Prev</a>��</td> 349 <td width="20%" align="center"> 350 <a accesskey="u" href="db.html">Up</a> 351 </td> 352 <td width="40%" align="right">��<a accesskey="n" href="dbc.html">Next</a></td> 353 </tr> 354 <tr> 355 <td width="40%" align="left" valign="top">DB->upgrade()��</td> 356 <td width="20%" align="center"> 357 <a accesskey="h" href="index.html">Home</a> 358 </td> 359 <td width="40%" align="right" valign="top">��Chapter��3.�� 360 The DBcursor Handle 361 </td> 362 </tr> 363 </table> 364 </div> 365 </body> 366</html> 367