* 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;
* Secondary index support.
* Linked list of secondary indices -- set in the primary.
* Explicit representations of structures from queue.h.
* LIST_HEAD(s_secondaries, __db);
* List entries for secondaries, and reference count of how many
* threads are updating this secondary (see Dbc.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;
/* 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. */
#define DB_ASSOC_IMMUTABLE_KEY 0x00000001 /* Secondary key is immutable. */
#define DB_ASSOC_CREATE 0x00000002 /* Secondary db populated on open. */
/* Flags passed to associate -- set in the secondary. */
* Linked list of primary dbs -- set in the foreign db
* Explicit representations of structures from queue.h.
* LIST_HEAD(f_primaries, __db);
struct __db_foreign_info *lh_first;
* Explicit representations of structures from queue.h.
* TAILQ_ENTRY(__db) felink;
* Links in a list of DBs involved in file extension
* during a transaction. These are to be used only while the
/* Reference to foreign -- set in the secondary. */
/* API-private structure: used by DB 1.85, C++, Java, Perl and Tcl */
/* Subsystem-private structure. */
void *bt_internal; /* Btree/Recno access method. */
void *h_internal; /* Hash access method. */
void *heap_internal; /* Heap access method. */
void *p_internal; /* Partition informaiton. */
void *q_internal; /* Queue access method. */
/* DB PUBLIC HANDLE LIST BEGIN */
int (*associate) __P((DB *, DB_TXN *, DB *,
int (*)(DB *, const DBT *, const DBT *, DBT *), u_int32_t));
int (*associate_foreign) __P((DB *, DB *,
int (*)(DB *, const DBT *, DBT *, const DBT *, int *),
int (*close) __P((DB *, u_int32_t));
int (*compact) __P((DB *,
DB_TXN *, DBT *, DBT *, DB_COMPACT *, u_int32_t, DBT *));
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 (*exists) __P((DB *, DB_TXN *, DBT *, u_int32_t));
int (*fd) __P((DB *, int *));
int (*get) __P((DB *, DB_TXN *, DBT *, DBT *, u_int32_t));
int (*get_alloc) __P((DB *, void *(**)(size_t),
void *(**)(void *, size_t), void (**)(void *)));
int (*get_append_recno) __P((DB *, int (**)(DB *, DBT *, db_recno_t)));
int (*get_assoc_flags) __P((DB *, u_int32_t *));
__P((DB *, int (**)(DB *, const DBT *, const DBT *)));
int (*get_bt_compress) __P((DB *,
const DBT *, const DBT *, const DBT *, const DBT *, DBT *),
int (**)(DB *, const DBT *, const DBT *, DBT *, DBT *, DBT *)));
int (*get_bt_minkey) __P((DB *, u_int32_t *));
__P((DB *, size_t (**)(DB *, const DBT *, const DBT *)));
int (*get_byteswapped) __P((DB *, int *));
int (*get_cachesize) __P((DB *, u_int32_t *, u_int32_t *, int *));
int (*get_create_dir) __P((DB *, const char **));
int (*get_dbname) __P((DB *, const char **, const char **));
__P((DB *, int (**)(DB *, const DBT *, const DBT *)));
int (*get_encrypt_flags) __P((DB *, u_int32_t *));
DB_ENV *(*get_env) __P((DB *));
void (*get_errcall) __P((DB *,
void (**)(const DB_ENV *, const char *, const char *)));
void (*get_errfile) __P((DB *, FILE **));
void (*get_errpfx) __P((DB *, const char **));
int (*get_feedback) __P((DB *, void (**)(DB *, int, int)));
int (*get_flags) __P((DB *, u_int32_t *));
__P((DB *, int (**)(DB *, const DBT *, const DBT *)));
int (*get_h_ffactor) __P((DB *, u_int32_t *));
__P((DB *, u_int32_t (**)(DB *, const void *, u_int32_t)));
int (*get_h_nelem) __P((DB *, u_int32_t *));
int (*get_heapsize) __P((DB *, u_int32_t *, u_int32_t *));
int (*get_heap_regionsize) __P((DB *, u_int32_t *));
int (*get_lk_exclusive) __P((DB *, int *, int *));
int (*get_lorder) __P((DB *, int *));
DB_MPOOLFILE *(*get_mpf) __P((DB *));
void (*get_msgcall) __P((DB *,
void (**)(const DB_ENV *, const char *)));
void (*get_msgfile) __P((DB *, FILE **));
int (*get_multiple) __P((DB *));
int (*get_open_flags) __P((DB *, u_int32_t *));
int (*get_pagesize) __P((DB *, u_int32_t *));
int (*get_partition_callback) __P((DB *,
u_int32_t *, u_int32_t (**)(DB *, DBT *key)));
int (*get_partition_dirs) __P((DB *, const char ***));
int (*get_partition_keys) __P((DB *, u_int32_t *, DBT **));
int (*get_priority) __P((DB *, DB_CACHE_PRIORITY *));
int (*get_q_extentsize) __P((DB *, u_int32_t *));
int (*get_re_delim) __P((DB *, int *));
int (*get_re_len) __P((DB *, u_int32_t *));
int (*get_re_pad) __P((DB *, int *));
int (*get_re_source) __P((DB *, const char **));
int (*get_transactional) __P((DB *));
int (*get_type) __P((DB *, DBTYPE *));
int (*join) __P((DB *, DBC **, DBC **, u_int32_t));
__P((DB *, DB_TXN *, DBT *, DB_KEY_RANGE *, u_int32_t));
DB_TXN *, const char *, const char *, DBTYPE, u_int32_t, int));
int (*pget) __P((DB *, DB_TXN *, DBT *, DBT *, DBT *, u_int32_t));
int (*put) __P((DB *, DB_TXN *, DBT *, DBT *, u_int32_t));
int (*remove) __P((DB *, const char *, const char *, u_int32_t));
const char *, const char *, const char *, u_int32_t));
int (*set_alloc) __P((DB *, void *(*)(size_t),
void *(*)(void *, size_t), void (*)(void *)));
int (*set_append_recno) __P((DB *, int (*)(DB *, DBT *, db_recno_t)));
__P((DB *, int (*)(DB *, const DBT *, const DBT *)));
int (*set_bt_compress) __P((DB *,
int (*)(DB *, const DBT *, const DBT *, const DBT *, const DBT *, DBT *),
int (*)(DB *, const DBT *, const DBT *, DBT *, DBT *, DBT *)));
int (*set_bt_minkey) __P((DB *, u_int32_t));
__P((DB *, size_t (*)(DB *, const DBT *, const DBT *)));
int (*set_cachesize) __P((DB *, u_int32_t, u_int32_t, int));
int (*set_create_dir) __P((DB *, const char *));
__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 DB_ENV *, const char *, const 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));
__P((DB *, int (*)(DB *, const DBT *, const DBT *)));
int (*set_h_ffactor) __P((DB *, u_int32_t));
__P((DB *, u_int32_t (*)(DB *, const void *, u_int32_t)));
int (*set_h_nelem) __P((DB *, u_int32_t));
int (*set_heapsize) __P((DB *, u_int32_t, u_int32_t, u_int32_t));
int (*set_heap_regionsize) __P((DB *, u_int32_t));
int (*set_lk_exclusive) __P((DB *, int));
int (*set_lorder) __P((DB *, int));
void (*set_msgcall) __P((DB *, void (*)(const DB_ENV *, const char *)));
void (*set_msgfile) __P((DB *, FILE *));
int (*set_pagesize) __P((DB *, u_int32_t));
int (*set_paniccall) __P((DB *, void (*)(DB_ENV *, int)));
int (*set_partition) __P((DB *,
u_int32_t, DBT *, u_int32_t (*)(DB *, DBT *key)));
int (*set_partition_dirs) __P((DB *, const char **));
int (*set_priority) __P((DB *, DB_CACHE_PRIORITY));
int (*set_q_extentsize) __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 (*sort_multiple) __P((DB *, DBT *, DBT *, u_int32_t));
int (*stat) __P((DB *, DB_TXN *, void *, u_int32_t));
int (*stat_print) __P((DB *, u_int32_t));
int (*sync) __P((DB *, u_int32_t));
int (*truncate) __P((DB *, DB_TXN *, u_int32_t *, u_int32_t));
int (*upgrade) __P((DB *, const char *, u_int32_t));
__P((DB *, const char *, const char *, FILE *, u_int32_t));
/* DB PUBLIC HANDLE LIST END */
/* DB PRIVATE HANDLE LIST BEGIN */
int (*dump) __P((DB *, const char *,
int (*)(void *, const void *), void *, int, int));
int (*db_am_remove) __P((DB *, DB_THREAD_INFO *,
DB_TXN *, const char *, const char *, u_int32_t));
int (*db_am_rename) __P((DB *, DB_THREAD_INFO *,
DB_TXN *, const char *, const char *, const char *));
/* DB PRIVATE HANDLE LIST END */
* 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));
/* Alternative handle close function, used by C++ API. */
int (*alt_close) __P((DB *, u_int32_t));
u_int32_t am_ok; /* Legal AM choices. */
* This field really ought to be an AM_FLAG, but we have
* have run out of bits. If/when we decide to split up
* the flags, we can incorporate it.
int preserve_fid; /* Do not free fileid on close. */
#define DB_AM_CHKSUM 0x00000001 /* Checksumming */
#define DB_AM_COMPENSATE 0x00000002 /* Created by compensating txn */
#define DB_AM_COMPRESS 0x00000004 /* Compressed BTree */
#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_DISCARD 0x00000080 /* Discard any cached pages */
#define DB_AM_DUP 0x00000100 /* DB_DUP */
#define DB_AM_DUPSORT 0x00000200 /* DB_DUPSORT */
#define DB_AM_ENCRYPT 0x00000400 /* Encryption */
#define DB_AM_FIXEDLEN 0x00000800 /* Fixed-length records */
#define DB_AM_INMEM 0x00001000 /* In-memory; no sync on close */
#define DB_AM_INORDER 0x00002000 /* DB_INORDER */
#define DB_AM_IN_RENAME 0x00004000 /* File is being renamed */
#define DB_AM_NOT_DURABLE 0x00008000 /* Do not log changes */
#define DB_AM_OPEN_CALLED 0x00010000 /* DB->open called */
#define DB_AM_PAD 0x00020000 /* Fixed-length record pad */
#define DB_AM_PARTDB 0x00040000 /* Handle for a database partition */
#define DB_AM_PGDEF 0x00080000 /* Page size was defaulted */
#define DB_AM_RDONLY 0x00100000 /* Database is readonly */
#define DB_AM_READ_UNCOMMITTED 0x00200000 /* Support degree 1 isolation */
#define DB_AM_RECNUM 0x00400000 /* DB_RECNUM */
#define DB_AM_RECOVER 0x00800000 /* DB opened by recovery routine */
#define DB_AM_RENUMBER 0x01000000 /* DB_RENUMBER */
#define DB_AM_REVSPLITOFF 0x02000000 /* DB_REVSPLITOFF */
#define DB_AM_SECONDARY 0x04000000 /* Database is a secondary index */
#define DB_AM_SNAPSHOT 0x08000000 /* DB_SNAPSHOT */
#define DB_AM_SUBDB 0x10000000 /* Subdatabases supported */
#define DB_AM_SWAP 0x20000000 /* Pages need to be byte-swapped */
#define DB_AM_TXN 0x40000000 /* Opened in a transaction */
#define DB_AM_VERIFYING 0x80000000 /* DB handle is in the verifier */
u_int32_t orig_flags; /* Flags at open, for refresh */
#define DB2_AM_EXCL 0x00000001 /* Exclusively lock the handle */
#define DB2_AM_INTEXCL 0x00000002 /* Internal exclusive lock. */
#define DB2_AM_NOWAIT 0x00000004 /* Do not wait for handle lock */
u_int32_t orig_flags2; /* Second flags word; for refresh */
u_int32_t flags2; /* Second flags word */
* Macros for bulk operations. These are only intended for the C API.
* For C++, use DbMultiple*Iterator or DbMultiple*Builder.
* Bulk operations store multiple entries into a single DBT structure. The
* following macros assist with creating and reading these Multiple DBTs.
* The basic layout for single data items is:
* -------------------------------------------------------------------------
* | data1 | ... | dataN | ..... |-1 | dNLen | dNOff | ... | d1Len | d1Off |
* -------------------------------------------------------------------------
* For the DB_MULTIPLE_KEY* macros, the items are in key/data pairs, so data1
* would be a key, and data2 its corresponding value (N is always even).
* For the DB_MULTIPLE_RECNO* macros, the record number is stored along with
* the len/off pair in the "header" section, and the list is zero terminated
* (since -1 is a valid record number):
* --------------------------------------------------------------------------
* | d1 |..| dN |..| 0 | dNLen | dNOff | recnoN |..| d1Len | d1Off | recno1 |
* --------------------------------------------------------------------------
#define DB_MULTIPLE_INIT(pointer, dbt) \
(pointer = (u_int8_t *)(dbt)->data + \
(dbt)->ulen - sizeof(u_int32_t))
#define DB_MULTIPLE_NEXT(pointer, dbt, retdata, retdlen) \
u_int32_t *__p = (u_int32_t *)(pointer); \
if (*__p == (u_int32_t)-1) { \
retdata = (u_int8_t *)(dbt)->data + *__p--; \
if (retdlen == 0 && retdata == (u_int8_t *)(dbt)->data) \
#define DB_MULTIPLE_KEY_NEXT(pointer, dbt, retkey, retklen, retdata, retdlen) \
u_int32_t *__p = (u_int32_t *)(pointer); \
if (*__p == (u_int32_t)-1) { \
retkey = (u_int8_t *)(dbt)->data + *__p--; \
retdata = (u_int8_t *)(dbt)->data + *__p--; \
#define DB_MULTIPLE_RECNO_NEXT(pointer, dbt, recno, retdata, retdlen) \
u_int32_t *__p = (u_int32_t *)(pointer); \
if (*__p == (u_int32_t)0) { \
retdata = (u_int8_t *)(dbt)->data + *__p--; \
#define DB_MULTIPLE_WRITE_INIT(pointer, dbt) \
(dbt)->flags |= DB_DBT_BULK; \
pointer = (u_int8_t *)(dbt)->data + \
(dbt)->ulen - sizeof(u_int32_t); \
*(u_int32_t *)(pointer) = (u_int32_t)-1; \
#define DB_MULTIPLE_RESERVE_NEXT(pointer, dbt, writedata, writedlen) \
u_int32_t *__p = (u_int32_t *)(pointer); \
u_int32_t __off = ((pointer) == (u_int8_t *)(dbt)->data +\
(dbt)->ulen - sizeof(u_int32_t)) ? 0 : __p[1] + __p[2];\
if ((u_int8_t *)(dbt)->data + __off + (writedlen) > \
writedata = (u_int8_t *)(dbt)->data + __off; \
__p[-1] = (u_int32_t)(writedlen); \
__p[-2] = (u_int32_t)-1; \
#define DB_MULTIPLE_WRITE_NEXT(pointer, dbt, writedata, writedlen) \
DB_MULTIPLE_RESERVE_NEXT((pointer), (dbt), \
memcpy(__destd, (writedata), (writedlen)); \
#define DB_MULTIPLE_KEY_RESERVE_NEXT(pointer, dbt, writekey, writeklen, writedata, writedlen) \
u_int32_t *__p = (u_int32_t *)(pointer); \
u_int32_t __off = ((pointer) == (u_int8_t *)(dbt)->data +\
(dbt)->ulen - sizeof(u_int32_t)) ? 0 : __p[1] + __p[2];\
if ((u_int8_t *)(dbt)->data + __off + (writeklen) + \
(writedlen) > (u_int8_t *)(__p - 4)) { \
writekey = (u_int8_t *)(dbt)->data + __off; \
__p[-1] = (u_int32_t)(writeklen); \
__off += (u_int32_t)(writeklen); \
writedata = (u_int8_t *)(dbt)->data + __off; \
__p[-1] = (u_int32_t)(writedlen); \
__p[-2] = (u_int32_t)-1; \
#define DB_MULTIPLE_KEY_WRITE_NEXT(pointer, dbt, writekey, writeklen, writedata, writedlen) \
void *__destk, *__destd; \
DB_MULTIPLE_KEY_RESERVE_NEXT((pointer), (dbt), \
__destk, (writeklen), __destd, (writedlen)); \
memcpy(__destk, (writekey), (writeklen)); \
memcpy(__destd, (writedata), (writedlen));\
#define DB_MULTIPLE_RECNO_WRITE_INIT(pointer, dbt) \
(dbt)->flags |= DB_DBT_BULK; \
pointer = (u_int8_t *)(dbt)->data + \
(dbt)->ulen - sizeof(u_int32_t); \
*(u_int32_t *)(pointer) = 0; \
#define DB_MULTIPLE_RECNO_RESERVE_NEXT(pointer, dbt, recno, writedata, writedlen) \
u_int32_t *__p = (u_int32_t *)(pointer); \
u_int32_t __off = ((pointer) == (u_int8_t *)(dbt)->data +\
(dbt)->ulen - sizeof(u_int32_t)) ? 0 : __p[1] + __p[2]; \
if (((u_int8_t *)(dbt)->data + __off) + (writedlen) > \
writedata = (u_int8_t *)(dbt)->data + __off; \
__p[0] = (u_int32_t)(recno); \
__p[-2] = (u_int32_t)(writedlen); \
#define DB_MULTIPLE_RECNO_WRITE_NEXT(pointer, dbt, recno, writedata, writedlen)\
DB_MULTIPLE_RECNO_RESERVE_NEXT((pointer), (dbt), \
(recno), __destd, (writedlen)); \
else if ((writedlen) != 0) \
memcpy(__destd, (writedata), (writedlen)); \