1 /* DO NOT EDIT: automatically built by dist/s_windows. */
3 * See the file LICENSE for redistribution information.
5 * Copyright (c) 1996-2009 Oracle. 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>
31 * Turn off inappropriate compiler warnings
35 * This warning is explicitly disabled in Visual C++ by default.
36 * It is necessary to explicitly enable the /Wall flag to generate this
38 * Since this is a shared include file it should compile without warnings
39 * at the highest warning level, so third party applications can use
40 * higher warning levels cleanly.
42 * 4820: 'bytes' bytes padding added after member 'member'
43 * The type and order of elements caused the compiler to
44 * add padding to the end of a struct.
47 #pragma warning(disable: 4820)
49 #if defined(__cplusplus)
55 #define __P(protos) protos
58 * Berkeley DB version information.
60 #define DB_VERSION_MAJOR 4
61 #define DB_VERSION_MINOR 8
62 #define DB_VERSION_PATCH 30
63 #define DB_VERSION_STRING "Berkeley DB 4.8.30: (April 12, 2010)"
67 * Berkeley DB uses specifically sized types. If they're not provided by
68 * the system, typedef them here.
70 * We protect them against multiple inclusion using __BIT_TYPES_DEFINED__,
71 * as does BIND and Kerberos, since we don't know for sure what #include
72 * files the user is using.
75 * We also provide the standard u_int, u_long etc., if they're not provided
78 #ifndef __BIT_TYPES_DEFINED__
79 #define __BIT_TYPES_DEFINED__
80 typedef unsigned char u_int8_t;
81 typedef short int16_t;
82 typedef unsigned short u_int16_t;
84 typedef unsigned int u_int32_t;
85 typedef __int64 int64_t;
86 typedef unsigned __int64 u_int64_t;
90 typedef unsigned char u_char;
91 typedef unsigned int u_int;
92 typedef unsigned long u_long;
94 typedef unsigned short u_short;
100 * Largest unsigned type, used to align structures in memory. We don't store
101 * floating point types in structures, so integral types should be sufficient
102 * (and we don't have to worry about systems that store floats in other than
103 * power-of-2 numbers of bytes). Additionally this fixes compilers that rewrite
104 * structure assignments and ANSI C memcpy calls to be in-line instructions
105 * that happen to require alignment.
108 * Unsigned type that's the same size as a pointer. There are places where
109 * DB modifies pointers by discarding the bottom bits to guarantee alignment.
110 * We can't use uintmax_t, it may be larger than the pointer, and compilers
111 * get upset about that. So far we haven't run on any machine where there's
112 * no unsigned type the same size as a pointer -- here's hoping.
114 #if defined(_MSC_VER) && _MSC_VER < 1300
115 typedef u_int32_t uintmax_t;
117 typedef u_int64_t uintmax_t;
120 typedef u_int64_t uintptr_t;
122 typedef u_int32_t uintptr_t;
126 * Windows defines off_t to long (i.e., 32 bits). We need to pass 64-bit
127 * file offsets, so we declare our own.
129 #define off_t __db_off_t
130 typedef int64_t off_t;
133 typedef int64_t ssize_t;
135 typedef int32_t ssize_t;
139 * Sequences are only available on machines with 64-bit integral types.
141 typedef int64_t db_seq_t;
143 /* Thread and process identification. */
144 typedef u_int32_t db_threadid_t;
146 /* Basic types that are exported or quasi-exported. */
147 typedef u_int32_t db_pgno_t; /* Page number type. */
148 typedef u_int16_t db_indx_t; /* Page offset type. */
149 #define DB_MAX_PAGES 0xffffffff /* >= # of pages in a file */
151 typedef u_int32_t db_recno_t; /* Record number type. */
152 #define DB_MAX_RECORDS 0xffffffff /* >= # of records in a tree */
154 typedef u_int32_t db_timeout_t; /* Type of a timeout. */
157 * Region offsets are the difference between a pointer in a region and the
158 * region's base address. With private environments, both addresses are the
159 * result of calling malloc, and we can't assume anything about what malloc
160 * will return, so region offsets have to be able to hold differences between
161 * arbitrary pointers.
163 typedef uintptr_t roff_t;
166 * Forward structure declarations, so we can declare pointers and
167 * applications can get type checking.
169 struct __db; typedef struct __db DB;
170 struct __db_bt_stat; typedef struct __db_bt_stat DB_BTREE_STAT;
171 struct __db_cipher; typedef struct __db_cipher DB_CIPHER;
172 struct __db_compact; typedef struct __db_compact DB_COMPACT;
173 struct __db_dbt; typedef struct __db_dbt DBT;
174 struct __db_distab; typedef struct __db_distab DB_DISTAB;
175 struct __db_env; typedef struct __db_env DB_ENV;
176 struct __db_h_stat; typedef struct __db_h_stat DB_HASH_STAT;
177 struct __db_ilock; typedef struct __db_ilock DB_LOCK_ILOCK;
178 struct __db_lock_hstat; typedef struct __db_lock_hstat DB_LOCK_HSTAT;
179 struct __db_lock_pstat; typedef struct __db_lock_pstat DB_LOCK_PSTAT;
180 struct __db_lock_stat; typedef struct __db_lock_stat DB_LOCK_STAT;
181 struct __db_lock_u; typedef struct __db_lock_u DB_LOCK;
182 struct __db_locker; typedef struct __db_locker DB_LOCKER;
183 struct __db_lockreq; typedef struct __db_lockreq DB_LOCKREQ;
184 struct __db_locktab; typedef struct __db_locktab DB_LOCKTAB;
185 struct __db_log; typedef struct __db_log DB_LOG;
186 struct __db_log_cursor; typedef struct __db_log_cursor DB_LOGC;
187 struct __db_log_stat; typedef struct __db_log_stat DB_LOG_STAT;
188 struct __db_lsn; typedef struct __db_lsn DB_LSN;
189 struct __db_mpool; typedef struct __db_mpool DB_MPOOL;
190 struct __db_mpool_fstat;typedef struct __db_mpool_fstat DB_MPOOL_FSTAT;
191 struct __db_mpool_stat; typedef struct __db_mpool_stat DB_MPOOL_STAT;
192 struct __db_mpoolfile; typedef struct __db_mpoolfile DB_MPOOLFILE;
193 struct __db_mutex_stat; typedef struct __db_mutex_stat DB_MUTEX_STAT;
194 struct __db_mutex_t; typedef struct __db_mutex_t DB_MUTEX;
195 struct __db_mutexmgr; typedef struct __db_mutexmgr DB_MUTEXMGR;
196 struct __db_preplist; typedef struct __db_preplist DB_PREPLIST;
197 struct __db_qam_stat; typedef struct __db_qam_stat DB_QUEUE_STAT;
198 struct __db_rep; typedef struct __db_rep DB_REP;
199 struct __db_rep_stat; typedef struct __db_rep_stat DB_REP_STAT;
200 struct __db_repmgr_site;typedef struct __db_repmgr_site DB_REPMGR_SITE;
201 struct __db_repmgr_stat;typedef struct __db_repmgr_stat DB_REPMGR_STAT;
202 struct __db_seq_record; typedef struct __db_seq_record DB_SEQ_RECORD;
203 struct __db_seq_stat; typedef struct __db_seq_stat DB_SEQUENCE_STAT;
204 struct __db_sequence; typedef struct __db_sequence DB_SEQUENCE;
205 struct __db_thread_info;typedef struct __db_thread_info DB_THREAD_INFO;
206 struct __db_txn; typedef struct __db_txn DB_TXN;
207 struct __db_txn_active; typedef struct __db_txn_active DB_TXN_ACTIVE;
208 struct __db_txn_stat; typedef struct __db_txn_stat DB_TXN_STAT;
209 struct __db_txnmgr; typedef struct __db_txnmgr DB_TXNMGR;
210 struct __dbc; typedef struct __dbc DBC;
211 struct __dbc_internal; typedef struct __dbc_internal DBC_INTERNAL;
212 struct __env; typedef struct __env ENV;
213 struct __fh_t; typedef struct __fh_t DB_FH;
214 struct __fname; typedef struct __fname FNAME;
215 struct __key_range; typedef struct __key_range DB_KEY_RANGE;
216 struct __mpoolfile; typedef struct __mpoolfile MPOOLFILE;
219 * The Berkeley DB API flags are automatically-generated -- the following flag
220 * names are no longer used, but remain for compatibility reasons.
222 #define DB_DEGREE_2 DB_READ_COMMITTED
223 #define DB_DIRTY_READ DB_READ_UNCOMMITTED
224 #define DB_JOINENV 0x0
226 /* Key/data structure -- a Data-Base Thang. */
228 void *data; /* Key/data */
229 u_int32_t size; /* key/data length */
231 u_int32_t ulen; /* RO: length of user buffer. */
232 u_int32_t dlen; /* RO: get/put record length. */
233 u_int32_t doff; /* RO: get/put record offset. */
237 #define DB_DBT_APPMALLOC 0x001 /* Callback allocated memory. */
238 #define DB_DBT_BULK 0x002 /* Internal: Insert if duplicate. */
239 #define DB_DBT_DUPOK 0x004 /* Internal: Insert if duplicate. */
240 #define DB_DBT_ISSET 0x008 /* Lower level calls set value. */
241 #define DB_DBT_MALLOC 0x010 /* Return in malloc'd memory. */
242 #define DB_DBT_MULTIPLE 0x020 /* References multiple records. */
243 #define DB_DBT_PARTIAL 0x040 /* Partial put/get. */
244 #define DB_DBT_REALLOC 0x080 /* Return in realloc'd memory. */
245 #define DB_DBT_STREAMING 0x100 /* Internal: DBT is being streamed. */
246 #define DB_DBT_USERCOPY 0x200 /* Use the user-supplied callback. */
247 #define DB_DBT_USERMEM 0x400 /* Return in user's memory. */
251 /*******************************************************
253 *******************************************************/
254 typedef u_int32_t db_mutex_t;
256 struct __db_mutex_stat {
257 /* The following fields are maintained in the region's copy. */
258 u_int32_t st_mutex_align; /* Mutex alignment */
259 u_int32_t st_mutex_tas_spins; /* Mutex test-and-set spins */
260 u_int32_t st_mutex_cnt; /* Mutex count */
261 u_int32_t st_mutex_free; /* Available mutexes */
262 u_int32_t st_mutex_inuse; /* Mutexes in use */
263 u_int32_t st_mutex_inuse_max; /* Maximum mutexes ever in use */
265 /* The following fields are filled-in from other places. */
266 #ifndef __TEST_DB_NO_STATISTICS
267 uintmax_t st_region_wait; /* Region lock granted after wait. */
268 uintmax_t st_region_nowait; /* Region lock granted without wait. */
269 roff_t st_regsize; /* Region size. */
273 /* This is the length of the buffer passed to DB_ENV->thread_id_string() */
274 #define DB_THREADID_STRLEN 128
276 /*******************************************************
278 *******************************************************/
279 #define DB_LOCKVERSION 1
281 #define DB_FILE_ID_LEN 20 /* Unique file ID length. */
284 * Deadlock detector modes; used in the DB_ENV structure to configure the
287 #define DB_LOCK_NORUN 0
288 #define DB_LOCK_DEFAULT 1 /* Default policy. */
289 #define DB_LOCK_EXPIRE 2 /* Only expire locks, no detection. */
290 #define DB_LOCK_MAXLOCKS 3 /* Select locker with max locks. */
291 #define DB_LOCK_MAXWRITE 4 /* Select locker with max writelocks. */
292 #define DB_LOCK_MINLOCKS 5 /* Select locker with min locks. */
293 #define DB_LOCK_MINWRITE 6 /* Select locker with min writelocks. */
294 #define DB_LOCK_OLDEST 7 /* Select oldest locker. */
295 #define DB_LOCK_RANDOM 8 /* Select random locker. */
296 #define DB_LOCK_YOUNGEST 9 /* Select youngest locker. */
299 * Simple R/W lock modes and for multi-granularity intention locking.
302 * These values are NOT random, as they are used as an index into the lock
303 * conflicts arrays, i.e., DB_LOCK_IWRITE must be == 3, and DB_LOCK_IREAD
307 DB_LOCK_NG=0, /* Not granted. */
308 DB_LOCK_READ=1, /* Shared/read. */
309 DB_LOCK_WRITE=2, /* Exclusive/write. */
310 DB_LOCK_WAIT=3, /* Wait for event */
311 DB_LOCK_IWRITE=4, /* Intent exclusive/write. */
312 DB_LOCK_IREAD=5, /* Intent to share/read. */
313 DB_LOCK_IWR=6, /* Intent to read and write. */
314 DB_LOCK_READ_UNCOMMITTED=7, /* Degree 1 isolation. */
315 DB_LOCK_WWRITE=8 /* Was Written. */
322 DB_LOCK_DUMP=0, /* Display held locks. */
323 DB_LOCK_GET=1, /* Get the lock. */
324 DB_LOCK_GET_TIMEOUT=2, /* Get lock with a timeout. */
325 DB_LOCK_INHERIT=3, /* Pass locks to parent. */
326 DB_LOCK_PUT=4, /* Release the lock. */
327 DB_LOCK_PUT_ALL=5, /* Release locker's locks. */
328 DB_LOCK_PUT_OBJ=6, /* Release locker's locks on obj. */
329 DB_LOCK_PUT_READ=7, /* Release locker's read locks. */
330 DB_LOCK_TIMEOUT=8, /* Force a txn to timeout. */
331 DB_LOCK_TRADE=9, /* Trade locker ids on a lock. */
332 DB_LOCK_UPGRADE_WRITE=10 /* Upgrade writes for dirty reads. */
339 DB_LSTAT_ABORTED=1, /* Lock belongs to an aborted txn. */
340 DB_LSTAT_EXPIRED=2, /* Lock has expired. */
341 DB_LSTAT_FREE=3, /* Lock is unallocated. */
342 DB_LSTAT_HELD=4, /* Lock is currently held. */
343 DB_LSTAT_PENDING=5, /* Lock was waiting and has been
344 * promoted; waiting for the owner
345 * to run and upgrade it to held. */
346 DB_LSTAT_WAITING=6 /* Lock is on the wait queue. */
349 /* Lock statistics structure. */
350 struct __db_lock_stat {
351 u_int32_t st_id; /* Last allocated locker ID. */
352 u_int32_t st_cur_maxid; /* Current maximum unused ID. */
353 u_int32_t st_maxlocks; /* Maximum number of locks in table. */
354 u_int32_t st_maxlockers; /* Maximum num of lockers in table. */
355 u_int32_t st_maxobjects; /* Maximum num of objects in table. */
356 u_int32_t st_partitions; /* number of partitions. */
357 int 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 {
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 {
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.
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 u_int32_t type; /* Type of lock. */
437 * The structure is allocated by the caller and filled in during a
438 * lock_get request (or a lock_vec/DB_LOCK_GET).
441 roff_t off; /* Offset of the lock in the region */
442 u_int32_t ndx; /* Index of the object referenced by
443 * this lock; used for locking. */
444 u_int32_t gen; /* Generation number of this lock. */
445 db_lockmode_t mode; /* mode of this lock. */
448 /* Lock request structure. */
449 struct __db_lockreq {
450 db_lockop_t op; /* Operation. */
451 db_lockmode_t mode; /* Requested mode. */
452 db_timeout_t timeout; /* Time to expire lock. */
453 DBT *obj; /* Object being locked. */
454 DB_LOCK lock; /* Lock returned. */
457 /*******************************************************
459 *******************************************************/
460 #define DB_LOGVERSION 16 /* Current log version. */
461 #define DB_LOGVERSION_LATCHING 15 /* Log version using latching. */
462 #define DB_LOGCHKSUM 12 /* Check sum headers. */
463 #define DB_LOGOLDVER 8 /* Oldest log version supported. */
464 #define DB_LOGMAGIC 0x040988
467 * A DB_LSN has two parts, a fileid which identifies a specific file, and an
468 * offset within that file. The fileid is an unsigned 4-byte quantity that
469 * uniquely identifies a file within the log directory -- currently a simple
470 * counter inside the log. The offset is also an unsigned 4-byte value. The
471 * log manager guarantees the offset is never more than 4 bytes by switching
472 * to a new log file before the maximum length imposed by an unsigned 4-byte
476 u_int32_t file; /* File ID. */
477 u_int32_t offset; /* File offset. */
481 * Application-specified log record types start at DB_user_BEGIN, and must not
482 * equal or exceed DB_debug_FLAG.
484 * DB_debug_FLAG is the high-bit of the u_int32_t that specifies a log record
485 * type. If the flag is set, it's a log record that was logged for debugging
486 * purposes only, even if it reflects a database change -- the change was part
487 * of a non-durable transaction.
489 #define DB_user_BEGIN 10000
490 #define DB_debug_FLAG 0x80000000
496 struct __db_log_cursor {
497 ENV *env; /* Environment */
499 DB_FH *fhp; /* File handle. */
500 DB_LSN lsn; /* Cursor: LSN */
501 u_int32_t len; /* Cursor: record length */
502 u_int32_t prev; /* Cursor: previous record's offset */
504 DBT dbt; /* Return DBT. */
505 DB_LSN p_lsn; /* Persist LSN. */
506 u_int32_t p_version; /* Persist version. */
508 u_int8_t *bp; /* Allocated read buffer. */
509 u_int32_t bp_size; /* Read buffer length in bytes. */
510 u_int32_t bp_rlen; /* Read buffer valid data length. */
511 DB_LSN bp_lsn; /* Read buffer first byte LSN. */
513 u_int32_t bp_maxrec; /* Max record length in the log file. */
515 /* DB_LOGC PUBLIC HANDLE LIST BEGIN */
516 int (*close) __P((DB_LOGC *, u_int32_t));
517 int (*get) __P((DB_LOGC *, DB_LSN *, DBT *, u_int32_t));
518 int (*version) __P((DB_LOGC *, u_int32_t *, u_int32_t));
519 /* DB_LOGC PUBLIC HANDLE LIST END */
521 #define DB_LOG_DISK 0x01 /* Log record came from disk. */
522 #define DB_LOG_LOCKED 0x02 /* Log region already locked */
523 #define DB_LOG_SILENT_ERR 0x04 /* Turn-off error messages. */
527 /* Log statistics structure. */
528 struct __db_log_stat {
529 u_int32_t st_magic; /* Log file magic number. */
530 u_int32_t st_version; /* Log file version number. */
531 int st_mode; /* Log file permissions mode. */
532 u_int32_t st_lg_bsize; /* Log buffer size. */
533 u_int32_t st_lg_size; /* Log file size. */
534 u_int32_t st_wc_bytes; /* Bytes to log since checkpoint. */
535 u_int32_t st_wc_mbytes; /* Megabytes to log since checkpoint. */
536 #ifndef __TEST_DB_NO_STATISTICS
537 uintmax_t st_record; /* Records entered into the log. */
538 u_int32_t st_w_bytes; /* Bytes to log. */
539 u_int32_t st_w_mbytes; /* Megabytes to log. */
540 uintmax_t st_wcount; /* Total I/O writes to the log. */
541 uintmax_t st_wcount_fill; /* Overflow writes to the log. */
542 uintmax_t st_rcount; /* Total I/O reads from the log. */
543 uintmax_t st_scount; /* Total syncs to the log. */
544 uintmax_t st_region_wait; /* Region lock granted after wait. */
545 uintmax_t st_region_nowait; /* Region lock granted without wait. */
546 u_int32_t st_cur_file; /* Current log file number. */
547 u_int32_t st_cur_offset; /* Current log file offset. */
548 u_int32_t st_disk_file; /* Known on disk log file number. */
549 u_int32_t st_disk_offset; /* Known on disk log file offset. */
550 u_int32_t st_maxcommitperflush; /* Max number of commits in a flush. */
551 u_int32_t st_mincommitperflush; /* Min number of commits in a flush. */
552 roff_t st_regsize; /* Region size. */
557 * We need to record the first log record of a transaction. For user
558 * defined logging this macro returns the place to put that information,
559 * if it is need in rlsnp, otherwise it leaves it unchanged. We also
560 * need to track the last record of the transaction, this returns the
561 * place to put that info.
563 #define DB_SET_TXN_LSNP(txn, blsnp, llsnp) \
564 ((txn)->set_txn_lsnp(txn, blsnp, llsnp))
566 /*******************************************************
567 * Shared buffer cache (mpool).
568 *******************************************************/
569 /* Priority values for DB_MPOOLFILE->{put,set_priority}. */
571 DB_PRIORITY_UNCHANGED=0,
572 DB_PRIORITY_VERY_LOW=1,
574 DB_PRIORITY_DEFAULT=3,
576 DB_PRIORITY_VERY_HIGH=5
579 /* Per-process DB_MPOOLFILE information. */
580 struct __db_mpoolfile {
581 DB_FH *fhp; /* Underlying file handle. */
585 * The ref, pinref and q fields are protected by the region lock.
587 u_int32_t ref; /* Reference count. */
589 u_int32_t pinref; /* Pinned block reference count. */
593 * Explicit representations of structures from queue.h.
594 * TAILQ_ENTRY(__db_mpoolfile) q;
597 struct __db_mpoolfile *tqe_next;
598 struct __db_mpoolfile **tqe_prev;
599 } q; /* Linked list of DB_MPOOLFILE's. */
603 * The rest of the fields (with the exception of the MP_FLUSH flag)
604 * are not thread-protected, even when they may be modified at any
605 * time by the application. The reason is the DB_MPOOLFILE handle
606 * is single-threaded from the viewpoint of the application, and so
607 * the only fields needing to be thread-protected are those accessed
608 * by checkpoint or sync threads when using DB_MPOOLFILE structures
609 * to flush buffers from the cache.
611 ENV *env; /* Environment */
612 MPOOLFILE *mfp; /* Underlying MPOOLFILE. */
614 u_int32_t clear_len; /* Cleared length on created pages. */
615 u_int8_t /* Unique file ID. */
616 fileid[DB_FILE_ID_LEN];
617 int ftype; /* File type. */
618 int32_t lsn_offset; /* LSN offset in page. */
619 u_int32_t gbytes, bytes; /* Maximum file size. */
620 DBT *pgcookie; /* Byte-string passed to pgin/pgout. */
621 int32_t priority; /* Cache priority. */
623 void *addr; /* Address of mmap'd region. */
624 size_t len; /* Length of mmap'd region. */
626 u_int32_t config_flags; /* Flags to DB_MPOOLFILE->set_flags. */
628 /* DB_MPOOLFILE PUBLIC HANDLE LIST BEGIN */
629 int (*close) __P((DB_MPOOLFILE *, u_int32_t));
631 __P((DB_MPOOLFILE *, db_pgno_t *, DB_TXN *, u_int32_t, void *));
632 int (*get_clear_len) __P((DB_MPOOLFILE *, u_int32_t *));
633 int (*get_fileid) __P((DB_MPOOLFILE *, u_int8_t *));
634 int (*get_flags) __P((DB_MPOOLFILE *, u_int32_t *));
635 int (*get_ftype) __P((DB_MPOOLFILE *, int *));
636 int (*get_last_pgno) __P((DB_MPOOLFILE *, db_pgno_t *));
637 int (*get_lsn_offset) __P((DB_MPOOLFILE *, int32_t *));
638 int (*get_maxsize) __P((DB_MPOOLFILE *, u_int32_t *, u_int32_t *));
639 int (*get_pgcookie) __P((DB_MPOOLFILE *, DBT *));
640 int (*get_priority) __P((DB_MPOOLFILE *, DB_CACHE_PRIORITY *));
641 int (*open) __P((DB_MPOOLFILE *, const char *, u_int32_t, int, size_t));
642 int (*put) __P((DB_MPOOLFILE *, void *, DB_CACHE_PRIORITY, u_int32_t));
643 int (*set_clear_len) __P((DB_MPOOLFILE *, u_int32_t));
644 int (*set_fileid) __P((DB_MPOOLFILE *, u_int8_t *));
645 int (*set_flags) __P((DB_MPOOLFILE *, u_int32_t, int));
646 int (*set_ftype) __P((DB_MPOOLFILE *, int));
647 int (*set_lsn_offset) __P((DB_MPOOLFILE *, int32_t));
648 int (*set_maxsize) __P((DB_MPOOLFILE *, u_int32_t, u_int32_t));
649 int (*set_pgcookie) __P((DB_MPOOLFILE *, DBT *));
650 int (*set_priority) __P((DB_MPOOLFILE *, DB_CACHE_PRIORITY));
651 int (*sync) __P((DB_MPOOLFILE *));
652 /* DB_MPOOLFILE PUBLIC HANDLE LIST END */
655 * MP_FILEID_SET, MP_OPEN_CALLED and MP_READONLY do not need to be
656 * thread protected because they are initialized before the file is
657 * linked onto the per-process lists, and never modified.
659 * MP_FLUSH is thread protected because it is potentially read/set by
660 * multiple threads of control.
662 #define MP_FILEID_SET 0x001 /* Application supplied a file ID. */
663 #define MP_FLUSH 0x002 /* Was opened to flush a buffer. */
664 #define MP_MULTIVERSION 0x004 /* Opened for multiversion access. */
665 #define MP_OPEN_CALLED 0x008 /* File opened. */
666 #define MP_READONLY 0x010 /* File is readonly. */
667 #define MP_DUMMY 0x020 /* File is dummy for __memp_fput. */
671 /* Mpool statistics structure. */
672 struct __db_mpool_stat {
673 u_int32_t st_gbytes; /* Total cache size: GB. */
674 u_int32_t st_bytes; /* Total cache size: B. */
675 u_int32_t st_ncache; /* Number of cache regions. */
676 u_int32_t st_max_ncache; /* Maximum number of regions. */
677 size_t st_mmapsize; /* Maximum file size for mmap. */
678 int st_maxopenfd; /* Maximum number of open fd's. */
679 int st_maxwrite; /* Maximum buffers to write. */
680 db_timeout_t st_maxwrite_sleep; /* Sleep after writing max buffers. */
681 u_int32_t st_pages; /* Total number of pages. */
682 #ifndef __TEST_DB_NO_STATISTICS
683 u_int32_t st_map; /* Pages from mapped files. */
684 uintmax_t st_cache_hit; /* Pages found in the cache. */
685 uintmax_t st_cache_miss; /* Pages not found in the cache. */
686 uintmax_t st_page_create; /* Pages created in the cache. */
687 uintmax_t st_page_in; /* Pages read in. */
688 uintmax_t st_page_out; /* Pages written out. */
689 uintmax_t st_ro_evict; /* Clean pages forced from the cache. */
690 uintmax_t st_rw_evict; /* Dirty pages forced from the cache. */
691 uintmax_t st_page_trickle; /* Pages written by memp_trickle. */
692 u_int32_t st_page_clean; /* Clean pages. */
693 u_int32_t st_page_dirty; /* Dirty pages. */
694 u_int32_t st_hash_buckets; /* Number of hash buckets. */
695 u_int32_t st_pagesize; /* Assumed page size. */
696 u_int32_t st_hash_searches; /* Total hash chain searches. */
697 u_int32_t st_hash_longest; /* Longest hash chain searched. */
698 uintmax_t st_hash_examined; /* Total hash entries searched. */
699 uintmax_t st_hash_nowait; /* Hash lock granted with nowait. */
700 uintmax_t st_hash_wait; /* Hash lock granted after wait. */
701 uintmax_t st_hash_max_nowait; /* Max hash lock granted with nowait. */
702 uintmax_t st_hash_max_wait; /* Max hash lock granted after wait. */
703 uintmax_t st_region_nowait; /* Region lock granted with nowait. */
704 uintmax_t st_region_wait; /* Region lock granted after wait. */
705 uintmax_t st_mvcc_frozen; /* Buffers frozen. */
706 uintmax_t st_mvcc_thawed; /* Buffers thawed. */
707 uintmax_t st_mvcc_freed; /* Frozen buffers freed. */
708 uintmax_t st_alloc; /* Number of page allocations. */
709 uintmax_t st_alloc_buckets; /* Buckets checked during allocation. */
710 uintmax_t st_alloc_max_buckets;/* Max checked during allocation. */
711 uintmax_t st_alloc_pages; /* Pages checked during allocation. */
712 uintmax_t st_alloc_max_pages; /* Max checked during allocation. */
713 uintmax_t st_io_wait; /* Thread waited on buffer I/O. */
714 uintmax_t st_sync_interrupted; /* Number of times sync interrupted. */
715 roff_t st_regsize; /* Region size. */
719 /* Mpool file statistics structure. */
720 struct __db_mpool_fstat {
721 char *file_name; /* File name. */
722 u_int32_t st_pagesize; /* Page size. */
723 #ifndef __TEST_DB_NO_STATISTICS
724 u_int32_t st_map; /* Pages from mapped files. */
725 uintmax_t st_cache_hit; /* Pages found in the cache. */
726 uintmax_t st_cache_miss; /* Pages not found in the cache. */
727 uintmax_t st_page_create; /* Pages created in the cache. */
728 uintmax_t st_page_in; /* Pages read in. */
729 uintmax_t st_page_out; /* Pages written out. */
733 /*******************************************************
734 * Transactions and recovery.
735 *******************************************************/
736 #define DB_TXNVERSION 1
739 DB_TXN_ABORT=0, /* Public. */
740 DB_TXN_APPLY=1, /* Public. */
741 DB_TXN_BACKWARD_ROLL=3, /* Public. */
742 DB_TXN_FORWARD_ROLL=4, /* Public. */
743 DB_TXN_OPENFILES=5, /* Internal. */
744 DB_TXN_POPENFILES=6, /* Internal. */
745 DB_TXN_PRINT=7 /* Public. */
749 * BACKWARD_ALLOC is used during the forward pass to pick up any aborted
750 * allocations for files that were created during the forward pass.
751 * The main difference between _ALLOC and _ROLL is that the entry for
752 * the file not exist during the rollforward pass.
754 #define DB_UNDO(op) ((op) == DB_TXN_ABORT || (op) == DB_TXN_BACKWARD_ROLL)
755 #define DB_REDO(op) ((op) == DB_TXN_FORWARD_ROLL || (op) == DB_TXN_APPLY)
758 DB_TXNMGR *mgrp; /* Pointer to transaction manager. */
759 DB_TXN *parent; /* Pointer to transaction's parent. */
760 DB_THREAD_INFO *thread_info; /* Pointer to thread information. */
762 u_int32_t txnid; /* Unique transaction id. */
763 char *name; /* Transaction name. */
764 DB_LOCKER *locker; /* Locker for this txn. */
766 void *td; /* Detail structure within region. */
767 db_timeout_t lock_timeout; /* Timeout for locks for this txn. */
768 db_timeout_t expire; /* Time transaction expires. */
769 void *txn_list; /* Undo information for parent. */
773 * Explicit representations of structures from queue.h.
774 * TAILQ_ENTRY(__db_txn) links;
777 struct __db_txn *tqe_next;
778 struct __db_txn **tqe_prev;
779 } links; /* Links transactions off manager. */
783 * Explicit representations of structures from queue.h.
784 * TAILQ_HEAD(__kids, __db_txn) kids;
787 struct __db_txn *tqh_first;
788 struct __db_txn **tqh_last;
793 * Explicit representations of structures from queue.h.
794 * TAILQ_HEAD(__events, __txn_event) events;
797 struct __txn_event *tqh_first;
798 struct __txn_event **tqh_last;
799 } events; /* Links deferred events. */
803 * Explicit representations of structures from queue.h.
804 * STAILQ_HEAD(__logrec, __txn_logrec) logs;
807 struct __txn_logrec *stqh_first;
808 struct __txn_logrec **stqh_last;
809 } logs; /* Links in memory log records. */
813 * Explicit representations of structures from queue.h.
814 * TAILQ_ENTRY(__db_txn) klinks;
817 struct __db_txn *tqe_next;
818 struct __db_txn **tqe_prev;
821 void *api_internal; /* C++ API private. */
822 void *xml_internal; /* XML API private. */
824 u_int32_t cursors; /* Number of cursors open for txn */
826 /* DB_TXN PUBLIC HANDLE LIST BEGIN */
827 int (*abort) __P((DB_TXN *));
828 int (*commit) __P((DB_TXN *, u_int32_t));
829 int (*discard) __P((DB_TXN *, u_int32_t));
830 int (*get_name) __P((DB_TXN *, const char **));
831 u_int32_t (*id) __P((DB_TXN *));
832 int (*prepare) __P((DB_TXN *, u_int8_t *));
833 int (*set_name) __P((DB_TXN *, const char *));
834 int (*set_timeout) __P((DB_TXN *, db_timeout_t, u_int32_t));
835 /* DB_TXN PUBLIC HANDLE LIST END */
837 /* DB_TXN PRIVATE HANDLE LIST BEGIN */
838 void (*set_txn_lsnp) __P((DB_TXN *txn, DB_LSN **, DB_LSN **));
839 /* DB_TXN PRIVATE HANDLE LIST END */
841 #define TXN_CHILDCOMMIT 0x0001 /* Txn has committed. */
842 #define TXN_CDSGROUP 0x0002 /* CDS group handle. */
843 #define TXN_COMPENSATE 0x0004 /* Compensating transaction. */
844 #define TXN_DEADLOCK 0x0008 /* Txn has deadlocked. */
845 #define TXN_LOCKTIMEOUT 0x0010 /* Txn has a lock timeout. */
846 #define TXN_MALLOC 0x0020 /* Structure allocated by TXN system. */
847 #define TXN_NOSYNC 0x0040 /* Do not sync on prepare and commit. */
848 #define TXN_NOWAIT 0x0080 /* Do not wait on locks. */
849 #define TXN_PRIVATE 0x0100 /* Txn owned by cursor.. */
850 #define TXN_READ_COMMITTED 0x0200 /* Txn has degree 2 isolation. */
851 #define TXN_READ_UNCOMMITTED 0x0400 /* Txn has degree 1 isolation. */
852 #define TXN_RESTORED 0x0800 /* Txn has been restored. */
853 #define TXN_SNAPSHOT 0x1000 /* Snapshot Isolation. */
854 #define TXN_SYNC 0x2000 /* Write and sync on prepare/commit. */
855 #define TXN_WRITE_NOSYNC 0x4000 /* Write only on prepare/commit. */
859 #define TXN_SYNC_FLAGS (TXN_SYNC | TXN_NOSYNC | TXN_WRITE_NOSYNC)
862 * Structure used for two phase commit interface.
863 * We set the size of our global transaction id (gid) to be 128 in order
864 * to match that defined by the XA X/Open standard.
866 #define DB_GID_SIZE 128
867 struct __db_preplist {
869 u_int8_t gid[DB_GID_SIZE];
872 /* Transaction statistics structure. */
873 struct __db_txn_active {
874 u_int32_t txnid; /* Transaction ID */
875 u_int32_t parentid; /* Transaction ID of parent */
876 pid_t pid; /* Process owning txn ID */
877 db_threadid_t tid; /* Thread owning txn ID */
879 DB_LSN lsn; /* LSN when transaction began */
881 DB_LSN read_lsn; /* Read LSN for MVCC */
882 u_int32_t mvcc_ref; /* MVCC reference count */
884 #define TXN_ABORTED 1
885 #define TXN_COMMITTED 2
886 #define TXN_PREPARED 3
887 #define TXN_RUNNING 4
888 u_int32_t status; /* Status of the transaction */
890 u_int8_t gid[DB_GID_SIZE]; /* Global transaction ID */
891 char name[51]; /* 50 bytes of name, nul termination */
894 struct __db_txn_stat {
895 u_int32_t st_nrestores; /* number of restored transactions
897 #ifndef __TEST_DB_NO_STATISTICS
898 DB_LSN st_last_ckp; /* lsn of the last checkpoint */
899 time_t st_time_ckp; /* time of last checkpoint */
900 u_int32_t st_last_txnid; /* last transaction id given out */
901 u_int32_t st_maxtxns; /* maximum txns possible */
902 uintmax_t st_naborts; /* number of aborted transactions */
903 uintmax_t st_nbegins; /* number of begun transactions */
904 uintmax_t st_ncommits; /* number of committed transactions */
905 u_int32_t st_nactive; /* number of active transactions */
906 u_int32_t st_nsnapshot; /* number of snapshot transactions */
907 u_int32_t st_maxnactive; /* maximum active transactions */
908 u_int32_t st_maxnsnapshot; /* maximum snapshot transactions */
909 DB_TXN_ACTIVE *st_txnarray; /* array of active transactions */
910 uintmax_t st_region_wait; /* Region lock granted after wait. */
911 uintmax_t st_region_nowait; /* Region lock granted without wait. */
912 roff_t st_regsize; /* Region size. */
916 /*******************************************************
918 *******************************************************/
919 /* Special, out-of-band environment IDs. */
920 #define DB_EID_BROADCAST -1
921 #define DB_EID_INVALID -2
923 #define DB_REP_DEFAULT_PRIORITY 100
925 /* Acknowledgement policies. */
926 #define DB_REPMGR_ACKS_ALL 1
927 #define DB_REPMGR_ACKS_ALL_PEERS 2
928 #define DB_REPMGR_ACKS_NONE 3
929 #define DB_REPMGR_ACKS_ONE 4
930 #define DB_REPMGR_ACKS_ONE_PEER 5
931 #define DB_REPMGR_ACKS_QUORUM 6
933 /* Replication timeout configuration values. */
934 #define DB_REP_ACK_TIMEOUT 1 /* RepMgr acknowledgements. */
935 #define DB_REP_CHECKPOINT_DELAY 2 /* Master checkpoint delay. */
936 #define DB_REP_CONNECTION_RETRY 3 /* RepMgr connections. */
937 #define DB_REP_ELECTION_RETRY 4 /* RepMgr elect retries. */
938 #define DB_REP_ELECTION_TIMEOUT 5 /* Rep normal elections. */
939 #define DB_REP_FULL_ELECTION_TIMEOUT 6 /* Rep full elections. */
940 #define DB_REP_HEARTBEAT_MONITOR 7 /* RepMgr client HB monitor. */
941 #define DB_REP_HEARTBEAT_SEND 8 /* RepMgr master send freq. */
942 #define DB_REP_LEASE_TIMEOUT 9 /* Master leases. */
944 /* Event notification types. */
945 #define DB_EVENT_NO_SUCH_EVENT 0 /* out-of-band sentinel value */
946 #define DB_EVENT_PANIC 1
947 #define DB_EVENT_REG_ALIVE 2
948 #define DB_EVENT_REG_PANIC 3
949 #define DB_EVENT_REP_CLIENT 4
950 #define DB_EVENT_REP_ELECTED 5
951 #define DB_EVENT_REP_MASTER 6
952 #define DB_EVENT_REP_NEWMASTER 7
953 #define DB_EVENT_REP_PERM_FAILED 8
954 #define DB_EVENT_REP_STARTUPDONE 9
955 #define DB_EVENT_WRITE_FAILED 10
957 /* Replication Manager site status. */
958 struct __db_repmgr_site {
963 #define DB_REPMGR_CONNECTED 0x01
964 #define DB_REPMGR_DISCONNECTED 0x02
968 /* Replication statistics. */
969 struct __db_rep_stat {
971 * Many replication statistics fields cannot be protected by a mutex
972 * without an unacceptable performance penalty, since most message
973 * processing is done without the need to hold a region-wide lock.
974 * Fields whose comments end with a '+' may be updated without holding
975 * the replication or log mutexes (as appropriate), and thus may be
976 * off somewhat (or, on unreasonable architectures under unlucky
977 * circumstances, garbaged).
979 uintmax_t st_log_queued; /* Log records currently queued.+ */
980 u_int32_t st_startup_complete; /* Site completed client sync-up. */
981 #ifndef __TEST_DB_NO_STATISTICS
982 u_int32_t st_status; /* Current replication status. */
983 DB_LSN st_next_lsn; /* Next LSN to use or expect. */
984 DB_LSN st_waiting_lsn; /* LSN we're awaiting, if any. */
985 DB_LSN st_max_perm_lsn; /* Maximum permanent LSN. */
986 db_pgno_t st_next_pg; /* Next pg we expect. */
987 db_pgno_t st_waiting_pg; /* pg we're awaiting, if any. */
989 u_int32_t st_dupmasters; /* # of times a duplicate master
990 condition was detected.+ */
991 int st_env_id; /* Current environment ID. */
992 u_int32_t st_env_priority; /* Current environment priority. */
993 uintmax_t st_bulk_fills; /* Bulk buffer fills. */
994 uintmax_t st_bulk_overflows; /* Bulk buffer overflows. */
995 uintmax_t st_bulk_records; /* Bulk records stored. */
996 uintmax_t st_bulk_transfers; /* Transfers of bulk buffers. */
997 uintmax_t st_client_rerequests;/* Number of forced rerequests. */
998 uintmax_t st_client_svc_req; /* Number of client service requests
999 received by this client. */
1000 uintmax_t st_client_svc_miss; /* Number of client service requests
1001 missing on this client. */
1002 u_int32_t st_gen; /* Current generation number. */
1003 u_int32_t st_egen; /* Current election gen number. */
1004 uintmax_t st_log_duplicated; /* Log records received multiply.+ */
1005 uintmax_t st_log_queued_max; /* Max. log records queued at once.+ */
1006 uintmax_t st_log_queued_total; /* Total # of log recs. ever queued.+ */
1007 uintmax_t st_log_records; /* Log records received and put.+ */
1008 uintmax_t st_log_requested; /* Log recs. missed and requested.+ */
1009 int st_master; /* Env. ID of the current master. */
1010 uintmax_t st_master_changes; /* # of times we've switched masters. */
1011 uintmax_t st_msgs_badgen; /* Messages with a bad generation #.+ */
1012 uintmax_t st_msgs_processed; /* Messages received and processed.+ */
1013 uintmax_t st_msgs_recover; /* Messages ignored because this site
1014 was a client in recovery.+ */
1015 uintmax_t st_msgs_send_failures;/* # of failed message sends.+ */
1016 uintmax_t st_msgs_sent; /* # of successful message sends.+ */
1017 uintmax_t st_newsites; /* # of NEWSITE msgs. received.+ */
1018 u_int32_t st_nsites; /* Current number of sites we will
1019 assume during elections. */
1020 uintmax_t st_nthrottles; /* # of times we were throttled. */
1021 uintmax_t st_outdated; /* # of times we detected and returned
1022 an OUTDATED condition.+ */
1023 uintmax_t st_pg_duplicated; /* Pages received multiply.+ */
1024 uintmax_t st_pg_records; /* Pages received and stored.+ */
1025 uintmax_t st_pg_requested; /* Pages missed and requested.+ */
1026 uintmax_t st_txns_applied; /* # of transactions applied.+ */
1027 uintmax_t st_startsync_delayed;/* # of STARTSYNC msgs delayed.+ */
1029 /* Elections generally. */
1030 uintmax_t st_elections; /* # of elections held.+ */
1031 uintmax_t st_elections_won; /* # of elections won by this site.+ */
1033 /* Statistics about an in-progress election. */
1034 int st_election_cur_winner; /* Current front-runner. */
1035 u_int32_t st_election_gen; /* Election generation number. */
1036 DB_LSN st_election_lsn; /* Max. LSN of current winner. */
1037 u_int32_t st_election_nsites; /* # of "registered voters". */
1038 u_int32_t st_election_nvotes; /* # of "registered voters" needed. */
1039 u_int32_t st_election_priority; /* Current election priority. */
1040 int st_election_status; /* Current election status. */
1041 u_int32_t st_election_tiebreaker;/* Election tiebreaker value. */
1042 u_int32_t st_election_votes; /* Votes received in this round. */
1043 u_int32_t st_election_sec; /* Last election time seconds. */
1044 u_int32_t st_election_usec; /* Last election time useconds. */
1045 u_int32_t st_max_lease_sec; /* Maximum lease timestamp seconds. */
1046 u_int32_t st_max_lease_usec; /* Maximum lease timestamp useconds. */
1048 /* Undocumented statistics only used by the test system. */
1050 u_int32_t st_filefail_cleanups; /* # of FILE_FAIL cleanups done. */
1055 /* Replication Manager statistics. */
1056 struct __db_repmgr_stat {
1057 uintmax_t st_perm_failed; /* # of insufficiently ack'ed msgs. */
1058 uintmax_t st_msgs_queued; /* # msgs queued for network delay. */
1059 uintmax_t st_msgs_dropped; /* # msgs discarded due to excessive
1061 uintmax_t st_connection_drop; /* Existing connections dropped. */
1062 uintmax_t st_connect_fail; /* Failed new connection attempts. */
1065 /*******************************************************
1067 *******************************************************/
1069 * The storage record for a sequence.
1071 struct __db_seq_record {
1072 u_int32_t seq_version; /* Version size/number. */
1073 u_int32_t flags; /* DB_SEQ_XXX Flags. */
1074 db_seq_t seq_value; /* Current value. */
1075 db_seq_t seq_max; /* Max permitted. */
1076 db_seq_t seq_min; /* Min permitted. */
1080 * Handle for a sequence object.
1082 struct __db_sequence {
1083 DB *seq_dbp; /* DB handle for this sequence. */
1084 db_mutex_t mtx_seq; /* Mutex if sequence is threaded. */
1085 DB_SEQ_RECORD *seq_rp; /* Pointer to current data. */
1086 DB_SEQ_RECORD seq_record; /* Data from DB_SEQUENCE. */
1087 int32_t seq_cache_size; /* Number of values cached. */
1088 db_seq_t seq_last_value; /* Last value cached. */
1089 DBT seq_key; /* DBT pointing to sequence key. */
1090 DBT seq_data; /* DBT pointing to seq_record. */
1092 /* API-private structure: used by C++ and Java. */
1095 /* DB_SEQUENCE PUBLIC HANDLE LIST BEGIN */
1096 int (*close) __P((DB_SEQUENCE *, u_int32_t));
1097 int (*get) __P((DB_SEQUENCE *,
1098 DB_TXN *, int32_t, db_seq_t *, u_int32_t));
1099 int (*get_cachesize) __P((DB_SEQUENCE *, int32_t *));
1100 int (*get_db) __P((DB_SEQUENCE *, DB **));
1101 int (*get_flags) __P((DB_SEQUENCE *, u_int32_t *));
1102 int (*get_key) __P((DB_SEQUENCE *, DBT *));
1103 int (*get_range) __P((DB_SEQUENCE *,
1104 db_seq_t *, db_seq_t *));
1105 int (*initial_value) __P((DB_SEQUENCE *, db_seq_t));
1106 int (*open) __P((DB_SEQUENCE *,
1107 DB_TXN *, DBT *, u_int32_t));
1108 int (*remove) __P((DB_SEQUENCE *, DB_TXN *, u_int32_t));
1109 int (*set_cachesize) __P((DB_SEQUENCE *, int32_t));
1110 int (*set_flags) __P((DB_SEQUENCE *, u_int32_t));
1111 int (*set_range) __P((DB_SEQUENCE *, db_seq_t, db_seq_t));
1112 int (*stat) __P((DB_SEQUENCE *,
1113 DB_SEQUENCE_STAT **, u_int32_t));
1114 int (*stat_print) __P((DB_SEQUENCE *, u_int32_t));
1115 /* DB_SEQUENCE PUBLIC HANDLE LIST END */
1118 struct __db_seq_stat {
1119 uintmax_t st_wait; /* Sequence lock granted w/o wait. */
1120 uintmax_t st_nowait; /* Sequence lock granted after wait. */
1121 db_seq_t st_current; /* Current value in db. */
1122 db_seq_t st_value; /* Current cached value. */
1123 db_seq_t st_last_value; /* Last cached value. */
1124 db_seq_t st_min; /* Minimum value. */
1125 db_seq_t st_max; /* Maximum value. */
1126 int32_t st_cache_size; /* Cache size. */
1127 u_int32_t st_flags; /* Flag value. */
1130 /*******************************************************
1132 *******************************************************/
1138 DB_UNKNOWN=5 /* Figure it out on open. */
1141 #define DB_RENAMEMAGIC 0x030800 /* File has been renamed. */
1143 #define DB_BTREEVERSION 9 /* Current btree version. */
1144 #define DB_BTREEOLDVER 8 /* Oldest btree version supported. */
1145 #define DB_BTREEMAGIC 0x053162
1147 #define DB_HASHVERSION 9 /* Current hash version. */
1148 #define DB_HASHOLDVER 7 /* Oldest hash version supported. */
1149 #define DB_HASHMAGIC 0x061561
1151 #define DB_QAMVERSION 4 /* Current queue version. */
1152 #define DB_QAMOLDVER 3 /* Oldest queue version supported. */
1153 #define DB_QAMMAGIC 0x042253
1155 #define DB_SEQUENCE_VERSION 2 /* Current sequence version. */
1156 #define DB_SEQUENCE_OLDVER 1 /* Oldest sequence version supported. */
1159 * DB access method and cursor operation values. Each value is an operation
1160 * code to which additional bit flags are added.
1162 #define DB_AFTER 1 /* Dbc.put */
1163 #define DB_APPEND 2 /* Db.put */
1164 #define DB_BEFORE 3 /* Dbc.put */
1165 #define DB_CONSUME 4 /* Db.get */
1166 #define DB_CONSUME_WAIT 5 /* Db.get */
1167 #define DB_CURRENT 6 /* Dbc.get, Dbc.put, DbLogc.get */
1168 #define DB_FIRST 7 /* Dbc.get, DbLogc->get */
1169 #define DB_GET_BOTH 8 /* Db.get, Dbc.get */
1170 #define DB_GET_BOTHC 9 /* Dbc.get (internal) */
1171 #define DB_GET_BOTH_RANGE 10 /* Db.get, Dbc.get */
1172 #define DB_GET_RECNO 11 /* Dbc.get */
1173 #define DB_JOIN_ITEM 12 /* Dbc.get; don't do primary lookup */
1174 #define DB_KEYFIRST 13 /* Dbc.put */
1175 #define DB_KEYLAST 14 /* Dbc.put */
1176 #define DB_LAST 15 /* Dbc.get, DbLogc->get */
1177 #define DB_NEXT 16 /* Dbc.get, DbLogc->get */
1178 #define DB_NEXT_DUP 17 /* Dbc.get */
1179 #define DB_NEXT_NODUP 18 /* Dbc.get */
1180 #define DB_NODUPDATA 19 /* Db.put, Dbc.put */
1181 #define DB_NOOVERWRITE 20 /* Db.put */
1182 #define DB_NOSYNC 21 /* Db.close */
1183 #define DB_OVERWRITE_DUP 22 /* Dbc.put, Db.put; no DB_KEYEXIST */
1184 #define DB_POSITION 23 /* Dbc.dup */
1185 #define DB_PREV 24 /* Dbc.get, DbLogc->get */
1186 #define DB_PREV_DUP 25 /* Dbc.get */
1187 #define DB_PREV_NODUP 26 /* Dbc.get */
1188 #define DB_SET 27 /* Dbc.get, DbLogc->get */
1189 #define DB_SET_RANGE 28 /* Dbc.get */
1190 #define DB_SET_RECNO 29 /* Db.get, Dbc.get */
1191 #define DB_UPDATE_SECONDARY 30 /* Dbc.get, Dbc.del (internal) */
1192 #define DB_SET_LTE 31 /* Dbc.get (internal) */
1193 #define DB_GET_BOTH_LTE 32 /* Dbc.get (internal) */
1195 /* This has to change when the max opcode hits 255. */
1196 #define DB_OPFLAGS_MASK 0x000000ff /* Mask for operations flags. */
1199 * DB (user visible) error return codes.
1202 * We don't want our error returns to conflict with other packages where
1203 * possible, so pick a base error value that's hopefully not common. We
1204 * document that we own the error name space from -30,800 to -30,999.
1206 /* DB (public) error return codes. */
1207 #define DB_BUFFER_SMALL (-30999)/* User memory too small for return. */
1208 #define DB_DONOTINDEX (-30998)/* "Null" return from 2ndary callbk. */
1209 #define DB_FOREIGN_CONFLICT (-30997)/* A foreign db constraint triggered. */
1210 #define DB_KEYEMPTY (-30996)/* Key/data deleted or never created. */
1211 #define DB_KEYEXIST (-30995)/* The key/data pair already exists. */
1212 #define DB_LOCK_DEADLOCK (-30994)/* Deadlock. */
1213 #define DB_LOCK_NOTGRANTED (-30993)/* Lock unavailable. */
1214 #define DB_LOG_BUFFER_FULL (-30992)/* In-memory log buffer full. */
1215 #define DB_NOSERVER (-30991)/* Server panic return. */
1216 #define DB_NOSERVER_HOME (-30990)/* Bad home sent to server. */
1217 #define DB_NOSERVER_ID (-30989)/* Bad ID sent to server. */
1218 #define DB_NOTFOUND (-30988)/* Key/data pair not found (EOF). */
1219 #define DB_OLD_VERSION (-30987)/* Out-of-date version. */
1220 #define DB_PAGE_NOTFOUND (-30986)/* Requested page not found. */
1221 #define DB_REP_DUPMASTER (-30985)/* There are two masters. */
1222 #define DB_REP_HANDLE_DEAD (-30984)/* Rolled back a commit. */
1223 #define DB_REP_HOLDELECTION (-30983)/* Time to hold an election. */
1224 #define DB_REP_IGNORE (-30982)/* This msg should be ignored.*/
1225 #define DB_REP_ISPERM (-30981)/* Cached not written perm written.*/
1226 #define DB_REP_JOIN_FAILURE (-30980)/* Unable to join replication group. */
1227 #define DB_REP_LEASE_EXPIRED (-30979)/* Master lease has expired. */
1228 #define DB_REP_LOCKOUT (-30978)/* API/Replication lockout now. */
1229 #define DB_REP_NEWSITE (-30977)/* New site entered system. */
1230 #define DB_REP_NOTPERM (-30976)/* Permanent log record not written. */
1231 #define DB_REP_UNAVAIL (-30975)/* Site cannot currently be reached. */
1232 #define DB_RUNRECOVERY (-30974)/* Panic return. */
1233 #define DB_SECONDARY_BAD (-30973)/* Secondary index corrupt. */
1234 #define DB_VERIFY_BAD (-30972)/* Verify failed; bad format. */
1235 #define DB_VERSION_MISMATCH (-30971)/* Environment version mismatch. */
1237 /* DB (private) error return codes. */
1238 #define DB_ALREADY_ABORTED (-30899)
1239 #define DB_DELETED (-30898)/* Recovery file marked deleted. */
1240 #define DB_EVENT_NOT_HANDLED (-30897)/* Forward event to application. */
1241 #define DB_NEEDSPLIT (-30896)/* Page needs to be split. */
1242 #define DB_REP_BULKOVF (-30895)/* Rep bulk buffer overflow. */
1243 #define DB_REP_EGENCHG (-30894)/* Egen changed while in election. */
1244 #define DB_REP_LOGREADY (-30893)/* Rep log ready for recovery. */
1245 #define DB_REP_NEWMASTER (-30892)/* We have learned of a new master. */
1246 #define DB_REP_PAGEDONE (-30891)/* This page was already done. */
1247 #define DB_REP_PAGELOCKED (-30890)/* Page we want is locked. */
1248 #define DB_SURPRISE_KID (-30889)/* Child commit where parent
1249 didn't know it was a parent. */
1250 #define DB_SWAPBYTES (-30888)/* Database needs byte swapping. */
1251 #define DB_TIMEOUT (-30887)/* Timed out waiting for election. */
1252 #define DB_TXN_CKP (-30886)/* Encountered ckp record in log. */
1253 #define DB_VERIFY_FATAL (-30885)/* DB->verify cannot proceed. */
1255 /* Database handle. */
1257 /*******************************************************
1258 * Public: owned by the application.
1259 *******************************************************/
1260 u_int32_t pgsize; /* Database logical page size. */
1261 DB_CACHE_PRIORITY priority; /* Database priority in cache. */
1264 int (*db_append_recno) __P((DB *, DBT *, db_recno_t));
1265 void (*db_feedback) __P((DB *, int, int));
1266 int (*dup_compare) __P((DB *, const DBT *, const DBT *));
1268 void *app_private; /* Application-private handle. */
1270 /*******************************************************
1271 * Private: owned by DB.
1272 *******************************************************/
1273 DB_ENV *dbenv; /* Backing public environment. */
1274 ENV *env; /* Backing private environment. */
1276 DBTYPE type; /* DB access method type. */
1278 DB_MPOOLFILE *mpf; /* Backing buffer pool. */
1280 db_mutex_t mutex; /* Synchronization for free threading */
1282 char *fname, *dname; /* File/database passed to DB->open. */
1283 const char *dirname; /* Direcory of DB file. */
1284 u_int32_t open_flags; /* Flags passed to DB->open. */
1286 u_int8_t fileid[DB_FILE_ID_LEN];/* File's unique ID for locking. */
1288 u_int32_t adj_fileid; /* File's unique ID for curs. adj. */
1290 #define DB_LOGFILEID_INVALID -1
1291 FNAME *log_filename; /* File's naming info for logging. */
1293 db_pgno_t meta_pgno; /* Meta page number */
1294 DB_LOCKER *locker; /* Locker for handle locking. */
1295 DB_LOCKER *cur_locker; /* Current handle lock holder. */
1296 DB_TXN *cur_txn; /* Opening transaction. */
1297 DB_LOCKER *associate_locker; /* Locker for DB->associate call. */
1298 DB_LOCK handle_lock; /* Lock held on this handle. */
1300 u_int cl_id; /* RPC: remote client id. */
1302 time_t timestamp; /* Handle timestamp for replication. */
1303 u_int32_t fid_gen; /* Rep generation number for fids. */
1306 * Returned data memory for DB->get() and friends.
1308 DBT my_rskey; /* Secondary key. */
1309 DBT my_rkey; /* [Primary] key. */
1310 DBT my_rdata; /* Data. */
1314 * Some applications use DB but implement their own locking outside of
1315 * DB. If they're using fcntl(2) locking on the underlying database
1316 * file, and we open and close a file descriptor for that file, we will
1317 * discard their locks. The DB_FCNTL_LOCKING flag to DB->open is an
1318 * undocumented interface to support this usage which leaves any file
1319 * descriptors we open until DB->close. This will only work with the
1320 * DB->open interface and simple caches, e.g., creating a transaction
1321 * thread may open/close file descriptors this flag doesn't protect.
1322 * Locking with fcntl(2) on a file that you don't own is a very, very
1323 * unsafe thing to do. 'Nuff said.
1325 DB_FH *saved_open_fhp; /* Saved file handle. */
1328 * Linked list of DBP's, linked from the ENV, used to keep track
1329 * of all open db handles for cursor adjustment.
1332 * Explicit representations of structures from queue.h.
1333 * TAILQ_ENTRY(__db) dblistlinks;
1336 struct __db *tqe_next;
1337 struct __db **tqe_prev;
1344 * Explicit representations of structures from queue.h.
1345 * TAILQ_HEAD(__cq_fq, __dbc) free_queue;
1346 * TAILQ_HEAD(__cq_aq, __dbc) active_queue;
1347 * TAILQ_HEAD(__cq_jq, __dbc) join_queue;
1350 struct __dbc *tqh_first;
1351 struct __dbc **tqh_last;
1354 struct __dbc *tqh_first;
1355 struct __dbc **tqh_last;
1358 struct __dbc *tqh_first;
1359 struct __dbc **tqh_last;
1363 * Secondary index support.
1365 * Linked list of secondary indices -- set in the primary.
1368 * Explicit representations of structures from queue.h.
1369 * LIST_HEAD(s_secondaries, __db);
1372 struct __db *lh_first;
1376 * List entries for secondaries, and reference count of how many
1377 * threads are updating this secondary (see Dbc.put).
1380 * Note that these are synchronized by the primary's mutex, but
1381 * filled in in the secondaries.
1384 * Explicit representations of structures from queue.h.
1385 * LIST_ENTRY(__db) s_links;
1388 struct __db *le_next;
1389 struct __db **le_prev;
1393 /* Secondary callback and free functions -- set in the secondary. */
1394 int (*s_callback) __P((DB *, const DBT *, const DBT *, DBT *));
1396 /* Reference to primary -- set in the secondary. */
1399 #define DB_ASSOC_IMMUTABLE_KEY 0x00000001 /* Secondary key is immutable. */
1401 /* Flags passed to associate -- set in the secondary. */
1402 u_int32_t s_assoc_flags;
1405 * Foreign key support.
1407 * Linked list of primary dbs -- set in the foreign db
1410 * Explicit representations of structures from queue.h.
1411 * LIST_HEAD(f_primaries, __db);
1414 struct __db_foreign_info *lh_first;
1417 /* Reference to foreign -- set in the secondary. */
1420 /* API-private structure: used by DB 1.85, C++, Java, Perl and Tcl */
1423 /* Subsystem-private structure. */
1424 void *bt_internal; /* Btree/Recno access method. */
1425 void *h_internal; /* Hash access method. */
1426 void *p_internal; /* Partition informaiton. */
1427 void *q_internal; /* Queue access method. */
1429 /* DB PUBLIC HANDLE LIST BEGIN */
1430 int (*associate) __P((DB *, DB_TXN *, DB *,
1431 int (*)(DB *, const DBT *, const DBT *, DBT *), u_int32_t));
1432 int (*associate_foreign) __P((DB *, DB *,
1433 int (*)(DB *, const DBT *, DBT *, const DBT *, int *),
1435 int (*close) __P((DB *, u_int32_t));
1436 int (*compact) __P((DB *,
1437 DB_TXN *, DBT *, DBT *, DB_COMPACT *, u_int32_t, DBT *));
1438 int (*cursor) __P((DB *, DB_TXN *, DBC **, u_int32_t));
1439 int (*del) __P((DB *, DB_TXN *, DBT *, u_int32_t));
1440 void (*err) __P((DB *, int, const char *, ...));
1441 void (*errx) __P((DB *, const char *, ...));
1442 int (*exists) __P((DB *, DB_TXN *, DBT *, u_int32_t));
1443 int (*fd) __P((DB *, int *));
1444 int (*get) __P((DB *, DB_TXN *, DBT *, DBT *, u_int32_t));
1445 int (*get_alloc) __P((DB *, void *(**)(size_t),
1446 void *(**)(void *, size_t), void (**)(void *)));
1447 int (*get_append_recno) __P((DB *, int (**)(DB *, DBT *, db_recno_t)));
1448 int (*get_bt_compare)
1449 __P((DB *, int (**)(DB *, const DBT *, const DBT *)));
1450 int (*get_bt_compress) __P((DB *,
1452 const DBT *, const DBT *, const DBT *, const DBT *, DBT *),
1453 int (**)(DB *, const DBT *, const DBT *, DBT *, DBT *, DBT *)));
1454 int (*get_bt_minkey) __P((DB *, u_int32_t *));
1455 int (*get_bt_prefix)
1456 __P((DB *, size_t (**)(DB *, const DBT *, const DBT *)));
1457 int (*get_byteswapped) __P((DB *, int *));
1458 int (*get_cachesize) __P((DB *, u_int32_t *, u_int32_t *, int *));
1459 int (*get_create_dir) __P((DB *, const char **));
1460 int (*get_dbname) __P((DB *, const char **, const char **));
1461 int (*get_dup_compare)
1462 __P((DB *, int (**)(DB *, const DBT *, const DBT *)));
1463 int (*get_encrypt_flags) __P((DB *, u_int32_t *));
1464 DB_ENV *(*get_env) __P((DB *));
1465 void (*get_errcall) __P((DB *,
1466 void (**)(const DB_ENV *, const char *, const char *)));
1467 void (*get_errfile) __P((DB *, FILE **));
1468 void (*get_errpfx) __P((DB *, const char **));
1469 int (*get_feedback) __P((DB *, void (**)(DB *, int, int)));
1470 int (*get_flags) __P((DB *, u_int32_t *));
1471 int (*get_h_compare)
1472 __P((DB *, int (**)(DB *, const DBT *, const DBT *)));
1473 int (*get_h_ffactor) __P((DB *, u_int32_t *));
1475 __P((DB *, u_int32_t (**)(DB *, const void *, u_int32_t)));
1476 int (*get_h_nelem) __P((DB *, u_int32_t *));
1477 int (*get_lorder) __P((DB *, int *));
1478 DB_MPOOLFILE *(*get_mpf) __P((DB *));
1479 void (*get_msgcall) __P((DB *,
1480 void (**)(const DB_ENV *, const char *)));
1481 void (*get_msgfile) __P((DB *, FILE **));
1482 int (*get_multiple) __P((DB *));
1483 int (*get_open_flags) __P((DB *, u_int32_t *));
1484 int (*get_pagesize) __P((DB *, u_int32_t *));
1485 int (*get_partition_callback) __P((DB *,
1486 u_int32_t *, u_int32_t (**)(DB *, DBT *key)));
1487 int (*get_partition_dirs) __P((DB *, const char ***));
1488 int (*get_partition_keys) __P((DB *, u_int32_t *, DBT **));
1489 int (*get_priority) __P((DB *, DB_CACHE_PRIORITY *));
1490 int (*get_q_extentsize) __P((DB *, u_int32_t *));
1491 int (*get_re_delim) __P((DB *, int *));
1492 int (*get_re_len) __P((DB *, u_int32_t *));
1493 int (*get_re_pad) __P((DB *, int *));
1494 int (*get_re_source) __P((DB *, const char **));
1495 int (*get_transactional) __P((DB *));
1496 int (*get_type) __P((DB *, DBTYPE *));
1497 int (*join) __P((DB *, DBC **, DBC **, u_int32_t));
1499 __P((DB *, DB_TXN *, DBT *, DB_KEY_RANGE *, u_int32_t));
1500 int (*open) __P((DB *,
1501 DB_TXN *, const char *, const char *, DBTYPE, u_int32_t, int));
1502 int (*pget) __P((DB *, DB_TXN *, DBT *, DBT *, DBT *, u_int32_t));
1503 int (*put) __P((DB *, DB_TXN *, DBT *, DBT *, u_int32_t));
1504 int (*remove) __P((DB *, const char *, const char *, u_int32_t));
1505 int (*rename) __P((DB *,
1506 const char *, const char *, const char *, u_int32_t));
1507 int (*set_alloc) __P((DB *, void *(*)(size_t),
1508 void *(*)(void *, size_t), void (*)(void *)));
1509 int (*set_append_recno) __P((DB *, int (*)(DB *, DBT *, db_recno_t)));
1510 int (*set_bt_compare)
1511 __P((DB *, int (*)(DB *, const DBT *, const DBT *)));
1512 int (*set_bt_compress) __P((DB *,
1513 int (*)(DB *, const DBT *, const DBT *, const DBT *, const DBT *, DBT *),
1514 int (*)(DB *, const DBT *, const DBT *, DBT *, DBT *, DBT *)));
1515 int (*set_bt_minkey) __P((DB *, u_int32_t));
1516 int (*set_bt_prefix)
1517 __P((DB *, size_t (*)(DB *, const DBT *, const DBT *)));
1518 int (*set_cachesize) __P((DB *, u_int32_t, u_int32_t, int));
1519 int (*set_create_dir) __P((DB *, const char *));
1520 int (*set_dup_compare)
1521 __P((DB *, int (*)(DB *, const DBT *, const DBT *)));
1522 int (*set_encrypt) __P((DB *, const char *, u_int32_t));
1523 void (*set_errcall) __P((DB *,
1524 void (*)(const DB_ENV *, const char *, const char *)));
1525 void (*set_errfile) __P((DB *, FILE *));
1526 void (*set_errpfx) __P((DB *, const char *));
1527 int (*set_feedback) __P((DB *, void (*)(DB *, int, int)));
1528 int (*set_flags) __P((DB *, u_int32_t));
1529 int (*set_h_compare)
1530 __P((DB *, int (*)(DB *, const DBT *, const DBT *)));
1531 int (*set_h_ffactor) __P((DB *, u_int32_t));
1533 __P((DB *, u_int32_t (*)(DB *, const void *, u_int32_t)));
1534 int (*set_h_nelem) __P((DB *, u_int32_t));
1535 int (*set_lorder) __P((DB *, int));
1536 void (*set_msgcall) __P((DB *, void (*)(const DB_ENV *, const char *)));
1537 void (*set_msgfile) __P((DB *, FILE *));
1538 int (*set_pagesize) __P((DB *, u_int32_t));
1539 int (*set_paniccall) __P((DB *, void (*)(DB_ENV *, int)));
1540 int (*set_partition) __P((DB *,
1541 u_int32_t, DBT *, u_int32_t (*)(DB *, DBT *key)));
1542 int (*set_partition_dirs) __P((DB *, const char **));
1543 int (*set_priority) __P((DB *, DB_CACHE_PRIORITY));
1544 int (*set_q_extentsize) __P((DB *, u_int32_t));
1545 int (*set_re_delim) __P((DB *, int));
1546 int (*set_re_len) __P((DB *, u_int32_t));
1547 int (*set_re_pad) __P((DB *, int));
1548 int (*set_re_source) __P((DB *, const char *));
1549 int (*sort_multiple) __P((DB *, DBT *, DBT *, u_int32_t));
1550 int (*stat) __P((DB *, DB_TXN *, void *, u_int32_t));
1551 int (*stat_print) __P((DB *, u_int32_t));
1552 int (*sync) __P((DB *, u_int32_t));
1553 int (*truncate) __P((DB *, DB_TXN *, u_int32_t *, u_int32_t));
1554 int (*upgrade) __P((DB *, const char *, u_int32_t));
1556 __P((DB *, const char *, const char *, FILE *, u_int32_t));
1557 /* DB PUBLIC HANDLE LIST END */
1559 /* DB PRIVATE HANDLE LIST BEGIN */
1560 int (*dump) __P((DB *, const char *,
1561 int (*)(void *, const void *), void *, int, int));
1562 int (*db_am_remove) __P((DB *, DB_THREAD_INFO *,
1563 DB_TXN *, const char *, const char *, u_int32_t));
1564 int (*db_am_rename) __P((DB *, DB_THREAD_INFO *,
1565 DB_TXN *, const char *, const char *, const char *));
1566 /* DB PRIVATE HANDLE LIST END */
1569 * Never called; these are a place to save function pointers
1570 * so that we can undo an associate.
1572 int (*stored_get) __P((DB *, DB_TXN *, DBT *, DBT *, u_int32_t));
1573 int (*stored_close) __P((DB *, u_int32_t));
1575 #define DB_OK_BTREE 0x01
1576 #define DB_OK_HASH 0x02
1577 #define DB_OK_QUEUE 0x04
1578 #define DB_OK_RECNO 0x08
1579 u_int32_t am_ok; /* Legal AM choices. */
1582 * This field really ought to be an AM_FLAG, but we have
1583 * have run out of bits. If/when we decide to split up
1584 * the flags, we can incorporate it.
1586 int preserve_fid; /* Do not free fileid on close. */
1588 #define DB_AM_CHKSUM 0x00000001 /* Checksumming */
1589 #define DB_AM_COMPENSATE 0x00000002 /* Created by compensating txn */
1590 #define DB_AM_COMPRESS 0x00000004 /* Compressed BTree */
1591 #define DB_AM_CREATED 0x00000008 /* Database was created upon open */
1592 #define DB_AM_CREATED_MSTR 0x00000010 /* Encompassing file was created */
1593 #define DB_AM_DBM_ERROR 0x00000020 /* Error in DBM/NDBM database */
1594 #define DB_AM_DELIMITER 0x00000040 /* Variable length delimiter set */
1595 #define DB_AM_DISCARD 0x00000080 /* Discard any cached pages */
1596 #define DB_AM_DUP 0x00000100 /* DB_DUP */
1597 #define DB_AM_DUPSORT 0x00000200 /* DB_DUPSORT */
1598 #define DB_AM_ENCRYPT 0x00000400 /* Encryption */
1599 #define DB_AM_FIXEDLEN 0x00000800 /* Fixed-length records */
1600 #define DB_AM_INMEM 0x00001000 /* In-memory; no sync on close */
1601 #define DB_AM_INORDER 0x00002000 /* DB_INORDER */
1602 #define DB_AM_IN_RENAME 0x00004000 /* File is being renamed */
1603 #define DB_AM_NOT_DURABLE 0x00008000 /* Do not log changes */
1604 #define DB_AM_OPEN_CALLED 0x00010000 /* DB->open called */
1605 #define DB_AM_PAD 0x00020000 /* Fixed-length record pad */
1606 #define DB_AM_PGDEF 0x00040000 /* Page size was defaulted */
1607 #define DB_AM_RDONLY 0x00080000 /* Database is readonly */
1608 #define DB_AM_READ_UNCOMMITTED 0x00100000 /* Support degree 1 isolation */
1609 #define DB_AM_RECNUM 0x00200000 /* DB_RECNUM */
1610 #define DB_AM_RECOVER 0x00400000 /* DB opened by recovery routine */
1611 #define DB_AM_RENUMBER 0x00800000 /* DB_RENUMBER */
1612 #define DB_AM_REVSPLITOFF 0x01000000 /* DB_REVSPLITOFF */
1613 #define DB_AM_SECONDARY 0x02000000 /* Database is a secondary index */
1614 #define DB_AM_SNAPSHOT 0x04000000 /* DB_SNAPSHOT */
1615 #define DB_AM_SUBDB 0x08000000 /* Subdatabases supported */
1616 #define DB_AM_SWAP 0x10000000 /* Pages need to be byte-swapped */
1617 #define DB_AM_TXN 0x20000000 /* Opened in a transaction */
1618 #define DB_AM_VERIFYING 0x40000000 /* DB handle is in the verifier */
1619 u_int32_t orig_flags; /* Flags at open, for refresh */
1624 * Macros for bulk operations. These are only intended for the C API.
1625 * For C++, use DbMultiple*Iterator or DbMultiple*Builder.
1627 * Bulk operations store multiple entries into a single DBT structure. The
1628 * following macros assist with creating and reading these Multiple DBTs.
1630 * The basic layout for single data items is:
1632 * -------------------------------------------------------------------------
1633 * | data1 | ... | dataN | ..... |-1 | dNLen | dNOff | ... | d1Len | d1Off |
1634 * -------------------------------------------------------------------------
1636 * For the DB_MULTIPLE_KEY* macros, the items are in key/data pairs, so data1
1637 * would be a key, and data2 its corresponding value (N is always even).
1639 * For the DB_MULTIPLE_RECNO* macros, the record number is stored along with
1640 * the len/off pair in the "header" section, and the list is zero terminated
1641 * (since -1 is a valid record number):
1643 * --------------------------------------------------------------------------
1644 * | d1 |..| dN |..| 0 | dNLen | dNOff | recnoN |..| d1Len | d1Off | recno1 |
1645 * --------------------------------------------------------------------------
1647 #define DB_MULTIPLE_INIT(pointer, dbt) \
1648 (pointer = (u_int8_t *)(dbt)->data + \
1649 (dbt)->ulen - sizeof(u_int32_t))
1651 #define DB_MULTIPLE_NEXT(pointer, dbt, retdata, retdlen) \
1653 u_int32_t *__p = (u_int32_t *)(pointer); \
1654 if (*__p == (u_int32_t)-1) { \
1659 retdata = (u_int8_t *)(dbt)->data + *__p--; \
1662 if (retdlen == 0 && retdata == (u_int8_t *)(dbt)->data) \
1666 #define DB_MULTIPLE_KEY_NEXT(pointer, dbt, retkey, retklen, retdata, retdlen) \
1668 u_int32_t *__p = (u_int32_t *)(pointer); \
1669 if (*__p == (u_int32_t)-1) { \
1675 retkey = (u_int8_t *)(dbt)->data + *__p--; \
1677 retdata = (u_int8_t *)(dbt)->data + *__p--; \
1682 #define DB_MULTIPLE_RECNO_NEXT(pointer, dbt, recno, retdata, retdlen) \
1684 u_int32_t *__p = (u_int32_t *)(pointer); \
1685 if (*__p == (u_int32_t)0) { \
1692 retdata = (u_int8_t *)(dbt)->data + *__p--; \
1697 #define DB_MULTIPLE_WRITE_INIT(pointer, dbt) \
1699 (dbt)->flags |= DB_DBT_BULK; \
1700 pointer = (u_int8_t *)(dbt)->data + \
1701 (dbt)->ulen - sizeof(u_int32_t); \
1702 *(u_int32_t *)(pointer) = (u_int32_t)-1; \
1705 #define DB_MULTIPLE_RESERVE_NEXT(pointer, dbt, writedata, writedlen) \
1707 u_int32_t *__p = (u_int32_t *)(pointer); \
1708 u_int32_t __off = ((pointer) == (u_int8_t *)(dbt)->data +\
1709 (dbt)->ulen - sizeof(u_int32_t)) ? 0 : __p[1] + __p[2];\
1710 if ((u_int8_t *)(dbt)->data + __off + (writedlen) > \
1711 (u_int8_t *)(__p - 2)) \
1714 writedata = (u_int8_t *)(dbt)->data + __off; \
1716 __p[-1] = (writedlen); \
1717 __p[-2] = (u_int32_t)-1; \
1718 pointer = __p - 2; \
1722 #define DB_MULTIPLE_WRITE_NEXT(pointer, dbt, writedata, writedlen) \
1725 DB_MULTIPLE_RESERVE_NEXT((pointer), (dbt), \
1726 __destd, (writedlen)); \
1727 if (__destd == NULL) \
1730 memcpy(__destd, (writedata), (writedlen)); \
1733 #define DB_MULTIPLE_KEY_RESERVE_NEXT(pointer, dbt, writekey, writeklen, writedata, writedlen) \
1735 u_int32_t *__p = (u_int32_t *)(pointer); \
1736 u_int32_t __off = ((pointer) == (u_int8_t *)(dbt)->data +\
1737 (dbt)->ulen - sizeof(u_int32_t)) ? 0 : __p[1] + __p[2];\
1738 if ((u_int8_t *)(dbt)->data + __off + (writeklen) + \
1739 (writedlen) > (u_int8_t *)(__p - 4)) { \
1743 writekey = (u_int8_t *)(dbt)->data + __off; \
1745 __p[-1] = (writeklen); \
1747 __off += (writeklen); \
1748 writedata = (u_int8_t *)(dbt)->data + __off; \
1750 __p[-1] = (writedlen); \
1751 __p[-2] = (u_int32_t)-1; \
1752 pointer = __p - 2; \
1756 #define DB_MULTIPLE_KEY_WRITE_NEXT(pointer, dbt, writekey, writeklen, writedata, writedlen) \
1758 void *__destk, *__destd; \
1759 DB_MULTIPLE_KEY_RESERVE_NEXT((pointer), (dbt), \
1760 __destk, (writeklen), __destd, (writedlen)); \
1761 if (__destk == NULL) \
1764 memcpy(__destk, (writekey), (writeklen)); \
1765 if (__destd != NULL) \
1766 memcpy(__destd, (writedata), (writedlen));\
1770 #define DB_MULTIPLE_RECNO_WRITE_INIT(pointer, dbt) \
1772 (dbt)->flags |= DB_DBT_BULK; \
1773 pointer = (u_int8_t *)(dbt)->data + \
1774 (dbt)->ulen - sizeof(u_int32_t); \
1775 *(u_int32_t *)(pointer) = 0; \
1778 #define DB_MULTIPLE_RECNO_RESERVE_NEXT(pointer, dbt, recno, writedata, writedlen) \
1780 u_int32_t *__p = (u_int32_t *)(pointer); \
1781 u_int32_t __off = ((pointer) == (u_int8_t *)(dbt)->data +\
1782 (dbt)->ulen - sizeof(u_int32_t)) ? 0 : __p[1] + __p[2]; \
1783 if (((u_int8_t *)(dbt)->data + __off) + (writedlen) > \
1784 (u_int8_t *)(__p - 3)) \
1787 writedata = (u_int8_t *)(dbt)->data + __off; \
1788 __p[0] = (u_int32_t)(recno); \
1790 __p[-2] = (writedlen); \
1792 pointer = __p - 3; \
1796 #define DB_MULTIPLE_RECNO_WRITE_NEXT(pointer, dbt, recno, writedata, writedlen)\
1799 DB_MULTIPLE_RECNO_RESERVE_NEXT((pointer), (dbt), \
1800 (recno), __destd, (writedlen)); \
1801 if (__destd == NULL) \
1803 else if ((writedlen) != 0) \
1804 memcpy(__destd, (writedata), (writedlen)); \
1807 /*******************************************************
1808 * Access method cursors.
1809 *******************************************************/
1811 DB *dbp; /* Backing database */
1812 DB_ENV *dbenv; /* Backing environment */
1813 ENV *env; /* Backing environment */
1815 DB_THREAD_INFO *thread_info; /* Thread that owns this cursor. */
1816 DB_TXN *txn; /* Associated transaction. */
1817 DB_CACHE_PRIORITY priority; /* Priority in cache. */
1820 * Active/free cursor queues.
1823 * Explicit representations of structures from queue.h.
1824 * TAILQ_ENTRY(__dbc) links;
1832 * The DBT *'s below are used by the cursor routines to return
1833 * data to the user when DBT flags indicate that DB should manage
1834 * the returned memory. They point at a DBT containing the buffer
1835 * and length that will be used, and "belonging" to the handle that
1836 * should "own" this memory. This may be a "my_*" field of this
1837 * cursor--the default--or it may be the corresponding field of
1838 * another cursor, a DB handle, a join cursor, etc. In general, it
1839 * will be whatever handle the user originally used for the current
1840 * DB interface call.
1842 DBT *rskey; /* Returned secondary key. */
1843 DBT *rkey; /* Returned [primary] key. */
1844 DBT *rdata; /* Returned data. */
1846 DBT my_rskey; /* Space for returned secondary key. */
1847 DBT my_rkey; /* Space for returned [primary] key. */
1848 DBT my_rdata; /* Space for returned data. */
1850 DB_LOCKER *lref; /* Reference to default locker. */
1851 DB_LOCKER *locker; /* Locker for this operation. */
1852 DBT lock_dbt; /* DBT referencing lock. */
1853 DB_LOCK_ILOCK lock; /* Object to be locked. */
1854 DB_LOCK mylock; /* CDB lock held on this cursor. */
1856 u_int cl_id; /* Remote client id. */
1858 DBTYPE dbtype; /* Cursor type. */
1860 DBC_INTERNAL *internal; /* Access method private. */
1862 /* DBC PUBLIC HANDLE LIST BEGIN */
1863 int (*close) __P((DBC *));
1864 int (*cmp) __P((DBC *, DBC *, int *, u_int32_t));
1865 int (*count) __P((DBC *, db_recno_t *, u_int32_t));
1866 int (*del) __P((DBC *, u_int32_t));
1867 int (*dup) __P((DBC *, DBC **, u_int32_t));
1868 int (*get) __P((DBC *, DBT *, DBT *, u_int32_t));
1869 int (*get_priority) __P((DBC *, DB_CACHE_PRIORITY *));
1870 int (*pget) __P((DBC *, DBT *, DBT *, DBT *, u_int32_t));
1871 int (*put) __P((DBC *, DBT *, DBT *, u_int32_t));
1872 int (*set_priority) __P((DBC *, DB_CACHE_PRIORITY));
1873 /* DBC PUBLIC HANDLE LIST END */
1875 /* The following are the method names deprecated in the 4.6 release. */
1876 int (*c_close) __P((DBC *));
1877 int (*c_count) __P((DBC *, db_recno_t *, u_int32_t));
1878 int (*c_del) __P((DBC *, u_int32_t));
1879 int (*c_dup) __P((DBC *, DBC **, u_int32_t));
1880 int (*c_get) __P((DBC *, DBT *, DBT *, u_int32_t));
1881 int (*c_pget) __P((DBC *, DBT *, DBT *, DBT *, u_int32_t));
1882 int (*c_put) __P((DBC *, DBT *, DBT *, u_int32_t));
1884 /* DBC PRIVATE HANDLE LIST BEGIN */
1885 int (*am_bulk) __P((DBC *, DBT *, u_int32_t));
1886 int (*am_close) __P((DBC *, db_pgno_t, int *));
1887 int (*am_del) __P((DBC *, u_int32_t));
1888 int (*am_destroy) __P((DBC *));
1889 int (*am_get) __P((DBC *, DBT *, DBT *, u_int32_t, db_pgno_t *));
1890 int (*am_put) __P((DBC *, DBT *, DBT *, u_int32_t, db_pgno_t *));
1891 int (*am_writelock) __P((DBC *));
1892 /* DBC PRIVATE HANDLE LIST END */
1895 * DBC_DONTLOCK and DBC_RECOVER are used during recovery and transaction
1896 * abort. If a transaction is being aborted or recovered then DBC_RECOVER
1897 * will be set and locking and logging will be disabled on this cursor. If
1898 * we are performing a compensating transaction (e.g. free page processing)
1899 * then DB_DONTLOCK will be set to inhibit locking, but logging will still
1900 * be required. DB_DONTLOCK is also used if the whole database is locked.
1902 #define DBC_ACTIVE 0x00001 /* Cursor in use. */
1903 #define DBC_BULK 0x00002 /* Bulk update cursor. */
1904 #define DBC_DONTLOCK 0x00004 /* Don't lock on this cursor. */
1905 #define DBC_DOWNREV 0x00008 /* Down rev replication master. */
1906 #define DBC_DUPLICATE 0x00010 /* Create a duplicate cursor. */
1907 #define DBC_FROM_DB_GET 0x00020 /* Called from the DB->get() method. */
1908 #define DBC_MULTIPLE 0x00040 /* Return Multiple data. */
1909 #define DBC_MULTIPLE_KEY 0x00080 /* Return Multiple keys and data. */
1910 #define DBC_OPD 0x00100 /* Cursor references off-page dups. */
1911 #define DBC_OWN_LID 0x00200 /* Free lock id on destroy. */
1912 #define DBC_PARTITIONED 0x00400 /* Cursor for a partitioned db. */
1913 #define DBC_READ_COMMITTED 0x00800 /* Cursor has degree 2 isolation. */
1914 #define DBC_READ_UNCOMMITTED 0x01000 /* Cursor has degree 1 isolation. */
1915 #define DBC_RECOVER 0x02000 /* Recovery cursor; don't log/lock. */
1916 #define DBC_RMW 0x04000 /* Acquire write flag in read op. */
1917 #define DBC_TRANSIENT 0x08000 /* Cursor is transient. */
1918 #define DBC_WAS_READ_COMMITTED 0x10000 /* Cursor holds a read commited lock. */
1919 #define DBC_WRITECURSOR 0x20000 /* Cursor may be used to write (CDB). */
1920 #define DBC_WRITER 0x40000 /* Cursor immediately writing (CDB). */
1924 /* Key range statistics structure */
1925 struct __key_range {
1931 /* Btree/Recno statistics structure. */
1932 struct __db_bt_stat {
1933 u_int32_t bt_magic; /* Magic number. */
1934 u_int32_t bt_version; /* Version number. */
1935 u_int32_t bt_metaflags; /* Metadata flags. */
1936 u_int32_t bt_nkeys; /* Number of unique keys. */
1937 u_int32_t bt_ndata; /* Number of data items. */
1938 u_int32_t bt_pagecnt; /* Page count. */
1939 u_int32_t bt_pagesize; /* Page size. */
1940 u_int32_t bt_minkey; /* Minkey value. */
1941 u_int32_t bt_re_len; /* Fixed-length record length. */
1942 u_int32_t bt_re_pad; /* Fixed-length record pad. */
1943 u_int32_t bt_levels; /* Tree levels. */
1944 u_int32_t bt_int_pg; /* Internal pages. */
1945 u_int32_t bt_leaf_pg; /* Leaf pages. */
1946 u_int32_t bt_dup_pg; /* Duplicate pages. */
1947 u_int32_t bt_over_pg; /* Overflow pages. */
1948 u_int32_t bt_empty_pg; /* Empty pages. */
1949 u_int32_t bt_free; /* Pages on the free list. */
1950 uintmax_t bt_int_pgfree; /* Bytes free in internal pages. */
1951 uintmax_t bt_leaf_pgfree; /* Bytes free in leaf pages. */
1952 uintmax_t bt_dup_pgfree; /* Bytes free in duplicate pages. */
1953 uintmax_t bt_over_pgfree; /* Bytes free in overflow pages. */
1956 struct __db_compact {
1957 /* Input Parameters. */
1958 u_int32_t compact_fillpercent; /* Desired fillfactor: 1-100 */
1959 db_timeout_t compact_timeout; /* Lock timeout. */
1960 u_int32_t compact_pages; /* Max pages to process. */
1962 u_int32_t compact_pages_free; /* Number of pages freed. */
1963 u_int32_t compact_pages_examine; /* Number of pages examine. */
1964 u_int32_t compact_levels; /* Number of levels removed. */
1965 u_int32_t compact_deadlock; /* Number of deadlocks. */
1966 db_pgno_t compact_pages_truncated; /* Pages truncated to OS. */
1968 db_pgno_t compact_truncate; /* Page number for truncation */
1971 /* Hash statistics structure. */
1972 struct __db_h_stat {
1973 u_int32_t hash_magic; /* Magic number. */
1974 u_int32_t hash_version; /* Version number. */
1975 u_int32_t hash_metaflags; /* Metadata flags. */
1976 u_int32_t hash_nkeys; /* Number of unique keys. */
1977 u_int32_t hash_ndata; /* Number of data items. */
1978 u_int32_t hash_pagecnt; /* Page count. */
1979 u_int32_t hash_pagesize; /* Page size. */
1980 u_int32_t hash_ffactor; /* Fill factor specified at create. */
1981 u_int32_t hash_buckets; /* Number of hash buckets. */
1982 u_int32_t hash_free; /* Pages on the free list. */
1983 uintmax_t hash_bfree; /* Bytes free on bucket pages. */
1984 u_int32_t hash_bigpages; /* Number of big key/data pages. */
1985 uintmax_t hash_big_bfree; /* Bytes free on big item pages. */
1986 u_int32_t hash_overflows; /* Number of overflow pages. */
1987 uintmax_t hash_ovfl_free; /* Bytes free on ovfl pages. */
1988 u_int32_t hash_dup; /* Number of dup pages. */
1989 uintmax_t hash_dup_free; /* Bytes free on duplicate pages. */
1992 /* Queue statistics structure. */
1993 struct __db_qam_stat {
1994 u_int32_t qs_magic; /* Magic number. */
1995 u_int32_t qs_version; /* Version number. */
1996 u_int32_t qs_metaflags; /* Metadata flags. */
1997 u_int32_t qs_nkeys; /* Number of unique keys. */
1998 u_int32_t qs_ndata; /* Number of data items. */
1999 u_int32_t qs_pagesize; /* Page size. */
2000 u_int32_t qs_extentsize; /* Pages per extent. */
2001 u_int32_t qs_pages; /* Data pages. */
2002 u_int32_t qs_re_len; /* Fixed-length record length. */
2003 u_int32_t qs_re_pad; /* Fixed-length record pad. */
2004 u_int32_t qs_pgfree; /* Bytes free in data pages. */
2005 u_int32_t qs_first_recno; /* First not deleted record. */
2006 u_int32_t qs_cur_recno; /* Next available record number. */
2009 /*******************************************************
2011 *******************************************************/
2012 #define DB_REGION_MAGIC 0x120897 /* Environment magic number. */
2015 * Database environment structure.
2017 * This is the public database environment handle. The private environment
2018 * handle is the ENV structure. The user owns this structure, the library
2019 * owns the ENV structure. The reason there are two structures is because
2020 * the user's configuration outlives any particular DB_ENV->open call, and
2021 * separate structures allows us to easily discard internal information without
2022 * discarding the user's configuration.
2024 * Fields in the DB_ENV structure should normally be set only by application
2025 * DB_ENV handle methods.
2028 ENV *env; /* Linked ENV structure */
2031 * The DB_ENV structure can be used concurrently, so field access is
2034 db_mutex_t mtx_db_env; /* DB_ENV structure mutex */
2036 /* Error message callback */
2037 void (*db_errcall) __P((const DB_ENV *, const char *, const char *));
2038 FILE *db_errfile; /* Error message file stream */
2039 const char *db_errpfx; /* Error message prefix */
2041 /* Other message callback */
2042 void (*db_msgcall) __P((const DB_ENV *, const char *));
2043 FILE *db_msgfile; /* Other message file stream */
2045 /* Other application callback functions */
2046 int (*app_dispatch) __P((DB_ENV *, DBT *, DB_LSN *, db_recops));
2047 void (*db_event_func) __P((DB_ENV *, u_int32_t, void *));
2048 void (*db_feedback) __P((DB_ENV *, int, int));
2049 void (*db_free) __P((void *));
2050 void (*db_paniccall) __P((DB_ENV *, int));
2051 void *(*db_malloc) __P((size_t));
2052 void *(*db_realloc) __P((void *, size_t));
2053 int (*is_alive) __P((DB_ENV *, pid_t, db_threadid_t, u_int32_t));
2054 void (*thread_id) __P((DB_ENV *, pid_t *, db_threadid_t *));
2055 char *(*thread_id_string) __P((DB_ENV *, pid_t, db_threadid_t, char *));
2057 /* Application specified paths */
2058 char *db_log_dir; /* Database log file directory */
2059 char *db_tmp_dir; /* Database tmp file directory */
2061 char *db_create_dir; /* Create directory for data files */
2062 char **db_data_dir; /* Database data file directories */
2063 int data_cnt; /* Database data file slots */
2064 int data_next; /* Next database data file slot */
2066 char *intermediate_dir_mode; /* Intermediate directory perms */
2068 long shm_key; /* shmget key */
2070 char *passwd; /* Cryptography support */
2073 void *cl_handle; /* RPC: remote client handle */
2074 u_int cl_id; /* RPC: remote client env id */
2076 /* Private handle references */
2077 void *app_private; /* Application-private handle */
2078 void *api1_internal; /* C++, Perl API private */
2079 void *api2_internal; /* Java API private */
2081 u_int32_t verbose; /* DB_VERB_XXX flags */
2083 /* Mutex configuration */
2084 u_int32_t mutex_align; /* Mutex alignment */
2085 u_int32_t mutex_cnt; /* Number of mutexes to configure */
2086 u_int32_t mutex_inc; /* Number of mutexes to add */
2087 u_int32_t mutex_tas_spins;/* Test-and-set spin count */
2089 /* Locking configuration */
2090 u_int8_t *lk_conflicts; /* Two dimensional conflict matrix */
2091 int lk_modes; /* Number of lock modes in table */
2092 u_int32_t lk_detect; /* Deadlock detect on all conflicts */
2093 u_int32_t lk_max; /* Maximum number of locks */
2094 u_int32_t lk_max_lockers;/* Maximum number of lockers */
2095 u_int32_t lk_max_objects;/* Maximum number of locked objects */
2096 u_int32_t lk_partitions ;/* Number of object partitions */
2097 db_timeout_t lk_timeout; /* Lock timeout period */
2099 /* Logging configuration */
2100 u_int32_t lg_bsize; /* Buffer size */
2101 int lg_filemode; /* Log file permission mode */
2102 u_int32_t lg_regionmax; /* Region size */
2103 u_int32_t lg_size; /* Log file size */
2104 u_int32_t lg_flags; /* Log configuration */
2106 /* Memory pool configuration */
2107 u_int32_t mp_gbytes; /* Cache size: GB */
2108 u_int32_t mp_bytes; /* Cache size: bytes */
2109 u_int32_t mp_max_gbytes; /* Maximum cache size: GB */
2110 u_int32_t mp_max_bytes; /* Maximum cache size: bytes */
2111 size_t mp_mmapsize; /* Maximum file size for mmap */
2112 int mp_maxopenfd; /* Maximum open file descriptors */
2113 int mp_maxwrite; /* Maximum buffers to write */
2114 u_int mp_ncache; /* Initial number of cache regions */
2115 u_int32_t mp_pagesize; /* Average page size */
2116 u_int32_t mp_tablesize; /* Approximate hash table size */
2117 /* Sleep after writing max buffers */
2118 db_timeout_t mp_maxwrite_sleep;
2120 /* Transaction configuration */
2121 u_int32_t tx_max; /* Maximum number of transactions */
2122 time_t tx_timestamp; /* Recover to specific timestamp */
2123 db_timeout_t tx_timeout; /* Timeout for transactions */
2125 /* Thread tracking configuration */
2126 u_int32_t thr_max; /* Thread count */
2129 * The following fields are not strictly user-owned, but they outlive
2130 * the ENV structure, and so are stored here.
2132 DB_FH *registry; /* DB_REGISTER file handle */
2133 u_int32_t registry_off; /*
2134 * Offset of our slot. We can't use
2135 * off_t because its size depends on
2138 db_timeout_t envreg_timeout; /* DB_REGISTER wait timeout */
2140 #define DB_ENV_AUTO_COMMIT 0x00000001 /* DB_AUTO_COMMIT */
2141 #define DB_ENV_CDB_ALLDB 0x00000002 /* CDB environment wide locking */
2142 #define DB_ENV_FAILCHK 0x00000004 /* Failchk is running */
2143 #define DB_ENV_DIRECT_DB 0x00000008 /* DB_DIRECT_DB set */
2144 #define DB_ENV_DSYNC_DB 0x00000010 /* DB_DSYNC_DB set */
2145 #define DB_ENV_MULTIVERSION 0x00000020 /* DB_MULTIVERSION set */
2146 #define DB_ENV_NOLOCKING 0x00000040 /* DB_NOLOCKING set */
2147 #define DB_ENV_NOMMAP 0x00000080 /* DB_NOMMAP set */
2148 #define DB_ENV_NOPANIC 0x00000100 /* Okay if panic set */
2149 #define DB_ENV_OVERWRITE 0x00000200 /* DB_OVERWRITE set */
2150 #define DB_ENV_REGION_INIT 0x00000400 /* DB_REGION_INIT set */
2151 #define DB_ENV_RPCCLIENT 0x00000800 /* DB_RPCCLIENT set */
2152 #define DB_ENV_RPCCLIENT_GIVEN 0x00001000 /* User-supplied RPC client struct */
2153 #define DB_ENV_TIME_NOTGRANTED 0x00002000 /* DB_TIME_NOTGRANTED set */
2154 #define DB_ENV_TXN_NOSYNC 0x00004000 /* DB_TXN_NOSYNC set */
2155 #define DB_ENV_TXN_NOWAIT 0x00008000 /* DB_TXN_NOWAIT set */
2156 #define DB_ENV_TXN_SNAPSHOT 0x00010000 /* DB_TXN_SNAPSHOT set */
2157 #define DB_ENV_TXN_WRITE_NOSYNC 0x00020000 /* DB_TXN_WRITE_NOSYNC set */
2158 #define DB_ENV_YIELDCPU 0x00040000 /* DB_YIELDCPU set */
2161 /* DB_ENV PUBLIC HANDLE LIST BEGIN */
2162 int (*add_data_dir) __P((DB_ENV *, const char *));
2163 int (*cdsgroup_begin) __P((DB_ENV *, DB_TXN **));
2164 int (*close) __P((DB_ENV *, u_int32_t));
2165 int (*dbremove) __P((DB_ENV *,
2166 DB_TXN *, const char *, const char *, u_int32_t));
2167 int (*dbrename) __P((DB_ENV *,
2168 DB_TXN *, const char *, const char *, const char *, u_int32_t));
2169 void (*err) __P((const DB_ENV *, int, const char *, ...));
2170 void (*errx) __P((const DB_ENV *, const char *, ...));
2171 int (*failchk) __P((DB_ENV *, u_int32_t));
2172 int (*fileid_reset) __P((DB_ENV *, const char *, u_int32_t));
2173 int (*get_alloc) __P((DB_ENV *, void *(**)(size_t),
2174 void *(**)(void *, size_t), void (**)(void *)));
2175 int (*get_app_dispatch)
2176 __P((DB_ENV *, int (**)(DB_ENV *, DBT *, DB_LSN *, db_recops)));
2177 int (*get_cache_max) __P((DB_ENV *, u_int32_t *, u_int32_t *));
2178 int (*get_cachesize) __P((DB_ENV *, u_int32_t *, u_int32_t *, int *));
2179 int (*get_create_dir) __P((DB_ENV *, const char **));
2180 int (*get_data_dirs) __P((DB_ENV *, const char ***));
2181 int (*get_encrypt_flags) __P((DB_ENV *, u_int32_t *));
2182 void (*get_errcall) __P((DB_ENV *,
2183 void (**)(const DB_ENV *, const char *, const char *)));
2184 void (*get_errfile) __P((DB_ENV *, FILE **));
2185 void (*get_errpfx) __P((DB_ENV *, const char **));
2186 int (*get_flags) __P((DB_ENV *, u_int32_t *));
2187 int (*get_feedback) __P((DB_ENV *, void (**)(DB_ENV *, int, int)));
2188 int (*get_home) __P((DB_ENV *, const char **));
2189 int (*get_intermediate_dir_mode) __P((DB_ENV *, const char **));
2190 int (*get_isalive) __P((DB_ENV *,
2191 int (**)(DB_ENV *, pid_t, db_threadid_t, u_int32_t)));
2192 int (*get_lg_bsize) __P((DB_ENV *, u_int32_t *));
2193 int (*get_lg_dir) __P((DB_ENV *, const char **));
2194 int (*get_lg_filemode) __P((DB_ENV *, int *));
2195 int (*get_lg_max) __P((DB_ENV *, u_int32_t *));
2196 int (*get_lg_regionmax) __P((DB_ENV *, u_int32_t *));
2197 int (*get_lk_conflicts) __P((DB_ENV *, const u_int8_t **, int *));
2198 int (*get_lk_detect) __P((DB_ENV *, u_int32_t *));
2199 int (*get_lk_max_lockers) __P((DB_ENV *, u_int32_t *));
2200 int (*get_lk_max_locks) __P((DB_ENV *, u_int32_t *));
2201 int (*get_lk_max_objects) __P((DB_ENV *, u_int32_t *));
2202 int (*get_lk_partitions) __P((DB_ENV *, u_int32_t *));
2203 int (*get_mp_max_openfd) __P((DB_ENV *, int *));
2204 int (*get_mp_max_write) __P((DB_ENV *, int *, db_timeout_t *));
2205 int (*get_mp_mmapsize) __P((DB_ENV *, size_t *));
2206 int (*get_mp_pagesize) __P((DB_ENV *, u_int32_t *));
2207 int (*get_mp_tablesize) __P((DB_ENV *, u_int32_t *));
2209 __P((DB_ENV *, void (**)(const DB_ENV *, const char *)));
2210 void (*get_msgfile) __P((DB_ENV *, FILE **));
2211 int (*get_open_flags) __P((DB_ENV *, u_int32_t *));
2212 int (*get_shm_key) __P((DB_ENV *, long *));
2213 int (*get_thread_count) __P((DB_ENV *, u_int32_t *));
2214 int (*get_thread_id_fn)
2215 __P((DB_ENV *, void (**)(DB_ENV *, pid_t *, db_threadid_t *)));
2216 int (*get_thread_id_string_fn) __P((DB_ENV *,
2217 char *(**)(DB_ENV *, pid_t, db_threadid_t, char *)));
2218 int (*get_timeout) __P((DB_ENV *, db_timeout_t *, u_int32_t));
2219 int (*get_tmp_dir) __P((DB_ENV *, const char **));
2220 int (*get_tx_max) __P((DB_ENV *, u_int32_t *));
2221 int (*get_tx_timestamp) __P((DB_ENV *, time_t *));
2222 int (*get_verbose) __P((DB_ENV *, u_int32_t, int *));
2223 int (*is_bigendian) __P((void));
2224 int (*lock_detect) __P((DB_ENV *, u_int32_t, u_int32_t, int *));
2225 int (*lock_get) __P((DB_ENV *,
2226 u_int32_t, u_int32_t, DBT *, db_lockmode_t, DB_LOCK *));
2227 int (*lock_id) __P((DB_ENV *, u_int32_t *));
2228 int (*lock_id_free) __P((DB_ENV *, u_int32_t));
2229 int (*lock_put) __P((DB_ENV *, DB_LOCK *));
2230 int (*lock_stat) __P((DB_ENV *, DB_LOCK_STAT **, u_int32_t));
2231 int (*lock_stat_print) __P((DB_ENV *, u_int32_t));
2232 int (*lock_vec) __P((DB_ENV *,
2233 u_int32_t, u_int32_t, DB_LOCKREQ *, int, DB_LOCKREQ **));
2234 int (*log_archive) __P((DB_ENV *, char **[], u_int32_t));
2235 int (*log_cursor) __P((DB_ENV *, DB_LOGC **, u_int32_t));
2236 int (*log_file) __P((DB_ENV *, const DB_LSN *, char *, size_t));
2237 int (*log_flush) __P((DB_ENV *, const DB_LSN *));
2238 int (*log_get_config) __P((DB_ENV *, u_int32_t, int *));
2239 int (*log_printf) __P((DB_ENV *, DB_TXN *, const char *, ...));
2240 int (*log_put) __P((DB_ENV *, DB_LSN *, const DBT *, u_int32_t));
2241 int (*log_set_config) __P((DB_ENV *, u_int32_t, int));
2242 int (*log_stat) __P((DB_ENV *, DB_LOG_STAT **, u_int32_t));
2243 int (*log_stat_print) __P((DB_ENV *, u_int32_t));
2244 int (*lsn_reset) __P((DB_ENV *, const char *, u_int32_t));
2245 int (*memp_fcreate) __P((DB_ENV *, DB_MPOOLFILE **, u_int32_t));
2246 int (*memp_register) __P((DB_ENV *, int, int (*)(DB_ENV *, db_pgno_t,
2247 void *, DBT *), int (*)(DB_ENV *, db_pgno_t, void *, DBT *)));
2248 int (*memp_stat) __P((DB_ENV *,
2249 DB_MPOOL_STAT **, DB_MPOOL_FSTAT ***, u_int32_t));
2250 int (*memp_stat_print) __P((DB_ENV *, u_int32_t));
2251 int (*memp_sync) __P((DB_ENV *, DB_LSN *));
2252 int (*memp_trickle) __P((DB_ENV *, int, int *));
2253 int (*mutex_alloc) __P((DB_ENV *, u_int32_t, db_mutex_t *));
2254 int (*mutex_free) __P((DB_ENV *, db_mutex_t));
2255 int (*mutex_get_align) __P((DB_ENV *, u_int32_t *));
2256 int (*mutex_get_increment) __P((DB_ENV *, u_int32_t *));
2257 int (*mutex_get_max) __P((DB_ENV *, u_int32_t *));
2258 int (*mutex_get_tas_spins) __P((DB_ENV *, u_int32_t *));
2259 int (*mutex_lock) __P((DB_ENV *, db_mutex_t));
2260 int (*mutex_set_align) __P((DB_ENV *, u_int32_t));
2261 int (*mutex_set_increment) __P((DB_ENV *, u_int32_t));
2262 int (*mutex_set_max) __P((DB_ENV *, u_int32_t));
2263 int (*mutex_set_tas_spins) __P((DB_ENV *, u_int32_t));
2264 int (*mutex_stat) __P((DB_ENV *, DB_MUTEX_STAT **, u_int32_t));
2265 int (*mutex_stat_print) __P((DB_ENV *, u_int32_t));
2266 int (*mutex_unlock) __P((DB_ENV *, db_mutex_t));
2267 int (*open) __P((DB_ENV *, const char *, u_int32_t, int));
2268 int (*remove) __P((DB_ENV *, const char *, u_int32_t));
2269 int (*rep_elect) __P((DB_ENV *, u_int32_t, u_int32_t, u_int32_t));
2270 int (*rep_flush) __P((DB_ENV *));
2271 int (*rep_get_clockskew) __P((DB_ENV *, u_int32_t *, u_int32_t *));
2272 int (*rep_get_config) __P((DB_ENV *, u_int32_t, int *));
2273 int (*rep_get_limit) __P((DB_ENV *, u_int32_t *, u_int32_t *));
2274 int (*rep_get_nsites) __P((DB_ENV *, u_int32_t *));
2275 int (*rep_get_priority) __P((DB_ENV *, u_int32_t *));
2276 int (*rep_get_request) __P((DB_ENV *, u_int32_t *, u_int32_t *));
2277 int (*rep_get_timeout) __P((DB_ENV *, int, u_int32_t *));
2278 int (*rep_process_message)
2279 __P((DB_ENV *, DBT *, DBT *, int, DB_LSN *));
2280 int (*rep_set_clockskew) __P((DB_ENV *, u_int32_t, u_int32_t));
2281 int (*rep_set_config) __P((DB_ENV *, u_int32_t, int));
2282 int (*rep_set_limit) __P((DB_ENV *, u_int32_t, u_int32_t));
2283 int (*rep_set_nsites) __P((DB_ENV *, u_int32_t));
2284 int (*rep_set_priority) __P((DB_ENV *, u_int32_t));
2285 int (*rep_set_request) __P((DB_ENV *, u_int32_t, u_int32_t));
2286 int (*rep_set_timeout) __P((DB_ENV *, int, db_timeout_t));
2287 int (*rep_set_transport) __P((DB_ENV *, int, int (*)(DB_ENV *,
2288 const DBT *, const DBT *, const DB_LSN *, int, u_int32_t)));
2289 int (*rep_start) __P((DB_ENV *, DBT *, u_int32_t));
2290 int (*rep_stat) __P((DB_ENV *, DB_REP_STAT **, u_int32_t));
2291 int (*rep_stat_print) __P((DB_ENV *, u_int32_t));
2292 int (*rep_sync) __P((DB_ENV *, u_int32_t));
2293 int (*repmgr_add_remote_site)
2294 __P((DB_ENV *, const char *, u_int, int *, u_int32_t));
2295 int (*repmgr_get_ack_policy) __P((DB_ENV *, int *));
2296 int (*repmgr_set_ack_policy) __P((DB_ENV *, int));
2297 int (*repmgr_set_local_site)
2298 __P((DB_ENV *, const char *, u_int, u_int32_t));
2299 int (*repmgr_site_list)
2300 __P((DB_ENV *, u_int *, DB_REPMGR_SITE **));
2301 int (*repmgr_start) __P((DB_ENV *, int, u_int32_t));
2302 int (*repmgr_stat) __P((DB_ENV *, DB_REPMGR_STAT **, u_int32_t));
2303 int (*repmgr_stat_print) __P((DB_ENV *, u_int32_t));
2304 int (*set_alloc) __P((DB_ENV *, void *(*)(size_t),
2305 void *(*)(void *, size_t), void (*)(void *)));
2306 int (*set_app_dispatch)
2307 __P((DB_ENV *, int (*)(DB_ENV *, DBT *, DB_LSN *, db_recops)));
2308 int (*set_cache_max) __P((DB_ENV *, u_int32_t, u_int32_t));
2309 int (*set_cachesize) __P((DB_ENV *, u_int32_t, u_int32_t, int));
2310 int (*set_create_dir) __P((DB_ENV *, const char *));
2311 int (*set_data_dir) __P((DB_ENV *, const char *));
2312 int (*set_encrypt) __P((DB_ENV *, const char *, u_int32_t));
2313 void (*set_errcall) __P((DB_ENV *,
2314 void (*)(const DB_ENV *, const char *, const char *)));
2315 void (*set_errfile) __P((DB_ENV *, FILE *));
2316 void (*set_errpfx) __P((DB_ENV *, const char *));
2317 int (*set_event_notify)
2318 __P((DB_ENV *, void (*)(DB_ENV *, u_int32_t, void *)));
2319 int (*set_feedback) __P((DB_ENV *, void (*)(DB_ENV *, int, int)));
2320 int (*set_flags) __P((DB_ENV *, u_int32_t, int));
2321 int (*set_intermediate_dir_mode) __P((DB_ENV *, const char *));
2322 int (*set_isalive) __P((DB_ENV *,
2323 int (*)(DB_ENV *, pid_t, db_threadid_t, u_int32_t)));
2324 int (*set_lg_bsize) __P((DB_ENV *, u_int32_t));
2325 int (*set_lg_dir) __P((DB_ENV *, const char *));
2326 int (*set_lg_filemode) __P((DB_ENV *, int));
2327 int (*set_lg_max) __P((DB_ENV *, u_int32_t));
2328 int (*set_lg_regionmax) __P((DB_ENV *, u_int32_t));
2329 int (*set_lk_conflicts) __P((DB_ENV *, u_int8_t *, int));
2330 int (*set_lk_detect) __P((DB_ENV *, u_int32_t));
2331 int (*set_lk_max_lockers) __P((DB_ENV *, u_int32_t));
2332 int (*set_lk_max_locks) __P((DB_ENV *, u_int32_t));
2333 int (*set_lk_max_objects) __P((DB_ENV *, u_int32_t));
2334 int (*set_lk_partitions) __P((DB_ENV *, u_int32_t));
2335 int (*set_mp_max_openfd) __P((DB_ENV *, int));
2336 int (*set_mp_max_write) __P((DB_ENV *, int, db_timeout_t));
2337 int (*set_mp_mmapsize) __P((DB_ENV *, size_t));
2338 int (*set_mp_pagesize) __P((DB_ENV *, u_int32_t));
2339 int (*set_mp_tablesize) __P((DB_ENV *, u_int32_t));
2341 __P((DB_ENV *, void (*)(const DB_ENV *, const char *)));
2342 void (*set_msgfile) __P((DB_ENV *, FILE *));
2343 int (*set_paniccall) __P((DB_ENV *, void (*)(DB_ENV *, int)));
2344 int (*set_rpc_server)
2345 __P((DB_ENV *, void *, const char *, long, long, u_int32_t));
2346 int (*set_shm_key) __P((DB_ENV *, long));
2347 int (*set_thread_count) __P((DB_ENV *, u_int32_t));
2348 int (*set_thread_id)
2349 __P((DB_ENV *, void (*)(DB_ENV *, pid_t *, db_threadid_t *)));
2350 int (*set_thread_id_string) __P((DB_ENV *,
2351 char *(*)(DB_ENV *, pid_t, db_threadid_t, char *)));
2352 int (*set_timeout) __P((DB_ENV *, db_timeout_t, u_int32_t));
2353 int (*set_tmp_dir) __P((DB_ENV *, const char *));
2354 int (*set_tx_max) __P((DB_ENV *, u_int32_t));
2355 int (*set_tx_timestamp) __P((DB_ENV *, time_t *));
2356 int (*set_verbose) __P((DB_ENV *, u_int32_t, int));
2357 int (*stat_print) __P((DB_ENV *, u_int32_t));
2358 int (*txn_begin) __P((DB_ENV *, DB_TXN *, DB_TXN **, u_int32_t));
2359 int (*txn_checkpoint) __P((DB_ENV *, u_int32_t, u_int32_t, u_int32_t));
2360 int (*txn_recover) __P((DB_ENV *,
2361 DB_PREPLIST *, u_int32_t, u_int32_t *, u_int32_t));
2362 int (*txn_stat) __P((DB_ENV *, DB_TXN_STAT **, u_int32_t));
2363 int (*txn_stat_print) __P((DB_ENV *, u_int32_t));
2364 /* DB_ENV PUBLIC HANDLE LIST END */
2366 /* DB_ENV PRIVATE HANDLE LIST BEGIN */
2367 int (*prdbt) __P((DBT *,
2368 int, const char *, void *, int (*)(void *, const void *), int));
2369 /* DB_ENV PRIVATE HANDLE LIST END */
2373 * Dispatch structure for recovery and print routines. Since internal and
2374 * external routines take different arguments (ENV versus DB_ENV), we need
2375 * something more elaborate than a single pointer and size.
2377 struct __db_distab {
2378 int (**int_dispatch) __P((ENV *, DBT *, DB_LSN *, db_recops, void *));
2380 int (**ext_dispatch) __P((DB_ENV *, DBT *, DB_LSN *, db_recops));
2384 #ifndef DB_DBM_HSEARCH
2385 #define DB_DBM_HSEARCH 0 /* No historic interfaces by default. */
2387 #if DB_DBM_HSEARCH != 0
2388 /*******************************************************
2389 * Dbm/Ndbm historic interfaces.
2390 *******************************************************/
2391 typedef struct __db DBM;
2393 #define DBM_INSERT 0 /* Flags to dbm_store(). */
2394 #define DBM_REPLACE 1
2397 * The DB support for ndbm(3) always appends this suffix to the
2398 * file name to avoid overwriting the user's original database.
2400 #define DBM_SUFFIX ".db"
2402 #if defined(_XPG4_2)
2415 * Translate NDBM calls into DB calls so that DB doesn't step on the
2416 * application's name space.
2418 #define dbm_clearerr(a) __db_ndbm_clearerr(a)
2419 #define dbm_close(a) __db_ndbm_close(a)
2420 #define dbm_delete(a, b) __db_ndbm_delete(a, b)
2421 #define dbm_dirfno(a) __db_ndbm_dirfno(a)
2422 #define dbm_error(a) __db_ndbm_error(a)
2423 #define dbm_fetch(a, b) __db_ndbm_fetch(a, b)
2424 #define dbm_firstkey(a) __db_ndbm_firstkey(a)
2425 #define dbm_nextkey(a) __db_ndbm_nextkey(a)
2426 #define dbm_open(a, b, c) __db_ndbm_open(a, b, c)
2427 #define dbm_pagfno(a) __db_ndbm_pagfno(a)
2428 #define dbm_rdonly(a) __db_ndbm_rdonly(a)
2429 #define dbm_store(a, b, c, d) \
2430 __db_ndbm_store(a, b, c, d)
2433 * Translate DBM calls into DB calls so that DB doesn't step on the
2434 * application's name space.
2436 * The global variables dbrdonly, dirf and pagf were not retained when 4BSD
2437 * replaced the dbm interface with ndbm, and are not supported here.
2439 #define dbminit(a) __db_dbm_init(a)
2440 #define dbmclose __db_dbm_close
2441 #if !defined(__cplusplus)
2442 #define delete(a) __db_dbm_delete(a)
2444 #define fetch(a) __db_dbm_fetch(a)
2445 #define firstkey __db_dbm_firstkey
2446 #define nextkey(a) __db_dbm_nextkey(a)
2447 #define store(a, b) __db_dbm_store(a, b)
2449 /*******************************************************
2450 * Hsearch historic interface.
2451 *******************************************************/
2456 typedef struct entry {
2461 #define hcreate(a) __db_hcreate(a)
2462 #define hdestroy __db_hdestroy
2463 #define hsearch(a, b) __db_hsearch(a, b)
2465 #endif /* DB_DBM_HSEARCH */
2467 #if defined(__cplusplus)
2471 /* Restore default compiler warnings */
2473 #pragma warning(pop)
2475 #endif /* !_DB_H_ */
2476 /* DO NOT EDIT: automatically built by dist/s_apiflags. */
2477 #define DB_AGGRESSIVE 0x00000001
2478 #define DB_ARCH_ABS 0x00000001
2479 #define DB_ARCH_DATA 0x00000002
2480 #define DB_ARCH_LOG 0x00000004
2481 #define DB_ARCH_REMOVE 0x00000008
2482 #define DB_AUTO_COMMIT 0x00000100
2483 #define DB_CDB_ALLDB 0x00000040
2484 #define DB_CHKSUM 0x00000008
2485 #define DB_CKP_INTERNAL 0x00000002
2486 #define DB_CREATE 0x00000001
2487 #define DB_CURSOR_BULK 0x00000001
2488 #define DB_CURSOR_TRANSIENT 0x00000004
2489 #define DB_CXX_NO_EXCEPTIONS 0x00000002
2490 #define DB_DIRECT 0x00000010
2491 #define DB_DIRECT_DB 0x00000080
2492 #define DB_DSYNC_DB 0x00000200
2493 #define DB_DUP 0x00000010
2494 #define DB_DUPSORT 0x00000004
2495 #define DB_DURABLE_UNKNOWN 0x00000020
2496 #define DB_ENCRYPT 0x00000001
2497 #define DB_ENCRYPT_AES 0x00000001
2498 #define DB_EXCL 0x00000040
2499 #define DB_EXTENT 0x00000040
2500 #define DB_FAILCHK 0x00000020
2501 #define DB_FAST_STAT 0x00000001
2502 #define DB_FCNTL_LOCKING 0x00000800
2503 #define DB_FLUSH 0x00000001
2504 #define DB_FORCE 0x00000001
2505 #define DB_FOREIGN_ABORT 0x00000001
2506 #define DB_FOREIGN_CASCADE 0x00000002
2507 #define DB_FOREIGN_NULLIFY 0x00000004
2508 #define DB_FREELIST_ONLY 0x00000001
2509 #define DB_FREE_SPACE 0x00000002
2510 #define DB_IGNORE_LEASE 0x00002000
2511 #define DB_IMMUTABLE_KEY 0x00000002
2512 #define DB_INIT_CDB 0x00000040
2513 #define DB_INIT_LOCK 0x00000080
2514 #define DB_INIT_LOG 0x00000100
2515 #define DB_INIT_MPOOL 0x00000200
2516 #define DB_INIT_REP 0x00000400
2517 #define DB_INIT_TXN 0x00000800
2518 #define DB_INORDER 0x00000020
2519 #define DB_JOIN_NOSORT 0x00000001
2520 #define DB_LOCKDOWN 0x00001000
2521 #define DB_LOCK_NOWAIT 0x00000001
2522 #define DB_LOCK_RECORD 0x00000002
2523 #define DB_LOCK_SET_TIMEOUT 0x00000004
2524 #define DB_LOCK_SWITCH 0x00000008
2525 #define DB_LOCK_UPGRADE 0x00000010
2526 #define DB_LOG_AUTO_REMOVE 0x00000001
2527 #define DB_LOG_CHKPNT 0x00000002
2528 #define DB_LOG_COMMIT 0x00000004
2529 #define DB_LOG_DIRECT 0x00000002
2530 #define DB_LOG_DSYNC 0x00000004
2531 #define DB_LOG_IN_MEMORY 0x00000008
2532 #define DB_LOG_NOCOPY 0x00000008
2533 #define DB_LOG_NOT_DURABLE 0x00000010
2534 #define DB_LOG_WRNOSYNC 0x00000020
2535 #define DB_LOG_ZERO 0x00000010
2536 #define DB_MPOOL_CREATE 0x00000001
2537 #define DB_MPOOL_DIRTY 0x00000002
2538 #define DB_MPOOL_DISCARD 0x00000001
2539 #define DB_MPOOL_EDIT 0x00000004
2540 #define DB_MPOOL_FREE 0x00000008
2541 #define DB_MPOOL_LAST 0x00000010
2542 #define DB_MPOOL_NEW 0x00000020
2543 #define DB_MPOOL_NOFILE 0x00000001
2544 #define DB_MPOOL_NOLOCK 0x00000002
2545 #define DB_MPOOL_TRY 0x00000040
2546 #define DB_MPOOL_UNLINK 0x00000002
2547 #define DB_MULTIPLE 0x00000800
2548 #define DB_MULTIPLE_KEY 0x00004000
2549 #define DB_MULTIVERSION 0x00000004
2550 #define DB_MUTEX_ALLOCATED 0x00000001
2551 #define DB_MUTEX_LOCKED 0x00000002
2552 #define DB_MUTEX_LOGICAL_LOCK 0x00000004
2553 #define DB_MUTEX_PROCESS_ONLY 0x00000008
2554 #define DB_MUTEX_SELF_BLOCK 0x00000010
2555 #define DB_MUTEX_SHARED 0x00000020
2556 #define DB_NOLOCKING 0x00000400
2557 #define DB_NOMMAP 0x00000008
2558 #define DB_NOORDERCHK 0x00000002
2559 #define DB_NOPANIC 0x00000800
2560 #define DB_NO_AUTO_COMMIT 0x00001000
2561 #define DB_ODDFILESIZE 0x00000080
2562 #define DB_ORDERCHKONLY 0x00000004
2563 #define DB_OVERWRITE 0x00001000
2564 #define DB_PANIC_ENVIRONMENT 0x00002000
2565 #define DB_PRINTABLE 0x00000008
2566 #define DB_PRIVATE 0x00002000
2567 #define DB_PR_PAGE 0x00000010
2568 #define DB_PR_RECOVERYTEST 0x00000020
2569 #define DB_RDONLY 0x00000400
2570 #define DB_RDWRMASTER 0x00002000
2571 #define DB_READ_COMMITTED 0x00000400
2572 #define DB_READ_UNCOMMITTED 0x00000200
2573 #define DB_RECNUM 0x00000040
2574 #define DB_RECOVER 0x00000002
2575 #define DB_RECOVER_FATAL 0x00004000
2576 #define DB_REGION_INIT 0x00004000
2577 #define DB_REGISTER 0x00008000
2578 #define DB_RENUMBER 0x00000080
2579 #define DB_REPMGR_CONF_2SITE_STRICT 0x00000001
2580 #define DB_REPMGR_PEER 0x00000001
2581 #define DB_REP_ANYWHERE 0x00000001
2582 #define DB_REP_CLIENT 0x00000001
2583 #define DB_REP_CONF_BULK 0x00000002
2584 #define DB_REP_CONF_DELAYCLIENT 0x00000004
2585 #define DB_REP_CONF_INMEM 0x00000008
2586 #define DB_REP_CONF_LEASE 0x00000010
2587 #define DB_REP_CONF_NOAUTOINIT 0x00000020
2588 #define DB_REP_CONF_NOWAIT 0x00000040
2589 #define DB_REP_ELECTION 0x00000004
2590 #define DB_REP_MASTER 0x00000002
2591 #define DB_REP_NOBUFFER 0x00000002
2592 #define DB_REP_PERMANENT 0x00000004
2593 #define DB_REP_REREQUEST 0x00000008
2594 #define DB_REVSPLITOFF 0x00000100
2595 #define DB_RMW 0x00001000
2596 #define DB_RPCCLIENT 0x00000001
2597 #define DB_SALVAGE 0x00000040
2598 #define DB_SA_SKIPFIRSTKEY 0x00000080
2599 #define DB_SA_UNKNOWNKEY 0x00000100
2600 #define DB_SEQ_DEC 0x00000001
2601 #define DB_SEQ_INC 0x00000002
2602 #define DB_SEQ_RANGE_SET 0x00000004
2603 #define DB_SEQ_WRAP 0x00000008
2604 #define DB_SEQ_WRAPPED 0x00000010
2605 #define DB_SET_LOCK_TIMEOUT 0x00000001
2606 #define DB_SET_REG_TIMEOUT 0x00000004
2607 #define DB_SET_TXN_NOW 0x00000008
2608 #define DB_SET_TXN_TIMEOUT 0x00000002
2609 #define DB_SHALLOW_DUP 0x00000100
2610 #define DB_SNAPSHOT 0x00000200
2611 #define DB_STAT_ALL 0x00000004
2612 #define DB_STAT_CLEAR 0x00000001
2613 #define DB_STAT_LOCK_CONF 0x00000008
2614 #define DB_STAT_LOCK_LOCKERS 0x00000010
2615 #define DB_STAT_LOCK_OBJECTS 0x00000020
2616 #define DB_STAT_LOCK_PARAMS 0x00000040
2617 #define DB_STAT_MEMP_HASH 0x00000008
2618 #define DB_STAT_MEMP_NOERROR 0x00000010
2619 #define DB_STAT_SUBSYSTEM 0x00000002
2620 #define DB_ST_DUPOK 0x00000200
2621 #define DB_ST_DUPSET 0x00000400
2622 #define DB_ST_DUPSORT 0x00000800
2623 #define DB_ST_IS_RECNO 0x00001000
2624 #define DB_ST_OVFL_LEAF 0x00002000
2625 #define DB_ST_RECNUM 0x00004000
2626 #define DB_ST_RELEN 0x00008000
2627 #define DB_ST_TOPLEVEL 0x00010000
2628 #define DB_SYSTEM_MEM 0x00010000
2629 #define DB_THREAD 0x00000010
2630 #define DB_TIME_NOTGRANTED 0x00008000
2631 #define DB_TRUNCATE 0x00004000
2632 #define DB_TXN_NOSYNC 0x00000001
2633 #define DB_TXN_NOT_DURABLE 0x00000002
2634 #define DB_TXN_NOWAIT 0x00000010
2635 #define DB_TXN_SNAPSHOT 0x00000002
2636 #define DB_TXN_SYNC 0x00000004
2637 #define DB_TXN_WAIT 0x00000008
2638 #define DB_TXN_WRITE_NOSYNC 0x00000020
2639 #define DB_UNREF 0x00020000
2640 #define DB_UPGRADE 0x00000001
2641 #define DB_USE_ENVIRON 0x00000004
2642 #define DB_USE_ENVIRON_ROOT 0x00000008
2643 #define DB_VERB_DEADLOCK 0x00000001
2644 #define DB_VERB_FILEOPS 0x00000002
2645 #define DB_VERB_FILEOPS_ALL 0x00000004
2646 #define DB_VERB_RECOVERY 0x00000008
2647 #define DB_VERB_REGISTER 0x00000010
2648 #define DB_VERB_REPLICATION 0x00000020
2649 #define DB_VERB_REPMGR_CONNFAIL 0x00000040
2650 #define DB_VERB_REPMGR_MISC 0x00000080
2651 #define DB_VERB_REP_ELECT 0x00000100
2652 #define DB_VERB_REP_LEASE 0x00000200
2653 #define DB_VERB_REP_MISC 0x00000400
2654 #define DB_VERB_REP_MSGS 0x00000800
2655 #define DB_VERB_REP_SYNC 0x00001000
2656 #define DB_VERB_REP_TEST 0x00002000
2657 #define DB_VERB_WAITSFOR 0x00004000
2658 #define DB_VERIFY 0x00000002
2659 #define DB_VERIFY_PARTITION 0x00040000
2660 #define DB_WRITECURSOR 0x00000008
2661 #define DB_WRITELOCK 0x00000010
2662 #define DB_WRITEOPEN 0x00008000
2663 #define DB_YIELDCPU 0x00010000
2665 /* DO NOT EDIT: automatically built by dist/s_include. */
2666 #ifndef _DB_EXT_PROT_IN_
2667 #define _DB_EXT_PROT_IN_
2669 #if defined(__cplusplus)
2673 int db_create __P((DB **, DB_ENV *, u_int32_t));
2674 char *db_strerror __P((int));
2675 int db_env_set_func_close __P((int (*)(int)));
2676 int db_env_set_func_dirfree __P((void (*)(char **, int)));
2677 int db_env_set_func_dirlist __P((int (*)(const char *, char ***, int *)));
2678 int db_env_set_func_exists __P((int (*)(const char *, int *)));
2679 int db_env_set_func_free __P((void (*)(void *)));
2680 int db_env_set_func_fsync __P((int (*)(int)));
2681 int db_env_set_func_ftruncate __P((int (*)(int, off_t)));
2682 int db_env_set_func_ioinfo __P((int (*)(const char *, int, u_int32_t *, u_int32_t *, u_int32_t *)));
2683 int db_env_set_func_malloc __P((void *(*)(size_t)));
2684 int db_env_set_func_file_map __P((int (*)(DB_ENV *, char *, size_t, int, void **), int (*)(DB_ENV *, void *)));
2685 int db_env_set_func_region_map __P((int (*)(DB_ENV *, char *, size_t, int *, void **), int (*)(DB_ENV *, void *)));
2686 int db_env_set_func_pread __P((ssize_t (*)(int, void *, size_t, off_t)));
2687 int db_env_set_func_pwrite __P((ssize_t (*)(int, const void *, size_t, off_t)));
2688 int db_env_set_func_open __P((int (*)(const char *, int, ...)));
2689 int db_env_set_func_read __P((ssize_t (*)(int, void *, size_t)));
2690 int db_env_set_func_realloc __P((void *(*)(void *, size_t)));
2691 int db_env_set_func_rename __P((int (*)(const char *, const char *)));
2692 int db_env_set_func_seek __P((int (*)(int, off_t, int)));
2693 int db_env_set_func_unlink __P((int (*)(const char *)));
2694 int db_env_set_func_write __P((ssize_t (*)(int, const void *, size_t)));
2695 int db_env_set_func_yield __P((int (*)(u_long, u_long)));
2696 int db_env_create __P((DB_ENV **, u_int32_t));
2697 char *db_version __P((int *, int *, int *));
2698 int log_compare __P((const DB_LSN *, const DB_LSN *));
2699 int db_sequence_create __P((DB_SEQUENCE **, DB *, u_int32_t));
2700 #if DB_DBM_HSEARCH != 0
2701 int __db_ndbm_clearerr __P((DBM *));
2702 void __db_ndbm_close __P((DBM *));
2703 int __db_ndbm_delete __P((DBM *, datum));
2704 int __db_ndbm_dirfno __P((DBM *));
2705 int __db_ndbm_error __P((DBM *));
2706 datum __db_ndbm_fetch __P((DBM *, datum));
2707 datum __db_ndbm_firstkey __P((DBM *));
2708 datum __db_ndbm_nextkey __P((DBM *));
2709 DBM *__db_ndbm_open __P((const char *, int, int));
2710 int __db_ndbm_pagfno __P((DBM *));
2711 int __db_ndbm_rdonly __P((DBM *));
2712 int __db_ndbm_store __P((DBM *, datum, datum, int));
2713 int __db_dbm_close __P((void));
2714 int __db_dbm_delete __P((datum));
2715 datum __db_dbm_fetch __P((datum));
2716 datum __db_dbm_firstkey __P((void));
2717 int __db_dbm_init __P((char *));
2718 datum __db_dbm_nextkey __P((datum));
2719 int __db_dbm_store __P((datum, datum));
2721 #if DB_DBM_HSEARCH != 0
2722 int __db_hcreate __P((size_t));
2723 ENTRY *__db_hsearch __P((ENTRY, ACTION));
2724 void __db_hdestroy __P((void));
2727 #if defined(__cplusplus)
2730 #endif /* !_DB_EXT_PROT_IN_ */