📄 db.h
字号:
u_int32_t st_gen; /* Current generation number. */ u_int32_t st_egen; /* Current election gen number. */ u_int32_t st_log_duplicated; /* Log records received multiply.+ */ u_int32_t st_log_queued; /* Log records currently queued.+ */ u_int32_t st_log_queued_max; /* Max. log records queued at once.+ */ u_int32_t st_log_queued_total; /* Total # of log recs. ever queued.+ */ u_int32_t st_log_records; /* Log records received and put.+ */ u_int32_t st_log_requested; /* Log recs. missed and requested.+ */ int st_master; /* Env. ID of the current master. */ u_int32_t st_master_changes; /* # of times we've switched masters. */ u_int32_t st_msgs_badgen; /* Messages with a bad generation #.+ */ u_int32_t st_msgs_processed; /* Messages received and processed.+ */ u_int32_t st_msgs_recover; /* Messages ignored because this site was a client in recovery.+ */ u_int32_t st_msgs_send_failures;/* # of failed message sends.+ */ u_int32_t st_msgs_sent; /* # of successful message sends.+ */ u_int32_t st_newsites; /* # of NEWSITE msgs. received.+ */ int st_nsites; /* Current number of sites we will assume during elections. */ u_int32_t st_nthrottles; /* # of times we were throttled. */ u_int32_t st_outdated; /* # of times we detected and returned an OUTDATED condition.+ */ u_int32_t st_pg_duplicated; /* Pages received multiply.+ */ u_int32_t st_pg_records; /* Pages received and stored.+ */ u_int32_t st_pg_requested; /* Pages missed and requested.+ */ u_int32_t st_startup_complete; /* Site completed client sync-up. */ u_int32_t st_txns_applied; /* # of transactions applied.+ */ /* Elections generally. */ u_int32_t st_elections; /* # of elections held.+ */ u_int32_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. */ int st_election_nsites; /* # of "registered voters". */ int st_election_nvotes; /* # of "registered voters" needed. */ int st_election_priority; /* Current election priority. */ int st_election_status; /* Current election status. */ u_int32_t st_election_tiebreaker;/* Election tiebreaker value. */ int st_election_votes; /* Votes received in this round. */};/* * The storage record for a sequence. */struct __db_seq_record { u_int32_t seq_version; /* Version size/number. */#define DB_SEQ_DEC 0x00000001 /* Decrement sequence. */#define DB_SEQ_INC 0x00000002 /* Increment sequence. */#define DB_SEQ_RANGE_SET 0x00000004 /* Range set (internal). */#define DB_SEQ_WRAP 0x00000008 /* Wrap sequence at min/max. */ u_int32_t flags; /* 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 *seq_mutexp; /* 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; 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));};struct __db_seq_stat { u_int32_t st_wait; /* Sequence lock granted without wait. */ u_int32_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 8 /* 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 1 /* Current sequence version. *//* * DB access method and cursor operation values. Each value is an operation * code to which additional bit flags are added. */#define DB_AFTER 1 /* c_put() */#define DB_APPEND 2 /* put() */#define DB_BEFORE 3 /* c_put() */#define DB_CACHED_COUNTS 4 /* stat() */#define DB_CONSUME 5 /* get() */#define DB_CONSUME_WAIT 6 /* get() */#define DB_CURRENT 7 /* c_get(), c_put(), DB_LOGC->get() */#define DB_FAST_STAT 8 /* stat() */#define DB_FIRST 9 /* c_get(), DB_LOGC->get() */#define DB_GET_BOTH 10 /* get(), c_get() */#define DB_GET_BOTHC 11 /* c_get() (internal) */#define DB_GET_BOTH_RANGE 12 /* get(), c_get() */#define DB_GET_RECNO 13 /* c_get() */#define DB_JOIN_ITEM 14 /* c_get(); do not do primary lookup */#define DB_KEYFIRST 15 /* c_put() */#define DB_KEYLAST 16 /* c_put() */#define DB_LAST 17 /* c_get(), DB_LOGC->get() */#define DB_NEXT 18 /* c_get(), DB_LOGC->get() */#define DB_NEXT_DUP 19 /* c_get() */#define DB_NEXT_NODUP 20 /* c_get() */#define DB_NODUPDATA 21 /* put(), c_put() */#define DB_NOOVERWRITE 22 /* put() */#define DB_NOSYNC 23 /* close() */#define DB_POSITION 24 /* c_dup() */#define DB_PREV 25 /* c_get(), DB_LOGC->get() */#define DB_PREV_NODUP 26 /* c_get(), DB_LOGC->get() */#define DB_RECORDCOUNT 27 /* stat() */#define DB_SET 28 /* c_get(), DB_LOGC->get() */#define DB_SET_LOCK_TIMEOUT 29 /* set_timout() */#define DB_SET_RANGE 30 /* c_get() */#define DB_SET_RECNO 31 /* get(), c_get() */#define DB_SET_TXN_NOW 32 /* set_timout() (internal) */#define DB_SET_TXN_TIMEOUT 33 /* set_timout() */#define DB_UPDATE_SECONDARY 34 /* c_get(), c_del() (internal) */#define DB_WRITECURSOR 35 /* cursor() */#define DB_WRITELOCK 36 /* cursor() (internal) *//* This has to change when the max opcode hits 255. */#define DB_OPFLAGS_MASK 0x000000ff /* Mask for operations flags. *//* * Masks for flags that can be OR'd into DB access method and cursor * operation values. * * DB_DIRTY_READ 0x04000000 Dirty Read. */#define DB_MULTIPLE 0x08000000 /* Return multiple data values. */#define DB_MULTIPLE_KEY 0x10000000 /* Return multiple data/key pairs. */#define DB_RMW 0x20000000 /* Acquire write flag immediately. *//* * DB (user visible) error return codes. * * !!! * For source compatibility with DB 2.X deadlock return (EAGAIN), use the * following: * #include <errno.h> * #define DB_LOCK_DEADLOCK EAGAIN * * !!! * 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_KEYEMPTY (-30997)/* Key/data deleted or never created. */#define DB_KEYEXIST (-30996)/* The key/data pair already exists. */#define DB_LOCK_DEADLOCK (-30995)/* Deadlock. */#define DB_LOCK_NOTGRANTED (-30994)/* Lock unavailable. */#define DB_LOG_BUFFER_FULL (-30993)/* In-memory log buffer full. */#define DB_NOSERVER (-30992)/* Server panic return. */#define DB_NOSERVER_HOME (-30991)/* Bad home sent to server. */#define DB_NOSERVER_ID (-30990)/* Bad ID sent to server. */#define DB_NOTFOUND (-30989)/* Key/data pair not found (EOF). */#define DB_OLD_VERSION (-30988)/* Out-of-date version. */#define DB_PAGE_NOTFOUND (-30987)/* Requested page not found. */#define DB_REP_DUPMASTER (-30986)/* There are two masters. */#define DB_REP_HANDLE_DEAD (-30985)/* Rolled back a commit. */#define DB_REP_HOLDELECTION (-30984)/* Time to hold an election. */#define DB_REP_ISPERM (-30983)/* Cached not written perm written.*/#define DB_REP_NEWMASTER (-30982)/* We have learned of a new master. */#define DB_REP_NEWSITE (-30981)/* New site entered system. */#define DB_REP_NOTPERM (-30980)/* Permanent log record not written. */#define DB_REP_STARTUPDONE (-30979)/* Client startup complete. */#define DB_REP_UNAVAIL (-30978)/* Site cannot currently be reached. */#define DB_RUNRECOVERY (-30977)/* Panic return. */#define DB_SECONDARY_BAD (-30976)/* Secondary index corrupt. */#define DB_VERIFY_BAD (-30975)/* Verify failed; bad format. */#define DB_VERSION_MISMATCH (-30974)/* Environment version mismatch. *//* DB (private) error return codes. */#define DB_ALREADY_ABORTED (-30899)#define DB_DELETED (-30898)/* Recovery file marked deleted. */#define DB_LOCK_NOTEXIST (-30897)/* Object to lock is gone. */#define DB_NEEDSPLIT (-30896)/* Page needs to be split. */#define DB_REP_EGENCHG (-30895)/* Egen changed while in election. */#define DB_REP_LOGREADY (-30894)/* Rep log ready for recovery. */#define DB_REP_PAGEDONE (-30893)/* This page was already done. */#define DB_SURPRISE_KID (-30892)/* Child commit where parent didn't know it was a parent. */#define DB_SWAPBYTES (-30891)/* Database needs byte swapping. */#define DB_TIMEOUT (-30890)/* Timed out waiting for election. */#define DB_TXN_CKP (-30889)/* Encountered ckp record in log. */#define DB_VERIFY_FATAL (-30888)/* DB->verify cannot proceed. *//* Database handle. */struct __db { /******************************************************* * Public: owned by the application. *******************************************************/ u_int32_t pgsize; /* Database logical page size. */ /* Callbacks. */ int (*db_append_recno) __P((DB *, DBT *, db_recno_t)); void (*db_feedback) __P((DB *, int, int)); int (*dup_compare) __P((DB *, const DBT *, const DBT *)); void *app_private; /* Application-private handle. */ /******************************************************* * Private: owned by DB. *******************************************************/ DB_ENV *dbenv; /* Backing environment. */ DBTYPE type; /* DB access method type. */ DB_MPOOLFILE *mpf; /* Backing buffer pool. */ DB_MUTEX *mutexp; /* Synchronization for free threading */ char *fname, *dname; /* File/database passed to DB->open. */ u_int32_t open_flags; /* Flags passed to DB->open. */ u_int8_t fileid[DB_FILE_ID_LEN];/* File's unique ID for locking. */ u_int32_t adj_fileid; /* File's unique ID for curs. adj. */#define DB_LOGFILEID_INVALID -1 FNAME *log_filename; /* File's naming info for logging. */ db_pgno_t meta_pgno; /* Meta page number */ u_int32_t lid; /* Locker id for handle locking. */ u_int32_t cur_lid; /* Current handle lock holder. */ u_int32_t associate_lid; /* Locker id for DB->associate call. */ DB_LOCK handle_lock; /* Lock held on this handle. */ u_int cl_id; /* RPC: remote client id. */ time_t timestamp; /* Handle timestamp for replication. */ /* * Returned data memory for DB->get() and friends. */ DBT my_rskey; /* Secondary key. */ DBT my_rkey; /* [Primary] key. */ DBT my_rdata; /* Data. */ /* * !!! * Some applications use DB but implement their own locking outside of * DB. If they're using fcntl(2) locking on the underlying database * file, and we open and close a file descriptor for that file, we will * discard their locks. The DB_FCNTL_LOCKING flag to DB->open is an * undocumented interface to support this usage which leaves any file * descriptors we open until DB->close. This will only work with the * DB->open interface and simple caches, e.g., creating a transaction * thread may open/close file descriptors this flag doesn't protect. * Locking with fcntl(2) on a file that you don't own is a very, very * unsafe thing to do. 'Nuff said. */ DB_FH *saved_open_fhp; /* Saved file handle. */ /* * Linked list of DBP's, linked from the DB_ENV, used to keep track * of all open db handles for cursor adjustment. * * !!! * Explicit representations of structures from queue.h. * LIST_ENTRY(__db) dblistlinks; */ struct { struct __db *le_next; struct __db **le_prev; } dblistlinks; /* * Cursor queues. * * !!! * Explicit representations of structures from queue.h. * TAILQ_HEAD(__cq_fq, __dbc) free_queue; * TAILQ_HEAD(__cq_aq, __dbc) active_queue; * TAILQ_HEAD(__cq_jq, __dbc) join_queue;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -