bdb-fork-grimen
Version:
Berkeley DB(5.X) bindings for node
1,286 lines (1,165 loc) • 103 kB
Plain Text
/*
* See the file LICENSE for redistribution information.
*
* Copyright (c) 1996, 2010 Oracle and/or its affiliates. All rights reserved.
*
* $Id$
*
* db.h include file layout:
* General.
* Database Environment.
* Locking subsystem.
* Logging subsystem.
* Shared buffer cache (mpool) subsystem.
* Transaction subsystem.
* Access methods.
* Access method cursors.
* Dbm/Ndbm, Hsearch historic interfaces.
*/
#ifndef _DB_H_
#define _DB_H_
#ifndef __NO_SYSTEM_INCLUDES
#include <sys/types.h>
@inttypes_h_decl@
@stdint_h_decl@
@stddef_h_decl@
#include <stdio.h>
@unistd_h_decl@
@thread_h_decl@
#endif
@platform_header@
#if defined(__cplusplus)
extern "C" {
#endif
@DB_CONST@
@DB_PROTO1@
@DB_PROTO2@
/*
* Berkeley DB version information.
*/
#define DB_VERSION_FAMILY @DB_VERSION_FAMILY@
#define DB_VERSION_RELEASE @DB_VERSION_RELEASE@
#define DB_VERSION_MAJOR @DB_VERSION_MAJOR@
#define DB_VERSION_MINOR @DB_VERSION_MINOR@
#define DB_VERSION_PATCH @DB_VERSION_PATCH@
#define DB_VERSION_STRING @DB_VERSION_STRING@
#define DB_VERSION_FULL_STRING @DB_VERSION_FULL_STRING@
/*
* !!!
* 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
* by the system.
*/
#ifndef __BIT_TYPES_DEFINED__
#define __BIT_TYPES_DEFINED__
@u_int8_decl@
@int16_decl@
@u_int16_decl@
@int32_decl@
@u_int32_decl@
@int64_decl@
@u_int64_decl@
#endif
@u_char_decl@
@u_int_decl@
@u_long_decl@
@u_short_decl@
/*
* Missing ANSI types.
*
* uintmax_t --
* 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.
*
* uintptr_t --
* 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.
*/
@uintmax_t_decl@
@uintptr_t_decl@
@FILE_t_decl@
@off_t_decl@
@pid_t_decl@
@size_t_decl@
@ssize_t_decl@
@time_t_decl@
/*
* Sequences are only available on machines with 64-bit integral types.
*/
@db_seq_decl@
/* Thread and process identification. */
@db_threadid_t_decl@
/* 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
* arbitrary pointers.
*/
typedef uintptr_t roff_t;
/*
* Forward structure declarations, so we can declare pointers and
* applications can get type checking.
*/
struct __db; typedef struct __db DB;
struct __db_bt_stat; typedef struct __db_bt_stat DB_BTREE_STAT;
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_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_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_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
#define DB_JOINENV 0x0
/* Key/data structure -- a Data-Base Thang. */
struct __db_dbt {
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. */
void *app_data;
#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_STREAMING 0x100 /* Internal: DBT is being streamed. */
#define DB_DBT_USERCOPY 0x200 /* Use the user-supplied callback. */
#define DB_DBT_USERMEM 0x400 /* Return in user's memory. */
u_int32_t flags;
};
/*******************************************************
* Mutexes.
*******************************************************/
typedef u_int32_t db_mutex_t;
struct __db_mutex_stat {
/* 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_cnt; /* Mutex count */
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. */
#endif
};
/* This is the length of the buffer passed to DB_ENV->thread_id_string() */
#define DB_THREADID_STRLEN 128
/*******************************************************
* Locking.
*******************************************************/
#define DB_LOCKVERSION 1
#define DB_FILE_ID_LEN 20 /* Unique file ID length. */
/*
* Deadlock detector modes; used in the DB_ENV structure to configure the
* locking subsystem.
*/
#define DB_LOCK_NORUN 0
#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
* must be == 4.
*/
typedef enum {
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_lockmode_t;
/*
* Request types.
*/
typedef enum {
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_lockop_t;
/*
* Status of a lock.
*/
typedef enum {
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. */
}db_status_t;
/* Lock statistics structure. */
struct __db_lock_stat {
u_int32_t st_id; /* Last allocated locker ID. */
u_int32_t st_cur_maxid; /* Current maximum unused ID. */
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. */
int 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. */
#endif
};
struct __db_lock_hstat {
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 {
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. */
};
/*
* DB_LOCK_ILOCK --
* Internal DB access method lock.
*/
struct __db_ilock {
db_pgno_t pgno; /* Page being locked. */
u_int8_t fileid[DB_FILE_ID_LEN];/* File id. */
#define DB_HANDLE_LOCK 1
#define DB_RECORD_LOCK 2
#define DB_PAGE_LOCK 3
#define DB_DATABASE_LOCK 4
u_int32_t type; /* Type of lock. */
};
/*
* DB_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 {
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. */
struct __db_lockreq {
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. */
};
/*******************************************************
* Logging.
*******************************************************/
#define DB_LOGVERSION 17 /* Current log version. */
#define DB_LOGVERSION_LATCHING 15 /* Log version using latching. */
#define DB_LOGCHKSUM 12 /* Check sum headers. */
#define DB_LOGOLDVER 8 /* Oldest log version supported. */
#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
* offset is reached.
*/
struct __db_lsn {
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.
*/
#define DB_user_BEGIN 10000
#define DB_debug_FLAG 0x80000000
/*
* DB_LOGC --
* Log cursor.
*/
struct __db_log_cursor {
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. */
u_int32_t flags;
};
/* Log statistics structure. */
struct __db_log_stat {
u_int32_t st_magic; /* Log file magic number. */
u_int32_t st_version; /* Log file version number. */
int 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. */
#ifndef __TEST_DB_NO_STATISTICS
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. */
#endif
};
/*
* 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 enum {
LOGREC_Done,
LOGREC_ARG,
LOGREC_HDR,
LOGREC_DATA,
LOGREC_DB,
LOGREC_DBOP,
LOGREC_DBT,
LOGREC_LOCKS,
LOGREC_OP,
LOGREC_PGDBT,
LOGREC_PGDDBT,
LOGREC_PGLIST,
LOGREC_POINTER,
LOGREC_TIME
} log_rec_type_t;
typedef const struct __log_rec_spec {
log_rec_type_t type;
u_int32_t offset;
const char *name;
const char fmt[4];
} DB_LOG_RECSPEC;
/*
* 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}. */
typedef enum {
DB_PRIORITY_UNCHANGED=0,
DB_PRIORITY_VERY_LOW=1,
DB_PRIORITY_LOW=2,
DB_PRIORITY_DEFAULT=3,
DB_PRIORITY_HIGH=4,
DB_PRIORITY_VERY_HIGH=5
} DB_CACHE_PRIORITY;
/* Per-process DB_MPOOLFILE information. */
struct __db_mpoolfile {
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 {
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. */
fileid[DB_FILE_ID_LEN];
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));
int (*get)
__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 opened to flush a buffer. */
#define MP_MULTIVERSION 0x004 /* Opened for multiversion access. */
#define MP_OPEN_CALLED 0x008 /* File opened. */
#define MP_READONLY 0x010 /* File is readonly. */
#define MP_DUMMY 0x020 /* File is dummy for __memp_fput. */
u_int32_t flags;
};
/* Mpool statistics structure. */
struct __db_mpool_stat {
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. */
size_t st_mmapsize; /* Maximum file size for mmap. */
int st_maxopenfd; /* Maximum number of open fd's. */
int 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. */
#endif
};
/* Mpool file statistics structure. */
struct __db_mpool_fstat {
char *file_name; /* File name. */
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. */
#endif
};
/*******************************************************
* Transactions and recovery.
*******************************************************/
#define DB_TXNVERSION 1
typedef enum {
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. */
} db_recops;
/*
* 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)
struct __db_txn {
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 {
struct __db_txn *tqe_next;
struct __db_txn **tqe_prev;
} links; /* Links transactions off manager. */
/*
* !!!
* Explicit representations of structures from queue.h.
* TAILQ_HEAD(__kids, __db_txn) kids;
*/
struct __kids {
struct __db_txn *tqh_first;
struct __db_txn **tqh_last;
} kids;
/*
* !!!
* Explicit representations of structures from queue.h.
* TAILQ_HEAD(__events, __txn_event) events;
*/
struct {
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 {
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 {
struct __db_txn *tqe_next;
struct __db_txn **tqe_prev;
} klinks;
/*
* !!!
* Explicit representations of structures from queue.h.
* TAILQ_HEAD(__my_cursors, __dbc) my_cursors;
*/
struct __my_cursors {
struct __dbc *tqh_first;
struct __dbc **tqh_last;
} my_cursors;
/*
* !!!
* Explicit representations of structures from queue.h.
* TAILQ_HEAD(__femfs, MPOOLFILE) femfs;
*
* These are DBs involved in file extension in this transaction.
*/
struct __femfs {
DB *tqh_first;
DB **tqh_last;
} femfs;
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_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. */
u_int32_t flags;
};
#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.
*/
#define DB_GID_SIZE 128
struct __db_preplist {
DB_TXN *txn;
u_int8_t gid[DB_GID_SIZE];
};
/* Transaction statistics structure. */
struct __db_txn_active {
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 */
#define TXN_ABORTED 1
#define TXN_COMMITTED 2
#define TXN_PREPARED 3
#define TXN_RUNNING 4
u_int32_t status; /* Status of the transaction */
u_int8_t gid[DB_GID_SIZE]; /* Global transaction ID */
char name[51]; /* 50 bytes of name, nul termination */
};
struct __db_txn_stat {
u_int32_t st_nrestores; /* number of restored transactions
after recovery. */
#ifndef __TEST_DB_NO_STATISTICS
DB_LSN st_last_ckp; /* lsn of the last checkpoint */
time_t st_time_ckp; /* time of last checkpoint */
u_int32_t st_last_txnid; /* last transaction id given out */
u_int32_t st_maxtxns; /* maximum txns possible */
uintmax_t st_naborts; /* number of aborted transactions */
uintmax_t st_nbegins; /* number of begun transactions */
uintmax_t st_ncommits; /* number of committed transactions */
u_int32_t st_nactive; /* number of active transactions */
u_int32_t st_nsnapshot; /* number of snapshot transactions */
u_int32_t st_maxnactive; /* maximum active transactions */
u_int32_t st_maxnsnapshot; /* maximum snapshot transactions */
DB_TXN_ACTIVE *st_txnarray; /* array of active transactions */
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. */
#endif
};
#define DB_TXN_TOKEN_SIZE 20
struct __db_txn_token {
u_int8_t buf[DB_TXN_TOKEN_SIZE];
};
/*******************************************************
* Replication.
*******************************************************/
/* Special, out-of-band environment IDs. */
#define DB_EID_BROADCAST -1
#define DB_EID_INVALID -2
#define DB_REP_DEFAULT_PRIORITY 100
/* Acknowledgement policies. */
#define DB_REPMGR_ACKS_ALL 1
#define DB_REPMGR_ACKS_ALL_AVAILABLE 2
#define DB_REPMGR_ACKS_ALL_PEERS 3
#define DB_REPMGR_ACKS_NONE 4
#define DB_REPMGR_ACKS_ONE 5
#define DB_REPMGR_ACKS_ONE_PEER 6
#define DB_REPMGR_ACKS_QUORUM 7
/* Replication timeout configuration values. */
#define DB_REP_ACK_TIMEOUT 1 /* RepMgr acknowledgements. */
#define DB_REP_CHECKPOINT_DELAY 2 /* Master checkpoint delay. */
#define DB_REP_CONNECTION_RETRY 3 /* RepMgr connections. */
#define DB_REP_ELECTION_RETRY 4 /* RepMgr elect retries. */
#define DB_REP_ELECTION_TIMEOUT 5 /* Rep normal elections. */
#define DB_REP_FULL_ELECTION_TIMEOUT 6 /* Rep full elections. */
#define DB_REP_HEARTBEAT_MONITOR 7 /* RepMgr client HB monitor. */
#define DB_REP_HEARTBEAT_SEND 8 /* RepMgr master send freq. */
#define DB_REP_LEASE_TIMEOUT 9 /* Master leases. */
/* Event notification types. */
#define DB_EVENT_PANIC 0
#define DB_EVENT_REG_ALIVE 1
#define DB_EVENT_REG_PANIC 2
#define DB_EVENT_REP_CLIENT 3
#define DB_EVENT_REP_DUPMASTER 4
#define DB_EVENT_REP_ELECTED 5
#define DB_EVENT_REP_ELECTION_FAILED 6
#define DB_EVENT_REP_JOIN_FAILURE 7
#define DB_EVENT_REP_MASTER 8
#define DB_EVENT_REP_MASTER_FAILURE 9
#define DB_EVENT_REP_NEWMASTER 10
#define DB_EVENT_REP_PERM_FAILED 11
#define DB_EVENT_REP_STARTUPDONE 12
#define DB_EVENT_WRITE_FAILED 13
#define DB_EVENT_NO_SUCH_EVENT 0xffffffff /* OOB sentinel value */
/* Replication Manager site status. */
struct __db_repmgr_site {
int eid;
char *host;
u_int port;
#define DB_REPMGR_CONNECTED 1
#define DB_REPMGR_DISCONNECTED 2
u_int32_t status;
#define DB_REPMGR_ISPEER 0x01
u_int32_t flags;
};
/* Replication statistics. */
struct __db_rep_stat {
/* !!!
* Many replication statistics fields cannot be protected by a mutex
* without an unacceptable performance penalty, since most message
* processing is done without the need to hold a region-wide lock.
* Fields whose comments end with a '+' may be updated without holding
* the replication or log mutexes (as appropriate), and thus may be
* off somewhat (or, on unreasonable architectures under unlucky
* circumstances, garbaged).
*/
u_int32_t st_startup_complete; /* Site completed client sync-up. */
#ifndef __TEST_DB_NO_STATISTICS
uintmax_t st_log_queued; /* Log records currently queued.+ */
u_int32_t st_status; /* Current replication status. */
DB_LSN st_next_lsn; /* Next LSN to use or expect. */
DB_LSN st_waiting_lsn; /* LSN we're awaiting, if any. */
DB_LSN st_max_perm_lsn; /* Maximum permanent LSN. */
db_pgno_t st_next_pg; /* Next pg we expect. */
db_pgno_t st_waiting_pg; /* pg we're awaiting, if any. */
u_int32_t st_dupmasters; /* # of times a duplicate master
condition was detected.+ */
int st_env_id; /* Current environment ID. */
u_int32_t st_env_priority; /* Current environment priority. */
uintmax_t st_bulk_fills; /* Bulk buffer fills. */
uintmax_t st_bulk_overflows; /* Bulk buffer overflows. */
uintmax_t st_bulk_records; /* Bulk records stored. */
uintmax_t st_bulk_transfers; /* Transfers of bulk buffers. */
uintmax_t st_client_rerequests;/* Number of forced rerequests. */
uintmax_t st_client_svc_req; /* Number of client service requests
received by this client. */
uintmax_t st_client_svc_miss; /* Number of client service requests
missing on this client. */
u_int32_t st_gen; /* Current generation number. */
u_int32_t st_egen; /* Current election gen number. */
uintmax_t st_log_duplicated; /* Log records received multiply.+ */
uintmax_t st_log_queued_max; /* Max. log records queued at once.+ */
uintmax_t st_log_queued_total; /* Total # of log recs. ever queued.+ */
uintmax_t st_log_records; /* Log records received and put.+ */
uintmax_t st_log_requested; /* Log recs. missed and requested.+ */
int st_master; /* Env. ID of the current master. */
uintmax_t st_master_changes; /* # of times we've switched masters. */
uintmax_t st_msgs_badgen; /* Messages with a bad generation #.+ */
uintmax_t st_msgs_processed; /* Messages received and processed.+ */
uintmax_t st_msgs_recover; /* Messages ignored because this site
was a client in recovery.+ */
uintmax_t st_msgs_send_failures;/* # of failed message sends.+ */
uintmax_t st_msgs_sent; /* # of successful message sends.+ */
uintmax_t st_newsites; /* # of NEWSITE msgs. received.+ */
u_int32_t st_nsites; /* Current number of sites we will
assume during elections. */
uintmax_t st_nthrottles; /* # of times we were throttled. */
uintmax_t st_outdated; /* # of times we detected and returned
an OUTDATED condition.+ */
uintmax_t st_pg_duplicated; /* Pages received multiply.+ */
uintmax_t st_pg_records; /* Pages received and stored.+ */
uintmax_t st_pg_requested; /* Pages missed and requested.+ */
uintmax_t st_txns_applied; /* # of transactions applied.+ */
uintmax_t st_startsync_delayed;/* # of STARTSYNC msgs delayed.+ */
/* Elections generally. */
uintmax_t st_elections; /* # of elections held.+ */
uintmax_t st_elections_won; /* # of elections won by this site.+ */
/* Statistics about an in-progress election. */
int st_election_cur_winner; /* Current front-runner. */
u_int32_t st_election_gen; /* Election generation number. */
DB_LSN st_election_lsn; /* Max. LSN of current winner. */
u_int32_t st_election_nsites; /* # of "registered voters". */
u_int32_t st_election_nvotes; /* # of "registered voters" needed. */
u_int32_t st_election_priority; /* Current election priority. */
int st_election_status; /* Current election status. */
u_int32_t st_election_tiebreaker;/* Election tiebreaker value. */
u_int32_t st_election_votes; /* Votes received in this round. */
u_int32_t st_election_sec; /* Last election time seconds. */
u_int32_t st_election_usec; /* Last election time useconds. */
u_int32_t st_max_lease_sec; /* Maximum lease timestamp seconds. */
u_int32_t st_max_lease_usec; /* Maximum lease timestamp useconds. */
/* Undocumented statistics only used by the test system. */
#ifdef CONFIG_TEST
u_int32_t st_filefail_cleanups; /* # of FILE_FAIL cleanups done. */
#endif
#endif
};
/* Replication Manager statistics. */
struct __db_repmgr_stat {
uintmax_t st_perm_failed; /* # of insufficiently ack'ed msgs. */
uintmax_t st_msgs_queued; /* # msgs queued for network delay. */
uintmax_t st_msgs_dropped; /* # msgs discarded due to excessive
queue length. */
uintmax_t st_connection_drop; /* Existing connections dropped. */
uintmax_t st_connect_fail; /* Failed new connection attempts. */
uintmax_t st_elect_threads; /* # of active election threads. */
uintmax_t st_max_elect_threads; /* Max concurrent e-threads ever. */
};
/*******************************************************
* Sequences.
*******************************************************/
/*
* The storage record for a sequence.
*/
struct __db_seq_record {
u_int32_t seq_version; /* Version size/number. */
u_int32_t flags; /* DB_SEQ_XXX Flags. */
db_seq_t seq_value; /* Current value. */
db_seq_t seq_max; /* Max permitted. */
db_seq_t seq_min; /* Min permitted. */
};
/*
* Handle for a sequence object.
*/
struct __db_sequence {
DB *seq_dbp; /* DB handle for this sequence. */
db_mutex_t mtx_seq; /* Mutex if sequence is threaded. */
DB_SEQ_RECORD *seq_rp; /* Pointer to current data. */
DB_SEQ_RECORD seq_record; /* Data from DB_SEQUENCE. */
int32_t seq_cache_size; /* Number of values cached. */
db_seq_t seq_last_value; /* Last value cached. */
DBT seq_key; /* DBT pointing to sequence key. */
DBT seq_data; /* DBT pointing to seq_record. */
/* API-private structure: used by C++ and Java. */
void *api_internal;
/* DB_SEQUENCE PUBLIC HANDLE LIST BEGIN */
int (*close) __P((DB_SEQUENCE *, u_int32_t));
int (*get) __P((DB_SEQUENCE *,
DB_TXN *, int32_t, db_seq_t *, u_int32_t));
int (*get_cachesize) __P((DB_SEQUENCE *, int32_t *));
int (*get_db) __P((DB_SEQUENCE *, DB **));
int (*get_flags) __P((DB_SEQUENCE *, u_int32_t *));
int (*get_key) __P((DB_SEQUENCE *, DBT *));
int (*get_range) __P((DB_SEQUENCE *,
db_seq_t *, db_seq_t *));
int (*initial_value) __P((DB_SEQUENCE *, db_seq_t));
int (*open) __P((DB_SEQUENCE *,
DB_TXN *, DBT *, u_int32_t));
int (*remove) __P((DB_SEQUENCE *, DB_TXN *, u_int32_t));
int (*set_cachesize) __P((DB_SEQUENCE *, int32_t));
int (*set_flags) __P((DB_SEQUENCE *, u_int32_t));
int (*set_range) __P((DB_SEQUENCE *, db_seq_t, db_seq_t));
int (*stat) __P((DB_SEQUENCE *,
DB_SEQUENCE_STAT **, u_int32_t));
int (*stat_print) __P((DB_SEQUENCE *, u_int32_t));
/* DB_SEQUENCE PUBLIC HANDLE LIST END */
};
struct __db_seq_stat {
uintmax_t st_wait; /* Sequence lock granted w/o wait. */
uintmax_t st_nowait; /* Sequence lock granted after wait. */
db_seq_t st_current; /* Current value in db. */
db_seq_t st_value; /* Current cached value. */
db_seq_t st_last_value; /* Last cached value. */
db_seq_t st_min; /* Minimum value. */
db_seq_t st_max; /* Maximum value. */
int32_t st_cache_size; /* Cache size. */
u_int32_t st_flags; /* Flag value. */
};
/*******************************************************
* Access methods.
*******************************************************/
typedef enum {
DB_BTREE=1,
DB_HASH=2,
DB_RECNO=3,
DB_QUEUE=4,
DB_UNKNOWN=5 /* Figure it out on open. */
} DBTYPE;
#define DB_RENAMEMAGIC 0x030800 /* File has been renamed. */
#define DB_BTREEVERSION 9 /* Current btree version. */
#define DB_BTREEOLDVER 8 /* Oldest btree version supported. */
#define DB_BTREEMAGIC 0x053162
#define DB_HASHVERSION 9 /* Current hash version. */
#define DB_HASHOLDVER 7 /* Oldest hash version supported. */
#define DB_HASHMAGIC 0x061561
#define DB_QAMVERSION 4 /* Current queue version. */
#define DB_QAMOLDVER 3 /* Oldest queue version supported. */
#define DB_QAMMAGIC 0x042253
#define DB_SEQUENCE_VERSION 2 /* Current sequence version. */
#define DB_SEQUENCE_OLDVER 1 /* Oldest sequence version supported. */
/*
* DB access method and cursor operation values. Each value is an operation
* code to which additional bit flags are added.
*/
#define DB_AFTER 1 /* Dbc.put */
#define DB_APPEND 2 /* Db.put */
#define DB_BEFORE 3 /* Dbc.put */
#define DB_CONSUME 4 /* Db.get */
#define DB_CONSUME_WAIT 5 /* Db.get */
#define DB_CURRENT 6 /* Dbc.get, Dbc.put, DbLogc.get */
#define DB_FIRST 7 /* Dbc.get, DbLogc->get */
#define DB_GET_BOTH 8 /* Db.get, Dbc.get */
#define DB_GET_BOTHC 9 /* Dbc.get (internal) */
#define DB_GET_BOTH_RANGE 10 /* Db.get, Dbc.get */
#define DB_GET_RECNO 11 /* Dbc.get */
#define DB_JOIN_ITEM 12 /* Dbc.get; don't do primary lookup */
#define DB_KEYFIRST 13 /* Dbc.put */
#define DB_KEYLAST 14 /* Dbc.put */
#define DB_LAST 15 /* Dbc.get, DbLogc->get */
#define DB_NEXT 16 /* Dbc.get, DbLogc->get */
#define DB_NEXT_DUP 17 /* Dbc.get */
#define DB_NEXT_NODUP 18 /* Dbc.get */
#define DB_NODUPDATA 19 /* Db.put, Dbc.put */
#define DB_NOOVERWRITE 20 /* Db.put */
#define DB_OVERWRITE_DUP 21 /* Dbc.put, Db.put; no DB_KEYEXIST */
#define DB_POSITION 22 /* Dbc.dup */
#define DB_PREV 23 /* Dbc.get, DbLogc->get */
#define DB_PREV_DUP 24 /* Dbc.get */
#define DB_PREV_NODUP 25 /* Dbc.get */
#define DB_SET 26 /* Dbc.get, DbLogc->get */
#define DB_SET_RANGE 27 /* Dbc.get */
#define DB_SET_RECNO 28 /* Db.get, Dbc.get */
#define DB_UPDATE_SECONDARY 29 /* Dbc.get, Dbc.del (internal) */
#define DB_SET_LTE 30 /* Dbc.get (internal) */
#define DB_GET_BOTH_LTE 31 /* Dbc.get (internal) */
/* This has to change when the max opcode hits 255. */
#define DB_OPFLAGS_MASK 0x000000ff /* Mask for operations flags. */
/*
* DB (user visible) error return codes.
*
* !!!
* We don't want our error returns to conflict with other packages where
* possible, so pick a base error value that's hopefully not common. We
* document that we own the error name space from -30,800 to -30,999.
*/
/* DB (public) error return codes. */
#define DB_BUFFER_SMALL (-30999)/* User memory too small for return. */
#define DB_DONOTINDEX (-30998)/* "Null" return from 2ndary callbk. */
#define DB_FOREIGN_CONFLICT (-30997)/* A foreign db constraint triggered. */
#define DB_KEYEMPTY (-30996)/* Key/data deleted or never created. */
#define DB_KEYEXIST (-30995)/* The key/data pair already exists. */
#define DB_LOCK_DEADLOCK (-30994)/* Deadlock. */
#define DB_LOCK_NOTGRANTED (-30993)/* Lock unavailable. */
#define DB_LOG_BUFFER_FULL (-30992)/* In-memory log buffer full. */
#define DB_LOG_VERIFY_BAD (-30991)/* Log verification failed. */
#define DB_NOSERVER (-30990)/* Server panic return. */
#define DB_NOSERVER_HOME (-30989)/* Bad home sent to server. */
#define DB_NOSERVER_ID (-30988)/* Bad ID sent to server. */
#define DB_NOTFOUND (-30987)/* Key/data pair not found (EOF). */
#define DB_OLD_VERSION (-30986)/* Out-of-date version. */
#define DB_PAGE_NOTFOUND (-30985)/* Requested page not found. */
#define DB_REP_DUPMASTER (-30984)/* There are two masters. */
#define DB_REP_HANDLE_DEAD (-30983)/* Rolled back a commit. */
#define DB_REP_HOLDELECTION (-30982)/* Time to hold an election. */
#define DB_REP_IGNORE (-30981)/* This msg should be ignored.*/
#define DB_REP_ISPERM (-30980)/* Cached not written perm written.*/
#define DB_REP_JOIN_FAILURE (-30979)/* Unable to join replication group. */
#define DB_REP_LEASE_EXPIRED (-30978)/* Master lease has expired. */
#define DB_REP_LOCKOUT (-30977)/* API/Replication lockout now. */
#define DB_REP_NEW