| 1 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> |
| 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 3 | <html xmlns="http://www.w3.org/1999/xhtml"> |
| 4 | <head> |
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
| 6 | <title>DbEnv::open()</title> |
| 7 | <link rel="stylesheet" href="apiReference.css" type="text/css" /> |
| 8 | <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /> |
| 9 | <link rel="start" href="index.html" title="Berkeley DB C++ API Reference" /> |
| 10 | <link rel="up" href="env.html" title="Chapter 5. The DbEnv Handle" /> |
| 11 | <link rel="prev" href="envlsn_reset.html" title="DbEnv::lsn_reset()" /> |
| 12 | <link rel="next" href="envremove.html" title="DbEnv::remove()" /> |
| 13 | </head> |
| 14 | <body> |
| 15 | <div xmlns="" class="navheader"> |
| 16 | <div class="libver"> |
| 17 | <p>Library Version 11.2.5.3</p> |
| 18 | </div> |
| 19 | <table width="100%" summary="Navigation header"> |
| 20 | <tr> |
| 21 | <th colspan="3" align="center">DbEnv::open()</th> |
| 22 | </tr> |
| 23 | <tr> |
| 24 | <td width="20%" align="left"><a accesskey="p" href="envlsn_reset.html">Prev</a> </td> |
| 25 | <th width="60%" align="center">Chapter 5. |
| 26 | The DbEnv Handle |
| 27 | </th> |
| 28 | <td width="20%" align="right"> <a accesskey="n" href="envremove.html">Next</a></td> |
| 29 | </tr> |
| 30 | </table> |
| 31 | <hr /> |
| 32 | </div> |
| 33 | <div class="sect1" lang="en" xml:lang="en"> |
| 34 | <div class="titlepage"> |
| 35 | <div> |
| 36 | <div> |
| 37 | <h2 class="title" style="clear: both"><a id="envopen"></a>DbEnv::open()</h2> |
| 38 | </div> |
| 39 | </div> |
| 40 | </div> |
| 41 | <pre class="programlisting">#include <db_cxx.h> |
| 42 | |
| 43 | int |
| 44 | DbEnv::open(const char *db_home, u_int32_t flags, int mode); </pre> |
| 45 | <p> |
| 46 | The <code class="methodname">DbEnv::open()</code> method opens a Berkeley |
| 47 | DB environment. It provides a structure for creating a consistent |
| 48 | environment for processes using one or more of the features of |
| 49 | Berkeley DB. |
| 50 | </p> |
| 51 | <p> |
| 52 | The <code class="methodname">DbEnv::open()</code> method <span> |
| 53 | |
| 54 | <span> |
| 55 | method either returns a non-zero error value or throws an |
| 56 | exception that encapsulates a non-zero error value on |
| 57 | failure, and returns 0 on success. |
| 58 | </span> |
| 59 | </span> If |
| 60 | <code class="methodname">DbEnv::open()</code> fails, the |
| 61 | <a class="xref" href="envclose.html" title="DbEnv::close()">DbEnv::close()</a> method must be |
| 62 | called to discard the <a class="link" href="env.html" title="Chapter 5. The DbEnv Handle">DbEnv</a> |
| 63 | handle. |
| 64 | </p> |
| 65 | <div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"> |
| 66 | <h3 class="title">Warning</h3> |
| 67 | <p> |
| 68 | Using environments with some journaling filesystems might |
| 69 | result in log file corruption. This can occur if the operating |
| 70 | system experiences an unclean shutdown when a log file is being |
| 71 | created. Please see |
| 72 | <a href="../../programmer_reference/transapp_journal.html" class="olink">Using |
| 73 | Recovery on Journaling Filesystems</a> |
| 74 | in the <em class="citetitle">Berkeley DB Programmer's Reference Guide</em> for more information. |
| 75 | </p> |
| 76 | </div> |
| 77 | <div class="sect2" lang="en" xml:lang="en"> |
| 78 | <div class="titlepage"> |
| 79 | <div> |
| 80 | <div> |
| 81 | <h3 class="title"><a id="idp7011736"></a>Parameters</h3> |
| 82 | </div> |
| 83 | </div> |
| 84 | </div> |
| 85 | <div class="sect3" lang="en" xml:lang="en"> |
| 86 | <div class="titlepage"> |
| 87 | <div> |
| 88 | <div> |
| 89 | <h4 class="title"><a id="idp6971408"></a>db_home</h4> |
| 90 | </div> |
| 91 | </div> |
| 92 | </div> |
| 93 | <p> |
| 94 | The <span class="bold"><strong>db_home</strong></span> |
| 95 | parameter is the database environment's home |
| 96 | directory. For more information on |
| 97 | <span class="bold"><strong>db_home</strong></span>, and filename |
| 98 | resolution in general, see <a href="../../programmer_reference/env_naming.html" class="olink">Berkeley DB File Naming</a>. The |
| 99 | environment variable |
| 100 | <span class="bold"><strong>DB_HOME</strong></span> may be used as the |
| 101 | path of the database home, as described in |
| 102 | <a href="../../programmer_reference/env_naming.html" class="olink">Berkeley DB File Naming</a>. |
| 103 | </p> |
| 104 | <p> |
| 105 | When using a Unicode build on Windows (the default), the |
| 106 | <span class="bold"><strong>db_home</strong></span> argument |
| 107 | will be interpreted as a UTF-8 string, which is equivalent to ASCII for |
| 108 | Latin characters. |
| 109 | </p> |
| 110 | </div> |
| 111 | <div class="sect3" lang="en" xml:lang="en"> |
| 112 | <div class="titlepage"> |
| 113 | <div> |
| 114 | <div> |
| 115 | <h4 class="title"><a id="idp7009408"></a>flags</h4> |
| 116 | </div> |
| 117 | </div> |
| 118 | </div> |
| 119 | <p> |
| 120 | The <span class="bold"><strong>flags</strong></span> parameter specifies |
| 121 | the subsystems that are initialized and how the application's |
| 122 | environment affects Berkeley DB file naming, among other things. |
| 123 | The <span class="bold"><strong>flags</strong></span> parameter must be set |
| 124 | to 0 or by bitwise inclusively |
| 125 | <span class="bold"><strong>OR</strong></span>'ing together one or more of the |
| 126 | values described in this section. |
| 127 | </p> |
| 128 | <p> |
| 129 | Because there are a large number of flags that can be specified, |
| 130 | they have been grouped together by functionality. The first |
| 131 | group of flags indicates which of the Berkeley DB subsystems |
| 132 | should be initialized. |
| 133 | </p> |
| 134 | <p> |
| 135 | The choice of subsystems initialized for a Berkeley DB database |
| 136 | environment is specified by the thread of control initially |
| 137 | creating the environment. Any subsequent thread of control |
| 138 | joining the environment will automatically be configured to use |
| 139 | the same subsystems as were created in the environment (unless |
| 140 | the thread of control requests a subsystem not available in the |
| 141 | environment, which will fail). Applications joining an |
| 142 | environment, able to adapt to whatever subsystems have been |
| 143 | configured in the environment, should open the environment |
| 144 | without specifying any subsystem flags. Applications joining an |
| 145 | environment, requiring specific subsystems from their |
| 146 | environments, should open the environment specifying those |
| 147 | specific subsystem flags. |
| 148 | </p> |
| 149 | <div class="itemizedlist"> |
| 150 | <ul type="disc"> |
| 151 | <li> |
| 152 | <p><a id="envopen_DB_INIT_CDB"></a> |
| 153 | <code class="literal">DB_INIT_CDB</code> |
| 154 | </p> |
| 155 | <p> |
| 156 | Initialize locking for the |
| 157 | <a href="../../programmer_reference/cam.html#cam_intro" class="olink">Berkeley DB Concurrent Data Store</a> |
| 158 | product. In this mode, Berkeley DB provides multiple |
| 159 | reader/single writer access. The only other subsystem |
| 160 | that should be specified with the <code class="literal">DB_INIT_CDB</code> |
| 161 | flag is <code class="literal">DB_INIT_MPOOL</code>. |
| 162 | </p> |
| 163 | </li> |
| 164 | <li> |
| 165 | <p><a id="envopen_DB_INIT_LOCK"></a> |
| 166 | <code class="literal">DB_INIT_LOCK</code> |
| 167 | </p> |
| 168 | <p> |
| 169 | Initialize the locking subsystem. This subsystem should |
| 170 | be used when multiple processes or threads are going to |
| 171 | be reading and writing a Berkeley DB database, so that |
| 172 | they do not interfere with each other. If all threads |
| 173 | are accessing the database(s) read-only, locking is |
| 174 | unnecessary. When the DB_INIT_LOCK flag is specified, it |
| 175 | is usually necessary to run a deadlock detector, as |
| 176 | well. See <a class="link" href="db_deadlock.html" title="db_deadlock">db_deadlock</a> |
| 177 | and <a class="xref" href="lockdetect.html" title="DbEnv::lock_detect()">DbEnv::lock_detect()</a> |
| 178 | for more information. |
| 179 | </p> |
| 180 | </li> |
| 181 | <li> |
| 182 | <p><a id="envopen_DB_INIT_LOG"></a> |
| 183 | <code class="literal">DB_INIT_LOG</code> |
| 184 | </p> |
| 185 | <p> |
| 186 | Initialize the logging subsystem. This subsystem should |
| 187 | be used when recovery from application or system failure |
| 188 | is necessary. If the log region is being created and log |
| 189 | files are already present, the log files are reviewed; |
| 190 | subsequent log writes are appended to the end of the |
| 191 | log, rather than overwriting current log entries. |
| 192 | </p> |
| 193 | </li> |
| 194 | <li> |
| 195 | <p><a id="envopen_DB_INIT_MPOOL"></a> |
| 196 | <code class="literal">DB_INIT_MPOOL</code> |
| 197 | </p> |
| 198 | <p> |
| 199 | Initialize the shared memory buffer pool subsystem. |
| 200 | This subsystem should be used whenever an application is |
| 201 | using any Berkeley DB access method. |
| 202 | </p> |
| 203 | </li> |
| 204 | <li> |
| 205 | <p><a id="envopen_DB_INIT_REP"></a> |
| 206 | <code class="literal">DB_INIT_REP</code> |
| 207 | </p> |
| 208 | <p> |
| 209 | Initialize the replication subsystem. This subsystem |
| 210 | should be used whenever an application plans on using |
| 211 | replication. The <code class="literal">DB_INIT_REP</code> flag |
| 212 | requires the <code class="literal">DB_INIT_TXN</code> and |
| 213 | <code class="literal">DB_INIT_LOCK</code> flags also be |
| 214 | configured. |
| 215 | </p> |
| 216 | <p> |
| 217 | You can also specify this flag in the <a href="../../programmer_reference/env_db_config.html#env_db_config.DB_CONFIG" class="olink">DB_CONFIG</a> |
| 218 | configuration file. The syntax is a single line |
| 219 | with the string "set_open_flags", one or more |
| 220 | whitespace characters, the string "DB_INIT_REP", |
| 221 | optionally one or more whitespace characters and |
| 222 | the string "on" or "off". If the optional string |
| 223 | is omitted, the default is "on"; for example, |
| 224 | "set_open_flags DB_INIT_REP" or "set_open_flags |
| 225 | DB_INIT_REP on". Because the DB_CONFIG file is |
| 226 | read when the database environment is opened, it |
| 227 | will silently overrule configuration done before |
| 228 | that time. |
| 229 | </p> |
| 230 | </li> |
| 231 | <li> |
| 232 | <p><a id="envopen_DB_INIT_TXN"></a> |
| 233 | <code class="literal">DB_INIT_TXN</code> |
| 234 | </p> |
| 235 | <p> |
| 236 | Initialize the transaction subsystem. This subsystem |
| 237 | should be used when recovery and atomicity of multiple |
| 238 | operations are important. The |
| 239 | <code class="literal">DB_INIT_TXN</code> flag implies the |
| 240 | <code class="literal">DB_INIT_LOG</code> flag. |
| 241 | </p> |
| 242 | </li> |
| 243 | </ul> |
| 244 | </div> |
| 245 | <p> |
| 246 | The second group of flags govern what recovery, if any, is |
| 247 | performed when the environment is initialized: |
| 248 | </p> |
| 249 | <div class="itemizedlist"> |
| 250 | <ul type="disc"> |
| 251 | <li> |
| 252 | <p><a id="envopen_DB_RECOVER"></a> |
| 253 | <code class="literal">DB_RECOVER</code> |
| 254 | </p> |
| 255 | <p> |
| 256 | Run normal recovery on this environment before opening |
| 257 | it for normal use. If this flag is set, the |
| 258 | <code class="literal">DB_CREATE</code> and |
| 259 | <code class="literal">DB_INIT_TXN</code> flags must also be set, |
| 260 | because the regions will be removed and re-created, and |
| 261 | transactions are required for application recovery. |
| 262 | </p> |
| 263 | </li> |
| 264 | <li> |
| 265 | <p><a id="envopen_DB_RECOVER_FATAL"></a> |
| 266 | <code class="literal">DB_RECOVER_FATAL</code> |
| 267 | </p> |
| 268 | <p> |
| 269 | Run catastrophic recovery on this environment before |
| 270 | opening it for normal use. If this flag is set, the |
| 271 | <code class="literal">DB_CREATE</code> and |
| 272 | <code class="literal">DB_INIT_TXN</code> flags must also be set, |
| 273 | because the regions will be removed and re-created, and |
| 274 | transactions are required for application recovery. |
| 275 | </p> |
| 276 | </li> |
| 277 | </ul> |
| 278 | </div> |
| 279 | <p> |
| 280 | A standard part of the recovery process is to remove the |
| 281 | existing Berkeley DB environment and create a new one in which |
| 282 | to perform recovery. If the thread of control performing |
| 283 | recovery does not specify the correct region initialization |
| 284 | information (for example, the correct memory pool cache size), |
| 285 | the result can be an application running in an environment with |
| 286 | incorrect cache and other subsystem sizes. For this reason, the |
| 287 | thread of control performing recovery should specify correct |
| 288 | configuration information before calling the |
| 289 | <code class="methodname">DbEnv::open()</code> method; or it should |
| 290 | remove the environment after recovery is completed, leaving |
| 291 | creation of the correctly sized environment to a subsequent call |
| 292 | to the <code class="methodname">DbEnv::open()</code> method. |
| 293 | </p> |
| 294 | <p> |
| 295 | All Berkeley DB recovery processing must be single-threaded; |
| 296 | that is, only a single thread of control may perform recovery or |
| 297 | access a Berkeley DB environment while recovery is being |
| 298 | performed. Because it is not an error to specify |
| 299 | <code class="literal">DB_RECOVER</code> for an environment for which no |
| 300 | recovery is required, it is reasonable programming practice for |
| 301 | the thread of control responsible for performing recovery and |
| 302 | creating the environment to always specify the |
| 303 | <code class="literal">DB_CREATE</code> and <code class="literal">DB_RECOVER</code> |
| 304 | flags during startup. |
| 305 | </p> |
| 306 | <p> |
| 307 | The third group of flags govern file-naming extensions in the |
| 308 | environment: |
| 309 | </p> |
| 310 | <div class="itemizedlist"> |
| 311 | <ul type="disc"> |
| 312 | <li> |
| 313 | <p><a id="envopen_DB_USE_ENVIRON"></a> |
| 314 | <code class="literal">DB_USE_ENVIRON</code> |
| 315 | </p> |
| 316 | <p> |
| 317 | The Berkeley DB process' environment may be permitted to |
| 318 | specify information to be used when naming files; see |
| 319 | <a href="../../programmer_reference/env_naming.html" class="olink">Berkeley DB File Naming</a>. |
| 320 | Because permitting users to specify which files are used |
| 321 | can create security problems, environment information |
| 322 | will be used in file naming for all users only if the |
| 323 | <code class="literal">DB_USE_ENVIRON</code> flag is set. |
| 324 | </p> |
| 325 | </li> |
| 326 | <li> |
| 327 | <p><a id="envopen_DB_USE_ENVIRON_ROOT"></a> |
| 328 | <code class="literal">DB_USE_ENVIRON_ROOT</code> |
| 329 | </p> |
| 330 | <p> |
| 331 | The Berkeley DB process' environment may be permitted to |
| 332 | specify information to be used when naming files; see |
| 333 | <a href="../../programmer_reference/env_naming.html" class="olink">Berkeley DB File Naming</a>. |
| 334 | Because permitting users to specify which files are used |
| 335 | can create security problems, if the |
| 336 | <code class="literal">DB_USE_ENVIRON_ROOT</code> flag is set, |
| 337 | environment information will be used in file naming only |
| 338 | for users with appropriate permissions (for example, |
| 339 | users with a user-ID of 0 on <code class="literal">UNIX</code> |
| 340 | systems). |
| 341 | </p> |
| 342 | </li> |
| 343 | </ul> |
| 344 | </div> |
| 345 | <p> |
| 346 | Finally, there are a few additional unrelated flags: |
| 347 | </p> |
| 348 | <div class="itemizedlist"> |
| 349 | <ul type="disc"> |
| 350 | <li> |
| 351 | <p><a id="envopen_DB_CREATE"></a> |
| 352 | <code class="literal">DB_CREATE</code> |
| 353 | </p> |
| 354 | <p> |
| 355 | Cause Berkeley DB subsystems to create any underlying |
| 356 | files, as necessary. |
| 357 | </p> |
| 358 | </li> |
| 359 | <li> |
| 360 | <p><a id="envopen_DB_LOCKDOWN"></a> |
| 361 | <code class="literal">DB_LOCKDOWN</code> |
| 362 | </p> |
| 363 | <p> |
| 364 | Lock shared Berkeley DB environment files and |
| 365 | memory-mapped databases into memory. |
| 366 | </p> |
| 367 | </li> |
| 368 | <li> |
| 369 | <p><a id="envopen_DB_FAILCHK"></a> |
| 370 | <code class="literal">DB_FAILCHK</code> |
| 371 | </p> |
| 372 | <p> |
| 373 | Internally call the <a class="xref" href="envfailchk.html" title="DbEnv::failchk()">DbEnv::failchk()</a> |
| 374 | method as part of opening the environment. When |
| 375 | <code class="literal">DB_FAILCHK</code> is specified, a check is |
| 376 | made to ensure all |
| 377 | <code class="methodname">DbEnv::failchk()</code> prerequisites |
| 378 | are meet. |
| 379 | </p> |
| 380 | <p> |
| 381 | If the <code class="literal">DB_FAILCHK</code> flag is used in |
| 382 | conjunction with the <code class="literal">DB_REGISTER</code> |
| 383 | flag, then a check will be made to see if the |
| 384 | environment needs recovery. If recovery is needed, a |
| 385 | call will be made to the |
| 386 | <code class="methodname">DbEnv::failchk()</code> method to |
| 387 | release any database reads locks held by the thread of |
| 388 | control that exited and, if needed, to abort the |
| 389 | unresolved transaction. If |
| 390 | <code class="methodname">DbEnv::failchk()</code> determines |
| 391 | environment recovery is still required, the recovery |
| 392 | actions for <code class="literal">DB_REGISTER</code> will be |
| 393 | followed. |
| 394 | </p> |
| 395 | <p> |
| 396 | If the <code class="literal">DB_FAILCHK</code> flag is not used in |
| 397 | conjunction with the <code class="literal">DB_REGISTER</code> |
| 398 | flag, then make an internal call to |
| 399 | <code class="methodname">DbEnv::failchk()</code> as the last |
| 400 | step of opening the environment. If |
| 401 | <code class="methodname">DbEnv::failchk()</code> determines |
| 402 | database environment recovery is |
| 403 | required, |
| 404 | <a href="../../programmer_reference/program_errorret.html#program_errorret.DB_RUNRECOVERY" class="olink">DB_RUNRECOVERY</a> |
| 405 | will be returned. |
| 406 | |
| 407 | </p> |
| 408 | </li> |
| 409 | <li> |
| 410 | <p><a id="envopen_DB_PRIVATE"></a> |
| 411 | <code class="literal">DB_PRIVATE</code> |
| 412 | </p> |
| 413 | <p> |
| 414 | Allocate region memory from the heap instead of from |
| 415 | memory backed by the filesystem or system shared memory. |
| 416 | </p> |
| 417 | <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"> |
| 418 | <h3 class="title">Note</h3> |
| 419 | <p> |
| 420 | Use of this flag means that the environment can only be |
| 421 | accessed by one environment handle. The environment |
| 422 | cannot be accessed by multiple processes. This is true |
| 423 | even if one of those processes is one of the the Berkeley DB |
| 424 | utilities. (For example, |
| 425 | <a class="link" href="db_archive.html" title="db_archive">db_archive</a>, |
| 426 | <a class="link" href="db_checkpoint.html" title="db_checkpoint">db_checkpoint</a> or |
| 427 | <a class="link" href="db_stat.html" title="db_stat">db_stat</a>.) |
| 428 | Nor can a single process open multiple |
| 429 | handles to the environment. |
| 430 | </p> |
| 431 | </div> |
| 432 | <p> |
| 433 | This flag has two effects on the Berkeley DB |
| 434 | environment. First, all underlying data structures are |
| 435 | allocated from per-process memory instead of from shared |
| 436 | memory that is accessible to more than a single process. |
| 437 | Second, mutexes are only configured to work between |
| 438 | threads. |
| 439 | </p> |
| 440 | <p> |
| 441 | See |
| 442 | <a href="../../programmer_reference/env_region.html" class="olink">Shared Memory Regions</a> |
| 443 | for more information. |
| 444 | </p> |
| 445 | <p> |
| 446 | You can also specify this flag in the <a href="../../programmer_reference/env_db_config.html#env_db_config.DB_CONFIG" class="olink">DB_CONFIG</a> |
| 447 | configuration file. The syntax is a single line with the |
| 448 | string "set_open_flags", one or more whitespace |
| 449 | characters, the string "DB_PRIVATE", optionally one or |
| 450 | more whitespace characters and the string "on" or "off". |
| 451 | If the optional string is omitted, the default is "on"; |
| 452 | for example, "set_open_flags DB_PRIVATE" or |
| 453 | "set_open_flags DB_PRIVATE on". Because the DB_CONFIG |
| 454 | file is read when the database environment is opened, it |
| 455 | will silently overrule configuration done before that |
| 456 | time. |
| 457 | </p> |
| 458 | </li> |
| 459 | <li> |
| 460 | <p><a id="envopen_DB_REGISTER"></a> |
| 461 | <code class="literal">DB_REGISTER</code> |
| 462 | </p> |
| 463 | <p> |
| 464 | Check to see if recovery needs to be performed before |
| 465 | opening the database environment. (For this check to be |
| 466 | accurate, all processes using the environment must |
| 467 | specify <code class="literal">DB_REGISTER</code> when opening the |
| 468 | environment.) If recovery needs to be performed for any |
| 469 | reason (including the initial use of the |
| 470 | <code class="literal">DB_REGISTER</code> flag), and |
| 471 | <code class="literal">DB_RECOVER</code> is also specified, |
| 472 | recovery will be performed and the open will proceed |
| 473 | normally. If recovery needs to be performed and |
| 474 | <code class="literal">DB_RECOVER</code> is not specified, |
| 475 | <a href="../../programmer_reference/program_errorret.html#program_errorret.DB_RUNRECOVERY" class="olink">DB_RUNRECOVERY</a> |
| 476 | will be returned. If recovery does not need to be |
| 477 | performed, the <code class="literal">DB_RECOVER</code> flag will |
| 478 | be ignored. See |
| 479 | <a href="../../programmer_reference/transapp_app.html" class="olink">Architecting Transactional Data Store applications</a> |
| 480 | for more information. |
| 481 | </p> |
| 482 | </li> |
| 483 | <li> |
| 484 | <p><a id="envopen_DB_SYSTEM_MEM"></a> |
| 485 | <code class="literal">DB_SYSTEM_MEM</code> |
| 486 | </p> |
| 487 | <p> |
| 488 | Allocate region memory from system shared memory instead |
| 489 | of from heap memory or memory backed by the filesystem. |
| 490 | </p> |
| 491 | <p> |
| 492 | See |
| 493 | <a href="../../programmer_reference/env_region.html" class="olink">Shared Memory Regions</a> |
| 494 | for more information. |
| 495 | </p> |
| 496 | </li> |
| 497 | <li> |
| 498 | <p><a id="envopen_DB_THREAD"></a> |
| 499 | <code class="literal">DB_THREAD</code> |
| 500 | </p> |
| 501 | <p> |
| 502 | Cause the |
| 503 | <a class="link" href="env.html" title="Chapter 5. The DbEnv Handle">DbEnv</a> |
| 504 | handle returned by <code class="methodname">DbEnv::open()</code> to be <span class="emphasis"><em>free-threaded;</em></span> that is, |
| 505 | concurrently usable by multiple threads in the |
| 506 | address space. The <code class="literal">DB_THREAD </code> |
| 507 | flag should be specified if the |
| 508 | <a class="link" href="env.html" title="Chapter 5. The DbEnv Handle">DbEnv</a> handle will be |
| 509 | concurrently used by more than one thread in the |
| 510 | process, or if any |
| 511 | <a class="link" href="db.html" title="Chapter 2. The Db Handle">Db</a> handles opened in |
| 512 | the scope of the |
| 513 | <a class="link" href="env.html" title="Chapter 5. The DbEnv Handle">DbEnv</a> handle will be |
| 514 | concurrently used by more than one thread in the |
| 515 | process. |
| 516 | </p> |
| 517 | <p> |
| 518 | This flag is required when using the Replication Manager. |
| 519 | </p> |
| 520 | <p> |
| 521 | You can also specify this flag in the <a href="../../programmer_reference/env_db_config.html#env_db_config.DB_CONFIG" class="olink">DB_CONFIG</a> |
| 522 | configuration file. The syntax is a single line with |
| 523 | the string "set_open_flags", one or more whitespace |
| 524 | characters, the string "DB_THREAD", optionally one |
| 525 | or more whitespace characters and the string "on" or |
| 526 | "off". If the optional string is omitted, the |
| 527 | default is "on"; for example, "set_open_flags |
| 528 | DB_THREAD" or "set_open_flags DB_THREAD on". |
| 529 | Because the DB_CONFIG file is read when the database |
| 530 | environment is opened, it will silently overrule |
| 531 | configuration done before that time. |
| 532 | </p> |
| 533 | </li> |
| 534 | </ul> |
| 535 | </div> |
| 536 | </div> |
| 537 | <div class="sect3" lang="en" xml:lang="en"> |
| 538 | <div class="titlepage"> |
| 539 | <div> |
| 540 | <div> |
| 541 | <h4 class="title"><a id="idp7021040"></a>mode</h4> |
| 542 | </div> |
| 543 | </div> |
| 544 | </div> |
| 545 | <p> |
| 546 | On Windows systems, the mode parameter is ignored. |
| 547 | </p> |
| 548 | <p> |
| 549 | On UNIX systems or in IEEE/ANSI Std 1003.1 (POSIX) |
| 550 | environments, files created by Berkeley DB are created with |
| 551 | mode <span class="bold"><strong>mode</strong></span> (as described in |
| 552 | <span class="bold"><strong>chmod</strong></span>(2)) and modified by the |
| 553 | process' umask value at the time of creation (see |
| 554 | <span class="bold"><strong>umask</strong></span>(2)). Created files are |
| 555 | owned by the process owner; the group ownership of created |
| 556 | files is based on the system and directory defaults, and is |
| 557 | not further specified by Berkeley DB. System shared memory |
| 558 | segments created by Berkeley DB are created with mode |
| 559 | <span class="bold"><strong>mode</strong></span>, unmodified by the |
| 560 | process' umask value. If |
| 561 | <span class="bold"><strong>mode</strong></span> is 0, Berkeley DB will use a |
| 562 | default mode of readable and writable by both owner and group. |
| 563 | </p> |
| 564 | </div> |
| 565 | </div> |
| 566 | <div class="sect2" lang="en" xml:lang="en"> |
| 567 | <div class="titlepage"> |
| 568 | <div> |
| 569 | <div> |
| 570 | <h3 class="title"><a id="idp7021232"></a>Errors</h3> |
| 571 | </div> |
| 572 | </div> |
| 573 | </div> |
| 574 | <p> |
| 575 | The <code class="methodname">DbEnv::open()</code> <span> |
| 576 | |
| 577 | <span> |
| 578 | method may fail and throw a <a class="link" href="dbexception.html" title="Chapter 6. The DbException Class">DbException</a> |
| 579 | exception, encapsulating one of the following non-zero errors, or return one |
| 580 | of the following non-zero errors: |
| 581 | </span> |
| 582 | </span> |
| 583 | </p> |
| 584 | <div class="sect3" lang="en" xml:lang="en"> |
| 585 | <div class="titlepage"> |
| 586 | <div> |
| 587 | <div> |
| 588 | <h4 class="title"><a id="idp7077936"></a>DB_RUNRECOVERY</h4> |
| 589 | </div> |
| 590 | </div> |
| 591 | </div> |
| 592 | <p> |
| 593 | Either the <code class="literal">DB_REGISTER</code> flag was specified, a |
| 594 | failure occurred, and no recovery flag was specified, or the |
| 595 | <code class="literal">DB_FAILCHK</code> flag was specified and recovery |
| 596 | was deemed necessary. |
| 597 | </p> |
| 598 | </div> |
| 599 | <div class="sect3" lang="en" xml:lang="en"> |
| 600 | <div class="titlepage"> |
| 601 | <div> |
| 602 | <div> |
| 603 | <h4 class="title"><a id="idp7020368"></a>DB_VERSION_MISMATCH</h4> |
| 604 | </div> |
| 605 | </div> |
| 606 | </div> |
| 607 | <p> |
| 608 | The version of the Berkeley DB library doesn't match the version |
| 609 | that created the database environment. |
| 610 | </p> |
| 611 | </div> |
| 612 | <div class="sect3" lang="en" xml:lang="en"> |
| 613 | <div class="titlepage"> |
| 614 | <div> |
| 615 | <div> |
| 616 | <h4 class="title"><a id="idp7062352"></a>EAGAIN</h4> |
| 617 | </div> |
| 618 | </div> |
| 619 | </div> |
| 620 | <p> |
| 621 | The shared memory region was locked and (repeatedly) unavailable. |
| 622 | </p> |
| 623 | </div> |
| 624 | <div class="sect3" lang="en" xml:lang="en"> |
| 625 | <div class="titlepage"> |
| 626 | <div> |
| 627 | <div> |
| 628 | <h4 class="title"><a id="idp7093440"></a>EINVAL</h4> |
| 629 | </div> |
| 630 | </div> |
| 631 | </div> |
| 632 | <p> |
| 633 | If the <code class="literal">DB_THREAD</code> flag was specified and fast |
| 634 | mutexes are not available for this architecture; The |
| 635 | <code class="literal">DB_HOME</code> or <code class="literal">TMPDIR</code> |
| 636 | environment variables were set, but empty; An incorrectly |
| 637 | formatted <span class="bold"><strong>NAME VALUE</strong></span> entry or |
| 638 | line was found; or if an invalid flag value or parameter was |
| 639 | specified. |
| 640 | </p> |
| 641 | </div> |
| 642 | <div class="sect3" lang="en" xml:lang="en"> |
| 643 | <div class="titlepage"> |
| 644 | <div> |
| 645 | <div> |
| 646 | <h4 class="title"><a id="idp6988664"></a>ENOENT</h4> |
| 647 | </div> |
| 648 | </div> |
| 649 | </div> |
| 650 | <p> |
| 651 | The file or directory does not exist. |
| 652 | </p> |
| 653 | </div> |
| 654 | </div> |
| 655 | <div class="sect2" lang="en" xml:lang="en"> |
| 656 | <div class="titlepage"> |
| 657 | <div> |
| 658 | <div> |
| 659 | <h3 class="title"><a id="idp7076856"></a>Class</h3> |
| 660 | </div> |
| 661 | </div> |
| 662 | </div> |
| 663 | <p> |
| 664 | <a class="link" href="env.html" title="Chapter 5. The DbEnv Handle">DbEnv</a> |
| 665 | </p> |
| 666 | </div> |
| 667 | <div class="sect2" lang="en" xml:lang="en"> |
| 668 | <div class="titlepage"> |
| 669 | <div> |
| 670 | <div> |
| 671 | <h3 class="title"><a id="idp7018000"></a>See Also</h3> |
| 672 | </div> |
| 673 | </div> |
| 674 | </div> |
| 675 | <p> |
| 676 | <a class="xref" href="env.html#envlist" title="Database Environments and Related Methods">Database Environments and Related Methods</a> |
| 677 | </p> |
| 678 | </div> |
| 679 | </div> |
| 680 | <div class="navfooter"> |
| 681 | <hr /> |
| 682 | <table width="100%" summary="Navigation footer"> |
| 683 | <tr> |
| 684 | <td width="40%" align="left"><a accesskey="p" href="envlsn_reset.html">Prev</a> </td> |
| 685 | <td width="20%" align="center"> |
| 686 | <a accesskey="u" href="env.html">Up</a> |
| 687 | </td> |
| 688 | <td width="40%" align="right"> <a accesskey="n" href="envremove.html">Next</a></td> |
| 689 | </tr> |
| 690 | <tr> |
| 691 | <td width="40%" align="left" valign="top">DbEnv::lsn_reset() </td> |
| 692 | <td width="20%" align="center"> |
| 693 | <a accesskey="h" href="index.html">Home</a> |
| 694 | </td> |
| 695 | <td width="40%" align="right" valign="top"> DbEnv::remove()</td> |
| 696 | </tr> |
| 697 | </table> |
| 698 | </div> |
| 699 | </body> |
| 700 | </html> |