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