| 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>DbMpoolFile::get()</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 9. The DbMpoolFile Handle" /> |
| 11 | <link rel="prev" href="mempfclose.html" title="DbMpoolFile::close()" /> |
| 12 | <link rel="next" href="mempfopen.html" title="DbMpoolFile::open()" /> |
| 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">DbMpoolFile::get()</th> |
| 22 | </tr> |
| 23 | <tr> |
| 24 | <td width="20%" align="left"><a accesskey="p" href="mempfclose.html">Prev</a> </td> |
| 25 | <th width="60%" align="center">Chapter 9. |
| 26 | The DbMpoolFile Handle |
| 27 | </th> |
| 28 | <td width="20%" align="right"> <a accesskey="n" href="mempfopen.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="mempfget"></a>DbMpoolFile::get()</h2> |
| 38 | </div> |
| 39 | </div> |
| 40 | </div> |
| 41 | <pre class="programlisting">#include <db_cxx.h> |
| 42 | |
| 43 | int |
| 44 | DbMpoolFile::get(db_pgno_t *pgnoaddr, |
| 45 | DbTxn *txnid, u_int32_t flags, void **pagep);</pre> |
| 46 | <p> |
| 47 | The <code class="methodname">DbMpoolFile::get()</code> method returns pages from the cache. |
| 48 | </p> |
| 49 | <p> |
| 50 | All pages returned by <code class="methodname">DbMpoolFile::get()</code> will be retained (that is, |
| 51 | <span class="emphasis"><em>latched</em></span>) in the cache until a subsequent call to |
| 52 | <a class="xref" href="mempput.html" title="DbMpoolFile::put()">DbMpoolFile::put()</a>. |
| 53 | There is no deadlock detection among latches so care must be taken in the application if the DB_MPOOL_DIRTY |
| 54 | or DB_MPOOL_EDIT flags are used as these get exlusive latches on the pages. |
| 55 | </p> |
| 56 | <p> |
| 57 | The returned page is <span class="bold"><strong>size_t</strong></span> type |
| 58 | aligned. |
| 59 | </p> |
| 60 | <p> |
| 61 | Fully or partially created pages have all their bytes set to a nul |
| 62 | byte, unless the |
| 63 | <a class="xref" href="mempset_clear_len.html" title="DbMpoolFile::set_clear_len()">DbMpoolFile::set_clear_len()</a> |
| 64 | method was called to specify other behavior before the file was |
| 65 | opened. |
| 66 | </p> |
| 67 | <p><a id="fget_DB_PAGE_NOTFOUND"></a> |
| 68 | The <code class="methodname">DbMpoolFile::get()</code> method will return |
| 69 | <code class="literal">DB_PAGE_NOTFOUND</code> if the requested page does not exist and DB_MPOOL_CREATE |
| 70 | was not set. Unless otherwise specified, the <code class="methodname">DbMpoolFile::get()</code> |
| 71 | <span> |
| 72 | |
| 73 | <span> |
| 74 | method either returns a non-zero error value or throws an |
| 75 | exception that encapsulates a non-zero error value on |
| 76 | failure, and returns 0 on success. |
| 77 | </span> |
| 78 | </span> |
| 79 | </p> |
| 80 | <div class="sect2" lang="en" xml:lang="en"> |
| 81 | <div class="titlepage"> |
| 82 | <div> |
| 83 | <div> |
| 84 | <h3 class="title"><a id="idp8879200"></a>Parameters</h3> |
| 85 | </div> |
| 86 | </div> |
| 87 | </div> |
| 88 | <div class="sect3" lang="en" xml:lang="en"> |
| 89 | <div class="titlepage"> |
| 90 | <div> |
| 91 | <div> |
| 92 | <h4 class="title"><a id="idp8878552"></a>flags</h4> |
| 93 | </div> |
| 94 | </div> |
| 95 | </div> |
| 96 | <p> |
| 97 | The <span class="bold"><strong>flags</strong></span> parameter must be set to 0 |
| 98 | or by bitwise inclusively <span class="bold"><strong>OR</strong></span>'ing |
| 99 | together one or more of the following values: |
| 100 | </p> |
| 101 | <div class="itemizedlist"> |
| 102 | <ul type="disc"> |
| 103 | <li> |
| 104 | <p><a id="mpoolfget_DB_MPOOL_CREATE"></a> |
| 105 | <code class="literal">DB_MPOOL_CREATE</code> |
| 106 | </p> |
| 107 | <p> |
| 108 | If the specified page does not exist, create it. In this case, the |
| 109 | <a class="link" href="mempregister.html" title="DbEnv::memp_register()">pgin</a> method, if |
| 110 | specified, is called. |
| 111 | </p> |
| 112 | </li> |
| 113 | <li> |
| 114 | <p><a id="fget_DB_MPOOL_DIRTY"></a> |
| 115 | <code class="literal">DB_MPOOL_DIRTY</code> |
| 116 | </p> |
| 117 | <p> |
| 118 | The page will be modified and must be written to the source file |
| 119 | before being evicted from the cache. For files open with the |
| 120 | <a class="link" href="dbopen.html#dbopen_DB_MULTIVERSION">DB_MULTIVERSION</a> |
| 121 | flag set, a new copy of the page will be made if this is the first |
| 122 | time the specified transaction is modifying it. |
| 123 | A page fetched with the <code class="literal">DB_MPOOL_DIRTY</code> flag will be |
| 124 | <span class="bold"><strong>exclusively latched</strong></span> until |
| 125 | a subsequent call to <a class="xref" href="mempput.html" title="DbMpoolFile::put()">DbMpoolFile::put()</a>. |
| 126 | </p> |
| 127 | </li> |
| 128 | <li> |
| 129 | <p><a id="fget_DB_MPOOL_EDIT"></a> |
| 130 | <code class="literal">DB_MPOOL_EDIT</code> |
| 131 | </p> |
| 132 | <p> |
| 133 | The page will be modified and must be written to the source file |
| 134 | before being evicted from the cache. No copy of the page will be made, |
| 135 | regardless of the |
| 136 | <a class="link" href="dbopen.html#dbopen_DB_MULTIVERSION">DB_MULTIVERSION</a> |
| 137 | setting. This flag is only intended for use in situations where a |
| 138 | transaction handle is not available, such as during aborts or |
| 139 | recovery. |
| 140 | A page fetched with the <code class="literal">DB_MPOOL_EDIT</code> flag will be |
| 141 | <span class="bold"><strong>exclusively latched</strong></span> until |
| 142 | a subsequent call to <a class="xref" href="mempput.html" title="DbMpoolFile::put()">DbMpoolFile::put()</a>. |
| 143 | </p> |
| 144 | </li> |
| 145 | <li> |
| 146 | <p><a id="fget_DB_MPOOL_LAST"></a> |
| 147 | <code class="literal">DB_MPOOL_LAST</code> |
| 148 | </p> |
| 149 | <p> |
| 150 | Return the last page of the source file, and copy its page number into |
| 151 | the memory location to which <span class="bold"><strong>pgnoaddr</strong></span> |
| 152 | refers. |
| 153 | </p> |
| 154 | </li> |
| 155 | <li> |
| 156 | <p><a id="mpoolfget_DB_MPOOL_NEW"></a> |
| 157 | <code class="literal">DB_MPOOL_NEW</code> |
| 158 | </p> |
| 159 | <p> |
| 160 | Create a new page in the file, and copy its page number into the |
| 161 | memory location to which <span class="bold"><strong>pgnoaddr</strong></span> |
| 162 | refers. In this case, the <code class="literal">pgin_fcn</code> callback, if specified on |
| 163 | <a class="xref" href="mempregister.html" title="DbEnv::memp_register()">DbEnv::memp_register()</a>, is |
| 164 | <span class="bold"><strong>not</strong></span> called. |
| 165 | </p> |
| 166 | </li> |
| 167 | </ul> |
| 168 | </div> |
| 169 | <p> |
| 170 | The <code class="literal">DB_MPOOL_CREATE</code>, <code class="literal">DB_MPOOL_LAST</code>, and |
| 171 | <code class="literal">DB_MPOOL_NEW</code> flags are mutually exclusive. |
| 172 | </p> |
| 173 | </div> |
| 174 | <div class="sect3" lang="en" xml:lang="en"> |
| 175 | <div class="titlepage"> |
| 176 | <div> |
| 177 | <div> |
| 178 | <h4 class="title"><a id="idp8884496"></a>pagep</h4> |
| 179 | </div> |
| 180 | </div> |
| 181 | </div> |
| 182 | <p> |
| 183 | The <span class="bold"><strong>pagep</strong></span> parameter references memory |
| 184 | into which a pointer to the returned page is copied. |
| 185 | </p> |
| 186 | </div> |
| 187 | <div class="sect3" lang="en" xml:lang="en"> |
| 188 | <div class="titlepage"> |
| 189 | <div> |
| 190 | <div> |
| 191 | <h4 class="title"><a id="idp8894544"></a>pgnoaddr</h4> |
| 192 | </div> |
| 193 | </div> |
| 194 | </div> |
| 195 | <p> |
| 196 | If the <span class="bold"><strong>flags</strong></span> parameter is set to |
| 197 | <code class="literal">DB_MPOOL_LAST</code> or <code class="literal">DB_MPOOL_NEW</code>, the |
| 198 | page number of the created page is copied into the memory location to |
| 199 | which the <span class="bold"><strong>pgnoaddr</strong></span> parameter refers. |
| 200 | Otherwise, the <span class="bold"><strong>pgnoaddr</strong></span> parameter is the |
| 201 | page to create or retrieve. |
| 202 | </p> |
| 203 | <div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"> |
| 204 | <h3 class="title">Note</h3> |
| 205 | <p> |
| 206 | Page numbers begin at 0; that is, the first page in the file is page number 0, |
| 207 | not page number 1. |
| 208 | </p> |
| 209 | </div> |
| 210 | </div> |
| 211 | <div class="sect3" lang="en" xml:lang="en"> |
| 212 | <div class="titlepage"> |
| 213 | <div> |
| 214 | <div> |
| 215 | <h4 class="title"><a id="idp8896304"></a>txnid</h4> |
| 216 | </div> |
| 217 | </div> |
| 218 | </div> |
| 219 | <p> |
| 220 | If the operation is part of an application-specified transaction, the |
| 221 | <span class="bold"><strong>txnid</strong></span> parameter is a transaction |
| 222 | handle returned from <a class="xref" href="txnbegin.html" title="DbEnv::txn_begin()">DbEnv::txn_begin()</a>; |
| 223 | otherwise NULL. A transaction is required if the file is open for multiversion |
| 224 | concurrency control by passing |
| 225 | <a class="link" href="dbopen.html#dbopen_DB_MULTIVERSION">DB_MULTIVERSION</a> |
| 226 | to |
| 227 | <a class="xref" href="mempfopen.html" title="DbMpoolFile::open()">DbMpoolFile::open()</a> |
| 228 | and the DB_MPOOL_DIRTY, DB_MPOOL_CREATE or DB_MPOOL_NEW flags were |
| 229 | specified. Otherwise it is ignored. |
| 230 | </p> |
| 231 | </div> |
| 232 | </div> |
| 233 | <div class="sect2" lang="en" xml:lang="en"> |
| 234 | <div class="titlepage"> |
| 235 | <div> |
| 236 | <div> |
| 237 | <h3 class="title"><a id="idp8897384"></a>Errors</h3> |
| 238 | </div> |
| 239 | </div> |
| 240 | </div> |
| 241 | <p> |
| 242 | The <code class="methodname">DbMpoolFile::get()</code> <span> |
| 243 | |
| 244 | <span> |
| 245 | method may fail and throw a <a class="link" href="dbexception.html" title="Chapter 6. The DbException Class">DbException</a> |
| 246 | exception, encapsulating one of the following non-zero errors, or return one |
| 247 | of the following non-zero errors: |
| 248 | </span> |
| 249 | </span> |
| 250 | </p> |
| 251 | <div class="sect3" lang="en" xml:lang="en"> |
| 252 | <div class="titlepage"> |
| 253 | <div> |
| 254 | <div> |
| 255 | <h4 class="title"><a id="idp8891952"></a>EACCES</h4> |
| 256 | </div> |
| 257 | </div> |
| 258 | </div> |
| 259 | <p> |
| 260 | The <code class="literal">DB_MPOOL_DIRTY</code> or |
| 261 | <code class="literal">DB_MPOOL_EDIT</code> flag was set and the source file was |
| 262 | not opened for writing. |
| 263 | </p> |
| 264 | </div> |
| 265 | <div class="sect3" lang="en" xml:lang="en"> |
| 266 | <div class="titlepage"> |
| 267 | <div> |
| 268 | <div> |
| 269 | <h4 class="title"><a id="idp8887224"></a>EAGAIN</h4> |
| 270 | </div> |
| 271 | </div> |
| 272 | </div> |
| 273 | <p> |
| 274 | The page reference count has overflowed. (This should never happen |
| 275 | unless there is a bug in the application.) |
| 276 | </p> |
| 277 | </div> |
| 278 | <div class="sect3" lang="en" xml:lang="en"> |
| 279 | <div class="titlepage"> |
| 280 | <div> |
| 281 | <div> |
| 282 | <h4 class="title"><a id="idp8909328"></a>EINVAL</h4> |
| 283 | </div> |
| 284 | </div> |
| 285 | </div> |
| 286 | <p> |
| 287 | If the <code class="literal">DB_MPOOL_NEW</code> flag was set, and the source |
| 288 | file was not opened for writing; more than one of |
| 289 | <code class="literal">DB_MPOOL_CREATE</code>, <code class="literal">DB_MPOOL_LAST</code>, |
| 290 | and <code class="literal">DB_MPOOL_NEW</code> was set; or if an invalid flag |
| 291 | value or parameter was specified. |
| 292 | </p> |
| 293 | </div> |
| 294 | <div class="sect3" lang="en" xml:lang="en"> |
| 295 | <div class="titlepage"> |
| 296 | <div> |
| 297 | <div> |
| 298 | <h4 class="title"><a id="idp8879632"></a>DB_LOCK_DEADLOCK</h4> |
| 299 | </div> |
| 300 | </div> |
| 301 | </div> |
| 302 | <p> |
| 303 | For transactions configured with |
| 304 | <a class="link" href="txnbegin.html#txnbegin_DB_TXN_SNAPSHOT">DB_TXN_SNAPSHOT</a>, |
| 305 | the page has been modified since the transaction began. |
| 306 | </p> |
| 307 | </div> |
| 308 | <div class="sect3" lang="en" xml:lang="en"> |
| 309 | <div class="titlepage"> |
| 310 | <div> |
| 311 | <div> |
| 312 | <h4 class="title"><a id="idp8881128"></a>ENOMEM</h4> |
| 313 | </div> |
| 314 | </div> |
| 315 | </div> |
| 316 | <p> |
| 317 | The cache is full, and no more pages will fit in the cache. |
| 318 | </p> |
| 319 | </div> |
| 320 | </div> |
| 321 | <div class="sect2" lang="en" xml:lang="en"> |
| 322 | <div class="titlepage"> |
| 323 | <div> |
| 324 | <div> |
| 325 | <h3 class="title"><a id="idp8887704"></a>Class</h3> |
| 326 | </div> |
| 327 | </div> |
| 328 | </div> |
| 329 | <p> |
| 330 | <a class="link" href="env.html" title="Chapter 5. The DbEnv Handle">DbEnv</a>, <a class="link" href="memp.html" title="Chapter 9. The DbMpoolFile Handle">DbMpoolFile</a> |
| 331 | </p> |
| 332 | </div> |
| 333 | <div class="sect2" lang="en" xml:lang="en"> |
| 334 | <div class="titlepage"> |
| 335 | <div> |
| 336 | <div> |
| 337 | <h3 class="title"><a id="idp8893784"></a>See Also</h3> |
| 338 | </div> |
| 339 | </div> |
| 340 | </div> |
| 341 | <p> |
| 342 | <a class="xref" href="memp.html#memplist" title="Memory Pools and Related Methods">Memory Pools and Related Methods</a> |
| 343 | </p> |
| 344 | </div> |
| 345 | </div> |
| 346 | <div class="navfooter"> |
| 347 | <hr /> |
| 348 | <table width="100%" summary="Navigation footer"> |
| 349 | <tr> |
| 350 | <td width="40%" align="left"><a accesskey="p" href="mempfclose.html">Prev</a> </td> |
| 351 | <td width="20%" align="center"> |
| 352 | <a accesskey="u" href="memp.html">Up</a> |
| 353 | </td> |
| 354 | <td width="40%" align="right"> <a accesskey="n" href="mempfopen.html">Next</a></td> |
| 355 | </tr> |
| 356 | <tr> |
| 357 | <td width="40%" align="left" valign="top">DbMpoolFile::close() </td> |
| 358 | <td width="20%" align="center"> |
| 359 | <a accesskey="h" href="index.html">Home</a> |
| 360 | </td> |
| 361 | <td width="40%" align="right" valign="top"> DbMpoolFile::open()</td> |
| 362 | </tr> |
| 363 | </table> |
| 364 | </div> |
| 365 | </body> |
| 366 | </html> |