DbEnv::dbrename

APIRef

#include <db_cxx.h>

int DbEnv::dbrename(DbTxn *txnid, const char *file, const char *database, const char *newname, u_int32_t flags);

Description

The DbEnv::dbrename method renames the database specified by the file and database arguments to newname. If no database is specified, the underlying file represented by file is renamed, incidentally renaming all databases that it contained.

Applications should not rename databases that are currently in use. If an underlying file is being renamed and logging is currently enabled in the database environment, no database in the file may be open when the DbEnv::dbrename method is called. In particular, some architectures do not permit renaming files with open handles. On these architectures, attempts to rename databases that are currently in use by any thread of control in the system will fail.

If the operation is to be transaction-protected, the txnid parameter is a transaction handle returned from DbEnv::txn_begin; otherwise, NULL.

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

DB_AUTO_COMMIT
Enclose the DbEnv::dbrename call within a transaction. If the call succeeds, changes made by the operation will be recoverable. If the call fails, the operation will have made no changes.

The DbEnv::dbrename method either returns a non-zero error value or throws an exception that encapsulates a non-zero error value on failure, and returns 0 on success.

Environment Variables

DB_HOME
The environment variable DB_HOME may be used as the path of the database environment home.

DbEnv::dbre return.

The constructor creates the DbEnv object. The constructor allocates memory internally; calling the DbEnv::close or DbEnv::remove methods will free that memory.

The following flags value may be specified:

DB_CLIENT
Create a client environment to connect to a server.

The DB_CLIENT flag indicates to the system that this environment is remote on a server. The use of this flag causes the environment methods to use functions that call a server instead of local functions. Prior to making any environment or database method calls, the application must call the DbEnv::set_rpc_server method to establish the connection to the server.

DB_CXX_NO_EXCEPTIONS
The Berkeley DB C++ API supports two different error behaviors. By default, whenever an error occurs, an exception is thrown that encapsulates the error information. This generally allows for cleaner logic for transaction processing because a try block can surround a single transaction. However, if DB_CXX_NO_EXCEPTIONS is specified, exceptions are not thrown; instead, each individual function returns an error code.

Each DbEnv object has an associated DB_ENV structure, which is used by the underlying implementation of Berkeley DB and its C-language API. The DbEnv::get_DB_ENV method returns a pointer to this struct. Given a const DbEnv object, DbEnv::get_const_DB_ENV returns a const pointer to the same struct.

Given a DB_ENV struct, the DbEnv::get_DbEnv method returns the corr