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