|
DB->upgrade
|
|
#include <db.h>
int
DB->upgrade(DB *db, const char *file, u_int32_t flags);
Description
The DB->upgrade function 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 flags value must be set to 0 or
the following value:
- DB_DUPSORT
- This flag is only meaningful when upgrading databases from
releases before the Berkeley DB 3.1 release.
As part of the upgrade from the Berkeley DB 3.0 release to the 3.1 release,
the on-disk format of duplicate data items changed. To correctly
upgrade the format requires applications to specify whether duplicate
data items in the database are sorted or not. Specifying the
DB_DUPSORT flag informs DB->upgrade that the duplicates
are sorted; otherwise they are assumed to be unsorted. Incorrectly
specifying the value of this flag may lead to database corruption.
Further, because the DB->upgrade function upgrades a physical file
(including all the databases it contains), it is not possible to use
DB->upgrade to upgrade files in which some of the databases it
includes have sorted duplicate data items, and some of the databases it
includes have unsorted duplicate data items. If the file does not have
more than a single database, if the databases do not support duplicate
data items, or if all of the databases that support duplicate data items
support the same style of duplicates (either sorted or unsorted),
DB->upgrade will work correctly as long as the
DB_DUPSORT flag is correctly specified. Otherwise, the file
cannot be upgraded using DB->upgrade; it must be upgraded
manually by dumping and reloading the databases.
The DB->upgrade function returns a non-zero error value on failure and 0 on success.
The DB->upgrade function is the underlying function 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.
Environment Variables
- DB_HOME
- If the dbenv argument to db_create was initialized using
DB_ENV->open, the environment variable DB_HOME may be used
as the path of the database environment home. Specifically, DB->upgrade
is affected by the configuration value DB_DATA_DIR.
Errors
The DB->upgrade function may fail and return a non-zero error for the following conditions:
- EINVAL
- An invalid flag value or parameter was specified.
The database is not in the same byte-order as the system.
- DB_OLD_VERSION
- The database cannot be upgraded by this version of the Berkeley DB software.
The DB->upgrade function may fail and return a non-zero error for errors specified for other Berkeley DB and C library or system functions.
If a catastrophic error has occurred, the DB->upgrade function may fail and return
DB_RUNRECOVERY, in which case all subsequent Berkeley DB calls will fail
in the same way.
See Also
db_create,
DB->associate,
DB->close,
DB->cursor,
DB->del,
DB->err, DB->errx
DB->fd,
DB->get,
DB->pget,
DB->get_byteswapped,
DB->get_type,
DB->join,
DB->key_range,
DB->open,
DB->put,
DB->remove,
DB->rename,
DB->set_alloc,
DB->set_append_recno,
DB->set_bt_compare,
DB->set_bt_minkey,
DB->set_bt_prefix,
DB->set_cachesize,
DB->set_dup_compare,
DB->set_errcall,
DB->set_errfile,
DB->set_errpfx,
DB->set_feedback,
DB->set_flags,
DB->set_h_ffactor,
DB->set_h_hash,
DB->set_h_nelem,
DB->set_lorder,
DB->set_pagesize,
DB->set_paniccall,
DB->set_q_extentsize,
DB->set_re_delim,
DB->set_re_len,
DB->set_re_pad,
DB->set_re_source,
DB->stat,
DB->sync,
DB->truncate,
DB->upgrade,
and
DB->verify.
Copyright Sleepycat Software
|