1<!--$Id-->
2<!--Copyright (c) 1997,2008 Oracle.  All rights reserved.-->
3<!--See the file LICENSE for redistribution information.-->
4<html>
5<head>
6<title>Berkeley DB: DB_ENV-&gt;set_flags</title>
7<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
8<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++">
9</head>
10<body bgcolor=white>
11<table width="100%"><tr valign=top>
12<td>
13<b>DB_ENV-&gt;set_flags</b>
14</td>
15<td align=right>
16<a href="../api_c/api_core.html"><img src="../images/api.gif" alt="API"></a>
17<a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a></td>
18</tr></table>
19<hr size=1 noshade>
20<tt>
21<b><pre>
22#include &lt;db.h&gt;
23<p>
24int
25DB_ENV-&gt;set_flags(DB_ENV *dbenv, u_int32_t flags, int onoff);
26<p>
27int
28DB_ENV-&gt;get_flags(DB_ENV *dbenv, u_int32_t *flagsp);
29</pre></b>
30<hr size=1 noshade>
31<b>Description: DB_ENV-&gt;set_flags</b>
32<p>Configure a database environment.</p>
33<p>The database environment's flag values may also be configured using the
34environment's <a href="../ref/env/db_config.html#DB_CONFIG">DB_CONFIG</a> file.  The syntax of the entry in that
35file is a single line with the string "set_flags", one or more whitespace
36characters, and the method flag parameter as a string; for example, "set_flags
37DB_TXN_NOSYNC".
38Because the <a href="../ref/env/db_config.html#DB_CONFIG">DB_CONFIG</a> file is read when the database environment
39is opened, it will silently overrule configuration done before that
40time.</p>
41<p>The DB_ENV-&gt;set_flags method
42returns a non-zero error value on failure
43and 0 on success.
44</p>
45<b>Parameters</b> <br>
46 <b>flags</b><ul compact><li>The <b>flags</b> parameter must be set by bitwise inclusively <b>OR</b>'ing together one or more
47of the following values:
48<br>
49<b><a name="DB_AUTO_COMMIT">DB_AUTO_COMMIT</a></b><ul compact><li>If set, <a href="../api_c/db_class.html">DB</a> handle operations for which no explicit transaction
50handle was specified, and which modify databases in the database
51environment, will be automatically enclosed within a transaction.
52<p>Calling DB_ENV-&gt;set_flags with the <a href="../api_c/env_set_flags.html#DB_AUTO_COMMIT">DB_AUTO_COMMIT</a> flag only affects
53the specified <a href="../api_c/env_class.html">DB_ENV</a> handle (and any other Berkeley DB handles opened
54within the scope of that handle).
55For consistent behavior across the environment, all <a href="../api_c/env_class.html">DB_ENV</a>
56handles opened in the environment must either set the <a href="../api_c/env_set_flags.html#DB_AUTO_COMMIT">DB_AUTO_COMMIT</a> flag
57or the flag should be specified in the <a href="../ref/env/db_config.html#DB_CONFIG">DB_CONFIG</a> configuration
58file.</p>
59<p>The <a href="../api_c/env_set_flags.html#DB_AUTO_COMMIT">DB_AUTO_COMMIT</a> flag may be used to configure Berkeley DB at any time during
60the life of the application.</p></ul>
61<a name="2"><!--meow--></a>
62<b><a name="DB_CDB_ALLDB">DB_CDB_ALLDB</a></b><ul compact><li>If set, Berkeley DB Concurrent Data Store applications will perform locking on an environment-wide
63basis rather than on a per-database basis.
64<p>Calling DB_ENV-&gt;set_flags with the DB_CDB_ALLDB flag only affects
65the specified <a href="../api_c/env_class.html">DB_ENV</a> handle (and any other Berkeley DB handles opened
66within the scope of that handle).
67For consistent behavior across the environment, all <a href="../api_c/env_class.html">DB_ENV</a>
68handles opened in the environment must either set the DB_CDB_ALLDB flag
69or the flag should be specified in the <a href="../ref/env/db_config.html#DB_CONFIG">DB_CONFIG</a> configuration
70file.</p>
71<p>The DB_CDB_ALLDB flag may be used to configure Berkeley DB only before the
72<a href="../api_c/env_open.html">DB_ENV-&gt;open</a> method is called.</p></ul>
73<a name="3"><!--meow--></a>
74<b><a name="DB_DIRECT_DB">DB_DIRECT_DB</a></b><ul compact><li>Turn off system buffering of Berkeley DB database files to avoid double caching.
75<p>Calling DB_ENV-&gt;set_flags with the DB_DIRECT_DB flag only affects
76the specified <a href="../api_c/env_class.html">DB_ENV</a> handle (and any other Berkeley DB handles opened
77within the scope of that handle).
78For consistent behavior across the environment, all <a href="../api_c/env_class.html">DB_ENV</a>
79handles opened in the environment must either set the DB_DIRECT_DB flag
80or the flag should be specified in the <a href="../ref/env/db_config.html#DB_CONFIG">DB_CONFIG</a> configuration
81file.</p>
82<p>The DB_DIRECT_DB flag may be used to configure Berkeley DB at any time during
83the life of the application.</p></ul>
84<a name="4"><!--meow--></a>
85<b><a name="DB_DSYNC_DB">DB_DSYNC_DB</a></b><ul compact><li>Configure Berkeley DB to flush database writes to the backing disk before
86returning from the write system call, rather than flushing database
87writes explicitly in a separate system call, as necessary.  This is only
88available on some systems (for example, systems supporting the
89IEEE/ANSI Std 1003.1 (POSIX) standard O_DSYNC flag, or systems supporting the Windows
90FILE_FLAG_WRITE_THROUGH flag).  This flag may result in inaccurate file
91modification times and other file-level information for Berkeley DB database
92files.  This flag will almost certainly result in a performance decrease
93on most systems.  This flag is only applicable to certain filesysystem
94(for example, the Veritas VxFS filesystem), where the filesystem's
95support for trickling writes back to stable storage behaves badly (or
96more likely, has been misconfigured).
97<p>Calling DB_ENV-&gt;set_flags with the DB_DSYNC_DB flag only affects
98the specified <a href="../api_c/env_class.html">DB_ENV</a> handle (and any other Berkeley DB handles opened
99within the scope of that handle).
100For consistent behavior across the environment, all <a href="../api_c/env_class.html">DB_ENV</a>
101handles opened in the environment must either set the DB_DSYNC_DB flag
102or the flag should be specified in the <a href="../ref/env/db_config.html#DB_CONFIG">DB_CONFIG</a> configuration
103file.</p>
104<p>The DB_DSYNC_DB flag may be used to configure Berkeley DB at any time during
105the life of the application.</p></ul>
106<b><a name="DB_MULTIVERSION">DB_MULTIVERSION</a></b><ul compact><li>If set, all databases in the environment will be opened as if
107DB_MULTIVERSION is passed to <a href="../api_c/db_open.html">DB-&gt;open</a>.  This flag will
108be ignored for queue databases for which DB_MULTIVERSION is not
109supported.
110<p>Calling DB_ENV-&gt;set_flags with the DB_MULTIVERSION flag only affects
111the specified <a href="../api_c/env_class.html">DB_ENV</a> handle (and any other Berkeley DB handles opened
112within the scope of that handle).
113For consistent behavior across the environment, all <a href="../api_c/env_class.html">DB_ENV</a>
114handles opened in the environment must either set the DB_MULTIVERSION flag
115or the flag should be specified in the <a href="../ref/env/db_config.html#DB_CONFIG">DB_CONFIG</a> configuration
116file.</p>
117<p>The DB_MULTIVERSION flag may be used to configure Berkeley DB at any time during
118the life of the application.</p></ul>
119<a name="5"><!--meow--></a>
120<b><a name="DB_NOLOCKING">DB_NOLOCKING</a></b><ul compact><li>If set, Berkeley DB will grant all requested mutual exclusion mutexes and
121database locks without regard for their actual availability.  This
122functionality should never be used for purposes other than debugging.
123<p>Calling DB_ENV-&gt;set_flags with the DB_NOLOCKING flag only affects
124the specified <a href="../api_c/env_class.html">DB_ENV</a> handle (and any other Berkeley DB handles opened
125within the scope of that handle).
126</p>
127<p>The DB_NOLOCKING flag may be used to configure Berkeley DB at any time during
128the life of the application.</p></ul>
129<a name="6"><!--meow--></a>
130<b><a name="DB_NOMMAP">DB_NOMMAP</a></b><ul compact><li>If set, Berkeley DB will copy read-only database files into the local cache
131instead of potentially mapping them into process memory (see the
132description of the <a href="../api_c/env_set_mp_mmapsize.html">DB_ENV-&gt;set_mp_mmapsize</a> method for further
133information).
134<p>Calling DB_ENV-&gt;set_flags with the DB_NOMMAP flag only affects
135the specified <a href="../api_c/env_class.html">DB_ENV</a> handle (and any other Berkeley DB handles opened
136within the scope of that handle).
137For consistent behavior across the environment, all <a href="../api_c/env_class.html">DB_ENV</a>
138handles opened in the environment must either set the DB_NOMMAP flag
139or the flag should be specified in the <a href="../ref/env/db_config.html#DB_CONFIG">DB_CONFIG</a> configuration
140file.</p>
141<p>The DB_NOMMAP flag may be used to configure Berkeley DB at any time during
142the life of the application.</p></ul>
143<a name="7"><!--meow--></a>
144<b><a name="DB_NOPANIC">DB_NOPANIC</a></b><ul compact><li>If set, Berkeley DB will ignore any panic state in the database environment.
145(Database environments in a panic state normally refuse all attempts to
146call Berkeley DB functions, returning <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>.) This
147functionality should never be used for purposes other than debugging.
148<p>Calling DB_ENV-&gt;set_flags with the DB_NOPANIC flag only affects
149the specified <a href="../api_c/env_class.html">DB_ENV</a> handle (and any other Berkeley DB handles opened
150within the scope of that handle).
151</p>
152<p>The DB_NOPANIC flag may be used to configure Berkeley DB at any time during
153the life of the application.</p></ul>
154<b><a name="DB_OVERWRITE">DB_OVERWRITE</a></b><ul compact><li>Overwrite files stored in encrypted formats before deleting them.  Berkeley DB
155overwrites files using alternating 0xff, 0x00 and 0xff byte patterns.
156For file overwriting to be effective, the underlying file must be stored
157on a fixed-block filesystem.  Systems with journaling or logging filesystems
158will require operating system support and probably modification of the
159Berkeley DB sources.
160<p>Calling DB_ENV-&gt;set_flags with the DB_OVERWRITE flag only affects
161the specified <a href="../api_c/env_class.html">DB_ENV</a> handle (and any other Berkeley DB handles opened
162within the scope of that handle).
163</p>
164<p>The DB_OVERWRITE flag may be used to configure Berkeley DB at any time during
165the life of the application.</p></ul>
166<a name="8"><!--meow--></a>
167<b><a name="DB_PANIC_ENVIRONMENT">DB_PANIC_ENVIRONMENT</a></b><ul compact><li>If set, Berkeley DB will set the panic state for the database environment.
168(Database environments in a panic state normally refuse all attempts to
169call Berkeley DB functions, returning <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>.) This flag may
170not be specified using the environment's <a href="../ref/env/db_config.html#DB_CONFIG">DB_CONFIG</a> file.
171<p>Calling DB_ENV-&gt;set_flags with the DB_PANIC_ENVIRONMENT flag affects the
172database environment, including all threads of control accessing the
173database environment.</p>
174<p>The DB_PANIC_ENVIRONMENT flag may be used to configure Berkeley DB only after the
175<a href="../api_c/env_open.html">DB_ENV-&gt;open</a> method is called.</p></ul>
176<a name="9"><!--meow--></a>
177<b><a name="DB_REGION_INIT">DB_REGION_INIT</a></b><ul compact><li>In some applications, the expense of page-faulting the underlying shared
178memory regions can affect performance.  (For example, if the page-fault
179occurs while holding a lock, other lock requests can convoy, and overall
180throughput may decrease.)  If set, Berkeley DB will page-fault shared regions
181into memory when initially creating or joining a Berkeley DB environment.  In
182addition, Berkeley DB will write the shared regions when creating an
183environment, forcing the underlying virtual memory and filesystems to
184instantiate both the necessary memory and the necessary disk space.
185This can also avoid out-of-disk space failures later on.
186<p>Calling DB_ENV-&gt;set_flags with the DB_REGION_INIT flag only affects
187the specified <a href="../api_c/env_class.html">DB_ENV</a> handle (and any other Berkeley DB handles opened
188within the scope of that handle).
189For consistent behavior across the environment, all <a href="../api_c/env_class.html">DB_ENV</a>
190handles opened in the environment must either set the DB_REGION_INIT flag
191or the flag should be specified in the <a href="../ref/env/db_config.html#DB_CONFIG">DB_CONFIG</a> configuration
192file.</p>
193<p>The DB_REGION_INIT flag may be used to configure Berkeley DB at any time during
194the life of the application.</p></ul>
195<b><a name="DB_TIME_NOTGRANTED">DB_TIME_NOTGRANTED</a></b><ul compact><li>If set, database calls timing out based on lock or transaction timeout
196values will
197return <a href="../ref/program/errorret.html#DB_LOCK_NOTGRANTED">DB_LOCK_NOTGRANTED</a> instead of <a href="../ref/program/errorret.html#DB_LOCK_DEADLOCK">DB_LOCK_DEADLOCK</a>.
198This allows applications to distinguish between operations which have
199deadlocked and operations which have exceeded their time limits.
200<p>Calling DB_ENV-&gt;set_flags with the DB_TIME_NOTGRANTED flag only affects
201the specified <a href="../api_c/env_class.html">DB_ENV</a> handle (and any other Berkeley DB handles opened
202within the scope of that handle).
203For consistent behavior across the environment, all <a href="../api_c/env_class.html">DB_ENV</a>
204handles opened in the environment must either set the DB_TIME_NOTGRANTED flag
205or the flag should be specified in the <a href="../ref/env/db_config.html#DB_CONFIG">DB_CONFIG</a> configuration
206file.</p>
207<p>The DB_TIME_NOTGRANTED flag may be used to configure Berkeley DB at any time during
208the life of the application.</p></ul>
209<a name="10"><!--meow--></a>
210<b><a name="DB_TXN_NOSYNC">DB_TXN_NOSYNC</a></b><ul compact><li>If set, Berkeley DB will not write or synchronously flush the log on transaction
211commit.
212This means that transactions exhibit the ACI (atomicity, consistency,
213and isolation) properties, but not D (durability); that is, database
214integrity will be maintained, but if the application or system fails,
215it is possible some number of the most recently committed transactions
216may be undone during recovery.  The number of transactions at risk is
217governed by how many log updates can fit into the log buffer, how often
218the operating system flushes dirty buffers to disk, and how often the
219log is checkpointed.
220<p>Calling DB_ENV-&gt;set_flags with the DB_TXN_NOSYNC flag only affects
221the specified <a href="../api_c/env_class.html">DB_ENV</a> handle (and any other Berkeley DB handles opened
222within the scope of that handle).
223For consistent behavior across the environment, all <a href="../api_c/env_class.html">DB_ENV</a>
224handles opened in the environment must either set the DB_TXN_NOSYNC flag
225or the flag should be specified in the <a href="../ref/env/db_config.html#DB_CONFIG">DB_CONFIG</a> configuration
226file.</p> <p>The DB_TXN_NOSYNC flag may be used to configure Berkeley DB at any time during
227the life of the application.</p></ul>
228<b><a name="DB_TXN_NOWAIT">DB_TXN_NOWAIT</a></b><ul compact><li>If set and a lock is unavailable for any Berkeley DB operation performed in
229the context of a transaction, cause the operation to
230return <a href="../ref/program/errorret.html#DB_LOCK_DEADLOCK">DB_LOCK_DEADLOCK</a> (or <a href="../ref/program/errorret.html#DB_LOCK_NOTGRANTED">DB_LOCK_NOTGRANTED</a> if
231configured using the DB_TIME_NOTGRANTED flag).
232<p>Calling DB_ENV-&gt;set_flags with the DB_TXN_NOWAIT flag only affects
233the specified <a href="../api_c/env_class.html">DB_ENV</a> handle (and any other Berkeley DB handles opened
234within the scope of that handle).
235For consistent behavior across the environment, all <a href="../api_c/env_class.html">DB_ENV</a>
236handles opened in the environment must either set the DB_TXN_NOWAIT flag
237or the flag should be specified in the <a href="../ref/env/db_config.html#DB_CONFIG">DB_CONFIG</a> configuration
238file.</p>
239<p>The DB_TXN_NOWAIT flag may be used to configure Berkeley DB at any time during
240the life of the application.</p></ul>
241<b><a name="DB_TXN_SNAPSHOT">DB_TXN_SNAPSHOT</a></b><ul compact><li>If set, all transactions in the environment will be started as if
242DB_TXN_SNAPSHOT were passed to <a href="../api_c/txn_begin.html">DB_ENV-&gt;txn_begin</a>, and all
243non-transactional cursors will be opened as if DB_TXN_SNAPSHOT
244were passed to <a href="../api_c/db_cursor.html">DB-&gt;cursor</a>.
245<p>Calling DB_ENV-&gt;set_flags with the DB_TXN_SNAPSHOT flag only affects
246the specified <a href="../api_c/env_class.html">DB_ENV</a> handle (and any other Berkeley DB handles opened
247within the scope of that handle).
248For consistent behavior across the environment, all <a href="../api_c/env_class.html">DB_ENV</a>
249handles opened in the environment must either set the DB_TXN_SNAPSHOT flag
250or the flag should be specified in the <a href="../ref/env/db_config.html#DB_CONFIG">DB_CONFIG</a> configuration
251file.</p>
252<p>The DB_TXN_SNAPSHOT flag may be used to configure Berkeley DB at any time during
253the life of the application.</p></ul>
254<a name="11"><!--meow--></a>
255<b><a name="DB_TXN_WRITE_NOSYNC">DB_TXN_WRITE_NOSYNC</a></b><ul compact><li>If set, Berkeley DB will write, but will not synchronously flush, the log on
256transaction commit.
257This means that transactions exhibit the ACI (atomicity, consistency,
258and isolation) properties, but not D (durability); that is, database
259integrity will be maintained, but if the system fails, it is possible
260some number of the most recently committed transactions may be undone
261during recovery.  The number of transactions at risk is governed by how
262often the system flushes dirty buffers to disk and how often the log is
263checkpointed.
264<p>Calling DB_ENV-&gt;set_flags with the DB_TXN_WRITE_NOSYNC flag only affects
265the specified <a href="../api_c/env_class.html">DB_ENV</a> handle (and any other Berkeley DB handles opened
266within the scope of that handle).
267For consistent behavior across the environment, all <a href="../api_c/env_class.html">DB_ENV</a>
268handles opened in the environment must either set the DB_TXN_WRITE_NOSYNC flag
269or the flag should be specified in the <a href="../ref/env/db_config.html#DB_CONFIG">DB_CONFIG</a> configuration
270file.</p>
271<p>The DB_TXN_WRITE_NOSYNC flag may be used to configure Berkeley DB at any time during
272the life of the application.</p></ul>
273<a name="12"><!--meow--></a>
274<b><a name="DB_YIELDCPU">DB_YIELDCPU</a></b><ul compact><li>If set, Berkeley DB will yield the processor immediately after each page or
275mutex acquisition.  This functionality should never be used for purposes
276other than stress testing.
277<p>Calling DB_ENV-&gt;set_flags with the DB_YIELDCPU flag only affects
278the specified <a href="../api_c/env_class.html">DB_ENV</a> handle (and any other Berkeley DB handles opened
279within the scope of that handle).
280For consistent behavior across the environment, all <a href="../api_c/env_class.html">DB_ENV</a>
281handles opened in the environment must either set the DB_YIELDCPU flag
282or the flag should be specified in the <a href="../ref/env/db_config.html#DB_CONFIG">DB_CONFIG</a> configuration
283file.</p>
284<p>The DB_YIELDCPU flag may be used to configure Berkeley DB at any time during
285the life of the application.</p></ul>
286<br></ul>
287 <b>onoff</b><ul compact><li>If the <b>onoff</b> parameter is zero, the specified flags are cleared;
288otherwise they are set.</ul>
289<br>
290<br><b>Errors</b>
291<p>The DB_ENV-&gt;set_flags method
292may fail and return one of the following non-zero errors:</p>
293<br>
294<b>EINVAL</b><ul compact><li>An
295invalid flag value or parameter was specified.</ul>
296<br>
297<hr size=1 noshade>
298<b>Description: DB_ENV-&gt;get_flags</b>
299<p>The DB_ENV-&gt;get_flags method returns the configuration flags.</p>
300<p>The DB_ENV-&gt;get_flags method may be called at any time during the life of the
301application.</p>
302<p>The DB_ENV-&gt;get_flags method
303returns a non-zero error value on failure
304and 0 on success.
305</p>
306<b>Parameters</b> <br>
307 <b>flagsp</b><ul compact><li>The DB_ENV-&gt;get_flags method returns  the
308configuration flags in <b>flagsp</b>.</ul>
309<br>
310<hr size=1 noshade>
311<br><b>Class</b>
312<a href="../api_c/env_class.html">DB_ENV</a>
313<br><b>See Also</b>
314<a href="../api_c/env_list.html">Database Environments and Related Methods</a>
315</tt>
316<table width="100%"><tr><td><br></td><td align=right>
317<a href="../api_c/api_core.html"><img src="../images/api.gif" alt="API"></a><a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a>
318</td></tr></table>
319<p><font size=1>Copyright (c) 1996,2008 Oracle.  All rights reserved.</font>
320</body>
321</html>
322