| 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_MPOOLFILE->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="memp.html" title="Chapter 8. The DB_MPOOLFILE Handle" /> |
| 11 | <link rel="prev" href="mempfget.html" title="DB_MPOOLFILE->get()" /> |
| 12 | <link rel="next" href="mempput.html" title="DB_MPOOLFILE->put()" /> |
| 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_MPOOLFILE->open()</th> |
| 22 | </tr> |
| 23 | <tr> |
| 24 | <td width="20%" align="left"><a accesskey="p" href="mempfget.html">Prev</a> </td> |
| 25 | <th width="60%" align="center">Chapter 8. |
| 26 | The DB_MPOOLFILE Handle |
| 27 | </th> |
| 28 | <td width="20%" align="right"> <a accesskey="n" href="mempput.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="mempfopen"></a>DB_MPOOLFILE->open()</h2> |
| 38 | </div> |
| 39 | </div> |
| 40 | </div> |
| 41 | <pre class="programlisting">#include <db.h> |
| 42 | |
| 43 | int |
| 44 | DB_MPOOLFILE->open(DB_MPOOLFILE *mpf, |
| 45 | char *file, u_int32_t flags, int mode, size_t pagesize); </pre> |
| 46 | <p> |
| 47 | The <code class="methodname">DB_MPOOLFILE->open()</code> method opens a file in the in-memory cache. |
| 48 | </p> |
| 49 | <p> |
| 50 | The <code class="methodname">DB_MPOOLFILE->open()</code> <span> |
| 51 | <span> |
| 52 | method returns a non-zero error value on failure and 0 on success. |
| 53 | </span> |
| 54 | |
| 55 | </span> |
| 56 | </p> |
| 57 | <div class="sect2" lang="en" xml:lang="en"> |
| 58 | <div class="titlepage"> |
| 59 | <div> |
| 60 | <div> |
| 61 | <h3 class="title"><a id="idp53449752"></a>Parameters</h3> |
| 62 | </div> |
| 63 | </div> |
| 64 | </div> |
| 65 | <div class="sect3" lang="en" xml:lang="en"> |
| 66 | <div class="titlepage"> |
| 67 | <div> |
| 68 | <div> |
| 69 | <h4 class="title"><a id="idp53457136"></a>file</h4> |
| 70 | </div> |
| 71 | </div> |
| 72 | </div> |
| 73 | <p> |
| 74 | The <span class="bold"><strong>file</strong></span> parameter is the name of the |
| 75 | file to be opened. If <span class="bold"><strong>file</strong></span> is NULL, |
| 76 | a private temporary file is created that cannot be shared with any |
| 77 | other process (although it may be shared with other threads of control |
| 78 | in the same process). |
| 79 | </p> |
| 80 | <p> |
| 81 | When using a Unicode build on Windows (the default), the |
| 82 | <span class="bold"><strong>file</strong></span> argument will |
| 83 | be interpreted as a UTF-8 string, which is equivalent to ASCII for Latin |
| 84 | characters. |
| 85 | </p> |
| 86 | </div> |
| 87 | <div class="sect3" lang="en" xml:lang="en"> |
| 88 | <div class="titlepage"> |
| 89 | <div> |
| 90 | <div> |
| 91 | <h4 class="title"><a id="idp53431536"></a>flags</h4> |
| 92 | </div> |
| 93 | </div> |
| 94 | </div> |
| 95 | <p> |
| 96 | The <span class="bold"><strong>flags</strong></span> parameter must be set to zero or |
| 97 | by bitwise inclusively <span class="bold"><strong>OR</strong></span>'ing together one |
| 98 | or more of the following values: |
| 99 | </p> |
| 100 | <div class="itemizedlist"> |
| 101 | <ul type="disc"> |
| 102 | <li> |
| 103 | <p><a id="mempopen_DB_CREATE"></a> |
| 104 | <code class="literal">DB_CREATE</code> |
| 105 | </p> |
| 106 | <p> |
| 107 | Create any underlying files, as necessary. If the database do not already exist |
| 108 | and the <code class="literal">DB_CREATE</code> flag is not specified, the |
| 109 | call will fail. |
| 110 | </p> |
| 111 | </li> |
| 112 | <li> |
| 113 | <p><a id="mempopen_DB_EXCL"></a> |
| 114 | <code class="literal">DB_DIRECT</code> |
| 115 | </p> |
| 116 | <p> |
| 117 | If set and supported by the system, turn off system buffering of the file to |
| 118 | avoid double caching. |
| 119 | </p> |
| 120 | </li> |
| 121 | <li> |
| 122 | <p><a id="mempopen_DB_MULTIVERSION"></a> |
| 123 | <code class="literal">DB_MULTIVERSION</code> |
| 124 | </p> |
| 125 | <p> |
| 126 | Open the file with support for |
| 127 | <a href="../../programmer_reference/transapp_read.html" class="olink">multiversion concurrency control</a>. |
| 128 | Calls to <a class="xref" href="mempfget.html" title="DB_MPOOLFILE->get()">DB_MPOOLFILE->get()</a> |
| 129 | with dirty pages will cause copies to be made in the cache. |
| 130 | </p> |
| 131 | </li> |
| 132 | <li> |
| 133 | <p><a id="mempopen_DB_NOMMAP"></a> |
| 134 | <code class="literal">DB_NOMMAP</code> |
| 135 | </p> |
| 136 | <p> |
| 137 | Always copy this file into the local cache instead of potentially mapping it |
| 138 | into process memory (see the |
| 139 | <a class="xref" href="envset_mp_mmapsize.html" title="DB_ENV->set_mp_mmapsize()">DB_ENV->set_mp_mmapsize()</a> |
| 140 | method for further information). |
| 141 | </p> |
| 142 | </li> |
| 143 | <li> |
| 144 | <p><a id="mempopen_DB_ODDFILESIZE"></a> |
| 145 | <code class="literal">DB_ODDFILESIZE</code> |
| 146 | </p> |
| 147 | <p> |
| 148 | Attempts to open files which are not a multiple of the page size in length will |
| 149 | fail, by default. If the DB_ODDFILESIZE flag is set, any partial page at the end |
| 150 | of the file will be ignored and the open will proceed. |
| 151 | </p> |
| 152 | </li> |
| 153 | <li> |
| 154 | <p><a id="mempopen_DB_RDONLY"></a> |
| 155 | <code class="literal">DB_RDONLY</code> |
| 156 | </p> |
| 157 | <p> |
| 158 | Open any underlying files for reading only. Any attempt to modify |
| 159 | the file using the memory pool (cache) functions will fail, regardless of the actual |
| 160 | permissions of the file. |
| 161 | </p> |
| 162 | </li> |
| 163 | </ul> |
| 164 | </div> |
| 165 | </div> |
| 166 | <div class="sect3" lang="en" xml:lang="en"> |
| 167 | <div class="titlepage"> |
| 168 | <div> |
| 169 | <div> |
| 170 | <h4 class="title"><a id="idp53474424"></a>mode</h4> |
| 171 | </div> |
| 172 | </div> |
| 173 | </div> |
| 174 | <p> |
| 175 | On Windows systems, the mode parameter is ignored. |
| 176 | </p> |
| 177 | <p> |
| 178 | On UNIX systems or in IEEE/ANSI Std 1003.1 (POSIX) environments, files |
| 179 | created by <code class="methodname">DB_MPOOLFILE->open()</code> are created with mode |
| 180 | <span class="bold"><strong>mode</strong></span> (as described in <span class="bold"><strong>chmod</strong></span>(2)) and modified by the process' umask |
| 181 | value at the time of creation (see <span class="bold"><strong>umask</strong></span>(2)). Created files are owned by the |
| 182 | process owner; the group ownership of created files is based on the system |
| 183 | and directory defaults, and is not further specified by Berkeley DB. System |
| 184 | shared memory segments created by <code class="methodname">DB_MPOOLFILE->open()</code> are |
| 185 | created with mode <span class="bold"><strong>mode</strong></span>, unmodified by the |
| 186 | process' umask value. If <span class="bold"><strong>mode</strong></span> is 0, |
| 187 | <code class="methodname">DB_MPOOLFILE->open()</code> will use a default mode of readable |
| 188 | and writable by both owner and group. |
| 189 | </p> |
| 190 | </div> |
| 191 | <div class="sect3" lang="en" xml:lang="en"> |
| 192 | <div class="titlepage"> |
| 193 | <div> |
| 194 | <div> |
| 195 | <h4 class="title"><a id="idp53463392"></a>pagesize</h4> |
| 196 | </div> |
| 197 | </div> |
| 198 | </div> |
| 199 | <p> |
| 200 | The <span class="bold"><strong>pagesize</strong></span> parameter is the size, |
| 201 | in bytes, of the unit of transfer between the application and the |
| 202 | cache, although it is not necessarily the unit of transfer between the |
| 203 | cache and the underlying filesystem. |
| 204 | </p> |
| 205 | </div> |
| 206 | </div> |
| 207 | <div class="sect2" lang="en" xml:lang="en"> |
| 208 | <div class="titlepage"> |
| 209 | <div> |
| 210 | <div> |
| 211 | <h3 class="title"><a id="idp53420144"></a>Errors</h3> |
| 212 | </div> |
| 213 | </div> |
| 214 | </div> |
| 215 | <p> |
| 216 | The <code class="methodname">DB_MPOOLFILE->open()</code> <span> |
| 217 | <span> |
| 218 | method may fail and return one of the following non-zero errors: |
| 219 | </span> |
| 220 | |
| 221 | </span> |
| 222 | </p> |
| 223 | <div class="sect3" lang="en" xml:lang="en"> |
| 224 | <div class="titlepage"> |
| 225 | <div> |
| 226 | <div> |
| 227 | <h4 class="title"><a id="idp53470184"></a>EINVAL</h4> |
| 228 | </div> |
| 229 | </div> |
| 230 | </div> |
| 231 | <p> |
| 232 | 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 |
| 233 | was entered into the cache, or the length of the file is not zero or a |
| 234 | multiple of the <span class="bold"><strong>pagesize</strong></span>; the |
| 235 | DB_RDONLY flag was specified for an in-memory cache; or if an invalid |
| 236 | flag value or parameter was specified. |
| 237 | </p> |
| 238 | </div> |
| 239 | <div class="sect3" lang="en" xml:lang="en"> |
| 240 | <div class="titlepage"> |
| 241 | <div> |
| 242 | <div> |
| 243 | <h4 class="title"><a id="idp53471400"></a>ENOMEM</h4> |
| 244 | </div> |
| 245 | </div> |
| 246 | </div> |
| 247 | <p> |
| 248 | The maximum number of open files has been reached. |
| 249 | </p> |
| 250 | </div> |
| 251 | </div> |
| 252 | <div class="sect2" lang="en" xml:lang="en"> |
| 253 | <div class="titlepage"> |
| 254 | <div> |
| 255 | <div> |
| 256 | <h3 class="title"><a id="idp53467328"></a>Class</h3> |
| 257 | </div> |
| 258 | </div> |
| 259 | </div> |
| 260 | <p> |
| 261 | <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> |
| 262 | </p> |
| 263 | </div> |
| 264 | <div class="sect2" lang="en" xml:lang="en"> |
| 265 | <div class="titlepage"> |
| 266 | <div> |
| 267 | <div> |
| 268 | <h3 class="title"><a id="idp53472480"></a>See Also</h3> |
| 269 | </div> |
| 270 | </div> |
| 271 | </div> |
| 272 | <p> |
| 273 | <a class="xref" href="memp.html#memplist" title="Memory Pools and Related Methods">Memory Pools and Related Methods</a> |
| 274 | </p> |
| 275 | </div> |
| 276 | </div> |
| 277 | <div class="navfooter"> |
| 278 | <hr /> |
| 279 | <table width="100%" summary="Navigation footer"> |
| 280 | <tr> |
| 281 | <td width="40%" align="left"><a accesskey="p" href="mempfget.html">Prev</a> </td> |
| 282 | <td width="20%" align="center"> |
| 283 | <a accesskey="u" href="memp.html">Up</a> |
| 284 | </td> |
| 285 | <td width="40%" align="right"> <a accesskey="n" href="mempput.html">Next</a></td> |
| 286 | </tr> |
| 287 | <tr> |
| 288 | <td width="40%" align="left" valign="top">DB_MPOOLFILE->get() </td> |
| 289 | <td width="20%" align="center"> |
| 290 | <a accesskey="h" href="index.html">Home</a> |
| 291 | </td> |
| 292 | <td width="40%" align="right" valign="top"> DB_MPOOLFILE->put()</td> |
| 293 | </tr> |
| 294 | </table> |
| 295 | </div> |
| 296 | </body> |
| 297 | </html> |