<!--$Id: memp_fget.so,v 10.48 2006/09/13 14:30:54 mjc Exp $--> <!--Copyright (c) 1997,2007 Oracle. All rights reserved.--> <!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB: DB_MPOOLFILE->get</title> <meta name="description" content="Berkeley DB: An embedded database programmatic toolkit."> <meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++"> </head> <body bgcolor=white> <table width="100%"><tr valign=top> <td> <h3>DB_MPOOLFILE->get</h3> </td> <td align=right> <a href="../../db46-devel-4.6.21/api_c/api_core.html"><img src="../../db46-devel-4.6.21/images/api.gif" alt="API"></a> <a href="../../db46-devel-4.6.21/ref/toc.html"><img src="../../db46-devel-4.6.21/images/ref.gif" alt="Ref"></a></td> </tr></table> <hr size=1 noshade> <tt> <h3><pre> #include <db.h> <p> int DB_MPOOLFILE->get(DB_MPOOLFILE *mpf, db_pgno_t *pgnoaddr, DB_TXN * txnid, u_int32_t flags, void **pagep); </pre></h3> <hr size=1 noshade> <h3>Description: DB_MPOOLFILE->get</h3> <p>The DB_MPOOLFILE->get method returns pages from the cache.</p> <p>All pages returned by DB_MPOOLFILE->get will be retained (that is, <i>pinned</i>), in the pool until a subsequent call to <a href="../../db46-devel-4.6.21/api_c/memp_fput.html">DB_MPOOLFILE->put</a>.</p> <p>The returned page is <b>size_t</b> type aligned.</p> <p>Fully or partially created pages have all their bytes set to a nul byte, unless the <a href="../../db46-devel-4.6.21/api_c/memp_set_clear_len.html">DB_MPOOLFILE->set_clear_len</a> method was called to specify other behavior before the file was opened.</p> <a name="2"><!--meow--></a> <p>The DB_MPOOLFILE->get method will return DB_PAGE_NOTFOUND if the requested page does not exist and DB_MPOOL_CREATE was not set. Unless otherwise specified, the DB_MPOOLFILE->get method returns a non-zero error value on failure and 0 on success. </p> <h3>Parameters</h3> <dl compact> <dt><b>flags</b><dd>The <b>flags</b> parameter must be set to 0 or by bitwise inclusively <b>OR</b>'ing together one or more of the following values: <dl compact> <dt><a name="DB_MPOOL_CREATE">DB_MPOOL_CREATE</a><dd>If the specified page does not exist, create it. In this case, the <a href="memp_register.html#pgin">pgin</a> method, if specified, is called. <dt><a name="DB_MPOOL_DIRTY">DB_MPOOL_DIRTY</a><dd>The page will be modified and must be written to the source file before being evicted from the pool. For files open with the <a href="../../db46-devel-4.6.21/api_c/db_open.html#DB_MULTIVERSION">DB_MULTIVERSION</a> flag set, a new copy of the page will be made if this is the first time the specified transaction is modifying it. <dt><a name="DB_MPOOL_EDIT">DB_MPOOL_EDIT</a><dd>The page will be modified and must be written to the source file before being evicted from the pool. No copy of the page will be made, regardless of the <a href="../../db46-devel-4.6.21/api_c/db_open.html#DB_MULTIVERSION">DB_MULTIVERSION</a> setting. This flag is only intended for use in situations where a transaction handle is not available, such as during aborts or recovery. <dt><a name="DB_MPOOL_LAST">DB_MPOOL_LAST</a><dd>Return the last page of the source file, and copy its page number into the memory location to which <b>pgnoaddr</b> refers. <dt><a name="DB_MPOOL_NEW">DB_MPOOL_NEW</a><dd>Create a new page in the file, and copy its page number into the memory location to which <b>pgnoaddr</b> refers. In this case, the <a href="memp_register.html#pgin">pgin</a> method, if specified, is <b>not</b> called. </dl> <p>The DB_MPOOL_CREATE, DB_MPOOL_LAST, and DB_MPOOL_NEW flags are mutually exclusive.</p> <dt><b>pagep</b><dd>The <b>pagep</b> parameter references memory into which a pointer to the returned page is copied. <dt><b>pgnoaddr</b><dd>If the <b>flags</b> parameter is set to DB_MPOOL_LAST or DB_MPOOL_NEW, the page number of the created page is copied into the memory location to which the <b>pgnoaddr</b> parameter refers. Otherwise, the <b>pgnoaddr</b> parameter is the page to create or retrieve. <p><b>Page numbers begin at 0; that is, the first page in the file is page number 0, not page number 1.</b></p> <dt><b>txnid</b><dd>If the operation is part of an application-specified transaction, the <b>txnid</b> parameter is a transaction handle returned from <a href="../../db46-devel-4.6.21/api_c/txn_begin.html">DB_ENV->txn_begin</a>; otherwise NULL. A transaction is required if the file is open for multiversion concurrency control by passing <a href="../../db46-devel-4.6.21/api_c/db_open.html#DB_MULTIVERSION">DB_MULTIVERSION</a> to <a href="../../db46-devel-4.6.21/api_c/memp_fopen.html">DB_MPOOLFILE->open</a> and the DB_MPOOL_DIRTY, DB_MPOOL_CREATE or DB_MPOOL_NEW flags were specified. Otherwise it is ignored. </dl> <h3>Errors</h3> <p>The DB_MPOOLFILE->get method may fail and return one of the following non-zero errors:</p> <dl compact> <dt>EACCES<dd>The DB_MPOOL_DIRTY or DB_MPOOL_EDIT flag was set and the source file was not opened for writing. </dl> <dl compact> <dt>EAGAIN<dd>The page reference count has overflowed. (This should never happen unless there is a bug in the application.) </dl> <dl compact> <dt>EINVAL<dd>If the DB_MPOOL_NEW flag was set, and the source file was not opened for writing; more than one of DB_MPOOL_CREATE, DB_MPOOL_LAST, and DB_MPOOL_NEW was set.; or if an invalid flag value or parameter was specified. </dl> <dl compact> <dt>DB_LOCK_DEADLOCK<dd>For transactions configured with <a href="../../db46-devel-4.6.21/api_c/txn_begin.html#DB_TXN_SNAPSHOT">DB_TXN_SNAPSHOT</a>, the page has been modified since the transaction began. </dl> <dl compact> <dt>ENOMEM<dd>The cache is full, and no more pages will fit in the pool. </dl> <hr size=1 noshade> <h3>Class</h3> <a href="../../db46-devel-4.6.21/api_c/env_class.html">DB_ENV</a>, <a href="../../db46-devel-4.6.21/api_c/mempfile_class.html">DB_MPOOLFILE</a> <h3>See Also</h3> <a href="../../db46-devel-4.6.21/api_c/memp_list.html">Memory Pools and Related Methods</a> </tt> <table width="100%"><tr><td><br></td><td align=right> <a href="../../db46-devel-4.6.21/api_c/api_core.html"><img src="../../db46-devel-4.6.21/images/api.gif" alt="API"></a><a href="../../db46-devel-4.6.21/ref/toc.html"><img src="../../db46-devel-4.6.21/images/ref.gif" alt="Ref"></a> </td></tr></table> <p><font size=1>Copyright (c) 1996,2007 Oracle. All rights reserved.</font> </body> </html>