libdb/docs/api_reference/C/mempfopen.html
2012-11-14 16:35:20 -05:00

297 lines
13 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>DB_MPOOLFILE-&gt;open()</title>
<link rel="stylesheet" href="apiReference.css" type="text/css" />
<meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
<link rel="start" href="index.html" title="Berkeley DB C API Reference" />
<link rel="up" href="memp.html" title="Chapter 8.  The DB_MPOOLFILE Handle" />
<link rel="prev" href="mempfget.html" title="DB_MPOOLFILE-&gt;get()" />
<link rel="next" href="mempput.html" title="DB_MPOOLFILE-&gt;put()" />
</head>
<body>
<div xmlns="" class="navheader">
<div class="libver">
<p>Library Version 11.2.5.3</p>
</div>
<table width="100%" summary="Navigation header">
<tr>
<th colspan="3" align="center">DB_MPOOLFILE-&gt;open()</th>
</tr>
<tr>
<td width="20%" align="left"><a accesskey="p" href="mempfget.html">Prev</a> </td>
<th width="60%" align="center">Chapter 8. 
The DB_MPOOLFILE Handle
</th>
<td width="20%" align="right"> <a accesskey="n" href="mempput.html">Next</a></td>
</tr>
</table>
<hr />
</div>
<div class="sect1" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h2 class="title" style="clear: both"><a id="mempfopen"></a>DB_MPOOLFILE-&gt;open()</h2>
</div>
</div>
</div>
<pre class="programlisting">#include &lt;db.h&gt;
int
DB_MPOOLFILE-&gt;open(DB_MPOOLFILE *mpf,
char *file, u_int32_t flags, int mode, size_t pagesize); </pre>
<p>
The <code class="methodname">DB_MPOOLFILE-&gt;open()</code> method opens a file in the in-memory cache.
</p>
<p>
The <code class="methodname">DB_MPOOLFILE-&gt;open()</code> <span>
<span>
method returns a non-zero error value on failure and 0 on success.
</span>
</span>
</p>
<div class="sect2" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h3 class="title"><a id="idp61413992"></a>Parameters</h3>
</div>
</div>
</div>
<div class="sect3" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h4 class="title"><a id="idp61421336"></a>file</h4>
</div>
</div>
</div>
<p>
The <span class="bold"><strong>file</strong></span> parameter is the name of the
file to be opened. If <span class="bold"><strong>file</strong></span> 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).
</p>
<p>
When using a Unicode build on Windows (the default), the
<span class="bold"><strong>file</strong></span> argument will
be interpreted as a UTF-8 string, which is equivalent to ASCII for Latin
characters.
</p>
</div>
<div class="sect3" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h4 class="title"><a id="idp61403432"></a>flags</h4>
</div>
</div>
</div>
<p>
The <span class="bold"><strong>flags</strong></span> parameter must be set to zero or
by bitwise inclusively <span class="bold"><strong>OR</strong></span>'ing together one
or more of the following values:
</p>
<div class="itemizedlist">
<ul type="disc">
<li>
<p><a id="mempopen_DB_CREATE"></a>
<code class="literal">DB_CREATE</code>
</p>
<p>
Create any underlying files, as necessary. If the database do not already exist
and the <code class="literal">DB_CREATE</code> flag is not specified, the
call will fail.
</p>
</li>
<li>
<p><a id="mempopen_DB_EXCL"></a>
<code class="literal">DB_DIRECT</code>
</p>
<p>
If set and supported by the system, turn off system buffering of the file to
avoid double caching.
</p>
</li>
<li>
<p><a id="mempopen_DB_MULTIVERSION"></a>
<code class="literal">DB_MULTIVERSION</code>
</p>
<p>
Open the file with support for
<a href="../../programmer_reference/transapp_read.html" class="olink">multiversion concurrency control</a>.
Calls to <a class="xref" href="mempfget.html" title="DB_MPOOLFILE-&gt;get()">DB_MPOOLFILE-&gt;get()</a>
with dirty pages will cause copies to be made in the cache.
</p>
</li>
<li>
<p><a id="mempopen_DB_NOMMAP"></a>
<code class="literal">DB_NOMMAP</code>
</p>
<p>
Always copy this file into the local cache instead of potentially mapping it
into process memory (see the
<a class="xref" href="envset_mp_mmapsize.html" title="DB_ENV-&gt;set_mp_mmapsize()">DB_ENV-&gt;set_mp_mmapsize()</a>
method for further information).
</p>
</li>
<li>
<p><a id="mempopen_DB_ODDFILESIZE"></a>
<code class="literal">DB_ODDFILESIZE</code>
</p>
<p>
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.
</p>
</li>
<li>
<p><a id="mempopen_DB_RDONLY"></a>
<code class="literal">DB_RDONLY</code>
</p>
<p>
Open any underlying files for reading only. Any attempt to modify
the file using the memory pool (cache) functions will fail, regardless of the actual
permissions of the file.
</p>
</li>
</ul>
</div>
</div>
<div class="sect3" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h4 class="title"><a id="idp61438656"></a>mode</h4>
</div>
</div>
</div>
<p>
On Windows systems, the mode parameter is ignored.
</p>
<p>
On UNIX systems or in IEEE/ANSI Std 1003.1 (POSIX) environments, files
created by <code class="methodname">DB_MPOOLFILE-&gt;open()</code> are created with mode
<span class="bold"><strong>mode</strong></span> (as described in <span class="bold"><strong>chmod</strong></span>(2)) and modified by the process' umask
value at the time of creation (see <span class="bold"><strong>umask</strong></span>(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 <code class="methodname">DB_MPOOLFILE-&gt;open()</code> are
created with mode <span class="bold"><strong>mode</strong></span>, unmodified by the
process' umask value. If <span class="bold"><strong>mode</strong></span> is 0,
<code class="methodname">DB_MPOOLFILE-&gt;open()</code> will use a default mode of readable
and writable by both owner and group.
</p>
</div>
<div class="sect3" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h4 class="title"><a id="idp61437920"></a>pagesize</h4>
</div>
</div>
</div>
<p>
The <span class="bold"><strong>pagesize</strong></span> 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.
</p>
</div>
</div>
<div class="sect2" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h3 class="title"><a id="idp61384616"></a>Errors</h3>
</div>
</div>
</div>
<p>
The <code class="methodname">DB_MPOOLFILE-&gt;open()</code> <span>
<span>
method may fail and return one of the following non-zero errors:
</span>
</span>
</p>
<div class="sect3" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h4 class="title"><a id="idp61434488"></a>EINVAL</h4>
</div>
</div>
</div>
<p>
If the file has already been entered into the cache, and the <span class="bold"><strong>pagesize</strong></span> value is not the same as when the file
was entered into the cache, or the length of the file is not zero or a
multiple of the <span class="bold"><strong>pagesize</strong></span>; the
DB_RDONLY flag was specified for an in-memory cache; or if an invalid
flag value or parameter was specified.
</p>
</div>
<div class="sect3" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h4 class="title"><a id="idp61435632"></a>ENOMEM</h4>
</div>
</div>
</div>
<p>
The maximum number of open files has been reached.
</p>
</div>
</div>
<div class="sect2" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h3 class="title"><a id="idp61431568"></a>Class</h3>
</div>
</div>
</div>
<p>
<a class="link" href="env.html" title="Chapter 5.  The DB_ENV Handle">DB_ENV</a>, <a class="link" href="memp.html" title="Chapter 8.  The DB_MPOOLFILE Handle">DB_MPOOLFILE</a>
</p>
</div>
<div class="sect2" lang="en" xml:lang="en">
<div class="titlepage">
<div>
<div>
<h3 class="title"><a id="idp61436712"></a>See Also</h3>
</div>
</div>
</div>
<p>
<a class="xref" href="memp.html#memplist" title="Memory Pools and Related Methods">Memory Pools and Related Methods</a>
</p>
</div>
</div>
<div class="navfooter">
<hr />
<table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left"><a accesskey="p" href="mempfget.html">Prev</a> </td>
<td width="20%" align="center">
<a accesskey="u" href="memp.html">Up</a>
</td>
<td width="40%" align="right"> <a accesskey="n" href="mempput.html">Next</a></td>
</tr>
<tr>
<td width="40%" align="left" valign="top">DB_MPOOLFILE-&gt;get() </td>
<td width="20%" align="center">
<a accesskey="h" href="index.html">Home</a>
</td>
<td width="40%" align="right" valign="top"> DB_MPOOLFILE-&gt;put()</td>
</tr>
</table>
</div>
</body>
</html>