Library Version 18.1.40

DB->convert()
Prev | Chapter 2. The DB Handle | Next

## DB->convert()

    #include <db.h>

    int
    DB->convert(DB *db, const char *file, u_int32_t lorder);

The `DB->convert()` method converts all of the databases included in the file file to a specified byte order, if necessary. If no conversion is necessary, `DB->convert()` always returns success.

If the database is partitioned, DB->set_partition() must be called before this method in order to convert all database partitions.

Database conversions 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 converted.

The `DB->convert()` method is non-atomic when used on a partitioned or sliced database, or a database with multiple queue extent files. If the operation fails, it is possible for the underlying database files to be in an inconsistent state.

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

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

### Parameters

#### file

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

#### lorder

The lorder parameter should represent the byte order as an integer; for example, big endian order is the number 4,321, and little endian order is the number 1,234.

### 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->convert()` is affected by any database directory specified using the DB_ENV->add_data_dir() method, or by setting the "add_data_dir" string in the environment's DB_CONFIG file.

### Errors

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

#### EINVAL

The database is corrupted or the the database is encrypted but the password is not provided.

### Class

DB

### See Also

Database and Related Methods

Prev | Up | Next
DB->compact() | Home | db_copy