#define DB_user_BEGIN 10000
#define DB_debug_FLAG 0x80000000
ENV *env; /* Environment */
DB_FH *fhp; /* File handle. */
DB_LSN lsn; /* Cursor: LSN */
u_int32_t len; /* Cursor: record length */
u_int32_t prev; /* Cursor: previous record's offset */
DBT dbt; /* Return DBT. */
DB_LSN p_lsn; /* Persist LSN. */
u_int32_t p_version; /* Persist version. */
u_int8_t *bp; /* Allocated read buffer. */
u_int32_t bp_size; /* Read buffer length in bytes. */
u_int32_t bp_rlen; /* Read buffer valid data length. */
DB_LSN bp_lsn; /* Read buffer first byte LSN. */
u_int32_t bp_maxrec; /* Max record length in the log file. */
/* DB_LOGC PUBLIC HANDLE LIST BEGIN */
int (*close) __P((DB_LOGC *, u_int32_t));
int (*get) __P((DB_LOGC *, DB_LSN *, DBT *, u_int32_t));
int (*version) __P((DB_LOGC *, u_int32_t *, u_int32_t));
/* DB_LOGC PUBLIC HANDLE LIST END */
#define DB_LOG_DISK 0x01 /* Log record came from disk. */
#define DB_LOG_LOCKED 0x02 /* Log region already locked */
#define DB_LOG_SILENT_ERR 0x04 /* Turn-off error messages. */
/* Log statistics structure. */
struct __db_log_stat { /* SHARED */
u_int32_t st_magic; /* Log file magic number. */
u_int32_t st_version; /* Log file version number. */
int32_t st_mode; /* Log file permissions mode. */
u_int32_t st_lg_bsize; /* Log buffer size. */
u_int32_t st_lg_size; /* Log file size. */
u_int32_t st_wc_bytes; /* Bytes to log since checkpoint. */
u_int32_t st_wc_mbytes; /* Megabytes to log since checkpoint. */
u_int32_t st_fileid_init; /* Initial allocation for fileids. */
#ifndef __TEST_DB_NO_STATISTICS
u_int32_t st_nfileid; /* Current number of fileids. */
u_int32_t st_maxnfileid; /* Maximum number of fileids used. */
uintmax_t st_record; /* Records entered into the log. */
u_int32_t st_w_bytes; /* Bytes to log. */
u_int32_t st_w_mbytes; /* Megabytes to log. */
uintmax_t st_wcount; /* Total I/O writes to the log. */
uintmax_t st_wcount_fill; /* Overflow writes to the log. */
uintmax_t st_rcount; /* Total I/O reads from the log. */
uintmax_t st_scount; /* Total syncs to the log. */
uintmax_t st_region_wait; /* Region lock granted after wait. */
uintmax_t st_region_nowait; /* Region lock granted without wait. */
u_int32_t st_cur_file; /* Current log file number. */
u_int32_t st_cur_offset; /* Current log file offset. */
u_int32_t st_disk_file; /* Known on disk log file number. */
u_int32_t st_disk_offset; /* Known on disk log file offset. */
u_int32_t st_maxcommitperflush; /* Max number of commits in a flush. */
u_int32_t st_mincommitperflush; /* Min number of commits in a flush. */
roff_t st_regsize; /* Region size. */
* We need to record the first log record of a transaction. For user
* defined logging this macro returns the place to put that information,
* if it is need in rlsnp, otherwise it leaves it unchanged. We also
* need to track the last record of the transaction, this returns the
* place to put that info.
#define DB_SET_TXN_LSNP(txn, blsnp, llsnp) \
((txn)->set_txn_lsnp(txn, blsnp, llsnp))
* Definition of the structure which specifies marshalling of log records.
typedef const struct __log_rec_spec {
* Size of a DBT in a log record.
#define LOG_DBT_SIZE(dbt) \
(sizeof(u_int32_t) + ((dbt) == NULL ? 0 : (dbt)->size))
/*******************************************************
* Shared buffer cache (mpool).
*******************************************************/
/* Priority values for DB_MPOOLFILE->{put,set_priority}. */
/* Per-process DB_MPOOLFILE information. */
DB_FH *fhp; /* Underlying file handle. */
* The ref, pinref and q fields are protected by the region lock.
u_int32_t ref; /* Reference count. */
u_int32_t pinref; /* Pinned block reference count. */
* Explicit representations of structures from queue.h.
* TAILQ_ENTRY(__db_mpoolfile) q;
struct __db_mpoolfile *tqe_next;
struct __db_mpoolfile **tqe_prev;
} q; /* Linked list of DB_MPOOLFILE's. */
* The rest of the fields (with the exception of the MP_FLUSH flag)
* are not thread-protected, even when they may be modified at any
* time by the application. The reason is the DB_MPOOLFILE handle
* is single-threaded from the viewpoint of the application, and so
* the only fields needing to be thread-protected are those accessed
* by checkpoint or sync threads when using DB_MPOOLFILE structures
* to flush buffers from the cache.
ENV *env; /* Environment */
MPOOLFILE *mfp; /* Underlying MPOOLFILE. */
u_int32_t clear_len; /* Cleared length on created pages. */
u_int8_t /* Unique file ID. */
int ftype; /* File type. */
int32_t lsn_offset; /* LSN offset in page. */
u_int32_t gbytes, bytes; /* Maximum file size. */
DBT *pgcookie; /* Byte-string passed to pgin/pgout. */
int32_t priority; /* Cache priority. */
void *addr; /* Address of mmap'd region. */
size_t len; /* Length of mmap'd region. */
u_int32_t config_flags; /* Flags to DB_MPOOLFILE->set_flags. */
/* DB_MPOOLFILE PUBLIC HANDLE LIST BEGIN */
int (*close) __P((DB_MPOOLFILE *, u_int32_t));
__P((DB_MPOOLFILE *, db_pgno_t *, DB_TXN *, u_int32_t, void *));
int (*get_clear_len) __P((DB_MPOOLFILE *, u_int32_t *));
int (*get_fileid) __P((DB_MPOOLFILE *, u_int8_t *));
int (*get_flags) __P((DB_MPOOLFILE *, u_int32_t *));
int (*get_ftype) __P((DB_MPOOLFILE *, int *));
int (*get_last_pgno) __P((DB_MPOOLFILE *, db_pgno_t *));
int (*get_lsn_offset) __P((DB_MPOOLFILE *, int32_t *));
int (*get_maxsize) __P((DB_MPOOLFILE *, u_int32_t *, u_int32_t *));
int (*get_pgcookie) __P((DB_MPOOLFILE *, DBT *));
int (*get_priority) __P((DB_MPOOLFILE *, DB_CACHE_PRIORITY *));
int (*open) __P((DB_MPOOLFILE *, const char *, u_int32_t, int, size_t));
int (*put) __P((DB_MPOOLFILE *, void *, DB_CACHE_PRIORITY, u_int32_t));
int (*set_clear_len) __P((DB_MPOOLFILE *, u_int32_t));
int (*set_fileid) __P((DB_MPOOLFILE *, u_int8_t *));
int (*set_flags) __P((DB_MPOOLFILE *, u_int32_t, int));
int (*set_ftype) __P((DB_MPOOLFILE *, int));
int (*set_lsn_offset) __P((DB_MPOOLFILE *, int32_t));
int (*set_maxsize) __P((DB_MPOOLFILE *, u_int32_t, u_int32_t));
int (*set_pgcookie) __P((DB_MPOOLFILE *, DBT *));
int (*set_priority) __P((DB_MPOOLFILE *, DB_CACHE_PRIORITY));
int (*sync) __P((DB_MPOOLFILE *));
/* DB_MPOOLFILE PUBLIC HANDLE LIST END */
* MP_FILEID_SET, MP_OPEN_CALLED and MP_READONLY do not need to be
* thread protected because they are initialized before the file is
* linked onto the per-process lists, and never modified.
* MP_FLUSH is thread protected because it is potentially read/set by
* multiple threads of control.
#define MP_FILEID_SET 0x001 /* Application supplied a file ID. */
#define MP_FLUSH 0x002 /* Was used to flush a buffer. */
#define MP_FOR_FLUSH 0x004 /* Was opened to flush a buffer. */
#define MP_MULTIVERSION 0x008 /* Opened for multiversion access. */
#define MP_OPEN_CALLED 0x010 /* File opened. */
#define MP_READONLY 0x020 /* File is readonly. */
#define MP_DUMMY 0x040 /* File is dummy for __memp_fput. */
/* Mpool statistics structure. */
struct __db_mpool_stat { /* SHARED */
u_int32_t st_gbytes; /* Total cache size: GB. */
u_int32_t st_bytes; /* Total cache size: B. */
u_int32_t st_ncache; /* Number of cache regions. */
u_int32_t st_max_ncache; /* Maximum number of regions. */
db_size_t st_mmapsize; /* Maximum file size for mmap. */
int32_t st_maxopenfd; /* Maximum number of open fd's. */
int32_t st_maxwrite; /* Maximum buffers to write. */
db_timeout_t st_maxwrite_sleep; /* Sleep after writing max buffers. */
u_int32_t st_pages; /* Total number of pages. */
#ifndef __TEST_DB_NO_STATISTICS
u_int32_t st_map; /* Pages from mapped files. */
uintmax_t st_cache_hit; /* Pages found in the cache. */
uintmax_t st_cache_miss; /* Pages not found in the cache. */
uintmax_t st_page_create; /* Pages created in the cache. */
uintmax_t st_page_in; /* Pages read in. */
uintmax_t st_page_out; /* Pages written out. */
uintmax_t st_ro_evict; /* Clean pages forced from the cache. */
uintmax_t st_rw_evict; /* Dirty pages forced from the cache. */
uintmax_t st_page_trickle; /* Pages written by memp_trickle. */
u_int32_t st_page_clean; /* Clean pages. */
u_int32_t st_page_dirty; /* Dirty pages. */
u_int32_t st_hash_buckets; /* Number of hash buckets. */
u_int32_t st_hash_mutexes; /* Number of hash bucket mutexes. */
u_int32_t st_pagesize; /* Assumed page size. */
u_int32_t st_hash_searches; /* Total hash chain searches. */
u_int32_t st_hash_longest; /* Longest hash chain searched. */
uintmax_t st_hash_examined; /* Total hash entries searched. */
uintmax_t st_hash_nowait; /* Hash lock granted with nowait. */
uintmax_t st_hash_wait; /* Hash lock granted after wait. */
uintmax_t st_hash_max_nowait; /* Max hash lock granted with nowait. */
uintmax_t st_hash_max_wait; /* Max hash lock granted after wait. */
uintmax_t st_region_nowait; /* Region lock granted with nowait. */
uintmax_t st_region_wait; /* Region lock granted after wait. */
uintmax_t st_mvcc_frozen; /* Buffers frozen. */
uintmax_t st_mvcc_thawed; /* Buffers thawed. */
uintmax_t st_mvcc_freed; /* Frozen buffers freed. */
uintmax_t st_alloc; /* Number of page allocations. */
uintmax_t st_alloc_buckets; /* Buckets checked during allocation. */
uintmax_t st_alloc_max_buckets;/* Max checked during allocation. */
uintmax_t st_alloc_pages; /* Pages checked during allocation. */
uintmax_t st_alloc_max_pages; /* Max checked during allocation. */
uintmax_t st_io_wait; /* Thread waited on buffer I/O. */
uintmax_t st_sync_interrupted; /* Number of times sync interrupted. */
roff_t st_regsize; /* Region size. */
roff_t st_regmax; /* Region max. */
* Mpool file statistics structure.
* The first fields in this structure must mirror the __db_mpool_fstat_int
* structure, since content is mem copied between the two.
struct __db_mpool_fstat {
u_int32_t st_pagesize; /* Page size. */
#ifndef __TEST_DB_NO_STATISTICS
u_int32_t st_map; /* Pages from mapped files. */
uintmax_t st_cache_hit; /* Pages found in the cache. */
uintmax_t st_cache_miss; /* Pages not found in the cache. */
uintmax_t st_page_create; /* Pages created in the cache. */
uintmax_t st_page_in; /* Pages read in. */
uintmax_t st_page_out; /* Pages written out. */
uintmax_t st_backup_spins; /* Number of spins during a copy. */
char *file_name; /* File name. */
/*******************************************************
* Transactions and recovery.
*******************************************************/
DB_TXN_ABORT=0, /* Public. */
DB_TXN_APPLY=1, /* Public. */
DB_TXN_BACKWARD_ROLL=3, /* Public. */
DB_TXN_FORWARD_ROLL=4, /* Public. */
DB_TXN_OPENFILES=5, /* Internal. */
DB_TXN_POPENFILES=6, /* Internal. */
DB_TXN_PRINT=7, /* Public. */
DB_TXN_LOG_VERIFY=8 /* Internal. */
* BACKWARD_ALLOC is used during the forward pass to pick up any aborted
* allocations for files that were created during the forward pass.
* The main difference between _ALLOC and _ROLL is that the entry for
* the file not exist during the rollforward pass.
#define DB_UNDO(op) ((op) == DB_TXN_ABORT || (op) == DB_TXN_BACKWARD_ROLL)
#define DB_REDO(op) ((op) == DB_TXN_FORWARD_ROLL || (op) == DB_TXN_APPLY)
DB_TXNMGR *mgrp; /* Pointer to transaction manager. */
DB_TXN *parent; /* Pointer to transaction's parent. */
DB_THREAD_INFO *thread_info; /* Pointer to thread information. */
u_int32_t txnid; /* Unique transaction id. */
char *name; /* Transaction name. */
DB_LOCKER *locker; /* Locker for this txn. */
void *td; /* Detail structure within region. */
db_timeout_t lock_timeout; /* Timeout for locks for this txn. */
void *txn_list; /* Undo information for parent. */
* Explicit representations of structures from queue.h.
* TAILQ_ENTRY(__db_txn) links;
struct __db_txn *tqe_next;
struct __db_txn **tqe_prev;
} links; /* Links transactions off manager. */
* Explicit representations of structures from shqueue.h.
* SH_TAILQ_ENTRY xa_links;
* These links link together transactions that are active in
* the same thread of control.
} xa_links; /* Links XA transactions. */
* Explicit representations of structures from queue.h.
* TAILQ_HEAD(__kids, __db_txn) kids;
struct __db_txn *tqh_first;
struct __db_txn **tqh_last;
* Explicit representations of structures from queue.h.
* TAILQ_HEAD(__events, __txn_event) events;
struct __txn_event *tqh_first;
struct __txn_event **tqh_last;
} events; /* Links deferred events. */
* Explicit representations of structures from queue.h.
* STAILQ_HEAD(__logrec, __txn_logrec) logs;
struct __txn_logrec *stqh_first;
struct __txn_logrec **stqh_last;
} logs; /* Links in memory log records. */
* Explicit representations of structures from queue.h.
* TAILQ_ENTRY(__db_txn) klinks;
struct __db_txn *tqe_next;
struct __db_txn **tqe_prev;
} klinks; /* Links of children in parent. */
* Explicit representations of structures from queue.h.
* TAILQ_HEAD(__my_cursors, __dbc) my_cursors;
* Explicit representations of structures from queue.h.
* TAILQ_HEAD(__femfs, MPOOLFILE) femfs;
* These are DBs involved in file extension in this transaction.
DB_TXN_TOKEN *token_buffer; /* User's commit token buffer. */
void *api_internal; /* C++ API private. */
void *xml_internal; /* XML API private. */
u_int32_t cursors; /* Number of cursors open for txn */
/* DB_TXN PUBLIC HANDLE LIST BEGIN */
int (*abort) __P((DB_TXN *));
int (*commit) __P((DB_TXN *, u_int32_t));
int (*discard) __P((DB_TXN *, u_int32_t));
int (*get_name) __P((DB_TXN *, const char **));
int (*get_priority) __P((DB_TXN *, u_int32_t *));
u_int32_t (*id) __P((DB_TXN *));
int (*prepare) __P((DB_TXN *, u_int8_t *));
int (*set_commit_token) __P((DB_TXN *, DB_TXN_TOKEN *));
int (*set_name) __P((DB_TXN *, const char *));
int (*set_priority) __P((DB_TXN *, u_int32_t));
int (*set_timeout) __P((DB_TXN *, db_timeout_t, u_int32_t));
/* DB_TXN PUBLIC HANDLE LIST END */
/* DB_TXN PRIVATE HANDLE LIST BEGIN */
void (*set_txn_lsnp) __P((DB_TXN *txn, DB_LSN **, DB_LSN **));
/* DB_TXN PRIVATE HANDLE LIST END */
#define TXN_XA_THREAD_NOTA 0
#define TXN_XA_THREAD_ASSOCIATED 1
#define TXN_XA_THREAD_SUSPENDED 2
#define TXN_XA_THREAD_UNASSOCIATED 3
#define TXN_CHILDCOMMIT 0x00001 /* Txn has committed. */
#define TXN_COMPENSATE 0x00002 /* Compensating transaction. */
#define TXN_DEADLOCK 0x00004 /* Txn has deadlocked. */
#define TXN_FAMILY 0x00008 /* Cursors/children are independent. */
#define TXN_IGNORE_LEASE 0x00010 /* Skip lease check at commit time. */
#define TXN_INFAMILY 0x00020 /* Part of a transaction family. */
#define TXN_LOCKTIMEOUT 0x00040 /* Txn has a lock timeout. */
#define TXN_MALLOC 0x00080 /* Structure allocated by TXN system. */
#define TXN_NOSYNC 0x00100 /* Do not sync on prepare and commit. */
#define TXN_NOWAIT 0x00200 /* Do not wait on locks. */
#define TXN_PRIVATE 0x00400 /* Txn owned by cursor. */
#define TXN_READONLY 0x00800 /* CDS group handle. */
#define TXN_READ_COMMITTED 0x01000 /* Txn has degree 2 isolation. */
#define TXN_READ_UNCOMMITTED 0x02000 /* Txn has degree 1 isolation. */
#define TXN_RESTORED 0x04000 /* Txn has been restored. */
#define TXN_SNAPSHOT 0x08000 /* Snapshot Isolation. */
#define TXN_SYNC 0x10000 /* Write and sync on prepare/commit. */
#define TXN_WRITE_NOSYNC 0x20000 /* Write only on prepare/commit. */
#define TXN_BULK 0x40000 /* Enable bulk loading optimization. */
#define TXN_SYNC_FLAGS (TXN_SYNC | TXN_NOSYNC | TXN_WRITE_NOSYNC)
* Structure used for two phase commit interface.
* We set the size of our global transaction id (gid) to be 128 in order
* to match that defined by the XA X/Open standard.
u_int8_t gid[DB_GID_SIZE];
/* Transaction statistics structure. */
u_int32_t txnid; /* Transaction ID */
u_int32_t parentid; /* Transaction ID of parent */
pid_t pid; /* Process owning txn ID */
db_threadid_t tid; /* Thread owning txn ID */
DB_LSN lsn; /* LSN when transaction began */
DB_LSN read_lsn; /* Read LSN for MVCC */
u_int32_t mvcc_ref; /* MVCC reference count */
u_int32_t priority; /* Deadlock resolution priority */
u_int32_t status; /* Status of the transaction */
#define TXN_XA_DEADLOCKED 2
#define TXN_XA_PREPARED 4