* See the file LICENSE for redistribution information.
* Copyright (c) 1996, 2013 Oracle and/or its affiliates. All rights reserved.
* db.h include file layout:
* Shared buffer cache (mpool) subsystem.
* Dbm/Ndbm, Hsearch historic interfaces.
#ifndef __NO_SYSTEM_INCLUDES
#define __P(protos) protos
* Berkeley DB version information.
#define DB_VERSION_FAMILY 11
#define DB_VERSION_RELEASE 2
#define DB_VERSION_MAJOR 5
#define DB_VERSION_MINOR 3
#define DB_VERSION_PATCH 28
#define DB_VERSION_STRING "Berkeley DB 5.3.28: (September 9, 2013)"
#define DB_VERSION_FULL_STRING "Berkeley DB 11g Release 2, library version 11.2.5.3.28: (September 9, 2013)"
* Berkeley DB uses specifically sized types. If they're not provided by
* the system, typedef them here.
* We protect them against multiple inclusion using __BIT_TYPES_DEFINED__,
* as does BIND and Kerberos, since we don't know for sure what #include
* files the user is using.
* We also provide the standard u_int, u_long etc., if they're not provided
#ifndef __BIT_TYPES_DEFINED__
#define __BIT_TYPES_DEFINED__
* Largest unsigned type, used to align structures in memory. We don't store
* floating point types in structures, so integral types should be sufficient
* (and we don't have to worry about systems that store floats in other than
* power-of-2 numbers of bytes). Additionally this fixes compilers that rewrite
* structure assignments and ANSI C memcpy calls to be in-line instructions
* that happen to require alignment.
* Unsigned type that's the same size as a pointer. There are places where
* DB modifies pointers by discarding the bottom bits to guarantee alignment.
* We can't use uintmax_t, it may be larger than the pointer, and compilers
* get upset about that. So far we haven't run on any machine where there's
* no unsigned type the same size as a pointer -- here's hoping.
#ifdef HAVE_MIXED_SIZE_ADDRESSING
typedef u_int32_t db_size_t;
typedef size_t db_size_t;
#ifdef HAVE_MIXED_SIZE_ADDRESSING
typedef int32_t db_ssize_t;
typedef ssize_t db_ssize_t;
* Sequences are only available on machines with 64-bit integral types.
typedef int64_t db_seq_t;
/* Thread and process identification. */
typedef pthread_t db_threadid_t;
/* Basic types that are exported or quasi-exported. */
typedef u_int32_t db_pgno_t; /* Page number type. */
typedef u_int16_t db_indx_t; /* Page offset type. */
#define DB_MAX_PAGES 0xffffffff /* >= # of pages in a file */
typedef u_int32_t db_recno_t; /* Record number type. */
#define DB_MAX_RECORDS 0xffffffff /* >= # of records in a tree */
typedef u_int32_t db_timeout_t; /* Type of a timeout. */
* Region offsets are the difference between a pointer in a region and the
* region's base address. With private environments, both addresses are the
* result of calling malloc, and we can't assume anything about what malloc
* will return, so region offsets have to be able to hold differences between
typedef db_size_t roff_t;
* Forward structure declarations, so we can declare pointers and
* applications can get type checking.
struct __channel; typedef struct __channel CHANNEL;
struct __db; typedef struct __db DB;
struct __db_bt_stat; typedef struct __db_bt_stat DB_BTREE_STAT;
struct __db_channel; typedef struct __db_channel DB_CHANNEL;
struct __db_cipher; typedef struct __db_cipher DB_CIPHER;
struct __db_compact; typedef struct __db_compact DB_COMPACT;
struct __db_dbt; typedef struct __db_dbt DBT;
struct __db_distab; typedef struct __db_distab DB_DISTAB;
struct __db_env; typedef struct __db_env DB_ENV;
struct __db_h_stat; typedef struct __db_h_stat DB_HASH_STAT;
struct __db_heap_rid; typedef struct __db_heap_rid DB_HEAP_RID;
struct __db_heap_stat; typedef struct __db_heap_stat DB_HEAP_STAT;
struct __db_ilock; typedef struct __db_ilock DB_LOCK_ILOCK;
struct __db_lock_hstat; typedef struct __db_lock_hstat DB_LOCK_HSTAT;
struct __db_lock_pstat; typedef struct __db_lock_pstat DB_LOCK_PSTAT;
struct __db_lock_stat; typedef struct __db_lock_stat DB_LOCK_STAT;
struct __db_lock_u; typedef struct __db_lock_u DB_LOCK;
struct __db_locker; typedef struct __db_locker DB_LOCKER;
struct __db_lockreq; typedef struct __db_lockreq DB_LOCKREQ;
struct __db_locktab; typedef struct __db_locktab DB_LOCKTAB;
struct __db_log; typedef struct __db_log DB_LOG;
struct __db_log_cursor; typedef struct __db_log_cursor DB_LOGC;
struct __db_log_stat; typedef struct __db_log_stat DB_LOG_STAT;
struct __db_lsn; typedef struct __db_lsn DB_LSN;
struct __db_mpool; typedef struct __db_mpool DB_MPOOL;
struct __db_mpool_fstat;typedef struct __db_mpool_fstat DB_MPOOL_FSTAT;
struct __db_mpool_stat; typedef struct __db_mpool_stat DB_MPOOL_STAT;
struct __db_mpoolfile; typedef struct __db_mpoolfile DB_MPOOLFILE;
struct __db_mutex_stat; typedef struct __db_mutex_stat DB_MUTEX_STAT;
struct __db_mutex_t; typedef struct __db_mutex_t DB_MUTEX;
struct __db_mutexmgr; typedef struct __db_mutexmgr DB_MUTEXMGR;
struct __db_preplist; typedef struct __db_preplist DB_PREPLIST;
struct __db_qam_stat; typedef struct __db_qam_stat DB_QUEUE_STAT;
struct __db_rep; typedef struct __db_rep DB_REP;
struct __db_rep_stat; typedef struct __db_rep_stat DB_REP_STAT;
struct __db_repmgr_conn_err;
typedef struct __db_repmgr_conn_err DB_REPMGR_CONN_ERR;
struct __db_repmgr_site;typedef struct __db_repmgr_site DB_REPMGR_SITE;
struct __db_repmgr_stat;typedef struct __db_repmgr_stat DB_REPMGR_STAT;
struct __db_seq_record; typedef struct __db_seq_record DB_SEQ_RECORD;
struct __db_seq_stat; typedef struct __db_seq_stat DB_SEQUENCE_STAT;
struct __db_site; typedef struct __db_site DB_SITE;
struct __db_sequence; typedef struct __db_sequence DB_SEQUENCE;
struct __db_thread_info;typedef struct __db_thread_info DB_THREAD_INFO;
struct __db_txn; typedef struct __db_txn DB_TXN;
struct __db_txn_active; typedef struct __db_txn_active DB_TXN_ACTIVE;
struct __db_txn_stat; typedef struct __db_txn_stat DB_TXN_STAT;
struct __db_txn_token; typedef struct __db_txn_token DB_TXN_TOKEN;
struct __db_txnmgr; typedef struct __db_txnmgr DB_TXNMGR;
struct __dbc; typedef struct __dbc DBC;
struct __dbc_internal; typedef struct __dbc_internal DBC_INTERNAL;
struct __env; typedef struct __env ENV;
struct __fh_t; typedef struct __fh_t DB_FH;
struct __fname; typedef struct __fname FNAME;
struct __key_range; typedef struct __key_range DB_KEY_RANGE;
struct __mpoolfile; typedef struct __mpoolfile MPOOLFILE;
struct __db_logvrfy_config;
typedef struct __db_logvrfy_config DB_LOG_VERIFY_CONFIG;
* The Berkeley DB API flags are automatically-generated -- the following flag
* names are no longer used, but remain for compatibility reasons.
#define DB_DEGREE_2 DB_READ_COMMITTED
#define DB_DIRTY_READ DB_READ_UNCOMMITTED
/* Key/data structure -- a Data-Base Thang. */
void *data; /* Key/data */
u_int32_t size; /* key/data length */
u_int32_t ulen; /* RO: length of user buffer. */
u_int32_t dlen; /* RO: get/put record length. */
u_int32_t doff; /* RO: get/put record offset. */
#define DB_DBT_APPMALLOC 0x001 /* Callback allocated memory. */
#define DB_DBT_BULK 0x002 /* Internal: Insert if duplicate. */
#define DB_DBT_DUPOK 0x004 /* Internal: Insert if duplicate. */
#define DB_DBT_ISSET 0x008 /* Lower level calls set value. */
#define DB_DBT_MALLOC 0x010 /* Return in malloc'd memory. */
#define DB_DBT_MULTIPLE 0x020 /* References multiple records. */
#define DB_DBT_PARTIAL 0x040 /* Partial put/get. */
#define DB_DBT_REALLOC 0x080 /* Return in realloc'd memory. */
#define DB_DBT_READONLY 0x100 /* Readonly, don't update. */
#define DB_DBT_STREAMING 0x200 /* Internal: DBT is being streamed. */
#define DB_DBT_USERCOPY 0x400 /* Use the user-supplied callback. */
#define DB_DBT_USERMEM 0x800 /* Return in user's memory. */
/*******************************************************
*******************************************************/
* When mixed size addressing is supported mutexes need to be the same size
* independent of the process address size is.
#ifdef HAVE_MIXED_SIZE_ADDRESSING
typedef db_size_t db_mutex_t;
typedef uintptr_t db_mutex_t;
struct __db_mutex_stat { /* SHARED */
/* The following fields are maintained in the region's copy. */
u_int32_t st_mutex_align; /* Mutex alignment */
u_int32_t st_mutex_tas_spins; /* Mutex test-and-set spins */
u_int32_t st_mutex_init; /* Initial mutex count */
u_int32_t st_mutex_cnt; /* Mutex count */
u_int32_t st_mutex_max; /* Mutex max */
u_int32_t st_mutex_free; /* Available mutexes */
u_int32_t st_mutex_inuse; /* Mutexes in use */
u_int32_t st_mutex_inuse_max; /* Maximum mutexes ever in use */
/* The following fields are filled-in from other places. */
#ifndef __TEST_DB_NO_STATISTICS
uintmax_t st_region_wait; /* Region lock granted after wait. */
uintmax_t st_region_nowait; /* Region lock granted without wait. */
roff_t st_regsize; /* Region size. */
roff_t st_regmax; /* Region max. */
/* This is the length of the buffer passed to DB_ENV->thread_id_string() */
#define DB_THREADID_STRLEN 128
/*******************************************************
*******************************************************/
#define DB_FILE_ID_LEN 20 /* Unique file ID length. */
* Deadlock detector modes; used in the DB_ENV structure to configure the
#define DB_LOCK_DEFAULT 1 /* Default policy. */
#define DB_LOCK_EXPIRE 2 /* Only expire locks, no detection. */
#define DB_LOCK_MAXLOCKS 3 /* Select locker with max locks. */
#define DB_LOCK_MAXWRITE 4 /* Select locker with max writelocks. */
#define DB_LOCK_MINLOCKS 5 /* Select locker with min locks. */
#define DB_LOCK_MINWRITE 6 /* Select locker with min writelocks. */
#define DB_LOCK_OLDEST 7 /* Select oldest locker. */
#define DB_LOCK_RANDOM 8 /* Select random locker. */
#define DB_LOCK_YOUNGEST 9 /* Select youngest locker. */
* Simple R/W lock modes and for multi-granularity intention locking.
* These values are NOT random, as they are used as an index into the lock
* conflicts arrays, i.e., DB_LOCK_IWRITE must be == 3, and DB_LOCK_IREAD
DB_LOCK_NG=0, /* Not granted. */
DB_LOCK_READ=1, /* Shared/read. */
DB_LOCK_WRITE=2, /* Exclusive/write. */
DB_LOCK_WAIT=3, /* Wait for event */
DB_LOCK_IWRITE=4, /* Intent exclusive/write. */
DB_LOCK_IREAD=5, /* Intent to share/read. */
DB_LOCK_IWR=6, /* Intent to read and write. */
DB_LOCK_READ_UNCOMMITTED=7, /* Degree 1 isolation. */
DB_LOCK_WWRITE=8 /* Was Written. */
DB_LOCK_DUMP=0, /* Display held locks. */
DB_LOCK_GET=1, /* Get the lock. */
DB_LOCK_GET_TIMEOUT=2, /* Get lock with a timeout. */
DB_LOCK_INHERIT=3, /* Pass locks to parent. */
DB_LOCK_PUT=4, /* Release the lock. */
DB_LOCK_PUT_ALL=5, /* Release locker's locks. */
DB_LOCK_PUT_OBJ=6, /* Release locker's locks on obj. */
DB_LOCK_PUT_READ=7, /* Release locker's read locks. */
DB_LOCK_TIMEOUT=8, /* Force a txn to timeout. */
DB_LOCK_TRADE=9, /* Trade locker ids on a lock. */
DB_LOCK_UPGRADE_WRITE=10 /* Upgrade writes for dirty reads. */
DB_LSTAT_ABORTED=1, /* Lock belongs to an aborted txn. */
DB_LSTAT_EXPIRED=2, /* Lock has expired. */
DB_LSTAT_FREE=3, /* Lock is unallocated. */
DB_LSTAT_HELD=4, /* Lock is currently held. */
DB_LSTAT_PENDING=5, /* Lock was waiting and has been
* promoted; waiting for the owner
* to run and upgrade it to held. */
DB_LSTAT_WAITING=6 /* Lock is on the wait queue. */
/* Lock statistics structure. */
struct __db_lock_stat { /* SHARED */
u_int32_t st_id; /* Last allocated locker ID. */
u_int32_t st_cur_maxid; /* Current maximum unused ID. */
u_int32_t st_initlocks; /* Initial number of locks in table. */
u_int32_t st_initlockers; /* Initial num of lockers in table. */
u_int32_t st_initobjects; /* Initial num of objects in table. */
u_int32_t st_locks; /* Current number of locks in table. */
u_int32_t st_lockers; /* Current num of lockers in table. */
u_int32_t st_objects; /* Current num of objects in table. */
u_int32_t st_maxlocks; /* Maximum number of locks in table. */
u_int32_t st_maxlockers; /* Maximum num of lockers in table. */
u_int32_t st_maxobjects; /* Maximum num of objects in table. */
u_int32_t st_partitions; /* number of partitions. */
u_int32_t st_tablesize; /* Size of object hash table. */
int32_t st_nmodes; /* Number of lock modes. */
u_int32_t st_nlockers; /* Current number of lockers. */
#ifndef __TEST_DB_NO_STATISTICS
u_int32_t st_nlocks; /* Current number of locks. */
u_int32_t st_maxnlocks; /* Maximum number of locks so far. */
u_int32_t st_maxhlocks; /* Maximum number of locks in any bucket. */
uintmax_t st_locksteals; /* Number of lock steals so far. */
uintmax_t st_maxlsteals; /* Maximum number steals in any partition. */
u_int32_t st_maxnlockers; /* Maximum number of lockers so far. */
u_int32_t st_nobjects; /* Current number of objects. */
u_int32_t st_maxnobjects; /* Maximum number of objects so far. */
u_int32_t st_maxhobjects; /* Maximum number of objectsin any bucket. */
uintmax_t st_objectsteals; /* Number of objects steals so far. */
uintmax_t st_maxosteals; /* Maximum number of steals in any partition. */
uintmax_t st_nrequests; /* Number of lock gets. */
uintmax_t st_nreleases; /* Number of lock puts. */
uintmax_t st_nupgrade; /* Number of lock upgrades. */
uintmax_t st_ndowngrade; /* Number of lock downgrades. */
uintmax_t st_lock_wait; /* Lock conflicts w/ subsequent wait */
uintmax_t st_lock_nowait; /* Lock conflicts w/o subsequent wait */
uintmax_t st_ndeadlocks; /* Number of lock deadlocks. */
db_timeout_t st_locktimeout; /* Lock timeout. */
uintmax_t st_nlocktimeouts; /* Number of lock timeouts. */
db_timeout_t st_txntimeout; /* Transaction timeout. */
uintmax_t st_ntxntimeouts; /* Number of transaction timeouts. */
uintmax_t st_part_wait; /* Partition lock granted after wait. */
uintmax_t st_part_nowait; /* Partition lock granted without wait. */
uintmax_t st_part_max_wait; /* Max partition lock granted after wait. */
uintmax_t st_part_max_nowait; /* Max partition lock granted without wait. */
uintmax_t st_objs_wait; /* Object lock granted after wait. */
uintmax_t st_objs_nowait; /* Object lock granted without wait. */
uintmax_t st_lockers_wait; /* Locker lock granted after wait. */
uintmax_t st_lockers_nowait; /* Locker lock granted without wait. */
uintmax_t st_region_wait; /* Region lock granted after wait. */
uintmax_t st_region_nowait; /* Region lock granted without wait. */
u_int32_t st_hash_len; /* Max length of bucket. */
roff_t st_regsize; /* Region size. */
struct __db_lock_hstat { /* SHARED */
uintmax_t st_nrequests; /* Number of lock gets. */
uintmax_t st_nreleases; /* Number of lock puts. */
uintmax_t st_nupgrade; /* Number of lock upgrades. */
uintmax_t st_ndowngrade; /* Number of lock downgrades. */
u_int32_t st_nlocks; /* Current number of locks. */
u_int32_t st_maxnlocks; /* Maximum number of locks so far. */
u_int32_t st_nobjects; /* Current number of objects. */
u_int32_t st_maxnobjects; /* Maximum number of objects so far. */
uintmax_t st_lock_wait; /* Lock conflicts w/ subsequent wait */
uintmax_t st_lock_nowait; /* Lock conflicts w/o subsequent wait */
uintmax_t st_nlocktimeouts; /* Number of lock timeouts. */
uintmax_t st_ntxntimeouts; /* Number of transaction timeouts. */
u_int32_t st_hash_len; /* Max length of bucket. */
struct __db_lock_pstat { /* SHARED */
u_int32_t st_nlocks; /* Current number of locks. */
u_int32_t st_maxnlocks; /* Maximum number of locks so far. */
u_int32_t st_nobjects; /* Current number of objects. */
u_int32_t st_maxnobjects; /* Maximum number of objects so far. */
uintmax_t st_locksteals; /* Number of lock steals so far. */
uintmax_t st_objectsteals; /* Number of objects steals so far. */
* Internal DB access method lock.
struct __db_ilock { /* SHARED */
db_pgno_t pgno; /* Page being locked. */
u_int8_t fileid[DB_FILE_ID_LEN];/* File id. */
#define DB_DATABASE_LOCK 4
u_int32_t type; /* Type of lock. */
* The structure is allocated by the caller and filled in during a
* lock_get request (or a lock_vec/DB_LOCK_GET).
struct __db_lock_u { /* SHARED */
roff_t off; /* Offset of the lock in the region */
u_int32_t ndx; /* Index of the object referenced by
* this lock; used for locking. */
u_int32_t gen; /* Generation number of this lock. */
db_lockmode_t mode; /* mode of this lock. */
/* Lock request structure. */
db_lockop_t op; /* Operation. */
db_lockmode_t mode; /* Requested mode. */
db_timeout_t timeout; /* Time to expire lock. */
DBT *obj; /* Object being locked. */
DB_LOCK lock; /* Lock returned. */
/*******************************************************
*******************************************************/
#define DB_LOGVERSION 19 /* Current log version. */
#define DB_LOGVERSION_LATCHING 15 /* Log version using latching: db-4.8 */
#define DB_LOGCHKSUM 12 /* Check sum headers: db-4.5 */
#define DB_LOGOLDVER 8 /* Oldest version supported: db-4.2 */
#define DB_LOGMAGIC 0x040988
* A DB_LSN has two parts, a fileid which identifies a specific file, and an
* offset within that file. The fileid is an unsigned 4-byte quantity that
* uniquely identifies a file within the log directory -- currently a simple
* counter inside the log. The offset is also an unsigned 4-byte value. The
* log manager guarantees the offset is never more than 4 bytes by switching
* to a new log file before the maximum length imposed by an unsigned 4-byte
struct __db_lsn { /* SHARED */
u_int32_t file; /* File ID. */
u_int32_t offset; /* File offset. */
* Application-specified log record types start at DB_user_BEGIN, and must not
* equal or exceed DB_debug_FLAG.
* DB_debug_FLAG is the high-bit of the u_int32_t that specifies a log record
* type. If the flag is set, it's a log record that was logged for debugging
* purposes only, even if it reflects a database change -- the change was part
* of a non-durable transaction.