1<!--$Id: memp_fopen.so,v 10.53 2006/08/08 05:24:05 mjc Exp $-->
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: DbMpoolFile::open</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>DbMpoolFile::open</b>
14</td>
15<td align=right>
16<a href="../api_cxx/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_cxx.h&gt;
23<p>
24int
25DbMpoolFile::open(const char *file, u_int32_t flags, int mode, size_t pagesize);
26</pre></b>
27<hr size=1 noshade>
28<b>Description: DbMpoolFile::open</b>
29<p>The DbMpoolFile::open method opens a file in the shared memory buffer pool.</p>
30<p>The DbMpoolFile::open method
31either returns a non-zero error value
32or throws an exception that encapsulates a non-zero error value on
33failure, and returns 0 on success.
34</p>
35<b>Parameters</b> <br>
36 <b>file</b><ul compact><li>The <b>file</b> parameter is the name of the file to be opened.  If
37<b>file</b> is NULL, a private temporary file is created that
38cannot be shared with any other process (although it may be shared with
39other threads of control in the same process).</ul>
40<p>When using a Unicode build on Windows (the default), the <b>file</b>
41argument will be interpreted as a UTF-8 string, which is equivalent to
42ASCII for Latin characters.</p>
43 <b>flags</b><ul compact><li>The <b>flags</b> parameter must be set to 0 or by bitwise inclusively <b>OR</b>'ing together one
44or more of the following values:
45<br>
46<b><a name="DB_CREATE">DB_CREATE</a></b><ul compact><li>Create any underlying files, as necessary.  If the files do not already
47exist and the DB_CREATE flag is not specified, the call will
48fail.</ul>
49<a name="2"><!--meow--></a>
50<b><a name="DB_DIRECT">DB_DIRECT</a></b><ul compact><li>If set and supported by the system, turn off system buffering of the
51file to avoid double caching.</ul>
52<b><a name="DB_MULTIVERSION">DB_MULTIVERSION</a></b><ul compact><li>Open the file with support for <a href="../ref/transapp/read.html">multiversion concurrency control</a>.  Calls to <a href="../api_cxx/memp_fget.html">DbMpoolFile::get</a> which
53dirty pages will cause copies to be made in the cache.</ul>
54<b><a name="DB_NOMMAP">DB_NOMMAP</a></b><ul compact><li>Always copy this file into the local cache instead of potentially mapping
55it into process memory (see the description of the
56<a href="../api_cxx/env_set_mp_mmapsize.html">DbEnv::set_mp_mmapsize</a> method for further information).</ul>
57<b><a name="DB_ODDFILESIZE">DB_ODDFILESIZE</a></b><ul compact><li>Attempts to open files which are not a multiple of the page size in
58length will fail, by default.  If the DB_ODDFILESIZE flag is
59set, any partial page at the end of the file will be ignored and the
60open will proceed.</ul>
61<b><a name="DB_RDONLY">DB_RDONLY</a></b><ul compact><li>Open any underlying files for reading only.  Any attempt to write the file
62using the pool functions will fail, regardless of the actual permissions
63of the file.</ul>
64<br></ul>
65 <b>mode</b><ul compact><li>On Windows systems, the mode parameter is ignored.
66<p>On UNIX systems or in IEEE/ANSI Std 1003.1 (POSIX) environments, files created by DbMpoolFile::open
67are created with mode <b>mode</b> (as described in <b>chmod</b>(2))
68and modified by the process' umask value at the time of creation (see
69<b>umask</b>(2)).  Created files are owned by the process owner; the
70group ownership of created files is based on the system and directory
71defaults, and is not further specified by Berkeley DB.  System shared memory
72segments created by DbMpoolFile::open are created with mode <b>mode</b>, unmodified
73by the process' umask value.  If <b>mode</b> is 0, DbMpoolFile::open will use a
74default mode of readable and writable by both owner and group.</p></ul>
75 <b>pagesize</b><ul compact><li>The <b>pagesize</b> parameter is the size, in bytes, of the unit of
76transfer between the application and the cache, although it is not
77necessarily the unit of transfer between the cache and the underlying
78filesystem.</ul>
79<br>
80<br><b>Errors</b>
81<p>The DbMpoolFile::open method
82may fail and throw
83<a href="../api_cxx/except_class.html">DbException</a>,
84encapsulating one of the following non-zero errors, or return one of
85the following non-zero errors:</p>
86<br>
87<b>EINVAL</b><ul compact><li>If the file has already been entered into the pool, and the <b>pagesize</b>
88value is not the same as when the file was entered into the pool, or the
89length of the file is not zero or a multiple of the <b>pagesize</b>;
90the DB_RDONLY flag was specified for an in-memory pool; or if an
91invalid flag value or parameter was specified.</ul>
92<br>
93<p>If the maximum number of open files has been reached, the DbMpoolFile::open method will fail and
94either return ENOMEM or
95throw a DbMemoryException.</p>
96<hr size=1 noshade>
97<br><b>Class</b>
98<a href="../api_cxx/env_class.html">DbEnv</a>, <a href="../api_cxx/mempfile_class.html">DbMpoolFile</a>
99<br><b>See Also</b>
100<a href="../api_cxx/memp_list.html">Memory Pools and Related Methods</a>
101</tt>
102<table width="100%"><tr><td><br></td><td align=right>
103<a href="../api_cxx/api_core.html"><img src="../images/api.gif" alt="API"></a><a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a>
104</td></tr></table>
105<p><font size=1>Copyright (c) 1996,2008 Oracle.  All rights reserved.</font>
106</body>
107</html>
108