Debian Codegraph @

docs/api_reference/C/mempfget.html

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