memp_fopen.html   [plain text]


<!--$Id: memp_fopen.so,v 10.53 2006/08/08 05:24:05 mjc Exp $-->
<!--Copyright (c) 1997,2008 Oracle.  All rights reserved.-->
<!--See the file LICENSE for redistribution information.-->
<html>
<head>
<title>Berkeley DB: DbMpoolFile::open</title>
<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++">
</head>
<body bgcolor=white>
<table width="100%"><tr valign=top>
<td>
<b>DbMpoolFile::open</b>
</td>
<td align=right>
<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></td>
</tr></table>
<hr size=1 noshade>
<tt>
<b><pre>
#include &lt;db_cxx.h&gt;
<p>
int
DbMpoolFile::open(const char *file, u_int32_t flags, int mode, size_t pagesize);
</pre></b>
<hr size=1 noshade>
<b>Description: DbMpoolFile::open</b>
<p>The DbMpoolFile::open method opens a file in the shared memory buffer pool.</p>
<p>The DbMpoolFile::open method
either returns a non-zero error value
or throws an exception that encapsulates a non-zero error value on
failure, and returns 0 on success.
</p>
<b>Parameters</b> <br>
 <b>file</b><ul compact><li>The <b>file</b> parameter is the name of the file to be opened.  If
<b>file</b> is NULL, a private temporary file is created that
cannot be shared with any other process (although it may be shared with
other threads of control in the same process).</ul>
<p>When using a Unicode build on Windows (the default), the <b>file</b>
argument will be interpreted as a UTF-8 string, which is equivalent to
ASCII for Latin characters.</p>
 <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
or more of the following values:
<br>
<b><a name="DB_CREATE">DB_CREATE</a></b><ul compact><li>Create any underlying files, as necessary.  If the files do not already
exist and the DB_CREATE flag is not specified, the call will
fail.</ul>
<a name="2"><!--meow--></a>
<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
file to avoid double caching.</ul>
<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
dirty pages will cause copies to be made in the cache.</ul>
<b><a name="DB_NOMMAP">DB_NOMMAP</a></b><ul compact><li>Always copy this file into the local cache instead of potentially mapping
it into process memory (see the description of the
<a href="../api_cxx/env_set_mp_mmapsize.html">DbEnv::set_mp_mmapsize</a> method for further information).</ul>
<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
length will fail, by default.  If the DB_ODDFILESIZE flag is
set, any partial page at the end of the file will be ignored and the
open will proceed.</ul>
<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
using the pool functions will fail, regardless of the actual permissions
of the file.</ul>
<br></ul>
 <b>mode</b><ul compact><li>On Windows systems, the mode parameter is ignored.
<p>On UNIX systems or in IEEE/ANSI Std 1003.1 (POSIX) environments, files created by DbMpoolFile::open
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 (see
<b>umask</b>(2)).  Created files are owned by the process owner; the
group ownership of created files is based on the system and directory
defaults, and is not further specified by Berkeley DB.  System shared memory
segments created by DbMpoolFile::open are created with mode <b>mode</b>, unmodified
by the process' umask value.  If <b>mode</b> is 0, DbMpoolFile::open will use a
default mode of readable and writable by both owner and group.</p></ul>
 <b>pagesize</b><ul compact><li>The <b>pagesize</b> parameter is the size, in bytes, of the unit of
transfer between the application and the cache, although it is not
necessarily the unit of transfer between the cache and the underlying
filesystem.</ul>
<br>
<br><b>Errors</b>
<p>The DbMpoolFile::open method
may fail and throw
<a href="../api_cxx/except_class.html">DbException</a>,
encapsulating one of the following non-zero errors, or return one of
the following non-zero errors:</p>
<br>
<b>EINVAL</b><ul compact><li>If the file has already been entered into the pool, and the <b>pagesize</b>
value is not the same as when the file was entered into the pool, or the
length of the file is not zero or a multiple of the <b>pagesize</b>;
the DB_RDONLY flag was specified for an in-memory pool; or if an
invalid flag value or parameter was specified.</ul>
<br>
<p>If the maximum number of open files has been reached, the DbMpoolFile::open method will fail and
either return ENOMEM or
throw a DbMemoryException.</p>
<hr size=1 noshade>
<br><b>Class</b>
<a href="../api_cxx/env_class.html">DbEnv</a>, <a href="../api_cxx/mempfile_class.html">DbMpoolFile</a>
<br><b>See Also</b>
<a href="../api_cxx/memp_list.html">Memory Pools and Related Methods</a>
</tt>
<table width="100%"><tr><td><br></td><td align=right>
<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>
</td></tr></table>
<p><font size=1>Copyright (c) 1996,2008 Oracle.  All rights reserved.</font>
</body>
</html>