Berkeley DB Reference Version 5.3.33

DB->upgrade()

#include <db.h>

int
DB->upgrade(DB *db, const char *file, u_int32_t flags);  

The DB->upgrade() method upgrades all of the databases included in the file file, if necessary. If no upgrade is necessary, DB->upgrade() always returns success.

Database upgrades are done in place and are destructive. For example, if pages need to be allocated and no disk space is available, the database may be left corrupted. Backups should be made before databases are upgraded. See Upgrading databases for more information.

Unlike all other database operations, DB->upgrade() may only be done on a system with the same byte-order as the database.

The DB->upgrade() method returns a non-zero error value on failure and 0 on success.

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

Parameters

file

The file parameter is the physical file containing the databases to be upgraded.

flags

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

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->upgrade() 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->upgrade() method may fail and return one of the following non-zero errors:

DB_OLD_VERSION

The database cannot be upgraded by this version of the Berkeley DB software.

Class

DB

See Also

Database and Related Methods