1/* DO NOT EDIT: automatically built by dist/s_brew. */ 2/* 3 * See the file LICENSE for redistribution information. 4 * 5 * Copyright (c) 1996,2008 Oracle. All rights reserved. 6 * 7 * $Id: db.in,v 12.193 2008/05/07 12:33:12 bschmeck Exp $ 8 * 9 * db.h include file layout: 10 * General. 11 * Database Environment. 12 * Locking subsystem. 13 * Logging subsystem. 14 * Shared buffer cache (mpool) subsystem. 15 * Transaction subsystem. 16 * Access methods. 17 * Access method cursors. 18 * Dbm/Ndbm, Hsearch historic interfaces. 19 */ 20 21#ifndef _DB_H_ 22#define _DB_H_ 23 24#include <AEEFile.h> 25 26#if defined(__cplusplus) 27extern "C" { 28#endif 29 30 31#undef __P 32#define __P(protos) protos 33 34/* 35 * Berkeley DB version information. 36 */ 37#define DB_VERSION_MAJOR 4 38#define DB_VERSION_MINOR 7 39#define DB_VERSION_PATCH 25 40#define DB_VERSION_STRING "Berkeley DB 4.7.25: (May 15, 2008)" 41 42/* 43 * !!! 44 * Berkeley DB uses specifically sized types. If they're not provided by 45 * the system, typedef them here. 46 * 47 * We protect them against multiple inclusion using __BIT_TYPES_DEFINED__, 48 * as does BIND and Kerberos, since we don't know for sure what #include 49 * files the user is using. 50 * 51 * !!! 52 * We also provide the standard u_int, u_long etc., if they're not provided 53 * by the system. 54 */ 55#ifndef __BIT_TYPES_DEFINED__ 56#define __BIT_TYPES_DEFINED__ 57typedef unsigned char u_int8_t; 58typedef short int16_t; 59typedef unsigned short u_int16_t; 60typedef int int32_t; 61typedef unsigned int u_int32_t; 62#endif 63 64typedef unsigned char u_char; 65typedef unsigned int u_int; 66typedef unsigned long u_long; 67typedef unsigned short u_short; 68 69/* 70 * Missing ANSI types. 71 * 72 * uintmax_t -- 73 * Largest unsigned type, used to align structures in memory. We don't store 74 * floating point types in structures, so integral types should be sufficient 75 * (and we don't have to worry about systems that store floats in other than 76 * power-of-2 numbers of bytes). Additionally this fixes compilers that rewrite 77 * structure assignments and ANSI C memcpy calls to be in-line instructions 78 * that happen to require alignment. 79 * 80 * uintptr_t -- 81 * Unsigned type that's the same size as a pointer. There are places where 82 * DB modifies pointers by discarding the bottom bits to guarantee alignment. 83 * We can't use uintmax_t, it may be larger than the pointer, and compilers 84 * get upset about that. So far we haven't run on any machine where there's 85 * no unsigned type the same size as a pointer -- here's hoping. 86 */ 87typedef unsigned long uintmax_t; 88typedef unsigned long uintptr_t; 89 90typedef IFile FILE; 91typedef u_int32_t off_t; 92typedef int pid_t; 93typedef unsigned int size_t; 94typedef int ssize_t; 95typedef long time_t; 96 97/* 98 * Sequences are only available on machines with 64-bit integral types. 99 */ 100typedef int32_t db_seq_t; 101 102/* Thread and process identification. */ 103typedef uintmax_t db_threadid_t; 104 105/* Basic types that are exported or quasi-exported. */ 106typedef u_int32_t db_pgno_t; /* Page number type. */ 107typedef u_int16_t db_indx_t; /* Page offset type. */ 108#define DB_MAX_PAGES 0xffffffff /* >= # of pages in a file */ 109 110typedef u_int32_t db_recno_t; /* Record number type. */ 111#define DB_MAX_RECORDS 0xffffffff /* >= # of records in a tree */ 112 113typedef u_int32_t db_timeout_t; /* Type of a timeout. */ 114 115/* 116 * Region offsets are the difference between a pointer in a region and the 117 * region's base address. With private environments, both addresses are the 118 * result of calling malloc, and we can't assume anything about what malloc 119 * will return, so region offsets have to be able to hold differences between 120 * arbitrary pointers. 121 */ 122typedef uintptr_t roff_t; 123 124/* 125 * Forward structure declarations, so we can declare pointers and 126 * applications can get type checking. 127 */ 128struct __db; typedef struct __db DB; 129struct __db_bt_stat; typedef struct __db_bt_stat DB_BTREE_STAT; 130struct __db_cipher; typedef struct __db_cipher DB_CIPHER; 131struct __db_compact; typedef struct __db_compact DB_COMPACT; 132struct __db_dbt; typedef struct __db_dbt DBT; 133struct __db_distab; typedef struct __db_distab DB_DISTAB; 134struct __db_env; typedef struct __db_env DB_ENV; 135struct __db_h_stat; typedef struct __db_h_stat DB_HASH_STAT; 136struct __db_ilock; typedef struct __db_ilock DB_LOCK_ILOCK; 137struct __db_lock_hstat; typedef struct __db_lock_hstat DB_LOCK_HSTAT; 138struct __db_lock_pstat; typedef struct __db_lock_pstat DB_LOCK_PSTAT; 139struct __db_lock_stat; typedef struct __db_lock_stat DB_LOCK_STAT; 140struct __db_lock_u; typedef struct __db_lock_u DB_LOCK; 141struct __db_locker; typedef struct __db_locker DB_LOCKER; 142struct __db_lockreq; typedef struct __db_lockreq DB_LOCKREQ; 143struct __db_locktab; typedef struct __db_locktab DB_LOCKTAB; 144struct __db_log; typedef struct __db_log DB_LOG; 145struct __db_log_cursor; typedef struct __db_log_cursor DB_LOGC; 146struct __db_log_stat; typedef struct __db_log_stat DB_LOG_STAT; 147struct __db_lsn; typedef struct __db_lsn DB_LSN; 148struct __db_mpool; typedef struct __db_mpool DB_MPOOL; 149struct __db_mpool_fstat;typedef struct __db_mpool_fstat DB_MPOOL_FSTAT; 150struct __db_mpool_stat; typedef struct __db_mpool_stat DB_MPOOL_STAT; 151struct __db_mpoolfile; typedef struct __db_mpoolfile DB_MPOOLFILE; 152struct __db_mutex_stat; typedef struct __db_mutex_stat DB_MUTEX_STAT; 153struct __db_mutex_t; typedef struct __db_mutex_t DB_MUTEX; 154struct __db_mutexmgr; typedef struct __db_mutexmgr DB_MUTEXMGR; 155struct __db_preplist; typedef struct __db_preplist DB_PREPLIST; 156struct __db_qam_stat; typedef struct __db_qam_stat DB_QUEUE_STAT; 157struct __db_rep; typedef struct __db_rep DB_REP; 158struct __db_rep_stat; typedef struct __db_rep_stat DB_REP_STAT; 159struct __db_repmgr_site;typedef struct __db_repmgr_site DB_REPMGR_SITE; 160struct __db_repmgr_stat;typedef struct __db_repmgr_stat DB_REPMGR_STAT; 161struct __db_seq_record; typedef struct __db_seq_record DB_SEQ_RECORD; 162struct __db_seq_stat; typedef struct __db_seq_stat DB_SEQUENCE_STAT; 163struct __db_sequence; typedef struct __db_sequence DB_SEQUENCE; 164struct __db_thread_info;typedef struct __db_thread_info DB_THREAD_INFO; 165struct __db_txn; typedef struct __db_txn DB_TXN; 166struct __db_txn_active; typedef struct __db_txn_active DB_TXN_ACTIVE; 167struct __db_txn_stat; typedef struct __db_txn_stat DB_TXN_STAT; 168struct __db_txnmgr; typedef struct __db_txnmgr DB_TXNMGR; 169struct __dbc; typedef struct __dbc DBC; 170struct __dbc_internal; typedef struct __dbc_internal DBC_INTERNAL; 171struct __env; typedef struct __env ENV; 172struct __fh_t; typedef struct __fh_t DB_FH; 173struct __fname; typedef struct __fname FNAME; 174struct __key_range; typedef struct __key_range DB_KEY_RANGE; 175struct __mpoolfile; typedef struct __mpoolfile MPOOLFILE; 176 177/* 178 * The Berkeley DB API flags are automatically-generated -- the following flag names are 179 * no longer used, but remain for compatibility reasons. 180 */ 181#define DB_DEGREE_2 DB_READ_COMMITTED 182#define DB_DIRTY_READ DB_READ_UNCOMMITTED 183#define DB_JOINENV 0x0 184 185/* Key/data structure -- a Data-Base Thang. */ 186struct __db_dbt { 187 void *data; /* Key/data */ 188 u_int32_t size; /* key/data length */ 189 190 u_int32_t ulen; /* RO: length of user buffer. */ 191 u_int32_t dlen; /* RO: get/put record length. */ 192 u_int32_t doff; /* RO: get/put record offset. */ 193 194 void *app_data; 195 196#define DB_DBT_APPMALLOC 0x001 /* Callback allocated memory. */ 197#define DB_DBT_DUPOK 0x002 /* Insert if duplicate. */ 198#define DB_DBT_ISSET 0x004 /* Lower level calls set value. */ 199#define DB_DBT_MALLOC 0x008 /* Return in malloc'd memory. */ 200#define DB_DBT_MULTIPLE 0x010 /* References multiple records. */ 201#define DB_DBT_PARTIAL 0x020 /* Partial put/get. */ 202#define DB_DBT_REALLOC 0x040 /* Return in realloc'd memory. */ 203#define DB_DBT_USERCOPY 0x080 /* Use the user-supplied callback. */ 204#define DB_DBT_USERMEM 0x100 /* Return in user's memory. */ 205 u_int32_t flags; 206}; 207 208/******************************************************* 209 * Mutexes. 210 *******************************************************/ 211typedef u_int32_t db_mutex_t; 212 213struct __db_mutex_stat { 214 /* The following fields are maintained in the region's copy. */ 215 u_int32_t st_mutex_align; /* Mutex alignment */ 216 u_int32_t st_mutex_tas_spins; /* Mutex test-and-set spins */ 217 u_int32_t st_mutex_cnt; /* Mutex count */ 218 u_int32_t st_mutex_free; /* Available mutexes */ 219 u_int32_t st_mutex_inuse; /* Mutexes in use */ 220 u_int32_t st_mutex_inuse_max; /* Maximum mutexes ever in use */ 221 222 /* The following fields are filled-in from other places. */ 223#ifndef __TEST_DB_NO_STATISTICS 224 u_int32_t st_region_wait; /* Region lock granted after wait. */ 225 u_int32_t st_region_nowait; /* Region lock granted without wait. */ 226 roff_t st_regsize; /* Region size. */ 227#endif 228}; 229 230/* This is the length of the buffer passed to DB_ENV->thread_id_string() */ 231#define DB_THREADID_STRLEN 128 232 233/******************************************************* 234 * Locking. 235 *******************************************************/ 236#define DB_LOCKVERSION 1 237 238#define DB_FILE_ID_LEN 20 /* Unique file ID length. */ 239 240/* 241 * Deadlock detector modes; used in the DB_ENV structure to configure the 242 * locking subsystem. 243 */ 244#define DB_LOCK_NORUN 0 245#define DB_LOCK_DEFAULT 1 /* Default policy. */ 246#define DB_LOCK_EXPIRE 2 /* Only expire locks, no detection. */ 247#define DB_LOCK_MAXLOCKS 3 /* Select locker with max locks. */ 248#define DB_LOCK_MAXWRITE 4 /* Select locker with max writelocks. */ 249#define DB_LOCK_MINLOCKS 5 /* Select locker with min locks. */ 250#define DB_LOCK_MINWRITE 6 /* Select locker with min writelocks. */ 251#define DB_LOCK_OLDEST 7 /* Select oldest locker. */ 252#define DB_LOCK_RANDOM 8 /* Select random locker. */ 253#define DB_LOCK_YOUNGEST 9 /* Select youngest locker. */ 254 255/* 256 * Simple R/W lock modes and for multi-granularity intention locking. 257 * 258 * !!! 259 * These values are NOT random, as they are used as an index into the lock 260 * conflicts arrays, i.e., DB_LOCK_IWRITE must be == 3, and DB_LOCK_IREAD 261 * must be == 4. 262 */ 263typedef enum { 264 DB_LOCK_NG=0, /* Not granted. */ 265 DB_LOCK_READ=1, /* Shared/read. */ 266 DB_LOCK_WRITE=2, /* Exclusive/write. */ 267 DB_LOCK_WAIT=3, /* Wait for event */ 268 DB_LOCK_IWRITE=4, /* Intent exclusive/write. */ 269 DB_LOCK_IREAD=5, /* Intent to share/read. */ 270 DB_LOCK_IWR=6, /* Intent to read and write. */ 271 DB_LOCK_READ_UNCOMMITTED=7, /* Degree 1 isolation. */ 272 DB_LOCK_WWRITE=8 /* Was Written. */ 273} db_lockmode_t; 274 275/* 276 * Request types. 277 */ 278typedef enum { 279 DB_LOCK_DUMP=0, /* Display held locks. */ 280 DB_LOCK_GET=1, /* Get the lock. */ 281 DB_LOCK_GET_TIMEOUT=2, /* Get lock with a timeout. */ 282 DB_LOCK_INHERIT=3, /* Pass locks to parent. */ 283 DB_LOCK_PUT=4, /* Release the lock. */ 284 DB_LOCK_PUT_ALL=5, /* Release locker's locks. */ 285 DB_LOCK_PUT_OBJ=6, /* Release locker's locks on obj. */ 286 DB_LOCK_PUT_READ=7, /* Release locker's read locks. */ 287 DB_LOCK_TIMEOUT=8, /* Force a txn to timeout. */ 288 DB_LOCK_TRADE=9, /* Trade locker ids on a lock. */ 289 DB_LOCK_UPGRADE_WRITE=10 /* Upgrade writes for dirty reads. */ 290} db_lockop_t; 291 292/* 293 * Status of a lock. 294 */ 295typedef enum { 296 DB_LSTAT_ABORTED=1, /* Lock belongs to an aborted txn. */ 297 DB_LSTAT_EXPIRED=2, /* Lock has expired. */ 298 DB_LSTAT_FREE=3, /* Lock is unallocated. */ 299 DB_LSTAT_HELD=4, /* Lock is currently held. */ 300 DB_LSTAT_PENDING=5, /* Lock was waiting and has been 301 * promoted; waiting for the owner 302 * to run and upgrade it to held. */ 303 DB_LSTAT_WAITING=6 /* Lock is on the wait queue. */ 304}db_status_t; 305 306/* Lock statistics structure. */ 307struct __db_lock_stat { 308 u_int32_t st_id; /* Last allocated locker ID. */ 309 u_int32_t st_cur_maxid; /* Current maximum unused ID. */ 310 u_int32_t st_maxlocks; /* Maximum number of locks in table. */ 311 u_int32_t st_maxlockers; /* Maximum num of lockers in table. */ 312 u_int32_t st_maxobjects; /* Maximum num of objects in table. */ 313 u_int32_t st_partitions; /* number of partitions. */ 314 int st_nmodes; /* Number of lock modes. */ 315 u_int32_t st_nlockers; /* Current number of lockers. */ 316#ifndef __TEST_DB_NO_STATISTICS 317 u_int32_t st_nlocks; /* Current number of locks. */ 318 u_int32_t st_maxnlocks; /* Maximum number of locks so far. */ 319 u_int32_t st_maxhlocks; /* Maximum number of locks in any bucket. */ 320 u_int32_t st_locksteals; /* Number of lock steals so far. */ 321 u_int32_t st_maxlsteals; /* Maximum number steals in any partition. */ 322 u_int32_t st_maxnlockers; /* Maximum number of lockers so far. */ 323 u_int32_t st_nobjects; /* Current number of objects. */ 324 u_int32_t st_maxnobjects; /* Maximum number of objects so far. */ 325 u_int32_t st_maxhobjects; /* Maximum number of objectsin any bucket. */ 326 u_int32_t st_objectsteals; /* Number of objects steals so far. */ 327 u_int32_t st_maxosteals; /* Maximum number of steals in any partition. */ 328 u_int32_t st_nrequests; /* Number of lock gets. */ 329 u_int32_t st_nreleases; /* Number of lock puts. */ 330 u_int32_t st_nupgrade; /* Number of lock upgrades. */ 331 u_int32_t st_ndowngrade; /* Number of lock downgrades. */ 332 u_int32_t st_lock_wait; /* Lock conflicts w/ subsequent wait */ 333 u_int32_t st_lock_nowait; /* Lock conflicts w/o subsequent wait */ 334 u_int32_t st_ndeadlocks; /* Number of lock deadlocks. */ 335 db_timeout_t st_locktimeout; /* Lock timeout. */ 336 u_int32_t st_nlocktimeouts; /* Number of lock timeouts. */ 337 db_timeout_t st_txntimeout; /* Transaction timeout. */ 338 u_int32_t st_ntxntimeouts; /* Number of transaction timeouts. */ 339 u_int32_t st_part_wait; /* Partition lock granted after wait. */ 340 u_int32_t st_part_nowait; /* Partition lock granted without wait. */ 341 u_int32_t st_part_max_wait; /* Max partition lock granted after wait. */ 342 u_int32_t st_part_max_nowait; /* Max partition lock granted without wait. */ 343 u_int32_t st_objs_wait; /* Object lock granted after wait. */ 344 u_int32_t st_objs_nowait; /* Object lock granted without wait. */ 345 u_int32_t st_lockers_wait; /* Locker lock granted after wait. */ 346 u_int32_t st_lockers_nowait; /* Locker lock granted without wait. */ 347 u_int32_t st_region_wait; /* Region lock granted after wait. */ 348 u_int32_t st_region_nowait; /* Region lock granted without wait. */ 349 u_int32_t st_hash_len; /* Max length of bucket. */ 350 roff_t st_regsize; /* Region size. */ 351#endif 352}; 353 354struct __db_lock_hstat { 355 u_int32_t st_nrequests; /* Number of lock gets. */ 356 u_int32_t st_nreleases; /* Number of lock puts. */ 357 u_int32_t st_nupgrade; /* Number of lock upgrades. */ 358 u_int32_t st_ndowngrade; /* Number of lock downgrades. */ 359 u_int32_t st_nlocks; /* Current number of locks. */ 360 u_int32_t st_maxnlocks; /* Maximum number of locks so far. */ 361 u_int32_t st_nobjects; /* Current number of objects. */ 362 u_int32_t st_maxnobjects; /* Maximum number of objects so far. */ 363 u_int32_t st_lock_wait; /* Lock conflicts w/ subsequent wait */ 364 u_int32_t st_lock_nowait; /* Lock conflicts w/o subsequent wait */ 365 u_int32_t st_nlocktimeouts; /* Number of lock timeouts. */ 366 u_int32_t st_ntxntimeouts; /* Number of transaction timeouts. */ 367 u_int32_t st_hash_len; /* Max length of bucket. */ 368}; 369 370struct __db_lock_pstat { 371 u_int32_t st_nlocks; /* Current number of locks. */ 372 u_int32_t st_maxnlocks; /* Maximum number of locks so far. */ 373 u_int32_t st_nobjects; /* Current number of objects. */ 374 u_int32_t st_maxnobjects; /* Maximum number of objects so far. */ 375 u_int32_t st_locksteals; /* Number of lock steals so far. */ 376 u_int32_t st_objectsteals; /* Number of objects steals so far. */ 377}; 378 379/* 380 * DB_LOCK_ILOCK -- 381 * Internal DB access method lock. 382 */ 383struct __db_ilock { 384 db_pgno_t pgno; /* Page being locked. */ 385 u_int8_t fileid[DB_FILE_ID_LEN];/* File id. */ 386#define DB_HANDLE_LOCK 1 387#define DB_RECORD_LOCK 2 388#define DB_PAGE_LOCK 3 389 u_int32_t type; /* Type of lock. */ 390}; 391 392/* 393 * DB_LOCK -- 394 * The structure is allocated by the caller and filled in during a 395 * lock_get request (or a lock_vec/DB_LOCK_GET). 396 */ 397struct __db_lock_u { 398 roff_t off; /* Offset of the lock in the region */ 399 u_int32_t ndx; /* Index of the object referenced by 400 * this lock; used for locking. */ 401 u_int32_t gen; /* Generation number of this lock. */ 402 db_lockmode_t mode; /* mode of this lock. */ 403}; 404 405/* Lock request structure. */ 406struct __db_lockreq { 407 db_lockop_t op; /* Operation. */ 408 db_lockmode_t mode; /* Requested mode. */ 409 db_timeout_t timeout; /* Time to expire lock. */ 410 DBT *obj; /* Object being locked. */ 411 DB_LOCK lock; /* Lock returned. */ 412}; 413 414/******************************************************* 415 * Logging. 416 *******************************************************/ 417#define DB_LOGVERSION 14 /* Current log version. */ 418#define DB_LOGOLDVER 8 /* Oldest log version supported. */ 419#define DB_LOGMAGIC 0x040988 420 421/* 422 * A DB_LSN has two parts, a fileid which identifies a specific file, and an 423 * offset within that file. The fileid is an unsigned 4-byte quantity that 424 * uniquely identifies a file within the log directory -- currently a simple 425 * counter inside the log. The offset is also an unsigned 4-byte value. The 426 * log manager guarantees the offset is never more than 4 bytes by switching 427 * to a new log file before the maximum length imposed by an unsigned 4-byte 428 * offset is reached. 429 */ 430struct __db_lsn { 431 u_int32_t file; /* File ID. */ 432 u_int32_t offset; /* File offset. */ 433}; 434 435/* 436 * Application-specified log record types start at DB_user_BEGIN, and must not 437 * equal or exceed DB_debug_FLAG. 438 * 439 * DB_debug_FLAG is the high-bit of the u_int32_t that specifies a log record 440 * type. If the flag is set, it's a log record that was logged for debugging 441 * purposes only, even if it reflects a database change -- the change was part 442 * of a non-durable transaction. 443 */ 444#define DB_user_BEGIN 10000 445#define DB_debug_FLAG 0x80000000 446 447/* 448 * DB_LOGC -- 449 * Log cursor. 450 */ 451struct __db_log_cursor { 452 ENV *env; /* Environment */ 453 454 DB_FH *fhp; /* File handle. */ 455 DB_LSN lsn; /* Cursor: LSN */ 456 u_int32_t len; /* Cursor: record length */ 457 u_int32_t prev; /* Cursor: previous record's offset */ 458 459 DBT dbt; /* Return DBT. */ 460 DB_LSN p_lsn; /* Persist LSN. */ 461 u_int32_t p_version; /* Persist version. */ 462 463 u_int8_t *bp; /* Allocated read buffer. */ 464 u_int32_t bp_size; /* Read buffer length in bytes. */ 465 u_int32_t bp_rlen; /* Read buffer valid data length. */ 466 DB_LSN bp_lsn; /* Read buffer first byte LSN. */ 467 468 u_int32_t bp_maxrec; /* Max record length in the log file. */ 469 470 /* DB_LOGC PUBLIC HANDLE LIST BEGIN */ 471 int (*close) __P((DB_LOGC *, u_int32_t)); 472 int (*get) __P((DB_LOGC *, DB_LSN *, DBT *, u_int32_t)); 473 int (*version) __P((DB_LOGC *, u_int32_t *, u_int32_t)); 474 /* DB_LOGC PUBLIC HANDLE LIST END */ 475 476#define DB_LOG_DISK 0x01 /* Log record came from disk. */ 477#define DB_LOG_LOCKED 0x02 /* Log region already locked */ 478#define DB_LOG_SILENT_ERR 0x04 /* Turn-off error messages. */ 479 u_int32_t flags; 480}; 481 482/* Log statistics structure. */ 483struct __db_log_stat { 484 u_int32_t st_magic; /* Log file magic number. */ 485 u_int32_t st_version; /* Log file version number. */ 486 int st_mode; /* Log file permissions mode. */ 487 u_int32_t st_lg_bsize; /* Log buffer size. */ 488 u_int32_t st_lg_size; /* Log file size. */ 489 u_int32_t st_wc_bytes; /* Bytes to log since checkpoint. */ 490 u_int32_t st_wc_mbytes; /* Megabytes to log since checkpoint. */ 491#ifndef __TEST_DB_NO_STATISTICS 492 u_int32_t st_record; /* Records entered into the log. */ 493 u_int32_t st_w_bytes; /* Bytes to log. */ 494 u_int32_t st_w_mbytes; /* Megabytes to log. */ 495 u_int32_t st_wcount; /* Total I/O writes to the log. */ 496 u_int32_t st_wcount_fill; /* Overflow writes to the log. */ 497 u_int32_t st_rcount; /* Total I/O reads from the log. */ 498 u_int32_t st_scount; /* Total syncs to the log. */ 499 u_int32_t st_region_wait; /* Region lock granted after wait. */ 500 u_int32_t st_region_nowait; /* Region lock granted without wait. */ 501 u_int32_t st_cur_file; /* Current log file number. */ 502 u_int32_t st_cur_offset; /* Current log file offset. */ 503 u_int32_t st_disk_file; /* Known on disk log file number. */ 504 u_int32_t st_disk_offset; /* Known on disk log file offset. */ 505 u_int32_t st_maxcommitperflush; /* Max number of commits in a flush. */ 506 u_int32_t st_mincommitperflush; /* Min number of commits in a flush. */ 507 roff_t st_regsize; /* Region size. */ 508#endif 509}; 510 511/* 512 * We need to record the first log record of a transaction. For user 513 * defined logging this macro returns the place to put that information, 514 * if it is need in rlsnp, otherwise it leaves it unchanged. We also 515 * need to track the last record of the transaction, this returns the 516 * place to put that info. 517 */ 518#define DB_SET_TXN_LSNP(txn, blsnp, llsnp) \ 519 ((txn)->set_txn_lsnp(txn, blsnp, llsnp)) 520 521/******************************************************* 522 * Shared buffer cache (mpool). 523 *******************************************************/ 524/* Priority values for DB_MPOOLFILE->{put,set_priority}. */ 525typedef enum { 526 DB_PRIORITY_UNCHANGED=0, 527 DB_PRIORITY_VERY_LOW=1, 528 DB_PRIORITY_LOW=2, 529 DB_PRIORITY_DEFAULT=3, 530 DB_PRIORITY_HIGH=4, 531 DB_PRIORITY_VERY_HIGH=5 532} DB_CACHE_PRIORITY; 533 534/* Per-process DB_MPOOLFILE information. */ 535struct __db_mpoolfile { 536 DB_FH *fhp; /* Underlying file handle. */ 537 538 /* 539 * !!! 540 * The ref, pinref and q fields are protected by the region lock. 541 */ 542 u_int32_t ref; /* Reference count. */ 543 544 u_int32_t pinref; /* Pinned block reference count. */ 545 546 /* 547 * !!! 548 * Explicit representations of structures from queue.h. 549 * TAILQ_ENTRY(__db_mpoolfile) q; 550 */ 551 struct { 552 struct __db_mpoolfile *tqe_next; 553 struct __db_mpoolfile **tqe_prev; 554 } q; /* Linked list of DB_MPOOLFILE's. */ 555 556 /* 557 * !!! 558 * The rest of the fields (with the exception of the MP_FLUSH flag) 559 * are not thread-protected, even when they may be modified at any 560 * time by the application. The reason is the DB_MPOOLFILE handle 561 * is single-threaded from the viewpoint of the application, and so 562 * the only fields needing to be thread-protected are those accessed 563 * by checkpoint or sync threads when using DB_MPOOLFILE structures 564 * to flush buffers from the cache. 565 */ 566 ENV *env; /* Environment */ 567 MPOOLFILE *mfp; /* Underlying MPOOLFILE. */ 568 569 u_int32_t clear_len; /* Cleared length on created pages. */ 570 u_int8_t /* Unique file ID. */ 571 fileid[DB_FILE_ID_LEN]; 572 int ftype; /* File type. */ 573 int32_t lsn_offset; /* LSN offset in page. */ 574 u_int32_t gbytes, bytes; /* Maximum file size. */ 575 DBT *pgcookie; /* Byte-string passed to pgin/pgout. */ 576 int32_t priority; /* Cache priority. */ 577 578 void *addr; /* Address of mmap'd region. */ 579 size_t len; /* Length of mmap'd region. */ 580 581 u_int32_t config_flags; /* Flags to DB_MPOOLFILE->set_flags. */ 582 583 /* DB_MPOOLFILE PUBLIC HANDLE LIST BEGIN */ 584 int (*close) __P((DB_MPOOLFILE *, u_int32_t)); 585 int (*get) 586 __P((DB_MPOOLFILE *, db_pgno_t *, DB_TXN *, u_int32_t, void *)); 587 int (*get_clear_len) __P((DB_MPOOLFILE *, u_int32_t *)); 588 int (*get_fileid) __P((DB_MPOOLFILE *, u_int8_t *)); 589 int (*get_flags) __P((DB_MPOOLFILE *, u_int32_t *)); 590 int (*get_ftype) __P((DB_MPOOLFILE *, int *)); 591 int (*get_last_pgno) __P((DB_MPOOLFILE *, db_pgno_t *)); 592 int (*get_lsn_offset) __P((DB_MPOOLFILE *, int32_t *)); 593 int (*get_maxsize) __P((DB_MPOOLFILE *, u_int32_t *, u_int32_t *)); 594 int (*get_pgcookie) __P((DB_MPOOLFILE *, DBT *)); 595 int (*get_priority) __P((DB_MPOOLFILE *, DB_CACHE_PRIORITY *)); 596 int (*open) __P((DB_MPOOLFILE *, const char *, u_int32_t, int, size_t)); 597 int (*put) __P((DB_MPOOLFILE *, void *, DB_CACHE_PRIORITY, u_int32_t)); 598 int (*set_clear_len) __P((DB_MPOOLFILE *, u_int32_t)); 599 int (*set_fileid) __P((DB_MPOOLFILE *, u_int8_t *)); 600 int (*set_flags) __P((DB_MPOOLFILE *, u_int32_t, int)); 601 int (*set_ftype) __P((DB_MPOOLFILE *, int)); 602 int (*set_lsn_offset) __P((DB_MPOOLFILE *, int32_t)); 603 int (*set_maxsize) __P((DB_MPOOLFILE *, u_int32_t, u_int32_t)); 604 int (*set_pgcookie) __P((DB_MPOOLFILE *, DBT *)); 605 int (*set_priority) __P((DB_MPOOLFILE *, DB_CACHE_PRIORITY)); 606 int (*sync) __P((DB_MPOOLFILE *)); 607 /* DB_MPOOLFILE PUBLIC HANDLE LIST END */ 608 609 /* 610 * MP_FILEID_SET, MP_OPEN_CALLED and MP_READONLY do not need to be 611 * thread protected because they are initialized before the file is 612 * linked onto the per-process lists, and never modified. 613 * 614 * MP_FLUSH is thread protected because it is potentially read/set by 615 * multiple threads of control. 616 */ 617#define MP_FILEID_SET 0x001 /* Application supplied a file ID. */ 618#define MP_FLUSH 0x002 /* Was opened to flush a buffer. */ 619#define MP_MULTIVERSION 0x004 /* Opened for multiversion access. */ 620#define MP_OPEN_CALLED 0x008 /* File opened. */ 621#define MP_READONLY 0x010 /* File is readonly. */ 622#define MP_DUMMY 0x020 /* File is dummy for __memp_fput. */ 623 u_int32_t flags; 624}; 625 626/* Mpool statistics structure. */ 627struct __db_mpool_stat { 628 u_int32_t st_gbytes; /* Total cache size: GB. */ 629 u_int32_t st_bytes; /* Total cache size: B. */ 630 u_int32_t st_ncache; /* Number of cache regions. */ 631 u_int32_t st_max_ncache; /* Maximum number of regions. */ 632 size_t st_mmapsize; /* Maximum file size for mmap. */ 633 int st_maxopenfd; /* Maximum number of open fd's. */ 634 int st_maxwrite; /* Maximum buffers to write. */ 635 db_timeout_t st_maxwrite_sleep; /* Sleep after writing max buffers. */ 636 u_int32_t st_pages; /* Total number of pages. */ 637#ifndef __TEST_DB_NO_STATISTICS 638 u_int32_t st_map; /* Pages from mapped files. */ 639 u_int32_t st_cache_hit; /* Pages found in the cache. */ 640 u_int32_t st_cache_miss; /* Pages not found in the cache. */ 641 u_int32_t st_page_create; /* Pages created in the cache. */ 642 u_int32_t st_page_in; /* Pages read in. */ 643 u_int32_t st_page_out; /* Pages written out. */ 644 u_int32_t st_ro_evict; /* Clean pages forced from the cache. */ 645 u_int32_t st_rw_evict; /* Dirty pages forced from the cache. */ 646 u_int32_t st_page_trickle; /* Pages written by memp_trickle. */ 647 u_int32_t st_page_clean; /* Clean pages. */ 648 u_int32_t st_page_dirty; /* Dirty pages. */ 649 u_int32_t st_hash_buckets; /* Number of hash buckets. */ 650 u_int32_t st_hash_searches; /* Total hash chain searches. */ 651 u_int32_t st_hash_longest; /* Longest hash chain searched. */ 652 u_int32_t st_hash_examined; /* Total hash entries searched. */ 653 u_int32_t st_hash_nowait; /* Hash lock granted with nowait. */ 654 u_int32_t st_hash_wait; /* Hash lock granted after wait. */ 655 u_int32_t st_hash_max_nowait; /* Max hash lock granted with nowait. */ 656 u_int32_t st_hash_max_wait; /* Max hash lock granted after wait. */ 657 u_int32_t st_region_nowait; /* Region lock granted with nowait. */ 658 u_int32_t st_region_wait; /* Region lock granted after wait. */ 659 u_int32_t st_mvcc_frozen; /* Buffers frozen. */ 660 u_int32_t st_mvcc_thawed; /* Buffers thawed. */ 661 u_int32_t st_mvcc_freed; /* Frozen buffers freed. */ 662 u_int32_t st_alloc; /* Number of page allocations. */ 663 u_int32_t st_alloc_buckets; /* Buckets checked during allocation. */ 664 u_int32_t st_alloc_max_buckets; /* Max checked during allocation. */ 665 u_int32_t st_alloc_pages; /* Pages checked during allocation. */ 666 u_int32_t st_alloc_max_pages; /* Max checked during allocation. */ 667 u_int32_t st_io_wait; /* Thread waited on buffer I/O. */ 668 roff_t st_regsize; /* Region size. */ 669#endif 670}; 671 672/* Mpool file statistics structure. */ 673struct __db_mpool_fstat { 674 char *file_name; /* File name. */ 675 u_int32_t st_pagesize; /* Page size. */ 676#ifndef __TEST_DB_NO_STATISTICS 677 u_int32_t st_map; /* Pages from mapped files. */ 678 u_int32_t st_cache_hit; /* Pages found in the cache. */ 679 u_int32_t st_cache_miss; /* Pages not found in the cache. */ 680 u_int32_t st_page_create; /* Pages created in the cache. */ 681 u_int32_t st_page_in; /* Pages read in. */ 682 u_int32_t st_page_out; /* Pages written out. */ 683#endif 684}; 685 686/******************************************************* 687 * Transactions and recovery. 688 *******************************************************/ 689#define DB_TXNVERSION 1 690 691typedef enum { 692 DB_TXN_ABORT=0, /* Public. */ 693 DB_TXN_APPLY=1, /* Public. */ 694 DB_TXN_BACKWARD_ROLL=3, /* Public. */ 695 DB_TXN_FORWARD_ROLL=4, /* Public. */ 696 DB_TXN_OPENFILES=5, /* Internal. */ 697 DB_TXN_POPENFILES=6, /* Internal. */ 698 DB_TXN_PRINT=7 /* Public. */ 699} db_recops; 700 701/* 702 * BACKWARD_ALLOC is used during the forward pass to pick up any aborted 703 * allocations for files that were created during the forward pass. 704 * The main difference between _ALLOC and _ROLL is that the entry for 705 * the file not exist during the rollforward pass. 706 */ 707#define DB_UNDO(op) ((op) == DB_TXN_ABORT || (op) == DB_TXN_BACKWARD_ROLL) 708#define DB_REDO(op) ((op) == DB_TXN_FORWARD_ROLL || (op) == DB_TXN_APPLY) 709 710struct __db_txn { 711 DB_TXNMGR *mgrp; /* Pointer to transaction manager. */ 712 DB_TXN *parent; /* Pointer to transaction's parent. */ 713 DB_THREAD_INFO *thread_info; /* Pointer to thread information. */ 714 715 u_int32_t txnid; /* Unique transaction id. */ 716 char *name; /* Transaction name. */ 717 DB_LOCKER *locker; /* Locker for this txn. */ 718 719 db_threadid_t tid; /* Thread id for use in MT XA. */ 720 void *td; /* Detail structure within region. */ 721 db_timeout_t lock_timeout; /* Timeout for locks for this txn. */ 722 db_timeout_t expire; /* Time transaction expires. */ 723 void *txn_list; /* Undo information for parent. */ 724 725 /* 726 * !!! 727 * Explicit representations of structures from queue.h. 728 * TAILQ_ENTRY(__db_txn) links; 729 * TAILQ_ENTRY(__db_txn) xalinks; 730 */ 731 struct { 732 struct __db_txn *tqe_next; 733 struct __db_txn **tqe_prev; 734 } links; /* Links transactions off manager. */ 735 struct { 736 struct __db_txn *tqe_next; 737 struct __db_txn **tqe_prev; 738 } xalinks; /* Links active XA transactions. */ 739 740 /* 741 * !!! 742 * Explicit representations of structures from queue.h. 743 * TAILQ_HEAD(__kids, __db_txn) kids; 744 */ 745 struct __kids { 746 struct __db_txn *tqh_first; 747 struct __db_txn **tqh_last; 748 } kids; 749 750 /* 751 * !!! 752 * Explicit representations of structures from queue.h. 753 * TAILQ_HEAD(__events, __txn_event) events; 754 */ 755 struct { 756 struct __txn_event *tqh_first; 757 struct __txn_event **tqh_last; 758 } events; /* Links deferred events. */ 759 760 /* 761 * !!! 762 * Explicit representations of structures from queue.h. 763 * STAILQ_HEAD(__logrec, __txn_logrec) logs; 764 */ 765 struct { 766 struct __txn_logrec *stqh_first; 767 struct __txn_logrec **stqh_last; 768 } logs; /* Links in memory log records. */ 769 770 /* 771 * !!! 772 * Explicit representations of structures from queue.h. 773 * TAILQ_ENTRY(__db_txn) klinks; 774 */ 775 struct { 776 struct __db_txn *tqe_next; 777 struct __db_txn **tqe_prev; 778 } klinks; 779 780 void *api_internal; /* C++ API private. */ 781 void *xml_internal; /* XML API private. */ 782 783 u_int32_t cursors; /* Number of cursors open for txn */ 784 785 /* DB_TXN PUBLIC HANDLE LIST BEGIN */ 786 int (*abort) __P((DB_TXN *)); 787 int (*commit) __P((DB_TXN *, u_int32_t)); 788 int (*discard) __P((DB_TXN *, u_int32_t)); 789 int (*get_name) __P((DB_TXN *, const char **)); 790 u_int32_t (*id) __P((DB_TXN *)); 791 int (*prepare) __P((DB_TXN *, u_int8_t *)); 792 int (*set_name) __P((DB_TXN *, const char *)); 793 int (*set_timeout) __P((DB_TXN *, db_timeout_t, u_int32_t)); 794 /* DB_TXN PUBLIC HANDLE LIST END */ 795 796 /* DB_TXN PRIVATE HANDLE LIST BEGIN */ 797 void (*set_txn_lsnp) __P((DB_TXN *txn, DB_LSN **, DB_LSN **)); 798 /* DB_TXN PRIVATE HANDLE LIST END */ 799 800#define TXN_CHILDCOMMIT 0x0001 /* Txn has committed. */ 801#define TXN_CDSGROUP 0x0002 /* CDS group handle. */ 802#define TXN_COMPENSATE 0x0004 /* Compensating transaction. */ 803#define TXN_DEADLOCK 0x0008 /* Txn has deadlocked. */ 804#define TXN_LOCKTIMEOUT 0x0010 /* Txn has a lock timeout. */ 805#define TXN_MALLOC 0x0020 /* Structure allocated by TXN system. */ 806#define TXN_NOSYNC 0x0040 /* Do not sync on prepare and commit. */ 807#define TXN_NOWAIT 0x0080 /* Do not wait on locks. */ 808#define TXN_PRIVATE 0x0100 /* Txn owned by cursor.. */ 809#define TXN_READ_COMMITTED 0x0200 /* Txn has degree 2 isolation. */ 810#define TXN_READ_UNCOMMITTED 0x0400 /* Txn has degree 1 isolation. */ 811#define TXN_RESTORED 0x0800 /* Txn has been restored. */ 812#define TXN_SNAPSHOT 0x1000 /* Snapshot Isolation. */ 813#define TXN_SYNC 0x2000 /* Write and sync on prepare/commit. */ 814#define TXN_WRITE_NOSYNC 0x4000 /* Write only on prepare/commit. */ 815 u_int32_t flags; 816}; 817 818#define TXN_SYNC_FLAGS (TXN_SYNC | TXN_NOSYNC | TXN_WRITE_NOSYNC) 819 820/* 821 * Structure used for two phase commit interface. Berkeley DB support for two 822 * phase commit is compatible with the X/Open XA interface. 823 * 824 * The XA #define XIDDATASIZE defines the size of a global transaction ID. We 825 * have our own version here (for name space reasons) which must have the same 826 * value. 827 */ 828#define DB_XIDDATASIZE 128 829struct __db_preplist { 830 DB_TXN *txn; 831 u_int8_t gid[DB_XIDDATASIZE]; 832}; 833 834/* Transaction statistics structure. */ 835struct __db_txn_active { 836 u_int32_t txnid; /* Transaction ID */ 837 u_int32_t parentid; /* Transaction ID of parent */ 838 pid_t pid; /* Process owning txn ID */ 839 db_threadid_t tid; /* Thread owning txn ID */ 840 841 DB_LSN lsn; /* LSN when transaction began */ 842 843 DB_LSN read_lsn; /* Read LSN for MVCC */ 844 u_int32_t mvcc_ref; /* MVCC reference count */ 845 846#define TXN_ABORTED 1 847#define TXN_COMMITTED 2 848#define TXN_PREPARED 3 849#define TXN_RUNNING 4 850 u_int32_t status; /* Status of the transaction */ 851 852#define TXN_XA_ABORTED 1 853#define TXN_XA_DEADLOCKED 2 854#define TXN_XA_ENDED 3 855#define TXN_XA_PREPARED 4 856#define TXN_XA_STARTED 5 857#define TXN_XA_SUSPENDED 6 858 u_int32_t xa_status; /* XA status */ 859 860 u_int8_t xid[DB_XIDDATASIZE]; /* Global transaction ID */ 861 char name[51]; /* 50 bytes of name, nul termination */ 862}; 863 864struct __db_txn_stat { 865 u_int32_t st_nrestores; /* number of restored transactions 866 after recovery. */ 867#ifndef __TEST_DB_NO_STATISTICS 868 DB_LSN st_last_ckp; /* lsn of the last checkpoint */ 869 time_t st_time_ckp; /* time of last checkpoint */ 870 u_int32_t st_last_txnid; /* last transaction id given out */ 871 u_int32_t st_maxtxns; /* maximum txns possible */ 872 u_int32_t st_naborts; /* number of aborted transactions */ 873 u_int32_t st_nbegins; /* number of begun transactions */ 874 u_int32_t st_ncommits; /* number of committed transactions */ 875 u_int32_t st_nactive; /* number of active transactions */ 876 u_int32_t st_nsnapshot; /* number of snapshot transactions */ 877 u_int32_t st_maxnactive; /* maximum active transactions */ 878 u_int32_t st_maxnsnapshot; /* maximum snapshot transactions */ 879 DB_TXN_ACTIVE *st_txnarray; /* array of active transactions */ 880 u_int32_t st_region_wait; /* Region lock granted after wait. */ 881 u_int32_t st_region_nowait; /* Region lock granted without wait. */ 882 roff_t st_regsize; /* Region size. */ 883#endif 884}; 885 886/******************************************************* 887 * Replication. 888 *******************************************************/ 889/* Special, out-of-band environment IDs. */ 890#define DB_EID_BROADCAST -1 891#define DB_EID_INVALID -2 892 893#define DB_REP_DEFAULT_PRIORITY 100 894 895/* Acknowledgement policies. */ 896#define DB_REPMGR_ACKS_ALL 1 897#define DB_REPMGR_ACKS_ALL_PEERS 2 898#define DB_REPMGR_ACKS_NONE 3 899#define DB_REPMGR_ACKS_ONE 4 900#define DB_REPMGR_ACKS_ONE_PEER 5 901#define DB_REPMGR_ACKS_QUORUM 6 902 903/* Replication timeout configuration values. */ 904#define DB_REP_ACK_TIMEOUT 1 /* RepMgr acknowledgements. */ 905#define DB_REP_CHECKPOINT_DELAY 2 /* Master checkpoint delay. */ 906#define DB_REP_CONNECTION_RETRY 3 /* RepMgr connections. */ 907#define DB_REP_ELECTION_RETRY 4 /* RepMgr elect retries. */ 908#define DB_REP_ELECTION_TIMEOUT 5 /* Rep normal elections. */ 909#define DB_REP_FULL_ELECTION_TIMEOUT 6 /* Rep full elections. */ 910#define DB_REP_HEARTBEAT_MONITOR 7 /* RepMgr client HB monitor. */ 911#define DB_REP_HEARTBEAT_SEND 8 /* RepMgr master send freq. */ 912#define DB_REP_LEASE_TIMEOUT 9 /* Master leases. */ 913 914/* Event notification types. */ 915#define DB_EVENT_NO_SUCH_EVENT 0 /* out-of-band sentinel value */ 916#define DB_EVENT_PANIC 1 917#define DB_EVENT_REP_CLIENT 2 918#define DB_EVENT_REP_ELECTED 3 919#define DB_EVENT_REP_MASTER 4 920#define DB_EVENT_REP_NEWMASTER 5 921#define DB_EVENT_REP_PERM_FAILED 6 922#define DB_EVENT_REP_STARTUPDONE 7 923#define DB_EVENT_WRITE_FAILED 8 924 925/* Replication Manager site status. */ 926struct __db_repmgr_site { 927 int eid; 928 char *host; 929 u_int port; 930 931#define DB_REPMGR_CONNECTED 0x01 932#define DB_REPMGR_DISCONNECTED 0x02 933 u_int32_t status; 934}; 935 936/* Replication statistics. */ 937struct __db_rep_stat { 938 /* !!! 939 * Many replication statistics fields cannot be protected by a mutex 940 * without an unacceptable performance penalty, since most message 941 * processing is done without the need to hold a region-wide lock. 942 * Fields whose comments end with a '+' may be updated without holding 943 * the replication or log mutexes (as appropriate), and thus may be 944 * off somewhat (or, on unreasonable architectures under unlucky 945 * circumstances, garbaged). 946 */ 947 u_int32_t st_log_queued; /* Log records currently queued.+ */ 948 u_int32_t st_startup_complete; /* Site completed client sync-up. */ 949#ifndef __TEST_DB_NO_STATISTICS 950 u_int32_t st_status; /* Current replication status. */ 951 DB_LSN st_next_lsn; /* Next LSN to use or expect. */ 952 DB_LSN st_waiting_lsn; /* LSN we're awaiting, if any. */ 953 DB_LSN st_max_perm_lsn; /* Maximum permanent LSN. */ 954 db_pgno_t st_next_pg; /* Next pg we expect. */ 955 db_pgno_t st_waiting_pg; /* pg we're awaiting, if any. */ 956 957 u_int32_t st_dupmasters; /* # of times a duplicate master 958 condition was detected.+ */ 959 int st_env_id; /* Current environment ID. */ 960 u_int32_t st_env_priority; /* Current environment priority. */ 961 u_int32_t st_bulk_fills; /* Bulk buffer fills. */ 962 u_int32_t st_bulk_overflows; /* Bulk buffer overflows. */ 963 u_int32_t st_bulk_records; /* Bulk records stored. */ 964 u_int32_t st_bulk_transfers; /* Transfers of bulk buffers. */ 965 u_int32_t st_client_rerequests; /* Number of forced rerequests. */ 966 u_int32_t st_client_svc_req; /* Number of client service requests 967 received by this client. */ 968 u_int32_t st_client_svc_miss; /* Number of client service requests 969 missing on this client. */ 970 u_int32_t st_gen; /* Current generation number. */ 971 u_int32_t st_egen; /* Current election gen number. */ 972 u_int32_t st_log_duplicated; /* Log records received multiply.+ */ 973 u_int32_t st_log_queued_max; /* Max. log records queued at once.+ */ 974 u_int32_t st_log_queued_total; /* Total # of log recs. ever queued.+ */ 975 u_int32_t st_log_records; /* Log records received and put.+ */ 976 u_int32_t st_log_requested; /* Log recs. missed and requested.+ */ 977 int st_master; /* Env. ID of the current master. */ 978 u_int32_t st_master_changes; /* # of times we've switched masters. */ 979 u_int32_t st_msgs_badgen; /* Messages with a bad generation #.+ */ 980 u_int32_t st_msgs_processed; /* Messages received and processed.+ */ 981 u_int32_t st_msgs_recover; /* Messages ignored because this site 982 was a client in recovery.+ */ 983 u_int32_t st_msgs_send_failures;/* # of failed message sends.+ */ 984 u_int32_t st_msgs_sent; /* # of successful message sends.+ */ 985 u_int32_t st_newsites; /* # of NEWSITE msgs. received.+ */ 986 u_int32_t st_nsites; /* Current number of sites we will 987 assume during elections. */ 988 u_int32_t st_nthrottles; /* # of times we were throttled. */ 989 u_int32_t st_outdated; /* # of times we detected and returned 990 an OUTDATED condition.+ */ 991 u_int32_t st_pg_duplicated; /* Pages received multiply.+ */ 992 u_int32_t st_pg_records; /* Pages received and stored.+ */ 993 u_int32_t st_pg_requested; /* Pages missed and requested.+ */ 994 u_int32_t st_txns_applied; /* # of transactions applied.+ */ 995 u_int32_t st_startsync_delayed; /* # of STARTSYNC msgs delayed.+ */ 996 997 /* Elections generally. */ 998 u_int32_t st_elections; /* # of elections held.+ */ 999 u_int32_t st_elections_won; /* # of elections won by this site.+ */ 1000 1001 /* Statistics about an in-progress election. */ 1002 int st_election_cur_winner; /* Current front-runner. */ 1003 u_int32_t st_election_gen; /* Election generation number. */ 1004 DB_LSN st_election_lsn; /* Max. LSN of current winner. */ 1005 u_int32_t st_election_nsites; /* # of "registered voters". */ 1006 u_int32_t st_election_nvotes; /* # of "registered voters" needed. */ 1007 u_int32_t st_election_priority; /* Current election priority. */ 1008 int st_election_status; /* Current election status. */ 1009 u_int32_t st_election_tiebreaker;/* Election tiebreaker value. */ 1010 u_int32_t st_election_votes; /* Votes received in this round. */ 1011 u_int32_t st_election_sec; /* Last election time seconds. */ 1012 u_int32_t st_election_usec; /* Last election time useconds. */ 1013 u_int32_t st_max_lease_sec; /* Maximum lease timestamp seconds. */ 1014 u_int32_t st_max_lease_usec; /* Maximum lease timestamp useconds. */ 1015#endif 1016}; 1017 1018/* Replication Manager statistics. */ 1019struct __db_repmgr_stat { 1020 u_int32_t st_perm_failed; /* # of insufficiently ack'ed msgs. */ 1021 u_int32_t st_msgs_queued; /* # msgs queued for network delay. */ 1022 u_int32_t st_msgs_dropped; /* # msgs discarded due to excessive 1023 queue length. */ 1024 u_int32_t st_connection_drop; /* Existing connections dropped. */ 1025 u_int32_t st_connect_fail; /* Failed new connection attempts. */ 1026}; 1027 1028/******************************************************* 1029 * Sequences. 1030 *******************************************************/ 1031/* 1032 * The storage record for a sequence. 1033 */ 1034struct __db_seq_record { 1035 u_int32_t seq_version; /* Version size/number. */ 1036 u_int32_t flags; /* DB_SEQ_XXX Flags. */ 1037 db_seq_t seq_value; /* Current value. */ 1038 db_seq_t seq_max; /* Max permitted. */ 1039 db_seq_t seq_min; /* Min permitted. */ 1040}; 1041 1042/* 1043 * Handle for a sequence object. 1044 */ 1045struct __db_sequence { 1046 DB *seq_dbp; /* DB handle for this sequence. */ 1047 db_mutex_t mtx_seq; /* Mutex if sequence is threaded. */ 1048 DB_SEQ_RECORD *seq_rp; /* Pointer to current data. */ 1049 DB_SEQ_RECORD seq_record; /* Data from DB_SEQUENCE. */ 1050 int32_t seq_cache_size; /* Number of values cached. */ 1051 db_seq_t seq_last_value; /* Last value cached. */ 1052 DBT seq_key; /* DBT pointing to sequence key. */ 1053 DBT seq_data; /* DBT pointing to seq_record. */ 1054 1055 /* API-private structure: used by C++ and Java. */ 1056 void *api_internal; 1057 1058 /* DB_SEQUENCE PUBLIC HANDLE LIST BEGIN */ 1059 int (*close) __P((DB_SEQUENCE *, u_int32_t)); 1060 int (*get) __P((DB_SEQUENCE *, 1061 DB_TXN *, int32_t, db_seq_t *, u_int32_t)); 1062 int (*get_cachesize) __P((DB_SEQUENCE *, int32_t *)); 1063 int (*get_db) __P((DB_SEQUENCE *, DB **)); 1064 int (*get_flags) __P((DB_SEQUENCE *, u_int32_t *)); 1065 int (*get_key) __P((DB_SEQUENCE *, DBT *)); 1066 int (*get_range) __P((DB_SEQUENCE *, 1067 db_seq_t *, db_seq_t *)); 1068 int (*initial_value) __P((DB_SEQUENCE *, db_seq_t)); 1069 int (*open) __P((DB_SEQUENCE *, 1070 DB_TXN *, DBT *, u_int32_t)); 1071 int (*remove) __P((DB_SEQUENCE *, DB_TXN *, u_int32_t)); 1072 int (*set_cachesize) __P((DB_SEQUENCE *, int32_t)); 1073 int (*set_flags) __P((DB_SEQUENCE *, u_int32_t)); 1074 int (*set_range) __P((DB_SEQUENCE *, db_seq_t, db_seq_t)); 1075 int (*stat) __P((DB_SEQUENCE *, 1076 DB_SEQUENCE_STAT **, u_int32_t)); 1077 int (*stat_print) __P((DB_SEQUENCE *, u_int32_t)); 1078 /* DB_SEQUENCE PUBLIC HANDLE LIST END */ 1079}; 1080 1081struct __db_seq_stat { 1082 u_int32_t st_wait; /* Sequence lock granted w/o wait. */ 1083 u_int32_t st_nowait; /* Sequence lock granted after wait. */ 1084 db_seq_t st_current; /* Current value in db. */ 1085 db_seq_t st_value; /* Current cached value. */ 1086 db_seq_t st_last_value; /* Last cached value. */ 1087 db_seq_t st_min; /* Minimum value. */ 1088 db_seq_t st_max; /* Maximum value. */ 1089 int32_t st_cache_size; /* Cache size. */ 1090 u_int32_t st_flags; /* Flag value. */ 1091}; 1092 1093/******************************************************* 1094 * Access methods. 1095 *******************************************************/ 1096typedef enum { 1097 DB_BTREE=1, 1098 DB_HASH=2, 1099 DB_RECNO=3, 1100 DB_QUEUE=4, 1101 DB_UNKNOWN=5 /* Figure it out on open. */ 1102} DBTYPE; 1103 1104#define DB_RENAMEMAGIC 0x030800 /* File has been renamed. */ 1105 1106#define DB_BTREEVERSION 9 /* Current btree version. */ 1107#define DB_BTREEOLDVER 8 /* Oldest btree version supported. */ 1108#define DB_BTREEMAGIC 0x053162 1109 1110#define DB_HASHVERSION 9 /* Current hash version. */ 1111#define DB_HASHOLDVER 7 /* Oldest hash version supported. */ 1112#define DB_HASHMAGIC 0x061561 1113 1114#define DB_QAMVERSION 4 /* Current queue version. */ 1115#define DB_QAMOLDVER 3 /* Oldest queue version supported. */ 1116#define DB_QAMMAGIC 0x042253 1117 1118#define DB_SEQUENCE_VERSION 2 /* Current sequence version. */ 1119#define DB_SEQUENCE_OLDVER 1 /* Oldest sequence version supported. */ 1120 1121/* 1122 * DB access method and cursor operation values. Each value is an operation 1123 * code to which additional bit flags are added. 1124 */ 1125#define DB_AFTER 1 /* Dbc.put */ 1126#define DB_APPEND 2 /* Db.put */ 1127#define DB_BEFORE 3 /* Dbc.put */ 1128#define DB_CONSUME 4 /* Db.get */ 1129#define DB_CONSUME_WAIT 5 /* Db.get */ 1130#define DB_CURRENT 6 /* Dbc.get, Dbc.put, DbLogc.get */ 1131#define DB_FIRST 7 /* Dbc.get, DbLogc->get */ 1132#define DB_GET_BOTH 8 /* Db.get, Dbc.get */ 1133#define DB_GET_BOTHC 9 /* Dbc.get (internal) */ 1134#define DB_GET_BOTH_RANGE 10 /* Db.get, Dbc.get */ 1135#define DB_GET_RECNO 11 /* Dbc.get */ 1136#define DB_JOIN_ITEM 12 /* Dbc.get; don't do primary lookup */ 1137#define DB_KEYFIRST 13 /* Dbc.put */ 1138#define DB_KEYLAST 14 /* Dbc.put */ 1139#define DB_LAST 15 /* Dbc.get, DbLogc->get */ 1140#define DB_NEXT 16 /* Dbc.get, DbLogc->get */ 1141#define DB_NEXT_DUP 17 /* Dbc.get */ 1142#define DB_NEXT_NODUP 18 /* Dbc.get */ 1143#define DB_NODUPDATA 19 /* Db.put, Dbc.put */ 1144#define DB_NOOVERWRITE 20 /* Db.put */ 1145#define DB_NOSYNC 21 /* Db.close */ 1146#define DB_POSITION 22 /* Dbc.dup */ 1147#define DB_PREV 23 /* Dbc.get, DbLogc->get */ 1148#define DB_PREV_DUP 24 /* Dbc.get */ 1149#define DB_PREV_NODUP 25 /* Dbc.get */ 1150#define DB_SET 26 /* Dbc.get, DbLogc->get */ 1151#define DB_SET_RANGE 27 /* Dbc.get */ 1152#define DB_SET_RECNO 28 /* Db.get, Dbc.get */ 1153#define DB_UPDATE_SECONDARY 29 /* Dbc.get, Dbc.del (internal) */ 1154#define DB_WRITECURSOR 30 /* Db.cursor */ 1155#define DB_WRITELOCK 31 /* Db.cursor (internal) */ 1156 1157/* This has to change when the max opcode hits 255. */ 1158#define DB_OPFLAGS_MASK 0x000000ff /* Mask for operations flags. */ 1159 1160/* 1161 * DB (user visible) error return codes. 1162 * 1163 * !!! 1164 * We don't want our error returns to conflict with other packages where 1165 * possible, so pick a base error value that's hopefully not common. We 1166 * document that we own the error name space from -30,800 to -30,999. 1167 */ 1168/* DB (public) error return codes. */ 1169#define DB_BUFFER_SMALL (-30999)/* User memory too small for return. */ 1170#define DB_DONOTINDEX (-30998)/* "Null" return from 2ndary callbk. */ 1171#define DB_FOREIGN_CONFLICT (-30997)/* A foreign db constraint triggered. */ 1172#define DB_KEYEMPTY (-30996)/* Key/data deleted or never created. */ 1173#define DB_KEYEXIST (-30995)/* The key/data pair already exists. */ 1174#define DB_LOCK_DEADLOCK (-30994)/* Deadlock. */ 1175#define DB_LOCK_NOTGRANTED (-30993)/* Lock unavailable. */ 1176#define DB_LOG_BUFFER_FULL (-30992)/* In-memory log buffer full. */ 1177#define DB_NOSERVER (-30991)/* Server panic return. */ 1178#define DB_NOSERVER_HOME (-30990)/* Bad home sent to server. */ 1179#define DB_NOSERVER_ID (-30989)/* Bad ID sent to server. */ 1180#define DB_NOTFOUND (-30988)/* Key/data pair not found (EOF). */ 1181#define DB_OLD_VERSION (-30987)/* Out-of-date version. */ 1182#define DB_PAGE_NOTFOUND (-30986)/* Requested page not found. */ 1183#define DB_REP_DUPMASTER (-30985)/* There are two masters. */ 1184#define DB_REP_HANDLE_DEAD (-30984)/* Rolled back a commit. */ 1185#define DB_REP_HOLDELECTION (-30983)/* Time to hold an election. */ 1186#define DB_REP_IGNORE (-30982)/* This msg should be ignored.*/ 1187#define DB_REP_ISPERM (-30981)/* Cached not written perm written.*/ 1188#define DB_REP_JOIN_FAILURE (-30980)/* Unable to join replication group. */ 1189#define DB_REP_LEASE_EXPIRED (-30979)/* Master lease has expired. */ 1190#define DB_REP_LOCKOUT (-30978)/* API/Replication lockout now. */ 1191#define DB_REP_NEWSITE (-30977)/* New site entered system. */ 1192#define DB_REP_NOTPERM (-30976)/* Permanent log record not written. */ 1193#define DB_REP_UNAVAIL (-30975)/* Site cannot currently be reached. */ 1194#define DB_RUNRECOVERY (-30974)/* Panic return. */ 1195#define DB_SECONDARY_BAD (-30973)/* Secondary index corrupt. */ 1196#define DB_VERIFY_BAD (-30972)/* Verify failed; bad format. */ 1197#define DB_VERSION_MISMATCH (-30971)/* Environment version mismatch. */ 1198 1199 1200/* DB (private) error return codes. */ 1201#define DB_ALREADY_ABORTED (-30899) 1202#define DB_DELETED (-30898)/* Recovery file marked deleted. */ 1203#define DB_EVENT_NOT_HANDLED (-30897)/* Forward event to application. */ 1204#define DB_NEEDSPLIT (-30896)/* Page needs to be split. */ 1205#define DB_REP_BULKOVF (-30895)/* Rep bulk buffer overflow. */ 1206#define DB_REP_EGENCHG (-30894)/* Egen changed while in election. */ 1207#define DB_REP_LOGREADY (-30893)/* Rep log ready for recovery. */ 1208#define DB_REP_NEWMASTER (-30892)/* We have learned of a new master. */ 1209#define DB_REP_PAGEDONE (-30891)/* This page was already done. */ 1210#define DB_SURPRISE_KID (-30890)/* Child commit where parent 1211 didn't know it was a parent. */ 1212#define DB_SWAPBYTES (-30889)/* Database needs byte swapping. */ 1213#define DB_TIMEOUT (-30888)/* Timed out waiting for election. */ 1214#define DB_TXN_CKP (-30887)/* Encountered ckp record in log. */ 1215#define DB_VERIFY_FATAL (-30886)/* DB->verify cannot proceed. */ 1216 1217/* Database handle. */ 1218struct __db { 1219 /******************************************************* 1220 * Public: owned by the application. 1221 *******************************************************/ 1222 u_int32_t pgsize; /* Database logical page size. */ 1223 DB_CACHE_PRIORITY priority; /* Database priority in cache. */ 1224 1225 /* Callbacks. */ 1226 int (*db_append_recno) __P((DB *, DBT *, db_recno_t)); 1227 void (*db_feedback) __P((DB *, int, int)); 1228 int (*dup_compare) __P((DB *, const DBT *, const DBT *)); 1229 1230 void *app_private; /* Application-private handle. */ 1231 1232 /******************************************************* 1233 * Private: owned by DB. 1234 *******************************************************/ 1235 DB_ENV *dbenv; /* Backing public environment. */ 1236 ENV *env; /* Backing private environment. */ 1237 1238 DBTYPE type; /* DB access method type. */ 1239 1240 DB_MPOOLFILE *mpf; /* Backing buffer pool. */ 1241 1242 db_mutex_t mutex; /* Synchronization for free threading */ 1243 1244 char *fname, *dname; /* File/database passed to DB->open. */ 1245 u_int32_t open_flags; /* Flags passed to DB->open. */ 1246 1247 u_int8_t fileid[DB_FILE_ID_LEN];/* File's unique ID for locking. */ 1248 1249 u_int32_t adj_fileid; /* File's unique ID for curs. adj. */ 1250 1251#define DB_LOGFILEID_INVALID -1 1252 FNAME *log_filename; /* File's naming info for logging. */ 1253 1254 db_pgno_t meta_pgno; /* Meta page number */ 1255 DB_LOCKER *locker; /* Locker for handle locking. */ 1256 DB_LOCKER *cur_locker; /* Current handle lock holder. */ 1257 DB_TXN *cur_txn; /* Opening transaction. */ 1258 DB_LOCKER *associate_locker; /* Locker for DB->associate call. */ 1259 DB_LOCK handle_lock; /* Lock held on this handle. */ 1260 1261 u_int cl_id; /* RPC: remote client id. */ 1262 1263 time_t timestamp; /* Handle timestamp for replication. */ 1264 u_int32_t fid_gen; /* Rep generation number for fids. */ 1265 1266 /* 1267 * Returned data memory for DB->get() and friends. 1268 */ 1269 DBT my_rskey; /* Secondary key. */ 1270 DBT my_rkey; /* [Primary] key. */ 1271 DBT my_rdata; /* Data. */ 1272 1273 /* 1274 * !!! 1275 * Some applications use DB but implement their own locking outside of 1276 * DB. If they're using fcntl(2) locking on the underlying database 1277 * file, and we open and close a file descriptor for that file, we will 1278 * discard their locks. The DB_FCNTL_LOCKING flag to DB->open is an 1279 * undocumented interface to support this usage which leaves any file 1280 * descriptors we open until DB->close. This will only work with the 1281 * DB->open interface and simple caches, e.g., creating a transaction 1282 * thread may open/close file descriptors this flag doesn't protect. 1283 * Locking with fcntl(2) on a file that you don't own is a very, very 1284 * unsafe thing to do. 'Nuff said. 1285 */ 1286 DB_FH *saved_open_fhp; /* Saved file handle. */ 1287 1288 /* 1289 * Linked list of DBP's, linked from the ENV, used to keep track 1290 * of all open db handles for cursor adjustment. 1291 * 1292 * !!! 1293 * Explicit representations of structures from queue.h. 1294 * TAILQ_ENTRY(__db) dblistlinks; 1295 */ 1296 struct { 1297 struct __db *tqe_next; 1298 struct __db **tqe_prev; 1299 } dblistlinks; 1300 1301 /* 1302 * Cursor queues. 1303 * 1304 * !!! 1305 * Explicit representations of structures from queue.h. 1306 * TAILQ_HEAD(__cq_fq, __dbc) free_queue; 1307 * TAILQ_HEAD(__cq_aq, __dbc) active_queue; 1308 * TAILQ_HEAD(__cq_jq, __dbc) join_queue; 1309 */ 1310 struct __cq_fq { 1311 struct __dbc *tqh_first; 1312 struct __dbc **tqh_last; 1313 } free_queue; 1314 struct __cq_aq { 1315 struct __dbc *tqh_first; 1316 struct __dbc **tqh_last; 1317 } active_queue; 1318 struct __cq_jq { 1319 struct __dbc *tqh_first; 1320 struct __dbc **tqh_last; 1321 } join_queue; 1322 1323 /* 1324 * Secondary index support. 1325 * 1326 * Linked list of secondary indices -- set in the primary. 1327 * 1328 * !!! 1329 * Explicit representations of structures from queue.h. 1330 * LIST_HEAD(s_secondaries, __db); 1331 */ 1332 struct { 1333 struct __db *lh_first; 1334 } s_secondaries; 1335 1336 /* 1337 * List entries for secondaries, and reference count of how many 1338 * threads are updating this secondary (see Dbc.put). 1339 * 1340 * !!! 1341 * Note that these are synchronized by the primary's mutex, but 1342 * filled in in the secondaries. 1343 * 1344 * !!! 1345 * Explicit representations of structures from queue.h. 1346 * LIST_ENTRY(__db) s_links; 1347 */ 1348 struct { 1349 struct __db *le_next; 1350 struct __db **le_prev; 1351 } s_links; 1352 u_int32_t s_refcnt; 1353 1354 /* Secondary callback and free functions -- set in the secondary. */ 1355 int (*s_callback) __P((DB *, const DBT *, const DBT *, DBT *)); 1356 1357 /* Reference to primary -- set in the secondary. */ 1358 DB *s_primary; 1359 1360#define DB_ASSOC_IMMUTABLE_KEY 0x00000001 /* Secondary key is immutable. */ 1361 1362 /* Flags passed to associate -- set in the secondary. */ 1363 u_int32_t s_assoc_flags; 1364 1365 /* 1366 * Foreign key support. 1367 * 1368 * Linked list of primary dbs -- set in the foreign db 1369 * 1370 * !!! 1371 * Explicit representations of structures from queue.h. 1372 * LIST_HEAD(f_primaries, __db); 1373 */ 1374 struct { 1375 struct __db_foreign_info *lh_first; 1376 } f_primaries; 1377 1378 /* Reference to foreign -- set in the secondary. */ 1379 DB *s_foreign; 1380 1381 /* API-private structure: used by DB 1.85, C++, Java, Perl and Tcl */ 1382 void *api_internal; 1383 1384 /* Subsystem-private structure. */ 1385 void *bt_internal; /* Btree/Recno access method. */ 1386 void *h_internal; /* Hash access method. */ 1387 void *q_internal; /* Queue access method. */ 1388 void *xa_internal; /* XA. */ 1389 1390 /* DB PUBLIC HANDLE LIST BEGIN */ 1391 int (*associate) __P((DB *, DB_TXN *, DB *, 1392 int (*)(DB *, const DBT *, const DBT *, DBT *), u_int32_t)); 1393 int (*associate_foreign) __P((DB *, DB *, 1394 int (*)(DB *, const DBT *, DBT *, const DBT *, int *), 1395 u_int32_t)); 1396 int (*close) __P((DB *, u_int32_t)); 1397 int (*compact) __P((DB *, 1398 DB_TXN *, DBT *, DBT *, DB_COMPACT *, u_int32_t, DBT *)); 1399 int (*cursor) __P((DB *, DB_TXN *, DBC **, u_int32_t)); 1400 int (*del) __P((DB *, DB_TXN *, DBT *, u_int32_t)); 1401 void (*err) __P((DB *, int, const char *, ...)); 1402 void (*errx) __P((DB *, const char *, ...)); 1403 int (*exists) __P((DB *, DB_TXN *, DBT *, u_int32_t)); 1404 int (*fd) __P((DB *, int *)); 1405 int (*get) __P((DB *, DB_TXN *, DBT *, DBT *, u_int32_t)); 1406 int (*get_bt_minkey) __P((DB *, u_int32_t *)); 1407 int (*get_byteswapped) __P((DB *, int *)); 1408 int (*get_cachesize) __P((DB *, u_int32_t *, u_int32_t *, int *)); 1409 int (*get_dbname) __P((DB *, const char **, const char **)); 1410 int (*get_encrypt_flags) __P((DB *, u_int32_t *)); 1411 DB_ENV *(*get_env) __P((DB *)); 1412 void (*get_errcall) __P((DB *, 1413 void (**)(const DB_ENV *, const char *, const char *))); 1414 void (*get_errfile) __P((DB *, FILE **)); 1415 void (*get_errpfx) __P((DB *, const char **)); 1416 int (*get_flags) __P((DB *, u_int32_t *)); 1417 int (*get_h_ffactor) __P((DB *, u_int32_t *)); 1418 int (*get_h_nelem) __P((DB *, u_int32_t *)); 1419 int (*get_lorder) __P((DB *, int *)); 1420 DB_MPOOLFILE *(*get_mpf) __P((DB *)); 1421 void (*get_msgfile) __P((DB *, FILE **)); 1422 int (*get_multiple) __P((DB *)); 1423 int (*get_open_flags) __P((DB *, u_int32_t *)); 1424 int (*get_pagesize) __P((DB *, u_int32_t *)); 1425 int (*get_priority) __P((DB *, DB_CACHE_PRIORITY *)); 1426 int (*get_q_extentsize) __P((DB *, u_int32_t *)); 1427 int (*get_re_delim) __P((DB *, int *)); 1428 int (*get_re_len) __P((DB *, u_int32_t *)); 1429 int (*get_re_pad) __P((DB *, int *)); 1430 int (*get_re_source) __P((DB *, const char **)); 1431 int (*get_transactional) __P((DB *)); 1432 int (*get_type) __P((DB *, DBTYPE *)); 1433 int (*join) __P((DB *, DBC **, DBC **, u_int32_t)); 1434 int (*key_range) 1435 __P((DB *, DB_TXN *, DBT *, DB_KEY_RANGE *, u_int32_t)); 1436 int (*open) __P((DB *, 1437 DB_TXN *, const char *, const char *, DBTYPE, u_int32_t, int)); 1438 int (*pget) __P((DB *, DB_TXN *, DBT *, DBT *, DBT *, u_int32_t)); 1439 int (*put) __P((DB *, DB_TXN *, DBT *, DBT *, u_int32_t)); 1440 int (*remove) __P((DB *, const char *, const char *, u_int32_t)); 1441 int (*rename) __P((DB *, 1442 const char *, const char *, const char *, u_int32_t)); 1443 int (*set_alloc) __P((DB *, void *(*)(size_t), 1444 void *(*)(void *, size_t), void (*)(void *))); 1445 int (*set_append_recno) __P((DB *, int (*)(DB *, DBT *, db_recno_t))); 1446 int (*set_bt_compare) 1447 __P((DB *, int (*)(DB *, const DBT *, const DBT *))); 1448 int (*set_bt_minkey) __P((DB *, u_int32_t)); 1449 int (*set_bt_prefix) 1450 __P((DB *, size_t (*)(DB *, const DBT *, const DBT *))); 1451 int (*set_cachesize) __P((DB *, u_int32_t, u_int32_t, int)); 1452 int (*set_dup_compare) 1453 __P((DB *, int (*)(DB *, const DBT *, const DBT *))); 1454 int (*set_encrypt) __P((DB *, const char *, u_int32_t)); 1455 void (*set_errcall) __P((DB *, 1456 void (*)(const DB_ENV *, const char *, const char *))); 1457 void (*set_errfile) __P((DB *, FILE *)); 1458 void (*set_errpfx) __P((DB *, const char *)); 1459 int (*set_feedback) __P((DB *, void (*)(DB *, int, int))); 1460 int (*set_flags) __P((DB *, u_int32_t)); 1461 int (*set_h_compare) 1462 __P((DB *, int (*)(DB *, const DBT *, const DBT *))); 1463 int (*set_h_ffactor) __P((DB *, u_int32_t)); 1464 int (*set_h_hash) 1465 __P((DB *, u_int32_t (*)(DB *, const void *, u_int32_t))); 1466 int (*set_h_nelem) __P((DB *, u_int32_t)); 1467 int (*set_lorder) __P((DB *, int)); 1468 void (*set_msgcall) __P((DB *, void (*)(const DB_ENV *, const char *))); 1469 void (*set_msgfile) __P((DB *, FILE *)); 1470 int (*set_pagesize) __P((DB *, u_int32_t)); 1471 int (*set_paniccall) __P((DB *, void (*)(DB_ENV *, int))); 1472 int (*set_priority) __P((DB *, DB_CACHE_PRIORITY)); 1473 int (*set_q_extentsize) __P((DB *, u_int32_t)); 1474 int (*set_re_delim) __P((DB *, int)); 1475 int (*set_re_len) __P((DB *, u_int32_t)); 1476 int (*set_re_pad) __P((DB *, int)); 1477 int (*set_re_source) __P((DB *, const char *)); 1478 int (*stat) __P((DB *, DB_TXN *, void *, u_int32_t)); 1479 int (*stat_print) __P((DB *, u_int32_t)); 1480 int (*sync) __P((DB *, u_int32_t)); 1481 int (*truncate) __P((DB *, DB_TXN *, u_int32_t *, u_int32_t)); 1482 int (*upgrade) __P((DB *, const char *, u_int32_t)); 1483 int (*verify) 1484 __P((DB *, const char *, const char *, FILE *, u_int32_t)); 1485 /* DB PUBLIC HANDLE LIST END */ 1486 1487 /* DB PRIVATE HANDLE LIST BEGIN */ 1488 int (*dump) __P((DB *, const char *, 1489 int (*)(void *, const void *), void *, int, int)); 1490 int (*db_am_remove) __P((DB *, DB_TXN *, const char *, const char *)); 1491 int (*db_am_rename) __P((DB *, DB_TXN *, 1492 const char *, const char *, const char *)); 1493 /* DB PRIVATE HANDLE LIST END */ 1494 1495 /* 1496 * Never called; these are a place to save function pointers 1497 * so that we can undo an associate. 1498 */ 1499 int (*stored_get) __P((DB *, DB_TXN *, DBT *, DBT *, u_int32_t)); 1500 int (*stored_close) __P((DB *, u_int32_t)); 1501 1502#define DB_OK_BTREE 0x01 1503#define DB_OK_HASH 0x02 1504#define DB_OK_QUEUE 0x04 1505#define DB_OK_RECNO 0x08 1506 u_int32_t am_ok; /* Legal AM choices. */ 1507 1508 /* 1509 * This field really ought to be an AM_FLAG, but we have 1510 * have run out of bits. If/when we decide to split up 1511 * the flags, we can incorporate it. 1512 */ 1513 int preserve_fid; /* Do not free fileid on close. */ 1514 1515#define DB_AM_CHKSUM 0x00000001 /* Checksumming */ 1516#define DB_AM_COMPENSATE 0x00000002 /* Created by compensating txn */ 1517#define DB_AM_CREATED 0x00000004 /* Database was created upon open */ 1518#define DB_AM_CREATED_MSTR 0x00000008 /* Encompassing file was created */ 1519#define DB_AM_DBM_ERROR 0x00000010 /* Error in DBM/NDBM database */ 1520#define DB_AM_DELIMITER 0x00000020 /* Variable length delimiter set */ 1521#define DB_AM_DISCARD 0x00000040 /* Discard any cached pages */ 1522#define DB_AM_DUP 0x00000080 /* DB_DUP */ 1523#define DB_AM_DUPSORT 0x00000100 /* DB_DUPSORT */ 1524#define DB_AM_ENCRYPT 0x00000200 /* Encryption */ 1525#define DB_AM_FIXEDLEN 0x00000400 /* Fixed-length records */ 1526#define DB_AM_INMEM 0x00000800 /* In-memory; no sync on close */ 1527#define DB_AM_INORDER 0x00001000 /* DB_INORDER */ 1528#define DB_AM_IN_RENAME 0x00002000 /* File is being renamed */ 1529#define DB_AM_NOT_DURABLE 0x00004000 /* Do not log changes */ 1530#define DB_AM_OPEN_CALLED 0x00008000 /* DB->open called */ 1531#define DB_AM_PAD 0x00010000 /* Fixed-length record pad */ 1532#define DB_AM_PGDEF 0x00020000 /* Page size was defaulted */ 1533#define DB_AM_RDONLY 0x00040000 /* Database is readonly */ 1534#define DB_AM_READ_UNCOMMITTED 0x00080000 /* Support degree 1 isolation */ 1535#define DB_AM_RECNUM 0x00100000 /* DB_RECNUM */ 1536#define DB_AM_RECOVER 0x00200000 /* DB opened by recovery routine */ 1537#define DB_AM_RENUMBER 0x00400000 /* DB_RENUMBER */ 1538#define DB_AM_REVSPLITOFF 0x00800000 /* DB_REVSPLITOFF */ 1539#define DB_AM_SECONDARY 0x01000000 /* Database is a secondary index */ 1540#define DB_AM_SNAPSHOT 0x02000000 /* DB_SNAPSHOT */ 1541#define DB_AM_SUBDB 0x04000000 /* Subdatabases supported */ 1542#define DB_AM_SWAP 0x08000000 /* Pages need to be byte-swapped */ 1543#define DB_AM_TXN 0x10000000 /* Opened in a transaction */ 1544#define DB_AM_VERIFYING 0x20000000 /* DB handle is in the verifier */ 1545 u_int32_t orig_flags; /* Flags at open, for refresh */ 1546 u_int32_t flags; 1547}; 1548 1549/* 1550 * Macros for bulk get. These are only intended for the C API. 1551 * For C++, use DbMultiple*Iterator. 1552 */ 1553#define DB_MULTIPLE_INIT(pointer, dbt) \ 1554 (pointer = (u_int8_t *)(dbt)->data + \ 1555 (dbt)->ulen - sizeof(u_int32_t)) 1556#define DB_MULTIPLE_NEXT(pointer, dbt, retdata, retdlen) \ 1557 do { \ 1558 if (*((u_int32_t *)(pointer)) == (u_int32_t)-1) { \ 1559 retdata = NULL; \ 1560 pointer = NULL; \ 1561 break; \ 1562 } \ 1563 retdata = (u_int8_t *) \ 1564 (dbt)->data + *(u_int32_t *)(pointer); \ 1565 (pointer) = (u_int32_t *)(pointer) - 1; \ 1566 retdlen = *(u_int32_t *)(pointer); \ 1567 (pointer) = (u_int32_t *)(pointer) - 1; \ 1568 if (retdlen == 0 && \ 1569 retdata == (u_int8_t *)(dbt)->data) \ 1570 retdata = NULL; \ 1571 } while (0) 1572#define DB_MULTIPLE_KEY_NEXT(pointer, dbt, retkey, retklen, retdata, retdlen) \ 1573 do { \ 1574 if (*((u_int32_t *)(pointer)) == (u_int32_t)-1) { \ 1575 retdata = NULL; \ 1576 retkey = NULL; \ 1577 pointer = NULL; \ 1578 break; \ 1579 } \ 1580 retkey = (u_int8_t *) \ 1581 (dbt)->data + *(u_int32_t *)(pointer); \ 1582 (pointer) = (u_int32_t *)(pointer) - 1; \ 1583 retklen = *(u_int32_t *)(pointer); \ 1584 (pointer) = (u_int32_t *)(pointer) - 1; \ 1585 retdata = (u_int8_t *) \ 1586 (dbt)->data + *(u_int32_t *)(pointer); \ 1587 (pointer) = (u_int32_t *)(pointer) - 1; \ 1588 retdlen = *(u_int32_t *)(pointer); \ 1589 (pointer) = (u_int32_t *)(pointer) - 1; \ 1590 } while (0) 1591 1592#define DB_MULTIPLE_RECNO_NEXT(pointer, dbt, recno, retdata, retdlen) \ 1593 do { \ 1594 if (*((u_int32_t *)(pointer)) == (u_int32_t)0) { \ 1595 recno = 0; \ 1596 retdata = NULL; \ 1597 pointer = NULL; \ 1598 break; \ 1599 } \ 1600 recno = *(u_int32_t *)(pointer); \ 1601 (pointer) = (u_int32_t *)(pointer) - 1; \ 1602 retdata = (u_int8_t *) \ 1603 (dbt)->data + *(u_int32_t *)(pointer); \ 1604 (pointer) = (u_int32_t *)(pointer) - 1; \ 1605 retdlen = *(u_int32_t *)(pointer); \ 1606 (pointer) = (u_int32_t *)(pointer) - 1; \ 1607 } while (0) 1608 1609/******************************************************* 1610 * Access method cursors. 1611 *******************************************************/ 1612struct __dbc { 1613 DB *dbp; /* Backing database */ 1614 DB_ENV *dbenv; /* Backing environment */ 1615 ENV *env; /* Backing environment */ 1616 1617 DB_THREAD_INFO *thread_info; /* Thread that owns this cursor. */ 1618 DB_TXN *txn; /* Associated transaction. */ 1619 DB_CACHE_PRIORITY priority; /* Priority in cache. */ 1620 1621 /* 1622 * Active/free cursor queues. 1623 * 1624 * !!! 1625 * Explicit representations of structures from queue.h. 1626 * TAILQ_ENTRY(__dbc) links; 1627 */ 1628 struct { 1629 DBC *tqe_next; 1630 DBC **tqe_prev; 1631 } links; 1632 1633 /* 1634 * The DBT *'s below are used by the cursor routines to return 1635 * data to the user when DBT flags indicate that DB should manage 1636 * the returned memory. They point at a DBT containing the buffer 1637 * and length that will be used, and "belonging" to the handle that 1638 * should "own" this memory. This may be a "my_*" field of this 1639 * cursor--the default--or it may be the corresponding field of 1640 * another cursor, a DB handle, a join cursor, etc. In general, it 1641 * will be whatever handle the user originally used for the current 1642 * DB interface call. 1643 */ 1644 DBT *rskey; /* Returned secondary key. */ 1645 DBT *rkey; /* Returned [primary] key. */ 1646 DBT *rdata; /* Returned data. */ 1647 1648 DBT my_rskey; /* Space for returned secondary key. */ 1649 DBT my_rkey; /* Space for returned [primary] key. */ 1650 DBT my_rdata; /* Space for returned data. */ 1651 1652 DB_LOCKER *lref; /* Reference to default locker. */ 1653 DB_LOCKER *locker; /* Locker for this operation. */ 1654 DBT lock_dbt; /* DBT referencing lock. */ 1655 DB_LOCK_ILOCK lock; /* Object to be locked. */ 1656 DB_LOCK mylock; /* CDB lock held on this cursor. */ 1657 1658 u_int cl_id; /* Remote client id. */ 1659 1660 DBTYPE dbtype; /* Cursor type. */ 1661 1662 DBC_INTERNAL *internal; /* Access method private. */ 1663 1664 /* DBC PUBLIC HANDLE LIST BEGIN */ 1665 int (*close) __P((DBC *)); 1666 int (*count) __P((DBC *, db_recno_t *, u_int32_t)); 1667 int (*del) __P((DBC *, u_int32_t)); 1668 int (*dup) __P((DBC *, DBC **, u_int32_t)); 1669 int (*get) __P((DBC *, DBT *, DBT *, u_int32_t)); 1670 int (*get_priority) __P((DBC *, DB_CACHE_PRIORITY *)); 1671 int (*pget) __P((DBC *, DBT *, DBT *, DBT *, u_int32_t)); 1672 int (*put) __P((DBC *, DBT *, DBT *, u_int32_t)); 1673 int (*set_priority) __P((DBC *, DB_CACHE_PRIORITY)); 1674 /* DBC PUBLIC HANDLE LIST END */ 1675 1676 /* The following are the method names deprecated in the 4.6 release. */ 1677 int (*c_close) __P((DBC *)); 1678 int (*c_count) __P((DBC *, db_recno_t *, u_int32_t)); 1679 int (*c_del) __P((DBC *, u_int32_t)); 1680 int (*c_dup) __P((DBC *, DBC **, u_int32_t)); 1681 int (*c_get) __P((DBC *, DBT *, DBT *, u_int32_t)); 1682 int (*c_pget) __P((DBC *, DBT *, DBT *, DBT *, u_int32_t)); 1683 int (*c_put) __P((DBC *, DBT *, DBT *, u_int32_t)); 1684 1685 /* DBC PRIVATE HANDLE LIST BEGIN */ 1686 int (*am_bulk) __P((DBC *, DBT *, u_int32_t)); 1687 int (*am_close) __P((DBC *, db_pgno_t, int *)); 1688 int (*am_del) __P((DBC *)); 1689 int (*am_destroy) __P((DBC *)); 1690 int (*am_get) __P((DBC *, DBT *, DBT *, u_int32_t, db_pgno_t *)); 1691 int (*am_put) __P((DBC *, DBT *, DBT *, u_int32_t, db_pgno_t *)); 1692 int (*am_writelock) __P((DBC *)); 1693 /* DBC PRIVATE HANDLE LIST END */ 1694 1695/* 1696 * DBC_DONTLOCK and DBC_RECOVER are used during recovery and transaction 1697 * abort. If a transaction is being aborted or recovered then DBC_RECOVER 1698 * will be set and locking and logging will be disabled on this cursor. If 1699 * we are performing a compensating transaction (e.g. free page processing) 1700 * then DB_DONTLOCK will be set to inhibit locking, but logging will still 1701 * be required. DB_DONTLOCK is also used if the whole database is locked. 1702 */ 1703#define DBC_ACTIVE 0x0001 /* Cursor in use. */ 1704#define DBC_DONTLOCK 0x0002 /* Don't lock on this cursor. */ 1705#define DBC_DUPLICATE 0x0004 /* Create a duplicate cursor. */ 1706#define DBC_MULTIPLE 0x0008 /* Return Multiple data. */ 1707#define DBC_MULTIPLE_KEY 0x0010 /* Return Multiple keys and data. */ 1708#define DBC_OPD 0x0020 /* Cursor references off-page dups. */ 1709#define DBC_OWN_LID 0x0040 /* Free lock id on destroy. */ 1710#define DBC_READ_COMMITTED 0x0080 /* Cursor has degree 2 isolation. */ 1711#define DBC_READ_UNCOMMITTED 0x0100 /* Cursor has degree 1 isolation. */ 1712#define DBC_RECOVER 0x0200 /* Recovery cursor; don't log/lock. */ 1713#define DBC_RMW 0x0400 /* Acquire write flag in read op. */ 1714#define DBC_TRANSIENT 0x0800 /* Cursor is transient. */ 1715#define DBC_WRITECURSOR 0x1000 /* Cursor may be used to write (CDB). */ 1716#define DBC_WRITER 0x2000 /* Cursor immediately writing (CDB). */ 1717 u_int32_t flags; 1718}; 1719 1720/* Key range statistics structure */ 1721struct __key_range { 1722 double less; 1723 double equal; 1724 double greater; 1725}; 1726 1727/* Btree/Recno statistics structure. */ 1728struct __db_bt_stat { 1729 u_int32_t bt_magic; /* Magic number. */ 1730 u_int32_t bt_version; /* Version number. */ 1731 u_int32_t bt_metaflags; /* Metadata flags. */ 1732 u_int32_t bt_nkeys; /* Number of unique keys. */ 1733 u_int32_t bt_ndata; /* Number of data items. */ 1734 u_int32_t bt_pagecnt; /* Page count. */ 1735 u_int32_t bt_pagesize; /* Page size. */ 1736 u_int32_t bt_minkey; /* Minkey value. */ 1737 u_int32_t bt_re_len; /* Fixed-length record length. */ 1738 u_int32_t bt_re_pad; /* Fixed-length record pad. */ 1739 u_int32_t bt_levels; /* Tree levels. */ 1740 u_int32_t bt_int_pg; /* Internal pages. */ 1741 u_int32_t bt_leaf_pg; /* Leaf pages. */ 1742 u_int32_t bt_dup_pg; /* Duplicate pages. */ 1743 u_int32_t bt_over_pg; /* Overflow pages. */ 1744 u_int32_t bt_empty_pg; /* Empty pages. */ 1745 u_int32_t bt_free; /* Pages on the free list. */ 1746 u_int32_t bt_int_pgfree; /* Bytes free in internal pages. */ 1747 u_int32_t bt_leaf_pgfree; /* Bytes free in leaf pages. */ 1748 u_int32_t bt_dup_pgfree; /* Bytes free in duplicate pages. */ 1749 u_int32_t bt_over_pgfree; /* Bytes free in overflow pages. */ 1750}; 1751 1752struct __db_compact { 1753 /* Input Parameters. */ 1754 u_int32_t compact_fillpercent; /* Desired fillfactor: 1-100 */ 1755 db_timeout_t compact_timeout; /* Lock timeout. */ 1756 u_int32_t compact_pages; /* Max pages to process. */ 1757 /* Output Stats. */ 1758 u_int32_t compact_pages_free; /* Number of pages freed. */ 1759 u_int32_t compact_pages_examine; /* Number of pages examine. */ 1760 u_int32_t compact_levels; /* Number of levels removed. */ 1761 u_int32_t compact_deadlock; /* Number of deadlocks. */ 1762 db_pgno_t compact_pages_truncated; /* Pages truncated to OS. */ 1763 /* Internal. */ 1764 db_pgno_t compact_truncate; /* Page number for truncation */ 1765}; 1766 1767/* Hash statistics structure. */ 1768struct __db_h_stat { 1769 u_int32_t hash_magic; /* Magic number. */ 1770 u_int32_t hash_version; /* Version number. */ 1771 u_int32_t hash_metaflags; /* Metadata flags. */ 1772 u_int32_t hash_nkeys; /* Number of unique keys. */ 1773 u_int32_t hash_ndata; /* Number of data items. */ 1774 u_int32_t hash_pagecnt; /* Page count. */ 1775 u_int32_t hash_pagesize; /* Page size. */ 1776 u_int32_t hash_ffactor; /* Fill factor specified at create. */ 1777 u_int32_t hash_buckets; /* Number of hash buckets. */ 1778 u_int32_t hash_free; /* Pages on the free list. */ 1779 u_int32_t hash_bfree; /* Bytes free on bucket pages. */ 1780 u_int32_t hash_bigpages; /* Number of big key/data pages. */ 1781 u_int32_t hash_big_bfree; /* Bytes free on big item pages. */ 1782 u_int32_t hash_overflows; /* Number of overflow pages. */ 1783 u_int32_t hash_ovfl_free; /* Bytes free on ovfl pages. */ 1784 u_int32_t hash_dup; /* Number of dup pages. */ 1785 u_int32_t hash_dup_free; /* Bytes free on duplicate pages. */ 1786}; 1787 1788/* Queue statistics structure. */ 1789struct __db_qam_stat { 1790 u_int32_t qs_magic; /* Magic number. */ 1791 u_int32_t qs_version; /* Version number. */ 1792 u_int32_t qs_metaflags; /* Metadata flags. */ 1793 u_int32_t qs_nkeys; /* Number of unique keys. */ 1794 u_int32_t qs_ndata; /* Number of data items. */ 1795 u_int32_t qs_pagesize; /* Page size. */ 1796 u_int32_t qs_extentsize; /* Pages per extent. */ 1797 u_int32_t qs_pages; /* Data pages. */ 1798 u_int32_t qs_re_len; /* Fixed-length record length. */ 1799 u_int32_t qs_re_pad; /* Fixed-length record pad. */ 1800 u_int32_t qs_pgfree; /* Bytes free in data pages. */ 1801 u_int32_t qs_first_recno; /* First not deleted record. */ 1802 u_int32_t qs_cur_recno; /* Next available record number. */ 1803}; 1804 1805/******************************************************* 1806 * Environment. 1807 *******************************************************/ 1808#define DB_REGION_MAGIC 0x120897 /* Environment magic number. */ 1809 1810/* 1811 * Database environment structure. 1812 * 1813 * This is the public database environment handle. The private environment 1814 * handle is the ENV structure. The user owns this structure, the library 1815 * owns the ENV structure. The reason there are two structures is because 1816 * the user's configuration outlives any particular DB_ENV->open call, and 1817 * separate structures allows us to easily discard internal information without 1818 * discarding the user's configuration. 1819 * 1820 * Fields in the DB_ENV structure should normally be set only by application 1821 * DB_ENV handle methods. 1822 */ 1823struct __db_env { 1824 ENV *env; /* Linked ENV structure */ 1825 1826 /* 1827 * The DB_ENV structure can be used concurrently, so field access is 1828 * protected. 1829 */ 1830 db_mutex_t mtx_db_env; /* DB_ENV structure mutex */ 1831 1832 /* Error message callback */ 1833 void (*db_errcall) __P((const DB_ENV *, const char *, const char *)); 1834 FILE *db_errfile; /* Error message file stream */ 1835 const char *db_errpfx; /* Error message prefix */ 1836 1837 /* Other message callback */ 1838 void (*db_msgcall) __P((const DB_ENV *, const char *)); 1839 FILE *db_msgfile; /* Other message file stream */ 1840 1841 /* Other application callback functions */ 1842 int (*app_dispatch) __P((DB_ENV *, DBT *, DB_LSN *, db_recops)); 1843 void (*db_event_func) __P((DB_ENV *, u_int32_t, void *)); 1844 void (*db_feedback) __P((DB_ENV *, int, int)); 1845 void (*db_free) __P((void *)); 1846 void (*db_paniccall) __P((DB_ENV *, int)); 1847 void *(*db_malloc) __P((size_t)); 1848 void *(*db_realloc) __P((void *, size_t)); 1849 int (*is_alive) __P((DB_ENV *, pid_t, db_threadid_t, u_int32_t)); 1850 void (*thread_id) __P((DB_ENV *, pid_t *, db_threadid_t *)); 1851 char *(*thread_id_string) __P((DB_ENV *, pid_t, db_threadid_t, char *)); 1852 1853 /* Application specified paths */ 1854 char *db_log_dir; /* Database log file directory */ 1855 char *db_tmp_dir; /* Database tmp file directory */ 1856 1857 char **db_data_dir; /* Database data file directories */ 1858 int data_cnt; /* Database data file slots */ 1859 int data_next; /* Next database data file slot */ 1860 1861 char *intermediate_dir_mode; /* Intermediate directory perms */ 1862 1863 long shm_key; /* shmget key */ 1864 1865 char *passwd; /* Cryptography support */ 1866 size_t passwd_len; 1867 1868 void *cl_handle; /* RPC: remote client handle */ 1869 u_int cl_id; /* RPC: remote client env id */ 1870 1871 /* Private handle references */ 1872 void *app_private; /* Application-private handle */ 1873 void *api1_internal; /* C++, Perl API private */ 1874 void *api2_internal; /* Java API private */ 1875 1876 u_int32_t verbose; /* DB_VERB_XXX flags */ 1877 1878 /* Mutex configuration */ 1879 u_int32_t mutex_align; /* Mutex alignment */ 1880 u_int32_t mutex_cnt; /* Number of mutexes to configure */ 1881 u_int32_t mutex_inc; /* Number of mutexes to add */ 1882 u_int32_t mutex_tas_spins;/* Test-and-set spin count */ 1883 1884 /* Locking configuration */ 1885 u_int8_t *lk_conflicts; /* Two dimensional conflict matrix */ 1886 int lk_modes; /* Number of lock modes in table */ 1887 u_int32_t lk_detect; /* Deadlock detect on all conflicts */ 1888 u_int32_t lk_max; /* Maximum number of locks */ 1889 u_int32_t lk_max_lockers;/* Maximum number of lockers */ 1890 u_int32_t lk_max_objects;/* Maximum number of locked objects */ 1891 u_int32_t lk_partitions ;/* Number of object partitions */ 1892 db_timeout_t lk_timeout; /* Lock timeout period */ 1893 1894 /* Logging configuration */ 1895 u_int32_t lg_bsize; /* Buffer size */ 1896 int lg_filemode; /* Log file permission mode */ 1897 u_int32_t lg_regionmax; /* Region size */ 1898 u_int32_t lg_size; /* Log file size */ 1899 u_int32_t lg_flags; /* Log configuration */ 1900 1901 /* Memory pool configuration */ 1902 u_int32_t mp_gbytes; /* Cache size: GB */ 1903 u_int32_t mp_bytes; /* Cache size: bytes */ 1904 u_int32_t mp_max_gbytes; /* Maximum cache size: GB */ 1905 u_int32_t mp_max_bytes; /* Maximum cache size: bytes */ 1906 size_t mp_mmapsize; /* Maximum file size for mmap */ 1907 int mp_maxopenfd; /* Maximum open file descriptors */ 1908 int mp_maxwrite; /* Maximum buffers to write */ 1909 u_int mp_ncache; /* Initial number of cache regions */ 1910 /* Sleep after writing max buffers */ 1911 db_timeout_t mp_maxwrite_sleep; 1912 1913 /* Transaction configuration */ 1914 u_int32_t tx_max; /* Maximum number of transactions */ 1915 time_t tx_timestamp; /* Recover to specific timestamp */ 1916 db_timeout_t tx_timeout; /* Timeout for transactions */ 1917 1918 /* Thread tracking configuration */ 1919 u_int32_t thr_max; /* Thread count */ 1920 1921 /* 1922 * The following fields are not strictly user-owned, but they outlive 1923 * the ENV structure, and so are stored here. 1924 */ 1925 DB_FH *registry; /* DB_REGISTER file handle */ 1926 u_int32_t registry_off; /* 1927 * Offset of our slot. We can't use 1928 * off_t because its size depends on 1929 * build settings. 1930 */ 1931 1932#define DB_ENV_AUTO_COMMIT 0x00000001 /* DB_AUTO_COMMIT */ 1933#define DB_ENV_CDB_ALLDB 0x00000002 /* CDB environment wide locking */ 1934#define DB_ENV_DIRECT_DB 0x00000004 /* DB_DIRECT_DB set */ 1935#define DB_ENV_DSYNC_DB 0x00000008 /* DB_DSYNC_DB set */ 1936#define DB_ENV_MULTIVERSION 0x00000010 /* DB_MULTIVERSION set */ 1937#define DB_ENV_NOLOCKING 0x00000020 /* DB_NOLOCKING set */ 1938#define DB_ENV_NOMMAP 0x00000040 /* DB_NOMMAP set */ 1939#define DB_ENV_NOPANIC 0x00000080 /* Okay if panic set */ 1940#define DB_ENV_OVERWRITE 0x00000100 /* DB_OVERWRITE set */ 1941#define DB_ENV_REGION_INIT 0x00000200 /* DB_REGION_INIT set */ 1942#define DB_ENV_RPCCLIENT 0x00000400 /* DB_RPCCLIENT set */ 1943#define DB_ENV_RPCCLIENT_GIVEN 0x00000800 /* User-supplied RPC client struct */ 1944#define DB_ENV_TIME_NOTGRANTED 0x00001000 /* DB_TIME_NOTGRANTED set */ 1945#define DB_ENV_TXN_NOSYNC 0x00002000 /* DB_TXN_NOSYNC set */ 1946#define DB_ENV_TXN_NOWAIT 0x00004000 /* DB_TXN_NOWAIT set */ 1947#define DB_ENV_TXN_SNAPSHOT 0x00008000 /* DB_TXN_SNAPSHOT set */ 1948#define DB_ENV_TXN_WRITE_NOSYNC 0x00010000 /* DB_TXN_WRITE_NOSYNC set */ 1949#define DB_ENV_YIELDCPU 0x00020000 /* DB_YIELDCPU set */ 1950 u_int32_t flags; 1951 1952 /* DB_ENV PUBLIC HANDLE LIST BEGIN */ 1953 int (*cdsgroup_begin) __P((DB_ENV *, DB_TXN **)); 1954 int (*close) __P((DB_ENV *, u_int32_t)); 1955 int (*dbremove) __P((DB_ENV *, 1956 DB_TXN *, const char *, const char *, u_int32_t)); 1957 int (*dbrename) __P((DB_ENV *, 1958 DB_TXN *, const char *, const char *, const char *, u_int32_t)); 1959 void (*err) __P((const DB_ENV *, int, const char *, ...)); 1960 void (*errx) __P((const DB_ENV *, const char *, ...)); 1961 int (*failchk) __P((DB_ENV *, u_int32_t)); 1962 int (*fileid_reset) __P((DB_ENV *, const char *, u_int32_t)); 1963 int (*get_cache_max) __P((DB_ENV *, u_int32_t *, u_int32_t *)); 1964 int (*get_cachesize) __P((DB_ENV *, u_int32_t *, u_int32_t *, int *)); 1965 int (*get_data_dirs) __P((DB_ENV *, const char ***)); 1966 int (*get_encrypt_flags) __P((DB_ENV *, u_int32_t *)); 1967 void (*get_errcall) __P((DB_ENV *, 1968 void (**)(const DB_ENV *, const char *, const char *))); 1969 void (*get_errfile) __P((DB_ENV *, FILE **)); 1970 void (*get_errpfx) __P((DB_ENV *, const char **)); 1971 int (*get_flags) __P((DB_ENV *, u_int32_t *)); 1972 int (*get_home) __P((DB_ENV *, const char **)); 1973 int (*get_intermediate_dir_mode) __P((DB_ENV *, const char **)); 1974 int (*get_lg_bsize) __P((DB_ENV *, u_int32_t *)); 1975 int (*get_lg_dir) __P((DB_ENV *, const char **)); 1976 int (*get_lg_filemode) __P((DB_ENV *, int *)); 1977 int (*get_lg_max) __P((DB_ENV *, u_int32_t *)); 1978 int (*get_lg_regionmax) __P((DB_ENV *, u_int32_t *)); 1979 int (*get_lk_conflicts) __P((DB_ENV *, const u_int8_t **, int *)); 1980 int (*get_lk_detect) __P((DB_ENV *, u_int32_t *)); 1981 int (*get_lk_max_lockers) __P((DB_ENV *, u_int32_t *)); 1982 int (*get_lk_max_locks) __P((DB_ENV *, u_int32_t *)); 1983 int (*get_lk_max_objects) __P((DB_ENV *, u_int32_t *)); 1984 int (*get_lk_partitions) __P((DB_ENV *, u_int32_t *)); 1985 int (*get_mp_max_openfd) __P((DB_ENV *, int *)); 1986 int (*get_mp_max_write) __P((DB_ENV *, int *, db_timeout_t *)); 1987 int (*get_mp_mmapsize) __P((DB_ENV *, size_t *)); 1988 void (*get_msgfile) __P((DB_ENV *, FILE **)); 1989 int (*get_open_flags) __P((DB_ENV *, u_int32_t *)); 1990 int (*get_shm_key) __P((DB_ENV *, long *)); 1991 int (*get_thread_count) __P((DB_ENV *, u_int32_t *)); 1992 int (*get_timeout) __P((DB_ENV *, db_timeout_t *, u_int32_t)); 1993 int (*get_tmp_dir) __P((DB_ENV *, const char **)); 1994 int (*get_tx_max) __P((DB_ENV *, u_int32_t *)); 1995 int (*get_tx_timestamp) __P((DB_ENV *, time_t *)); 1996 int (*get_verbose) __P((DB_ENV *, u_int32_t, int *)); 1997 int (*is_bigendian) __P((void)); 1998 int (*lock_detect) __P((DB_ENV *, u_int32_t, u_int32_t, int *)); 1999 int (*lock_get) __P((DB_ENV *, 2000 u_int32_t, u_int32_t, const DBT *, db_lockmode_t, DB_LOCK *)); 2001 int (*lock_id) __P((DB_ENV *, u_int32_t *)); 2002 int (*lock_id_free) __P((DB_ENV *, u_int32_t)); 2003 int (*lock_put) __P((DB_ENV *, DB_LOCK *)); 2004 int (*lock_stat) __P((DB_ENV *, DB_LOCK_STAT **, u_int32_t)); 2005 int (*lock_stat_print) __P((DB_ENV *, u_int32_t)); 2006 int (*lock_vec) __P((DB_ENV *, 2007 u_int32_t, u_int32_t, DB_LOCKREQ *, int, DB_LOCKREQ **)); 2008 int (*log_archive) __P((DB_ENV *, char **[], u_int32_t)); 2009 int (*log_cursor) __P((DB_ENV *, DB_LOGC **, u_int32_t)); 2010 int (*log_file) __P((DB_ENV *, const DB_LSN *, char *, size_t)); 2011 int (*log_flush) __P((DB_ENV *, const DB_LSN *)); 2012 int (*log_get_config) __P((DB_ENV *, u_int32_t, int *)); 2013 int (*log_printf) __P((DB_ENV *, DB_TXN *, const char *, ...)); 2014 int (*log_put) __P((DB_ENV *, DB_LSN *, const DBT *, u_int32_t)); 2015 int (*log_set_config) __P((DB_ENV *, u_int32_t, int)); 2016 int (*log_stat) __P((DB_ENV *, DB_LOG_STAT **, u_int32_t)); 2017 int (*log_stat_print) __P((DB_ENV *, u_int32_t)); 2018 int (*lsn_reset) __P((DB_ENV *, const char *, u_int32_t)); 2019 int (*memp_fcreate) __P((DB_ENV *, DB_MPOOLFILE **, u_int32_t)); 2020 int (*memp_register) __P((DB_ENV *, int, int (*)(DB_ENV *, db_pgno_t, 2021 void *, DBT *), int (*)(DB_ENV *, db_pgno_t, void *, DBT *))); 2022 int (*memp_stat) __P((DB_ENV *, 2023 DB_MPOOL_STAT **, DB_MPOOL_FSTAT ***, u_int32_t)); 2024 int (*memp_stat_print) __P((DB_ENV *, u_int32_t)); 2025 int (*memp_sync) __P((DB_ENV *, DB_LSN *)); 2026 int (*memp_trickle) __P((DB_ENV *, int, int *)); 2027 int (*mutex_alloc) __P((DB_ENV *, u_int32_t, db_mutex_t *)); 2028 int (*mutex_free) __P((DB_ENV *, db_mutex_t)); 2029 int (*mutex_get_align) __P((DB_ENV *, u_int32_t *)); 2030 int (*mutex_get_increment) __P((DB_ENV *, u_int32_t *)); 2031 int (*mutex_get_max) __P((DB_ENV *, u_int32_t *)); 2032 int (*mutex_get_tas_spins) __P((DB_ENV *, u_int32_t *)); 2033 int (*mutex_lock) __P((DB_ENV *, db_mutex_t)); 2034 int (*mutex_set_align) __P((DB_ENV *, u_int32_t)); 2035 int (*mutex_set_increment) __P((DB_ENV *, u_int32_t)); 2036 int (*mutex_set_max) __P((DB_ENV *, u_int32_t)); 2037 int (*mutex_set_tas_spins) __P((DB_ENV *, u_int32_t)); 2038 int (*mutex_stat) __P((DB_ENV *, DB_MUTEX_STAT **, u_int32_t)); 2039 int (*mutex_stat_print) __P((DB_ENV *, u_int32_t)); 2040 int (*mutex_unlock) __P((DB_ENV *, db_mutex_t)); 2041 int (*open) __P((DB_ENV *, const char *, u_int32_t, int)); 2042 int (*remove) __P((DB_ENV *, const char *, u_int32_t)); 2043 int (*rep_elect) __P((DB_ENV *, u_int32_t, u_int32_t, u_int32_t)); 2044 int (*rep_flush) __P((DB_ENV *)); 2045 int (*rep_get_clockskew) __P((DB_ENV *, u_int32_t *, u_int32_t *)); 2046 int (*rep_get_config) __P((DB_ENV *, u_int32_t, int *)); 2047 int (*rep_get_limit) __P((DB_ENV *, u_int32_t *, u_int32_t *)); 2048 int (*rep_get_nsites) __P((DB_ENV *, u_int32_t *)); 2049 int (*rep_get_priority) __P((DB_ENV *, u_int32_t *)); 2050 int (*rep_get_request) __P((DB_ENV *, u_int32_t *, u_int32_t *)); 2051 int (*rep_get_timeout) __P((DB_ENV *, int, u_int32_t *)); 2052 int (*rep_process_message) 2053 __P((DB_ENV *, DBT *, DBT *, int, DB_LSN *)); 2054 int (*rep_set_clockskew) __P((DB_ENV *, u_int32_t, u_int32_t)); 2055 int (*rep_set_config) __P((DB_ENV *, u_int32_t, int)); 2056 int (*rep_set_limit) __P((DB_ENV *, u_int32_t, u_int32_t)); 2057 int (*rep_set_nsites) __P((DB_ENV *, u_int32_t)); 2058 int (*rep_set_priority) __P((DB_ENV *, u_int32_t)); 2059 int (*rep_set_request) __P((DB_ENV *, u_int32_t, u_int32_t)); 2060 int (*rep_set_timeout) __P((DB_ENV *, int, db_timeout_t)); 2061 int (*rep_set_transport) __P((DB_ENV *, int, int (*)(DB_ENV *, 2062 const DBT *, const DBT *, const DB_LSN *, int, u_int32_t))); 2063 int (*rep_start) __P((DB_ENV *, DBT *, u_int32_t)); 2064 int (*rep_stat) __P((DB_ENV *, DB_REP_STAT **, u_int32_t)); 2065 int (*rep_stat_print) __P((DB_ENV *, u_int32_t)); 2066 int (*rep_sync) __P((DB_ENV *, u_int32_t)); 2067 int (*repmgr_add_remote_site) 2068 __P((DB_ENV *, const char *, u_int, int *, u_int32_t)); 2069 int (*repmgr_get_ack_policy) __P((DB_ENV *, int *)); 2070 int (*repmgr_set_ack_policy) __P((DB_ENV *, int)); 2071 int (*repmgr_set_local_site) 2072 __P((DB_ENV *, const char *, u_int, u_int32_t)); 2073 int (*repmgr_site_list) 2074 __P((DB_ENV *, u_int *, DB_REPMGR_SITE **)); 2075 int (*repmgr_start) __P((DB_ENV *, int, u_int32_t)); 2076 int (*repmgr_stat) __P((DB_ENV *, DB_REPMGR_STAT **, u_int32_t)); 2077 int (*repmgr_stat_print) __P((DB_ENV *, u_int32_t)); 2078 int (*set_alloc) __P((DB_ENV *, void *(*)(size_t), 2079 void *(*)(void *, size_t), void (*)(void *))); 2080 int (*set_app_dispatch) 2081 __P((DB_ENV *, int (*)(DB_ENV *, DBT *, DB_LSN *, db_recops))); 2082 int (*set_cache_max) __P((DB_ENV *, u_int32_t, u_int32_t)); 2083 int (*set_cachesize) __P((DB_ENV *, u_int32_t, u_int32_t, int)); 2084 int (*set_data_dir) __P((DB_ENV *, const char *)); 2085 int (*set_encrypt) __P((DB_ENV *, const char *, u_int32_t)); 2086 void (*set_errcall) __P((DB_ENV *, 2087 void (*)(const DB_ENV *, const char *, const char *))); 2088 void (*set_errfile) __P((DB_ENV *, FILE *)); 2089 void (*set_errpfx) __P((DB_ENV *, const char *)); 2090 int (*set_event_notify) 2091 __P((DB_ENV *, void (*)(DB_ENV *, u_int32_t, void *))); 2092 int (*set_feedback) __P((DB_ENV *, void (*)(DB_ENV *, int, int))); 2093 int (*set_flags) __P((DB_ENV *, u_int32_t, int)); 2094 int (*set_intermediate_dir_mode) __P((DB_ENV *, const char *)); 2095 int (*set_isalive) __P((DB_ENV *, 2096 int (*)(DB_ENV *, pid_t, db_threadid_t, u_int32_t))); 2097 int (*set_lg_bsize) __P((DB_ENV *, u_int32_t)); 2098 int (*set_lg_dir) __P((DB_ENV *, const char *)); 2099 int (*set_lg_filemode) __P((DB_ENV *, int)); 2100 int (*set_lg_max) __P((DB_ENV *, u_int32_t)); 2101 int (*set_lg_regionmax) __P((DB_ENV *, u_int32_t)); 2102 int (*set_lk_conflicts) __P((DB_ENV *, u_int8_t *, int)); 2103 int (*set_lk_detect) __P((DB_ENV *, u_int32_t)); 2104 int (*set_lk_max_lockers) __P((DB_ENV *, u_int32_t)); 2105 int (*set_lk_max_locks) __P((DB_ENV *, u_int32_t)); 2106 int (*set_lk_max_objects) __P((DB_ENV *, u_int32_t)); 2107 int (*set_lk_partitions) __P((DB_ENV *, u_int32_t)); 2108 int (*set_mp_max_openfd) __P((DB_ENV *, int)); 2109 int (*set_mp_max_write) __P((DB_ENV *, int, db_timeout_t)); 2110 int (*set_mp_mmapsize) __P((DB_ENV *, size_t)); 2111 void (*set_msgcall) 2112 __P((DB_ENV *, void (*)(const DB_ENV *, const char *))); 2113 void (*set_msgfile) __P((DB_ENV *, FILE *)); 2114 int (*set_paniccall) __P((DB_ENV *, void (*)(DB_ENV *, int))); 2115 int (*set_rpc_server) 2116 __P((DB_ENV *, void *, const char *, long, long, u_int32_t)); 2117 int (*set_shm_key) __P((DB_ENV *, long)); 2118 int (*set_thread_count) __P((DB_ENV *, u_int32_t)); 2119 int (*set_thread_id) 2120 __P((DB_ENV *, void (*)(DB_ENV *, pid_t *, db_threadid_t *))); 2121 int (*set_thread_id_string) __P((DB_ENV *, 2122 char *(*)(DB_ENV *, pid_t, db_threadid_t, char *))); 2123 int (*set_timeout) __P((DB_ENV *, db_timeout_t, u_int32_t)); 2124 int (*set_tmp_dir) __P((DB_ENV *, const char *)); 2125 int (*set_tx_max) __P((DB_ENV *, u_int32_t)); 2126 int (*set_tx_timestamp) __P((DB_ENV *, time_t *)); 2127 int (*set_verbose) __P((DB_ENV *, u_int32_t, int)); 2128 int (*stat_print) __P((DB_ENV *, u_int32_t)); 2129 int (*txn_begin) __P((DB_ENV *, DB_TXN *, DB_TXN **, u_int32_t)); 2130 int (*txn_checkpoint) __P((DB_ENV *, u_int32_t, u_int32_t, u_int32_t)); 2131 int (*txn_recover) 2132 __P((DB_ENV *, DB_PREPLIST *, long, long *, u_int32_t)); 2133 int (*txn_stat) __P((DB_ENV *, DB_TXN_STAT **, u_int32_t)); 2134 int (*txn_stat_print) __P((DB_ENV *, u_int32_t)); 2135 /* DB_ENV PUBLIC HANDLE LIST END */ 2136 2137 /* DB_ENV PRIVATE HANDLE LIST BEGIN */ 2138 int (*prdbt) __P((DBT *, 2139 int, const char *, void *, int (*)(void *, const void *), int)); 2140 /* DB_ENV PRIVATE HANDLE LIST END */ 2141}; 2142 2143/* 2144 * Dispatch structure for recovery and print routines. Since internal and 2145 * external routines take different arguments (ENV versus DB_ENV), we need 2146 * something more elaborate than a single pointer and size. 2147 */ 2148struct __db_distab { 2149 int (**int_dispatch) __P((ENV *, DBT *, DB_LSN *, db_recops, void *)); 2150 size_t int_size; 2151 int (**ext_dispatch) __P((DB_ENV *, DBT *, DB_LSN *, db_recops)); 2152 size_t ext_size; 2153}; 2154 2155#ifndef DB_DBM_HSEARCH 2156#define DB_DBM_HSEARCH 0 /* No historic interfaces by default. */ 2157#endif 2158#if DB_DBM_HSEARCH != 0 2159/******************************************************* 2160 * Dbm/Ndbm historic interfaces. 2161 *******************************************************/ 2162typedef struct __db DBM; 2163 2164#define DBM_INSERT 0 /* Flags to dbm_store(). */ 2165#define DBM_REPLACE 1 2166 2167/* 2168 * The DB support for ndbm(3) always appends this suffix to the 2169 * file name to avoid overwriting the user's original database. 2170 */ 2171#define DBM_SUFFIX ".db" 2172 2173#if defined(_XPG4_2) 2174typedef struct { 2175 char *dptr; 2176 size_t dsize; 2177} datum; 2178#else 2179typedef struct { 2180 char *dptr; 2181 int dsize; 2182} datum; 2183#endif 2184 2185/* 2186 * Translate NDBM calls into DB calls so that DB doesn't step on the 2187 * application's name space. 2188 */ 2189#define dbm_clearerr(a) __db_ndbm_clearerr(a) 2190#define dbm_close(a) __db_ndbm_close(a) 2191#define dbm_delete(a, b) __db_ndbm_delete(a, b) 2192#define dbm_dirfno(a) __db_ndbm_dirfno(a) 2193#define dbm_error(a) __db_ndbm_error(a) 2194#define dbm_fetch(a, b) __db_ndbm_fetch(a, b) 2195#define dbm_firstkey(a) __db_ndbm_firstkey(a) 2196#define dbm_nextkey(a) __db_ndbm_nextkey(a) 2197#define dbm_open(a, b, c) __db_ndbm_open(a, b, c) 2198#define dbm_pagfno(a) __db_ndbm_pagfno(a) 2199#define dbm_rdonly(a) __db_ndbm_rdonly(a) 2200#define dbm_store(a, b, c, d) \ 2201 __db_ndbm_store(a, b, c, d) 2202 2203/* 2204 * Translate DBM calls into DB calls so that DB doesn't step on the 2205 * application's name space. 2206 * 2207 * The global variables dbrdonly, dirf and pagf were not retained when 4BSD 2208 * replaced the dbm interface with ndbm, and are not supported here. 2209 */ 2210#define dbminit(a) __db_dbm_init(a) 2211#define dbmclose __db_dbm_close 2212#if !defined(__cplusplus) 2213#define delete(a) __db_dbm_delete(a) 2214#endif 2215#define fetch(a) __db_dbm_fetch(a) 2216#define firstkey __db_dbm_firstkey 2217#define nextkey(a) __db_dbm_nextkey(a) 2218#define store(a, b) __db_dbm_store(a, b) 2219 2220/******************************************************* 2221 * Hsearch historic interface. 2222 *******************************************************/ 2223typedef enum { 2224 FIND, ENTER 2225} ACTION; 2226 2227typedef struct entry { 2228 char *key; 2229 char *data; 2230} ENTRY; 2231 2232#define hcreate(a) __db_hcreate(a) 2233#define hdestroy __db_hdestroy 2234#define hsearch(a, b) __db_hsearch(a, b) 2235 2236#endif /* DB_DBM_HSEARCH */ 2237 2238#if defined(__cplusplus) 2239} 2240#endif 2241 2242typedef struct { 2243 AEEApplet a; /* AEEApplet must be listed first. */ 2244 void *db_global_values; 2245} BDBApp; 2246int brew_bdb_begin __P((void)); 2247void brew_bdb_end __P((void)); 2248#endif /* !_DB_H_ */ 2249/* DO NOT EDIT: automatically built by dist/s_apiflags. */ 2250#define DB_AGGRESSIVE 0x00000001 2251#define DB_ARCH_ABS 0x00000001 2252#define DB_ARCH_DATA 0x00000002 2253#define DB_ARCH_LOG 0x00000004 2254#define DB_ARCH_REMOVE 0x00000008 2255#define DB_AUTO_COMMIT 0x00000100 2256#define DB_CDB_ALLDB 0x00000004 2257#define DB_CHKSUM 0x00000004 2258#define DB_CKP_INTERNAL 0x00000002 2259#define DB_CREATE 0x00000001 2260#define DB_CXX_NO_EXCEPTIONS 0x00000002 2261#define DB_DIRECT 0x00000002 2262#define DB_DIRECT_DB 0x00000040 2263#define DB_DSYNC_DB 0x00000080 2264#define DB_DUP 0x00000008 2265#define DB_DUPSORT 0x00000002 2266#define DB_DURABLE_UNKNOWN 0x00000020 2267#define DB_ENCRYPT 0x00000001 2268#define DB_ENCRYPT_AES 0x00000001 2269#define DB_EXCL 0x00000400 2270#define DB_EXTENT 0x00000004 2271#define DB_FAST_STAT 0x00000001 2272#define DB_FCNTL_LOCKING 0x00001000 2273#define DB_FLUSH 0x00000001 2274#define DB_FORCE 0x00000001 2275#define DB_FOREIGN_ABORT 0x00000001 2276#define DB_FOREIGN_CASCADE 0x00000002 2277#define DB_FOREIGN_NULLIFY 0x00000004 2278#define DB_FREELIST_ONLY 0x00000001 2279#define DB_FREE_SPACE 0x00000002 2280#define DB_IGNORE_LEASE 0x00001000 2281#define DB_IMMUTABLE_KEY 0x00000002 2282#define DB_INIT_CDB 0x00000020 2283#define DB_INIT_LOCK 0x00000040 2284#define DB_INIT_LOG 0x00000080 2285#define DB_INIT_MPOOL 0x00000100 2286#define DB_INIT_REP 0x00000200 2287#define DB_INIT_TXN 0x00000400 2288#define DB_INORDER 0x00000010 2289#define DB_JOIN_NOSORT 0x00000001 2290#define DB_LOCKDOWN 0x00000800 2291#define DB_LOCK_NOWAIT 0x00000001 2292#define DB_LOCK_RECORD 0x00000002 2293#define DB_LOCK_SET_TIMEOUT 0x00000004 2294#define DB_LOCK_SWITCH 0x00000008 2295#define DB_LOCK_UPGRADE 0x00000010 2296#define DB_LOG_AUTO_REMOVE 0x00000004 2297#define DB_LOG_CHKPNT 0x00000002 2298#define DB_LOG_COMMIT 0x00000004 2299#define DB_LOG_DIRECT 0x00000001 2300#define DB_LOG_DSYNC 0x00000002 2301#define DB_LOG_IN_MEMORY 0x00000008 2302#define DB_LOG_NOCOPY 0x00000008 2303#define DB_LOG_NOT_DURABLE 0x00000010 2304#define DB_LOG_WRNOSYNC 0x00000020 2305#define DB_LOG_ZERO 0x00000010 2306#define DB_MPOOL_CREATE 0x00000001 2307#define DB_MPOOL_DIRTY 0x00000002 2308#define DB_MPOOL_DISCARD 0x00000001 2309#define DB_MPOOL_EDIT 0x00000004 2310#define DB_MPOOL_FREE 0x00000008 2311#define DB_MPOOL_LAST 0x00000010 2312#define DB_MPOOL_NEW 0x00000020 2313#define DB_MPOOL_NOFILE 0x00000001 2314#define DB_MPOOL_NOLOCK 0x00000002 2315#define DB_MPOOL_UNLINK 0x00000002 2316#define DB_MULTIPLE 0x00002000 2317#define DB_MULTIPLE_KEY 0x00000100 2318#define DB_MULTIVERSION 0x00000008 2319#define DB_MUTEX_ALLOCATED 0x00000001 2320#define DB_MUTEX_LOCKED 0x00000002 2321#define DB_MUTEX_LOGICAL_LOCK 0x00000004 2322#define DB_MUTEX_PROCESS_ONLY 0x00000008 2323#define DB_MUTEX_SELF_BLOCK 0x00000010 2324#define DB_NOLOCKING 0x00000200 2325#define DB_NOMMAP 0x00000010 2326#define DB_NOORDERCHK 0x00000002 2327#define DB_NOPANIC 0x00000400 2328#define DB_NO_AUTO_COMMIT 0x00002000 2329#define DB_ODDFILESIZE 0x00000040 2330#define DB_ORDERCHKONLY 0x00000004 2331#define DB_OVERWRITE 0x00001000 2332#define DB_PANIC_ENVIRONMENT 0x00002000 2333#define DB_PRINTABLE 0x00000008 2334#define DB_PRIVATE 0x00001000 2335#define DB_PR_PAGE 0x00000010 2336#define DB_PR_RECOVERYTEST 0x00000020 2337#define DB_RDONLY 0x00000080 2338#define DB_RDWRMASTER 0x00004000 2339#define DB_READ_COMMITTED 0x00000400 2340#define DB_READ_UNCOMMITTED 0x00000200 2341#define DB_RECNUM 0x00000020 2342#define DB_RECOVER 0x00000010 2343#define DB_RECOVER_FATAL 0x00002000 2344#define DB_REGION_INIT 0x00004000 2345#define DB_REGISTER 0x00004000 2346#define DB_RENUMBER 0x00000040 2347#define DB_REPMGR_CONF_2SITE_STRICT 0x00000001 2348#define DB_REPMGR_PEER 0x00000001 2349#define DB_REP_ANYWHERE 0x00000001 2350#define DB_REP_CLIENT 0x00000001 2351#define DB_REP_CONF_BULK 0x00000002 2352#define DB_REP_CONF_DELAYCLIENT 0x00000004 2353#define DB_REP_CONF_LEASE 0x00000008 2354#define DB_REP_CONF_NOAUTOINIT 0x00000010 2355#define DB_REP_CONF_NOWAIT 0x00000020 2356#define DB_REP_ELECTION 0x00000004 2357#define DB_REP_MASTER 0x00000002 2358#define DB_REP_NOBUFFER 0x00000002 2359#define DB_REP_PERMANENT 0x00000004 2360#define DB_REP_REREQUEST 0x00000008 2361#define DB_REVSPLITOFF 0x00000080 2362#define DB_RMW 0x00000800 2363#define DB_RPCCLIENT 0x00000001 2364#define DB_SALVAGE 0x00000040 2365#define DB_SA_SKIPFIRSTKEY 0x00010000 2366#define DB_SEQ_DEC 0x00000001 2367#define DB_SEQ_INC 0x00000002 2368#define DB_SEQ_RANGE_SET 0x00000004 2369#define DB_SEQ_WRAP 0x00000008 2370#define DB_SEQ_WRAPPED 0x00000010 2371#define DB_SET_LOCK_TIMEOUT 0x00000002 2372#define DB_SET_TXN_NOW 0x00000004 2373#define DB_SET_TXN_TIMEOUT 0x00000001 2374#define DB_SNAPSHOT 0x00000100 2375#define DB_STAT_ALL 0x00000002 2376#define DB_STAT_CLEAR 0x00000001 2377#define DB_STAT_LOCK_CONF 0x00000004 2378#define DB_STAT_LOCK_LOCKERS 0x00000008 2379#define DB_STAT_LOCK_OBJECTS 0x00000010 2380#define DB_STAT_LOCK_PARAMS 0x00000020 2381#define DB_STAT_MEMP_HASH 0x00000004 2382#define DB_STAT_MEMP_NOERROR 0x00000008 2383#define DB_STAT_SUBSYSTEM 0x00000004 2384#define DB_ST_DUPOK 0x00000100 2385#define DB_ST_DUPSET 0x00000200 2386#define DB_ST_DUPSORT 0x00000400 2387#define DB_ST_IS_RECNO 0x00000800 2388#define DB_ST_OVFL_LEAF 0x00001000 2389#define DB_ST_RECNUM 0x00002000 2390#define DB_ST_RELEN 0x00004000 2391#define DB_ST_TOPLEVEL 0x00008000 2392#define DB_SYSTEM_MEM 0x00008000 2393#define DB_THREAD 0x00000004 2394#define DB_TIME_NOTGRANTED 0x00008000 2395#define DB_TRUNCATE 0x00008000 2396#define DB_TXN_NOSYNC 0x00000001 2397#define DB_TXN_NOT_DURABLE 0x00000200 2398#define DB_TXN_NOWAIT 0x00000002 2399#define DB_TXN_SNAPSHOT 0x00000800 2400#define DB_TXN_SYNC 0x00000004 2401#define DB_TXN_WAIT 0x00000008 2402#define DB_TXN_WRITE_NOSYNC 0x00000020 2403#define DB_UNREF 0x00000080 2404#define DB_UPGRADE 0x00000001 2405#define DB_USE_ENVIRON 0x00000002 2406#define DB_USE_ENVIRON_ROOT 0x00000008 2407#define DB_VERB_DEADLOCK 0x00000001 2408#define DB_VERB_FILEOPS 0x00000002 2409#define DB_VERB_FILEOPS_ALL 0x00000004 2410#define DB_VERB_RECOVERY 0x00000008 2411#define DB_VERB_REGISTER 0x00000010 2412#define DB_VERB_REPLICATION 0x00000020 2413#define DB_VERB_REPMGR_CONNFAIL 0x00000040 2414#define DB_VERB_REPMGR_MISC 0x00000080 2415#define DB_VERB_REP_ELECT 0x00000100 2416#define DB_VERB_REP_LEASE 0x00000200 2417#define DB_VERB_REP_MISC 0x00000400 2418#define DB_VERB_REP_MSGS 0x00000800 2419#define DB_VERB_REP_SYNC 0x00001000 2420#define DB_VERB_WAITSFOR 0x00002000 2421#define DB_VERIFY 0x00000002 2422#define DB_WRITEOPEN 0x00010000 2423#define DB_XA_CREATE 0x00000800 2424#define DB_YIELDCPU 0x00010000 2425 2426/* DO NOT EDIT: automatically built by dist/s_include. */ 2427#ifndef _DB_EXT_PROT_IN_ 2428#define _DB_EXT_PROT_IN_ 2429 2430#if defined(__cplusplus) 2431extern "C" { 2432#endif 2433 2434int db_create __P((DB **, DB_ENV *, u_int32_t)); 2435char *db_strerror __P((int)); 2436int db_env_set_func_close __P((int (*)(int))); 2437int db_env_set_func_dirfree __P((void (*)(char **, int))); 2438int db_env_set_func_dirlist __P((int (*)(const char *, char ***, int *))); 2439int db_env_set_func_exists __P((int (*)(const char *, int *))); 2440int db_env_set_func_free __P((void (*)(void *))); 2441int db_env_set_func_fsync __P((int (*)(int))); 2442int db_env_set_func_ftruncate __P((int (*)(int, off_t))); 2443int db_env_set_func_ioinfo __P((int (*)(const char *, int, u_int32_t *, u_int32_t *, u_int32_t *))); 2444int db_env_set_func_malloc __P((void *(*)(size_t))); 2445int db_env_set_func_file_map __P((int (*)(DB_ENV *, char *, size_t, int, void **), int (*)(DB_ENV *, void *))); 2446int db_env_set_func_region_map __P((int (*)(DB_ENV *, char *, size_t, int *, void **), int (*)(DB_ENV *, void *))); 2447int db_env_set_func_pread __P((ssize_t (*)(int, void *, size_t, off_t))); 2448int db_env_set_func_pwrite __P((ssize_t (*)(int, const void *, size_t, off_t))); 2449int db_env_set_func_open __P((int (*)(const char *, int, ...))); 2450int db_env_set_func_read __P((ssize_t (*)(int, void *, size_t))); 2451int db_env_set_func_realloc __P((void *(*)(void *, size_t))); 2452int db_env_set_func_rename __P((int (*)(const char *, const char *))); 2453int db_env_set_func_seek __P((int (*)(int, off_t, int))); 2454int db_env_set_func_unlink __P((int (*)(const char *))); 2455int db_env_set_func_write __P((ssize_t (*)(int, const void *, size_t))); 2456int db_env_set_func_yield __P((int (*)(u_long, u_long))); 2457int db_env_create __P((DB_ENV **, u_int32_t)); 2458char *db_version __P((int *, int *, int *)); 2459int log_compare __P((const DB_LSN *, const DB_LSN *)); 2460int db_sequence_create __P((DB_SEQUENCE **, DB *, u_int32_t)); 2461#if DB_DBM_HSEARCH != 0 2462int __db_ndbm_clearerr __P((DBM *)); 2463void __db_ndbm_close __P((DBM *)); 2464int __db_ndbm_delete __P((DBM *, datum)); 2465int __db_ndbm_dirfno __P((DBM *)); 2466int __db_ndbm_error __P((DBM *)); 2467datum __db_ndbm_fetch __P((DBM *, datum)); 2468datum __db_ndbm_firstkey __P((DBM *)); 2469datum __db_ndbm_nextkey __P((DBM *)); 2470DBM *__db_ndbm_open __P((const char *, int, int)); 2471int __db_ndbm_pagfno __P((DBM *)); 2472int __db_ndbm_rdonly __P((DBM *)); 2473int __db_ndbm_store __P((DBM *, datum, datum, int)); 2474int __db_dbm_close __P((void)); 2475int __db_dbm_delete __P((datum)); 2476datum __db_dbm_fetch __P((datum)); 2477datum __db_dbm_firstkey __P((void)); 2478int __db_dbm_init __P((char *)); 2479datum __db_dbm_nextkey __P((datum)); 2480int __db_dbm_store __P((datum, datum)); 2481#endif 2482#if DB_DBM_HSEARCH != 0 2483int __db_hcreate __P((size_t)); 2484ENTRY *__db_hsearch __P((ENTRY, ACTION)); 2485void __db_hdestroy __P((void)); 2486#endif 2487 2488#if defined(__cplusplus) 2489} 2490#endif 2491#endif /* !_DB_EXT_PROT_IN_ */ 2492