- bdb_open(+File, +Mode, -DB, +Options) is det
- Open File holding a database. Mode is one of
read
, providing read-only access orupdate
, providing read/write access. Options is a list of options. Supported options are below. The boolean options are passed as flags toDB->open()
. The option name is derived from the flag name by stripping theDB_
prefix and converting to lower case. Consult the Berkeley DB documentation for details.- auto_commit(+Boolean)
- Open the database in a transaction. Ensures no database is created in case of failure.
- create(+Boolean)
- Create a new database of the database does not exist.
- dup(+Boolean)
- Do/do not allow for duplicate values on the same key. Default is not to allow for duplicates.
- excl(+Boolean)
- Combined with
create(true)
, fail if the database already exists. - multiversion(+Boolean)
- Open the database with support for multiversion concurrency control. The flag is passed, but no further support is provided yet.
- nommap(+Boolean)
- Do not map this database into process memory.
- rdonly(+Boolean)
- Open the database for reading only.
- read_uncommitted(+Boolean)
- Read operations on the database may request the return of modified but not yet committed data. This flag must be specified on all DB handles used to perform dirty reads or database updates, otherwise requests for dirty reads may not be honored and the read may block.
- thread(+Boolean)
- Enable access to the database handle from multiple threads. This is default if the corresponding flag is specified for the environment.
- truncate(+Boolean)
- When specified, truncate the underlying file, i.e., start with an empty database.
- database(+Name)
- If File contains multiple databases, address the named database in the file. A DB file can only consist of multiple databases if the bdb_open/4 call that created it specified this argument. Each database in the file has its own characteristics.
- environment(+Environment)
- Specify a database environment created using bdb_init/2.
- key(+Type)
- value(+Type)
- Specify the type of the key or value. Allowed values are:
- term
- Key/Value is a Prolog term (default). This type allows for representing arbitrary Prolog data in both keys and value. The representation is space-efficient, but Prolog specific. See PL_record_external() in the SWI-Prolog Reference Manual for details on the representation. The other representations are more neutral. This implies they are more stable and sharing the DB with other languages is feasible.
- atom
- Key/Value is an atom. The text is represented as a UTF-8 string and its length.
- c_blob
- Key/Value is a blob (sequence of bytes). On output, a Prolog string is used. The input is either a Prolog string or an atom holding only characters in the range [0..255].
- c_string
- Key/Value is an atom. The text is represented as a C 0-terminated UTF-8 string.
- c_long
- Key/Value is an integer. The value is represented as a native C long in machine byte-order.
- Arguments:
-
DB - is unified with a blob of type db
. Database handles are subject to atom garbage collection. - Errors
- -
permission_error(access, bdb_environment, Env)
if an environment is not thread-enabled and accessed from multiple threads.