~ubuntu-branches/ubuntu/edgy/rpm/edgy

« back to all changes in this revision

Viewing changes to db/docs/api_c/db_open.html

  • Committer: Bazaar Package Importer
  • Author(s): Joey Hess
  • Date: 2002-01-22 20:56:57 UTC
  • Revision ID: james.westby@ubuntu.com-20020122205657-l74j50mr9z8ofcl5
Tags: upstream-4.0.3
ImportĀ upstreamĀ versionĀ 4.0.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!--$Id: db_open.so,v 10.67 2001/06/19 19:49:24 bostic Exp $-->
 
2
<!--Copyright 1997-2001 by Sleepycat Software, Inc.-->
 
3
<!--All rights reserved.-->
 
4
<html>
 
5
<head>
 
6
<title>Berkeley DB: DB-&gt;open</title>
 
7
<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
 
8
<meta name="keywords" content="embedded,database,programmatic,toolkit,b+tree,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,java,C,C++">
 
9
</head>
 
10
<body bgcolor=white>
 
11
<a name="2"><!--meow--></a>
 
12
<table width="100%"><tr valign=top>
 
13
<td>
 
14
<h1>DB-&gt;open</h1>
 
15
</td>
 
16
<td align=right>
 
17
<a href="../api_c/c_index.html"><img src="../images/api.gif" alt="API"></a><a href="../reftoc.html"><img src="../images/ref.gif" alt="Ref"></a>
 
18
</td></tr></table>
 
19
<hr size=1 noshade>
 
20
<tt>
 
21
<h3><pre>
 
22
#include &lt;db.h&gt;
 
23
<p>
 
24
int
 
25
DB-&gt;open(DB *db, const char *file,
 
26
    const char *database, DBTYPE type, u_int32_t flags, int mode);
 
27
</pre></h3>
 
28
<h1>Description</h1>
 
29
<p>The currently supported Berkeley DB file formats (or <i>access methods</i>)
 
30
are Btree, Hash, Queue, and Recno.  The Btree format is a representation
 
31
of a sorted, balanced tree structure.  The Hash format is an extensible,
 
32
dynamic hashing scheme.  The Queue format supports fast access to
 
33
fixed-length records accessed sequentially or by logical record number.
 
34
The Recno format supports fixed- or variable-length records, accessed
 
35
sequentially or by logical record number, and optionally backed by a
 
36
flat text file.
 
37
<p>Storage and retrieval for the Berkeley DB access methods are based on key/data
 
38
pairs; see <a href="../api_c/dbt.html">DBT</a> for more information.
 
39
<p>The DB-&gt;open interface opens the database represented by the
 
40
<b>file</b> and <b>database</b> arguments for both reading and
 
41
writing.  The <b>file</b> argument is used as the name of an underlying
 
42
file that will be used to back the database.  The <b>database</b>
 
43
argument is optional, and allows applications to have multiple databases
 
44
in a single file.  Although no <b>database</b> argument needs to be
 
45
specified, it is an error to attempt to open a second database in a
 
46
<b>file</b> that was not initially created using a <b>database</b>
 
47
name.  Further, the <b>database</b> argument is not supported by the
 
48
Queue format.
 
49
<p>In-memory databases never intended to be preserved on disk may be
 
50
created by setting both the <b>file</b> and <b>database</b> arguments
 
51
to NULL.  Note that in-memory databases can only ever be shared by
 
52
sharing the single database handle that created them, in circumstances
 
53
where doing so is safe.
 
54
<p>The <b>type</b> argument is of type DBTYPE, and must be set to one of DB_BTREE, DB_HASH,
 
55
DB_QUEUE, DB_RECNO, or DB_UNKNOWN.  If
 
56
<b>type</b> is DB_UNKNOWN, the database must already exist
 
57
and DB-&gt;open will automatically determine its type.  The
 
58
<a href="../api_c/db_get_type.html">DB-&gt;get_type</a> function may be used to determine the underlying type of
 
59
databases opened using DB_UNKNOWN.
 
60
<p>The <b>flags</b> and <b>mode</b> arguments specify how files will be opened
 
61
and/or created if they do not already exist.
 
62
<p>The <b>flags</b> value must be set to 0 or by bitwise inclusively <b>OR</b>'ing together one or
 
63
more of the following values:
 
64
<p><dl compact>
 
65
<p><dt><a name="DB_CREATE">DB_CREATE</a><dd>Create any underlying files, as necessary.  If the files do not already
 
66
exist and the DB_CREATE flag is not specified, the call will fail.
 
67
<p><dt><a name="DB_DIRTY_READ">DB_DIRTY_READ</a><dd>Support dirty reads; that is, transactions, cursors and read operations
 
68
in the database may request the return of modified but not yet committed
 
69
data.
 
70
<p><dt><a name="DB_EXCL">DB_EXCL</a><dd>Return an error if the file already exists.  Underlying filesystem
 
71
primitives are used to implement this flag.  For this reason, it is only
 
72
applicable to the file and cannot be used to test whether a database in a
 
73
file already exists.
 
74
<p>The DB_EXCL flag is only meaningful when specified with the
 
75
DB_CREATE flag.
 
76
<p><dt><a name="DB_NOMMAP">DB_NOMMAP</a><dd>Do not map this database into process memory (see the description of the
 
77
<a href="../api_c/env_set_mp_mmapsize.html">DB_ENV-&gt;set_mp_mmapsize</a> function for further information).
 
78
<p><dt><a name="DB_RDONLY">DB_RDONLY</a><dd>Open the database for reading only.  Any attempt to modify items in the
 
79
database will fail, regardless of the actual permissions of any underlying
 
80
files.
 
81
<p><dt><a name="DB_THREAD">DB_THREAD</a><dd>Cause the DB handle returned by DB-&gt;open to be
 
82
<i>free-threaded</i>; that is, usable by multiple threads within a
 
83
single address space.
 
84
<p><dt><a name="DB_TRUNCATE">DB_TRUNCATE</a><dd>Physically truncate the underlying file, discarding all previous
 
85
databases it might have held.  Underlying filesystem primitives are used
 
86
to implement this flag.  For this reason, it is applicable only to the
 
87
file and cannot be used to discard databases within a file.
 
88
<p>The DB_TRUNCATE flag cannot be transaction-protected, and it is
 
89
an error to specify it in a transaction-protected environment.
 
90
</dl>
 
91
<p>On UNIX systems or in IEEE/ANSI Std 1003.1 (POSIX) environments, all files created by
 
92
the access methods are created with mode <b>mode</b> (as described in <b>chmod</b>(2)) and modified by the process' umask value at the time of creation
 
93
(see <b>umask</b>(2)).  If <b>mode</b> is 0, the access methods will use a default
 
94
mode of readable and writable by both owner and group.  On Windows
 
95
systems, the mode argument is ignored. The group ownership of created
 
96
files is based on the system and directory defaults, and is not further
 
97
specified by Berkeley DB.
 
98
<p>Calling DB-&gt;open is a reasonably expensive operation, and
 
99
maintaining a set of open databases will normally be preferable to
 
100
repeatedly opening and closing the database for each new query.
 
101
<p>The DB-&gt;open function returns a non-zero error value on failure and 0 on success.
 
102
<h1>Environment Variables</h1>
 
103
<p><dl compact>
 
104
<p><dt>DB_HOME<dd>If the <b>dbenv</b> argument to <a href="../api_c/db_create.html">db_create</a> was initialized using
 
105
<a href="../api_c/env_open.html">DB_ENV-&gt;open</a>, the environment variable <b>DB_HOME</b> may be used
 
106
as the path of the database environment home.  Specifically, DB-&gt;open
 
107
is affected by the configuration value DB_DATA_DIR.
 
108
</dl>
 
109
<p><dl compact>
 
110
<p><dt>TMPDIR<dd>If the <b>file</b> and <b>dbenv</b> arguments to DB-&gt;open are
 
111
NULL, the environment variable <b>TMPDIR</b> may be used as a
 
112
directory in which to create a temporary backing file.
 
113
</dl>
 
114
<h1>Errors</h1>
 
115
<p>The DB-&gt;open function may fail and return a non-zero error for the following conditions:
 
116
<p><dl compact>
 
117
<p><dt><a name="DB_OLD_VERSION">DB_OLD_VERSION</a><dd>The database cannot be opened without being first upgraded.
 
118
<p><dt>EEXIST<dd>DB_CREATE and DB_EXCL were specified and the file exists.
 
119
<p><dt>EINVAL<dd>An invalid flag value or parameter was specified (for example, unknown
 
120
database type, page size, hash function, pad byte, byte order) or a flag
 
121
value or parameter that is incompatible with the specified database.
 
122
<p>
 
123
The <a href="../api_c/env_open.html#DB_THREAD">DB_THREAD</a> flag was specified and fast mutexes are not
 
124
available for this architecture.
 
125
<p>The <a href="../api_c/env_open.html#DB_THREAD">DB_THREAD</a> flag was specified to DB-&gt;open, but was not
 
126
specified to the <a href="../api_c/env_open.html">DB_ENV-&gt;open</a> call for the environment in which the
 
127
DB handle was created.
 
128
<p>A backing flat text file was specified with either the <a href="../api_c/env_open.html#DB_THREAD">DB_THREAD</a>
 
129
flag or the provided database environment supports transaction
 
130
processing.
 
131
<p><dt>ENOENT<dd>A nonexistent <b>re_source</b> file was specified.
 
132
</dl>
 
133
<p>The DB-&gt;open function may fail and return a non-zero error for errors specified for other Berkeley DB and C library or system functions.
 
134
If a catastrophic error has occurred, the DB-&gt;open function may fail and return
 
135
<a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, in which case all subsequent Berkeley DB calls will fail
 
136
in the same way.
 
137
<h1>See Also</h1>
 
138
<a href="../api_c/db_create.html">db_create</a>,
 
139
<a href="../api_c/db_associate.html">DB-&gt;associate</a>,
 
140
<a href="../api_c/db_close.html">DB-&gt;close</a>,
 
141
<a href="../api_c/db_cursor.html">DB-&gt;cursor</a>,
 
142
<a href="../api_c/db_del.html">DB-&gt;del</a>,
 
143
<a href="../api_c/db_err.html">DB-&gt;err</a>, <a href="../api_c/db_err.html">DB-&gt;errx</a>
 
144
<a href="../api_c/db_fd.html">DB-&gt;fd</a>,
 
145
<a href="../api_c/db_get.html">DB-&gt;get</a>,
 
146
<a href="../api_c/db_get.html">DB-&gt;pget</a>,
 
147
<a href="../api_c/db_get_byteswapped.html">DB-&gt;get_byteswapped</a>,
 
148
<a href="../api_c/db_get_type.html">DB-&gt;get_type</a>,
 
149
<a href="../api_c/db_join.html">DB-&gt;join</a>,
 
150
<a href="../api_c/db_key_range.html">DB-&gt;key_range</a>,
 
151
<a href="../api_c/db_open.html">DB-&gt;open</a>,
 
152
<a href="../api_c/db_put.html">DB-&gt;put</a>,
 
153
<a href="../api_c/db_remove.html">DB-&gt;remove</a>,
 
154
<a href="../api_c/db_rename.html">DB-&gt;rename</a>,
 
155
<a href="../api_c/db_set_alloc.html">DB-&gt;set_alloc</a>,
 
156
<a href="../api_c/db_set_append_recno.html">DB-&gt;set_append_recno</a>,
 
157
<a href="../api_c/db_set_bt_compare.html">DB-&gt;set_bt_compare</a>,
 
158
<a href="../api_c/db_set_bt_minkey.html">DB-&gt;set_bt_minkey</a>,
 
159
<a href="../api_c/db_set_bt_prefix.html">DB-&gt;set_bt_prefix</a>,
 
160
<a href="../api_c/db_set_cachesize.html">DB-&gt;set_cachesize</a>,
 
161
<a href="../api_c/db_set_dup_compare.html">DB-&gt;set_dup_compare</a>,
 
162
<a href="../api_c/db_set_errcall.html">DB-&gt;set_errcall</a>,
 
163
<a href="../api_c/db_set_errfile.html">DB-&gt;set_errfile</a>,
 
164
<a href="../api_c/db_set_errpfx.html">DB-&gt;set_errpfx</a>,
 
165
<a href="../api_c/db_set_feedback.html">DB-&gt;set_feedback</a>,
 
166
<a href="../api_c/db_set_flags.html">DB-&gt;set_flags</a>,
 
167
<a href="../api_c/db_set_h_ffactor.html">DB-&gt;set_h_ffactor</a>,
 
168
<a href="../api_c/db_set_h_hash.html">DB-&gt;set_h_hash</a>,
 
169
<a href="../api_c/db_set_h_nelem.html">DB-&gt;set_h_nelem</a>,
 
170
<a href="../api_c/db_set_lorder.html">DB-&gt;set_lorder</a>,
 
171
<a href="../api_c/db_set_pagesize.html">DB-&gt;set_pagesize</a>,
 
172
<a href="../api_c/db_set_paniccall.html">DB-&gt;set_paniccall</a>,
 
173
<a href="../api_c/db_set_q_extentsize.html">DB-&gt;set_q_extentsize</a>,
 
174
<a href="../api_c/db_set_re_delim.html">DB-&gt;set_re_delim</a>,
 
175
<a href="../api_c/db_set_re_len.html">DB-&gt;set_re_len</a>,
 
176
<a href="../api_c/db_set_re_pad.html">DB-&gt;set_re_pad</a>,
 
177
<a href="../api_c/db_set_re_source.html">DB-&gt;set_re_source</a>,
 
178
<a href="../api_c/db_stat.html">DB-&gt;stat</a>,
 
179
<a href="../api_c/db_sync.html">DB-&gt;sync</a>,
 
180
<a href="../api_c/db_truncate.html">DB-&gt;truncate</a>,
 
181
<a href="../api_c/db_upgrade.html">DB-&gt;upgrade</a>,
 
182
and
 
183
<a href="../api_c/db_verify.html">DB-&gt;verify</a>.
 
184
</tt>
 
185
<table width="100%"><tr><td><br></td><td align=right>
 
186
<a href="../api_c/c_index.html"><img src="../images/api.gif" alt="API"></a><a href="../reftoc.html"><img src="../images/ref.gif" alt="Ref"></a>
 
187
</td></tr></table>
 
188
<p><font size=1><a href="http://www.sleepycat.com">Copyright Sleepycat Software</a></font>
 
189
</body>
 
190
</html>