<!--$Id: memp_fget.so,v 10.48 2006/09/13 14:30:54 mjc Exp $--> <!--Copyright (c) 1997,2008 Oracle. All rights reserved.--> <!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB: DbMpoolFile::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> <b>DbMpoolFile::get</b> </td> <td align=right> <a href="../api_cxx/api_core.html"><img src="../images/api.gif" alt="API"></a> <a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a></td> </tr></table> <hr size=1 noshade> <tt> <b><pre> #include <db_cxx.h> <p> int DbMpoolFile::get(db_pgno_t *pgnoaddr, DbTxn *txnid, u_int32_t flags, void **pagep); </pre></b> <hr size=1 noshade> <b>Description: DbMpoolFile::get</b> <p>The DbMpoolFile::get method returns pages from the cache.</p> <p>All pages returned by DbMpoolFile::get will be retained (that is, <i>pinned</i>), in the pool until a subsequent call to <a href="../api_cxx/memp_fput.html">DbMpoolFile::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="../api_cxx/memp_set_clear_len.html">DbMpoolFile::set_clear_len</a> method was called to specify other behavior before the file was opened.</p> <a name="2"><!--meow--></a> <p>The DbMpoolFile::get method will either return DB_PAGE_NOTFOUND or throw an exception that encapsulates DB_PAGE_NOTFOUND if the requested page does not exist and DB_MPOOL_CREATE was not set. Unless otherwise specified, the DbMpoolFile::get method either returns a non-zero error value or throws an exception that encapsulates a non-zero error value on failure, and returns 0 on success. </p> <b>Parameters</b> <br> <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 or more of the following values: <br> <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 <a href="memp_register.html#pgin">pgin</a> method, if specified, is called.</ul> <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 being evicted from the pool. For files open with the <a href="../api_cxx/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.</ul> <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 being evicted from the pool. No copy of the page will be made, regardless of the <a href="../api_cxx/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.</ul> <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 the memory location to which <b>pgnoaddr</b> refers.</ul> <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 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.</ul> <br> <p>The DB_MPOOL_CREATE, DB_MPOOL_LAST, and DB_MPOOL_NEW flags are mutually exclusive.</p></ul> <b>pagep</b><ul compact><li>The <b>pagep</b> parameter references memory into which a pointer to the returned page is copied.</ul> <b>pgnoaddr</b><ul compact><li>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></ul> <b>txnid</b><ul compact><li>If the operation is part of an application-specified transaction, the <b>txnid</b> parameter is a transaction handle returned from <a href="../api_cxx/txn_begin.html">DbEnv::txn_begin</a>; otherwise NULL. A transaction is required if the file is open for multiversion concurrency control by passing <a href="../api_cxx/db_open.html#DB_MULTIVERSION">DB_MULTIVERSION</a> to <a href="../api_cxx/memp_fopen.html">DbMpoolFile::open</a> and the DB_MPOOL_DIRTY, DB_MPOOL_CREATE or DB_MPOOL_NEW flags were specified. Otherwise it is ignored.</ul> <br> <br><b>Errors</b> <p>The DbMpoolFile::get method may fail and throw <a href="../api_cxx/except_class.html">DbException</a>, encapsulating one of the following non-zero errors, or return one of the following non-zero errors:</p> <br> <b>EACCES</b><ul compact><li>The DB_MPOOL_DIRTY or DB_MPOOL_EDIT flag was set and the source file was not opened for writing.</ul> <br> <br> <b>EAGAIN</b><ul compact><li>The page reference count has overflowed. (This should never happen unless there is a bug in the application.)</ul> <br> <br> <b>EINVAL</b><ul compact><li>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.</ul> <br> <br> <b>DB_LOCK_DEADLOCK</b><ul compact><li>For transactions configured with <a href="../api_cxx/txn_begin.html#DB_TXN_SNAPSHOT">DB_TXN_SNAPSHOT</a>, the page has been modified since the transaction began.</ul> <br> <p>If the cache is full, and no more pages will fit in the pool, the DbMpoolFile::get method will fail and either return ENOMEM or throw a DbMemoryException.</p> <hr size=1 noshade> <br><b>Class</b> <a href="../api_cxx/env_class.html">DbEnv</a>, <a href="../api_cxx/mempfile_class.html">DbMpoolFile</a> <br><b>See Also</b> <a href="../api_cxx/memp_list.html">Memory Pools and Related Methods</a> </tt> <table width="100%"><tr><td><br></td><td align=right> <a href="../api_cxx/api_core.html"><img src="../images/api.gif" alt="API"></a><a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a> </td></tr></table> <p><font size=1>Copyright (c) 1996,2008 Oracle. All rights reserved.</font> </body> </html>