📄 db.in
字号:
#define DB_DELETED (-30898)/* Recovery file marked deleted. */#define DB_JAVA_CALLBACK (-30897)/* Exception during a java callback. */#define DB_LOCK_NOTEXIST (-30896)/* Object to lock is gone. */#define DB_NEEDSPLIT (-30895)/* Page needs to be split. */#define DB_SURPRISE_KID (-30894)/* Child commit where parent didn't know it was a parent. */#define DB_SWAPBYTES (-30893)/* Database needs byte swapping. */#define DB_TIMEOUT (-30892)/* Timed out waiting for election. */#define DB_TXN_CKP (-30891)/* Encountered ckp record in log. */#define DB_VERIFY_FATAL (-30890)/* 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_CACHE_PRIORITY priority; /* Priority in the buffer pool. */ DB_MUTEX *mutexp; /* Synchronization for free threading */ 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. */ long cl_id; /* RPC: remote client id. */ /* * 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; */ struct __cq_fq { struct __dbc *tqh_first; struct __dbc **tqh_last; } free_queue; struct __cq_aq { struct __dbc *tqh_first; struct __dbc **tqh_last; } active_queue; struct __cq_jq { struct __dbc *tqh_first; struct __dbc **tqh_last; } join_queue; /* * Secondary index support. * * Linked list of secondary indices -- set in the primary. * * !!! * Explicit representations of structures from queue.h. * LIST_HEAD(s_secondaries, __db); */ struct { struct __db *lh_first; } s_secondaries; /* * List entries for secondaries, and reference count of how * many threads are updating this secondary (see __db_c_put). * * !!! * Note that these are synchronized by the primary's mutex, but * filled in in the secondaries. * * !!! * Explicit representations of structures from queue.h. * LIST_ENTRY(__db) s_links; */ struct { struct __db *le_next; struct __db **le_prev; } s_links; u_int32_t s_refcnt; /* Secondary callback and free functions -- set in the secondary. */ int (*s_callback) __P((DB *, const DBT *, const DBT *, DBT *)); /* Reference to primary -- set in the secondary. */ DB *s_primary; /* API-private structure: used by DB 1.85, C++, Java, Perl and Tcl */ void *api_internal; /* Subsystem-private structure. */ void *bt_internal; /* Btree/Recno access method. */ void *h_internal; /* Hash access method. */ void *q_internal; /* Queue access method. */ void *xa_internal; /* XA. */ /* Methods. */ int (*associate) __P((DB *, DB_TXN *, DB *, int (*)(DB *, const DBT *, const DBT *, DBT *), u_int32_t)); int (*close) __P((DB *, u_int32_t)); int (*cursor) __P((DB *, DB_TXN *, DBC **, u_int32_t)); int (*del) __P((DB *, DB_TXN *, DBT *, u_int32_t)); void (*err) __P((DB *, int, const char *, ...)); void (*errx) __P((DB *, const char *, ...)); int (*fd) __P((DB *, int *)); int (*get) __P((DB *, DB_TXN *, DBT *, DBT *, u_int32_t)); int (*pget) __P((DB *, DB_TXN *, DBT *, DBT *, DBT *, u_int32_t)); int (*get_byteswapped) __P((DB *, int *)); int (*get_type) __P((DB *, DBTYPE *)); int (*join) __P((DB *, DBC **, DBC **, u_int32_t)); int (*key_range) __P((DB *, DB_TXN *, DBT *, DB_KEY_RANGE *, u_int32_t)); int (*open) __P((DB *, DB_TXN *, const char *, const char *, DBTYPE, u_int32_t, int)); int (*put) __P((DB *, DB_TXN *, DBT *, DBT *, u_int32_t)); int (*remove) __P((DB *, const char *, const char *, u_int32_t)); int (*rename) __P((DB *, const char *, const char *, const char *, u_int32_t)); int (*truncate) __P((DB *, DB_TXN *, u_int32_t *, u_int32_t)); int (*set_append_recno) __P((DB *, int (*)(DB *, DBT *, db_recno_t))); int (*set_alloc) __P((DB *, void *(*)(size_t), void *(*)(void *, size_t), void (*)(void *))); int (*set_cachesize) __P((DB *, u_int32_t, u_int32_t, int)); int (*set_cache_priority) __P((DB *, DB_CACHE_PRIORITY)); int (*set_dup_compare) __P((DB *, int (*)(DB *, const DBT *, const DBT *))); int (*set_encrypt) __P((DB *, const char *, u_int32_t)); void (*set_errcall) __P((DB *, void (*)(const char *, char *))); void (*set_errfile) __P((DB *, FILE *)); void (*set_errpfx) __P((DB *, const char *)); int (*set_feedback) __P((DB *, void (*)(DB *, int, int))); int (*set_flags) __P((DB *, u_int32_t)); int (*set_lorder) __P((DB *, int)); int (*set_pagesize) __P((DB *, u_int32_t)); int (*set_paniccall) __P((DB *, void (*)(DB_ENV *, int))); int (*stat) __P((DB *, void *, u_int32_t)); int (*sync) __P((DB *, u_int32_t)); int (*upgrade) __P((DB *, const char *, u_int32_t)); int (*verify) __P((DB *, const char *, const char *, FILE *, u_int32_t)); int (*set_bt_compare) __P((DB *, int (*)(DB *, const DBT *, const DBT *))); int (*set_bt_maxkey) __P((DB *, u_int32_t)); int (*set_bt_minkey) __P((DB *, u_int32_t)); int (*set_bt_prefix) __P((DB *, size_t (*)(DB *, const DBT *, const DBT *))); int (*set_h_ffactor) __P((DB *, u_int32_t)); int (*set_h_hash) __P((DB *, u_int32_t (*)(DB *, const void *, u_int32_t))); int (*set_h_nelem) __P((DB *, u_int32_t)); int (*set_re_delim) __P((DB *, int)); int (*set_re_len) __P((DB *, u_int32_t)); int (*set_re_pad) __P((DB *, int)); int (*set_re_source) __P((DB *, const char *)); int (*set_q_extentsize) __P((DB *, u_int32_t)); int (*db_am_remove) __P((DB *, DB_TXN *, const char *, const char *, DB_LSN *)); int (*db_am_rename) __P((DB *, DB_TXN *, const char *, const char *, const char *)); /* * Never called; these are a place to save function pointers * so that we can undo an associate. */ int (*stored_get) __P((DB *, DB_TXN *, DBT *, DBT *, u_int32_t)); int (*stored_close) __P((DB *, u_int32_t));#define DB_OK_BTREE 0x01#define DB_OK_HASH 0x02#define DB_OK_QUEUE 0x04#define DB_OK_RECNO 0x08 u_int32_t am_ok; /* Legal AM choices. */#define DB_AM_CHKSUM 0x00000001 /* Checksumming. */#define DB_AM_CL_WRITER 0x00000002 /* Allow writes in client replica. */#define DB_AM_COMPENSATE 0x00000004 /* Created by compensating txn. */#define DB_AM_CREATED 0x00000008 /* Database was created upon open. */#define DB_AM_CREATED_MSTR 0x00000010 /* Encompassing file was created. */#define DB_AM_DBM_ERROR 0x00000020 /* Error in DBM/NDBM database. */#define DB_AM_DELIMITER 0x00000040 /* Variable length delimiter set. */#define DB_AM_DIRTY 0x00000080 /* Support Dirty Reads. */#define DB_AM_DISCARD 0x00000100 /* Discard any cached pages. */#define DB_AM_DUP 0x00000200 /* DB_DUP. */#define DB_AM_DUPSORT 0x00000400 /* DB_DUPSORT. */#define DB_AM_ENCRYPT 0x00000800 /* Encryption. */#define DB_AM_FIXEDLEN 0x00001000 /* Fixed-length records. */#define DB_AM_INMEM 0x00002000 /* In-memory; no sync on close. */#define DB_AM_IN_RENAME 0x00004000 /* File is being renamed. */#define DB_AM_OPEN_CALLED 0x00008000 /* DB->open called. */#define DB_AM_PAD 0x00010000 /* Fixed-length record pad. */#define DB_AM_PGDEF 0x00020000 /* Page size was defaulted. */#define DB_AM_RDONLY 0x00040000 /* Database is readonly. */#define DB_AM_RECNUM 0x00080000 /* DB_RECNUM. */#define DB_AM_RECOVER 0x00100000 /* DB opened by recovery routine. */#define DB_AM_RENUMBER 0x00200000 /* DB_RENUMBER. */#define DB_AM_REVSPLITOFF 0x00400000 /* DB_REVSPLITOFF. */#define DB_AM_SECONDARY 0x00800000 /* Database is a secondary index. */#define DB_AM_SNAPSHOT 0x01000000 /* DB_SNAPSHOT. */#define DB_AM_SUBDB 0x02000000 /* Subdatabases supported. */#define DB_AM_SWAP 0x04000000 /* Pages need to be byte-swapped. */#define DB_AM_TXN 0x08000000 /* Opened in a transaction. */#define DB_AM_VERIFYING 0x10000000 /* DB handle is in the verifier. */ u_int32_t flags;};/* * Macros for bulk get. Note that wherever we use a DBT *, we explicitly * cast it; this allows the same macros to work with C++ Dbt *'s, as Dbt * is a subclass of struct DBT in C++. */#define DB_MULTIPLE_INIT(pointer, dbt) \ (pointer = (u_int8_t *)((DBT *)(dbt))->data + \ ((DBT *)(dbt))->ulen - sizeof(u_int32_t))#define DB_MULTIPLE_NEXT(pointer, dbt, retdata, retdlen) \ do { \ if (*((u_int32_t *)(pointer)) == (u_int32_t)-1) { \ retdata = NULL; \ pointer = NULL; \ break; \ } \ retdata = (u_int8_t *) \ ((DBT *)(dbt))->data + *(u_int32_t *)(pointer); \ (pointer) = (u_int32_t *)(pointer) - 1; \ retdlen = *(u_int32_t *)(pointer); \ (pointer) = (u_int32_t *)(pointer) - 1; \ if (retdlen == 0 && \ retdata == (u_int8_t *)((DBT *)(dbt))->data) \ retdata = NULL; \ } while (0)#define DB_MULTIPLE_KEY_NEXT(pointer, dbt, retkey, retklen, retdata, retdlen) \ do { \ if (*((u_int32_t *)(pointer)) == (u_int32_t)-1) { \ retdata = NULL; \ retkey = NULL; \ pointer = NULL; \ break; \ } \ retkey = (u_int8_t *) \ ((DBT *)(dbt))->data + *(u_int32_t *)(pointer); \ (pointer) = (u_int32_t *)(pointer) - 1; \ retklen = *(u_int32_t *)(pointer); \ (pointer) = (u_int32_t *)(pointer) - 1; \ retdata = (u_int8_t *) \ ((DBT *)(dbt))->data + *(u_int32_t *)(pointer); \ (pointer) = (u_int32_t *)(pointer) - 1; \ retdlen = *(u_int32_t *)(pointer); \ (pointer) = (u_int32_t *)(pointer) - 1; \ } while (0)#define DB_MULTIPLE_RECNO_NEXT(pointer, dbt, recno, retdata, retdlen) \ do { \ if (*((u_int32_t *)(pointer)) == (u_int32_t)0) { \ recno = 0; \ retdata = NULL; \ pointer = NULL; \ break; \ } \ recno = *(u_int32_t *)(pointer); \ (pointer) = (u_int32_t *)(pointer) - 1; \ retdata = (u_int8_t *) \ ((DBT *)(dbt))->data + *(u_int32_t *)(pointer); \ (pointer) = (u_int32_t *)(pointer) - 1; \ retdlen = *(u_int32_t *)(pointer); \ (pointer) = (u_int32_t *)(pointer) - 1; \ } while (0)/******************************************************* * Access method cursors. *******************************************************/struct __dbc { DB *dbp; /* Related DB access method. */ DB_TXN *txn; /* Associated transaction. */ /* * Active/free cursor queues. *
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -