1 /* DO NOT EDIT: automatically built by dist/s_vxworks. */
3 * See the file LICENSE for redistribution information.
5 * Copyright (c) 1996, 2012 Oracle and/or its affiliates. All rights reserved.
9 * db.h include file layout:
11 * Database Environment.
14 * Shared buffer cache (mpool) subsystem.
15 * Transaction subsystem.
17 * Access method cursors.
18 * Dbm/Ndbm, Hsearch historic interfaces.
24 #ifndef __NO_SYSTEM_INCLUDES
25 #include <sys/types.h>
30 #if defined(__cplusplus)
34 /* Tornado 2 does not provide a standard C pre-processor #define. */
41 #define __P(protos) protos
44 * Berkeley DB version information.
46 #define DB_VERSION_FAMILY 11
47 #define DB_VERSION_RELEASE 2
48 #define DB_VERSION_MAJOR 5
49 #define DB_VERSION_MINOR 3
50 #define DB_VERSION_PATCH 21
51 #define DB_VERSION_STRING "Berkeley DB 5.3.21: (May 11, 2012)"
52 #define DB_VERSION_FULL_STRING "Berkeley DB 11g Release 2, library version 11.2.5.3.21: (May 11, 2012)"
56 * Berkeley DB uses specifically sized types. If they're not provided by
57 * the system, typedef them here.
59 * We protect them against multiple inclusion using __BIT_TYPES_DEFINED__,
60 * as does BIND and Kerberos, since we don't know for sure what #include
61 * files the user is using.
64 * We also provide the standard u_int, u_long etc., if they're not provided
67 #ifndef __BIT_TYPES_DEFINED__
68 #define __BIT_TYPES_DEFINED__
69 typedef unsigned char u_int8_t;
70 typedef unsigned short u_int16_t;
71 typedef unsigned int u_int32_t;
73 typedef unsigned long long u_int64_t;
81 * Largest unsigned type, used to align structures in memory. We don't store
82 * floating point types in structures, so integral types should be sufficient
83 * (and we don't have to worry about systems that store floats in other than
84 * power-of-2 numbers of bytes). Additionally this fixes compilers that rewrite
85 * structure assignments and ANSI C memcpy calls to be in-line instructions
86 * that happen to require alignment.
89 * Unsigned type that's the same size as a pointer. There are places where
90 * DB modifies pointers by discarding the bottom bits to guarantee alignment.
91 * We can't use uintmax_t, it may be larger than the pointer, and compilers
92 * get upset about that. So far we haven't run on any machine where there's
93 * no unsigned type the same size as a pointer -- here's hoping.
95 typedef unsigned long uintmax_t;
96 typedef unsigned long uintptr_t;
98 #ifdef HAVE_MIXED_SIZE_ADDRESSING
99 typedef u_int32_t db_size_t;
101 typedef size_t db_size_t;
103 #ifdef HAVE_MIXED_SIZE_ADDRESSING
104 typedef int32_t db_ssize_t;
106 typedef ssize_t db_ssize_t;
110 * Sequences are only available on machines with 64-bit integral types.
112 typedef int db_seq_t;
114 /* Thread and process identification. */
115 typedef uintmax_t db_threadid_t;
117 /* Basic types that are exported or quasi-exported. */
118 typedef u_int32_t db_pgno_t; /* Page number type. */
119 typedef u_int16_t db_indx_t; /* Page offset type. */
120 #define DB_MAX_PAGES 0xffffffff /* >= # of pages in a file */
122 typedef u_int32_t db_recno_t; /* Record number type. */
123 #define DB_MAX_RECORDS 0xffffffff /* >= # of records in a tree */
125 typedef u_int32_t db_timeout_t; /* Type of a timeout. */
128 * Region offsets are the difference between a pointer in a region and the
129 * region's base address. With private environments, both addresses are the
130 * result of calling malloc, and we can't assume anything about what malloc
131 * will return, so region offsets have to be able to hold differences between
132 * arbitrary pointers.
134 typedef db_size_t roff_t;
137 * Forward structure declarations, so we can declare pointers and
138 * applications can get type checking.
140 struct __channel; typedef struct __channel CHANNEL;
141 struct __db; typedef struct __db DB;
142 struct __db_bt_stat; typedef struct __db_bt_stat DB_BTREE_STAT;
143 struct __db_channel; typedef struct __db_channel DB_CHANNEL;
144 struct __db_cipher; typedef struct __db_cipher DB_CIPHER;
145 struct __db_compact; typedef struct __db_compact DB_COMPACT;
146 struct __db_dbt; typedef struct __db_dbt DBT;
147 struct __db_distab; typedef struct __db_distab DB_DISTAB;
148 struct __db_env; typedef struct __db_env DB_ENV;
149 struct __db_h_stat; typedef struct __db_h_stat DB_HASH_STAT;
150 struct __db_heap_rid; typedef struct __db_heap_rid DB_HEAP_RID;
151 struct __db_heap_stat; typedef struct __db_heap_stat DB_HEAP_STAT;
152 struct __db_ilock; typedef struct __db_ilock DB_LOCK_ILOCK;
153 struct __db_lock_hstat; typedef struct __db_lock_hstat DB_LOCK_HSTAT;
154 struct __db_lock_pstat; typedef struct __db_lock_pstat DB_LOCK_PSTAT;
155 struct __db_lock_stat; typedef struct __db_lock_stat DB_LOCK_STAT;
156 struct __db_lock_u; typedef struct __db_lock_u DB_LOCK;
157 struct __db_locker; typedef struct __db_locker DB_LOCKER;
158 struct __db_lockreq; typedef struct __db_lockreq DB_LOCKREQ;
159 struct __db_locktab; typedef struct __db_locktab DB_LOCKTAB;
160 struct __db_log; typedef struct __db_log DB_LOG;
161 struct __db_log_cursor; typedef struct __db_log_cursor DB_LOGC;
162 struct __db_log_stat; typedef struct __db_log_stat DB_LOG_STAT;
163 struct __db_lsn; typedef struct __db_lsn DB_LSN;
164 struct __db_mpool; typedef struct __db_mpool DB_MPOOL;
165 struct __db_mpool_fstat;typedef struct __db_mpool_fstat DB_MPOOL_FSTAT;
166 struct __db_mpool_stat; typedef struct __db_mpool_stat DB_MPOOL_STAT;
167 struct __db_mpoolfile; typedef struct __db_mpoolfile DB_MPOOLFILE;
168 struct __db_mutex_stat; typedef struct __db_mutex_stat DB_MUTEX_STAT;
169 struct __db_mutex_t; typedef struct __db_mutex_t DB_MUTEX;
170 struct __db_mutexmgr; typedef struct __db_mutexmgr DB_MUTEXMGR;
171 struct __db_preplist; typedef struct __db_preplist DB_PREPLIST;
172 struct __db_qam_stat; typedef struct __db_qam_stat DB_QUEUE_STAT;
173 struct __db_rep; typedef struct __db_rep DB_REP;
174 struct __db_rep_stat; typedef struct __db_rep_stat DB_REP_STAT;
175 struct __db_repmgr_conn_err;
176 typedef struct __db_repmgr_conn_err DB_REPMGR_CONN_ERR;
177 struct __db_repmgr_site;typedef struct __db_repmgr_site DB_REPMGR_SITE;
178 struct __db_repmgr_stat;typedef struct __db_repmgr_stat DB_REPMGR_STAT;
179 struct __db_seq_record; typedef struct __db_seq_record DB_SEQ_RECORD;
180 struct __db_seq_stat; typedef struct __db_seq_stat DB_SEQUENCE_STAT;
181 struct __db_site; typedef struct __db_site DB_SITE;
182 struct __db_sequence; typedef struct __db_sequence DB_SEQUENCE;
183 struct __db_thread_info;typedef struct __db_thread_info DB_THREAD_INFO;
184 struct __db_txn; typedef struct __db_txn DB_TXN;
185 struct __db_txn_active; typedef struct __db_txn_active DB_TXN_ACTIVE;
186 struct __db_txn_stat; typedef struct __db_txn_stat DB_TXN_STAT;
187 struct __db_txn_token; typedef struct __db_txn_token DB_TXN_TOKEN;
188 struct __db_txnmgr; typedef struct __db_txnmgr DB_TXNMGR;
189 struct __dbc; typedef struct __dbc DBC;
190 struct __dbc_internal; typedef struct __dbc_internal DBC_INTERNAL;
191 struct __env; typedef struct __env ENV;
192 struct __fh_t; typedef struct __fh_t DB_FH;
193 struct __fname; typedef struct __fname FNAME;
194 struct __key_range; typedef struct __key_range DB_KEY_RANGE;
195 struct __mpoolfile; typedef struct __mpoolfile MPOOLFILE;
196 struct __db_logvrfy_config;
197 typedef struct __db_logvrfy_config DB_LOG_VERIFY_CONFIG;
200 * The Berkeley DB API flags are automatically-generated -- the following flag
201 * names are no longer used, but remain for compatibility reasons.
203 #define DB_DEGREE_2 DB_READ_COMMITTED
204 #define DB_DIRTY_READ DB_READ_UNCOMMITTED
205 #define DB_JOINENV 0x0
207 /* Key/data structure -- a Data-Base Thang. */
209 void *data; /* Key/data */
210 u_int32_t size; /* key/data length */
212 u_int32_t ulen; /* RO: length of user buffer. */
213 u_int32_t dlen; /* RO: get/put record length. */
214 u_int32_t doff; /* RO: get/put record offset. */
218 #define DB_DBT_APPMALLOC 0x001 /* Callback allocated memory. */
219 #define DB_DBT_BULK 0x002 /* Internal: Insert if duplicate. */
220 #define DB_DBT_DUPOK 0x004 /* Internal: Insert if duplicate. */
221 #define DB_DBT_ISSET 0x008 /* Lower level calls set value. */
222 #define DB_DBT_MALLOC 0x010 /* Return in malloc'd memory. */
223 #define DB_DBT_MULTIPLE 0x020 /* References multiple records. */
224 #define DB_DBT_PARTIAL 0x040 /* Partial put/get. */
225 #define DB_DBT_REALLOC 0x080 /* Return in realloc'd memory. */
226 #define DB_DBT_READONLY 0x100 /* Readonly, don't update. */
227 #define DB_DBT_STREAMING 0x200 /* Internal: DBT is being streamed. */
228 #define DB_DBT_USERCOPY 0x400 /* Use the user-supplied callback. */
229 #define DB_DBT_USERMEM 0x800 /* Return in user's memory. */
233 /*******************************************************
235 *******************************************************/
237 * When mixed size addressing is supported mutexes need to be the same size
238 * independent of the process address size is.
240 #ifdef HAVE_MIXED_SIZE_ADDRESSING
241 typedef db_size_t db_mutex_t;
243 typedef uintptr_t db_mutex_t;
246 struct __db_mutex_stat { /* SHARED */
247 /* The following fields are maintained in the region's copy. */
248 u_int32_t st_mutex_align; /* Mutex alignment */
249 u_int32_t st_mutex_tas_spins; /* Mutex test-and-set spins */
250 u_int32_t st_mutex_init; /* Initial mutex count */
251 u_int32_t st_mutex_cnt; /* Mutex count */
252 u_int32_t st_mutex_max; /* Mutex max */
253 u_int32_t st_mutex_free; /* Available mutexes */
254 u_int32_t st_mutex_inuse; /* Mutexes in use */
255 u_int32_t st_mutex_inuse_max; /* Maximum mutexes ever in use */
257 /* The following fields are filled-in from other places. */
258 #ifndef __TEST_DB_NO_STATISTICS
259 uintmax_t st_region_wait; /* Region lock granted after wait. */
260 uintmax_t st_region_nowait; /* Region lock granted without wait. */
261 roff_t st_regsize; /* Region size. */
262 roff_t st_regmax; /* Region max. */
266 /* This is the length of the buffer passed to DB_ENV->thread_id_string() */
267 #define DB_THREADID_STRLEN 128
269 /*******************************************************
271 *******************************************************/
272 #define DB_LOCKVERSION 1
274 #define DB_FILE_ID_LEN 20 /* Unique file ID length. */
277 * Deadlock detector modes; used in the DB_ENV structure to configure the
280 #define DB_LOCK_NORUN 0
281 #define DB_LOCK_DEFAULT 1 /* Default policy. */
282 #define DB_LOCK_EXPIRE 2 /* Only expire locks, no detection. */
283 #define DB_LOCK_MAXLOCKS 3 /* Select locker with max locks. */
284 #define DB_LOCK_MAXWRITE 4 /* Select locker with max writelocks. */
285 #define DB_LOCK_MINLOCKS 5 /* Select locker with min locks. */
286 #define DB_LOCK_MINWRITE 6 /* Select locker with min writelocks. */
287 #define DB_LOCK_OLDEST 7 /* Select oldest locker. */
288 #define DB_LOCK_RANDOM 8 /* Select random locker. */
289 #define DB_LOCK_YOUNGEST 9 /* Select youngest locker. */
292 * Simple R/W lock modes and for multi-granularity intention locking.
295 * These values are NOT random, as they are used as an index into the lock
296 * conflicts arrays, i.e., DB_LOCK_IWRITE must be == 3, and DB_LOCK_IREAD
300 DB_LOCK_NG=0, /* Not granted. */
301 DB_LOCK_READ=1, /* Shared/read. */
302 DB_LOCK_WRITE=2, /* Exclusive/write. */
303 DB_LOCK_WAIT=3, /* Wait for event */
304 DB_LOCK_IWRITE=4, /* Intent exclusive/write. */
305 DB_LOCK_IREAD=5, /* Intent to share/read. */
306 DB_LOCK_IWR=6, /* Intent to read and write. */
307 DB_LOCK_READ_UNCOMMITTED=7, /* Degree 1 isolation. */
308 DB_LOCK_WWRITE=8 /* Was Written. */
315 DB_LOCK_DUMP=0, /* Display held locks. */
316 DB_LOCK_GET=1, /* Get the lock. */
317 DB_LOCK_GET_TIMEOUT=2, /* Get lock with a timeout. */
318 DB_LOCK_INHERIT=3, /* Pass locks to parent. */
319 DB_LOCK_PUT=4, /* Release the lock. */
320 DB_LOCK_PUT_ALL=5, /* Release locker's locks. */
321 DB_LOCK_PUT_OBJ=6, /* Release locker's locks on obj. */
322 DB_LOCK_PUT_READ=7, /* Release locker's read locks. */
323 DB_LOCK_TIMEOUT=8, /* Force a txn to timeout. */
324 DB_LOCK_TRADE=9, /* Trade locker ids on a lock. */
325 DB_LOCK_UPGRADE_WRITE=10 /* Upgrade writes for dirty reads. */
332 DB_LSTAT_ABORTED=1, /* Lock belongs to an aborted txn. */
333 DB_LSTAT_EXPIRED=2, /* Lock has expired. */
334 DB_LSTAT_FREE=3, /* Lock is unallocated. */
335 DB_LSTAT_HELD=4, /* Lock is currently held. */
336 DB_LSTAT_PENDING=5, /* Lock was waiting and has been
337 * promoted; waiting for the owner
338 * to run and upgrade it to held. */
339 DB_LSTAT_WAITING=6 /* Lock is on the wait queue. */
342 /* Lock statistics structure. */
343 struct __db_lock_stat { /* SHARED */
344 u_int32_t st_id; /* Last allocated locker ID. */
345 u_int32_t st_cur_maxid; /* Current maximum unused ID. */
346 u_int32_t st_initlocks; /* Initial number of locks in table. */
347 u_int32_t st_initlockers; /* Initial num of lockers in table. */
348 u_int32_t st_initobjects; /* Initial num of objects in table. */
349 u_int32_t st_locks; /* Current number of locks in table. */
350 u_int32_t st_lockers; /* Current num of lockers in table. */
351 u_int32_t st_objects; /* Current num of objects in table. */
352 u_int32_t st_maxlocks; /* Maximum number of locks in table. */
353 u_int32_t st_maxlockers; /* Maximum num of lockers in table. */
354 u_int32_t st_maxobjects; /* Maximum num of objects in table. */
355 u_int32_t st_partitions; /* number of partitions. */
356 u_int32_t st_tablesize; /* Size of object hash table. */
357 int32_t st_nmodes; /* Number of lock modes. */
358 u_int32_t st_nlockers; /* Current number of lockers. */
359 #ifndef __TEST_DB_NO_STATISTICS
360 u_int32_t st_nlocks; /* Current number of locks. */
361 u_int32_t st_maxnlocks; /* Maximum number of locks so far. */
362 u_int32_t st_maxhlocks; /* Maximum number of locks in any bucket. */
363 uintmax_t st_locksteals; /* Number of lock steals so far. */
364 uintmax_t st_maxlsteals; /* Maximum number steals in any partition. */
365 u_int32_t st_maxnlockers; /* Maximum number of lockers so far. */
366 u_int32_t st_nobjects; /* Current number of objects. */
367 u_int32_t st_maxnobjects; /* Maximum number of objects so far. */
368 u_int32_t st_maxhobjects; /* Maximum number of objectsin any bucket. */
369 uintmax_t st_objectsteals; /* Number of objects steals so far. */
370 uintmax_t st_maxosteals; /* Maximum number of steals in any partition. */
371 uintmax_t st_nrequests; /* Number of lock gets. */
372 uintmax_t st_nreleases; /* Number of lock puts. */
373 uintmax_t st_nupgrade; /* Number of lock upgrades. */
374 uintmax_t st_ndowngrade; /* Number of lock downgrades. */
375 uintmax_t st_lock_wait; /* Lock conflicts w/ subsequent wait */
376 uintmax_t st_lock_nowait; /* Lock conflicts w/o subsequent wait */
377 uintmax_t st_ndeadlocks; /* Number of lock deadlocks. */
378 db_timeout_t st_locktimeout; /* Lock timeout. */
379 uintmax_t st_nlocktimeouts; /* Number of lock timeouts. */
380 db_timeout_t st_txntimeout; /* Transaction timeout. */
381 uintmax_t st_ntxntimeouts; /* Number of transaction timeouts. */
382 uintmax_t st_part_wait; /* Partition lock granted after wait. */
383 uintmax_t st_part_nowait; /* Partition lock granted without wait. */
384 uintmax_t st_part_max_wait; /* Max partition lock granted after wait. */
385 uintmax_t st_part_max_nowait; /* Max partition lock granted without wait. */
386 uintmax_t st_objs_wait; /* Object lock granted after wait. */
387 uintmax_t st_objs_nowait; /* Object lock granted without wait. */
388 uintmax_t st_lockers_wait; /* Locker lock granted after wait. */
389 uintmax_t st_lockers_nowait; /* Locker lock granted without wait. */
390 uintmax_t st_region_wait; /* Region lock granted after wait. */
391 uintmax_t st_region_nowait; /* Region lock granted without wait. */
392 u_int32_t st_hash_len; /* Max length of bucket. */
393 roff_t st_regsize; /* Region size. */
397 struct __db_lock_hstat { /* SHARED */
398 uintmax_t st_nrequests; /* Number of lock gets. */
399 uintmax_t st_nreleases; /* Number of lock puts. */
400 uintmax_t st_nupgrade; /* Number of lock upgrades. */
401 uintmax_t st_ndowngrade; /* Number of lock downgrades. */
402 u_int32_t st_nlocks; /* Current number of locks. */
403 u_int32_t st_maxnlocks; /* Maximum number of locks so far. */
404 u_int32_t st_nobjects; /* Current number of objects. */
405 u_int32_t st_maxnobjects; /* Maximum number of objects so far. */
406 uintmax_t st_lock_wait; /* Lock conflicts w/ subsequent wait */
407 uintmax_t st_lock_nowait; /* Lock conflicts w/o subsequent wait */
408 uintmax_t st_nlocktimeouts; /* Number of lock timeouts. */
409 uintmax_t st_ntxntimeouts; /* Number of transaction timeouts. */
410 u_int32_t st_hash_len; /* Max length of bucket. */
413 struct __db_lock_pstat { /* SHARED */
414 u_int32_t st_nlocks; /* Current number of locks. */
415 u_int32_t st_maxnlocks; /* Maximum number of locks so far. */
416 u_int32_t st_nobjects; /* Current number of objects. */
417 u_int32_t st_maxnobjects; /* Maximum number of objects so far. */
418 uintmax_t st_locksteals; /* Number of lock steals so far. */
419 uintmax_t st_objectsteals; /* Number of objects steals so far. */
424 * Internal DB access method lock.
426 struct __db_ilock { /* SHARED */
427 db_pgno_t pgno; /* Page being locked. */
428 u_int8_t fileid[DB_FILE_ID_LEN];/* File id. */
429 #define DB_HANDLE_LOCK 1
430 #define DB_RECORD_LOCK 2
431 #define DB_PAGE_LOCK 3
432 #define DB_DATABASE_LOCK 4
433 u_int32_t type; /* Type of lock. */
438 * The structure is allocated by the caller and filled in during a
439 * lock_get request (or a lock_vec/DB_LOCK_GET).
441 struct __db_lock_u { /* SHARED */
442 roff_t off; /* Offset of the lock in the region */
443 u_int32_t ndx; /* Index of the object referenced by
444 * this lock; used for locking. */
445 u_int32_t gen; /* Generation number of this lock. */
446 db_lockmode_t mode; /* mode of this lock. */
449 /* Lock request structure. */
450 struct __db_lockreq {
451 db_lockop_t op; /* Operation. */
452 db_lockmode_t mode; /* Requested mode. */
453 db_timeout_t timeout; /* Time to expire lock. */
454 DBT *obj; /* Object being locked. */
455 DB_LOCK lock; /* Lock returned. */
458 /*******************************************************
460 *******************************************************/
461 #define DB_LOGVERSION 19 /* Current log version. */
462 #define DB_LOGVERSION_LATCHING 15 /* Log version using latching: db-4.8 */
463 #define DB_LOGCHKSUM 12 /* Check sum headers: db-4.5 */
464 #define DB_LOGOLDVER 8 /* Oldest version supported: db-4.2 */
465 #define DB_LOGMAGIC 0x040988
468 * A DB_LSN has two parts, a fileid which identifies a specific file, and an
469 * offset within that file. The fileid is an unsigned 4-byte quantity that
470 * uniquely identifies a file within the log directory -- currently a simple
471 * counter inside the log. The offset is also an unsigned 4-byte value. The
472 * log manager guarantees the offset is never more than 4 bytes by switching
473 * to a new log file before the maximum length imposed by an unsigned 4-byte
476 struct __db_lsn { /* SHARED */
477 u_int32_t file; /* File ID. */
478 u_int32_t offset; /* File offset. */
482 * Application-specified log record types start at DB_user_BEGIN, and must not
483 * equal or exceed DB_debug_FLAG.
485 * DB_debug_FLAG is the high-bit of the u_int32_t that specifies a log record
486 * type. If the flag is set, it's a log record that was logged for debugging
487 * purposes only, even if it reflects a database change -- the change was part
488 * of a non-durable transaction.
490 #define DB_user_BEGIN 10000
491 #define DB_debug_FLAG 0x80000000
497 struct __db_log_cursor {
498 ENV *env; /* Environment */
500 DB_FH *fhp; /* File handle. */
501 DB_LSN lsn; /* Cursor: LSN */
502 u_int32_t len; /* Cursor: record length */
503 u_int32_t prev; /* Cursor: previous record's offset */
505 DBT dbt; /* Return DBT. */
506 DB_LSN p_lsn; /* Persist LSN. */
507 u_int32_t p_version; /* Persist version. */
509 u_int8_t *bp; /* Allocated read buffer. */
510 u_int32_t bp_size; /* Read buffer length in bytes. */
511 u_int32_t bp_rlen; /* Read buffer valid data length. */
512 DB_LSN bp_lsn; /* Read buffer first byte LSN. */
514 u_int32_t bp_maxrec; /* Max record length in the log file. */
516 /* DB_LOGC PUBLIC HANDLE LIST BEGIN */
517 int (*close) __P((DB_LOGC *, u_int32_t));
518 int (*get) __P((DB_LOGC *, DB_LSN *, DBT *, u_int32_t));
519 int (*version) __P((DB_LOGC *, u_int32_t *, u_int32_t));
520 /* DB_LOGC PUBLIC HANDLE LIST END */
522 #define DB_LOG_DISK 0x01 /* Log record came from disk. */
523 #define DB_LOG_LOCKED 0x02 /* Log region already locked */
524 #define DB_LOG_SILENT_ERR 0x04 /* Turn-off error messages. */
528 /* Log statistics structure. */
529 struct __db_log_stat { /* SHARED */
530 u_int32_t st_magic; /* Log file magic number. */
531 u_int32_t st_version; /* Log file version number. */
532 int32_t st_mode; /* Log file permissions mode. */
533 u_int32_t st_lg_bsize; /* Log buffer size. */
534 u_int32_t st_lg_size; /* Log file size. */
535 u_int32_t st_wc_bytes; /* Bytes to log since checkpoint. */
536 u_int32_t st_wc_mbytes; /* Megabytes to log since checkpoint. */
537 u_int32_t st_fileid_init; /* Initial allocation for fileids. */
538 #ifndef __TEST_DB_NO_STATISTICS
539 u_int32_t st_nfileid; /* Current number of fileids. */
540 u_int32_t st_maxnfileid; /* Maximum number of fileids used. */
541 uintmax_t st_record; /* Records entered into the log. */
542 u_int32_t st_w_bytes; /* Bytes to log. */
543 u_int32_t st_w_mbytes; /* Megabytes to log. */
544 uintmax_t st_wcount; /* Total I/O writes to the log. */
545 uintmax_t st_wcount_fill; /* Overflow writes to the log. */
546 uintmax_t st_rcount; /* Total I/O reads from the log. */
547 uintmax_t st_scount; /* Total syncs to the log. */
548 uintmax_t st_region_wait; /* Region lock granted after wait. */
549 uintmax_t st_region_nowait; /* Region lock granted without wait. */
550 u_int32_t st_cur_file; /* Current log file number. */
551 u_int32_t st_cur_offset; /* Current log file offset. */
552 u_int32_t st_disk_file; /* Known on disk log file number. */
553 u_int32_t st_disk_offset; /* Known on disk log file offset. */
554 u_int32_t st_maxcommitperflush; /* Max number of commits in a flush. */
555 u_int32_t st_mincommitperflush; /* Min number of commits in a flush. */
556 roff_t st_regsize; /* Region size. */
561 * We need to record the first log record of a transaction. For user
562 * defined logging this macro returns the place to put that information,
563 * if it is need in rlsnp, otherwise it leaves it unchanged. We also
564 * need to track the last record of the transaction, this returns the
565 * place to put that info.
567 #define DB_SET_TXN_LSNP(txn, blsnp, llsnp) \
568 ((txn)->set_txn_lsnp(txn, blsnp, llsnp))
571 * Definition of the structure which specifies marshalling of log records.
590 typedef const struct __log_rec_spec {
598 * Size of a DBT in a log record.
600 #define LOG_DBT_SIZE(dbt) \
601 (sizeof(u_int32_t) + ((dbt) == NULL ? 0 : (dbt)->size))
603 /*******************************************************
604 * Shared buffer cache (mpool).
605 *******************************************************/
606 /* Priority values for DB_MPOOLFILE->{put,set_priority}. */
608 DB_PRIORITY_UNCHANGED=0,
609 DB_PRIORITY_VERY_LOW=1,
611 DB_PRIORITY_DEFAULT=3,
613 DB_PRIORITY_VERY_HIGH=5
616 /* Per-process DB_MPOOLFILE information. */
617 struct __db_mpoolfile {
618 DB_FH *fhp; /* Underlying file handle. */
622 * The ref, pinref and q fields are protected by the region lock.
624 u_int32_t ref; /* Reference count. */
626 u_int32_t pinref; /* Pinned block reference count. */
630 * Explicit representations of structures from queue.h.
631 * TAILQ_ENTRY(__db_mpoolfile) q;
634 struct __db_mpoolfile *tqe_next;
635 struct __db_mpoolfile **tqe_prev;
636 } q; /* Linked list of DB_MPOOLFILE's. */
640 * The rest of the fields (with the exception of the MP_FLUSH flag)
641 * are not thread-protected, even when they may be modified at any
642 * time by the application. The reason is the DB_MPOOLFILE handle
643 * is single-threaded from the viewpoint of the application, and so
644 * the only fields needing to be thread-protected are those accessed
645 * by checkpoint or sync threads when using DB_MPOOLFILE structures
646 * to flush buffers from the cache.
648 ENV *env; /* Environment */
649 MPOOLFILE *mfp; /* Underlying MPOOLFILE. */
651 u_int32_t clear_len; /* Cleared length on created pages. */
652 u_int8_t /* Unique file ID. */
653 fileid[DB_FILE_ID_LEN];
654 int ftype; /* File type. */
655 int32_t lsn_offset; /* LSN offset in page. */
656 u_int32_t gbytes, bytes; /* Maximum file size. */
657 DBT *pgcookie; /* Byte-string passed to pgin/pgout. */
658 int32_t priority; /* Cache priority. */
660 void *addr; /* Address of mmap'd region. */
661 size_t len; /* Length of mmap'd region. */
663 u_int32_t config_flags; /* Flags to DB_MPOOLFILE->set_flags. */
665 /* DB_MPOOLFILE PUBLIC HANDLE LIST BEGIN */
666 int (*close) __P((DB_MPOOLFILE *, u_int32_t));
668 __P((DB_MPOOLFILE *, db_pgno_t *, DB_TXN *, u_int32_t, void *));
669 int (*get_clear_len) __P((DB_MPOOLFILE *, u_int32_t *));
670 int (*get_fileid) __P((DB_MPOOLFILE *, u_int8_t *));
671 int (*get_flags) __P((DB_MPOOLFILE *, u_int32_t *));
672 int (*get_ftype) __P((DB_MPOOLFILE *, int *));
673 int (*get_last_pgno) __P((DB_MPOOLFILE *, db_pgno_t *));
674 int (*get_lsn_offset) __P((DB_MPOOLFILE *, int32_t *));
675 int (*get_maxsize) __P((DB_MPOOLFILE *, u_int32_t *, u_int32_t *));
676 int (*get_pgcookie) __P((DB_MPOOLFILE *, DBT *));
677 int (*get_priority) __P((DB_MPOOLFILE *, DB_CACHE_PRIORITY *));
678 int (*open) __P((DB_MPOOLFILE *, const char *, u_int32_t, int, size_t));
679 int (*put) __P((DB_MPOOLFILE *, void *, DB_CACHE_PRIORITY, u_int32_t));
680 int (*set_clear_len) __P((DB_MPOOLFILE *, u_int32_t));
681 int (*set_fileid) __P((DB_MPOOLFILE *, u_int8_t *));
682 int (*set_flags) __P((DB_MPOOLFILE *, u_int32_t, int));
683 int (*set_ftype) __P((DB_MPOOLFILE *, int));
684 int (*set_lsn_offset) __P((DB_MPOOLFILE *, int32_t));
685 int (*set_maxsize) __P((DB_MPOOLFILE *, u_int32_t, u_int32_t));
686 int (*set_pgcookie) __P((DB_MPOOLFILE *, DBT *));
687 int (*set_priority) __P((DB_MPOOLFILE *, DB_CACHE_PRIORITY));
688 int (*sync) __P((DB_MPOOLFILE *));
689 /* DB_MPOOLFILE PUBLIC HANDLE LIST END */
692 * MP_FILEID_SET, MP_OPEN_CALLED and MP_READONLY do not need to be
693 * thread protected because they are initialized before the file is
694 * linked onto the per-process lists, and never modified.
696 * MP_FLUSH is thread protected because it is potentially read/set by
697 * multiple threads of control.
699 #define MP_FILEID_SET 0x001 /* Application supplied a file ID. */
700 #define MP_FLUSH 0x002 /* Was used to flush a buffer. */
701 #define MP_FOR_FLUSH 0x004 /* Was opened to flush a buffer. */
702 #define MP_MULTIVERSION 0x008 /* Opened for multiversion access. */
703 #define MP_OPEN_CALLED 0x010 /* File opened. */
704 #define MP_READONLY 0x020 /* File is readonly. */
705 #define MP_DUMMY 0x040 /* File is dummy for __memp_fput. */
709 /* Mpool statistics structure. */
710 struct __db_mpool_stat { /* SHARED */
711 u_int32_t st_gbytes; /* Total cache size: GB. */
712 u_int32_t st_bytes; /* Total cache size: B. */
713 u_int32_t st_ncache; /* Number of cache regions. */
714 u_int32_t st_max_ncache; /* Maximum number of regions. */
715 db_size_t st_mmapsize; /* Maximum file size for mmap. */
716 int32_t st_maxopenfd; /* Maximum number of open fd's. */
717 int32_t st_maxwrite; /* Maximum buffers to write. */
718 db_timeout_t st_maxwrite_sleep; /* Sleep after writing max buffers. */
719 u_int32_t st_pages; /* Total number of pages. */
720 #ifndef __TEST_DB_NO_STATISTICS
721 u_int32_t st_map; /* Pages from mapped files. */
722 uintmax_t st_cache_hit; /* Pages found in the cache. */
723 uintmax_t st_cache_miss; /* Pages not found in the cache. */
724 uintmax_t st_page_create; /* Pages created in the cache. */
725 uintmax_t st_page_in; /* Pages read in. */
726 uintmax_t st_page_out; /* Pages written out. */
727 uintmax_t st_ro_evict; /* Clean pages forced from the cache. */
728 uintmax_t st_rw_evict; /* Dirty pages forced from the cache. */
729 uintmax_t st_page_trickle; /* Pages written by memp_trickle. */
730 u_int32_t st_page_clean; /* Clean pages. */
731 u_int32_t st_page_dirty; /* Dirty pages. */
732 u_int32_t st_hash_buckets; /* Number of hash buckets. */
733 u_int32_t st_hash_mutexes; /* Number of hash bucket mutexes. */
734 u_int32_t st_pagesize; /* Assumed page size. */
735 u_int32_t st_hash_searches; /* Total hash chain searches. */
736 u_int32_t st_hash_longest; /* Longest hash chain searched. */
737 uintmax_t st_hash_examined; /* Total hash entries searched. */
738 uintmax_t st_hash_nowait; /* Hash lock granted with nowait. */
739 uintmax_t st_hash_wait; /* Hash lock granted after wait. */
740 uintmax_t st_hash_max_nowait; /* Max hash lock granted with nowait. */
741 uintmax_t st_hash_max_wait; /* Max hash lock granted after wait. */
742 uintmax_t st_region_nowait; /* Region lock granted with nowait. */
743 uintmax_t st_region_wait; /* Region lock granted after wait. */
744 uintmax_t st_mvcc_frozen; /* Buffers frozen. */
745 uintmax_t st_mvcc_thawed; /* Buffers thawed. */
746 uintmax_t st_mvcc_freed; /* Frozen buffers freed. */
747 uintmax_t st_alloc; /* Number of page allocations. */
748 uintmax_t st_alloc_buckets; /* Buckets checked during allocation. */
749 uintmax_t st_alloc_max_buckets;/* Max checked during allocation. */
750 uintmax_t st_alloc_pages; /* Pages checked during allocation. */
751 uintmax_t st_alloc_max_pages; /* Max checked during allocation. */
752 uintmax_t st_io_wait; /* Thread waited on buffer I/O. */
753 uintmax_t st_sync_interrupted; /* Number of times sync interrupted. */
754 roff_t st_regsize; /* Region size. */
755 roff_t st_regmax; /* Region max. */
760 * Mpool file statistics structure.
761 * The first fields in this structure must mirror the __db_mpool_fstat_int
762 * structure, since content is mem copied between the two.
764 struct __db_mpool_fstat {
765 u_int32_t st_pagesize; /* Page size. */
766 #ifndef __TEST_DB_NO_STATISTICS
767 u_int32_t st_map; /* Pages from mapped files. */
768 uintmax_t st_cache_hit; /* Pages found in the cache. */
769 uintmax_t st_cache_miss; /* Pages not found in the cache. */
770 uintmax_t st_page_create; /* Pages created in the cache. */
771 uintmax_t st_page_in; /* Pages read in. */
772 uintmax_t st_page_out; /* Pages written out. */
773 uintmax_t st_backup_spins; /* Number of spins during a copy. */
775 char *file_name; /* File name. */
778 /*******************************************************
779 * Transactions and recovery.
780 *******************************************************/
781 #define DB_TXNVERSION 1
784 DB_TXN_ABORT=0, /* Public. */
785 DB_TXN_APPLY=1, /* Public. */
786 DB_TXN_BACKWARD_ROLL=3, /* Public. */
787 DB_TXN_FORWARD_ROLL=4, /* Public. */
788 DB_TXN_OPENFILES=5, /* Internal. */
789 DB_TXN_POPENFILES=6, /* Internal. */
790 DB_TXN_PRINT=7, /* Public. */
791 DB_TXN_LOG_VERIFY=8 /* Internal. */
795 * BACKWARD_ALLOC is used during the forward pass to pick up any aborted
796 * allocations for files that were created during the forward pass.
797 * The main difference between _ALLOC and _ROLL is that the entry for
798 * the file not exist during the rollforward pass.
800 #define DB_UNDO(op) ((op) == DB_TXN_ABORT || (op) == DB_TXN_BACKWARD_ROLL)
801 #define DB_REDO(op) ((op) == DB_TXN_FORWARD_ROLL || (op) == DB_TXN_APPLY)
804 DB_TXNMGR *mgrp; /* Pointer to transaction manager. */
805 DB_TXN *parent; /* Pointer to transaction's parent. */
806 DB_THREAD_INFO *thread_info; /* Pointer to thread information. */
808 u_int32_t txnid; /* Unique transaction id. */
809 char *name; /* Transaction name. */
810 DB_LOCKER *locker; /* Locker for this txn. */
812 void *td; /* Detail structure within region. */
813 db_timeout_t lock_timeout; /* Timeout for locks for this txn. */
814 void *txn_list; /* Undo information for parent. */
818 * Explicit representations of structures from queue.h.
819 * TAILQ_ENTRY(__db_txn) links;
822 struct __db_txn *tqe_next;
823 struct __db_txn **tqe_prev;
824 } links; /* Links transactions off manager. */
828 * Explicit representations of structures from shqueue.h.
829 * SH_TAILQ_ENTRY xa_links;
830 * These links link together transactions that are active in
831 * the same thread of control.
834 db_ssize_t stqe_next;
835 db_ssize_t stqe_prev;
836 } xa_links; /* Links XA transactions. */
840 * Explicit representations of structures from queue.h.
841 * TAILQ_HEAD(__kids, __db_txn) kids;
844 struct __db_txn *tqh_first;
845 struct __db_txn **tqh_last;
850 * Explicit representations of structures from queue.h.
851 * TAILQ_HEAD(__events, __txn_event) events;
854 struct __txn_event *tqh_first;
855 struct __txn_event **tqh_last;
856 } events; /* Links deferred events. */
860 * Explicit representations of structures from queue.h.
861 * STAILQ_HEAD(__logrec, __txn_logrec) logs;
864 struct __txn_logrec *stqh_first;
865 struct __txn_logrec **stqh_last;
866 } logs; /* Links in memory log records. */
870 * Explicit representations of structures from queue.h.
871 * TAILQ_ENTRY(__db_txn) klinks;
874 struct __db_txn *tqe_next;
875 struct __db_txn **tqe_prev;
876 } klinks; /* Links of children in parent. */
880 * Explicit representations of structures from queue.h.
881 * TAILQ_HEAD(__my_cursors, __dbc) my_cursors;
883 struct __my_cursors {
884 struct __dbc *tqh_first;
885 struct __dbc **tqh_last;
890 * Explicit representations of structures from queue.h.
891 * TAILQ_HEAD(__femfs, MPOOLFILE) femfs;
893 * These are DBs involved in file extension in this transaction.
900 DB_TXN_TOKEN *token_buffer; /* User's commit token buffer. */
901 void *api_internal; /* C++ API private. */
902 void *xml_internal; /* XML API private. */
904 u_int32_t cursors; /* Number of cursors open for txn */
906 /* DB_TXN PUBLIC HANDLE LIST BEGIN */
907 int (*abort) __P((DB_TXN *));
908 int (*commit) __P((DB_TXN *, u_int32_t));
909 int (*discard) __P((DB_TXN *, u_int32_t));
910 int (*get_name) __P((DB_TXN *, const char **));
911 int (*get_priority) __P((DB_TXN *, u_int32_t *));
912 u_int32_t (*id) __P((DB_TXN *));
913 int (*prepare) __P((DB_TXN *, u_int8_t *));
914 int (*set_commit_token) __P((DB_TXN *, DB_TXN_TOKEN *));
915 int (*set_name) __P((DB_TXN *, const char *));
916 int (*set_priority) __P((DB_TXN *, u_int32_t));
917 int (*set_timeout) __P((DB_TXN *, db_timeout_t, u_int32_t));
918 /* DB_TXN PUBLIC HANDLE LIST END */
920 /* DB_TXN PRIVATE HANDLE LIST BEGIN */
921 void (*set_txn_lsnp) __P((DB_TXN *txn, DB_LSN **, DB_LSN **));
922 /* DB_TXN PRIVATE HANDLE LIST END */
924 #define TXN_XA_THREAD_NOTA 0
925 #define TXN_XA_THREAD_ASSOCIATED 1
926 #define TXN_XA_THREAD_SUSPENDED 2
927 #define TXN_XA_THREAD_UNASSOCIATED 3
928 u_int32_t xa_thr_status;
930 #define TXN_CHILDCOMMIT 0x00001 /* Txn has committed. */
931 #define TXN_COMPENSATE 0x00002 /* Compensating transaction. */
932 #define TXN_DEADLOCK 0x00004 /* Txn has deadlocked. */
933 #define TXN_FAMILY 0x00008 /* Cursors/children are independent. */
934 #define TXN_IGNORE_LEASE 0x00010 /* Skip lease check at commit time. */
935 #define TXN_INFAMILY 0x00020 /* Part of a transaction family. */
936 #define TXN_LOCKTIMEOUT 0x00040 /* Txn has a lock timeout. */
937 #define TXN_MALLOC 0x00080 /* Structure allocated by TXN system. */
938 #define TXN_NOSYNC 0x00100 /* Do not sync on prepare and commit. */
939 #define TXN_NOWAIT 0x00200 /* Do not wait on locks. */
940 #define TXN_PRIVATE 0x00400 /* Txn owned by cursor. */
941 #define TXN_READONLY 0x00800 /* CDS group handle. */
942 #define TXN_READ_COMMITTED 0x01000 /* Txn has degree 2 isolation. */
943 #define TXN_READ_UNCOMMITTED 0x02000 /* Txn has degree 1 isolation. */
944 #define TXN_RESTORED 0x04000 /* Txn has been restored. */
945 #define TXN_SNAPSHOT 0x08000 /* Snapshot Isolation. */
946 #define TXN_SYNC 0x10000 /* Write and sync on prepare/commit. */
947 #define TXN_WRITE_NOSYNC 0x20000 /* Write only on prepare/commit. */
948 #define TXN_BULK 0x40000 /* Enable bulk loading optimization. */
952 #define TXN_SYNC_FLAGS (TXN_SYNC | TXN_NOSYNC | TXN_WRITE_NOSYNC)
955 * Structure used for two phase commit interface.
956 * We set the size of our global transaction id (gid) to be 128 in order
957 * to match that defined by the XA X/Open standard.
959 #define DB_GID_SIZE 128
960 struct __db_preplist {
962 u_int8_t gid[DB_GID_SIZE];
965 /* Transaction statistics structure. */
966 struct __db_txn_active {
967 u_int32_t txnid; /* Transaction ID */
968 u_int32_t parentid; /* Transaction ID of parent */
969 pid_t pid; /* Process owning txn ID */
970 db_threadid_t tid; /* Thread owning txn ID */
972 DB_LSN lsn; /* LSN when transaction began */
974 DB_LSN read_lsn; /* Read LSN for MVCC */
975 u_int32_t mvcc_ref; /* MVCC reference count */
977 u_int32_t priority; /* Deadlock resolution priority */
979 #define TXN_ABORTED 1
980 #define TXN_COMMITTED 2
981 #define TXN_NEED_ABORT 3
982 #define TXN_PREPARED 4
983 #define TXN_RUNNING 5
984 u_int32_t status; /* Status of the transaction */
986 #define TXN_XA_ACTIVE 1
987 #define TXN_XA_DEADLOCKED 2
988 #define TXN_XA_IDLE 3
989 #define TXN_XA_PREPARED 4
990 #define TXN_XA_ROLLEDBACK 5
991 u_int32_t xa_status; /* XA status */
993 u_int8_t gid[DB_GID_SIZE]; /* Global transaction ID */
994 char name[51]; /* 50 bytes of name, nul termination */
997 struct __db_txn_stat {
998 u_int32_t st_nrestores; /* number of restored transactions
1000 #ifndef __TEST_DB_NO_STATISTICS
1001 DB_LSN st_last_ckp; /* lsn of the last checkpoint */
1002 time_t st_time_ckp; /* time of last checkpoint */
1003 u_int32_t st_last_txnid; /* last transaction id given out */
1004 u_int32_t st_inittxns; /* inital txns allocated */
1005 u_int32_t st_maxtxns; /* maximum txns possible */
1006 uintmax_t st_naborts; /* number of aborted transactions */
1007 uintmax_t st_nbegins; /* number of begun transactions */
1008 uintmax_t st_ncommits; /* number of committed transactions */
1009 u_int32_t st_nactive; /* number of active transactions */
1010 u_int32_t st_nsnapshot; /* number of snapshot transactions */
1011 u_int32_t st_maxnactive; /* maximum active transactions */
1012 u_int32_t st_maxnsnapshot; /* maximum snapshot transactions */
1013 uintmax_t st_region_wait; /* Region lock granted after wait. */
1014 uintmax_t st_region_nowait; /* Region lock granted without wait. */
1015 roff_t st_regsize; /* Region size. */
1016 DB_TXN_ACTIVE *st_txnarray; /* array of active transactions */
1020 #define DB_TXN_TOKEN_SIZE 20
1021 struct __db_txn_token {
1022 u_int8_t buf[DB_TXN_TOKEN_SIZE];
1025 /*******************************************************
1027 *******************************************************/
1028 /* Special, out-of-band environment IDs. */
1029 #define DB_EID_BROADCAST -1
1030 #define DB_EID_INVALID -2
1031 #define DB_EID_MASTER -3
1033 #define DB_REP_DEFAULT_PRIORITY 100
1035 /* Acknowledgement policies; 0 reserved as OOB. */
1036 #define DB_REPMGR_ACKS_ALL 1
1037 #define DB_REPMGR_ACKS_ALL_AVAILABLE 2
1038 #define DB_REPMGR_ACKS_ALL_PEERS 3
1039 #define DB_REPMGR_ACKS_NONE 4
1040 #define DB_REPMGR_ACKS_ONE 5
1041 #define DB_REPMGR_ACKS_ONE_PEER 6
1042 #define DB_REPMGR_ACKS_QUORUM 7
1044 /* Replication timeout configuration values. */
1045 #define DB_REP_ACK_TIMEOUT 1 /* RepMgr acknowledgements. */
1046 #define DB_REP_CHECKPOINT_DELAY 2 /* Master checkpoint delay. */
1047 #define DB_REP_CONNECTION_RETRY 3 /* RepMgr connections. */
1048 #define DB_REP_ELECTION_RETRY 4 /* RepMgr elect retries. */
1049 #define DB_REP_ELECTION_TIMEOUT 5 /* Rep normal elections. */
1050 #define DB_REP_FULL_ELECTION_TIMEOUT 6 /* Rep full elections. */
1051 #define DB_REP_HEARTBEAT_MONITOR 7 /* RepMgr client HB monitor. */
1052 #define DB_REP_HEARTBEAT_SEND 8 /* RepMgr master send freq. */
1053 #define DB_REP_LEASE_TIMEOUT 9 /* Master leases. */
1056 * Event notification types. (Tcl testing interface currently assumes there are
1057 * no more than 32 of these.)
1059 #define DB_EVENT_PANIC 0
1060 #define DB_EVENT_REG_ALIVE 1
1061 #define DB_EVENT_REG_PANIC 2
1062 #define DB_EVENT_REP_CLIENT 3
1063 #define DB_EVENT_REP_CONNECT_BROKEN 4
1064 #define DB_EVENT_REP_CONNECT_ESTD 5
1065 #define DB_EVENT_REP_CONNECT_TRY_FAILED 6
1066 #define DB_EVENT_REP_DUPMASTER 7
1067 #define DB_EVENT_REP_ELECTED 8
1068 #define DB_EVENT_REP_ELECTION_FAILED 9
1069 #define DB_EVENT_REP_INIT_DONE 10
1070 #define DB_EVENT_REP_JOIN_FAILURE 11
1071 #define DB_EVENT_REP_LOCAL_SITE_REMOVED 12
1072 #define DB_EVENT_REP_MASTER 13
1073 #define DB_EVENT_REP_MASTER_FAILURE 14
1074 #define DB_EVENT_REP_NEWMASTER 15
1075 #define DB_EVENT_REP_PERM_FAILED 16
1076 #define DB_EVENT_REP_SITE_ADDED 17
1077 #define DB_EVENT_REP_SITE_REMOVED 18
1078 #define DB_EVENT_REP_STARTUPDONE 19
1079 #define DB_EVENT_REP_WOULD_ROLLBACK 20 /* Undocumented; C API only. */
1080 #define DB_EVENT_WRITE_FAILED 21
1081 #define DB_EVENT_NO_SUCH_EVENT 0xffffffff /* OOB sentinel value */
1083 /* Replication Manager site status. */
1084 struct __db_repmgr_site {
1089 #define DB_REPMGR_CONNECTED 1
1090 #define DB_REPMGR_DISCONNECTED 2
1093 #define DB_REPMGR_ISPEER 0x01
1097 /* Replication statistics. */
1098 struct __db_rep_stat { /* SHARED */
1100 * Many replication statistics fields cannot be protected by a mutex
1101 * without an unacceptable performance penalty, since most message
1102 * processing is done without the need to hold a region-wide lock.
1103 * Fields whose comments end with a '+' may be updated without holding
1104 * the replication or log mutexes (as appropriate), and thus may be
1105 * off somewhat (or, on unreasonable architectures under unlucky
1106 * circumstances, garbaged).
1108 u_int32_t st_startup_complete; /* Site completed client sync-up. */
1109 #ifndef __TEST_DB_NO_STATISTICS
1110 uintmax_t st_log_queued; /* Log records currently queued.+ */
1111 u_int32_t st_status; /* Current replication status. */
1112 DB_LSN st_next_lsn; /* Next LSN to use or expect. */
1113 DB_LSN st_waiting_lsn; /* LSN we're awaiting, if any. */
1114 DB_LSN st_max_perm_lsn; /* Maximum permanent LSN. */
1115 db_pgno_t st_next_pg; /* Next pg we expect. */
1116 db_pgno_t st_waiting_pg; /* pg we're awaiting, if any. */
1118 u_int32_t st_dupmasters; /* # of times a duplicate master
1119 condition was detected.+ */
1120 db_ssize_t st_env_id; /* Current environment ID. */
1121 u_int32_t st_env_priority; /* Current environment priority. */
1122 uintmax_t st_bulk_fills; /* Bulk buffer fills. */
1123 uintmax_t st_bulk_overflows; /* Bulk buffer overflows. */
1124 uintmax_t st_bulk_records; /* Bulk records stored. */
1125 uintmax_t st_bulk_transfers; /* Transfers of bulk buffers. */
1126 uintmax_t st_client_rerequests;/* Number of forced rerequests. */
1127 uintmax_t st_client_svc_req; /* Number of client service requests
1128 received by this client. */
1129 uintmax_t st_client_svc_miss; /* Number of client service requests
1130 missing on this client. */
1131 u_int32_t st_gen; /* Current generation number. */
1132 u_int32_t st_egen; /* Current election gen number. */
1133 uintmax_t st_lease_chk; /* Lease validity checks. */
1134 uintmax_t st_lease_chk_misses; /* Lease checks invalid. */
1135 uintmax_t st_lease_chk_refresh; /* Lease refresh attempts. */
1136 uintmax_t st_lease_sends; /* Lease messages sent live. */
1138 uintmax_t st_log_duplicated; /* Log records received multiply.+ */
1139 uintmax_t st_log_queued_max; /* Max. log records queued at once.+ */
1140 uintmax_t st_log_queued_total; /* Total # of log recs. ever queued.+ */
1141 uintmax_t st_log_records; /* Log records received and put.+ */
1142 uintmax_t st_log_requested; /* Log recs. missed and requested.+ */
1143 db_ssize_t st_master; /* Env. ID of the current master. */
1144 uintmax_t st_master_changes; /* # of times we've switched masters. */
1145 uintmax_t st_msgs_badgen; /* Messages with a bad generation #.+ */
1146 uintmax_t st_msgs_processed; /* Messages received and processed.+ */
1147 uintmax_t st_msgs_recover; /* Messages ignored because this site
1148 was a client in recovery.+ */
1149 uintmax_t st_msgs_send_failures;/* # of failed message sends.+ */
1150 uintmax_t st_msgs_sent; /* # of successful message sends.+ */
1151 uintmax_t st_newsites; /* # of NEWSITE msgs. received.+ */
1152 u_int32_t st_nsites; /* Current number of sites we will
1153 assume during elections. */
1154 uintmax_t st_nthrottles; /* # of times we were throttled. */
1155 uintmax_t st_outdated; /* # of times we detected and returned
1156 an OUTDATED condition.+ */
1157 uintmax_t st_pg_duplicated; /* Pages received multiply.+ */
1158 uintmax_t st_pg_records; /* Pages received and stored.+ */
1159 uintmax_t st_pg_requested; /* Pages missed and requested.+ */
1160 uintmax_t st_txns_applied; /* # of transactions applied.+ */
1161 uintmax_t st_startsync_delayed;/* # of STARTSYNC msgs delayed.+ */
1163 /* Elections generally. */
1164 uintmax_t st_elections; /* # of elections held.+ */
1165 uintmax_t st_elections_won; /* # of elections won by this site.+ */
1167 /* Statistics about an in-progress election. */
1168 db_ssize_t st_election_cur_winner; /* Current front-runner. */
1169 u_int32_t st_election_gen; /* Election generation number. */
1170 u_int32_t st_election_datagen; /* Election data generation number. */
1171 DB_LSN st_election_lsn; /* Max. LSN of current winner. */
1172 u_int32_t st_election_nsites; /* # of "registered voters". */
1173 u_int32_t st_election_nvotes; /* # of "registered voters" needed. */
1174 u_int32_t st_election_priority; /* Current election priority. */
1175 int32_t st_election_status; /* Current election status. */
1176 u_int32_t st_election_tiebreaker;/* Election tiebreaker value. */
1177 u_int32_t st_election_votes; /* Votes received in this round. */
1178 u_int32_t st_election_sec; /* Last election time seconds. */
1179 u_int32_t st_election_usec; /* Last election time useconds. */
1180 u_int32_t st_max_lease_sec; /* Maximum lease timestamp seconds. */
1181 u_int32_t st_max_lease_usec; /* Maximum lease timestamp useconds. */
1183 /* Undocumented statistics only used by the test system. */
1185 u_int32_t st_filefail_cleanups; /* # of FILE_FAIL cleanups done. */
1190 /* Replication Manager statistics. */
1191 struct __db_repmgr_stat { /* SHARED */
1192 uintmax_t st_perm_failed; /* # of insufficiently ack'ed msgs. */
1193 uintmax_t st_msgs_queued; /* # msgs queued for network delay. */
1194 uintmax_t st_msgs_dropped; /* # msgs discarded due to excessive
1196 uintmax_t st_connection_drop; /* Existing connections dropped. */
1197 uintmax_t st_connect_fail; /* Failed new connection attempts. */
1198 uintmax_t st_elect_threads; /* # of active election threads. */
1199 uintmax_t st_max_elect_threads; /* Max concurrent e-threads ever. */
1202 /* Replication Manager connection error. */
1203 struct __db_repmgr_conn_err {
1204 int eid; /* Replication Environment ID. */
1205 int error; /* System networking error code. */
1208 /*******************************************************
1210 *******************************************************/
1212 * The storage record for a sequence.
1214 struct __db_seq_record {
1215 u_int32_t seq_version; /* Version size/number. */
1216 u_int32_t flags; /* DB_SEQ_XXX Flags. */
1217 db_seq_t seq_value; /* Current value. */
1218 db_seq_t seq_max; /* Max permitted. */
1219 db_seq_t seq_min; /* Min permitted. */
1223 * Handle for a sequence object.
1225 struct __db_sequence {
1226 DB *seq_dbp; /* DB handle for this sequence. */
1227 db_mutex_t mtx_seq; /* Mutex if sequence is threaded. */
1228 DB_SEQ_RECORD *seq_rp; /* Pointer to current data. */
1229 DB_SEQ_RECORD seq_record; /* Data from DB_SEQUENCE. */
1230 int32_t seq_cache_size; /* Number of values cached. */
1231 db_seq_t seq_last_value; /* Last value cached. */
1232 db_seq_t seq_prev_value; /* Last value returned. */
1233 DBT seq_key; /* DBT pointing to sequence key. */
1234 DBT seq_data; /* DBT pointing to seq_record. */
1236 /* API-private structure: used by C++ and Java. */
1239 /* DB_SEQUENCE PUBLIC HANDLE LIST BEGIN */
1240 int (*close) __P((DB_SEQUENCE *, u_int32_t));
1241 int (*get) __P((DB_SEQUENCE *,
1242 DB_TXN *, int32_t, db_seq_t *, u_int32_t));
1243 int (*get_cachesize) __P((DB_SEQUENCE *, int32_t *));
1244 int (*get_db) __P((DB_SEQUENCE *, DB **));
1245 int (*get_flags) __P((DB_SEQUENCE *, u_int32_t *));
1246 int (*get_key) __P((DB_SEQUENCE *, DBT *));
1247 int (*get_range) __P((DB_SEQUENCE *,
1248 db_seq_t *, db_seq_t *));
1249 int (*initial_value) __P((DB_SEQUENCE *, db_seq_t));
1250 int (*open) __P((DB_SEQUENCE *,
1251 DB_TXN *, DBT *, u_int32_t));
1252 int (*remove) __P((DB_SEQUENCE *, DB_TXN *, u_int32_t));
1253 int (*set_cachesize) __P((DB_SEQUENCE *, int32_t));
1254 int (*set_flags) __P((DB_SEQUENCE *, u_int32_t));
1255 int (*set_range) __P((DB_SEQUENCE *, db_seq_t, db_seq_t));
1256 int (*stat) __P((DB_SEQUENCE *,
1257 DB_SEQUENCE_STAT **, u_int32_t));
1258 int (*stat_print) __P((DB_SEQUENCE *, u_int32_t));
1259 /* DB_SEQUENCE PUBLIC HANDLE LIST END */
1262 struct __db_seq_stat { /* SHARED */
1263 uintmax_t st_wait; /* Sequence lock granted w/o wait. */
1264 uintmax_t st_nowait; /* Sequence lock granted after wait. */
1265 db_seq_t st_current; /* Current value in db. */
1266 db_seq_t st_value; /* Current cached value. */
1267 db_seq_t st_last_value; /* Last cached value. */
1268 db_seq_t st_min; /* Minimum value. */
1269 db_seq_t st_max; /* Maximum value. */
1270 int32_t st_cache_size; /* Cache size. */
1271 u_int32_t st_flags; /* Flag value. */
1274 /*******************************************************
1276 *******************************************************/
1278 * Any new methods need to retain the original numbering. The type
1279 * is written in a log record so must be maintained.
1287 DB_UNKNOWN=5 /* Figure it out on open. */
1290 #define DB_RENAMEMAGIC 0x030800 /* File has been renamed. */
1292 #define DB_BTREEVERSION 9 /* Current btree version. */
1293 #define DB_BTREEOLDVER 8 /* Oldest btree version supported. */
1294 #define DB_BTREEMAGIC 0x053162
1296 #define DB_HASHVERSION 9 /* Current hash version. */
1297 #define DB_HASHOLDVER 7 /* Oldest hash version supported. */
1298 #define DB_HASHMAGIC 0x061561
1300 #define DB_HEAPVERSION 1 /* Current heap version. */
1301 #define DB_HEAPOLDVER 1 /* Oldest heap version supported. */
1302 #define DB_HEAPMAGIC 0x074582
1304 #define DB_QAMVERSION 4 /* Current queue version. */
1305 #define DB_QAMOLDVER 3 /* Oldest queue version supported. */
1306 #define DB_QAMMAGIC 0x042253
1308 #define DB_SEQUENCE_VERSION 2 /* Current sequence version. */
1309 #define DB_SEQUENCE_OLDVER 1 /* Oldest sequence version supported. */
1312 * DB access method and cursor operation values. Each value is an operation
1313 * code to which additional bit flags are added.
1315 #define DB_AFTER 1 /* Dbc.put */
1316 #define DB_APPEND 2 /* Db.put */
1317 #define DB_BEFORE 3 /* Dbc.put */
1318 #define DB_CONSUME 4 /* Db.get */
1319 #define DB_CONSUME_WAIT 5 /* Db.get */
1320 #define DB_CURRENT 6 /* Dbc.get, Dbc.put, DbLogc.get */
1321 #define DB_FIRST 7 /* Dbc.get, DbLogc->get */
1322 #define DB_GET_BOTH 8 /* Db.get, Dbc.get */
1323 #define DB_GET_BOTHC 9 /* Dbc.get (internal) */
1324 #define DB_GET_BOTH_RANGE 10 /* Db.get, Dbc.get */
1325 #define DB_GET_RECNO 11 /* Dbc.get */
1326 #define DB_JOIN_ITEM 12 /* Dbc.get; don't do primary lookup */
1327 #define DB_KEYFIRST 13 /* Dbc.put */
1328 #define DB_KEYLAST 14 /* Dbc.put */
1329 #define DB_LAST 15 /* Dbc.get, DbLogc->get */
1330 #define DB_NEXT 16 /* Dbc.get, DbLogc->get */
1331 #define DB_NEXT_DUP 17 /* Dbc.get */
1332 #define DB_NEXT_NODUP 18 /* Dbc.get */
1333 #define DB_NODUPDATA 19 /* Db.put, Dbc.put */
1334 #define DB_NOOVERWRITE 20 /* Db.put */
1335 #define DB_OVERWRITE_DUP 21 /* Dbc.put, Db.put; no DB_KEYEXIST */
1336 #define DB_POSITION 22 /* Dbc.dup */
1337 #define DB_PREV 23 /* Dbc.get, DbLogc->get */
1338 #define DB_PREV_DUP 24 /* Dbc.get */
1339 #define DB_PREV_NODUP 25 /* Dbc.get */
1340 #define DB_SET 26 /* Dbc.get, DbLogc->get */
1341 #define DB_SET_RANGE 27 /* Dbc.get */
1342 #define DB_SET_RECNO 28 /* Db.get, Dbc.get */
1343 #define DB_UPDATE_SECONDARY 29 /* Dbc.get, Dbc.del (internal) */
1344 #define DB_SET_LTE 30 /* Dbc.get (internal) */
1345 #define DB_GET_BOTH_LTE 31 /* Dbc.get (internal) */
1347 /* This has to change when the max opcode hits 255. */
1348 #define DB_OPFLAGS_MASK 0x000000ff /* Mask for operations flags. */
1351 * DB (user visible) error return codes.
1354 * We don't want our error returns to conflict with other packages where
1355 * possible, so pick a base error value that's hopefully not common. We
1356 * document that we own the error name space from -30,800 to -30,999.
1358 /* DB (public) error return codes. */
1359 #define DB_BUFFER_SMALL (-30999)/* User memory too small for return. */
1360 #define DB_DONOTINDEX (-30998)/* "Null" return from 2ndary callbk. */
1361 #define DB_FOREIGN_CONFLICT (-30997)/* A foreign db constraint triggered. */
1362 #define DB_HEAP_FULL (-30996)/* No free space in a heap file. */
1363 #define DB_KEYEMPTY (-30995)/* Key/data deleted or never created. */
1364 #define DB_KEYEXIST (-30994)/* The key/data pair already exists. */
1365 #define DB_LOCK_DEADLOCK (-30993)/* Deadlock. */
1366 #define DB_LOCK_NOTGRANTED (-30992)/* Lock unavailable. */
1367 #define DB_LOG_BUFFER_FULL (-30991)/* In-memory log buffer full. */
1368 #define DB_LOG_VERIFY_BAD (-30990)/* Log verification failed. */
1369 #define DB_NOSERVER (-30989)/* Server panic return. */
1370 #define DB_NOTFOUND (-30988)/* Key/data pair not found (EOF). */
1371 #define DB_OLD_VERSION (-30987)/* Out-of-date version. */
1372 #define DB_PAGE_NOTFOUND (-30986)/* Requested page not found. */
1373 #define DB_REP_DUPMASTER (-30985)/* There are two masters. */
1374 #define DB_REP_HANDLE_DEAD (-30984)/* Rolled back a commit. */
1375 #define DB_REP_HOLDELECTION (-30983)/* Time to hold an election. */
1376 #define DB_REP_IGNORE (-30982)/* This msg should be ignored.*/
1377 #define DB_REP_ISPERM (-30981)/* Cached not written perm written.*/
1378 #define DB_REP_JOIN_FAILURE (-30980)/* Unable to join replication group. */
1379 #define DB_REP_LEASE_EXPIRED (-30979)/* Master lease has expired. */
1380 #define DB_REP_LOCKOUT (-30978)/* API/Replication lockout now. */
1381 #define DB_REP_NEWSITE (-30977)/* New site entered system. */
1382 #define DB_REP_NOTPERM (-30976)/* Permanent log record not written. */
1383 #define DB_REP_UNAVAIL (-30975)/* Site cannot currently be reached. */
1384 #define DB_REP_WOULDROLLBACK (-30974)/* UNDOC: rollback inhibited by app. */
1385 #define DB_RUNRECOVERY (-30973)/* Panic return. */
1386 #define DB_SECONDARY_BAD (-30972)/* Secondary index corrupt. */
1387 #define DB_TIMEOUT (-30971)/* Timed out on read consistency. */
1388 #define DB_VERIFY_BAD (-30970)/* Verify failed; bad format. */
1389 #define DB_VERSION_MISMATCH (-30969)/* Environment version mismatch. */
1391 /* DB (private) error return codes. */
1392 #define DB_ALREADY_ABORTED (-30899)
1393 #define DB_CHKSUM_FAIL (-30898)/* Checksum failed. */
1394 #define DB_DELETED (-30897)/* Recovery file marked deleted. */
1395 #define DB_EVENT_NOT_HANDLED (-30896)/* Forward event to application. */
1396 #define DB_NEEDSPLIT (-30895)/* Page needs to be split. */
1397 #define DB_REP_BULKOVF (-30894)/* Rep bulk buffer overflow. */
1398 #define DB_REP_LOGREADY (-30893)/* Rep log ready for recovery. */
1399 #define DB_REP_NEWMASTER (-30892)/* We have learned of a new master. */
1400 #define DB_REP_PAGEDONE (-30891)/* This page was already done. */
1401 #define DB_SURPRISE_KID (-30890)/* Child commit where parent
1402 didn't know it was a parent. */
1403 #define DB_SWAPBYTES (-30889)/* Database needs byte swapping. */
1404 #define DB_TXN_CKP (-30888)/* Encountered ckp record in log. */
1405 #define DB_VERIFY_FATAL (-30887)/* DB->verify cannot proceed. */
1407 /* Database handle. */
1409 /*******************************************************
1410 * Public: owned by the application.
1411 *******************************************************/
1412 u_int32_t pgsize; /* Database logical page size. */
1413 DB_CACHE_PRIORITY priority; /* Database priority in cache. */
1416 int (*db_append_recno) __P((DB *, DBT *, db_recno_t));
1417 void (*db_feedback) __P((DB *, int, int));
1418 int (*dup_compare) __P((DB *, const DBT *, const DBT *));
1420 void *app_private; /* Application-private handle. */
1422 /*******************************************************
1423 * Private: owned by DB.
1424 *******************************************************/
1425 DB_ENV *dbenv; /* Backing public environment. */
1426 ENV *env; /* Backing private environment. */
1428 DBTYPE type; /* DB access method type. */
1430 DB_MPOOLFILE *mpf; /* Backing buffer pool. */
1432 db_mutex_t mutex; /* Synchronization for free threading */
1434 char *fname, *dname; /* File/database passed to DB->open. */
1435 const char *dirname; /* Directory of DB file. */
1436 u_int32_t open_flags; /* Flags passed to DB->open. */
1438 u_int8_t fileid[DB_FILE_ID_LEN];/* File's unique ID for locking. */
1440 u_int32_t adj_fileid; /* File's unique ID for curs. adj. */
1442 #define DB_LOGFILEID_INVALID -1
1443 FNAME *log_filename; /* File's naming info for logging. */
1445 db_pgno_t meta_pgno; /* Meta page number */
1446 DB_LOCKER *locker; /* Locker for handle locking. */
1447 DB_LOCKER *cur_locker; /* Current handle lock holder. */
1448 DB_TXN *cur_txn; /* Opening transaction. */
1449 DB_LOCKER *associate_locker; /* Locker for DB->associate call. */
1450 DB_LOCK handle_lock; /* Lock held on this handle. */
1452 time_t timestamp; /* Handle timestamp for replication. */
1453 u_int32_t fid_gen; /* Rep generation number for fids. */
1456 * Returned data memory for DB->get() and friends.
1458 DBT my_rskey; /* Secondary key. */
1459 DBT my_rkey; /* [Primary] key. */
1460 DBT my_rdata; /* Data. */
1464 * Some applications use DB but implement their own locking outside of
1465 * DB. If they're using fcntl(2) locking on the underlying database
1466 * file, and we open and close a file descriptor for that file, we will
1467 * discard their locks. The DB_FCNTL_LOCKING flag to DB->open is an
1468 * undocumented interface to support this usage which leaves any file
1469 * descriptors we open until DB->close. This will only work with the
1470 * DB->open interface and simple caches, e.g., creating a transaction
1471 * thread may open/close file descriptors this flag doesn't protect.
1472 * Locking with fcntl(2) on a file that you don't own is a very, very
1473 * unsafe thing to do. 'Nuff said.
1475 DB_FH *saved_open_fhp; /* Saved file handle. */
1478 * Linked list of DBP's, linked from the ENV, used to keep track
1479 * of all open db handles for cursor adjustment.
1482 * Explicit representations of structures from queue.h.
1483 * TAILQ_ENTRY(__db) dblistlinks;
1486 struct __db *tqe_next;
1487 struct __db **tqe_prev;
1494 * Explicit representations of structures from queue.h.
1495 * TAILQ_HEAD(__cq_fq, __dbc) free_queue;
1496 * TAILQ_HEAD(__cq_aq, __dbc) active_queue;
1497 * TAILQ_HEAD(__cq_jq, __dbc) join_queue;
1500 struct __dbc *tqh_first;
1501 struct __dbc **tqh_last;
1504 struct __dbc *tqh_first;
1505 struct __dbc **tqh_last;
1508 struct __dbc *tqh_first;
1509 struct __dbc **tqh_last;
1513 * Secondary index support.
1515 * Linked list of secondary indices -- set in the primary.
1518 * Explicit representations of structures from queue.h.
1519 * LIST_HEAD(s_secondaries, __db);
1522 struct __db *lh_first;
1526 * List entries for secondaries, and reference count of how many
1527 * threads are updating this secondary (see Dbc.put).
1530 * Note that these are synchronized by the primary's mutex, but
1531 * filled in in the secondaries.
1534 * Explicit representations of structures from queue.h.
1535 * LIST_ENTRY(__db) s_links;
1538 struct __db *le_next;
1539 struct __db **le_prev;
1543 /* Secondary callback and free functions -- set in the secondary. */
1544 int (*s_callback) __P((DB *, const DBT *, const DBT *, DBT *));
1546 /* Reference to primary -- set in the secondary. */
1549 #define DB_ASSOC_IMMUTABLE_KEY 0x00000001 /* Secondary key is immutable. */
1550 #define DB_ASSOC_CREATE 0x00000002 /* Secondary db populated on open. */
1552 /* Flags passed to associate -- set in the secondary. */
1553 u_int32_t s_assoc_flags;
1556 * Foreign key support.
1558 * Linked list of primary dbs -- set in the foreign db
1561 * Explicit representations of structures from queue.h.
1562 * LIST_HEAD(f_primaries, __db);
1565 struct __db_foreign_info *lh_first;
1570 * Explicit representations of structures from queue.h.
1571 * TAILQ_ENTRY(__db) felink;
1573 * Links in a list of DBs involved in file extension
1574 * during a transaction. These are to be used only while the
1575 * metadata is locked.
1578 struct __db *tqe_next;
1579 struct __db **tqe_prev;
1582 /* Reference to foreign -- set in the secondary. */
1585 /* API-private structure: used by DB 1.85, C++, Java, Perl and Tcl */
1588 /* Subsystem-private structure. */
1589 void *bt_internal; /* Btree/Recno access method. */
1590 void *h_internal; /* Hash access method. */
1591 void *heap_internal; /* Heap access method. */
1592 void *p_internal; /* Partition informaiton. */
1593 void *q_internal; /* Queue access method. */
1595 /* DB PUBLIC HANDLE LIST BEGIN */
1596 int (*associate) __P((DB *, DB_TXN *, DB *,
1597 int (*)(DB *, const DBT *, const DBT *, DBT *), u_int32_t));
1598 int (*associate_foreign) __P((DB *, DB *,
1599 int (*)(DB *, const DBT *, DBT *, const DBT *, int *),
1601 int (*close) __P((DB *, u_int32_t));
1602 int (*compact) __P((DB *,
1603 DB_TXN *, DBT *, DBT *, DB_COMPACT *, u_int32_t, DBT *));
1604 int (*cursor) __P((DB *, DB_TXN *, DBC **, u_int32_t));
1605 int (*del) __P((DB *, DB_TXN *, DBT *, u_int32_t));
1606 void (*err) __P((DB *, int, const char *, ...));
1607 void (*errx) __P((DB *, const char *, ...));
1608 int (*exists) __P((DB *, DB_TXN *, DBT *, u_int32_t));
1609 int (*fd) __P((DB *, int *));
1610 int (*get) __P((DB *, DB_TXN *, DBT *, DBT *, u_int32_t));
1611 int (*get_alloc) __P((DB *, void *(**)(size_t),
1612 void *(**)(void *, size_t), void (**)(void *)));
1613 int (*get_append_recno) __P((DB *, int (**)(DB *, DBT *, db_recno_t)));
1614 int (*get_assoc_flags) __P((DB *, u_int32_t *));
1615 int (*get_bt_compare)
1616 __P((DB *, int (**)(DB *, const DBT *, const DBT *)));
1617 int (*get_bt_compress) __P((DB *,
1619 const DBT *, const DBT *, const DBT *, const DBT *, DBT *),
1620 int (**)(DB *, const DBT *, const DBT *, DBT *, DBT *, DBT *)));
1621 int (*get_bt_minkey) __P((DB *, u_int32_t *));
1622 int (*get_bt_prefix)
1623 __P((DB *, size_t (**)(DB *, const DBT *, const DBT *)));
1624 int (*get_byteswapped) __P((DB *, int *));
1625 int (*get_cachesize) __P((DB *, u_int32_t *, u_int32_t *, int *));
1626 int (*get_create_dir) __P((DB *, const char **));
1627 int (*get_dbname) __P((DB *, const char **, const char **));
1628 int (*get_dup_compare)
1629 __P((DB *, int (**)(DB *, const DBT *, const DBT *)));
1630 int (*get_encrypt_flags) __P((DB *, u_int32_t *));
1631 DB_ENV *(*get_env) __P((DB *));
1632 void (*get_errcall) __P((DB *,
1633 void (**)(const DB_ENV *, const char *, const char *)));
1634 void (*get_errfile) __P((DB *, FILE **));
1635 void (*get_errpfx) __P((DB *, const char **));
1636 int (*get_feedback) __P((DB *, void (**)(DB *, int, int)));
1637 int (*get_flags) __P((DB *, u_int32_t *));
1638 int (*get_h_compare)
1639 __P((DB *, int (**)(DB *, const DBT *, const DBT *)));
1640 int (*get_h_ffactor) __P((DB *, u_int32_t *));
1642 __P((DB *, u_int32_t (**)(DB *, const void *, u_int32_t)));
1643 int (*get_h_nelem) __P((DB *, u_int32_t *));
1644 int (*get_heapsize) __P((DB *, u_int32_t *, u_int32_t *));
1645 int (*get_heap_regionsize) __P((DB *, u_int32_t *));
1646 int (*get_lk_exclusive) __P((DB *, int *, int *));
1647 int (*get_lorder) __P((DB *, int *));
1648 DB_MPOOLFILE *(*get_mpf) __P((DB *));
1649 void (*get_msgcall) __P((DB *,
1650 void (**)(const DB_ENV *, const char *)));
1651 void (*get_msgfile) __P((DB *, FILE **));
1652 int (*get_multiple) __P((DB *));
1653 int (*get_open_flags) __P((DB *, u_int32_t *));
1654 int (*get_pagesize) __P((DB *, u_int32_t *));
1655 int (*get_partition_callback) __P((DB *,
1656 u_int32_t *, u_int32_t (**)(DB *, DBT *key)));
1657 int (*get_partition_dirs) __P((DB *, const char ***));
1658 int (*get_partition_keys) __P((DB *, u_int32_t *, DBT **));
1659 int (*get_priority) __P((DB *, DB_CACHE_PRIORITY *));
1660 int (*get_q_extentsize) __P((DB *, u_int32_t *));
1661 int (*get_re_delim) __P((DB *, int *));
1662 int (*get_re_len) __P((DB *, u_int32_t *));
1663 int (*get_re_pad) __P((DB *, int *));
1664 int (*get_re_source) __P((DB *, const char **));
1665 int (*get_transactional) __P((DB *));
1666 int (*get_type) __P((DB *, DBTYPE *));
1667 int (*join) __P((DB *, DBC **, DBC **, u_int32_t));
1669 __P((DB *, DB_TXN *, DBT *, DB_KEY_RANGE *, u_int32_t));
1670 int (*open) __P((DB *,
1671 DB_TXN *, const char *, const char *, DBTYPE, u_int32_t, int));
1672 int (*pget) __P((DB *, DB_TXN *, DBT *, DBT *, DBT *, u_int32_t));
1673 int (*put) __P((DB *, DB_TXN *, DBT *, DBT *, u_int32_t));
1674 int (*remove) __P((DB *, const char *, const char *, u_int32_t));
1675 int (*rename) __P((DB *,
1676 const char *, const char *, const char *, u_int32_t));
1677 int (*set_alloc) __P((DB *, void *(*)(size_t),
1678 void *(*)(void *, size_t), void (*)(void *)));
1679 int (*set_append_recno) __P((DB *, int (*)(DB *, DBT *, db_recno_t)));
1680 int (*set_bt_compare)
1681 __P((DB *, int (*)(DB *, const DBT *, const DBT *)));
1682 int (*set_bt_compress) __P((DB *,
1683 int (*)(DB *, const DBT *, const DBT *, const DBT *, const DBT *, DBT *),
1684 int (*)(DB *, const DBT *, const DBT *, DBT *, DBT *, DBT *)));
1685 int (*set_bt_minkey) __P((DB *, u_int32_t));
1686 int (*set_bt_prefix)
1687 __P((DB *, size_t (*)(DB *, const DBT *, const DBT *)));
1688 int (*set_cachesize) __P((DB *, u_int32_t, u_int32_t, int));
1689 int (*set_create_dir) __P((DB *, const char *));
1690 int (*set_dup_compare)
1691 __P((DB *, int (*)(DB *, const DBT *, const DBT *)));
1692 int (*set_encrypt) __P((DB *, const char *, u_int32_t));
1693 void (*set_errcall) __P((DB *,
1694 void (*)(const DB_ENV *, const char *, const char *)));
1695 void (*set_errfile) __P((DB *, FILE *));
1696 void (*set_errpfx) __P((DB *, const char *));
1697 int (*set_feedback) __P((DB *, void (*)(DB *, int, int)));
1698 int (*set_flags) __P((DB *, u_int32_t));
1699 int (*set_h_compare)
1700 __P((DB *, int (*)(DB *, const DBT *, const DBT *)));
1701 int (*set_h_ffactor) __P((DB *, u_int32_t));
1703 __P((DB *, u_int32_t (*)(DB *, const void *, u_int32_t)));
1704 int (*set_h_nelem) __P((DB *, u_int32_t));
1705 int (*set_heapsize) __P((DB *, u_int32_t, u_int32_t, u_int32_t));
1706 int (*set_heap_regionsize) __P((DB *, u_int32_t));
1707 int (*set_lk_exclusive) __P((DB *, int));
1708 int (*set_lorder) __P((DB *, int));
1709 void (*set_msgcall) __P((DB *, void (*)(const DB_ENV *, const char *)));
1710 void (*set_msgfile) __P((DB *, FILE *));
1711 int (*set_pagesize) __P((DB *, u_int32_t));
1712 int (*set_paniccall) __P((DB *, void (*)(DB_ENV *, int)));
1713 int (*set_partition) __P((DB *,
1714 u_int32_t, DBT *, u_int32_t (*)(DB *, DBT *key)));
1715 int (*set_partition_dirs) __P((DB *, const char **));
1716 int (*set_priority) __P((DB *, DB_CACHE_PRIORITY));
1717 int (*set_q_extentsize) __P((DB *, u_int32_t));
1718 int (*set_re_delim) __P((DB *, int));
1719 int (*set_re_len) __P((DB *, u_int32_t));
1720 int (*set_re_pad) __P((DB *, int));
1721 int (*set_re_source) __P((DB *, const char *));
1722 int (*sort_multiple) __P((DB *, DBT *, DBT *, u_int32_t));
1723 int (*stat) __P((DB *, DB_TXN *, void *, u_int32_t));
1724 int (*stat_print) __P((DB *, u_int32_t));
1725 int (*sync) __P((DB *, u_int32_t));
1726 int (*truncate) __P((DB *, DB_TXN *, u_int32_t *, u_int32_t));
1727 int (*upgrade) __P((DB *, const char *, u_int32_t));
1729 __P((DB *, const char *, const char *, FILE *, u_int32_t));
1730 /* DB PUBLIC HANDLE LIST END */
1732 /* DB PRIVATE HANDLE LIST BEGIN */
1733 int (*dump) __P((DB *, const char *,
1734 int (*)(void *, const void *), void *, int, int));
1735 int (*db_am_remove) __P((DB *, DB_THREAD_INFO *,
1736 DB_TXN *, const char *, const char *, u_int32_t));
1737 int (*db_am_rename) __P((DB *, DB_THREAD_INFO *,
1738 DB_TXN *, const char *, const char *, const char *));
1739 /* DB PRIVATE HANDLE LIST END */
1742 * Never called; these are a place to save function pointers
1743 * so that we can undo an associate.
1745 int (*stored_get) __P((DB *, DB_TXN *, DBT *, DBT *, u_int32_t));
1746 int (*stored_close) __P((DB *, u_int32_t));
1748 /* Alternative handle close function, used by C++ API. */
1749 int (*alt_close) __P((DB *, u_int32_t));
1751 #define DB_OK_BTREE 0x01
1752 #define DB_OK_HASH 0x02
1753 #define DB_OK_HEAP 0x04
1754 #define DB_OK_QUEUE 0x08
1755 #define DB_OK_RECNO 0x10
1756 u_int32_t am_ok; /* Legal AM choices. */
1759 * This field really ought to be an AM_FLAG, but we have
1760 * have run out of bits. If/when we decide to split up
1761 * the flags, we can incorporate it.
1763 int preserve_fid; /* Do not free fileid on close. */
1765 #define DB_AM_CHKSUM 0x00000001 /* Checksumming */
1766 #define DB_AM_COMPENSATE 0x00000002 /* Created by compensating txn */
1767 #define DB_AM_COMPRESS 0x00000004 /* Compressed BTree */
1768 #define DB_AM_CREATED 0x00000008 /* Database was created upon open */
1769 #define DB_AM_CREATED_MSTR 0x00000010 /* Encompassing file was created */
1770 #define DB_AM_DBM_ERROR 0x00000020 /* Error in DBM/NDBM database */
1771 #define DB_AM_DELIMITER 0x00000040 /* Variable length delimiter set */
1772 #define DB_AM_DISCARD 0x00000080 /* Discard any cached pages */
1773 #define DB_AM_DUP 0x00000100 /* DB_DUP */
1774 #define DB_AM_DUPSORT 0x00000200 /* DB_DUPSORT */
1775 #define DB_AM_ENCRYPT 0x00000400 /* Encryption */
1776 #define DB_AM_FIXEDLEN 0x00000800 /* Fixed-length records */
1777 #define DB_AM_INMEM 0x00001000 /* In-memory; no sync on close */
1778 #define DB_AM_INORDER 0x00002000 /* DB_INORDER */
1779 #define DB_AM_IN_RENAME 0x00004000 /* File is being renamed */
1780 #define DB_AM_NOT_DURABLE 0x00008000 /* Do not log changes */
1781 #define DB_AM_OPEN_CALLED 0x00010000 /* DB->open called */
1782 #define DB_AM_PAD 0x00020000 /* Fixed-length record pad */
1783 #define DB_AM_PARTDB 0x00040000 /* Handle for a database partition */
1784 #define DB_AM_PGDEF 0x00080000 /* Page size was defaulted */
1785 #define DB_AM_RDONLY 0x00100000 /* Database is readonly */
1786 #define DB_AM_READ_UNCOMMITTED 0x00200000 /* Support degree 1 isolation */
1787 #define DB_AM_RECNUM 0x00400000 /* DB_RECNUM */
1788 #define DB_AM_RECOVER 0x00800000 /* DB opened by recovery routine */
1789 #define DB_AM_RENUMBER 0x01000000 /* DB_RENUMBER */
1790 #define DB_AM_REVSPLITOFF 0x02000000 /* DB_REVSPLITOFF */
1791 #define DB_AM_SECONDARY 0x04000000 /* Database is a secondary index */
1792 #define DB_AM_SNAPSHOT 0x08000000 /* DB_SNAPSHOT */
1793 #define DB_AM_SUBDB 0x10000000 /* Subdatabases supported */
1794 #define DB_AM_SWAP 0x20000000 /* Pages need to be byte-swapped */
1795 #define DB_AM_TXN 0x40000000 /* Opened in a transaction */
1796 #define DB_AM_VERIFYING 0x80000000 /* DB handle is in the verifier */
1797 u_int32_t orig_flags; /* Flags at open, for refresh */
1800 #define DB2_AM_EXCL 0x00000001 /* Exclusively lock the handle */
1801 #define DB2_AM_INTEXCL 0x00000002 /* Internal exclusive lock. */
1802 #define DB2_AM_NOWAIT 0x00000004 /* Do not wait for handle lock */
1803 u_int32_t orig_flags2; /* Second flags word; for refresh */
1804 u_int32_t flags2; /* Second flags word */
1808 * Macros for bulk operations. These are only intended for the C API.
1809 * For C++, use DbMultiple*Iterator or DbMultiple*Builder.
1811 * Bulk operations store multiple entries into a single DBT structure. The
1812 * following macros assist with creating and reading these Multiple DBTs.
1814 * The basic layout for single data items is:
1816 * -------------------------------------------------------------------------
1817 * | data1 | ... | dataN | ..... |-1 | dNLen | dNOff | ... | d1Len | d1Off |
1818 * -------------------------------------------------------------------------
1820 * For the DB_MULTIPLE_KEY* macros, the items are in key/data pairs, so data1
1821 * would be a key, and data2 its corresponding value (N is always even).
1823 * For the DB_MULTIPLE_RECNO* macros, the record number is stored along with
1824 * the len/off pair in the "header" section, and the list is zero terminated
1825 * (since -1 is a valid record number):
1827 * --------------------------------------------------------------------------
1828 * | d1 |..| dN |..| 0 | dNLen | dNOff | recnoN |..| d1Len | d1Off | recno1 |
1829 * --------------------------------------------------------------------------
1831 #define DB_MULTIPLE_INIT(pointer, dbt) \
1832 (pointer = (u_int8_t *)(dbt)->data + \
1833 (dbt)->ulen - sizeof(u_int32_t))
1835 #define DB_MULTIPLE_NEXT(pointer, dbt, retdata, retdlen) \
1837 u_int32_t *__p = (u_int32_t *)(pointer); \
1838 if (*__p == (u_int32_t)-1) { \
1843 retdata = (u_int8_t *)(dbt)->data + *__p--; \
1846 if (retdlen == 0 && retdata == (u_int8_t *)(dbt)->data) \
1850 #define DB_MULTIPLE_KEY_NEXT(pointer, dbt, retkey, retklen, retdata, retdlen) \
1852 u_int32_t *__p = (u_int32_t *)(pointer); \
1853 if (*__p == (u_int32_t)-1) { \
1859 retkey = (u_int8_t *)(dbt)->data + *__p--; \
1861 retdata = (u_int8_t *)(dbt)->data + *__p--; \
1866 #define DB_MULTIPLE_RECNO_NEXT(pointer, dbt, recno, retdata, retdlen) \
1868 u_int32_t *__p = (u_int32_t *)(pointer); \
1869 if (*__p == (u_int32_t)0) { \
1876 retdata = (u_int8_t *)(dbt)->data + *__p--; \
1881 #define DB_MULTIPLE_WRITE_INIT(pointer, dbt) \
1883 (dbt)->flags |= DB_DBT_BULK; \
1884 pointer = (u_int8_t *)(dbt)->data + \
1885 (dbt)->ulen - sizeof(u_int32_t); \
1886 *(u_int32_t *)(pointer) = (u_int32_t)-1; \
1889 #define DB_MULTIPLE_RESERVE_NEXT(pointer, dbt, writedata, writedlen) \
1891 u_int32_t *__p = (u_int32_t *)(pointer); \
1892 u_int32_t __off = ((pointer) == (u_int8_t *)(dbt)->data +\
1893 (dbt)->ulen - sizeof(u_int32_t)) ? 0 : __p[1] + __p[2];\
1894 if ((u_int8_t *)(dbt)->data + __off + (writedlen) > \
1895 (u_int8_t *)(__p - 2)) \
1898 writedata = (u_int8_t *)(dbt)->data + __off; \
1900 __p[-1] = (u_int32_t)(writedlen); \
1901 __p[-2] = (u_int32_t)-1; \
1902 pointer = __p - 2; \
1906 #define DB_MULTIPLE_WRITE_NEXT(pointer, dbt, writedata, writedlen) \
1909 DB_MULTIPLE_RESERVE_NEXT((pointer), (dbt), \
1910 __destd, (writedlen)); \
1911 if (__destd == NULL) \
1914 memcpy(__destd, (writedata), (writedlen)); \
1917 #define DB_MULTIPLE_KEY_RESERVE_NEXT(pointer, dbt, writekey, writeklen, writedata, writedlen) \
1919 u_int32_t *__p = (u_int32_t *)(pointer); \
1920 u_int32_t __off = ((pointer) == (u_int8_t *)(dbt)->data +\
1921 (dbt)->ulen - sizeof(u_int32_t)) ? 0 : __p[1] + __p[2];\
1922 if ((u_int8_t *)(dbt)->data + __off + (writeklen) + \
1923 (writedlen) > (u_int8_t *)(__p - 4)) { \
1927 writekey = (u_int8_t *)(dbt)->data + __off; \
1929 __p[-1] = (u_int32_t)(writeklen); \
1931 __off += (u_int32_t)(writeklen); \
1932 writedata = (u_int8_t *)(dbt)->data + __off; \
1934 __p[-1] = (u_int32_t)(writedlen); \
1935 __p[-2] = (u_int32_t)-1; \
1936 pointer = __p - 2; \
1940 #define DB_MULTIPLE_KEY_WRITE_NEXT(pointer, dbt, writekey, writeklen, writedata, writedlen) \
1942 void *__destk, *__destd; \
1943 DB_MULTIPLE_KEY_RESERVE_NEXT((pointer), (dbt), \
1944 __destk, (writeklen), __destd, (writedlen)); \
1945 if (__destk == NULL) \
1948 memcpy(__destk, (writekey), (writeklen)); \
1949 if (__destd != NULL) \
1950 memcpy(__destd, (writedata), (writedlen));\
1954 #define DB_MULTIPLE_RECNO_WRITE_INIT(pointer, dbt) \
1956 (dbt)->flags |= DB_DBT_BULK; \
1957 pointer = (u_int8_t *)(dbt)->data + \
1958 (dbt)->ulen - sizeof(u_int32_t); \
1959 *(u_int32_t *)(pointer) = 0; \
1962 #define DB_MULTIPLE_RECNO_RESERVE_NEXT(pointer, dbt, recno, writedata, writedlen) \
1964 u_int32_t *__p = (u_int32_t *)(pointer); \
1965 u_int32_t __off = ((pointer) == (u_int8_t *)(dbt)->data +\
1966 (dbt)->ulen - sizeof(u_int32_t)) ? 0 : __p[1] + __p[2]; \
1967 if (((u_int8_t *)(dbt)->data + __off) + (writedlen) > \
1968 (u_int8_t *)(__p - 3)) \
1971 writedata = (u_int8_t *)(dbt)->data + __off; \
1972 __p[0] = (u_int32_t)(recno); \
1974 __p[-2] = (u_int32_t)(writedlen); \
1976 pointer = __p - 3; \
1980 #define DB_MULTIPLE_RECNO_WRITE_NEXT(pointer, dbt, recno, writedata, writedlen)\
1983 DB_MULTIPLE_RECNO_RESERVE_NEXT((pointer), (dbt), \
1984 (recno), __destd, (writedlen)); \
1985 if (__destd == NULL) \
1987 else if ((writedlen) != 0) \
1988 memcpy(__destd, (writedata), (writedlen)); \
1991 struct __db_heap_rid {
1992 db_pgno_t pgno; /* Page number. */
1993 db_indx_t indx; /* Index in the offset table. */
1995 #define DB_HEAP_RID_SZ (sizeof(db_pgno_t) + sizeof(db_indx_t))
1997 /*******************************************************
1998 * Access method cursors.
1999 *******************************************************/
2001 DB *dbp; /* Backing database */
2002 DB_ENV *dbenv; /* Backing environment */
2003 ENV *env; /* Backing environment */
2005 DB_THREAD_INFO *thread_info; /* Thread that owns this cursor. */
2006 DB_TXN *txn; /* Associated transaction. */
2007 DB_CACHE_PRIORITY priority; /* Priority in cache. */
2010 * Active/free cursor queues.
2013 * Explicit representations of structures from queue.h.
2014 * TAILQ_ENTRY(__dbc) links;
2022 * Cursor queue of the owning transaction.
2025 * Explicit representations of structures from queue.h.
2026 * TAILQ_ENTRY(__dbc) txn_cursors;
2029 DBC *tqe_next; /* next element */
2030 DBC **tqe_prev; /* address of previous next element */
2034 * The DBT *'s below are used by the cursor routines to return
2035 * data to the user when DBT flags indicate that DB should manage
2036 * the returned memory. They point at a DBT containing the buffer
2037 * and length that will be used, and "belonging" to the handle that
2038 * should "own" this memory. This may be a "my_*" field of this
2039 * cursor--the default--or it may be the corresponding field of
2040 * another cursor, a DB handle, a join cursor, etc. In general, it
2041 * will be whatever handle the user originally used for the current
2042 * DB interface call.
2044 DBT *rskey; /* Returned secondary key. */
2045 DBT *rkey; /* Returned [primary] key. */
2046 DBT *rdata; /* Returned data. */
2048 DBT my_rskey; /* Space for returned secondary key. */
2049 DBT my_rkey; /* Space for returned [primary] key. */
2050 DBT my_rdata; /* Space for returned data. */
2052 DB_LOCKER *lref; /* Reference to default locker. */
2053 DB_LOCKER *locker; /* Locker for this operation. */
2054 DBT lock_dbt; /* DBT referencing lock. */
2055 DB_LOCK_ILOCK lock; /* Object to be locked. */
2056 DB_LOCK mylock; /* CDB lock held on this cursor. */
2058 DBTYPE dbtype; /* Cursor type. */
2060 DBC_INTERNAL *internal; /* Access method private. */
2062 /* DBC PUBLIC HANDLE LIST BEGIN */
2063 int (*close) __P((DBC *));
2064 int (*cmp) __P((DBC *, DBC *, int *, u_int32_t));
2065 int (*count) __P((DBC *, db_recno_t *, u_int32_t));
2066 int (*del) __P((DBC *, u_int32_t));
2067 int (*dup) __P((DBC *, DBC **, u_int32_t));
2068 int (*get) __P((DBC *, DBT *, DBT *, u_int32_t));
2069 int (*get_priority) __P((DBC *, DB_CACHE_PRIORITY *));
2070 int (*pget) __P((DBC *, DBT *, DBT *, DBT *, u_int32_t));
2071 int (*put) __P((DBC *, DBT *, DBT *, u_int32_t));
2072 int (*set_priority) __P((DBC *, DB_CACHE_PRIORITY));
2073 /* DBC PUBLIC HANDLE LIST END */
2075 /* The following are the method names deprecated in the 4.6 release. */
2076 int (*c_close) __P((DBC *));
2077 int (*c_count) __P((DBC *, db_recno_t *, u_int32_t));
2078 int (*c_del) __P((DBC *, u_int32_t));
2079 int (*c_dup) __P((DBC *, DBC **, u_int32_t));
2080 int (*c_get) __P((DBC *, DBT *, DBT *, u_int32_t));
2081 int (*c_pget) __P((DBC *, DBT *, DBT *, DBT *, u_int32_t));
2082 int (*c_put) __P((DBC *, DBT *, DBT *, u_int32_t));
2084 /* DBC PRIVATE HANDLE LIST BEGIN */
2085 int (*am_bulk) __P((DBC *, DBT *, u_int32_t));
2086 int (*am_close) __P((DBC *, db_pgno_t, int *));
2087 int (*am_del) __P((DBC *, u_int32_t));
2088 int (*am_destroy) __P((DBC *));
2089 int (*am_get) __P((DBC *, DBT *, DBT *, u_int32_t, db_pgno_t *));
2090 int (*am_put) __P((DBC *, DBT *, DBT *, u_int32_t, db_pgno_t *));
2091 int (*am_writelock) __P((DBC *));
2092 /* DBC PRIVATE HANDLE LIST END */
2095 * DBC_DONTLOCK and DBC_RECOVER are used during recovery and transaction
2096 * abort. If a transaction is being aborted or recovered then DBC_RECOVER
2097 * will be set and locking and logging will be disabled on this cursor. If
2098 * we are performing a compensating transaction (e.g. free page processing)
2099 * then DB_DONTLOCK will be set to inhibit locking, but logging will still
2100 * be required. DB_DONTLOCK is also used if the whole database is locked.
2102 #define DBC_ACTIVE 0x00001 /* Cursor in use. */
2103 #define DBC_BULK 0x00002 /* Bulk update cursor. */
2104 #define DBC_DONTLOCK 0x00004 /* Don't lock on this cursor. */
2105 #define DBC_DOWNREV 0x00008 /* Down rev replication master. */
2106 #define DBC_DUPLICATE 0x00010 /* Create a duplicate cursor. */
2107 #define DBC_ERROR 0x00020 /* Error in this request. */
2108 #define DBC_FAMILY 0x00040 /* Part of a locker family. */
2109 #define DBC_FROM_DB_GET 0x00080 /* Called from the DB->get() method. */
2110 #define DBC_MULTIPLE 0x00100 /* Return Multiple data. */
2111 #define DBC_MULTIPLE_KEY 0x00200 /* Return Multiple keys and data. */
2112 #define DBC_OPD 0x00400 /* Cursor references off-page dups. */
2113 #define DBC_OWN_LID 0x00800 /* Free lock id on destroy. */
2114 #define DBC_PARTITIONED 0x01000 /* Cursor for a partitioned db. */
2115 #define DBC_READ_COMMITTED 0x02000 /* Cursor has degree 2 isolation. */
2116 #define DBC_READ_UNCOMMITTED 0x04000 /* Cursor has degree 1 isolation. */
2117 #define DBC_RECOVER 0x08000 /* Recovery cursor; don't log/lock. */
2118 #define DBC_RMW 0x10000 /* Acquire write flag in read op. */
2119 #define DBC_TRANSIENT 0x20000 /* Cursor is transient. */
2120 #define DBC_WAS_READ_COMMITTED 0x40000 /* Cursor holds a read commited lock. */
2121 #define DBC_WRITECURSOR 0x80000 /* Cursor may be used to write (CDB). */
2122 #define DBC_WRITER 0x100000 /* Cursor immediately writing (CDB). */
2126 /* Key range statistics structure */
2127 struct __key_range {
2133 /* Btree/Recno statistics structure. */
2134 struct __db_bt_stat { /* SHARED */
2135 u_int32_t bt_magic; /* Magic number. */
2136 u_int32_t bt_version; /* Version number. */
2137 u_int32_t bt_metaflags; /* Metadata flags. */
2138 u_int32_t bt_nkeys; /* Number of unique keys. */
2139 u_int32_t bt_ndata; /* Number of data items. */
2140 u_int32_t bt_pagecnt; /* Page count. */
2141 u_int32_t bt_pagesize; /* Page size. */
2142 u_int32_t bt_minkey; /* Minkey value. */
2143 u_int32_t bt_re_len; /* Fixed-length record length. */
2144 u_int32_t bt_re_pad; /* Fixed-length record pad. */
2145 u_int32_t bt_levels; /* Tree levels. */
2146 u_int32_t bt_int_pg; /* Internal pages. */
2147 u_int32_t bt_leaf_pg; /* Leaf pages. */
2148 u_int32_t bt_dup_pg; /* Duplicate pages. */
2149 u_int32_t bt_over_pg; /* Overflow pages. */
2150 u_int32_t bt_empty_pg; /* Empty pages. */
2151 u_int32_t bt_free; /* Pages on the free list. */
2152 uintmax_t bt_int_pgfree; /* Bytes free in internal pages. */
2153 uintmax_t bt_leaf_pgfree; /* Bytes free in leaf pages. */
2154 uintmax_t bt_dup_pgfree; /* Bytes free in duplicate pages. */
2155 uintmax_t bt_over_pgfree; /* Bytes free in overflow pages. */
2158 struct __db_compact {
2159 /* Input Parameters. */
2160 u_int32_t compact_fillpercent; /* Desired fillfactor: 1-100 */
2161 db_timeout_t compact_timeout; /* Lock timeout. */
2162 u_int32_t compact_pages; /* Max pages to process. */
2164 u_int32_t compact_empty_buckets; /* Empty hash buckets found. */
2165 u_int32_t compact_pages_free; /* Number of pages freed. */
2166 u_int32_t compact_pages_examine; /* Number of pages examine. */
2167 u_int32_t compact_levels; /* Number of levels removed. */
2168 u_int32_t compact_deadlock; /* Number of deadlocks. */
2169 db_pgno_t compact_pages_truncated; /* Pages truncated to OS. */
2171 db_pgno_t compact_truncate; /* Page number for truncation */
2174 /* Hash statistics structure. */
2175 struct __db_h_stat { /* SHARED */
2176 u_int32_t hash_magic; /* Magic number. */
2177 u_int32_t hash_version; /* Version number. */
2178 u_int32_t hash_metaflags; /* Metadata flags. */
2179 u_int32_t hash_nkeys; /* Number of unique keys. */
2180 u_int32_t hash_ndata; /* Number of data items. */
2181 u_int32_t hash_pagecnt; /* Page count. */
2182 u_int32_t hash_pagesize; /* Page size. */
2183 u_int32_t hash_ffactor; /* Fill factor specified at create. */
2184 u_int32_t hash_buckets; /* Number of hash buckets. */
2185 u_int32_t hash_free; /* Pages on the free list. */
2186 uintmax_t hash_bfree; /* Bytes free on bucket pages. */
2187 u_int32_t hash_bigpages; /* Number of big key/data pages. */
2188 uintmax_t hash_big_bfree; /* Bytes free on big item pages. */
2189 u_int32_t hash_overflows; /* Number of overflow pages. */
2190 uintmax_t hash_ovfl_free; /* Bytes free on ovfl pages. */
2191 u_int32_t hash_dup; /* Number of dup pages. */
2192 uintmax_t hash_dup_free; /* Bytes free on duplicate pages. */
2195 /* Heap statistics structure. */
2196 struct __db_heap_stat { /* SHARED */
2197 u_int32_t heap_magic; /* Magic number. */
2198 u_int32_t heap_version; /* Version number. */
2199 u_int32_t heap_metaflags; /* Metadata flags. */
2200 u_int32_t heap_nrecs; /* Number of records. */
2201 u_int32_t heap_pagecnt; /* Page count. */
2202 u_int32_t heap_pagesize; /* Page size. */
2203 u_int32_t heap_nregions; /* Number of regions. */
2204 u_int32_t heap_regionsize; /* Number of pages in a region. */
2207 /* Queue statistics structure. */
2208 struct __db_qam_stat { /* SHARED */
2209 u_int32_t qs_magic; /* Magic number. */
2210 u_int32_t qs_version; /* Version number. */
2211 u_int32_t qs_metaflags; /* Metadata flags. */
2212 u_int32_t qs_nkeys; /* Number of unique keys. */
2213 u_int32_t qs_ndata; /* Number of data items. */
2214 u_int32_t qs_pagesize; /* Page size. */
2215 u_int32_t qs_extentsize; /* Pages per extent. */
2216 u_int32_t qs_pages; /* Data pages. */
2217 u_int32_t qs_re_len; /* Fixed-length record length. */
2218 u_int32_t qs_re_pad; /* Fixed-length record pad. */
2219 u_int32_t qs_pgfree; /* Bytes free in data pages. */
2220 u_int32_t qs_first_recno; /* First not deleted record. */
2221 u_int32_t qs_cur_recno; /* Next available record number. */
2224 /*******************************************************
2226 *******************************************************/
2227 #define DB_REGION_MAGIC 0x120897 /* Environment magic number. */
2230 * Database environment structure.
2232 * This is the public database environment handle. The private environment
2233 * handle is the ENV structure. The user owns this structure, the library
2234 * owns the ENV structure. The reason there are two structures is because
2235 * the user's configuration outlives any particular DB_ENV->open call, and
2236 * separate structures allows us to easily discard internal information without
2237 * discarding the user's configuration.
2239 * Fields in the DB_ENV structure should normally be set only by application
2240 * DB_ENV handle methods.
2244 * Memory configuration types.
2248 DB_MEM_LOCKOBJECT=2,
2251 DB_MEM_TRANSACTION=5,
2256 * Backup configuration types.
2259 DB_BACKUP_READ_COUNT = 1,
2260 DB_BACKUP_READ_SLEEP = 2,
2262 DB_BACKUP_WRITE_DIRECT = 4
2266 ENV *env; /* Linked ENV structure */
2269 * The DB_ENV structure can be used concurrently, so field access is
2272 db_mutex_t mtx_db_env; /* DB_ENV structure mutex */
2274 /* Error message callback */
2275 void (*db_errcall) __P((const DB_ENV *, const char *, const char *));
2276 FILE *db_errfile; /* Error message file stream */
2277 const char *db_errpfx; /* Error message prefix */
2279 /* Other message callback */
2280 void (*db_msgcall) __P((const DB_ENV *, const char *));
2281 FILE *db_msgfile; /* Other message file stream */
2283 /* Other application callback functions */
2284 int (*app_dispatch) __P((DB_ENV *, DBT *, DB_LSN *, db_recops));
2285 void (*db_event_func) __P((DB_ENV *, u_int32_t, void *));
2286 void (*db_feedback) __P((DB_ENV *, int, int));
2287 void (*db_free) __P((void *));
2288 void (*db_paniccall) __P((DB_ENV *, int));
2289 void *(*db_malloc) __P((size_t));
2290 void *(*db_realloc) __P((void *, size_t));
2291 int (*is_alive) __P((DB_ENV *, pid_t, db_threadid_t, u_int32_t));
2292 void (*thread_id) __P((DB_ENV *, pid_t *, db_threadid_t *));
2293 char *(*thread_id_string) __P((DB_ENV *, pid_t, db_threadid_t, char *));
2295 /* Application specified paths */
2296 char *db_log_dir; /* Database log file directory */
2297 char *db_md_dir; /* Persistent metadata directory */
2298 char *db_tmp_dir; /* Database tmp file directory */
2300 char *db_create_dir; /* Create directory for data files */
2301 char **db_data_dir; /* Database data file directories */
2302 int data_cnt; /* Database data file slots */
2303 int data_next; /* Next database data file slot */
2305 char *intermediate_dir_mode; /* Intermediate directory perms */
2307 long shm_key; /* shmget key */
2309 char *passwd; /* Cryptography support */
2312 /* Private handle references */
2313 void *app_private; /* Application-private handle */
2314 void *api1_internal; /* C++, Perl API private */
2315 void *api2_internal; /* Java API private */
2317 u_int32_t verbose; /* DB_VERB_XXX flags */
2319 /* Mutex configuration */
2320 u_int32_t mutex_align; /* Mutex alignment */
2321 u_int32_t mutex_cnt; /* Number of mutexes to configure */
2322 u_int32_t mutex_inc; /* Number of mutexes to add */
2323 u_int32_t mutex_max; /* Max number of mutexes */
2324 u_int32_t mutex_tas_spins;/* Test-and-set spin count */
2326 /* Locking configuration */
2327 u_int8_t *lk_conflicts; /* Two dimensional conflict matrix */
2328 int lk_modes; /* Number of lock modes in table */
2329 u_int32_t lk_detect; /* Deadlock detect on all conflicts */
2330 u_int32_t lk_max; /* Maximum number of locks */
2331 u_int32_t lk_max_lockers;/* Maximum number of lockers */
2332 u_int32_t lk_max_objects;/* Maximum number of locked objects */
2333 u_int32_t lk_init; /* Initial number of locks */
2334 u_int32_t lk_init_lockers;/* Initial number of lockers */
2335 u_int32_t lk_init_objects;/* Initial number of locked objects */
2336 u_int32_t lk_partitions ;/* Number of object partitions */
2337 db_timeout_t lk_timeout; /* Lock timeout period */
2338 /* Used during initialization */
2339 u_int32_t locker_t_size; /* Locker hash table size. */
2340 u_int32_t object_t_size; /* Object hash table size. */
2342 /* Logging configuration */
2343 u_int32_t lg_bsize; /* Buffer size */
2344 u_int32_t lg_fileid_init; /* Initial allocation for fname structs */
2345 int lg_filemode; /* Log file permission mode */
2346 u_int32_t lg_regionmax; /* Region size */
2347 u_int32_t lg_size; /* Log file size */
2348 u_int32_t lg_flags; /* Log configuration */
2350 /* Memory pool configuration */
2351 u_int32_t mp_gbytes; /* Cache size: GB */
2352 u_int32_t mp_bytes; /* Cache size: bytes */
2353 u_int32_t mp_max_gbytes; /* Maximum cache size: GB */
2354 u_int32_t mp_max_bytes; /* Maximum cache size: bytes */
2355 size_t mp_mmapsize; /* Maximum file size for mmap */
2356 int mp_maxopenfd; /* Maximum open file descriptors */
2357 int mp_maxwrite; /* Maximum buffers to write */
2358 u_int mp_ncache; /* Initial number of cache regions */
2359 u_int32_t mp_pagesize; /* Average page size */
2360 u_int32_t mp_tablesize; /* Approximate hash table size */
2361 u_int32_t mp_mtxcount; /* Number of mutexs */
2362 /* Sleep after writing max buffers */
2363 db_timeout_t mp_maxwrite_sleep;
2365 /* Transaction configuration */
2366 u_int32_t tx_init; /* Initial number of transactions */
2367 u_int32_t tx_max; /* Maximum number of transactions */
2368 time_t tx_timestamp; /* Recover to specific timestamp */
2369 db_timeout_t tx_timeout; /* Timeout for transactions */
2371 /* Thread tracking configuration */
2372 u_int32_t thr_init; /* Thread count */
2373 u_int32_t thr_max; /* Thread max */
2374 roff_t memory_max; /* Maximum region memory */
2377 * The following fields are not strictly user-owned, but they outlive
2378 * the ENV structure, and so are stored here.
2380 DB_FH *registry; /* DB_REGISTER file handle */
2381 u_int32_t registry_off; /*
2382 * Offset of our slot. We can't use
2383 * off_t because its size depends on
2386 db_timeout_t envreg_timeout; /* DB_REGISTER wait timeout */
2388 #define DB_ENV_AUTO_COMMIT 0x00000001 /* DB_AUTO_COMMIT */
2389 #define DB_ENV_CDB_ALLDB 0x00000002 /* CDB environment wide locking */
2390 #define DB_ENV_FAILCHK 0x00000004 /* Failchk is running */
2391 #define DB_ENV_DIRECT_DB 0x00000008 /* DB_DIRECT_DB set */
2392 #define DB_ENV_DSYNC_DB 0x00000010 /* DB_DSYNC_DB set */
2393 #define DB_ENV_DATABASE_LOCKING 0x00000020 /* Try database-level locking */
2394 #define DB_ENV_MULTIVERSION 0x00000040 /* DB_MULTIVERSION set */
2395 #define DB_ENV_NOLOCKING 0x00000080 /* DB_NOLOCKING set */
2396 #define DB_ENV_NOMMAP 0x00000100 /* DB_NOMMAP set */
2397 #define DB_ENV_NOPANIC 0x00000200 /* Okay if panic set */
2398 #define DB_ENV_OVERWRITE 0x00000400 /* DB_OVERWRITE set */
2399 #define DB_ENV_REGION_INIT 0x00000800 /* DB_REGION_INIT set */
2400 #define DB_ENV_TIME_NOTGRANTED 0x00001000 /* DB_TIME_NOTGRANTED set */
2401 #define DB_ENV_TXN_NOSYNC 0x00002000 /* DB_TXN_NOSYNC set */
2402 #define DB_ENV_TXN_NOWAIT 0x00004000 /* DB_TXN_NOWAIT set */
2403 #define DB_ENV_TXN_SNAPSHOT 0x00008000 /* DB_TXN_SNAPSHOT set */
2404 #define DB_ENV_TXN_WRITE_NOSYNC 0x00010000 /* DB_TXN_WRITE_NOSYNC set */
2405 #define DB_ENV_YIELDCPU 0x00020000 /* DB_YIELDCPU set */
2406 #define DB_ENV_HOTBACKUP 0x00040000 /* DB_HOTBACKUP_IN_PROGRESS set */
2407 #define DB_ENV_NOFLUSH 0x00080000 /* DB_NOFLUSH set */
2410 /* DB_ENV PUBLIC HANDLE LIST BEGIN */
2411 int (*add_data_dir) __P((DB_ENV *, const char *));
2412 int (*backup) __P((DB_ENV *, const char *, u_int32_t));
2413 int (*cdsgroup_begin) __P((DB_ENV *, DB_TXN **));
2414 int (*close) __P((DB_ENV *, u_int32_t));
2415 int (*dbbackup) __P((DB_ENV *, const char *, const char *, u_int32_t));
2416 int (*dbremove) __P((DB_ENV *,
2417 DB_TXN *, const char *, const char *, u_int32_t));
2418 int (*dbrename) __P((DB_ENV *,
2419 DB_TXN *, const char *, const char *, const char *, u_int32_t));
2420 void (*err) __P((const DB_ENV *, int, const char *, ...));
2421 void (*errx) __P((const DB_ENV *, const char *, ...));
2422 int (*failchk) __P((DB_ENV *, u_int32_t));
2423 int (*fileid_reset) __P((DB_ENV *, const char *, u_int32_t));
2424 int (*get_alloc) __P((DB_ENV *, void *(**)(size_t),
2425 void *(**)(void *, size_t), void (**)(void *)));
2426 int (*get_app_dispatch)
2427 __P((DB_ENV *, int (**)(DB_ENV *, DBT *, DB_LSN *, db_recops)));
2428 int (*get_cache_max) __P((DB_ENV *, u_int32_t *, u_int32_t *));
2429 int (*get_cachesize) __P((DB_ENV *, u_int32_t *, u_int32_t *, int *));
2430 int (*get_create_dir) __P((DB_ENV *, const char **));
2431 int (*get_data_dirs) __P((DB_ENV *, const char ***));
2432 int (*get_data_len) __P((DB_ENV *, u_int32_t *));
2433 int (*get_backup_callbacks) __P((DB_ENV *,
2434 int (**)(DB_ENV *, const char *, const char *, void **),
2435 int (**)(DB_ENV *, u_int32_t, u_int32_t, u_int32_t, u_int8_t *, void *),
2436 int (**)(DB_ENV *, const char *, void *)));
2437 int (*get_backup_config) __P((DB_ENV *, DB_BACKUP_CONFIG, u_int32_t *));
2438 int (*get_encrypt_flags) __P((DB_ENV *, u_int32_t *));
2439 void (*get_errcall) __P((DB_ENV *,
2440 void (**)(const DB_ENV *, const char *, const char *)));
2441 void (*get_errfile) __P((DB_ENV *, FILE **));
2442 void (*get_errpfx) __P((DB_ENV *, const char **));
2443 int (*get_flags) __P((DB_ENV *, u_int32_t *));
2444 int (*get_feedback) __P((DB_ENV *, void (**)(DB_ENV *, int, int)));
2445 int (*get_home) __P((DB_ENV *, const char **));
2446 int (*get_intermediate_dir_mode) __P((DB_ENV *, const char **));
2447 int (*get_isalive) __P((DB_ENV *,
2448 int (**)(DB_ENV *, pid_t, db_threadid_t, u_int32_t)));
2449 int (*get_lg_bsize) __P((DB_ENV *, u_int32_t *));
2450 int (*get_lg_dir) __P((DB_ENV *, const char **));
2451 int (*get_lg_filemode) __P((DB_ENV *, int *));
2452 int (*get_lg_max) __P((DB_ENV *, u_int32_t *));
2453 int (*get_lg_regionmax) __P((DB_ENV *, u_int32_t *));
2454 int (*get_lk_conflicts) __P((DB_ENV *, const u_int8_t **, int *));
2455 int (*get_lk_detect) __P((DB_ENV *, u_int32_t *));
2456 int (*get_lk_max_lockers) __P((DB_ENV *, u_int32_t *));
2457 int (*get_lk_max_locks) __P((DB_ENV *, u_int32_t *));
2458 int (*get_lk_max_objects) __P((DB_ENV *, u_int32_t *));
2459 int (*get_lk_partitions) __P((DB_ENV *, u_int32_t *));
2460 int (*get_lk_priority) __P((DB_ENV *, u_int32_t, u_int32_t *));
2461 int (*get_lk_tablesize) __P((DB_ENV *, u_int32_t *));
2462 int (*get_memory_init) __P((DB_ENV *, DB_MEM_CONFIG, u_int32_t *));
2463 int (*get_memory_max) __P((DB_ENV *, u_int32_t *, u_int32_t *));
2464 int (*get_metadata_dir) __P((DB_ENV *, const char **));
2465 int (*get_mp_max_openfd) __P((DB_ENV *, int *));
2466 int (*get_mp_max_write) __P((DB_ENV *, int *, db_timeout_t *));
2467 int (*get_mp_mmapsize) __P((DB_ENV *, size_t *));
2468 int (*get_mp_mtxcount) __P((DB_ENV *, u_int32_t *));
2469 int (*get_mp_pagesize) __P((DB_ENV *, u_int32_t *));
2470 int (*get_mp_tablesize) __P((DB_ENV *, u_int32_t *));
2472 __P((DB_ENV *, void (**)(const DB_ENV *, const char *)));
2473 void (*get_msgfile) __P((DB_ENV *, FILE **));
2474 int (*get_open_flags) __P((DB_ENV *, u_int32_t *));
2475 int (*get_shm_key) __P((DB_ENV *, long *));
2476 int (*get_thread_count) __P((DB_ENV *, u_int32_t *));
2477 int (*get_thread_id_fn)
2478 __P((DB_ENV *, void (**)(DB_ENV *, pid_t *, db_threadid_t *)));
2479 int (*get_thread_id_string_fn) __P((DB_ENV *,
2480 char *(**)(DB_ENV *, pid_t, db_threadid_t, char *)));
2481 int (*get_timeout) __P((DB_ENV *, db_timeout_t *, u_int32_t));
2482 int (*get_tmp_dir) __P((DB_ENV *, const char **));
2483 int (*get_tx_max) __P((DB_ENV *, u_int32_t *));
2484 int (*get_tx_timestamp) __P((DB_ENV *, time_t *));
2485 int (*get_verbose) __P((DB_ENV *, u_int32_t, int *));
2486 int (*is_bigendian) __P((void));
2487 int (*lock_detect) __P((DB_ENV *, u_int32_t, u_int32_t, int *));
2488 int (*lock_get) __P((DB_ENV *,
2489 u_int32_t, u_int32_t, DBT *, db_lockmode_t, DB_LOCK *));
2490 int (*lock_id) __P((DB_ENV *, u_int32_t *));
2491 int (*lock_id_free) __P((DB_ENV *, u_int32_t));
2492 int (*lock_put) __P((DB_ENV *, DB_LOCK *));
2493 int (*lock_stat) __P((DB_ENV *, DB_LOCK_STAT **, u_int32_t));
2494 int (*lock_stat_print) __P((DB_ENV *, u_int32_t));
2495 int (*lock_vec) __P((DB_ENV *,
2496 u_int32_t, u_int32_t, DB_LOCKREQ *, int, DB_LOCKREQ **));
2497 int (*log_archive) __P((DB_ENV *, char **[], u_int32_t));
2498 int (*log_cursor) __P((DB_ENV *, DB_LOGC **, u_int32_t));
2499 int (*log_file) __P((DB_ENV *, const DB_LSN *, char *, size_t));
2500 int (*log_flush) __P((DB_ENV *, const DB_LSN *));
2501 int (*log_get_config) __P((DB_ENV *, u_int32_t, int *));
2502 int (*log_printf) __P((DB_ENV *, DB_TXN *, const char *, ...));
2503 int (*log_put) __P((DB_ENV *, DB_LSN *, const DBT *, u_int32_t));
2504 int (*log_put_record) __P((DB_ENV *, DB *, DB_TXN *, DB_LSN *,
2505 u_int32_t, u_int32_t, u_int32_t, u_int32_t,
2506 DB_LOG_RECSPEC *, ...));
2507 int (*log_read_record) __P((DB_ENV *, DB **,
2508 void *, void *, DB_LOG_RECSPEC *, u_int32_t, void **));
2509 int (*log_set_config) __P((DB_ENV *, u_int32_t, int));
2510 int (*log_stat) __P((DB_ENV *, DB_LOG_STAT **, u_int32_t));
2511 int (*log_stat_print) __P((DB_ENV *, u_int32_t));
2512 int (*log_verify) __P((DB_ENV *, const DB_LOG_VERIFY_CONFIG *));
2513 int (*lsn_reset) __P((DB_ENV *, const char *, u_int32_t));
2514 int (*memp_fcreate) __P((DB_ENV *, DB_MPOOLFILE **, u_int32_t));
2515 int (*memp_register) __P((DB_ENV *, int, int (*)(DB_ENV *, db_pgno_t,
2516 void *, DBT *), int (*)(DB_ENV *, db_pgno_t, void *, DBT *)));
2517 int (*memp_stat) __P((DB_ENV *,
2518 DB_MPOOL_STAT **, DB_MPOOL_FSTAT ***, u_int32_t));
2519 int (*memp_stat_print) __P((DB_ENV *, u_int32_t));
2520 int (*memp_sync) __P((DB_ENV *, DB_LSN *));
2521 int (*memp_trickle) __P((DB_ENV *, int, int *));
2522 int (*mutex_alloc) __P((DB_ENV *, u_int32_t, db_mutex_t *));
2523 int (*mutex_free) __P((DB_ENV *, db_mutex_t));
2524 int (*mutex_get_align) __P((DB_ENV *, u_int32_t *));
2525 int (*mutex_get_increment) __P((DB_ENV *, u_int32_t *));
2526 int (*mutex_get_init) __P((DB_ENV *, u_int32_t *));
2527 int (*mutex_get_max) __P((DB_ENV *, u_int32_t *));
2528 int (*mutex_get_tas_spins) __P((DB_ENV *, u_int32_t *));
2529 int (*mutex_lock) __P((DB_ENV *, db_mutex_t));
2530 int (*mutex_set_align) __P((DB_ENV *, u_int32_t));
2531 int (*mutex_set_increment) __P((DB_ENV *, u_int32_t));
2532 int (*mutex_set_init) __P((DB_ENV *, u_int32_t));
2533 int (*mutex_set_max) __P((DB_ENV *, u_int32_t));
2534 int (*mutex_set_tas_spins) __P((DB_ENV *, u_int32_t));
2535 int (*mutex_stat) __P((DB_ENV *, DB_MUTEX_STAT **, u_int32_t));
2536 int (*mutex_stat_print) __P((DB_ENV *, u_int32_t));
2537 int (*mutex_unlock) __P((DB_ENV *, db_mutex_t));
2538 int (*open) __P((DB_ENV *, const char *, u_int32_t, int));
2539 int (*remove) __P((DB_ENV *, const char *, u_int32_t));
2540 int (*rep_elect) __P((DB_ENV *, u_int32_t, u_int32_t, u_int32_t));
2541 int (*rep_flush) __P((DB_ENV *));
2542 int (*rep_get_clockskew) __P((DB_ENV *, u_int32_t *, u_int32_t *));
2543 int (*rep_get_config) __P((DB_ENV *, u_int32_t, int *));
2544 int (*rep_get_limit) __P((DB_ENV *, u_int32_t *, u_int32_t *));
2545 int (*rep_get_nsites) __P((DB_ENV *, u_int32_t *));
2546 int (*rep_get_priority) __P((DB_ENV *, u_int32_t *));
2547 int (*rep_get_request) __P((DB_ENV *, u_int32_t *, u_int32_t *));
2548 int (*rep_get_timeout) __P((DB_ENV *, int, u_int32_t *));
2549 int (*rep_process_message)
2550 __P((DB_ENV *, DBT *, DBT *, int, DB_LSN *));
2551 int (*rep_set_clockskew) __P((DB_ENV *, u_int32_t, u_int32_t));
2552 int (*rep_set_config) __P((DB_ENV *, u_int32_t, int));
2553 int (*rep_set_limit) __P((DB_ENV *, u_int32_t, u_int32_t));
2554 int (*rep_set_nsites) __P((DB_ENV *, u_int32_t));
2555 int (*rep_set_priority) __P((DB_ENV *, u_int32_t));
2556 int (*rep_set_request) __P((DB_ENV *, u_int32_t, u_int32_t));
2557 int (*rep_set_timeout) __P((DB_ENV *, int, db_timeout_t));
2558 int (*rep_set_transport) __P((DB_ENV *, int, int (*)(DB_ENV *,
2559 const DBT *, const DBT *, const DB_LSN *, int, u_int32_t)));
2560 int (*rep_start) __P((DB_ENV *, DBT *, u_int32_t));
2561 int (*rep_stat) __P((DB_ENV *, DB_REP_STAT **, u_int32_t));
2562 int (*rep_stat_print) __P((DB_ENV *, u_int32_t));
2563 int (*rep_sync) __P((DB_ENV *, u_int32_t));
2564 int (*repmgr_channel) __P((DB_ENV *, int, DB_CHANNEL **, u_int32_t));
2565 int (*repmgr_get_ack_policy) __P((DB_ENV *, int *));
2566 int (*repmgr_local_site) __P((DB_ENV *, DB_SITE **));
2567 int (*repmgr_msg_dispatch) __P((DB_ENV *,
2568 void (*)(DB_ENV *, DB_CHANNEL *, DBT *, u_int32_t, u_int32_t),
2570 int (*repmgr_set_ack_policy) __P((DB_ENV *, int));
2572 __P((DB_ENV *, const char *, u_int, DB_SITE**, u_int32_t));
2573 int (*repmgr_site_by_eid) __P((DB_ENV *, int, DB_SITE**));
2574 int (*repmgr_site_list) __P((DB_ENV *, u_int *, DB_REPMGR_SITE **));
2575 int (*repmgr_start) __P((DB_ENV *, int, u_int32_t));
2576 int (*repmgr_stat) __P((DB_ENV *, DB_REPMGR_STAT **, u_int32_t));
2577 int (*repmgr_stat_print) __P((DB_ENV *, u_int32_t));
2578 int (*set_alloc) __P((DB_ENV *, void *(*)(size_t),
2579 void *(*)(void *, size_t), void (*)(void *)));
2580 int (*set_app_dispatch)
2581 __P((DB_ENV *, int (*)(DB_ENV *, DBT *, DB_LSN *, db_recops)));
2582 int (*set_cache_max) __P((DB_ENV *, u_int32_t, u_int32_t));
2583 int (*set_cachesize) __P((DB_ENV *, u_int32_t, u_int32_t, int));
2584 int (*set_create_dir) __P((DB_ENV *, const char *));
2585 int (*set_data_dir) __P((DB_ENV *, const char *));
2586 int (*set_data_len) __P((DB_ENV *, u_int32_t));
2587 int (*set_backup_callbacks) __P((DB_ENV *,
2588 int (*)(DB_ENV *, const char *, const char *, void **),
2589 int (*)(DB_ENV *, u_int32_t,
2590 u_int32_t, u_int32_t, u_int8_t *, void *),
2591 int (*)(DB_ENV *, const char *, void *)));
2592 int (*set_backup_config) __P((DB_ENV *, DB_BACKUP_CONFIG, u_int32_t));
2593 int (*set_encrypt) __P((DB_ENV *, const char *, u_int32_t));
2594 void (*set_errcall) __P((DB_ENV *,
2595 void (*)(const DB_ENV *, const char *, const char *)));
2596 void (*set_errfile) __P((DB_ENV *, FILE *));
2597 void (*set_errpfx) __P((DB_ENV *, const char *));
2598 int (*set_event_notify)
2599 __P((DB_ENV *, void (*)(DB_ENV *, u_int32_t, void *)));
2600 int (*set_feedback) __P((DB_ENV *, void (*)(DB_ENV *, int, int)));
2601 int (*set_flags) __P((DB_ENV *, u_int32_t, int));
2602 int (*set_intermediate_dir_mode) __P((DB_ENV *, const char *));
2603 int (*set_isalive) __P((DB_ENV *,
2604 int (*)(DB_ENV *, pid_t, db_threadid_t, u_int32_t)));
2605 int (*set_lg_bsize) __P((DB_ENV *, u_int32_t));
2606 int (*set_lg_dir) __P((DB_ENV *, const char *));
2607 int (*set_lg_filemode) __P((DB_ENV *, int));
2608 int (*set_lg_max) __P((DB_ENV *, u_int32_t));
2609 int (*set_lg_regionmax) __P((DB_ENV *, u_int32_t));
2610 int (*set_lk_conflicts) __P((DB_ENV *, u_int8_t *, int));
2611 int (*set_lk_detect) __P((DB_ENV *, u_int32_t));
2612 int (*set_lk_max_lockers) __P((DB_ENV *, u_int32_t));
2613 int (*set_lk_max_locks) __P((DB_ENV *, u_int32_t));
2614 int (*set_lk_max_objects) __P((DB_ENV *, u_int32_t));
2615 int (*set_lk_partitions) __P((DB_ENV *, u_int32_t));
2616 int (*set_lk_priority) __P((DB_ENV *, u_int32_t, u_int32_t));
2617 int (*set_lk_tablesize) __P((DB_ENV *, u_int32_t));
2618 int (*set_memory_init) __P((DB_ENV *, DB_MEM_CONFIG, u_int32_t));
2619 int (*set_memory_max) __P((DB_ENV *, u_int32_t, u_int32_t));
2620 int (*set_metadata_dir) __P((DB_ENV *, const char *));
2621 int (*set_mp_max_openfd) __P((DB_ENV *, int));
2622 int (*set_mp_max_write) __P((DB_ENV *, int, db_timeout_t));
2623 int (*set_mp_mmapsize) __P((DB_ENV *, size_t));
2624 int (*set_mp_mtxcount) __P((DB_ENV *, u_int32_t));
2625 int (*set_mp_pagesize) __P((DB_ENV *, u_int32_t));
2626 int (*set_mp_tablesize) __P((DB_ENV *, u_int32_t));
2628 __P((DB_ENV *, void (*)(const DB_ENV *, const char *)));
2629 void (*set_msgfile) __P((DB_ENV *, FILE *));
2630 int (*set_paniccall) __P((DB_ENV *, void (*)(DB_ENV *, int)));
2631 int (*set_shm_key) __P((DB_ENV *, long));
2632 int (*set_thread_count) __P((DB_ENV *, u_int32_t));
2633 int (*set_thread_id)
2634 __P((DB_ENV *, void (*)(DB_ENV *, pid_t *, db_threadid_t *)));
2635 int (*set_thread_id_string) __P((DB_ENV *,
2636 char *(*)(DB_ENV *, pid_t, db_threadid_t, char *)));
2637 int (*set_timeout) __P((DB_ENV *, db_timeout_t, u_int32_t));
2638 int (*set_tmp_dir) __P((DB_ENV *, const char *));
2639 int (*set_tx_max) __P((DB_ENV *, u_int32_t));
2640 int (*set_tx_timestamp) __P((DB_ENV *, time_t *));
2641 int (*set_verbose) __P((DB_ENV *, u_int32_t, int));
2642 int (*txn_applied) __P((DB_ENV *,
2643 DB_TXN_TOKEN *, db_timeout_t, u_int32_t));
2644 int (*stat_print) __P((DB_ENV *, u_int32_t));
2645 int (*txn_begin) __P((DB_ENV *, DB_TXN *, DB_TXN **, u_int32_t));
2646 int (*txn_checkpoint) __P((DB_ENV *, u_int32_t, u_int32_t, u_int32_t));
2647 int (*txn_recover) __P((DB_ENV *,
2648 DB_PREPLIST *, long, long *, u_int32_t));
2649 int (*txn_stat) __P((DB_ENV *, DB_TXN_STAT **, u_int32_t));
2650 int (*txn_stat_print) __P((DB_ENV *, u_int32_t));
2651 /* DB_ENV PUBLIC HANDLE LIST END */
2653 /* DB_ENV PRIVATE HANDLE LIST BEGIN */
2654 int (*prdbt) __P((DBT *, int,
2655 const char *, void *, int (*)(void *, const void *), int, int));
2656 /* DB_ENV PRIVATE HANDLE LIST END */
2660 * Dispatch structure for recovery, log verification and print routines. Since
2661 * internal and external routines take different arguments (ENV versus DB_ENV),
2662 * we need something more elaborate than a single pointer and size.
2664 struct __db_distab {
2665 int (**int_dispatch) __P((ENV *, DBT *, DB_LSN *, db_recops, void *));
2667 int (**ext_dispatch) __P((DB_ENV *, DBT *, DB_LSN *, db_recops));
2672 * Log verification configuration structure.
2674 struct __db_logvrfy_config {
2675 int continue_after_fail, verbose;
2676 u_int32_t cachesize;
2677 const char *temp_envhome;
2678 const char *dbfile, *dbname;
2679 DB_LSN start_lsn, end_lsn;
2680 time_t start_time, end_time;
2683 struct __db_channel {
2684 CHANNEL *channel; /* Pointer to internal state details. */
2685 int eid; /* Env. ID passed in constructor. */
2686 db_timeout_t timeout;
2688 /* DB_CHANNEL PUBLIC HANDLE LIST BEGIN */
2689 int (*close) __P((DB_CHANNEL *, u_int32_t));
2690 int (*send_msg) __P((DB_CHANNEL *, DBT *, u_int32_t, u_int32_t));
2691 int (*send_request) __P((DB_CHANNEL *,
2692 DBT *, u_int32_t, DBT *, db_timeout_t, u_int32_t));
2693 int (*set_timeout) __P((DB_CHANNEL *, db_timeout_t));
2694 /* DB_CHANNEL PUBLIC HANDLE LIST END */
2704 /* DB_SITE PUBLIC HANDLE LIST BEGIN */
2705 int (*get_address) __P((DB_SITE *, const char **, u_int *));
2706 int (*get_config) __P((DB_SITE *, u_int32_t, u_int32_t *));
2707 int (*get_eid) __P((DB_SITE *, int *));
2708 int (*set_config) __P((DB_SITE *, u_int32_t, u_int32_t));
2709 int (*remove) __P((DB_SITE *));
2710 int (*close) __P((DB_SITE *));
2711 /* DB_SITE PUBLIC HANDLE LIST END */
2714 #if DB_DBM_HSEARCH != 0
2715 /*******************************************************
2716 * Dbm/Ndbm historic interfaces.
2717 *******************************************************/
2718 typedef struct __db DBM;
2720 #define DBM_INSERT 0 /* Flags to dbm_store(). */
2721 #define DBM_REPLACE 1
2724 * The DB support for ndbm(3) always appends this suffix to the
2725 * file name to avoid overwriting the user's original database.
2727 #define DBM_SUFFIX ".db"
2729 #if defined(_XPG4_2)
2742 * Translate NDBM calls into DB calls so that DB doesn't step on the
2743 * application's name space.
2745 #define dbm_clearerr(a) __db_ndbm_clearerr(a)
2746 #define dbm_close(a) __db_ndbm_close(a)
2747 #define dbm_delete(a, b) __db_ndbm_delete(a, b)
2748 #define dbm_dirfno(a) __db_ndbm_dirfno(a)
2749 #define dbm_error(a) __db_ndbm_error(a)
2750 #define dbm_fetch(a, b) __db_ndbm_fetch(a, b)
2751 #define dbm_firstkey(a) __db_ndbm_firstkey(a)
2752 #define dbm_nextkey(a) __db_ndbm_nextkey(a)
2753 #define dbm_open(a, b, c) __db_ndbm_open(a, b, c)
2754 #define dbm_pagfno(a) __db_ndbm_pagfno(a)
2755 #define dbm_rdonly(a) __db_ndbm_rdonly(a)
2756 #define dbm_store(a, b, c, d) \
2757 __db_ndbm_store(a, b, c, d)
2760 * Translate DBM calls into DB calls so that DB doesn't step on the
2761 * application's name space.
2763 * The global variables dbrdonly, dirf and pagf were not retained when 4BSD
2764 * replaced the dbm interface with ndbm, and are not supported here.
2766 #define dbminit(a) __db_dbm_init(a)
2767 #define dbmclose __db_dbm_close
2768 #if !defined(__cplusplus)
2769 #define delete(a) __db_dbm_delete(a)
2771 #define fetch(a) __db_dbm_fetch(a)
2772 #define firstkey __db_dbm_firstkey
2773 #define nextkey(a) __db_dbm_nextkey(a)
2774 #define store(a, b) __db_dbm_store(a, b)
2776 /*******************************************************
2777 * Hsearch historic interface.
2778 *******************************************************/
2783 typedef struct entry {
2788 #define hcreate(a) __db_hcreate(a)
2789 #define hdestroy __db_hdestroy
2790 #define hsearch(a, b) __db_hsearch(a, b)
2792 #endif /* DB_DBM_HSEARCH */
2794 #if defined(__cplusplus)
2798 #endif /* !_DB_H_ */
2799 /* DO NOT EDIT: automatically built by dist/s_apiflags. */
2800 #define DB_AGGRESSIVE 0x00000001
2801 #define DB_ARCH_ABS 0x00000001
2802 #define DB_ARCH_DATA 0x00000002
2803 #define DB_ARCH_LOG 0x00000004
2804 #define DB_ARCH_REMOVE 0x00000008
2805 #define DB_AUTO_COMMIT 0x00000100
2806 #define DB_BACKUP_CLEAN 0x00000002
2807 #define DB_BACKUP_FILES 0x00000008
2808 #define DB_BACKUP_NO_LOGS 0x00000010
2809 #define DB_BACKUP_SINGLE_DIR 0x00000020
2810 #define DB_BACKUP_UPDATE 0x00000040
2811 #define DB_BOOTSTRAP_HELPER 0x00000001
2812 #define DB_CDB_ALLDB 0x00000040
2813 #define DB_CHKSUM 0x00000008
2814 #define DB_CKP_INTERNAL 0x00000002
2815 #define DB_CREATE 0x00000001
2816 #define DB_CURSOR_BULK 0x00000001
2817 #define DB_CURSOR_TRANSIENT 0x00000008
2818 #define DB_CXX_NO_EXCEPTIONS 0x00000002
2819 #define DB_DATABASE_LOCKING 0x00000080
2820 #define DB_DIRECT 0x00000020
2821 #define DB_DIRECT_DB 0x00000200
2822 #define DB_DSYNC_DB 0x00000400
2823 #define DB_DUP 0x00000010
2824 #define DB_DUPSORT 0x00000002
2825 #define DB_DURABLE_UNKNOWN 0x00000040
2826 #define DB_ENCRYPT 0x00000001
2827 #define DB_ENCRYPT_AES 0x00000001
2828 #define DB_EXCL 0x00000004
2829 #define DB_EXTENT 0x00000100
2830 #define DB_FAILCHK 0x00000010
2831 #define DB_FAILCHK_ISALIVE 0x00000040
2832 #define DB_FAST_STAT 0x00000001
2833 #define DB_FCNTL_LOCKING 0x00000800
2834 #define DB_FLUSH 0x00000002
2835 #define DB_FORCE 0x00000001
2836 #define DB_FORCESYNC 0x00000001
2837 #define DB_FOREIGN_ABORT 0x00000001
2838 #define DB_FOREIGN_CASCADE 0x00000002
2839 #define DB_FOREIGN_NULLIFY 0x00000004
2840 #define DB_FREELIST_ONLY 0x00000001
2841 #define DB_FREE_SPACE 0x00000002
2842 #define DB_GROUP_CREATOR 0x00000002
2843 #define DB_HOTBACKUP_IN_PROGRESS 0x00000800
2844 #define DB_IGNORE_LEASE 0x00001000
2845 #define DB_IMMUTABLE_KEY 0x00000002
2846 #define DB_INIT_CDB 0x00000080
2847 #define DB_INIT_LOCK 0x00000100
2848 #define DB_INIT_LOG 0x00000200
2849 #define DB_INIT_MPOOL 0x00000400
2850 #define DB_INIT_MUTEX 0x00000800
2851 #define DB_INIT_REP 0x00001000
2852 #define DB_INIT_TXN 0x00002000
2853 #define DB_INORDER 0x00000020
2854 #define DB_INTERNAL_PERSISTENT_DB 0x00001000
2855 #define DB_INTERNAL_TEMPORARY_DB 0x00002000
2856 #define DB_JOIN_NOSORT 0x00000001
2857 #define DB_LEGACY 0x00000004
2858 #define DB_LOCAL_SITE 0x00000008
2859 #define DB_LOCKDOWN 0x00004000
2860 #define DB_LOCK_CHECK 0x00000001
2861 #define DB_LOCK_IGNORE_REC 0x00000002
2862 #define DB_LOCK_NOWAIT 0x00000004
2863 #define DB_LOCK_RECORD 0x00000008
2864 #define DB_LOCK_SET_TIMEOUT 0x00000010
2865 #define DB_LOCK_SWITCH 0x00000020
2866 #define DB_LOCK_UPGRADE 0x00000040
2867 #define DB_LOG_AUTO_REMOVE 0x00000001
2868 #define DB_LOG_CHKPNT 0x00000001
2869 #define DB_LOG_COMMIT 0x00000004
2870 #define DB_LOG_DIRECT 0x00000002
2871 #define DB_LOG_DSYNC 0x00000004
2872 #define DB_LOG_IN_MEMORY 0x00000008
2873 #define DB_LOG_NOCOPY 0x00000008
2874 #define DB_LOG_NOT_DURABLE 0x00000010
2875 #define DB_LOG_NO_DATA 0x00000002
2876 #define DB_LOG_VERIFY_CAF 0x00000001
2877 #define DB_LOG_VERIFY_DBFILE 0x00000002
2878 #define DB_LOG_VERIFY_ERR 0x00000004
2879 #define DB_LOG_VERIFY_FORWARD 0x00000008
2880 #define DB_LOG_VERIFY_INTERR 0x00000010
2881 #define DB_LOG_VERIFY_PARTIAL 0x00000020
2882 #define DB_LOG_VERIFY_VERBOSE 0x00000040
2883 #define DB_LOG_VERIFY_WARNING 0x00000080
2884 #define DB_LOG_WRNOSYNC 0x00000020
2885 #define DB_LOG_ZERO 0x00000010
2886 #define DB_MPOOL_CREATE 0x00000001
2887 #define DB_MPOOL_DIRTY 0x00000002
2888 #define DB_MPOOL_DISCARD 0x00000001
2889 #define DB_MPOOL_EDIT 0x00000004
2890 #define DB_MPOOL_FREE 0x00000008
2891 #define DB_MPOOL_LAST 0x00000010
2892 #define DB_MPOOL_NEW 0x00000020
2893 #define DB_MPOOL_NOFILE 0x00000001
2894 #define DB_MPOOL_NOLOCK 0x00000004
2895 #define DB_MPOOL_TRY 0x00000040
2896 #define DB_MPOOL_UNLINK 0x00000002
2897 #define DB_MULTIPLE 0x00000800
2898 #define DB_MULTIPLE_KEY 0x00004000
2899 #define DB_MULTIVERSION 0x00000008
2900 #define DB_MUTEX_ALLOCATED 0x00000001
2901 #define DB_MUTEX_LOCKED 0x00000002
2902 #define DB_MUTEX_LOGICAL_LOCK 0x00000004
2903 #define DB_MUTEX_PROCESS_ONLY 0x00000008
2904 #define DB_MUTEX_SELF_BLOCK 0x00000010
2905 #define DB_MUTEX_SHARED 0x00000020
2906 #define DB_NOERROR 0x00004000
2907 #define DB_NOFLUSH 0x00001000
2908 #define DB_NOLOCKING 0x00002000
2909 #define DB_NOMMAP 0x00000010
2910 #define DB_NOORDERCHK 0x00000002
2911 #define DB_NOPANIC 0x00004000
2912 #define DB_NOSYNC 0x00000001
2913 #define DB_NO_AUTO_COMMIT 0x00008000
2914 #define DB_NO_CHECKPOINT 0x00008000
2915 #define DB_ODDFILESIZE 0x00000080
2916 #define DB_ORDERCHKONLY 0x00000004
2917 #define DB_OVERWRITE 0x00008000
2918 #define DB_PANIC_ENVIRONMENT 0x00010000
2919 #define DB_PRINTABLE 0x00000008
2920 #define DB_PRIVATE 0x00010000
2921 #define DB_PR_PAGE 0x00000010
2922 #define DB_PR_RECOVERYTEST 0x00000020
2923 #define DB_RDONLY 0x00000400
2924 #define DB_RDWRMASTER 0x00010000
2925 #define DB_READ_COMMITTED 0x00000400
2926 #define DB_READ_UNCOMMITTED 0x00000200
2927 #define DB_RECNUM 0x00000040
2928 #define DB_RECOVER 0x00000002
2929 #define DB_RECOVER_FATAL 0x00020000
2930 #define DB_REGION_INIT 0x00020000
2931 #define DB_REGISTER 0x00040000
2932 #define DB_RENUMBER 0x00000080
2933 #define DB_REPMGR_CONF_2SITE_STRICT 0x00000001
2934 #define DB_REPMGR_CONF_ELECTIONS 0x00000002
2935 #define DB_REPMGR_NEED_RESPONSE 0x00000001
2936 #define DB_REPMGR_PEER 0x00000010
2937 #define DB_REP_ANYWHERE 0x00000001
2938 #define DB_REP_CLIENT 0x00000001
2939 #define DB_REP_CONF_AUTOINIT 0x00000004
2940 #define DB_REP_CONF_AUTOROLLBACK 0x00000008
2941 #define DB_REP_CONF_BULK 0x00000010
2942 #define DB_REP_CONF_DELAYCLIENT 0x00000020
2943 #define DB_REP_CONF_INMEM 0x00000040
2944 #define DB_REP_CONF_LEASE 0x00000080
2945 #define DB_REP_CONF_NOWAIT 0x00000100
2946 #define DB_REP_ELECTION 0x00000004
2947 #define DB_REP_MASTER 0x00000002
2948 #define DB_REP_NOBUFFER 0x00000002
2949 #define DB_REP_PERMANENT 0x00000004
2950 #define DB_REP_REREQUEST 0x00000008
2951 #define DB_REVSPLITOFF 0x00000100
2952 #define DB_RMW 0x00002000
2953 #define DB_SALVAGE 0x00000040
2954 #define DB_SA_SKIPFIRSTKEY 0x00000080
2955 #define DB_SA_UNKNOWNKEY 0x00000100
2956 #define DB_SEQ_DEC 0x00000001
2957 #define DB_SEQ_INC 0x00000002
2958 #define DB_SEQ_RANGE_SET 0x00000004
2959 #define DB_SEQ_WRAP 0x00000008
2960 #define DB_SEQ_WRAPPED 0x00000010
2961 #define DB_SET_LOCK_TIMEOUT 0x00000001
2962 #define DB_SET_REG_TIMEOUT 0x00000004
2963 #define DB_SET_TXN_NOW 0x00000008
2964 #define DB_SET_TXN_TIMEOUT 0x00000002
2965 #define DB_SHALLOW_DUP 0x00000100
2966 #define DB_SNAPSHOT 0x00000200
2967 #define DB_STAT_ALL 0x00000004
2968 #define DB_STAT_ALLOC 0x00000008
2969 #define DB_STAT_CLEAR 0x00000001
2970 #define DB_STAT_LOCK_CONF 0x00000010
2971 #define DB_STAT_LOCK_LOCKERS 0x00000020
2972 #define DB_STAT_LOCK_OBJECTS 0x00000040
2973 #define DB_STAT_LOCK_PARAMS 0x00000080
2974 #define DB_STAT_MEMP_HASH 0x00000010
2975 #define DB_STAT_MEMP_NOERROR 0x00000020
2976 #define DB_STAT_SUBSYSTEM 0x00000002
2977 #define DB_STAT_SUMMARY 0x00000010
2978 #define DB_ST_DUPOK 0x00000200
2979 #define DB_ST_DUPSET 0x00000400
2980 #define DB_ST_DUPSORT 0x00000800
2981 #define DB_ST_IS_RECNO 0x00001000
2982 #define DB_ST_OVFL_LEAF 0x00002000
2983 #define DB_ST_RECNUM 0x00004000
2984 #define DB_ST_RELEN 0x00008000
2985 #define DB_ST_TOPLEVEL 0x00010000
2986 #define DB_SYSTEM_MEM 0x00080000
2987 #define DB_THREAD 0x00000020
2988 #define DB_TIME_NOTGRANTED 0x00040000
2989 #define DB_TRUNCATE 0x00020000
2990 #define DB_TXN_BULK 0x00000010
2991 #define DB_TXN_FAMILY 0x00000040
2992 #define DB_TXN_NOSYNC 0x00000001
2993 #define DB_TXN_NOT_DURABLE 0x00000004
2994 #define DB_TXN_NOWAIT 0x00000002
2995 #define DB_TXN_SNAPSHOT 0x00000004
2996 #define DB_TXN_SYNC 0x00000008
2997 #define DB_TXN_WAIT 0x00000080
2998 #define DB_TXN_WRITE_NOSYNC 0x00000020
2999 #define DB_UNREF 0x00020000
3000 #define DB_UPGRADE 0x00000001
3001 #define DB_USE_ENVIRON 0x00000004
3002 #define DB_USE_ENVIRON_ROOT 0x00000008
3003 #define DB_VERB_BACKUP 0x00000001
3004 #define DB_VERB_DEADLOCK 0x00000002
3005 #define DB_VERB_FILEOPS 0x00000004
3006 #define DB_VERB_FILEOPS_ALL 0x00000008
3007 #define DB_VERB_RECOVERY 0x00000010
3008 #define DB_VERB_REGISTER 0x00000020
3009 #define DB_VERB_REPLICATION 0x00000040
3010 #define DB_VERB_REPMGR_CONNFAIL 0x00000080
3011 #define DB_VERB_REPMGR_MISC 0x00000100
3012 #define DB_VERB_REP_ELECT 0x00000200
3013 #define DB_VERB_REP_LEASE 0x00000400
3014 #define DB_VERB_REP_MISC 0x00000800
3015 #define DB_VERB_REP_MSGS 0x00001000
3016 #define DB_VERB_REP_SYNC 0x00002000
3017 #define DB_VERB_REP_SYSTEM 0x00004000
3018 #define DB_VERB_REP_TEST 0x00008000
3019 #define DB_VERB_WAITSFOR 0x00010000
3020 #define DB_VERIFY 0x00000002
3021 #define DB_VERIFY_PARTITION 0x00040000
3022 #define DB_WRITECURSOR 0x00000010
3023 #define DB_WRITELOCK 0x00000020
3024 #define DB_WRITEOPEN 0x00040000
3025 #define DB_XA_CREATE 0x00000001
3026 #define DB_YIELDCPU 0x00080000
3028 /* DO NOT EDIT: automatically built by dist/s_include. */
3029 #ifndef _DB_EXT_PROT_IN_
3030 #define _DB_EXT_PROT_IN_
3032 #if defined(__cplusplus)
3036 int db_copy __P((DB_ENV *, const char *, const char *, const char *));
3037 int db_create __P((DB **, DB_ENV *, u_int32_t));
3038 char *db_strerror __P((int));
3039 int db_env_set_func_assert __P((void (*)(const char *, const char *, int)));
3040 int db_env_set_func_close __P((int (*)(int)));
3041 int db_env_set_func_dirfree __P((void (*)(char **, int)));
3042 int db_env_set_func_dirlist __P((int (*)(const char *, char ***, int *)));
3043 int db_env_set_func_exists __P((int (*)(const char *, int *)));
3044 int db_env_set_func_free __P((void (*)(void *)));
3045 int db_env_set_func_fsync __P((int (*)(int)));
3046 int db_env_set_func_ftruncate __P((int (*)(int, off_t)));
3047 int db_env_set_func_ioinfo __P((int (*)(const char *, int, u_int32_t *, u_int32_t *, u_int32_t *)));
3048 int db_env_set_func_malloc __P((void *(*)(size_t)));
3049 int db_env_set_func_file_map __P((int (*)(DB_ENV *, char *, size_t, int, void **), int (*)(DB_ENV *, void *)));
3050 int db_env_set_func_region_map __P((int (*)(DB_ENV *, char *, size_t, int *, void **), int (*)(DB_ENV *, void *)));
3051 int db_env_set_func_pread __P((ssize_t (*)(int, void *, size_t, off_t)));
3052 int db_env_set_func_pwrite __P((ssize_t (*)(int, const void *, size_t, off_t)));
3053 int db_env_set_func_open __P((int (*)(const char *, int, ...)));
3054 int db_env_set_func_read __P((ssize_t (*)(int, void *, size_t)));
3055 int db_env_set_func_realloc __P((void *(*)(void *, size_t)));
3056 int db_env_set_func_rename __P((int (*)(const char *, const char *)));
3057 int db_env_set_func_seek __P((int (*)(int, off_t, int)));
3058 int db_env_set_func_unlink __P((int (*)(const char *)));
3059 int db_env_set_func_write __P((ssize_t (*)(int, const void *, size_t)));
3060 int db_env_set_func_yield __P((int (*)(u_long, u_long)));
3061 int db_env_create __P((DB_ENV **, u_int32_t));
3062 char *db_version __P((int *, int *, int *));
3063 char *db_full_version __P((int *, int *, int *, int *, int *));
3064 int log_compare __P((const DB_LSN *, const DB_LSN *));
3065 #if defined(DB_WIN32) && !defined(DB_WINCE)
3066 int db_env_set_win_security __P((SECURITY_ATTRIBUTES *sa));
3068 int db_sequence_create __P((DB_SEQUENCE **, DB *, u_int32_t));
3069 #if DB_DBM_HSEARCH != 0
3070 int __db_ndbm_clearerr __P((DBM *));
3071 void __db_ndbm_close __P((DBM *));
3072 int __db_ndbm_delete __P((DBM *, datum));
3073 int __db_ndbm_dirfno __P((DBM *));
3074 int __db_ndbm_error __P((DBM *));
3075 datum __db_ndbm_fetch __P((DBM *, datum));
3076 datum __db_ndbm_firstkey __P((DBM *));
3077 datum __db_ndbm_nextkey __P((DBM *));
3078 DBM *__db_ndbm_open __P((const char *, int, int));
3079 int __db_ndbm_pagfno __P((DBM *));
3080 int __db_ndbm_rdonly __P((DBM *));
3081 int __db_ndbm_store __P((DBM *, datum, datum, int));
3082 int __db_dbm_close __P((void));
3083 int __db_dbm_delete __P((datum));
3084 datum __db_dbm_fetch __P((datum));
3085 datum __db_dbm_firstkey __P((void));
3086 int __db_dbm_init __P((char *));
3087 datum __db_dbm_nextkey __P((datum));
3088 int __db_dbm_store __P((datum, datum));
3090 #if DB_DBM_HSEARCH != 0
3091 int __db_hcreate __P((size_t));
3092 ENTRY *__db_hsearch __P((ENTRY, ACTION));
3093 void __db_hdestroy __P((void));
3096 #if defined(__cplusplus)
3099 #endif /* !_DB_EXT_PROT_IN_ */