DB->open API Ref

#include <db.h>

int DB->open(DB *db, DB_TXN *txnid, const char *file, const char *database, DBTYPE type, u_int32_t flags, int mode);

int DB->get_dbname(DB *db, const char **filenamep, const char **dbnamep);

int DB->get_multiple(DB *db);

int DB->get_open_flags(DB *db, u_int32_t *flagsp);

int DB->get_transactional(DB *db);


Description: DB->open

The DB->open method opens the database represented by the file and database parameters for both reading and writing.

The currently supported Berkeley DB file formats (or access methods) are Btree, Hash, Queue, and Recno. The Btree format is a representation of a sorted, balanced tree structure. The Hash format is an extensible, dynamic hashing scheme. The Queue format supports fast access to fixed-length records accessed sequentially or by logical record number. The Recno format supports fixed- or variable-length records, accessed sequentially or by logical record number, and optionally backed by a flat text file.

Storage and retrieval for the Berkeley DB access methods are based on key/data pairs; see DBT for more information.

Calling DB->open is a relatively expensive operation, and maintaining a set of open databases will normally be preferable to repeatedly opening and closing the database for each new query.

The DB->open method returns a non-zero error value on failure and 0 on success. If DB->open fails, the DB->close method must be called to discard the DB handle.

Parameters
database file

When using a Unicode build on Windows (the default), the file argument will be interpreted as a UTF-8 string, which is equivalent to ASCII for Latin characters.

flags mode txnid type

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->open 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.


TMPDIR

Errors

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


DB_LOCK_DEADLOCK DB_LOCK_NOTGRANTED

ENOENT

DB_OLD_VERSION

EEXIST

EINVAL

ENOENT

DB_REP_HANDLE_DEAD

DB_REP_LOCKOUT

Description: DB->get_dbname

The DB->get_dbname method returns the current filename and database name.

Parameters
filenamep dbnamep

The DB->get_dbname method may be called at any time during the life of the application.

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


Description: DB->get_multiple

The DB->get_multiple method returns non-zero if the DB handle references a physical file supporting multiple databases.

In this case, the DB handle is a handle on a database whose key values are the names of the databases stored in the physical file and whose data values are opaque objects. No keys or data values may be modified or stored using the database handle.

The DB->get_multiple method may not be called before the DB->open method is called.


Description: DB->get_open_flags

The DB->get_open_flags method returns the current open method flags.

The DB->get_open_flags method may not be called before the DB->open method is called.

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

Parameters
flagsp

Description: DB->get_transactional

The DB->get_transactional method returns non-zero if the DB handle has been opened in a transactional mode.

The DB->get_transactional method may be called at any time during the life of the application.



Class DB
See Also Databases and Related Methods

APIRef

Copyright (c) 1996,2008 Oracle. All rights reserved.