1<!--$Id: memp_fget.so,v 10.48 2006/09/13 14:30:54 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: DB_MPOOLFILE-&gt;get</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>DB_MPOOLFILE-&gt;get</b>
14</td>
15<td align=right>
16<a href="../api_c/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.h&gt;
23<p>
24int
25DB_MPOOLFILE-&gt;get(DB_MPOOLFILE *mpf,
26    db_pgno_t *pgnoaddr, DB_TXN * txnid, u_int32_t flags, void **pagep);
27</pre></b>
28<hr size=1 noshade>
29<b>Description: DB_MPOOLFILE-&gt;get</b>
30<p>The DB_MPOOLFILE-&gt;get method returns pages from the cache.</p>
31<p>All pages returned by DB_MPOOLFILE-&gt;get will be retained (that is,
32<i>pinned</i>), in the pool until a subsequent call to
33<a href="../api_c/memp_fput.html">DB_MPOOLFILE-&gt;put</a>.</p>
34<p>The returned page is <b>size_t</b> type aligned.</p>
35<p>Fully or partially created pages have all their bytes set to a nul byte,
36unless the <a href="../api_c/memp_set_clear_len.html">DB_MPOOLFILE-&gt;set_clear_len</a> method was called to specify other
37behavior before the file was opened.</p>
38<a name="2"><!--meow--></a>
39<p>The DB_MPOOLFILE-&gt;get method
40will return DB_PAGE_NOTFOUND if the requested page does not exist and DB_MPOOL_CREATE was
41not set.
42Unless otherwise specified, the DB_MPOOLFILE-&gt;get method
43returns a non-zero error value on failure
44and 0 on success.
45</p>
46<b>Parameters</b> <br>
47 <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
48or more of the following values:
49<br>
50<b><a name="DB_MPOOL_CREATE">DB_MPOOL_CREATE</a></b><ul compact><li>If the specified page does not exist, create it.  In this case, the
51<a href="memp_register.html#pgin">pgin</a> method, if specified, is
52called.</ul>
53<b><a name="DB_MPOOL_DIRTY">DB_MPOOL_DIRTY</a></b><ul compact><li>The page will be modified and must be written to the source file before
54being evicted from the pool.  For files open with the
55<a href="../api_c/db_open.html#DB_MULTIVERSION">DB_MULTIVERSION</a> flag set, a new copy of the page will be made
56if this is the first time the specified transaction is modifying it.</ul>
57<b><a name="DB_MPOOL_EDIT">DB_MPOOL_EDIT</a></b><ul compact><li>The page will be modified and must be written to the source file before
58being evicted from the pool.  No copy of the page will be made, regardless
59of the <a href="../api_c/db_open.html#DB_MULTIVERSION">DB_MULTIVERSION</a> setting.  This flag is only intended for
60use in situations where a transaction handle is not available, such as during
61aborts or recovery.</ul>
62<b><a name="DB_MPOOL_LAST">DB_MPOOL_LAST</a></b><ul compact><li>Return the last page of the source file, and copy its page number into
63the memory location to which <b>pgnoaddr</b> refers.</ul>
64<b><a name="DB_MPOOL_NEW">DB_MPOOL_NEW</a></b><ul compact><li>Create a new page in the file, and copy its page number into the memory
65location to which <b>pgnoaddr</b> refers.  In this case, the
66<a href="memp_register.html#pgin">pgin</a> method, if specified, is
67<b>not</b> called.</ul>
68<br>
69<p>The DB_MPOOL_CREATE, DB_MPOOL_LAST, and
70DB_MPOOL_NEW flags are mutually exclusive.</p></ul>
71 <b>pagep</b><ul compact><li>The <b>pagep</b> parameter references memory into which
72a pointer to the returned page is copied.</ul> 
73 <b>pgnoaddr</b><ul compact><li>If the <b>flags</b> parameter is set to DB_MPOOL_LAST or
74DB_MPOOL_NEW, the page number of the created page is copied
75into the memory location to which the <b>pgnoaddr</b> parameter
76refers.  Otherwise, the <b>pgnoaddr</b> parameter is the page to
77create or retrieve.
78<p><b>Page numbers begin at 0; that is, the first page in the file is page
79number 0, not page number 1.</b></p></ul>
80 <b>txnid</b><ul compact><li>If the operation is part of an application-specified
81transaction, the <b>txnid</b> parameter is a transaction handle
82returned from <a href="../api_c/txn_begin.html">DB_ENV-&gt;txn_begin</a>; otherwise NULL.  A transaction is
83required if the file is open for multiversion concurrency control by
84passing <a href="../api_c/db_open.html#DB_MULTIVERSION">DB_MULTIVERSION</a> to <a href="../api_c/memp_fopen.html">DB_MPOOLFILE-&gt;open</a> and the
85DB_MPOOL_DIRTY, DB_MPOOL_CREATE or
86DB_MPOOL_NEW flags were specified.  Otherwise it is ignored.</ul>
87<br>
88<br><b>Errors</b>
89<p>The DB_MPOOLFILE-&gt;get method
90may fail and return one of the following non-zero errors:</p>
91<br>
92<b>EACCES</b><ul compact><li>The DB_MPOOL_DIRTY or DB_MPOOL_EDIT flag was set and
93the source file was not opened for writing.</ul>
94<br>
95<br>
96<b>EAGAIN</b><ul compact><li>The page reference count has overflowed.  (This should never happen
97unless there is a bug in the application.)</ul>
98<br>
99<br>
100<b>EINVAL</b><ul compact><li>If the DB_MPOOL_NEW flag was set, and the source file was not
101opened for writing;
102more than one of DB_MPOOL_CREATE, DB_MPOOL_LAST, and
103DB_MPOOL_NEW was set.; or if an
104invalid flag value or parameter was specified.</ul>
105<br>
106<br>
107<b>DB_LOCK_DEADLOCK</b><ul compact><li>For transactions configured with <a href="../api_c/txn_begin.html#DB_TXN_SNAPSHOT">DB_TXN_SNAPSHOT</a>, the page has
108been modified since the transaction began.</ul>
109<br>
110<br>
111<b>ENOMEM</b><ul compact><li>The cache is full, and no more pages will fit in the pool.</ul>
112<br>
113<hr size=1 noshade>
114<br><b>Class</b>
115<a href="../api_c/env_class.html">DB_ENV</a>, <a href="../api_c/mempfile_class.html">DB_MPOOLFILE</a>
116<br><b>See Also</b>
117<a href="../api_c/memp_list.html">Memory Pools and Related Methods</a>
118</tt>
119<table width="100%"><tr><td><br></td><td align=right>
120<a href="../api_c/api_core.html"><img src="../images/api.gif" alt="API"></a><a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a>
121</td></tr></table>
122<p><font size=1>Copyright (c) 1996,2008 Oracle.  All rights reserved.</font>
123</body>
124</html>
125