Berkeley DB Reference Version 5.3.33

DB->verify()

#include <db.h>

int
DB->verify(DB *db, const char *file,
    const char *database, FILE *outfile, u_int32_t flags);  

The DB->verify() method verifies the integrity of all databases in the file specified by the file parameter, and optionally outputs the databases' key/data pairs to the file stream specified by the outfile parameter.

The DB->verify() method does not perform any locking, even in Berkeley DB environments that are configured with a locking subsystem. As such, it should only be used on files that are not being modified by another thread of control.

The DB->verify() method may not be called after the DB->open() method is called.

The DB handle may not be accessed again after DB->verify() is called, regardless of its return.

The DB->verify() method is the underlying method used by the db_verify utility. See the db_verify utility source code for an example of using DB->verify() in a IEEE/ANSI Std 1003.1 (POSIX) environment.

The DB->verify() method will return DB_VERIFY_BAD if a database is corrupted. When the DB_SALVAGE flag is specified, the DB_VERIFY_BAD return means that all key/data pairs in the file may not have been successfully output. Unless otherwise specified, the DB->verify() method returns a non-zero error value on failure and 0 on success.

Parameters

file

The file parameter is the physical file in which the databases to be verified are found.

database

The database parameter is the database in file on which the database checks for btree and duplicate sort order and for hashing are to be performed. See the DB_ORDERCHKONLY flag for more information.

The database parameter must be set to NULL except when the DB_ORDERCHKONLY flag is set.

outfile

The outfile parameter is an optional file stream to which the databases' key/data pairs are written.

flags

The flags parameter must be set to 0 or the following value:

In addition, the following flags may be set by bitwise inclusively OR'ing them into the flags parameter:

Environment Variables

If the database was opened within a database environment, the environment variable DB_HOME may be used as the path of the database environment home.

DB->verify() is affected by any database directory specified using the DB_ENV->set_data_dir() method, or by setting the "set_data_dir" string in the environment's DB_CONFIG file.

Errors

The DB->verify() method may fail and return one of the following non-zero errors:

EINVAL

If the method was called after DB->open() was called; or if an invalid flag value or parameter was specified.

ENOENT

The file or directory does not exist.

Class

DB

See Also

Database and Related Methods