Google

DB_MPOOLFILE->get

APIRef

#include <db.h>

int DB_MPOOLFILE->get(DB_MPOOLFILE *mpf, db_pgno_t *pgnoaddr, u_int32_t flags, void **pagep);

Description

The DB_MPOOLFILE->get function copies a pointer to the page with the page number specified by pgnoaddr, from the source file in the DB_MPOOLFILE, into the memory location to which pagep refers. If the page does not exist or cannot be retrieved, DB_MPOOLFILE->get will fail.

Page numbers begin at 0; that is, the first page in the file is page number 0, not page number 1.

The returned page is size_t type aligned.

The flags value must be set to 0 or by bitwise inclusively OR'ing together one or more of the following values:

DB_MPOOL_CREATE
If the specified page does not exist, create it. In this case, the pgin function, if specified, is called.

DB_MPOOL_LAST
Return the last page of the source file, and copy its page number into the memory location to which pgnoaddr refers.

DB_MPOOL_NEW
Create a new page in the file, and copy its page number into the memory location to which pgnoaddr refers. In this case, the pgin function, if specified, is not called.

The DB_MPOOL_CREATE, DB_MPOOL_LAST, and DB_MPOOL_NEW flags are mutually exclusive.

Fully or partially created pages have all their bytes set to a nul byte, unless the DB_MPOOLFILE->set_clear_len function was called to specify other behavior before the file was opened.

All pages returned by DB_MPOOLFILE->get will be retained (that is, pinned), in the pool until a subsequent call to DB_MPOOLFILE->put.

The DB_MPOOLFILE->get function returns a non-zero error value on failure, 0 on success, and returns DB_PAGE_NOTFOUND if the requested page does not exist and DB_MPOOL_CREATE was not set.

Errors

The DB_MPOOLFILE->get function may fail and return a non-zero error for the following conditions:

EAGAIN
The page reference count has overflowed. (This should never happen unless there's a bug in the application.)

EINVAL
An invalid flag value or parameter was specified.

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.

ENOMEM
The cache is full, and no more pages will fit in the pool.

The DB_MPOOLFILE->get function may fail and return a non-zero error for errors specified for other Berkeley DB and C library or system functions. If a catastrophic error has occurred, the DB_MPOOLFILE->get function may fail and return DB_RUNRECOVERY, in which case all subsequent Berkeley DB calls will fail in the same way.

See Also

DB_ENV->set_cachesize, DB_ENV->set_mp_mmapsize, DB_ENV->memp_fcreate, DB_MPOOLFILE->close, DB_MPOOLFILE->get, DB_MPOOLFILE->open, DB_MPOOLFILE->put, DB_MPOOLFILE->set, DB_MPOOLFILE->sync, DB_ENV->memp_register, DB_MPOOLFILE->set_clear_len, DB_MPOOLFILE->set_fileid, DB_MPOOLFILE->set_ftype, DB_MPOOLFILE->set_lsn_offset, DB_MPOOLFILE->set_pgcookie, DB_ENV->memp_stat, DB_ENV->memp_sync, and DB_ENV->memp_trickle.

APIRef

Copyright Sleepycat Software