1 /* DO NOT EDIT: automatically built by dist/s_windows. */ 2 /* 3 * Copyright (c) 1996, 2020 Oracle and/or its affiliates. All rights reserved. 4 * 5 * See the file LICENSE for license information. 6 * 7 * $Id$ 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 #ifndef __NO_SYSTEM_INCLUDES 25 #include <sys/types.h> 26 #include <stddef.h> 27 #include <stdio.h> 28 #endif 29 30 /* 31 * Turn off inappropriate compiler warnings 32 */ 33 #ifdef _MSC_VER 34 /* 35 * This warning is explicitly disabled in Visual C++ by default. 36 * It is necessary to explicitly enable the /Wall flag to generate this 37 * warning. 38 * Since this is a shared include file it should compile without warnings 39 * at the highest warning level, so third party applications can use 40 * higher warning levels cleanly. 41 * 42 * 4820: 'bytes' bytes padding added after member 'member' 43 * The type and order of elements caused the compiler to 44 * add padding to the end of a struct. 45 */ 46 #pragma warning(push) 47 #pragma warning(disable: 4820) 48 #endif /* _MSC_VER */ 49 #if defined(__cplusplus) 50 extern "C" { 51 #endif 52 53 54 #undef __P 55 #define __P(protos) protos 56 57 /* 58 * Berkeley DB version information. 59 */ 60 #define DB_VERSION_MAJOR 18 61 #define DB_VERSION_MINOR 1 62 #define DB_VERSION_PATCH 40 63 #define DB_VERSION_STRING "Berkeley DB 18.1.40: (May 29, 2020)" 64 #define DB_VERSION_FULL_STRING "Berkeley DB Release 18.1, library version 18.1.40: (May 29, 2020)" 65 66 /* 67 * These two version numbers are deprecated and will be removed in a future 68 * release. Until that time they are the same as the major and minor numbers. 69 */ 70 #define DB_VERSION_FAMILY 18 71 #define DB_VERSION_RELEASE 1 72 73 /* 74 * !!! 75 * Berkeley DB uses specifically sized types. If they're not provided by 76 * the system, typedef them here. 77 * 78 * We protect them against multiple inclusion using __BIT_TYPES_DEFINED__, 79 * as does BIND and Kerberos, since we don't know for sure what #include 80 * files the user is using. 81 * 82 * !!! 83 * We also provide the standard u_int, u_long etc., if they're not provided 84 * by the system. 85 */ 86 #ifndef __BIT_TYPES_DEFINED__ 87 #define __BIT_TYPES_DEFINED__ 88 typedef unsigned char u_int8_t; 89 typedef short int16_t; 90 typedef unsigned short u_int16_t; 91 typedef int int32_t; 92 typedef unsigned int u_int32_t; 93 typedef __int64 int64_t; 94 typedef unsigned __int64 u_int64_t; 95 #endif 96 97 #ifndef _WINSOCKAPI_ 98 typedef unsigned char u_char; 99 typedef unsigned int u_int; 100 typedef unsigned long u_long; 101 #endif 102 typedef unsigned short u_short; 103 104 /* 105 * Missing ANSI types. 106 * 107 * uintmax_t -- 108 * Largest unsigned type, used to align structures in memory. We don't store 109 * floating point types in structures, so integral types should be sufficient 110 * (and we don't have to worry about systems that store floats in other than 111 * power-of-2 numbers of bytes). Additionally this fixes compilers that rewrite 112 * structure assignments and ANSI C memcpy calls to be in-line instructions 113 * that happen to require alignment. 114 * 115 * uintptr_t -- 116 * Unsigned type that's the same size as a pointer. There are places where 117 * DB modifies pointers by discarding the bottom bits to guarantee alignment. 118 * We can't use uintmax_t, it may be larger than the pointer, and compilers 119 * get upset about that. So far we haven't run on any machine where there's 120 * no unsigned type the same size as a pointer -- here's hoping. 121 */ 122 #if defined(_MSC_VER) && _MSC_VER < 1300 123 typedef u_int32_t uintmax_t; 124 #else 125 typedef u_int64_t uintmax_t; 126 #endif 127 #ifdef _WIN64 128 typedef u_int64_t uintptr_t; 129 #else 130 typedef u_int32_t uintptr_t; 131 #endif 132 133 /* 134 * Windows defines off_t to long (i.e., 32 bits). We need to pass 64-bit 135 * file offsets, so we declare our own. 136 */ 137 #define off_t __db_off_t 138 typedef int64_t off_t; 139 typedef int64_t db_off_t; 140 #define DB_OFF_T_MAX INT64_MAX 141 typedef int32_t pid_t; 142 #ifdef HAVE_MIXED_SIZE_ADDRESSING 143 typedef u_int32_t db_size_t; 144 #else 145 typedef size_t db_size_t; 146 #endif 147 #ifdef _WIN64 148 typedef int64_t ssize_t; 149 #else 150 typedef int32_t ssize_t; 151 #endif 152 #ifdef HAVE_MIXED_SIZE_ADDRESSING 153 typedef int32_t db_ssize_t; 154 #else 155 typedef ssize_t db_ssize_t; 156 #endif 157 158 /* 159 * Sequences are only available on machines with 64-bit integral types. 160 */ 161 typedef int64_t db_seq_t; 162 163 /* Thread and process identification. */ 164 typedef u_int32_t db_threadid_t; 165 166 /* Basic types that are exported or quasi-exported. */ 167 typedef u_int32_t db_pgno_t; /* Page number type. */ 168 typedef u_int16_t db_indx_t; /* Page offset type. */ 169 #define DB_MAX_PAGES 0xffffffff /* >= # of pages in a file */ 170 171 typedef u_int32_t db_recno_t; /* Record number type. */ 172 #define DB_MAX_RECORDS 0xffffffff /* >= # of records in a recno tree. */ 173 174 typedef u_int32_t db_timeout_t; /* Type of a timeout in microseconds. */ 175 176 /* 177 * Region offsets are the difference between a pointer in a region and the 178 * region's base address. With private environments, both addresses are the 179 * result of calling malloc, and we can't assume anything about what malloc 180 * will return, so region offsets have to be able to hold differences between 181 * arbitrary pointers. 182 */ 183 typedef db_size_t roff_t; 184 185 /* 186 * Forward structure declarations, so we can declare pointers and 187 * applications can get type checking. 188 */ 189 struct __channel; typedef struct __channel CHANNEL; 190 struct __db; typedef struct __db DB; 191 struct __db_bt_stat; typedef struct __db_bt_stat DB_BTREE_STAT; 192 struct __db_channel; typedef struct __db_channel DB_CHANNEL; 193 struct __db_cipher; typedef struct __db_cipher DB_CIPHER; 194 struct __db_compact; typedef struct __db_compact DB_COMPACT; 195 struct __db_dbt; typedef struct __db_dbt DBT; 196 struct __db_distab; typedef struct __db_distab DB_DISTAB; 197 struct __db_env; typedef struct __db_env DB_ENV; 198 struct __db_event_mutex_died_info; 199 typedef struct __db_event_mutex_died_info DB_EVENT_MUTEX_DIED_INFO; 200 struct __db_event_failchk_info; 201 typedef struct __db_event_failchk_info DB_EVENT_FAILCHK_INFO; 202 struct __db_h_stat; typedef struct __db_h_stat DB_HASH_STAT; 203 struct __db_heap_rid; typedef struct __db_heap_rid DB_HEAP_RID; 204 struct __db_heap_stat; typedef struct __db_heap_stat DB_HEAP_STAT; 205 struct __db_ilock; typedef struct __db_ilock DB_LOCK_ILOCK; 206 struct __db_lock_hstat; typedef struct __db_lock_hstat DB_LOCK_HSTAT; 207 struct __db_lock_pstat; typedef struct __db_lock_pstat DB_LOCK_PSTAT; 208 struct __db_lock_stat; typedef struct __db_lock_stat DB_LOCK_STAT; 209 struct __db_lock_u; typedef struct __db_lock_u DB_LOCK; 210 struct __db_locker; typedef struct __db_locker DB_LOCKER; 211 struct __db_lockreq; typedef struct __db_lockreq DB_LOCKREQ; 212 struct __db_locktab; typedef struct __db_locktab DB_LOCKTAB; 213 struct __db_log; typedef struct __db_log DB_LOG; 214 struct __db_log_cursor; typedef struct __db_log_cursor DB_LOGC; 215 struct __db_log_stat; typedef struct __db_log_stat DB_LOG_STAT; 216 struct __db_lsn; typedef struct __db_lsn DB_LSN; 217 struct __db_mpool; typedef struct __db_mpool DB_MPOOL; 218 struct __db_mpool_fstat;typedef struct __db_mpool_fstat DB_MPOOL_FSTAT; 219 struct __db_mpool_stat; typedef struct __db_mpool_stat DB_MPOOL_STAT; 220 struct __db_mpoolfile; typedef struct __db_mpoolfile DB_MPOOLFILE; 221 struct __db_mutex_stat; typedef struct __db_mutex_stat DB_MUTEX_STAT; 222 struct __db_mutex_t; typedef struct __db_mutex_t DB_MUTEX; 223 struct __db_mutexmgr; typedef struct __db_mutexmgr DB_MUTEXMGR; 224 struct __db_preplist; typedef struct __db_preplist DB_PREPLIST; 225 struct __db_qam_stat; typedef struct __db_qam_stat DB_QUEUE_STAT; 226 struct __db_rep; typedef struct __db_rep DB_REP; 227 struct __db_rep_stat; typedef struct __db_rep_stat DB_REP_STAT; 228 struct __db_repmgr_conn_err; 229 typedef struct __db_repmgr_conn_err DB_REPMGR_CONN_ERR; 230 struct __db_repmgr_site;typedef struct __db_repmgr_site DB_REPMGR_SITE; 231 struct __db_repmgr_stat;typedef struct __db_repmgr_stat DB_REPMGR_STAT; 232 struct __db_seq_record; typedef struct __db_seq_record DB_SEQ_RECORD; 233 struct __db_seq_stat; typedef struct __db_seq_stat DB_SEQUENCE_STAT; 234 struct __db_stream; typedef struct __db_stream DB_STREAM; 235 struct __db_site; typedef struct __db_site DB_SITE; 236 struct __db_sequence; typedef struct __db_sequence DB_SEQUENCE; 237 struct __db_thread_info;typedef struct __db_thread_info DB_THREAD_INFO; 238 struct __db_txn; typedef struct __db_txn DB_TXN; 239 struct __db_txn_active; typedef struct __db_txn_active DB_TXN_ACTIVE; 240 struct __db_txn_active_slice; 241 typedef struct __db_txn_active_slice DB_TXN_ACTIVE_SLICE; 242 struct __db_txn_stat; typedef struct __db_txn_stat DB_TXN_STAT; 243 struct __db_txn_token; typedef struct __db_txn_token DB_TXN_TOKEN; 244 struct __db_txnmgr; typedef struct __db_txnmgr DB_TXNMGR; 245 struct __dbc; typedef struct __dbc DBC; 246 struct __dbc_internal; typedef struct __dbc_internal DBC_INTERNAL; 247 struct __env; typedef struct __env ENV; 248 struct __fh_t; typedef struct __fh_t DB_FH; 249 struct __fname; typedef struct __fname FNAME; 250 struct __key_range; typedef struct __key_range DB_KEY_RANGE; 251 struct __mpoolfile; typedef struct __mpoolfile MPOOLFILE; 252 struct __db_logvrfy_config; 253 typedef struct __db_logvrfy_config DB_LOG_VERIFY_CONFIG; 254 255 /* 256 * The Berkeley DB API flags are automatically-generated -- the following flag 257 * names are no longer used, but remain for compatibility reasons. 258 */ 259 #define DB_DEGREE_2 DB_READ_COMMITTED 260 #define DB_DIRTY_READ DB_READ_UNCOMMITTED 261 #define DB_JOINENV 0x0 262 263 /* Key/data structure -- a Data-Base Thang. */ 264 struct __db_dbt { 265 void *data; /* Key/data */ 266 u_int32_t size; /* key/data length */ 267 268 u_int32_t ulen; /* RO: length of user buffer. */ 269 u_int32_t dlen; /* RO: get/put record length. */ 270 u_int32_t doff; /* RO: get/put record offset. */ 271 272 void *app_data; 273 274 #define DB_DBT_APPMALLOC 0x0001 /* Callback allocated memory. */ 275 #define DB_DBT_BULK 0x0002 /* Internal: Insert if duplicate. */ 276 #define DB_DBT_DUPOK 0x0004 /* Internal: Insert if duplicate. */ 277 #define DB_DBT_ISSET 0x0008 /* Lower level calls set value. */ 278 #define DB_DBT_MALLOC 0x0010 /* Return in malloc'd memory. */ 279 #define DB_DBT_MULTIPLE 0x0020 /* References multiple records. */ 280 #define DB_DBT_PARTIAL 0x0040 /* Partial put/get. */ 281 #define DB_DBT_REALLOC 0x0080 /* Return in realloc'd memory. */ 282 #define DB_DBT_READONLY 0x0100 /* Readonly, don't update. */ 283 #define DB_DBT_STREAMING 0x0200 /* Internal: DBT is being streamed. */ 284 #define DB_DBT_USERCOPY 0x0400 /* Use the user-supplied callback. */ 285 #define DB_DBT_USERMEM 0x0800 /* Return in user's memory. */ 286 #define DB_DBT_BLOB 0x1000 /* Alias DB_DBT_EXT_FILE. */ 287 #define DB_DBT_EXT_FILE 0x1000 /* Data item is an external file. */ 288 #define DB_DBT_BLOB_REC 0x2000 /* Internal: Blob database record. */ 289 u_int32_t flags; 290 }; 291 292 /******************************************************* 293 * Mutexes. 294 *******************************************************/ 295 /* 296 * When mixed size addressing is supported mutexes need to be the same size 297 * independent of the process address size is. 298 */ 299 #ifdef HAVE_MIXED_SIZE_ADDRESSING 300 typedef db_size_t db_mutex_t; 301 #else 302 typedef uintptr_t db_mutex_t; 303 #endif 304 305 struct __db_mutex_stat { /* SHARED */ 306 /* The following fields are maintained in the region's copy. */ 307 u_int32_t st_mutex_align; /* Mutex alignment */ 308 u_int32_t st_mutex_tas_spins; /* Mutex test-and-set spins */ 309 u_int32_t st_mutex_init; /* Initial mutex count */ 310 u_int32_t st_mutex_cnt; /* Mutex count */ 311 u_int32_t st_mutex_max; /* Mutex max */ 312 u_int32_t st_mutex_free; /* Available mutexes */ 313 u_int32_t st_mutex_inuse; /* Mutexes in use */ 314 u_int32_t st_mutex_inuse_max; /* Maximum mutexes ever in use */ 315 316 /* The following fields are filled-in from other places. */ 317 #ifndef __TEST_DB_NO_STATISTICS 318 uintmax_t st_region_wait; /* Region lock granted after wait. */ 319 uintmax_t st_region_nowait; /* Region lock granted without wait. */ 320 roff_t st_regsize; /* Region size. */ 321 roff_t st_regmax; /* Region max. */ 322 #endif 323 }; 324 325 /* Buffers passed to __mutex_describe() must be at least this large. */ 326 #define DB_MUTEX_DESCRIBE_STRLEN 128 327 328 /* This is the info of a DB_EVENT_MUTEX_DIED event notification. */ 329 struct __db_event_mutex_died_info { 330 pid_t pid; /* Process which last owned the mutex */ 331 db_threadid_t tid; /* Thread which last owned the mutex */ 332 db_mutex_t mutex; /* ID of the mutex */ 333 char desc[DB_MUTEX_DESCRIBE_STRLEN]; 334 }; 335 336 /* This is the info of a DB_EVENT_FAILCHK event notification. */ 337 #define DB_FAILURE_SYMPTOM_SIZE 120 338 struct __db_event_failchk_info { 339 int error; 340 char symptom[DB_FAILURE_SYMPTOM_SIZE]; 341 }; 342 /* This is the length of the buffer passed to DB_ENV->thread_id_string() */ 343 #define DB_THREADID_STRLEN 128 344 345 /* 346 * Type of the number of slices in a sliced environment; also the subscript 347 * into a slice array, such as DB.db_slices[]. 348 */ 349 typedef u_int32_t db_slice_t; 350 351 /******************************************************* 352 * Locking. 353 *******************************************************/ 354 #define DB_LOCKVERSION 1 355 356 #define DB_FILE_ID_LEN 20 /* Unique file ID length. */ 357 358 /* 359 * Deadlock detector modes; used in the DB_ENV structure to configure the 360 * locking subsystem. 361 */ 362 #define DB_LOCK_NORUN 0 363 #define DB_LOCK_DEFAULT 1 /* Default policy. */ 364 #define DB_LOCK_EXPIRE 2 /* Only expire locks, no detection. */ 365 #define DB_LOCK_MAXLOCKS 3 /* Select locker with max locks. */ 366 #define DB_LOCK_MAXWRITE 4 /* Select locker with max writelocks. */ 367 #define DB_LOCK_MINLOCKS 5 /* Select locker with min locks. */ 368 #define DB_LOCK_MINWRITE 6 /* Select locker with min writelocks. */ 369 #define DB_LOCK_OLDEST 7 /* Select oldest locker. */ 370 #define DB_LOCK_RANDOM 8 /* Select random locker. */ 371 #define DB_LOCK_YOUNGEST 9 /* Select youngest locker. */ 372 373 /* 374 * Simple R/W lock modes and for multi-granularity intention locking. 375 * 376 * !!! 377 * These values are NOT random, as they are used as an index into the lock 378 * conflicts arrays, i.e., DB_LOCK_IWRITE must be == 3, and DB_LOCK_IREAD 379 * must be == 4. 380 */ 381 typedef enum { 382 DB_LOCK_NG=0, /* Not granted. */ 383 DB_LOCK_READ=1, /* Shared/read. */ 384 DB_LOCK_WRITE=2, /* Exclusive/write. */ 385 DB_LOCK_WAIT=3, /* Wait for event */ 386 DB_LOCK_IWRITE=4, /* Intent exclusive/write. */ 387 DB_LOCK_IREAD=5, /* Intent to share/read. */ 388 DB_LOCK_IWR=6, /* Intent to read and write. */ 389 DB_LOCK_READ_UNCOMMITTED=7, /* Degree 1 isolation. */ 390 DB_LOCK_WWRITE=8 /* Was Written. */ 391 } db_lockmode_t; 392 393 /* 394 * Request types. 395 */ 396 typedef enum { 397 DB_LOCK_DUMP=0, /* Display held locks. */ 398 DB_LOCK_GET=1, /* Get the lock. */ 399 DB_LOCK_GET_TIMEOUT=2, /* Get lock with a timeout. */ 400 DB_LOCK_INHERIT=3, /* Pass locks to parent. */ 401 DB_LOCK_PUT=4, /* Release the lock. */ 402 DB_LOCK_PUT_ALL=5, /* Release locker's locks. */ 403 DB_LOCK_PUT_OBJ=6, /* Release locker's locks on obj. */ 404 DB_LOCK_PUT_READ=7, /* Release locker's read locks. */ 405 DB_LOCK_TIMEOUT=8, /* Force a txn to timeout. */ 406 DB_LOCK_TRADE=9, /* Trade locker ids on a lock. */ 407 DB_LOCK_UPGRADE_WRITE=10 /* Upgrade writes for dirty reads. */ 408 } db_lockop_t; 409 410 /* 411 * Status of a lock. 412 */ 413 typedef enum { 414 DB_LSTAT_ABORTED=1, /* Lock belongs to an aborted txn. */ 415 DB_LSTAT_EXPIRED=2, /* Lock has expired. */ 416 DB_LSTAT_FREE=3, /* Lock is unallocated. */ 417 DB_LSTAT_HELD=4, /* Lock is currently held. */ 418 DB_LSTAT_PENDING=5, /* Lock was waiting and has been 419 * promoted; waiting for the owner 420 * to run and upgrade it to held. */ 421 DB_LSTAT_WAITING=6 /* Lock is on the wait queue. */ 422 }db_status_t; 423 424 /* Lock statistics structure. */ 425 struct __db_lock_stat { /* SHARED */ 426 u_int32_t st_id; /* Last allocated locker ID. */ 427 u_int32_t st_cur_maxid; /* Current maximum unused ID. */ 428 u_int32_t st_initlocks; /* Initial number of locks in table. */ 429 u_int32_t st_initlockers; /* Initial num of lockers in table. */ 430 u_int32_t st_initobjects; /* Initial num of objects in table. */ 431 u_int32_t st_locks; /* Current number of locks in table. */ 432 u_int32_t st_lockers; /* Current num of lockers in table. */ 433 u_int32_t st_objects; /* Current num of objects in table. */ 434 u_int32_t st_maxlocks; /* Maximum number of locks in table. */ 435 u_int32_t st_maxlockers; /* Maximum num of lockers in table. */ 436 u_int32_t st_maxobjects; /* Maximum num of objects in table. */ 437 u_int32_t st_partitions; /* number of partitions. */ 438 u_int32_t st_tablesize; /* Size of object hash table. */ 439 int32_t st_nmodes; /* Number of lock modes. */ 440 u_int32_t st_nlockers; /* Current number of lockers. */ 441 #ifndef __TEST_DB_NO_STATISTICS 442 u_int32_t st_nlocks; /* Current number of locks. */ 443 u_int32_t st_maxnlocks; /* Maximum number of locks so far. */ 444 u_int32_t st_maxhlocks; /* Maximum number of locks in any bucket. */ 445 uintmax_t st_locksteals; /* Number of lock steals so far. */ 446 uintmax_t st_maxlsteals; /* Maximum number steals in any partition. */ 447 u_int32_t st_maxnlockers; /* Maximum number of lockers so far. */ 448 u_int32_t st_nobjects; /* Current number of objects. */ 449 u_int32_t st_maxnobjects; /* Maximum number of objects so far. */ 450 u_int32_t st_maxhobjects; /* Maximum number of objectsin any bucket. */ 451 uintmax_t st_objectsteals; /* Number of objects steals so far. */ 452 uintmax_t st_maxosteals; /* Maximum number of steals in any partition. */ 453 uintmax_t st_nrequests; /* Number of lock gets. */ 454 uintmax_t st_nreleases; /* Number of lock puts. */ 455 uintmax_t st_nupgrade; /* Number of lock upgrades. */ 456 uintmax_t st_ndowngrade; /* Number of lock downgrades. */ 457 uintmax_t st_lock_wait; /* Lock conflicts w/ subsequent wait */ 458 uintmax_t st_lock_nowait; /* Lock conflicts w/o subsequent wait */ 459 uintmax_t st_ndeadlocks; /* Number of lock deadlocks. */ 460 db_timeout_t st_locktimeout; /* Lock timeout. */ 461 uintmax_t st_nlocktimeouts; /* Number of lock timeouts. */ 462 db_timeout_t st_txntimeout; /* Transaction timeout. */ 463 uintmax_t st_ntxntimeouts; /* Number of transaction timeouts. */ 464 uintmax_t st_part_wait; /* Partition lock granted after wait. */ 465 uintmax_t st_part_nowait; /* Partition lock granted without wait. */ 466 uintmax_t st_part_max_wait; /* Max partition lock granted after wait. */ 467 uintmax_t st_part_max_nowait; /* Max partition lock granted without wait. */ 468 uintmax_t st_objs_wait; /* Object lock granted after wait. */ 469 uintmax_t st_objs_nowait; /* Object lock granted without wait. */ 470 uintmax_t st_lockers_wait; /* Locker lock granted after wait. */ 471 uintmax_t st_lockers_nowait; /* Locker lock granted without wait. */ 472 uintmax_t st_region_wait; /* Region lock granted after wait. */ 473 uintmax_t st_region_nowait; /* Region lock granted without wait. */ 474 uintmax_t st_nlockers_hit; /* Lockers found in thread info. */ 475 uintmax_t st_nlockers_reused; /* Lockers reallocated from thread info. */ 476 u_int32_t st_hash_len; /* Max length of bucket. */ 477 roff_t st_regsize; /* Region size. */ 478 #endif 479 }; 480 481 struct __db_lock_hstat { /* SHARED */ 482 uintmax_t st_nrequests; /* Number of lock gets. */ 483 uintmax_t st_nreleases; /* Number of lock puts. */ 484 uintmax_t st_nupgrade; /* Number of lock upgrades. */ 485 uintmax_t st_ndowngrade; /* Number of lock downgrades. */ 486 u_int32_t st_nlocks; /* Current number of locks. */ 487 u_int32_t st_maxnlocks; /* Maximum number of locks so far. */ 488 u_int32_t st_nobjects; /* Current number of objects. */ 489 u_int32_t st_maxnobjects; /* Maximum number of objects so far. */ 490 uintmax_t st_lock_wait; /* Lock conflicts w/ subsequent wait */ 491 uintmax_t st_lock_nowait; /* Lock conflicts w/o subsequent wait */ 492 uintmax_t st_nlocktimeouts; /* Number of lock timeouts. */ 493 uintmax_t st_ntxntimeouts; /* Number of transaction timeouts. */ 494 u_int32_t st_hash_len; /* Max length of bucket. */ 495 }; 496 497 struct __db_lock_pstat { /* SHARED */ 498 u_int32_t st_nlocks; /* Current number of locks. */ 499 u_int32_t st_maxnlocks; /* Maximum number of locks so far. */ 500 u_int32_t st_nobjects; /* Current number of objects. */ 501 u_int32_t st_maxnobjects; /* Maximum number of objects so far. */ 502 uintmax_t st_locksteals; /* Number of lock steals so far. */ 503 uintmax_t st_objectsteals; /* Number of objects steals so far. */ 504 }; 505 506 /* 507 * DB_LOCK_ILOCK -- 508 * Internal DB access method lock. 509 */ 510 struct __db_ilock { /* SHARED */ 511 db_pgno_t pgno; /* Page being locked. */ 512 u_int8_t fileid[DB_FILE_ID_LEN];/* File id. */ 513 #define DB_HANDLE_LOCK 1 514 #define DB_RECORD_LOCK 2 515 #define DB_PAGE_LOCK 3 516 #define DB_DATABASE_LOCK 4 517 u_int32_t type; /* Type of lock. */ 518 }; 519 520 /* 521 * DB_LOCK -- 522 * The structure is allocated by the caller and filled in during a 523 * lock_get request (or a lock_vec/DB_LOCK_GET). 524 */ 525 struct __db_lock_u { /* SHARED */ 526 roff_t off; /* Offset of the lock in the region */ 527 u_int32_t ndx; /* Index of the object referenced by 528 * this lock; used for locking. */ 529 u_int32_t gen; /* Generation number of this lock. */ 530 db_lockmode_t mode; /* mode of this lock. */ 531 }; 532 533 /* Lock request structure. */ 534 struct __db_lockreq { 535 db_lockop_t op; /* Operation. */ 536 db_lockmode_t mode; /* Requested mode. */ 537 db_timeout_t timeout; /* Time to expire lock. */ 538 DBT *obj; /* Object being locked. */ 539 DB_LOCK lock; /* Lock returned. */ 540 }; 541 542 /******************************************************* 543 * Logging. 544 *******************************************************/ 545 #define DB_LOGVERSION 23 /* Current log version. */ 546 #define DB_LOGVERSION_LATCHING 15 /* Log version using latching: db-4.8 */ 547 #define DB_LOGCHKSUM 12 /* Check sum headers: db-4.5 */ 548 #define DB_LOGOLDVER 8 /* Oldest version supported: db-4.2 */ 549 #define DB_LOGMAGIC 0x040988 550 551 /* 552 * A DB_LSN has two parts, a fileid which identifies a specific file, and an 553 * offset within that file. The fileid is an unsigned 4-byte quantity that 554 * uniquely identifies a file within the log directory -- currently a simple 555 * counter inside the log. The offset is also an unsigned 4-byte value. The 556 * log manager guarantees the offset is never more than 4 bytes by switching 557 * to a new log file before the maximum length imposed by an unsigned 4-byte 558 * offset is reached. 559 */ 560 struct __db_lsn { /* SHARED */ 561 u_int32_t file; /* File ID. */ 562 u_int32_t offset; /* File offset. */ 563 }; 564 565 /* 566 * Application-specified log record types start at DB_user_BEGIN, and must not 567 * equal or exceed DB_debug_FLAG. 568 * 569 * DB_debug_FLAG is the high-bit of the u_int32_t that specifies a log record 570 * type. If the flag is set, it's a log record that was logged for debugging 571 * purposes only, even if it reflects a database change -- the change was part 572 * of a non-durable transaction. 573 */ 574 #define DB_user_BEGIN 10000 575 #define DB_debug_FLAG 0x80000000 576 577 /* 578 * DB_LOGC -- 579 * Log cursor. 580 */ 581 struct __db_log_cursor { 582 ENV *env; /* Environment */ 583 584 DB_FH *fhp; /* File handle. */ 585 DB_LSN lsn; /* Cursor: LSN */ 586 u_int32_t len; /* Cursor: record length */ 587 u_int32_t prev; /* Cursor: previous record's offset */ 588 589 DBT dbt; /* Return DBT. */ 590 DB_LSN p_lsn; /* Persist LSN. */ 591 u_int32_t p_version; /* Persist version. */ 592 593 u_int8_t *bp; /* Allocated read buffer. */ 594 u_int32_t bp_size; /* Read buffer length in bytes. */ 595 u_int32_t bp_rlen; /* Read buffer valid data length. */ 596 DB_LSN bp_lsn; /* Read buffer first byte LSN. */ 597 598 u_int32_t bp_maxrec; /* Max record length in the log file. */ 599 600 /* DB_LOGC PUBLIC HANDLE LIST BEGIN */ 601 int (*close) __P((DB_LOGC *, u_int32_t)); 602 int (*get) __P((DB_LOGC *, DB_LSN *, DBT *, u_int32_t)); 603 int (*version) __P((DB_LOGC *, u_int32_t *, u_int32_t)); 604 /* DB_LOGC PUBLIC HANDLE LIST END */ 605 606 #define DB_LOG_DISK 0x01 /* Log record came from disk. */ 607 #define DB_LOG_LOCKED 0x02 /* Log region already locked */ 608 #define DB_LOG_SILENT_ERR 0x04 /* Turn-off error messages. */ 609 u_int32_t flags; 610 }; 611 612 /* Log statistics structure. */ 613 struct __db_log_stat { /* SHARED */ 614 u_int32_t st_magic; /* Log file magic number. */ 615 u_int32_t st_version; /* Log file version number. */ 616 int32_t st_mode; /* Log file permissions mode. */ 617 u_int32_t st_lg_bsize; /* Log buffer size. */ 618 u_int32_t st_lg_size; /* Log file size. */ 619 u_int32_t st_wc_bytes; /* Bytes to log since checkpoint. */ 620 u_int32_t st_wc_mbytes; /* Megabytes to log since checkpoint. */ 621 u_int32_t st_fileid_init; /* Initial allocation for fileids. */ 622 #ifndef __TEST_DB_NO_STATISTICS 623 u_int32_t st_nfileid; /* Current number of fileids. */ 624 u_int32_t st_maxnfileid; /* Maximum number of fileids used. */ 625 uintmax_t st_record; /* Records entered into the log. */ 626 u_int32_t st_w_bytes; /* Bytes to log. */ 627 u_int32_t st_w_mbytes; /* Megabytes to log. */ 628 uintmax_t st_wcount; /* Total I/O writes to the log. */ 629 uintmax_t st_wcount_fill; /* Overflow writes to the log. */ 630 uintmax_t st_rcount; /* Total I/O reads from the log. */ 631 uintmax_t st_scount; /* Total syncs to the log. */ 632 uintmax_t st_region_wait; /* Region lock granted after wait. */ 633 uintmax_t st_region_nowait; /* Region lock granted without wait. */ 634 u_int32_t st_cur_file; /* Current log file number. */ 635 u_int32_t st_cur_offset; /* Current log file offset. */ 636 u_int32_t st_disk_file; /* Known on disk log file number. */ 637 u_int32_t st_disk_offset; /* Known on disk log file offset. */ 638 u_int32_t st_maxcommitperflush; /* Max number of commits in a flush. */ 639 u_int32_t st_mincommitperflush; /* Min number of commits in a flush. */ 640 roff_t st_regsize; /* Region size. */ 641 #endif 642 }; 643 644 /* 645 * We need to record the first log record of a transaction. For user 646 * defined logging this macro returns the place to put that information, 647 * if it is need in rlsnp, otherwise it leaves it unchanged. We also 648 * need to track the last record of the transaction, this returns the 649 * place to put that info. 650 */ 651 #define DB_SET_TXN_LSNP(txn, blsnp, llsnp) \ 652 ((txn)->set_txn_lsnp(txn, blsnp, llsnp)) 653 654 /* 655 * Definition of the structure which specifies marshalling of log records. 656 */ 657 typedef enum { 658 LOGREC_Done, 659 LOGREC_ARG, 660 LOGREC_HDR, 661 LOGREC_DATA, 662 LOGREC_DB, 663 LOGREC_DBOP, 664 LOGREC_DBT, 665 LOGREC_LOCKS, 666 LOGREC_OP, 667 LOGREC_PGDBT, 668 LOGREC_PGDDBT, 669 LOGREC_PGLIST, 670 LOGREC_POINTER, 671 LOGREC_TIME, 672 LOGREC_LONGARG 673 } log_rec_type_t; 674 675 typedef const struct __log_rec_spec { 676 log_rec_type_t type; 677 u_int32_t offset; 678 const char *name; 679 const char fmt[4]; 680 } DB_LOG_RECSPEC; 681 682 /* 683 * Size of a DBT in a log record. 684 */ 685 #define LOG_DBT_SIZE(dbt) \ 686 (sizeof(u_int32_t) + ((dbt) == NULL ? 0 : (dbt)->size)) 687 688 /******************************************************* 689 * Shared buffer cache (mpool). 690 *******************************************************/ 691 /* Priority values for DB_MPOOLFILE->{put,set_priority}. */ 692 typedef enum { 693 DB_PRIORITY_UNCHANGED=0, 694 DB_PRIORITY_VERY_LOW=1, 695 DB_PRIORITY_LOW=2, 696 DB_PRIORITY_DEFAULT=3, 697 DB_PRIORITY_HIGH=4, 698 DB_PRIORITY_VERY_HIGH=5 699 } DB_CACHE_PRIORITY; 700 701 /* Per-process DB_MPOOLFILE information. */ 702 struct __db_mpoolfile { 703 DB_FH *fhp; /* Underlying file handle. */ 704 705 /* 706 * !!! 707 * The ref, pinref and q fields are protected by the region lock. 708 */ 709 u_int32_t ref; /* Reference count. */ 710 711 u_int32_t pinref; /* Pinned block reference count. */ 712 713 /* 714 * !!! 715 * Explicit representations of structures from queue.h. 716 * TAILQ_ENTRY(__db_mpoolfile) q; 717 */ 718 struct { 719 struct __db_mpoolfile *tqe_next; 720 struct __db_mpoolfile **tqe_prev; 721 } q; /* Linked list of DB_MPOOLFILE's. */ 722 723 /* 724 * !!! 725 * The rest of the fields (with the exception of the MP_FLUSH flag) 726 * are not thread-protected, even when they may be modified at any 727 * time by the application. The reason is the DB_MPOOLFILE handle 728 * is single-threaded from the viewpoint of the application, and so 729 * the only fields needing to be thread-protected are those accessed 730 * by checkpoint or sync threads when using DB_MPOOLFILE structures 731 * to flush buffers from the cache. 732 */ 733 ENV *env; /* Environment */ 734 MPOOLFILE *mfp; /* Underlying MPOOLFILE. */ 735 736 u_int32_t clear_len; /* Cleared length on created pages. */ 737 u_int8_t /* Unique file ID. */ 738 fileid[DB_FILE_ID_LEN]; 739 int ftype; /* File type. */ 740 int32_t lsn_offset; /* LSN offset in page. */ 741 u_int32_t gbytes, bytes; /* Maximum file size. */ 742 DBT *pgcookie; /* Byte-string passed to pgin/pgout. */ 743 int32_t priority; /* Cache priority. */ 744 745 void *addr; /* Address of mmap'd region. */ 746 size_t len; /* Length of mmap'd region. */ 747 748 u_int32_t config_flags; /* Flags to DB_MPOOLFILE->set_flags. */ 749 750 /* DB_MPOOLFILE PUBLIC HANDLE LIST BEGIN */ 751 int (*close) __P((DB_MPOOLFILE *, u_int32_t)); 752 int (*get) 753 __P((DB_MPOOLFILE *, db_pgno_t *, DB_TXN *, u_int32_t, void *)); 754 int (*get_clear_len) __P((DB_MPOOLFILE *, u_int32_t *)); 755 int (*get_fileid) __P((DB_MPOOLFILE *, u_int8_t *)); 756 int (*get_flags) __P((DB_MPOOLFILE *, u_int32_t *)); 757 int (*get_ftype) __P((DB_MPOOLFILE *, int *)); 758 int (*get_last_pgno) __P((DB_MPOOLFILE *, db_pgno_t *)); 759 int (*get_lsn_offset) __P((DB_MPOOLFILE *, int32_t *)); 760 int (*get_maxsize) __P((DB_MPOOLFILE *, u_int32_t *, u_int32_t *)); 761 int (*get_pgcookie) __P((DB_MPOOLFILE *, DBT *)); 762 int (*get_priority) __P((DB_MPOOLFILE *, DB_CACHE_PRIORITY *)); 763 int (*open) __P((DB_MPOOLFILE *, const char *, u_int32_t, int, size_t)); 764 int (*put) __P((DB_MPOOLFILE *, void *, DB_CACHE_PRIORITY, u_int32_t)); 765 int (*set_clear_len) __P((DB_MPOOLFILE *, u_int32_t)); 766 int (*set_fileid) __P((DB_MPOOLFILE *, u_int8_t *)); 767 int (*set_flags) __P((DB_MPOOLFILE *, u_int32_t, int)); 768 int (*set_ftype) __P((DB_MPOOLFILE *, int)); 769 int (*set_lsn_offset) __P((DB_MPOOLFILE *, int32_t)); 770 int (*set_maxsize) __P((DB_MPOOLFILE *, u_int32_t, u_int32_t)); 771 int (*set_pgcookie) __P((DB_MPOOLFILE *, DBT *)); 772 int (*set_priority) __P((DB_MPOOLFILE *, DB_CACHE_PRIORITY)); 773 int (*sync) __P((DB_MPOOLFILE *)); 774 /* DB_MPOOLFILE PUBLIC HANDLE LIST END */ 775 776 /* 777 * MP_FILEID_SET, MP_OPEN_CALLED and MP_READONLY do not need to be 778 * thread protected because they are initialized before the file is 779 * linked onto the per-process lists, and never modified. 780 * 781 * MP_FLUSH is thread protected because it is potentially read/set by 782 * multiple threads of control. 783 */ 784 #define MP_FILEID_SET 0x001 /* Application supplied a file ID. */ 785 #define MP_FLUSH 0x002 /* Was used to flush a buffer. */ 786 #define MP_FOR_FLUSH 0x004 /* Was opened to flush a buffer. */ 787 #define MP_MULTIVERSION 0x008 /* Opened for multiversion access. */ 788 #define MP_OPEN_CALLED 0x010 /* File opened. */ 789 #define MP_READONLY 0x020 /* File is readonly. */ 790 #define MP_DUMMY 0x040 /* File is dummy for __memp_fput. */ 791 u_int32_t flags; 792 }; 793 794 /* Mpool statistics structure. */ 795 struct __db_mpool_stat { /* SHARED */ 796 u_int32_t st_gbytes; /* Total cache size: GB. */ 797 u_int32_t st_bytes; /* Total cache size: B. */ 798 u_int32_t st_ncache; /* Number of cache regions. */ 799 u_int32_t st_max_ncache; /* Maximum number of regions. */ 800 db_size_t st_mmapsize; /* Maximum file size for mmap. */ 801 int32_t st_maxopenfd; /* Maximum number of open fd's. */ 802 int32_t st_maxwrite; /* Maximum buffers to write. */ 803 db_timeout_t st_maxwrite_sleep; /* Sleep after writing max buffers. */ 804 u_int32_t st_pages; /* Total number of pages. */ 805 #ifndef __TEST_DB_NO_STATISTICS 806 u_int32_t st_map; /* Pages from mapped files. */ 807 uintmax_t st_cache_hit; /* Pages found in the cache. */ 808 uintmax_t st_cache_miss; /* Pages not found in the cache. */ 809 uintmax_t st_page_create; /* Pages created in the cache. */ 810 uintmax_t st_page_in; /* Pages read in. */ 811 uintmax_t st_page_out; /* Pages written out. */ 812 uintmax_t st_ro_evict; /* Clean pages forced from the cache. */ 813 uintmax_t st_rw_evict; /* Dirty pages forced from the cache. */ 814 uintmax_t st_page_trickle; /* Pages written by memp_trickle. */ 815 u_int32_t st_page_clean; /* Clean pages. */ 816 u_int32_t st_page_dirty; /* Dirty pages. */ 817 u_int32_t st_hash_buckets; /* Number of hash buckets. */ 818 u_int32_t st_hash_mutexes; /* Number of hash bucket mutexes. */ 819 u_int32_t st_pagesize; /* Assumed page size. */ 820 u_int32_t st_hash_searches; /* Total hash chain searches. */ 821 u_int32_t st_hash_longest; /* Longest hash chain searched. */ 822 uintmax_t st_hash_examined; /* Total hash entries searched. */ 823 uintmax_t st_hash_nowait; /* Hash lock granted with nowait. */ 824 uintmax_t st_hash_wait; /* Hash lock granted after wait. */ 825 uintmax_t st_hash_max_nowait; /* Max hash lock granted with nowait. */ 826 uintmax_t st_hash_max_wait; /* Max hash lock granted after wait. */ 827 uintmax_t st_region_nowait; /* Region lock granted with nowait. */ 828 uintmax_t st_region_wait; /* Region lock granted after wait. */ 829 uintmax_t st_mvcc_frozen; /* Buffers frozen. */ 830 uintmax_t st_mvcc_thawed; /* Buffers thawed. */ 831 uintmax_t st_mvcc_freed; /* Frozen buffers freed. */ 832 uintmax_t st_mvcc_reused; /* Outdated invisible buffers reused. */ 833 uintmax_t st_alloc; /* Number of page allocations. */ 834 uintmax_t st_alloc_buckets; /* Buckets checked during allocation. */ 835 uintmax_t st_alloc_max_buckets;/* Max checked during allocation. */ 836 uintmax_t st_alloc_pages; /* Pages checked during allocation. */ 837 uintmax_t st_alloc_max_pages; /* Max checked during allocation. */ 838 uintmax_t st_io_wait; /* Thread waited on buffer I/O. */ 839 uintmax_t st_sync_interrupted; /* Number of times sync interrupted. */ 840 u_int32_t st_oddfsize_detect; /* Odd file size detected. */ 841 u_int32_t st_oddfsize_resolve; /* Odd file size resolved. */ 842 roff_t st_regsize; /* Region size. */ 843 roff_t st_regmax; /* Region max. */ 844 #endif 845 }; 846 847 /* 848 * Mpool file statistics structure. 849 * The first fields in this structure must mirror the __db_mpool_fstat_int 850 * structure, since content is mem copied between the two. 851 */ 852 struct __db_mpool_fstat { 853 u_int32_t st_pagesize; /* Page size. */ 854 #ifndef __TEST_DB_NO_STATISTICS 855 u_int32_t st_map; /* Pages from mapped files. */ 856 uintmax_t st_cache_hit; /* Pages found in the cache. */ 857 uintmax_t st_cache_miss; /* Pages not found in the cache. */ 858 uintmax_t st_page_create; /* Pages created in the cache. */ 859 uintmax_t st_page_in; /* Pages read in. */ 860 uintmax_t st_page_out; /* Pages written out. */ 861 uintmax_t st_backup_spins; /* Number of spins during a copy. */ 862 #endif 863 char *file_name; /* File name. */ 864 }; 865 866 /******************************************************* 867 * Transactions and recovery. 868 *******************************************************/ 869 #define DB_TXNVERSION 1 870 871 typedef enum { 872 DB_TXN_ABORT=0, /* Public. */ 873 DB_TXN_APPLY=1, /* Public. */ 874 DB_TXN_BACKWARD_ROLL=3, /* Public. */ 875 DB_TXN_FORWARD_ROLL=4, /* Public. */ 876 DB_TXN_OPENFILES=5, /* Internal. */ 877 DB_TXN_POPENFILES=6, /* Internal. */ 878 DB_TXN_PRINT=7, /* Public. */ 879 DB_TXN_LOG_VERIFY=8 /* Internal. */ 880 } db_recops; 881 882 /* 883 * BACKWARD_ALLOC is used during the forward pass to pick up any aborted 884 * allocations for files that were created during the forward pass. 885 * The main difference between _ALLOC and _ROLL is that the entry for 886 * the file not exist during the rollforward pass. 887 */ 888 #define DB_UNDO(op) ((op) == DB_TXN_ABORT || (op) == DB_TXN_BACKWARD_ROLL) 889 #define DB_REDO(op) ((op) == DB_TXN_FORWARD_ROLL || (op) == DB_TXN_APPLY) 890 891 struct __db_txn { 892 DB_TXNMGR *mgrp; /* Pointer to transaction manager. */ 893 DB_TXN *parent; /* Pointer to transaction's parent. */ 894 DB_THREAD_INFO *thread_info; /* Pointer to thread information. */ 895 896 u_int32_t cursors; /* Number of cursors open for txn */ 897 898 u_int32_t txnid; /* Unique transaction id. */ 899 char *name; /* Transaction name. */ 900 DB_LOCKER *locker; /* Locker for this txn. */ 901 902 void *td; /* Detail structure within region. */ 903 db_timeout_t lock_timeout; /* Timeout for locks for this txn. */ 904 void *txn_list; /* Undo information for parent. */ 905 906 907 /* 908 * Txn_slices is __os_calloc'd with one potential entry for each 909 * slice. DML is allowed to set only one entry. DDL can have one per 910 * slice, but does not (in V1) guarantee atomicity between those txns. 911 */ 912 DB_TXN **txn_slices; /* Txns for this container's slices. */ 913 DB_TXN *txn_container; /* Container of this slice. */ 914 915 /* 916 * !!! 917 * Explicit representations of structures from queue.h. 918 * TAILQ_ENTRY(__db_txn) links; 919 */ 920 struct { 921 struct __db_txn *tqe_next; 922 struct __db_txn **tqe_prev; 923 } links; /* Links transactions off manager. */ 924 925 /* 926 * !!! 927 * Explicit representations of structures from shqueue.h. 928 * SH_TAILQ_ENTRY xa_links; 929 * These links link together transactions that are active in 930 * the same thread of control. 931 */ 932 struct { 933 db_ssize_t stqe_next; 934 db_ssize_t stqe_prev; 935 } xa_links; /* Links XA transactions. */ 936 937 /* 938 * !!! 939 * Explicit representations of structures from queue.h. 940 * TAILQ_HEAD(__kids, __db_txn) kids; 941 */ 942 struct __kids { 943 struct __db_txn *tqh_first; 944 struct __db_txn **tqh_last; 945 } kids; 946 947 /* 948 * !!! 949 * Explicit representations of structures from queue.h. 950 * TAILQ_HEAD(__events, __txn_event) events; 951 */ 952 struct { 953 struct __txn_event *tqh_first; 954 struct __txn_event **tqh_last; 955 } events; /* Links deferred events. */ 956 957 /* 958 * !!! 959 * Explicit representations of structures from queue.h. 960 * STAILQ_HEAD(__logrec, __txn_logrec) logs; 961 */ 962 struct { 963 struct __txn_logrec *stqh_first; 964 struct __txn_logrec **stqh_last; 965 } logs; /* Links in memory log records. */ 966 967 /* 968 * !!! 969 * Explicit representations of structures from queue.h. 970 * TAILQ_ENTRY(__db_txn) klinks; 971 */ 972 struct { 973 struct __db_txn *tqe_next; 974 struct __db_txn **tqe_prev; 975 } klinks; /* Links of children in parent. */ 976 977 /* 978 * !!! 979 * Explicit representations of structures from queue.h. 980 * TAILQ_HEAD(__my_cursors, __dbc) my_cursors; 981 */ 982 struct __my_cursors { 983 struct __dbc *tqh_first; 984 struct __dbc **tqh_last; 985 } my_cursors; 986 987 /* 988 * !!! 989 * Explicit representations of structures from queue.h. 990 * TAILQ_HEAD(__femfs, MPOOLFILE) femfs; 991 * 992 * These are DBs involved in file extension in this transaction. 993 */ 994 struct __femfs { 995 DB *tqh_first; 996 DB **tqh_last; 997 } femfs; 998 999 DB_TXN_TOKEN *token_buffer; /* User's commit token buffer. */ 1000 void *api_internal; /* C++ API private. */ 1001 void *xml_internal; /* XML API private. */ 1002 1003 /* DB_TXN PUBLIC HANDLE LIST BEGIN */ 1004 int (*abort) __P((DB_TXN *)); 1005 int (*commit) __P((DB_TXN *, u_int32_t)); 1006 int (*discard) __P((DB_TXN *, u_int32_t)); 1007 int (*get_name) __P((DB_TXN *, const char **)); 1008 int (*get_priority) __P((DB_TXN *, u_int32_t *)); 1009 u_int32_t (*id) __P((DB_TXN *)); 1010 int (*prepare) __P((DB_TXN *, u_int8_t *)); 1011 int (*set_commit_token) __P((DB_TXN *, DB_TXN_TOKEN *)); 1012 int (*set_name) __P((DB_TXN *, const char *)); 1013 int (*set_priority) __P((DB_TXN *, u_int32_t)); 1014 int (*set_timeout) __P((DB_TXN *, db_timeout_t, u_int32_t)); 1015 /* DB_TXN PUBLIC HANDLE LIST END */ 1016 1017 /* DB_TXN PRIVATE HANDLE LIST BEGIN */ 1018 void (*set_txn_lsnp) __P((DB_TXN *txn, DB_LSN **, DB_LSN **)); 1019 /* DB_TXN PRIVATE HANDLE LIST END */ 1020 1021 #define TXN_XA_THREAD_NOTA 0 1022 #define TXN_XA_THREAD_ASSOCIATED 1 1023 #define TXN_XA_THREAD_SUSPENDED 2 1024 #define TXN_XA_THREAD_UNASSOCIATED 3 1025 u_int32_t xa_thr_status; 1026 1027 #define TXN_CHILDCOMMIT 0x00001 /* Txn has committed. */ 1028 #define TXN_DISPATCH 0x00002 /* Internal; use for __db_dispatch(). */ 1029 #define TXN_DEADLOCK 0x00004 /* Txn has deadlocked. */ 1030 #define TXN_FAMILY 0x00008 /* Cursors/children are independent. */ 1031 #define TXN_IGNORE_LEASE 0x00010 /* Skip lease check at commit time. */ 1032 #define TXN_INFAMILY 0x00020 /* Part of a transaction family. */ 1033 #define TXN_LOCKTIMEOUT 0x00040 /* Txn has a lock timeout. */ 1034 #define TXN_MALLOC 0x00080 /* Structure allocated by TXN system. */ 1035 #define TXN_NOSYNC 0x00100 /* Do not sync on prepare and commit. */ 1036 #define TXN_NOWAIT 0x00200 /* Do not wait on locks. */ 1037 #define TXN_PRIVATE 0x00400 /* Txn owned by cursor. */ 1038 #define TXN_READONLY 0x00800 /* CDS group handle. */ 1039 #define TXN_READ_COMMITTED 0x01000 /* Txn has degree 2 isolation. */ 1040 #define TXN_READ_UNCOMMITTED 0x02000 /* Txn has degree 1 isolation. */ 1041 #define TXN_RESTORED 0x04000 /* Txn has been restored. */ 1042 #define TXN_SNAPSHOT 0x08000 /* Snapshot Isolation. */ 1043 #define TXN_SYNC 0x10000 /* Write and sync on prepare/commit. */ 1044 #define TXN_WRITE_NOSYNC 0x20000 /* Write only on prepare/commit. */ 1045 #define TXN_BULK 0x40000 /* Enable bulk loading optimization. */ 1046 u_int32_t flags; 1047 1048 u_int32_t begin_flags; /* Saved by txn_begin(), for slices. */ 1049 }; 1050 1051 #define TXN_SYNC_FLAGS (TXN_SYNC | TXN_NOSYNC | TXN_WRITE_NOSYNC) 1052 1053 /* 1054 * Structure used for two phase commit interface. 1055 * We set the size of our global transaction id (gid) to be 128 in order 1056 * to match that defined by the XA X/Open standard. 1057 */ 1058 #define DB_GID_SIZE 128 1059 struct __db_preplist { 1060 DB_TXN *txn; 1061 u_int8_t gid[DB_GID_SIZE]; 1062 }; 1063 1064 /* 1065 * Active transaction statistics for slices. 1066 * If a container's transaction touches any slices, its TXN_DETAIL.slice_details 1067 * has a DB_ENV->slice_cnt sized array in shared memory of these. Entries whose 1068 * txnid is not TXN_INVALID are active. The slice number is implied by the 1069 * position in the array. 1070 */ 1071 struct __db_txn_active_slice { 1072 u_int32_t txnid; /* Txnid in that slice */ 1073 }; 1074 1075 /* Active transaction statistics structure. */ 1076 struct __db_txn_active { 1077 u_int32_t txnid; /* Transaction ID */ 1078 u_int32_t parentid; /* Transaction ID of parent */ 1079 pid_t pid; /* Process owning txn ID */ 1080 db_threadid_t tid; /* Thread owning txn ID */ 1081 1082 DB_LSN lsn; /* LSN when transaction began */ 1083 1084 DB_LSN read_lsn; /* Read LSN for MVCC */ 1085 u_int32_t mvcc_ref; /* MVCC reference count */ 1086 1087 u_int32_t priority; /* Deadlock resolution priority */ 1088 1089 #define TXN_ABORTED 1 1090 #define TXN_COMMITTED 2 1091 #define TXN_NEED_ABORT 3 1092 #define TXN_PREPARED 4 1093 #define TXN_RUNNING 5 1094 u_int32_t status; /* Status of the transaction */ 1095 1096 #define TXN_XA_ACTIVE 1 1097 #define TXN_XA_DEADLOCKED 2 1098 #define TXN_XA_IDLE 3 1099 #define TXN_XA_PREPARED 4 1100 #define TXN_XA_ROLLEDBACK 5 1101 u_int32_t xa_status; /* XA status */ 1102 1103 u_int8_t gid[DB_GID_SIZE]; /* Global transaction ID */ 1104 char name[51]; /* 50 bytes of name, nul termination */ 1105 1106 /* 1107 * This array of txnids can either be NULL, or it is a 1108 * DB_ENV->get_slice_count()-sized array. Any slices which have active 1109 * subordinate transactions have non-empty entries. 1110 */ 1111 DB_TXN_ACTIVE_SLICE *slice_txns; 1112 }; 1113 1114 struct __db_txn_stat { 1115 u_int32_t st_nrestores; /* number of restored transactions 1116 after recovery. */ 1117 #ifndef __TEST_DB_NO_STATISTICS 1118 DB_LSN st_last_ckp; /* lsn of the last checkpoint */ 1119 time_t st_time_ckp; /* time of last checkpoint */ 1120 u_int32_t st_last_txnid; /* last transaction id given out */ 1121 u_int32_t st_inittxns; /* inital txns allocated */ 1122 u_int32_t st_maxtxns; /* maximum txns possible */ 1123 uintmax_t st_naborts; /* number of aborted transactions */ 1124 uintmax_t st_nbegins; /* number of begun transactions */ 1125 uintmax_t st_ncommits; /* number of committed transactions */ 1126 u_int32_t st_nactive; /* number of active transactions */ 1127 u_int32_t st_nsnapshot; /* number of snapshot transactions */ 1128 u_int32_t st_maxnactive; /* maximum active transactions */ 1129 u_int32_t st_maxnsnapshot; /* maximum snapshot transactions */ 1130 uintmax_t st_region_wait; /* Region lock granted after wait. */ 1131 uintmax_t st_region_nowait; /* Region lock granted without wait. */ 1132 roff_t st_regsize; /* Region size. */ 1133 DB_TXN_ACTIVE *st_txnarray; /* array of active transactions */ 1134 #endif 1135 }; 1136 1137 #define DB_TXN_TOKEN_SIZE 20 1138 struct __db_txn_token { 1139 u_int8_t buf[DB_TXN_TOKEN_SIZE]; 1140 }; 1141 1142 /******************************************************* 1143 * Replication. 1144 *******************************************************/ 1145 /* Special, out-of-band environment IDs. */ 1146 #define DB_EID_BROADCAST -1 1147 #define DB_EID_INVALID -2 1148 #define DB_EID_MASTER -3 1149 1150 #define DB_REP_DEFAULT_PRIORITY 100 1151 1152 /* Acknowledgement policies; 0 reserved as OOB. */ 1153 #define DB_REPMGR_ACKS_ALL 1 1154 #define DB_REPMGR_ACKS_ALL_AVAILABLE 2 1155 #define DB_REPMGR_ACKS_ALL_PEERS 3 1156 #define DB_REPMGR_ACKS_NONE 4 1157 #define DB_REPMGR_ACKS_ONE 5 1158 #define DB_REPMGR_ACKS_ONE_PEER 6 1159 #define DB_REPMGR_ACKS_QUORUM 7 1160 1161 /* Configuration options for SSL support for Replication Manager */ 1162 #define DB_REPMGR_SSL_CA_CERT 1 /* CA Cert Location */ 1163 #define DB_REPMGR_SSL_CA_DIR 2 /* CA Cert Directory */ 1164 #define DB_REPMGR_SSL_REPNODE_CERT 3 /* RepNode Cert for auth */ 1165 #define DB_REPMGR_SSL_REPNODE_PRIVATE_KEY 4 /* Repnode Cert Private key */ 1166 #define DB_REPMGR_SSL_REPNODE_KEY_PASSWD 5 /* Password for Private key */ 1167 #define DB_REPMGR_SSL_VERIFY_DEPTH 6 /* SSL verification depth */ 1168 1169 /* Replication timeout configuration values. */ 1170 #define DB_REP_ACK_TIMEOUT 1 /* RepMgr acknowledgements. */ 1171 #define DB_REP_CHECKPOINT_DELAY 2 /* Master checkpoint delay. */ 1172 #define DB_REP_CONNECTION_RETRY 3 /* RepMgr connections. */ 1173 #define DB_REP_ELECTION_RETRY 4 /* RepMgr elect retries. */ 1174 #define DB_REP_ELECTION_TIMEOUT 5 /* Rep normal elections. */ 1175 #define DB_REP_FULL_ELECTION_TIMEOUT 6 /* Rep full elections. */ 1176 #define DB_REP_HEARTBEAT_MONITOR 7 /* RepMgr client HB monitor. */ 1177 #define DB_REP_HEARTBEAT_SEND 8 /* RepMgr master send freq. */ 1178 #define DB_REP_LEASE_TIMEOUT 9 /* Master leases. */ 1179 #define DB_REP_WRITE_FORWARD_TIMEOUT 10 /* Write forwarding. */ 1180 1181 /* 1182 * Event notification types. (Tcl testing interface currently assumes there are 1183 * no more than 32 of these.). Comments include any relevant event_info types. 1184 */ 1185 #define DB_EVENT_PANIC 0 1186 #define DB_EVENT_REG_ALIVE 1 /* int: pid which was in env */ 1187 #define DB_EVENT_REG_PANIC 2 /* int: error causing the panic. */ 1188 #define DB_EVENT_REP_AUTOTAKEOVER 3 1189 #define DB_EVENT_REP_AUTOTAKEOVER_FAILED 4 1190 #define DB_EVENT_REP_CLIENT 5 1191 #define DB_EVENT_REP_CONNECT_BROKEN 6 /* DB_REPMGR_CONN_ERR */ 1192 #define DB_EVENT_REP_CONNECT_ESTD 7 /* int: EID of remote site */ 1193 #define DB_EVENT_REP_CONNECT_TRY_FAILED 8 /* DB_REPMGR_CONN_ERR */ 1194 #define DB_EVENT_REP_DUPMASTER 9 1195 #define DB_EVENT_REP_ELECTED 10 1196 #define DB_EVENT_REP_ELECTION_FAILED 11 1197 #define DB_EVENT_REP_INIT_DONE 12 1198 #define DB_EVENT_REP_INQUEUE_FULL 13 1199 #define DB_EVENT_REP_JOIN_FAILURE 14 1200 #define DB_EVENT_REP_LOCAL_SITE_REMOVED 15 1201 #define DB_EVENT_REP_MASTER 16 1202 #define DB_EVENT_REP_MASTER_FAILURE 17 1203 #define DB_EVENT_REP_NEWMASTER 18 /* int: new master's site id */ 1204 #define DB_EVENT_REP_PERM_FAILED 19 1205 #define DB_EVENT_REP_SITE_ADDED 20 /* int: eid */ 1206 #define DB_EVENT_REP_SITE_REMOVED 21 /* int: eid */ 1207 #define DB_EVENT_REP_STARTUPDONE 22 1208 #define DB_EVENT_REP_WOULD_ROLLBACK 23 /* Undocumented; C API only. */ 1209 #define DB_EVENT_WRITE_FAILED 24 1210 #define DB_EVENT_MUTEX_DIED 25 /* DB_EVENT_MUTEX_DIED_INFO */ 1211 #define DB_EVENT_FAILCHK_PANIC 26 /* DB_EVENT_FAILCHK_INFO */ 1212 #define DB_EVENT_NO_SUCH_EVENT 0xffffffff /* OOB sentinel value */ 1213 1214 /* Supported network event polling methods */ 1215 typedef enum { 1216 SELECT=1, 1217 POLL=2, 1218 EPOLL=3 1219 } poll_method_t; 1220 1221 #if defined(HAVE_EPOLL_CREATE) && defined(HAVE_EPOLL_CTL) && defined(HAVE_EPOLL_WAIT) 1222 #define HAVE_EPOLL 1 1223 #endif 1224 1225 /* Replication Manager site status. */ 1226 struct __db_repmgr_site { 1227 int eid; 1228 char *host; 1229 u_int port; 1230 DB_LSN max_ack_lsn; 1231 1232 #define DB_REPMGR_CONNECTED 1 1233 #define DB_REPMGR_DISCONNECTED 2 1234 u_int32_t status; 1235 1236 #define DB_REPMGR_ISELECTABLE 0x01 1237 #define DB_REPMGR_ISPEER 0x02 1238 #define DB_REPMGR_ISVIEW 0x04 1239 u_int32_t flags; 1240 }; 1241 1242 /* Replication statistics. */ 1243 struct __db_rep_stat { /* SHARED */ 1244 /* !!! 1245 * Many replication statistics fields cannot be protected by a mutex 1246 * without an unacceptable performance penalty, since most message 1247 * processing is done without the need to hold a region-wide lock. 1248 * Fields whose comments end with a '+' may be updated without holding 1249 * the replication or log mutexes (as appropriate), and thus may be 1250 * off somewhat (or, on unreasonable architectures under unlucky 1251 * circumstances, garbaged). 1252 */ 1253 u_int32_t st_startup_complete; /* Site completed client sync-up. */ 1254 u_int32_t st_view; /* Site is a view. */ 1255 #ifndef __TEST_DB_NO_STATISTICS 1256 uintmax_t st_log_queued; /* Log records currently queued.+ */ 1257 u_int32_t st_status; /* Current replication status. */ 1258 DB_LSN st_next_lsn; /* Next LSN to use or expect. */ 1259 DB_LSN st_waiting_lsn; /* LSN we're awaiting, if any. */ 1260 DB_LSN st_max_perm_lsn; /* Maximum permanent LSN. */ 1261 db_pgno_t st_next_pg; /* Next pg we expect. */ 1262 db_pgno_t st_waiting_pg; /* pg we're awaiting, if any. */ 1263 1264 u_int32_t st_dupmasters; /* # of times a duplicate master 1265 condition was detected.+ */ 1266 db_ssize_t st_env_id; /* Current environment ID. */ 1267 u_int32_t st_env_priority; /* Current environment priority. */ 1268 uintmax_t st_ext_duplicated; /* Dup ext file data messages.+ */ 1269 uintmax_t st_ext_records; /* # of ext file data messages.+ */ 1270 uintmax_t st_ext_rereq; /* Ext file chunk re-requests.+ */ 1271 uintmax_t st_ext_update_rereq; /* Ext file update re-requests. + */ 1272 uintmax_t st_bulk_fills; /* Bulk buffer fills. */ 1273 uintmax_t st_bulk_overflows; /* Bulk buffer overflows. */ 1274 uintmax_t st_bulk_records; /* Bulk records stored. */ 1275 uintmax_t st_bulk_transfers; /* Transfers of bulk buffers. */ 1276 uintmax_t st_client_rerequests;/* Number of forced rerequests. */ 1277 uintmax_t st_client_svc_req; /* Number of client service requests 1278 received by this client. */ 1279 uintmax_t st_client_svc_miss; /* Number of client service requests 1280 missing on this client. */ 1281 u_int32_t st_gen; /* Current generation number. */ 1282 u_int32_t st_egen; /* Current election gen number. */ 1283 uintmax_t st_lease_chk; /* Lease validity checks. */ 1284 uintmax_t st_lease_chk_misses; /* Lease checks invalid. */ 1285 uintmax_t st_lease_chk_refresh; /* Lease refresh attempts. */ 1286 uintmax_t st_lease_sends; /* Lease messages sent live. */ 1287 1288 uintmax_t st_log_duplicated; /* Log records received multiply.+ */ 1289 uintmax_t st_log_queued_max; /* Max. log records queued at once.+ */ 1290 uintmax_t st_log_queued_total; /* Total # of log recs. ever queued.+ */ 1291 uintmax_t st_log_records; /* Log records received and put.+ */ 1292 uintmax_t st_log_requested; /* Log recs. missed and requested.+ */ 1293 db_ssize_t st_master; /* Env. ID of the current master. */ 1294 uintmax_t st_master_changes; /* # of times we've switched masters. */ 1295 uintmax_t st_msgs_badgen; /* Messages with a bad generation #.+ */ 1296 uintmax_t st_msgs_processed; /* Messages received and processed.+ */ 1297 uintmax_t st_msgs_recover; /* Messages ignored because this site 1298 was a client in recovery.+ */ 1299 uintmax_t st_msgs_send_failures;/* # of failed message sends.+ */ 1300 uintmax_t st_msgs_sent; /* # of successful message sends.+ */ 1301 uintmax_t st_newsites; /* # of NEWSITE msgs. received.+ */ 1302 u_int32_t st_nsites; /* Current number of sites we will 1303 assume during elections. */ 1304 uintmax_t st_nthrottles; /* # of times we were throttled. */ 1305 uintmax_t st_outdated; /* # of times we detected and returned 1306 an OUTDATED condition.+ */ 1307 uintmax_t st_pg_duplicated; /* Pages received multiply.+ */ 1308 uintmax_t st_pg_records; /* Pages received and stored.+ */ 1309 uintmax_t st_pg_requested; /* Pages missed and requested.+ */ 1310 uintmax_t st_txns_applied; /* # of transactions applied.+ */ 1311 uintmax_t st_startsync_delayed;/* # of STARTSYNC msgs delayed.+ */ 1312 1313 /* Elections generally. */ 1314 uintmax_t st_elections; /* # of elections held.+ */ 1315 uintmax_t st_elections_won; /* # of elections won by this site.+ */ 1316 1317 /* Statistics about an in-progress election. */ 1318 db_ssize_t st_election_cur_winner; /* Current front-runner. */ 1319 u_int32_t st_election_gen; /* Election generation number. */ 1320 u_int32_t st_election_datagen; /* Election data generation number. */ 1321 DB_LSN st_election_lsn; /* Max. LSN of current winner. */ 1322 u_int32_t st_election_nsites; /* # of "registered voters". */ 1323 u_int32_t st_election_nvotes; /* # of "registered voters" needed. */ 1324 u_int32_t st_election_priority; /* Current election priority. */ 1325 int32_t st_election_status; /* Current election status. */ 1326 u_int32_t st_election_tiebreaker;/* Election tiebreaker value. */ 1327 u_int32_t st_election_votes; /* Votes received in this round. */ 1328 u_int32_t st_election_sec; /* Last election time seconds. */ 1329 u_int32_t st_election_usec; /* Last election time useconds. */ 1330 u_int32_t st_max_lease_sec; /* Maximum lease timestamp seconds. */ 1331 u_int32_t st_max_lease_usec; /* Maximum lease timestamp useconds. */ 1332 1333 /* Undocumented statistics only used by the test system. */ 1334 #ifdef CONFIG_TEST 1335 uintmax_t st_ext_deleted; /* Ext files deleted during II.+ */ 1336 uintmax_t st_ext_truncated; /* Ext files shortened during II.+ */ 1337 u_int32_t st_filefail_cleanups; /* # of FILE_FAIL cleanups done. */ 1338 uintmax_t st_log_futuredup; /* Future log records that are dups. */ 1339 #endif 1340 #endif 1341 }; 1342 1343 /* Replication Manager statistics. */ 1344 struct __db_repmgr_stat { /* SHARED */ 1345 uintmax_t st_perm_failed; /* # of insufficiently ack'ed msgs. */ 1346 uintmax_t st_msgs_queued; /* # msgs queued for network delay. */ 1347 uintmax_t st_msgs_dropped; /* # msgs discarded due to excessive 1348 queue length. */ 1349 u_int32_t st_incoming_queue_gbytes; /* Incoming queue size: GB. */ 1350 u_int32_t st_incoming_queue_bytes; /* Incoming queue size: B. */ 1351 uintmax_t st_incoming_msgs_dropped; /* # of msgs discarded due to 1352 incoming queue full. */ 1353 uintmax_t st_connection_drop; /* Existing connections dropped. */ 1354 uintmax_t st_connect_fail; /* Failed new connection attempts. */ 1355 u_int32_t st_elect_threads; /* # of active election threads. */ 1356 u_int32_t st_group_stable_log_file; /* Earliest log file still 1357 needed by repgroup. */ 1358 u_int32_t st_max_elect_threads; /* Max concurrent e-threads ever. */ 1359 u_int32_t st_site_participants; /* # of repgroup participant sites. */ 1360 u_int32_t st_site_total; /* # of repgroup total sites. */ 1361 u_int32_t st_site_views; /* # of repgroup view sites. */ 1362 u_int32_t st_polling_method; /* 1=select, 2=poll, 3=epoll. */ 1363 uintmax_t st_takeovers; /* # of automatic listener takeovers. */ 1364 uintmax_t st_write_ops_forwarded; /* # of writes forwarded by 1365 this client. */ 1366 uintmax_t st_write_ops_received; /* # of forwarded writes 1367 received by this master. */ 1368 }; 1369 1370 /* Replication Manager connection error. */ 1371 struct __db_repmgr_conn_err { 1372 int eid; /* Replication Environment ID. */ 1373 int error; /* System networking error code. */ 1374 }; 1375 1376 /* Replication Manager socket. */ 1377 #include <winsock2.h> 1378 typedef SOCKET DB_REPMGR_SOCKET; 1379 1380 /******************************************************* 1381 * Sequences. 1382 *******************************************************/ 1383 /* 1384 * The storage record for a sequence. 1385 */ 1386 struct __db_seq_record { 1387 u_int32_t seq_version; /* Version size/number. */ 1388 u_int32_t flags; /* DB_SEQ_XXX Flags. */ 1389 db_seq_t seq_value; /* Current value. */ 1390 db_seq_t seq_max; /* Max permitted. */ 1391 db_seq_t seq_min; /* Min permitted. */ 1392 }; 1393 1394 /* 1395 * Handle for a sequence object. 1396 */ 1397 struct __db_sequence { 1398 DB *seq_dbp; /* DB handle for this sequence. */ 1399 db_mutex_t mtx_seq; /* Mutex if sequence is threaded. */ 1400 DB_SEQ_RECORD *seq_rp; /* Pointer to current data. */ 1401 DB_SEQ_RECORD seq_record; /* Data from DB_SEQUENCE. */ 1402 u_int32_t seq_cache_size; /* Number of values cached. */ 1403 db_seq_t seq_last_value; /* Last value cached. */ 1404 db_seq_t seq_prev_value; /* Last value returned. */ 1405 DBT seq_key; /* DBT pointing to sequence key. */ 1406 DBT seq_data; /* DBT pointing to seq_record. */ 1407 1408 /* API-private structure: used by C++ and Java. */ 1409 void *api_internal; 1410 1411 /* DB_SEQUENCE PUBLIC HANDLE LIST BEGIN */ 1412 int (*close) __P((DB_SEQUENCE *, u_int32_t)); 1413 int (*get) __P((DB_SEQUENCE *, 1414 DB_TXN *, u_int32_t, db_seq_t *, u_int32_t)); 1415 int (*get_cachesize) __P((DB_SEQUENCE *, u_int32_t *)); 1416 int (*get_db) __P((DB_SEQUENCE *, DB **)); 1417 int (*get_flags) __P((DB_SEQUENCE *, u_int32_t *)); 1418 int (*get_key) __P((DB_SEQUENCE *, DBT *)); 1419 int (*get_range) __P((DB_SEQUENCE *, 1420 db_seq_t *, db_seq_t *)); 1421 int (*initial_value) __P((DB_SEQUENCE *, db_seq_t)); 1422 int (*open) __P((DB_SEQUENCE *, 1423 DB_TXN *, DBT *, u_int32_t)); 1424 int (*remove) __P((DB_SEQUENCE *, DB_TXN *, u_int32_t)); 1425 int (*set_cachesize) __P((DB_SEQUENCE *, u_int32_t)); 1426 int (*set_flags) __P((DB_SEQUENCE *, u_int32_t)); 1427 int (*set_range) __P((DB_SEQUENCE *, db_seq_t, db_seq_t)); 1428 int (*stat) __P((DB_SEQUENCE *, 1429 DB_SEQUENCE_STAT **, u_int32_t)); 1430 int (*stat_print) __P((DB_SEQUENCE *, u_int32_t)); 1431 /* DB_SEQUENCE PUBLIC HANDLE LIST END */ 1432 }; 1433 1434 struct __db_seq_stat { /* SHARED */ 1435 uintmax_t st_wait; /* Sequence lock granted w/o wait. */ 1436 uintmax_t st_nowait; /* Sequence lock granted after wait. */ 1437 db_seq_t st_current; /* Current value in db. */ 1438 db_seq_t st_value; /* Current cached value. */ 1439 db_seq_t st_last_value; /* Last cached value. */ 1440 db_seq_t st_min; /* Minimum value. */ 1441 db_seq_t st_max; /* Maximum value. */ 1442 u_int32_t st_cache_size; /* Cache size. */ 1443 u_int32_t st_flags; /* Flag value. */ 1444 }; 1445 1446 /******************************************************* 1447 * Access methods. 1448 *******************************************************/ 1449 /* 1450 * Any new methods need to retain the original numbering. The type 1451 * is written in a log record so must be maintained. 1452 */ 1453 typedef enum { 1454 DB_BTREE=1, 1455 DB_HASH=2, 1456 DB_HEAP=6, 1457 DB_RECNO=3, 1458 DB_QUEUE=4, 1459 DB_UNKNOWN=5 /* Figure it out on open. */ 1460 } DBTYPE; 1461 1462 #define DB_RENAMEMAGIC 0x030800 /* File has been renamed. */ 1463 1464 #define DB_BTREEVERSION 10 /* Current btree version. */ 1465 #define DB_BTREEOLDVER 8 /* Oldest btree version supported. */ 1466 #define DB_BTREEMAGIC 0x053162 1467 1468 #define DB_HASHVERSION 10 /* Current hash version. */ 1469 #define DB_HASHOLDVER 7 /* Oldest hash version supported. */ 1470 #define DB_HASHMAGIC 0x061561 1471 1472 #define DB_HEAPVERSION 2 /* Current heap version. */ 1473 #define DB_HEAPOLDVER 1 /* Oldest heap version supported. */ 1474 #define DB_HEAPMAGIC 0x074582 1475 1476 #define DB_QAMVERSION 4 /* Current queue version. */ 1477 #define DB_QAMOLDVER 3 /* Oldest queue version supported. */ 1478 #define DB_QAMMAGIC 0x042253 1479 1480 #define DB_SEQUENCE_VERSION 2 /* Current sequence version. */ 1481 #define DB_SEQUENCE_OLDVER 1 /* Oldest sequence version supported. */ 1482 1483 /* 1484 * DB access method and cursor operation values. Each value is an operation 1485 * code to which additional bit flags are added. 1486 */ 1487 #define DB_AFTER 1 /* Dbc.put */ 1488 #define DB_APPEND 2 /* Db.put */ 1489 #define DB_BEFORE 3 /* Dbc.put */ 1490 #define DB_CONSUME 4 /* Db.get */ 1491 #define DB_CONSUME_WAIT 5 /* Db.get */ 1492 #define DB_CURRENT 6 /* Dbc.get, Dbc.put, DbLogc.get */ 1493 #define DB_FIRST 7 /* Dbc.get, DbLogc->get */ 1494 #define DB_GET_BOTH 8 /* Db.get, Dbc.get */ 1495 #define DB_GET_BOTHC 9 /* Dbc.get (internal) */ 1496 #define DB_GET_BOTH_RANGE 10 /* Db.get, Dbc.get */ 1497 #define DB_GET_RECNO 11 /* Dbc.get */ 1498 #define DB_JOIN_ITEM 12 /* Dbc.get; don't do primary lookup */ 1499 #define DB_KEYFIRST 13 /* Dbc.put */ 1500 #define DB_KEYLAST 14 /* Dbc.put */ 1501 #define DB_LAST 15 /* Dbc.get, DbLogc->get */ 1502 #define DB_NEXT 16 /* Dbc.get, DbLogc->get */ 1503 #define DB_NEXT_DUP 17 /* Dbc.get */ 1504 #define DB_NEXT_NODUP 18 /* Dbc.get */ 1505 #define DB_NODUPDATA 19 /* Db.put, Dbc.put */ 1506 #define DB_NOOVERWRITE 20 /* Db.put */ 1507 #define DB_OVERWRITE_DUP 21 /* Dbc.put, Db.put; no DB_KEYEXIST */ 1508 #define DB_POSITION 22 /* Dbc.dup */ 1509 #define DB_PREV 23 /* Dbc.get, DbLogc->get */ 1510 #define DB_PREV_DUP 24 /* Dbc.get */ 1511 #define DB_PREV_NODUP 25 /* Dbc.get */ 1512 #define DB_SET 26 /* Dbc.get, DbLogc->get */ 1513 #define DB_SET_RANGE 27 /* Dbc.get */ 1514 #define DB_SET_RECNO 28 /* Db.get, Dbc.get */ 1515 #define DB_UPDATE_SECONDARY 29 /* Dbc.get, Dbc.del (internal) */ 1516 #define DB_SET_LTE 30 /* Dbc.get (internal) */ 1517 #define DB_GET_BOTH_LTE 31 /* Dbc.get (internal) */ 1518 1519 /* This has to change when the max opcode hits 255. */ 1520 #define DB_OPFLAGS_MASK 0x000000ff /* Mask for operations flags. */ 1521 1522 /* 1523 * DB (user visible) error return codes. 1524 * 1525 * !!! 1526 * We don't want our error returns to conflict with other packages where 1527 * possible, so pick a base error value that's hopefully not common. We 1528 * document that we own the error name space from -30,800 to -30,999. 1529 */ 1530 /* DB (public) error return codes. */ 1531 #define DB_BUFFER_SMALL (-30999)/* User memory too small for return. */ 1532 #define DB_DONOTINDEX (-30998)/* "Null" return from 2ndary callbk. */ 1533 #define DB_FOREIGN_CONFLICT (-30997)/* A foreign db constraint triggered. */ 1534 #define DB_HEAP_FULL (-30996)/* No free space in a heap file. */ 1535 #define DB_KEYEMPTY (-30995)/* Key/data deleted or never created. */ 1536 #define DB_KEYEXIST (-30994)/* The key/data pair already exists. */ 1537 #define DB_LOCK_DEADLOCK (-30993)/* Deadlock. */ 1538 #define DB_LOCK_NOTGRANTED (-30992)/* Lock unavailable. */ 1539 #define DB_LOG_BUFFER_FULL (-30991)/* In-memory log buffer full. */ 1540 #define DB_LOG_VERIFY_BAD (-30990)/* Log verification failed. */ 1541 #define DB_META_CHKSUM_FAIL (-30989)/* Metadata page checksum failed. */ 1542 #define DB_NOSERVER (-30988)/* Server panic return. */ 1543 #define DB_NOTFOUND (-30987)/* Key/data pair not found (EOF). */ 1544 #define DB_OLD_VERSION (-30986)/* Out-of-date version. */ 1545 #define DB_PAGE_NOTFOUND (-30985)/* Requested page not found. */ 1546 #define DB_REP_DUPMASTER (-30984)/* There are two masters. */ 1547 #define DB_REP_HANDLE_DEAD (-30983)/* Rolled back a commit. */ 1548 #define DB_REP_HOLDELECTION (-30982)/* Time to hold an election. */ 1549 #define DB_REP_IGNORE (-30981)/* This msg should be ignored.*/ 1550 #define DB_REP_INELECT (-30980)/* Replication is in an election. */ 1551 #define DB_REP_ISPERM (-30979)/* Cached not written perm written.*/ 1552 #define DB_REP_JOIN_FAILURE (-30978)/* Unable to join replication group. */ 1553 #define DB_REP_LEASE_EXPIRED (-30977)/* Master lease has expired. */ 1554 #define DB_REP_LOCKOUT (-30976)/* API/Replication lockout now. */ 1555 #define DB_REP_NEWSITE (-30975)/* New site entered system. */ 1556 #define DB_REP_NOTPERM (-30974)/* Permanent log record not written. */ 1557 #define DB_REP_UNAVAIL (-30973)/* Site cannot currently be reached. */ 1558 #define DB_REP_WOULDROLLBACK (-30972)/* UNDOC: rollback inhibited by app. */ 1559 #define DB_RUNRECOVERY (-30971)/* Panic return. */ 1560 #define DB_SECONDARY_BAD (-30970)/* Secondary index corrupt. */ 1561 #define DB_SLICE_CORRUPT (-30969)/* A part of a sliced env is corrupt. */ 1562 #define DB_TIMEOUT (-30968)/* Timed out on read consistency. */ 1563 #define DB_VERIFY_BAD (-30967)/* Verify failed; bad format. */ 1564 #define DB_VERSION_MISMATCH (-30966)/* Environment version mismatch. */ 1565 #define DB_SYSTEM_MEM_MISSING (-30965)/* Attach to shared memory failed. */ 1566 1567 /* DB (private) error return codes. */ 1568 #define DB_ALREADY_ABORTED (-30899) 1569 /* Spare error number (-30898). */ 1570 #define DB_DELETED (-30897)/* Recovery file marked deleted. */ 1571 #define DB_EVENT_NOT_HANDLED (-30896)/* Forward event to application. */ 1572 #define DB_NEEDSPLIT (-30895)/* Page needs to be split. */ 1573 #define DB_NOINTMP (-30886)/* Sequences not supported in temporary 1574 or in-memory databases. */ 1575 #define DB_REP_BULKOVF (-30894)/* Rep bulk buffer overflow. */ 1576 #define DB_REP_LOGREADY (-30893)/* Rep log ready for recovery. */ 1577 #define DB_REP_NEWMASTER (-30892)/* We have learned of a new master. */ 1578 #define DB_REP_PAGEDONE (-30891)/* This page was already done. */ 1579 #define DB_SURPRISE_KID (-30890)/* Child commit where parent 1580 didn't know it was a parent. */ 1581 #define DB_SWAPBYTES (-30889)/* Database needs byte swapping. */ 1582 #define DB_TXN_CKP (-30888)/* Encountered ckp record in log. */ 1583 #define DB_VERIFY_FATAL (-30887)/* DB->verify cannot proceed. */ 1584 1585 /* 1586 * This exit status indicates that a BDB utility failed because it needed a 1587 * resource which had been held by a process which crashed or otherwise did 1588 * not exit cleanly. 1589 */ 1590 #define DB_EXIT_FAILCHK 3 1591 1592 /* Database handle. */ 1593 struct __db { 1594 /******************************************************* 1595 * Public: owned by the application. 1596 *******************************************************/ 1597 u_int32_t pgsize; /* Database logical page size. */ 1598 DB_CACHE_PRIORITY priority; /* Database priority in cache. */ 1599 1600 /* Callbacks. */ 1601 int (*db_append_recno) __P((DB *, DBT *, db_recno_t)); 1602 void (*db_feedback) __P((DB *, int, int)); 1603 int (*dup_compare) __P((DB *, const DBT *, const DBT *, size_t *)); 1604 1605 void *app_private; /* Application-private handle. */ 1606 1607 /******************************************************* 1608 * Private: owned by DB. 1609 *******************************************************/ 1610 DB_ENV *dbenv; /* Backing public environment. */ 1611 ENV *env; /* Backing private environment. */ 1612 1613 DB_MPOOLFILE *mpf; /* Backing buffer pool. */ 1614 1615 DB **db_slices; /* A containing db's array of DB handles 1616 for its slices. */ 1617 DB *db_container; /* A slice's pointer to its 1618 containing DB. */ 1619 db_slice_t db_slice_index; /* Position in container's db_slices. */ 1620 DBTYPE type; /* DB access method type. */ 1621 1622 db_mutex_t mutex; /* Synchronization for free threading */ 1623 1624 char *fname, *dname; /* File/database passed to DB->open. */ 1625 const char *dirname; /* Directory of DB file. */ 1626 u_int32_t open_flags; /* Flags passed to DB->open. */ 1627 1628 u_int8_t fileid[DB_FILE_ID_LEN];/* File's unique ID for locking. */ 1629 1630 u_int32_t adj_fileid; /* File's unique ID for curs. adj. */ 1631 1632 u_int32_t blob_threshold; /* Ext file threshold record size. */ 1633 1634 #define DB_LOGFILEID_INVALID -1 1635 FNAME *log_filename; /* File's naming info for logging. */ 1636 1637 db_pgno_t meta_pgno; /* Meta page number */ 1638 DB_LOCKER *locker; /* Locker for handle locking. */ 1639 DB_LOCKER *cur_locker; /* Current handle lock holder. */ 1640 DB_TXN *cur_txn; /* Opening transaction. */ 1641 DB_LOCKER *associate_locker; /* Locker for DB->associate call. */ 1642 DB_LOCK handle_lock; /* Lock held on this handle. */ 1643 1644 time_t timestamp; /* Handle timestamp for replication. */ 1645 u_int32_t fid_gen; /* Rep generation number for fids. */ 1646 1647 /* 1648 * Returned data memory for DB->get() and friends. 1649 */ 1650 DBT my_rskey; /* Secondary key. */ 1651 DBT my_rkey; /* [Primary] key. */ 1652 DBT my_rdata; /* Data. */ 1653 1654 /* 1655 * !!! 1656 * Some applications use DB but implement their own locking outside of 1657 * DB. If they're using fcntl(2) locking on the underlying database 1658 * file, and we open and close a file descriptor for that file, we will 1659 * discard their locks. The DB_FCNTL_LOCKING flag to DB->open is an 1660 * undocumented interface to support this usage which leaves any file 1661 * descriptors we open until DB->close. This will only work with the 1662 * DB->open interface and simple caches, e.g., creating a transaction 1663 * thread may open/close file descriptors this flag doesn't protect. 1664 * Locking with fcntl(2) on a file that you don't own is a very, very 1665 * unsafe thing to do. 'Nuff said. 1666 */ 1667 DB_FH *saved_open_fhp; /* Saved file handle. */ 1668 1669 /* 1670 * Linked list of DBP's, linked from the ENV, used to keep track 1671 * of all open db handles for cursor adjustment. 1672 * 1673 * !!! 1674 * Explicit representations of structures from queue.h. 1675 * TAILQ_ENTRY(__db) dblistlinks; 1676 */ 1677 struct { 1678 struct __db *tqe_next; 1679 struct __db **tqe_prev; 1680 } dblistlinks; 1681 1682 /* 1683 * Cursor queues. 1684 * 1685 * !!! 1686 * Explicit representations of structures from queue.h. 1687 * TAILQ_HEAD(__cq_fq, __dbc) free_queue; 1688 * TAILQ_HEAD(__cq_aq, __dbc) active_queue; 1689 * TAILQ_HEAD(__cq_jq, __dbc) join_queue; 1690 */ 1691 struct __cq_fq { 1692 struct __dbc *tqh_first; 1693 struct __dbc **tqh_last; 1694 } free_queue; 1695 struct __cq_aq { 1696 struct __dbc *tqh_first; 1697 struct __dbc **tqh_last; 1698 } active_queue; 1699 struct __cq_jq { 1700 struct __dbc *tqh_first; 1701 struct __dbc **tqh_last; 1702 } join_queue; 1703 1704 /* 1705 * Secondary index support. 1706 * 1707 * Linked list of secondary indices -- set in the primary. 1708 * 1709 * !!! 1710 * Explicit representations of structures from queue.h. 1711 * LIST_HEAD(s_secondaries, __db); 1712 */ 1713 struct { 1714 struct __db *lh_first; 1715 } s_secondaries; 1716 1717 /* 1718 * List entries for secondaries, and reference count of how many 1719 * threads are updating this secondary (see Dbc.put). 1720 * 1721 * !!! 1722 * Note that these are synchronized by the primary's mutex, but 1723 * filled in in the secondaries. 1724 * 1725 * !!! 1726 * Explicit representations of structures from queue.h. 1727 * LIST_ENTRY(__db) s_links; 1728 */ 1729 struct { 1730 struct __db *le_next; 1731 struct __db **le_prev; 1732 } s_links; 1733 u_int32_t s_refcnt; 1734 1735 /* Secondary callback and free functions -- set in the secondary. */ 1736 int (*s_callback) __P((DB *, const DBT *, const DBT *, DBT *)); 1737 1738 /* Reference to primary -- set in the secondary. */ 1739 DB *s_primary; 1740 1741 #define DB_ASSOC_IMMUTABLE_KEY 0x00000001 /* Secondary key is immutable. */ 1742 #define DB_ASSOC_CREATE 0x00000002 /* Secondary db populated on open. */ 1743 1744 /* Flags passed to associate -- set in the secondary. */ 1745 u_int32_t s_assoc_flags; 1746 1747 /* 1748 * Foreign key support. 1749 * 1750 * Linked list of primary dbs -- set in the foreign db 1751 * 1752 * !!! 1753 * Explicit representations of structures from queue.h. 1754 * LIST_HEAD(f_primaries, __db); 1755 */ 1756 struct { 1757 struct __db_foreign_info *lh_first; 1758 } f_primaries; 1759 1760 /* 1761 * !!! 1762 * Explicit representations of structures from queue.h. 1763 * TAILQ_ENTRY(__db) felink; 1764 * 1765 * Links in a list of DBs involved in file extension 1766 * during a transaction. These are to be used only while the 1767 * metadata is locked. 1768 */ 1769 struct { 1770 struct __db *tqe_next; 1771 struct __db **tqe_prev; 1772 } felink; 1773 1774 /* Reference to foreign -- set in the secondary. */ 1775 DB *s_foreign; 1776 1777 DB *blob_meta_db; /* DBs holding ext file metadata. */ 1778 DB_SEQUENCE *blob_seq; /* Sequence of ext file ids. */ 1779 char *blob_sub_dir; /* Subdirectory for ext files */ 1780 db_seq_t blob_file_id; /* Id of the file ext file directory. */ 1781 db_seq_t blob_sdb_id; /* Id of subdb ext file directory. */ 1782 1783 /* API-private structure: used by DB 1.85, C++, Java, Perl and Tcl */ 1784 void *api_internal; 1785 1786 /* Subsystem-private structure. */ 1787 void *bt_internal; /* Btree/Recno access method. */ 1788 void *h_internal; /* Hash access method. */ 1789 void *heap_internal; /* Heap access method. */ 1790 void *p_internal; /* Partition informaiton. */ 1791 void *q_internal; /* Queue access method. */ 1792 1793 /* DB PUBLIC HANDLE LIST BEGIN */ 1794 int (*associate) __P((DB *, DB_TXN *, DB *, 1795 int (*)(DB *, const DBT *, const DBT *, DBT *), u_int32_t)); 1796 int (*associate_foreign) __P((DB *, DB *, 1797 int (*)(DB *, const DBT *, DBT *, const DBT *, int *), 1798 u_int32_t)); 1799 int (*close) __P((DB *, u_int32_t)); 1800 int (*compact) __P((DB *, 1801 DB_TXN *, DBT *, DBT *, DB_COMPACT *, u_int32_t, DBT *)); 1802 int (*convert) __P((DB *, const char *, u_int32_t)); 1803 int (*cursor) __P((DB *, DB_TXN *, DBC **, u_int32_t)); 1804 int (*del) __P((DB *, DB_TXN *, DBT *, u_int32_t)); 1805 void (*err) __P((DB *, int, const char *, ...)); 1806 void (*errx) __P((DB *, const char *, ...)); 1807 int (*exists) __P((DB *, DB_TXN *, DBT *, u_int32_t)); 1808 int (*fd) __P((DB *, int *)); 1809 int (*get) __P((DB *, DB_TXN *, DBT *, DBT *, u_int32_t)); 1810 int (*get_alloc) __P((DB *, void *(**)(size_t), 1811 void *(**)(void *, size_t), void (**)(void *))); 1812 int (*get_append_recno) __P((DB *, int (**)(DB *, DBT *, db_recno_t))); 1813 int (*get_assoc_flags) __P((DB *, u_int32_t *)); 1814 int (*get_blob_dir) __P((DB *, const char **)); 1815 int (*get_blob_sub_dir) __P((DB *, const char **)); 1816 int (*get_blob_threshold) __P((DB *, u_int32_t *)); 1817 int (*get_bt_compare) 1818 __P((DB *, int (**)(DB *, const DBT *, const DBT *, size_t *))); 1819 int (*get_bt_compress) __P((DB *, 1820 int (**)(DB *, 1821 const DBT *, const DBT *, const DBT *, const DBT *, DBT *), 1822 int (**)(DB *, const DBT *, const DBT *, DBT *, DBT *, DBT *))); 1823 int (*get_bt_minkey) __P((DB *, u_int32_t *)); 1824 int (*get_bt_prefix) 1825 __P((DB *, size_t (**)(DB *, const DBT *, const DBT *))); 1826 int (*get_byteswapped) __P((DB *, int *)); 1827 int (*get_cachesize) __P((DB *, u_int32_t *, u_int32_t *, int *)); 1828 int (*get_create_dir) __P((DB *, const char **)); 1829 int (*get_dbname) __P((DB *, const char **, const char **)); 1830 int (*get_dup_compare) 1831 __P((DB *, int (**)(DB *, const DBT *, const DBT *, size_t *))); 1832 int (*get_encrypt_flags) __P((DB *, u_int32_t *)); 1833 DB_ENV *(*get_env) __P((DB *)); 1834 void (*get_errcall) __P((DB *, 1835 void (**)(const DB_ENV *, const char *, const char *))); 1836 void (*get_errfile) __P((DB *, FILE **)); 1837 void (*get_errpfx) __P((DB *, const char **)); 1838 int (*get_ext_file_dir) __P((DB *, const char **)); 1839 int (*get_ext_file_threshold) __P((DB *, u_int32_t *)); 1840 int (*get_feedback) __P((DB *, void (**)(DB *, int, int))); 1841 int (*get_flags) __P((DB *, u_int32_t *)); 1842 int (*get_h_compare) 1843 __P((DB *, int (**)(DB *, const DBT *, const DBT *, size_t *))); 1844 int (*get_h_ffactor) __P((DB *, u_int32_t *)); 1845 int (*get_h_hash) 1846 __P((DB *, u_int32_t (**)(DB *, const void *, u_int32_t))); 1847 int (*get_h_nelem) __P((DB *, u_int32_t *)); 1848 int (*get_heapsize) __P((DB *, u_int32_t *, u_int32_t *)); 1849 int (*get_heap_regionsize) __P((DB *, u_int32_t *)); 1850 int (*get_lk_exclusive) __P((DB *, int *, int *)); 1851 int (*get_lorder) __P((DB *, int *)); 1852 DB_MPOOLFILE *(*get_mpf) __P((DB *)); 1853 void (*get_msgcall) __P((DB *, 1854 void (**)(const DB_ENV *, const char *, const char *))); 1855 void (*get_msgfile) __P((DB *, FILE **)); 1856 void (*get_msgpfx) __P((DB *, const char **)); 1857 int (*get_multiple) __P((DB *)); 1858 int (*get_open_flags) __P((DB *, u_int32_t *)); 1859 int (*get_pagesize) __P((DB *, u_int32_t *)); 1860 int (*get_partition_callback) __P((DB *, 1861 u_int32_t *, u_int32_t (**)(DB *, DBT *key))); 1862 int (*get_partition_dirs) __P((DB *, const char ***)); 1863 int (*get_partition_keys) __P((DB *, u_int32_t *, DBT **)); 1864 int (*get_priority) __P((DB *, DB_CACHE_PRIORITY *)); 1865 int (*get_q_extentsize) __P((DB *, u_int32_t *)); 1866 int (*get_re_delim) __P((DB *, int *)); 1867 int (*get_re_len) __P((DB *, u_int32_t *)); 1868 int (*get_re_pad) __P((DB *, int *)); 1869 int (*get_re_source) __P((DB *, const char **)); 1870 int (*get_slices) __P((DB *, DB ***)); 1871 int (*get_transactional) __P((DB *)); 1872 int (*get_type) __P((DB *, DBTYPE *)); 1873 int (*join) __P((DB *, DBC **, DBC **, u_int32_t)); 1874 int (*key_range) 1875 __P((DB *, DB_TXN *, DBT *, DB_KEY_RANGE *, u_int32_t)); 1876 void (*msg) __P((DB *, const char *, ...)); 1877 int (*open) __P((DB *, 1878 DB_TXN *, const char *, const char *, DBTYPE, u_int32_t, int)); 1879 int (*pget) __P((DB *, DB_TXN *, DBT *, DBT *, DBT *, u_int32_t)); 1880 int (*put) __P((DB *, DB_TXN *, DBT *, DBT *, u_int32_t)); 1881 int (*remove) __P((DB *, const char *, const char *, u_int32_t)); 1882 int (*rename) __P((DB *, 1883 const char *, const char *, const char *, u_int32_t)); 1884 int (*set_alloc) __P((DB *, void *(*)(size_t), 1885 void *(*)(void *, size_t), void (*)(void *))); 1886 int (*set_append_recno) __P((DB *, int (*)(DB *, DBT *, db_recno_t))); 1887 int (*set_blob_dir) __P((DB *, const char *)); 1888 int (*set_blob_threshold) __P((DB *, u_int32_t, u_int32_t)); 1889 int (*set_bt_compare) 1890 __P((DB *, int (*)(DB *, const DBT *, const DBT *, size_t *))); 1891 int (*set_bt_compress) __P((DB *, 1892 int (*)(DB *, const DBT *, const DBT *, const DBT *, const DBT *, DBT *), 1893 int (*)(DB *, const DBT *, const DBT *, DBT *, DBT *, DBT *))); 1894 int (*set_bt_minkey) __P((DB *, u_int32_t)); 1895 int (*set_bt_prefix) 1896 __P((DB *, size_t (*)(DB *, const DBT *, const DBT *))); 1897 int (*set_cachesize) __P((DB *, u_int32_t, u_int32_t, int)); 1898 int (*set_create_dir) __P((DB *, const char *)); 1899 int (*set_dup_compare) 1900 __P((DB *, int (*)(DB *, const DBT *, const DBT *, size_t *))); 1901 int (*set_encrypt) __P((DB *, const char *, u_int32_t)); 1902 void (*set_errcall) __P((DB *, 1903 void (*)(const DB_ENV *, const char *, const char *))); 1904 void (*set_errfile) __P((DB *, FILE *)); 1905 void (*set_errpfx) __P((DB *, const char *)); 1906 int (*set_ext_file_dir) __P((DB *, const char *)); 1907 int (*set_ext_file_threshold) __P((DB *, u_int32_t, u_int32_t)); 1908 int (*set_feedback) __P((DB *, void (*)(DB *, int, int))); 1909 int (*set_flags) __P((DB *, u_int32_t)); 1910 int (*set_h_compare) 1911 __P((DB *, int (*)(DB *, const DBT *, const DBT *, size_t *))); 1912 int (*set_h_ffactor) __P((DB *, u_int32_t)); 1913 int (*set_h_hash) 1914 __P((DB *, u_int32_t (*)(DB *, const void *, u_int32_t))); 1915 int (*set_h_nelem) __P((DB *, u_int32_t)); 1916 int (*set_heapsize) __P((DB *, u_int32_t, u_int32_t, u_int32_t)); 1917 int (*set_heap_regionsize) __P((DB *, u_int32_t)); 1918 int (*set_lk_exclusive) __P((DB *, int)); 1919 int (*set_lorder) __P((DB *, int)); 1920 int (*set_slice_callback) 1921 __P((DB *, int (*)(const DB *, const DBT *, DBT *))); 1922 void (*set_msgcall) __P((DB *, 1923 void (*)(const DB_ENV *, const char *, const char *))); 1924 void (*set_msgfile) __P((DB *, FILE *)); 1925 void (*set_msgpfx) __P((DB *, const char *)); 1926 int (*set_pagesize) __P((DB *, u_int32_t)); 1927 int (*set_paniccall) __P((DB *, void (*)(DB_ENV *, int))); 1928 int (*set_partition) __P((DB *, 1929 u_int32_t, DBT *, u_int32_t (*)(DB *, DBT *key))); 1930 int (*set_partition_dirs) __P((DB *, const char **)); 1931 int (*set_priority) __P((DB *, DB_CACHE_PRIORITY)); 1932 int (*set_q_extentsize) __P((DB *, u_int32_t)); 1933 int (*set_re_delim) __P((DB *, int)); 1934 int (*set_re_len) __P((DB *, u_int32_t)); 1935 int (*set_re_pad) __P((DB *, int)); 1936 int (*set_re_source) __P((DB *, const char *)); 1937 int (*slice_lookup) __P((DB *, const DBT *, DB **, u_int32_t)); 1938 int (*sort_multiple) __P((DB *, DBT *, DBT *, u_int32_t)); 1939 int (*stat) __P((DB *, DB_TXN *, void *, u_int32_t)); 1940 int (*stat_print) __P((DB *, u_int32_t)); 1941 int (*sync) __P((DB *, u_int32_t)); 1942 int (*truncate) __P((DB *, DB_TXN *, u_int32_t *, u_int32_t)); 1943 int (*upgrade) __P((DB *, const char *, u_int32_t)); 1944 int (*verify) 1945 __P((DB *, const char *, const char *, FILE *, u_int32_t)); 1946 /* DB PUBLIC HANDLE LIST END */ 1947 1948 /* DB PRIVATE HANDLE LIST BEGIN */ 1949 int (*slice_callback)(const DB *db, const DBT *key, DBT *slice); 1950 int (*dump) __P((DB *, const char *, 1951 int (*)(void *, const void *), void *, int, int)); 1952 int (*db_am_remove) __P((DB *, DB_THREAD_INFO *, 1953 DB_TXN *, const char *, const char *, u_int32_t)); 1954 int (*db_am_rename) __P((DB *, DB_THREAD_INFO *, 1955 DB_TXN *, const char *, const char *, const char *)); 1956 /* DB PRIVATE HANDLE LIST END */ 1957 1958 /* 1959 * Never called; these are a place to save function pointers 1960 * so that we can undo an associate. 1961 */ 1962 int (*stored_get) __P((DB *, DB_TXN *, DBT *, DBT *, u_int32_t)); 1963 int (*stored_close) __P((DB *, u_int32_t)); 1964 1965 /* Alternative handle close function, used by C++ API. */ 1966 int (*alt_close) __P((DB *, u_int32_t)); 1967 1968 #define DB_OK_BTREE 0x01 1969 #define DB_OK_HASH 0x02 1970 #define DB_OK_HEAP 0x04 1971 #define DB_OK_QUEUE 0x08 1972 #define DB_OK_RECNO 0x10 1973 u_int32_t am_ok; /* Legal AM choices. */ 1974 1975 /* 1976 * This field really ought to be an AM_FLAG, but we have 1977 * have run out of bits. If/when we decide to split up 1978 * the flags, we can incorporate it. 1979 */ 1980 int preserve_fid; /* Do not free fileid on close. */ 1981 1982 /* 1983 * This saves the DB_ flags from open, for refresh; they are not the 1984 * DB_AM_... or DB2_AM_... translations. 1985 */ 1986 u_int32_t orig_flags; 1987 1988 #define DB_AM_CHKSUM 0x00000001 /* Checksumming */ 1989 #define DB_AM_COMPENSATE 0x00000002 /* Created by compensating txn */ 1990 #define DB_AM_COMPRESS 0x00000004 /* Compressed BTree */ 1991 #define DB_AM_CREATED 0x00000008 /* Database was created upon open */ 1992 #define DB_AM_CREATED_MSTR 0x00000010 /* Encompassing file was created */ 1993 #define DB_AM_DBM_ERROR 0x00000020 /* Error in DBM/NDBM database */ 1994 #define DB_AM_DELIMITER 0x00000040 /* Variable length delimiter set */ 1995 #define DB_AM_DISCARD 0x00000080 /* Discard any cached pages */ 1996 #define DB_AM_DUP 0x00000100 /* DB_DUP */ 1997 #define DB_AM_DUPSORT 0x00000200 /* DB_DUPSORT */ 1998 #define DB_AM_ENCRYPT 0x00000400 /* Encryption */ 1999 #define DB_AM_FIXEDLEN 0x00000800 /* Fixed-length records */ 2000 #define DB_AM_INMEM 0x00001000 /* In-memory; no sync on close */ 2001 #define DB_AM_INORDER 0x00002000 /* DB_INORDER */ 2002 #define DB_AM_IN_RENAME 0x00004000 /* File is being renamed */ 2003 #define DB_AM_NOT_DURABLE 0x00008000 /* Do not log changes */ 2004 #define DB_AM_OPEN_CALLED 0x00010000 /* DB->open called */ 2005 #define DB_AM_PAD 0x00020000 /* Fixed-length record pad */ 2006 #define DB_AM_PARTDB 0x00040000 /* Handle for a database partition */ 2007 #define DB_AM_PGDEF 0x00080000 /* Page size was defaulted */ 2008 #define DB_AM_RDONLY 0x00100000 /* Database is readonly */ 2009 #define DB_AM_READ_UNCOMMITTED 0x00200000 /* Support degree 1 isolation */ 2010 #define DB_AM_RECNUM 0x00400000 /* DB_RECNUM */ 2011 #define DB_AM_RECOVER 0x00800000 /* DB opened by recovery routine */ 2012 #define DB_AM_RENUMBER 0x01000000 /* DB_RENUMBER */ 2013 #define DB_AM_REVSPLITOFF 0x02000000 /* DB_REVSPLITOFF */ 2014 #define DB_AM_SECONDARY 0x04000000 /* Database is a secondary index */ 2015 #define DB_AM_SNAPSHOT 0x08000000 /* DB_SNAPSHOT */ 2016 #define DB_AM_SUBDB 0x10000000 /* Subdatabases supported */ 2017 #define DB_AM_SWAP 0x20000000 /* Pages need to be byte-swapped */ 2018 #define DB_AM_TXN 0x40000000 /* Opened in a transaction */ 2019 #define DB_AM_VERIFYING 0x80000000 /* DB handle is in the verifier */ 2020 u_int32_t flags; 2021 2022 #define DB2_AM_EXCL 0x00000001 /* Exclusively lock the handle */ 2023 #define DB2_AM_INTEXCL 0x00000002 /* Internal exclusive lock. */ 2024 #define DB2_AM_MPOOL_OPENED 0x00000004 /* Memory pool setup completed */ 2025 #define DB2_AM_NOWAIT 0x00000008 /* Do not wait for handle lock */ 2026 u_int32_t flags2; /* Second flags word */ 2027 }; 2028 2029 /* 2030 * Stream interface for external files. 2031 */ 2032 struct __db_stream { 2033 DBC *dbc; /* Cursor pointing to the db ext file record. */ 2034 DB_FH *fhp; 2035 2036 /* DB_STREAM PUBLIC HANDLE LIST BEGIN */ 2037 int (*close) __P((DB_STREAM *, u_int32_t)); 2038 int (*read) __P((DB_STREAM *, DBT *, db_off_t, u_int32_t, u_int32_t)); 2039 int (*size) __P((DB_STREAM *, db_off_t *, u_int32_t)); 2040 int (*write) __P((DB_STREAM *, DBT *, db_off_t, u_int32_t)); 2041 /* DB_STREAM PUBLIC HANDLE LIST END */ 2042 2043 u_int32_t flags; 2044 #define DB_STREAM_READ 0x00000001 /* Stream is read only. */ 2045 #define DB_STREAM_WRITE 0x00000002 /* Stream is writeable. */ 2046 #define DB_STREAM_SYNC_WRITE 0x00000004 /* Sync file on each write. */ 2047 db_seq_t blob_id; 2048 db_off_t file_size; 2049 }; 2050 2051 /* 2052 * Macros for bulk operations. These are only intended for the C API. 2053 * For C++, use DbMultiple*Iterator or DbMultiple*Builder. 2054 * 2055 * Bulk operations store multiple entries into a single DBT structure. The 2056 * following macros assist with creating and reading these Multiple DBTs. 2057 * 2058 * The basic layout for single data items is: 2059 * 2060 * ------------------------------------------------------------------------- 2061 * | data1 | ... | dataN | ..... |-1 | dNLen | dNOff | ... | d1Len | d1Off | 2062 * ------------------------------------------------------------------------- 2063 * 2064 * For the DB_MULTIPLE_KEY* macros, the items are in key/data pairs, so data1 2065 * would be a key, and data2 its corresponding value (N is always even). 2066 * 2067 * For the DB_MULTIPLE_RECNO* macros, the record number is stored along with 2068 * the len/off pair in the "header" section, and the list is zero terminated 2069 * (since -1 is a valid record number): 2070 * 2071 * -------------------------------------------------------------------------- 2072 * | d1 |..| dN |..| 0 | dNLen | dNOff | recnoN |..| d1Len | d1Off | recno1 | 2073 * -------------------------------------------------------------------------- 2074 */ 2075 #define DB_MULTIPLE_INIT(pointer, dbt) \ 2076 (pointer = (u_int8_t *)(dbt)->data + \ 2077 (dbt)->ulen - sizeof(u_int32_t)) 2078 2079 #define DB_MULTIPLE_NEXT(pointer, dbt, retdata, retdlen) \ 2080 do { \ 2081 u_int32_t *__p = (u_int32_t *)(pointer); \ 2082 if (*__p == (u_int32_t)-1) { \ 2083 retdata = NULL; \ 2084 pointer = NULL; \ 2085 break; \ 2086 } \ 2087 retdata = (u_int8_t *)(dbt)->data + *__p--; \ 2088 retdlen = *__p--; \ 2089 pointer = __p; \ 2090 if (retdlen == 0 && retdata == (u_int8_t *)(dbt)->data) \ 2091 retdata = NULL; \ 2092 } while (0) 2093 2094 #define DB_MULTIPLE_KEY_NEXT(pointer, dbt, retkey, retklen, retdata, retdlen) \ 2095 do { \ 2096 u_int32_t *__p = (u_int32_t *)(pointer); \ 2097 if (*__p == (u_int32_t)-1) { \ 2098 retdata = NULL; \ 2099 retkey = NULL; \ 2100 pointer = NULL; \ 2101 break; \ 2102 } \ 2103 retkey = (u_int8_t *)(dbt)->data + *__p--; \ 2104 retklen = *__p--; \ 2105 retdata = (u_int8_t *)(dbt)->data + *__p--; \ 2106 retdlen = *__p--; \ 2107 pointer = __p; \ 2108 } while (0) 2109 2110 #define DB_MULTIPLE_RECNO_NEXT(pointer, dbt, recno, retdata, retdlen) \ 2111 do { \ 2112 u_int32_t *__p = (u_int32_t *)(pointer); \ 2113 if (*__p == (u_int32_t)0) { \ 2114 recno = 0; \ 2115 retdata = NULL; \ 2116 pointer = NULL; \ 2117 break; \ 2118 } \ 2119 recno = *__p--; \ 2120 retdata = (u_int8_t *)(dbt)->data + *__p--; \ 2121 retdlen = *__p--; \ 2122 pointer = __p; \ 2123 } while (0) 2124 2125 #define DB_MULTIPLE_WRITE_INIT(pointer, dbt) \ 2126 do { \ 2127 (dbt)->flags |= DB_DBT_BULK; \ 2128 pointer = (u_int8_t *)(dbt)->data + \ 2129 (dbt)->ulen - sizeof(u_int32_t); \ 2130 *(u_int32_t *)(pointer) = (u_int32_t)-1; \ 2131 } while (0) 2132 2133 #define DB_MULTIPLE_RESERVE_NEXT(pointer, dbt, writedata, writedlen) \ 2134 do { \ 2135 u_int32_t *__p = (u_int32_t *)(pointer); \ 2136 u_int32_t __off = ((pointer) == (u_int8_t *)(dbt)->data +\ 2137 (dbt)->ulen - sizeof(u_int32_t)) ? 0 : __p[1] + __p[2];\ 2138 if ((u_int8_t *)(dbt)->data + __off + (writedlen) > \ 2139 (u_int8_t *)(__p - 2)) \ 2140 writedata = NULL; \ 2141 else { \ 2142 writedata = (u_int8_t *)(dbt)->data + __off; \ 2143 __p[0] = __off; \ 2144 __p[-1] = (u_int32_t)(writedlen); \ 2145 __p[-2] = (u_int32_t)-1; \ 2146 pointer = __p - 2; \ 2147 } \ 2148 } while (0) 2149 2150 #define DB_MULTIPLE_WRITE_NEXT(pointer, dbt, writedata, writedlen) \ 2151 do { \ 2152 void *__destd; \ 2153 DB_MULTIPLE_RESERVE_NEXT((pointer), (dbt), \ 2154 __destd, (writedlen)); \ 2155 if (__destd == NULL) \ 2156 pointer = NULL; \ 2157 else \ 2158 memcpy(__destd, (writedata), (writedlen)); \ 2159 } while (0) 2160 2161 #define DB_MULTIPLE_KEY_RESERVE_NEXT(pointer, dbt, writekey, writeklen, writedata, writedlen) \ 2162 do { \ 2163 u_int32_t *__p = (u_int32_t *)(pointer); \ 2164 u_int32_t __off = ((pointer) == (u_int8_t *)(dbt)->data +\ 2165 (dbt)->ulen - sizeof(u_int32_t)) ? 0 : __p[1] + __p[2];\ 2166 if ((u_int8_t *)(dbt)->data + __off + (writeklen) + \ 2167 (writedlen) > (u_int8_t *)(__p - 4)) { \ 2168 writekey = NULL; \ 2169 writedata = NULL; \ 2170 } else { \ 2171 writekey = (u_int8_t *)(dbt)->data + __off; \ 2172 __p[0] = __off; \ 2173 __p[-1] = (u_int32_t)(writeklen); \ 2174 __p -= 2; \ 2175 __off += (u_int32_t)(writeklen); \ 2176 writedata = (u_int8_t *)(dbt)->data + __off; \ 2177 __p[0] = __off; \ 2178 __p[-1] = (u_int32_t)(writedlen); \ 2179 __p[-2] = (u_int32_t)-1; \ 2180 pointer = __p - 2; \ 2181 } \ 2182 } while (0) 2183 2184 #define DB_MULTIPLE_KEY_WRITE_NEXT(pointer, dbt, writekey, writeklen, writedata, writedlen) \ 2185 do { \ 2186 void *__destk, *__destd; \ 2187 DB_MULTIPLE_KEY_RESERVE_NEXT((pointer), (dbt), \ 2188 __destk, (writeklen), __destd, (writedlen)); \ 2189 if (__destk == NULL) \ 2190 pointer = NULL; \ 2191 else { \ 2192 memcpy(__destk, (writekey), (writeklen)); \ 2193 if (__destd != NULL) \ 2194 memcpy(__destd, (writedata), (writedlen));\ 2195 } \ 2196 } while (0) 2197 2198 #define DB_MULTIPLE_RECNO_WRITE_INIT(pointer, dbt) \ 2199 do { \ 2200 (dbt)->flags |= DB_DBT_BULK; \ 2201 pointer = (u_int8_t *)(dbt)->data + \ 2202 (dbt)->ulen - sizeof(u_int32_t); \ 2203 *(u_int32_t *)(pointer) = 0; \ 2204 } while (0) 2205 2206 #define DB_MULTIPLE_RECNO_RESERVE_NEXT(pointer, dbt, recno, writedata, writedlen) \ 2207 do { \ 2208 u_int32_t *__p = (u_int32_t *)(pointer); \ 2209 u_int32_t __off = ((pointer) == (u_int8_t *)(dbt)->data +\ 2210 (dbt)->ulen - sizeof(u_int32_t)) ? 0 : __p[1] + __p[2]; \ 2211 if (((u_int8_t *)(dbt)->data + __off) + (writedlen) > \ 2212 (u_int8_t *)(__p - 3)) \ 2213 writedata = NULL; \ 2214 else { \ 2215 writedata = (u_int8_t *)(dbt)->data + __off; \ 2216 __p[0] = (u_int32_t)(recno); \ 2217 __p[-1] = __off; \ 2218 __p[-2] = (u_int32_t)(writedlen); \ 2219 __p[-3] = 0; \ 2220 pointer = __p - 3; \ 2221 } \ 2222 } while (0) 2223 2224 #define DB_MULTIPLE_RECNO_WRITE_NEXT(pointer, dbt, recno, writedata, writedlen)\ 2225 do { \ 2226 void *__destd; \ 2227 DB_MULTIPLE_RECNO_RESERVE_NEXT((pointer), (dbt), \ 2228 (recno), __destd, (writedlen)); \ 2229 if (__destd == NULL) \ 2230 pointer = NULL; \ 2231 else if ((writedlen) != 0) \ 2232 memcpy(__destd, (writedata), (writedlen)); \ 2233 } while (0) 2234 2235 struct __db_heap_rid { 2236 db_pgno_t pgno; /* Page number. */ 2237 db_indx_t indx; /* Index in the offset table. */ 2238 }; 2239 #define DB_HEAP_RID_SZ (sizeof(db_pgno_t) + sizeof(db_indx_t)) 2240 2241 /******************************************************* 2242 * Access method cursors. 2243 *******************************************************/ 2244 struct __dbc { 2245 DB *dbp; /* Backing database */ 2246 DB_ENV *dbenv; /* Backing environment */ 2247 ENV *env; /* Backing environment */ 2248 2249 DB_THREAD_INFO *thread_info; /* Thread that owns this cursor. */ 2250 DB_TXN *txn; /* Associated transaction. */ 2251 DB_CACHE_PRIORITY priority; /* Priority in cache. */ 2252 2253 db_slice_t dbc_curslice; /* Current DB of an all-slice DBC. */ 2254 DBC *dbc_slices[1]; /* A containing dbc's array of DBC 2255 handles for its slices. */ 2256 2257 /* 2258 * Active/free cursor queues. 2259 * 2260 * !!! 2261 * Explicit representations of structures from queue.h. 2262 * TAILQ_ENTRY(__dbc) links; 2263 */ 2264 struct { 2265 DBC *tqe_next; 2266 DBC **tqe_prev; 2267 } links; 2268 2269 /* 2270 * Cursor queue of the owning transaction. 2271 * 2272 * !!! 2273 * Explicit representations of structures from queue.h. 2274 * TAILQ_ENTRY(__dbc) txn_cursors; 2275 */ 2276 struct { 2277 DBC *tqe_next; /* next element */ 2278 DBC **tqe_prev; /* address of previous next element */ 2279 } txn_cursors; 2280 2281 /* 2282 * The DBT *'s below are used by the cursor routines to return 2283 * data to the user when DBT flags indicate that DB should manage 2284 * the returned memory. They point at a DBT containing the buffer 2285 * and length that will be used, and "belonging" to the handle that 2286 * should "own" this memory. This may be a "my_*" field of this 2287 * cursor--the default--or it may be the corresponding field of 2288 * another cursor, a DB handle, a join cursor, etc. In general, it 2289 * will be whatever handle the user originally used for the current 2290 * DB interface call. 2291 */ 2292 DBT *rskey; /* Returned secondary key. */ 2293 DBT *rkey; /* Returned [primary] key. */ 2294 DBT *rdata; /* Returned data. */ 2295 2296 DBT my_rskey; /* Space for returned secondary key. */ 2297 DBT my_rkey; /* Space for returned [primary] key. */ 2298 DBT my_rdata; /* Space for returned data. */ 2299 2300 DBT *cur_key; 2301 2302 DB_LOCKER *lref; /* Reference to default locker. */ 2303 DB_LOCKER *locker; /* Locker for this operation. */ 2304 DBT lock_dbt; /* DBT referencing lock. */ 2305 DB_LOCK_ILOCK lock; /* Object to be locked. */ 2306 DB_LOCK mylock; /* CDB lock held on this cursor. */ 2307 2308 DBTYPE dbtype; /* Cursor type. */ 2309 2310 DBC_INTERNAL *internal; /* Access method private. */ 2311 2312 /* DBC PUBLIC HANDLE LIST BEGIN */ 2313 int (*close) __P((DBC *)); 2314 int (*cmp) __P((DBC *, DBC *, int *, u_int32_t)); 2315 int (*count) __P((DBC *, db_recno_t *, u_int32_t)); 2316 int (*db_stream) __P((DBC *, DB_STREAM **, u_int32_t)); 2317 int (*del) __P((DBC *, u_int32_t)); 2318 int (*dup) __P((DBC *, DBC **, u_int32_t)); 2319 int (*get) __P((DBC *, DBT *, DBT *, u_int32_t)); 2320 int (*get_priority) __P((DBC *, DB_CACHE_PRIORITY *)); 2321 int (*pget) __P((DBC *, DBT *, DBT *, DBT *, u_int32_t)); 2322 int (*put) __P((DBC *, DBT *, DBT *, u_int32_t)); 2323 int (*set_priority) __P((DBC *, DB_CACHE_PRIORITY)); 2324 /* DBC PUBLIC HANDLE LIST END */ 2325 2326 /* The following are the method names deprecated in the 4.6 release. */ 2327 int (*c_close) __P((DBC *)); 2328 int (*c_count) __P((DBC *, db_recno_t *, u_int32_t)); 2329 int (*c_del) __P((DBC *, u_int32_t)); 2330 int (*c_dup) __P((DBC *, DBC **, u_int32_t)); 2331 int (*c_get) __P((DBC *, DBT *, DBT *, u_int32_t)); 2332 int (*c_pget) __P((DBC *, DBT *, DBT *, DBT *, u_int32_t)); 2333 int (*c_put) __P((DBC *, DBT *, DBT *, u_int32_t)); 2334 2335 /* DBC PRIVATE HANDLE LIST BEGIN */ 2336 int (*am_bulk) __P((DBC *, DBT *, u_int32_t)); 2337 int (*am_close) __P((DBC *, db_pgno_t, int *)); 2338 int (*am_del) __P((DBC *, u_int32_t)); 2339 int (*am_destroy) __P((DBC *)); 2340 int (*am_get) __P((DBC *, DBT *, DBT *, u_int32_t, db_pgno_t *)); 2341 int (*am_put) __P((DBC *, DBT *, DBT *, u_int32_t, db_pgno_t *)); 2342 int (*am_writelock) __P((DBC *)); 2343 /* DBC PRIVATE HANDLE LIST END */ 2344 2345 u_int32_t open_flags; /* Flags passed to DB->cursor. */ 2346 /* 2347 * DBC_DONTLOCK and DBC_RECOVER are used during recovery and transaction 2348 * abort. If a transaction is being aborted or recovered then DBC_RECOVER 2349 * will be set and locking and logging will be disabled on this cursor. If 2350 * we are performing a compensating transaction (e.g. free page processing) 2351 * then DB_DONTLOCK will be set to inhibit locking, but logging will still 2352 * be required. DB_DONTLOCK is also used if the whole database is locked. 2353 */ 2354 #define DBC_ACTIVE 0x00001 /* Cursor in use. */ 2355 #define DBC_BULK 0x00002 /* Bulk update cursor. */ 2356 #define DBC_DONTLOCK 0x00004 /* Don't lock on this cursor. */ 2357 #define DBC_DOWNREV 0x00008 /* Down rev replication master. */ 2358 #define DBC_DUPLICATE 0x00010 /* Create a duplicate cursor. */ 2359 #define DBC_ERROR 0x00020 /* Error in this request. */ 2360 #define DBC_FAMILY 0x00040 /* Part of a locker family. */ 2361 #define DBC_FROM_DB_GET 0x00080 /* Called from the DB->get() method. */ 2362 #define DBC_MULTIPLE 0x00100 /* Return Multiple data. */ 2363 #define DBC_MULTIPLE_KEY 0x00200 /* Return Multiple keys and data. */ 2364 #define DBC_OPD 0x00400 /* Cursor references off-page dups. */ 2365 #define DBC_OWN_LID 0x00800 /* Free lock id on destroy. */ 2366 #define DBC_PARTITIONED 0x01000 /* Cursor for a partitioned db. */ 2367 #define DBC_READ_COMMITTED 0x02000 /* Cursor has degree 2 isolation. */ 2368 #define DBC_READ_UNCOMMITTED 0x04000 /* Cursor has degree 1 isolation. */ 2369 #define DBC_RECOVER 0x08000 /* Recovery cursor; don't log/lock. */ 2370 #define DBC_RMW 0x10000 /* Acquire write flag in read op. */ 2371 #define DBC_TRANSIENT 0x20000 /* Cursor is transient. */ 2372 #define DBC_WAS_READ_COMMITTED 0x40000 /* Cursor holds a read commited lock. */ 2373 #define DBC_WRITECURSOR 0x80000 /* Cursor may be used to write (CDB). */ 2374 #define DBC_WRITER 0x100000 /* Cursor immediately writing (CDB). */ 2375 u_int32_t flags; 2376 }; 2377 2378 /* Key range statistics structure */ 2379 struct __key_range { 2380 double less; 2381 double equal; 2382 double greater; 2383 }; 2384 2385 /* Btree/Recno statistics structure. */ 2386 struct __db_bt_stat { /* SHARED */ 2387 u_int32_t bt_magic; /* Magic number. */ 2388 u_int32_t bt_version; /* Version number. */ 2389 u_int32_t bt_metaflags; /* Metadata flags. */ 2390 u_int32_t bt_nkeys; /* Number of unique keys. */ 2391 u_int32_t bt_ndata; /* Number of data items. */ 2392 u_int32_t bt_pagecnt; /* Page count. */ 2393 u_int32_t bt_pagesize; /* Page size. */ 2394 u_int32_t bt_minkey; /* Minkey value. */ 2395 u_int32_t bt_ext_files; /* Number of external files. */ 2396 u_int32_t bt_nblobs; /* Deprecated alias bt_ext_files. */ 2397 u_int32_t bt_re_len; /* Fixed-length record length. */ 2398 u_int32_t bt_re_pad; /* Fixed-length record pad. */ 2399 u_int32_t bt_levels; /* Tree levels. */ 2400 u_int32_t bt_int_pg; /* Internal pages. */ 2401 u_int32_t bt_leaf_pg; /* Leaf pages. */ 2402 u_int32_t bt_dup_pg; /* Duplicate pages. */ 2403 u_int32_t bt_over_pg; /* Overflow pages. */ 2404 u_int32_t bt_empty_pg; /* Empty pages. */ 2405 u_int32_t bt_free; /* Pages on the free list. */ 2406 uintmax_t bt_int_pgfree; /* Bytes free in internal pages. */ 2407 uintmax_t bt_leaf_pgfree; /* Bytes free in leaf pages. */ 2408 uintmax_t bt_dup_pgfree; /* Bytes free in duplicate pages. */ 2409 uintmax_t bt_over_pgfree; /* Bytes free in overflow pages. */ 2410 }; 2411 2412 struct __db_compact { 2413 /* Input Parameters. */ 2414 u_int32_t compact_fillpercent; /* Desired fillfactor: 1-100 */ 2415 db_timeout_t compact_timeout; /* Lock timeout. */ 2416 u_int32_t compact_pages; /* Max pages to process. */ 2417 /* Output Stats. */ 2418 u_int32_t compact_empty_buckets; /* Empty hash buckets found. */ 2419 u_int32_t compact_pages_free; /* Number of pages freed. */ 2420 u_int32_t compact_pages_examine; /* Number of pages examine. */ 2421 u_int32_t compact_levels; /* Number of levels removed. */ 2422 u_int32_t compact_deadlock; /* Number of deadlocks. */ 2423 db_pgno_t compact_pages_truncated; /* Pages truncated to OS. */ 2424 /* Internal. */ 2425 db_pgno_t compact_truncate; /* Exchange pages above here. */ 2426 }; 2427 2428 /* Hash statistics structure. */ 2429 struct __db_h_stat { /* SHARED */ 2430 u_int32_t hash_magic; /* Magic number. */ 2431 u_int32_t hash_version; /* Version number. */ 2432 u_int32_t hash_metaflags; /* Metadata flags. */ 2433 u_int32_t hash_nkeys; /* Number of unique keys. */ 2434 u_int32_t hash_ndata; /* Number of data items. */ 2435 u_int32_t hash_ext_files; /* Number of external files. */ 2436 u_int32_t hash_nblobs; /* Deprecated alias hash_ext_files. */ 2437 u_int32_t hash_pagecnt; /* Page count. */ 2438 u_int32_t hash_pagesize; /* Page size. */ 2439 u_int32_t hash_ffactor; /* Fill factor specified at create. */ 2440 u_int32_t hash_buckets; /* Number of hash buckets. */ 2441 u_int32_t hash_free; /* Pages on the free list. */ 2442 uintmax_t hash_bfree; /* Bytes free on bucket pages. */ 2443 u_int32_t hash_bigpages; /* Number of big key/data pages. */ 2444 uintmax_t hash_big_bfree; /* Bytes free on big item pages. */ 2445 u_int32_t hash_overflows; /* Number of overflow pages. */ 2446 uintmax_t hash_ovfl_free; /* Bytes free on ovfl pages. */ 2447 u_int32_t hash_dup; /* Number of dup pages. */ 2448 uintmax_t hash_dup_free; /* Bytes free on duplicate pages. */ 2449 }; 2450 2451 /* Heap statistics structure. */ 2452 struct __db_heap_stat { /* SHARED */ 2453 u_int32_t heap_magic; /* Magic number. */ 2454 u_int32_t heap_version; /* Version number. */ 2455 u_int32_t heap_metaflags; /* Metadata flags. */ 2456 u_int32_t heap_ext_files; /* Number of external files. */ 2457 u_int32_t heap_nblobs; /* Deprecated alias heap_ext_files. */ 2458 u_int32_t heap_nrecs; /* Number of records. */ 2459 u_int32_t heap_pagecnt; /* Page count. */ 2460 u_int32_t heap_pagesize; /* Page size. */ 2461 u_int32_t heap_nregions; /* Number of regions. */ 2462 u_int32_t heap_regionsize; /* Number of pages in a region. */ 2463 }; 2464 2465 /* Queue statistics structure. */ 2466 struct __db_qam_stat { /* SHARED */ 2467 u_int32_t qs_magic; /* Magic number. */ 2468 u_int32_t qs_version; /* Version number. */ 2469 u_int32_t qs_metaflags; /* Metadata flags. */ 2470 u_int32_t qs_nkeys; /* Number of unique keys. */ 2471 u_int32_t qs_ndata; /* Number of data items. */ 2472 u_int32_t qs_pagesize; /* Page size. */ 2473 u_int32_t qs_extentsize; /* Pages per extent. */ 2474 u_int32_t qs_pages; /* Data pages. */ 2475 u_int32_t qs_re_len; /* Fixed-length record length. */ 2476 u_int32_t qs_re_pad; /* Fixed-length record pad. */ 2477 u_int32_t qs_pgfree; /* Bytes free in data pages. */ 2478 u_int32_t qs_first_recno; /* First not deleted record. */ 2479 u_int32_t qs_cur_recno; /* Next available record number. */ 2480 }; 2481 2482 /******************************************************* 2483 * Environment. 2484 *******************************************************/ 2485 #define DB_REGION_MAGIC 0x120897 /* The environment is available. */ 2486 #define DB_REGION_MAGIC_RECOVER 0xeeeccc /* Recovery is running. */ 2487 2488 /* 2489 * Database environment structure. 2490 * 2491 * This is the public database environment handle. The private environment 2492 * handle is the ENV structure. The user owns this structure, the library 2493 * owns the ENV structure. The reason there are two structures is because 2494 * the user's configuration outlives any particular DB_ENV->open call, and 2495 * separate structures allows us to easily discard internal information without 2496 * discarding the user's configuration. 2497 * 2498 * Fields in the DB_ENV structure should normally be set only by application 2499 * DB_ENV handle methods. 2500 */ 2501 2502 /* 2503 * Memory configuration types. 2504 */ 2505 typedef enum { 2506 DB_MEM_DATABASE=1, 2507 DB_MEM_DATABASE_LENGTH=2, 2508 DB_MEM_EXTFILE_DATABASE=3, 2509 DB_MEM_LOCK=4, 2510 DB_MEM_LOCKOBJECT=5, 2511 DB_MEM_LOCKER=6, 2512 DB_MEM_LOGID=7, 2513 DB_MEM_REP_SITE=8, 2514 DB_MEM_TRANSACTION=9, 2515 DB_MEM_THREAD=10 2516 } DB_MEM_CONFIG; 2517 2518 /* 2519 * Backup configuration types. 2520 */ 2521 typedef enum { 2522 DB_BACKUP_READ_COUNT=1, 2523 DB_BACKUP_READ_SLEEP=2, 2524 DB_BACKUP_SIZE=3, 2525 DB_BACKUP_WRITE_DIRECT=4 2526 } DB_BACKUP_CONFIG; 2527 2528 struct __db_env { 2529 ENV *env; /* Linked ENV structure */ 2530 2531 /* Error message callback */ 2532 void (*db_errcall) __P((const DB_ENV *, const char *, const char *)); 2533 FILE *db_errfile; /* Error message file stream */ 2534 const char *db_errpfx; /* Error message prefix */ 2535 2536 /* Other message callback */ 2537 void (*db_msgcall) __P((const DB_ENV *, const char *, const char *)); 2538 FILE *db_msgfile; /* Other message file stream */ 2539 const char *db_msgpfx; /* Other message prefix */ 2540 2541 /* Other application callback functions */ 2542 int (*app_dispatch) __P((DB_ENV *, DBT *, DB_LSN *, db_recops)); 2543 void (*db_event_func) __P((DB_ENV *, u_int32_t, void *)); 2544 void (*db_feedback) __P((DB_ENV *, int, int)); 2545 void (*db_free) __P((void *)); 2546 void (*db_paniccall) __P((DB_ENV *, int)); 2547 void *(*db_malloc) __P((size_t)); 2548 void *(*db_realloc) __P((void *, size_t)); 2549 int (*is_alive) __P((DB_ENV *, pid_t, db_threadid_t, u_int32_t)); 2550 void (*thread_id) __P((DB_ENV *, pid_t *, db_threadid_t *)); 2551 char *(*thread_id_string) __P((DB_ENV *, pid_t, db_threadid_t, char *)); 2552 2553 /* Application specified paths */ 2554 char *db_blob_dir; /* External file directory */ 2555 char *db_log_dir; /* Database log file directory */ 2556 char *db_md_dir; /* Persistent metadata directory */ 2557 char *db_reg_dir; /* Region file directory */ 2558 char *db_tmp_dir; /* Database tmp file directory */ 2559 2560 char *db_create_dir; /* Create directory for data files */ 2561 char **db_data_dir; /* Database data file directories (or 2562 sliced environment home dirs?) */ 2563 int data_cnt; /* Database data file slots */ 2564 int data_next; /* Next database data file slot */ 2565 2566 char *intermediate_dir_mode; /* Intermediate directory perms */ 2567 2568 long shm_key; /* shmget key */ 2569 2570 char *passwd; /* Cryptography support */ 2571 size_t passwd_len; 2572 u_int32_t encrypt_flags; 2573 2574 /* Private handle references */ 2575 void *app_private; /* Application-private handle */ 2576 void *api1_internal; /* C++, Perl API private */ 2577 void *api2_internal; /* Java API private */ 2578 2579 u_int32_t verbose; /* DB_VERB_XXX flags */ 2580 2581 u_int32_t blob_threshold; /* External file threshold size */ 2582 2583 /* Database configuration */ 2584 u_int32_t db_init_databases; /* Number of databases. */ 2585 u_int32_t db_init_db_len; /* Database name length. */ 2586 u_int32_t db_init_extfile_dbs; /* 2587 * Number of additional 2588 * external file metadata 2589 * databases. 2590 */ 2591 2592 /* Mutex configuration */ 2593 u_int32_t mutex_align; /* Mutex alignment */ 2594 u_int32_t mutex_cnt; /* Number of mutexes to configure */ 2595 u_int32_t mutex_inc; /* Number of mutexes to add */ 2596 u_int32_t mutex_max; /* Max number of mutexes */ 2597 u_int32_t mutex_tas_spins;/* Test-and-set spin count */ 2598 2599 /* Locking configuration */ 2600 u_int8_t *lk_conflicts; /* Two dimensional conflict matrix */ 2601 int lk_modes; /* Number of lock modes in table */ 2602 u_int32_t lk_detect; /* Deadlock detect on all conflicts */ 2603 u_int32_t lk_max; /* Maximum number of locks */ 2604 u_int32_t lk_max_lockers;/* Maximum number of lockers */ 2605 u_int32_t lk_max_objects;/* Maximum number of locked objects */ 2606 u_int32_t lk_init; /* Initial number of locks */ 2607 u_int32_t lk_init_lockers;/* Initial number of lockers */ 2608 u_int32_t lk_init_objects;/* Initial number of locked objects */ 2609 u_int32_t lk_partitions ;/* Number of object partitions */ 2610 db_timeout_t lk_timeout; /* Lock timeout period */ 2611 /* Used during initialization */ 2612 u_int32_t locker_t_size; /* Locker hash table size. */ 2613 u_int32_t object_t_size; /* Object hash table size. */ 2614 2615 /* Logging configuration */ 2616 u_int32_t lg_bsize; /* Buffer size */ 2617 u_int32_t lg_fileid_init; /* Initial allocation for fname structs */ 2618 int lg_filemode; /* Log file permission mode */ 2619 u_int32_t lg_regionmax; /* Region size */ 2620 u_int32_t lg_size; /* Log file size */ 2621 u_int32_t lg_flags; /* Log configuration */ 2622 2623 /* Memory pool configuration */ 2624 u_int32_t mp_gbytes; /* Cache size: GB */ 2625 u_int32_t mp_bytes; /* Cache size: bytes */ 2626 u_int32_t mp_max_gbytes; /* Maximum cache size: GB */ 2627 u_int32_t mp_max_bytes; /* Maximum cache size: bytes */ 2628 size_t mp_mmapsize; /* Maximum file size for mmap */ 2629 int mp_maxopenfd; /* Maximum open file descriptors */ 2630 int mp_maxwrite; /* Maximum buffers to write */ 2631 u_int mp_ncache; /* Initial number of cache regions */ 2632 u_int32_t mp_pagesize; /* Average page size */ 2633 u_int32_t mp_tablesize; /* Approximate hash table size */ 2634 u_int32_t mp_mtxcount; /* Number of mutexs */ 2635 /* Sleep after writing max buffers */ 2636 db_timeout_t mp_maxwrite_sleep; 2637 2638 /* Replication configuration */ 2639 u_int32_t rep_init_sites; /* Number of replication sites. */ 2640 2641 /* Transaction configuration */ 2642 u_int32_t tx_init; /* Initial number of transactions */ 2643 u_int32_t tx_max; /* Maximum number of transactions */ 2644 time_t tx_timestamp; /* Recover to specific timestamp */ 2645 db_timeout_t tx_timeout; /* Timeout for transactions */ 2646 2647 /* Thread tracking configuration */ 2648 u_int32_t thr_init; /* Thread count */ 2649 u_int32_t thr_max; /* Thread max */ 2650 roff_t memory_max; /* Maximum region memory */ 2651 2652 /* 2653 * The following fields are not strictly user-owned, but they outlive 2654 * the ENV structure, and so are stored here. 2655 */ 2656 DB_FH *registry; /* DB_REGISTER file handle */ 2657 u_int32_t registry_off; /* 2658 * Offset of our slot. We can't use 2659 * off_t because its size depends on 2660 * build settings. 2661 */ 2662 db_timeout_t envreg_timeout; /* DB_REGISTER wait timeout */ 2663 2664 /* 2665 * When failchk broadcasting is active, any wait for a mutex will wake 2666 * up this frequently in order to check whether the mutex has died. 2667 */ 2668 db_timeout_t mutex_failchk_timeout; 2669 2670 /* slice_cnt is non-zero only for containers. */ 2671 db_slice_t slice_cnt; 2672 2673 #define DB_ENV_AUTO_COMMIT 0x00000001 /* DB_AUTO_COMMIT */ 2674 #define DB_ENV_CDB_ALLDB 0x00000002 /* CDB environment wide locking */ 2675 #define DB_ENV_FAILCHK 0x00000004 /* Failchk is running */ 2676 #define DB_ENV_DIRECT_DB 0x00000008 /* DB_DIRECT_DB set */ 2677 #define DB_ENV_DSYNC_DB 0x00000010 /* DB_DSYNC_DB set */ 2678 #define DB_ENV_DATABASE_LOCKING 0x00000020 /* Try database-level locking */ 2679 #define DB_ENV_MULTIVERSION 0x00000040 /* DB_MULTIVERSION set */ 2680 #define DB_ENV_NOLOCKING 0x00000080 /* DB_NOLOCKING set */ 2681 #define DB_ENV_NOMMAP 0x00000100 /* DB_NOMMAP set */ 2682 #define DB_ENV_NOPANIC 0x00000200 /* Okay if panic set */ 2683 #define DB_ENV_OVERWRITE 0x00000400 /* DB_OVERWRITE set */ 2684 #define DB_ENV_REGION_INIT 0x00000800 /* DB_REGION_INIT set */ 2685 #define DB_ENV_TIME_NOTGRANTED 0x00001000 /* DB_TIME_NOTGRANTED set */ 2686 #define DB_ENV_TXN_NOSYNC 0x00002000 /* DB_TXN_NOSYNC set */ 2687 #define DB_ENV_TXN_NOWAIT 0x00004000 /* DB_TXN_NOWAIT set */ 2688 #define DB_ENV_TXN_SNAPSHOT 0x00008000 /* DB_TXN_SNAPSHOT set */ 2689 #define DB_ENV_TXN_WRITE_NOSYNC 0x00010000 /* DB_TXN_WRITE_NOSYNC set */ 2690 #define DB_ENV_YIELDCPU 0x00020000 /* DB_YIELDCPU set */ 2691 #define DB_ENV_HOTBACKUP 0x00040000 /* DB_HOTBACKUP_IN_PROGRESS set */ 2692 #define DB_ENV_NOFLUSH 0x00080000 /* DB_NOFLUSH set */ 2693 u_int32_t flags; 2694 2695 /* DB_ENV PUBLIC HANDLE LIST BEGIN */ 2696 int (*add_data_dir) __P((DB_ENV *, const char *)); 2697 int (*backup) __P((DB_ENV *, const char *, u_int32_t)); 2698 int (*cdsgroup_begin) __P((DB_ENV *, DB_TXN **)); 2699 int (*close) __P((DB_ENV *, u_int32_t)); 2700 int (*dbbackup) __P((DB_ENV *, const char *, const char *, u_int32_t)); 2701 int (*dbremove) __P((DB_ENV *, 2702 DB_TXN *, const char *, const char *, u_int32_t)); 2703 int (*dbrename) __P((DB_ENV *, 2704 DB_TXN *, const char *, const char *, const char *, u_int32_t)); 2705 void (*err) __P((const DB_ENV *, int, const char *, ...)); 2706 void (*errx) __P((const DB_ENV *, const char *, ...)); 2707 int (*failchk) __P((DB_ENV *, u_int32_t)); 2708 int (*fileid_reset) __P((DB_ENV *, const char *, u_int32_t)); 2709 int (*get_alloc) __P((DB_ENV *, void *(**)(size_t), 2710 void *(**)(void *, size_t), void (**)(void *))); 2711 int (*get_app_dispatch) 2712 __P((DB_ENV *, int (**)(DB_ENV *, DBT *, DB_LSN *, db_recops))); 2713 int (*get_blob_dir) __P((DB_ENV *, const char **)); 2714 int (*get_blob_threshold) __P((DB_ENV*, u_int32_t *)); 2715 int (*get_cache_max) __P((DB_ENV *, u_int32_t *, u_int32_t *)); 2716 int (*get_cachesize) __P((DB_ENV *, u_int32_t *, u_int32_t *, int *)); 2717 int (*get_create_dir) __P((DB_ENV *, const char **)); 2718 int (*get_data_dirs) __P((DB_ENV *, const char ***)); 2719 int (*get_data_len) __P((DB_ENV *, u_int32_t *)); 2720 int (*get_backup_callbacks) __P((DB_ENV *, 2721 int (**)(DB_ENV *, const char *, const char *, void **), 2722 int (**)(DB_ENV *, u_int32_t, u_int32_t, u_int32_t, u_int8_t *, void *), 2723 int (**)(DB_ENV *, const char *, void *))); 2724 int (*get_backup_config) __P((DB_ENV *, DB_BACKUP_CONFIG, u_int32_t *)); 2725 int (*get_encrypt_flags) __P((DB_ENV *, u_int32_t *)); 2726 void (*get_errcall) __P((DB_ENV *, 2727 void (**)(const DB_ENV *, const char *, const char *))); 2728 void (*get_errfile) __P((DB_ENV *, FILE **)); 2729 void (*get_errpfx) __P((DB_ENV *, const char **)); 2730 int (*get_ext_file_dir) __P((DB_ENV *, const char **)); 2731 int (*get_ext_file_threshold) __P((DB_ENV*, u_int32_t *)); 2732 int (*get_feedback) __P((DB_ENV *, void (**)(DB_ENV *, int, int))); 2733 int (*get_flags) __P((DB_ENV *, u_int32_t *)); 2734 int (*get_home) __P((DB_ENV *, const char **)); 2735 int (*get_intermediate_dir_mode) __P((DB_ENV *, const char **)); 2736 int (*get_isalive) __P((DB_ENV *, 2737 int (**)(DB_ENV *, pid_t, db_threadid_t, u_int32_t))); 2738 int (*get_lg_bsize) __P((DB_ENV *, u_int32_t *)); 2739 int (*get_lg_dir) __P((DB_ENV *, const char **)); 2740 int (*get_lg_filemode) __P((DB_ENV *, int *)); 2741 int (*get_lg_max) __P((DB_ENV *, u_int32_t *)); 2742 int (*get_lg_regionmax) __P((DB_ENV *, u_int32_t *)); 2743 int (*get_lk_conflicts) __P((DB_ENV *, const u_int8_t **, int *)); 2744 int (*get_lk_detect) __P((DB_ENV *, u_int32_t *)); 2745 int (*get_lk_max_lockers) __P((DB_ENV *, u_int32_t *)); 2746 int (*get_lk_max_locks) __P((DB_ENV *, u_int32_t *)); 2747 int (*get_lk_max_objects) __P((DB_ENV *, u_int32_t *)); 2748 int (*get_lk_partitions) __P((DB_ENV *, u_int32_t *)); 2749 int (*get_lk_priority) __P((DB_ENV *, u_int32_t, u_int32_t *)); 2750 int (*get_lk_tablesize) __P((DB_ENV *, u_int32_t *)); 2751 int (*get_memory_init) __P((DB_ENV *, DB_MEM_CONFIG, u_int32_t *)); 2752 int (*get_memory_max) __P((DB_ENV *, u_int32_t *, u_int32_t *)); 2753 int (*get_metadata_dir) __P((DB_ENV *, const char **)); 2754 int (*get_mp_max_openfd) __P((DB_ENV *, int *)); 2755 int (*get_mp_max_write) __P((DB_ENV *, int *, db_timeout_t *)); 2756 int (*get_mp_mmapsize) __P((DB_ENV *, size_t *)); 2757 int (*get_mp_mtxcount) __P((DB_ENV *, u_int32_t *)); 2758 int (*get_mp_pagesize) __P((DB_ENV *, u_int32_t *)); 2759 int (*get_mp_tablesize) __P((DB_ENV *, u_int32_t *)); 2760 void (*get_msgcall) __P((DB_ENV *, 2761 void (**)(const DB_ENV *, const char *, const char *))); 2762 void (*get_msgfile) __P((DB_ENV *, FILE **)); 2763 void (*get_msgpfx) __P((DB_ENV *, const char **)); 2764 int (*get_open_flags) __P((DB_ENV *, u_int32_t *)); 2765 int (*get_region_dir) __P((DB_ENV *, const char **)); 2766 int (*get_slice_count) __P((DB_ENV *, u_int32_t *)); 2767 int (*get_slices) __P((DB_ENV *, DB_ENV ***)); 2768 int (*get_shm_key) __P((DB_ENV *, long *)); 2769 int (*get_thread_count) __P((DB_ENV *, u_int32_t *)); 2770 int (*get_thread_id_fn) 2771 __P((DB_ENV *, void (**)(DB_ENV *, pid_t *, db_threadid_t *))); 2772 int (*get_thread_id_string_fn) __P((DB_ENV *, 2773 char *(**)(DB_ENV *, pid_t, db_threadid_t, char *))); 2774 int (*get_timeout) __P((DB_ENV *, db_timeout_t *, u_int32_t)); 2775 int (*get_tmp_dir) __P((DB_ENV *, const char **)); 2776 int (*get_tx_max) __P((DB_ENV *, u_int32_t *)); 2777 int (*get_tx_timestamp) __P((DB_ENV *, time_t *)); 2778 int (*get_verbose) __P((DB_ENV *, u_int32_t, int *)); 2779 int (*is_bigendian) __P((void)); 2780 int (*lock_detect) __P((DB_ENV *, u_int32_t, u_int32_t, int *)); 2781 int (*lock_get) __P((DB_ENV *, 2782 u_int32_t, u_int32_t, DBT *, db_lockmode_t, DB_LOCK *)); 2783 int (*lock_id) __P((DB_ENV *, u_int32_t *)); 2784 int (*lock_id_free) __P((DB_ENV *, u_int32_t)); 2785 int (*lock_put) __P((DB_ENV *, DB_LOCK *)); 2786 int (*lock_stat) __P((DB_ENV *, DB_LOCK_STAT **, u_int32_t)); 2787 int (*lock_stat_print) __P((DB_ENV *, u_int32_t)); 2788 int (*lock_vec) __P((DB_ENV *, 2789 u_int32_t, u_int32_t, DB_LOCKREQ *, int, DB_LOCKREQ **)); 2790 int (*log_archive) __P((DB_ENV *, char **[], u_int32_t)); 2791 int (*log_cursor) __P((DB_ENV *, DB_LOGC **, u_int32_t)); 2792 int (*log_file) __P((DB_ENV *, const DB_LSN *, char *, size_t)); 2793 int (*log_flush) __P((DB_ENV *, const DB_LSN *)); 2794 int (*log_get_config) __P((DB_ENV *, u_int32_t, int *)); 2795 int (*log_printf) __P((DB_ENV *, DB_TXN *, const char *, ...)); 2796 int (*log_put) __P((DB_ENV *, DB_LSN *, const DBT *, u_int32_t)); 2797 int (*log_put_record) __P((DB_ENV *, DB *, DB_TXN *, DB_LSN *, 2798 u_int32_t, u_int32_t, u_int32_t, u_int32_t, 2799 DB_LOG_RECSPEC *, ...)); 2800 int (*log_read_record) __P((DB_ENV *, DB **, 2801 void *, void *, DB_LOG_RECSPEC *, u_int32_t, void **)); 2802 int (*log_set_config) __P((DB_ENV *, u_int32_t, int)); 2803 int (*log_stat) __P((DB_ENV *, DB_LOG_STAT **, u_int32_t)); 2804 int (*log_stat_print) __P((DB_ENV *, u_int32_t)); 2805 int (*log_verify) __P((DB_ENV *, const DB_LOG_VERIFY_CONFIG *)); 2806 int (*lsn_reset) __P((DB_ENV *, const char *, u_int32_t)); 2807 int (*memp_fcreate) __P((DB_ENV *, DB_MPOOLFILE **, u_int32_t)); 2808 int (*memp_register) __P((DB_ENV *, int, int (*)(DB_ENV *, db_pgno_t, 2809 void *, DBT *), int (*)(DB_ENV *, db_pgno_t, void *, DBT *))); 2810 int (*memp_stat) __P((DB_ENV *, 2811 DB_MPOOL_STAT **, DB_MPOOL_FSTAT ***, u_int32_t)); 2812 int (*memp_stat_print) __P((DB_ENV *, u_int32_t)); 2813 int (*memp_sync) __P((DB_ENV *, DB_LSN *)); 2814 int (*memp_trickle) __P((DB_ENV *, int, int *)); 2815 void (*msg) __P((const DB_ENV *, const char *, ...)); 2816 int (*mutex_alloc) __P((DB_ENV *, u_int32_t, db_mutex_t *)); 2817 int (*mutex_free) __P((DB_ENV *, db_mutex_t)); 2818 int (*mutex_get_align) __P((DB_ENV *, u_int32_t *)); 2819 int (*mutex_get_increment) __P((DB_ENV *, u_int32_t *)); 2820 int (*mutex_get_init) __P((DB_ENV *, u_int32_t *)); 2821 int (*mutex_get_max) __P((DB_ENV *, u_int32_t *)); 2822 int (*mutex_get_tas_spins) __P((DB_ENV *, u_int32_t *)); 2823 int (*mutex_lock) __P((DB_ENV *, db_mutex_t)); 2824 int (*mutex_set_align) __P((DB_ENV *, u_int32_t)); 2825 int (*mutex_set_increment) __P((DB_ENV *, u_int32_t)); 2826 int (*mutex_set_init) __P((DB_ENV *, u_int32_t)); 2827 int (*mutex_set_max) __P((DB_ENV *, u_int32_t)); 2828 int (*mutex_set_tas_spins) __P((DB_ENV *, u_int32_t)); 2829 int (*mutex_stat) __P((DB_ENV *, DB_MUTEX_STAT **, u_int32_t)); 2830 int (*mutex_stat_print) __P((DB_ENV *, u_int32_t)); 2831 int (*mutex_unlock) __P((DB_ENV *, db_mutex_t)); 2832 int (*open) __P((DB_ENV *, const char *, u_int32_t, int)); 2833 int (*remove) __P((DB_ENV *, const char *, u_int32_t)); 2834 int (*rep_elect) __P((DB_ENV *, u_int32_t, u_int32_t, u_int32_t)); 2835 int (*rep_flush) __P((DB_ENV *)); 2836 int (*rep_get_clockskew) __P((DB_ENV *, u_int32_t *, u_int32_t *)); 2837 int (*rep_get_config) __P((DB_ENV *, u_int32_t, int *)); 2838 int (*rep_get_limit) __P((DB_ENV *, u_int32_t *, u_int32_t *)); 2839 int (*rep_get_nsites) __P((DB_ENV *, u_int32_t *)); 2840 int (*rep_get_priority) __P((DB_ENV *, u_int32_t *)); 2841 int (*rep_get_request) __P((DB_ENV *, u_int32_t *, u_int32_t *)); 2842 int (*rep_get_timeout) __P((DB_ENV *, int, u_int32_t *)); 2843 int (*rep_process_message) 2844 __P((DB_ENV *, DBT *, DBT *, int, DB_LSN *)); 2845 int (*rep_set_clockskew) __P((DB_ENV *, u_int32_t, u_int32_t)); 2846 int (*rep_set_config) __P((DB_ENV *, u_int32_t, int)); 2847 int (*rep_set_limit) __P((DB_ENV *, u_int32_t, u_int32_t)); 2848 int (*rep_set_nsites) __P((DB_ENV *, u_int32_t)); 2849 int (*rep_set_priority) __P((DB_ENV *, u_int32_t)); 2850 int (*rep_set_request) __P((DB_ENV *, u_int32_t, u_int32_t)); 2851 int (*rep_set_timeout) __P((DB_ENV *, int, db_timeout_t)); 2852 int (*rep_set_transport) __P((DB_ENV *, int, int (*)(DB_ENV *, 2853 const DBT *, const DBT *, const DB_LSN *, int, u_int32_t))); 2854 int (*rep_set_view) __P((DB_ENV *, int (*)(DB_ENV *, 2855 const char *, int *, u_int32_t))); 2856 int (*rep_start) __P((DB_ENV *, DBT *, u_int32_t)); 2857 int (*rep_stat) __P((DB_ENV *, DB_REP_STAT **, u_int32_t)); 2858 int (*rep_stat_print) __P((DB_ENV *, u_int32_t)); 2859 int (*rep_sync) __P((DB_ENV *, u_int32_t)); 2860 int (*repmgr_channel) __P((DB_ENV *, int, DB_CHANNEL **, u_int32_t)); 2861 int (*repmgr_get_ack_policy) __P((DB_ENV *, int *)); 2862 int (*repmgr_get_incoming_queue_max) 2863 __P((DB_ENV *, u_int32_t *, u_int32_t *)); 2864 int (*repmgr_local_site) __P((DB_ENV *, DB_SITE **)); 2865 int (*repmgr_msg_dispatch) __P((DB_ENV *, 2866 void (*)(DB_ENV *, DB_CHANNEL *, DBT *, u_int32_t, u_int32_t), 2867 u_int32_t)); 2868 int (*repmgr_set_ack_policy) __P((DB_ENV *, int)); 2869 int (*repmgr_set_incoming_queue_max) 2870 __P((DB_ENV *, u_int32_t, u_int32_t)); 2871 int (*repmgr_set_socket) __P((DB_ENV *, int (*)(DB_ENV *, 2872 DB_REPMGR_SOCKET, int *, u_int32_t))); 2873 int (*repmgr_set_ssl_config) __P((DB_ENV *, int, char *)); 2874 int (*repmgr_site) 2875 __P((DB_ENV *, const char *, u_int, DB_SITE**, u_int32_t)); 2876 int (*repmgr_site_by_eid) __P((DB_ENV *, int, DB_SITE**)); 2877 int (*repmgr_site_list) __P((DB_ENV *, u_int *, DB_REPMGR_SITE **)); 2878 int (*repmgr_start) __P((DB_ENV *, int, u_int32_t)); 2879 int (*repmgr_stat) __P((DB_ENV *, DB_REPMGR_STAT **, u_int32_t)); 2880 int (*repmgr_stat_print) __P((DB_ENV *, u_int32_t)); 2881 int (*set_alloc) __P((DB_ENV *, void *(*)(size_t), 2882 void *(*)(void *, size_t), void (*)(void *))); 2883 int (*set_app_dispatch) 2884 __P((DB_ENV *, int (*)(DB_ENV *, DBT *, DB_LSN *, db_recops))); 2885 int (*set_blob_dir) __P((DB_ENV *, const char *)); 2886 int (*set_blob_threshold) __P((DB_ENV *, u_int32_t, u_int32_t)); 2887 int (*set_cache_max) __P((DB_ENV *, u_int32_t, u_int32_t)); 2888 int (*set_cachesize) __P((DB_ENV *, u_int32_t, u_int32_t, int)); 2889 int (*set_create_dir) __P((DB_ENV *, const char *)); 2890 int (*set_data_dir) __P((DB_ENV *, const char *)); 2891 int (*set_data_len) __P((DB_ENV *, u_int32_t)); 2892 int (*set_backup_callbacks) __P((DB_ENV *, 2893 int (*)(DB_ENV *, const char *, const char *, void **), 2894 int (*)(DB_ENV *, u_int32_t, 2895 u_int32_t, u_int32_t, u_int8_t *, void *), 2896 int (*)(DB_ENV *, const char *, void *))); 2897 int (*set_backup_config) __P((DB_ENV *, DB_BACKUP_CONFIG, u_int32_t)); 2898 int (*set_encrypt) __P((DB_ENV *, const char *, u_int32_t)); 2899 void (*set_errcall) __P((DB_ENV *, 2900 void (*)(const DB_ENV *, const char *, const char *))); 2901 void (*set_errfile) __P((DB_ENV *, FILE *)); 2902 void (*set_errpfx) __P((DB_ENV *, const char *)); 2903 int (*set_event_notify) 2904 __P((DB_ENV *, void (*)(DB_ENV *, u_int32_t, void *))); 2905 int (*set_ext_file_dir) __P((DB_ENV *, const char *)); 2906 int (*set_ext_file_threshold) __P((DB_ENV *, u_int32_t, u_int32_t)); 2907 int (*set_feedback) __P((DB_ENV *, void (*)(DB_ENV *, int, int))); 2908 int (*set_flags) __P((DB_ENV *, u_int32_t, int)); 2909 int (*set_intermediate_dir_mode) __P((DB_ENV *, const char *)); 2910 int (*set_isalive) __P((DB_ENV *, 2911 int (*)(DB_ENV *, pid_t, db_threadid_t, u_int32_t))); 2912 int (*set_lg_bsize) __P((DB_ENV *, u_int32_t)); 2913 int (*set_lg_dir) __P((DB_ENV *, const char *)); 2914 int (*set_lg_filemode) __P((DB_ENV *, int)); 2915 int (*set_lg_max) __P((DB_ENV *, u_int32_t)); 2916 int (*set_lg_regionmax) __P((DB_ENV *, u_int32_t)); 2917 int (*set_lk_conflicts) __P((DB_ENV *, u_int8_t *, int)); 2918 int (*set_lk_detect) __P((DB_ENV *, u_int32_t)); 2919 int (*set_lk_max_lockers) __P((DB_ENV *, u_int32_t)); 2920 int (*set_lk_max_locks) __P((DB_ENV *, u_int32_t)); 2921 int (*set_lk_max_objects) __P((DB_ENV *, u_int32_t)); 2922 int (*set_lk_partitions) __P((DB_ENV *, u_int32_t)); 2923 int (*set_lk_priority) __P((DB_ENV *, u_int32_t, u_int32_t)); 2924 int (*set_lk_tablesize) __P((DB_ENV *, u_int32_t)); 2925 int (*set_memory_init) __P((DB_ENV *, DB_MEM_CONFIG, u_int32_t)); 2926 int (*set_memory_max) __P((DB_ENV *, u_int32_t, u_int32_t)); 2927 int (*set_metadata_dir) __P((DB_ENV *, const char *)); 2928 int (*set_mp_max_openfd) __P((DB_ENV *, int)); 2929 int (*set_mp_max_write) __P((DB_ENV *, int, db_timeout_t)); 2930 int (*set_mp_mmapsize) __P((DB_ENV *, size_t)); 2931 int (*set_mp_mtxcount) __P((DB_ENV *, u_int32_t)); 2932 int (*set_mp_pagesize) __P((DB_ENV *, u_int32_t)); 2933 int (*set_mp_tablesize) __P((DB_ENV *, u_int32_t)); 2934 void (*set_msgcall) __P((DB_ENV *, 2935 void (*)(const DB_ENV *, const char *, const char *))); 2936 void (*set_msgfile) __P((DB_ENV *, FILE *)); 2937 void (*set_msgpfx) __P((DB_ENV *, const char *)); 2938 int (*set_paniccall) __P((DB_ENV *, void (*)(DB_ENV *, int))); 2939 int (*set_region_dir) __P((DB_ENV *, const char *)); 2940 int (*set_shm_key) __P((DB_ENV *, long)); 2941 int (*set_thread_count) __P((DB_ENV *, u_int32_t)); 2942 int (*set_thread_id) 2943 __P((DB_ENV *, void (*)(DB_ENV *, pid_t *, db_threadid_t *))); 2944 int (*set_thread_id_string) __P((DB_ENV *, 2945 char *(*)(DB_ENV *, pid_t, db_threadid_t, char *))); 2946 int (*set_timeout) __P((DB_ENV *, db_timeout_t, u_int32_t)); 2947 int (*set_tmp_dir) __P((DB_ENV *, const char *)); 2948 int (*set_tx_max) __P((DB_ENV *, u_int32_t)); 2949 int (*set_tx_timestamp) __P((DB_ENV *, time_t *)); 2950 int (*set_verbose) __P((DB_ENV *, u_int32_t, int)); 2951 int (*txn_applied) __P((DB_ENV *, 2952 DB_TXN_TOKEN *, db_timeout_t, u_int32_t)); 2953 int (*stat_print) __P((DB_ENV *, u_int32_t)); 2954 int (*txn_begin) __P((DB_ENV *, DB_TXN *, DB_TXN **, u_int32_t)); 2955 int (*txn_checkpoint) __P((DB_ENV *, u_int32_t, u_int32_t, u_int32_t)); 2956 int (*txn_recover) __P((DB_ENV *, 2957 DB_PREPLIST *, long, long *, u_int32_t)); 2958 int (*txn_stat) __P((DB_ENV *, DB_TXN_STAT **, u_int32_t)); 2959 int (*txn_stat_print) __P((DB_ENV *, u_int32_t)); 2960 /* DB_ENV PUBLIC HANDLE LIST END */ 2961 2962 /* DB_ENV PRIVATE HANDLE LIST BEGIN */ 2963 int (*prdbt) __P((DBT *, int, const char *, void *, 2964 int (*)(void *, const void *), int, int, int)); 2965 /* DB_ENV PRIVATE HANDLE LIST END */ 2966 }; 2967 2968 /* 2969 * Dispatch structure for recovery, log verification and print routines. Since 2970 * internal and external routines take different arguments (ENV versus DB_ENV), 2971 * we need something more elaborate than a single pointer and size. Each size 2972 * is the number of allocated entries in the corresponding dispatch table, 2973 * rather than a byte count. 2974 */ 2975 struct __db_distab { 2976 int (**int_dispatch) __P((ENV *, DBT *, DB_LSN *, db_recops, void *)); 2977 int (**ext_dispatch) __P((DB_ENV *, DBT *, DB_LSN *, db_recops)); 2978 size_t int_size; 2979 size_t ext_size; 2980 }; 2981 2982 /* 2983 * Log verification configuration structure. 2984 */ 2985 struct __db_logvrfy_config { 2986 int continue_after_fail; 2987 int verbose; 2988 u_int32_t cachesize; 2989 const char *temp_envhome; 2990 const char *dbfile; 2991 const char *dbname; 2992 DB_LSN start_lsn; 2993 DB_LSN end_lsn; 2994 time_t start_time; 2995 time_t end_time; 2996 }; 2997 2998 struct __db_channel { 2999 CHANNEL *channel; /* Pointer to internal state details. */ 3000 int eid; /* Env. ID passed in constructor. */ 3001 db_timeout_t timeout; 3002 3003 /* DB_CHANNEL PUBLIC HANDLE LIST BEGIN */ 3004 int (*close) __P((DB_CHANNEL *, u_int32_t)); 3005 int (*send_msg) __P((DB_CHANNEL *, DBT *, u_int32_t, u_int32_t)); 3006 int (*send_request) __P((DB_CHANNEL *, 3007 DBT *, u_int32_t, DBT *, db_timeout_t, u_int32_t)); 3008 int (*set_timeout) __P((DB_CHANNEL *, db_timeout_t)); 3009 /* DB_CHANNEL PUBLIC HANDLE LIST END */ 3010 }; 3011 3012 struct __db_site { 3013 ENV *env; 3014 int eid; 3015 const char *host; 3016 u_int port; 3017 u_int32_t flags; 3018 3019 /* DB_SITE PUBLIC HANDLE LIST BEGIN */ 3020 int (*get_address) __P((DB_SITE *, const char **, u_int *)); 3021 int (*get_config) __P((DB_SITE *, u_int32_t, u_int32_t *)); 3022 int (*get_eid) __P((DB_SITE *, int *)); 3023 int (*set_config) __P((DB_SITE *, u_int32_t, u_int32_t)); 3024 int (*remove) __P((DB_SITE *)); 3025 int (*close) __P((DB_SITE *)); 3026 /* DB_SITE PUBLIC HANDLE LIST END */ 3027 }; 3028 3029 #if DB_DBM_HSEARCH != 0 3030 /******************************************************* 3031 * Dbm/Ndbm historic interfaces. 3032 *******************************************************/ 3033 typedef struct __db DBM; 3034 3035 #define DBM_INSERT 0 /* Flags to dbm_store(). */ 3036 #define DBM_REPLACE 1 3037 3038 /* 3039 * The DB support for ndbm(3) always appends this suffix to the 3040 * file name to avoid overwriting the user's original database. 3041 */ 3042 #define DBM_SUFFIX ".db" 3043 3044 #if defined(_XPG4_2) 3045 typedef struct { 3046 char *dptr; 3047 size_t dsize; 3048 } datum; 3049 #else 3050 typedef struct { 3051 char *dptr; 3052 int dsize; 3053 } datum; 3054 #endif 3055 3056 /* 3057 * Translate NDBM calls into DB calls so that DB doesn't step on the 3058 * application's name space. 3059 */ 3060 #define dbm_clearerr(a) __db_ndbm_clearerr(a) 3061 #define dbm_close(a) __db_ndbm_close(a) 3062 #define dbm_delete(a, b) __db_ndbm_delete(a, b) 3063 #define dbm_dirfno(a) __db_ndbm_dirfno(a) 3064 #define dbm_error(a) __db_ndbm_error(a) 3065 #define dbm_fetch(a, b) __db_ndbm_fetch(a, b) 3066 #define dbm_firstkey(a) __db_ndbm_firstkey(a) 3067 #define dbm_nextkey(a) __db_ndbm_nextkey(a) 3068 #define dbm_open(a, b, c) __db_ndbm_open(a, b, c) 3069 #define dbm_pagfno(a) __db_ndbm_pagfno(a) 3070 #define dbm_rdonly(a) __db_ndbm_rdonly(a) 3071 #define dbm_store(a, b, c, d) \ 3072 __db_ndbm_store(a, b, c, d) 3073 3074 /* 3075 * Translate DBM calls into DB calls so that DB doesn't step on the 3076 * application's name space. 3077 * 3078 * The global variables dbrdonly, dirf and pagf were not retained when 4BSD 3079 * replaced the dbm interface with ndbm, and are not supported here. 3080 * 3081 * Definition of 'store' interface will cause macro conflict for modern 3082 * compiler with C++11 support, we will exclude this case here. 3083 */ 3084 #define dbminit(a) __db_dbm_init(a) 3085 #define dbmclose __db_dbm_close 3086 #if !defined(__cplusplus) 3087 #define delete(a) __db_dbm_delete(a) 3088 #define store(a, b) __db_dbm_store(a, b) 3089 #endif 3090 #define fetch(a) __db_dbm_fetch(a) 3091 #define firstkey __db_dbm_firstkey 3092 #define nextkey(a) __db_dbm_nextkey(a) 3093 3094 /******************************************************* 3095 * Hsearch historic interface. 3096 *******************************************************/ 3097 typedef enum { 3098 FIND, ENTER 3099 } ACTION; 3100 3101 typedef struct entry { 3102 char *key; 3103 char *data; 3104 } ENTRY; 3105 3106 #define hcreate(a) __db_hcreate(a) 3107 #define hdestroy __db_hdestroy 3108 #define hsearch(a, b) __db_hsearch(a, b) 3109 3110 #endif /* DB_DBM_HSEARCH */ 3111 3112 #if defined(__cplusplus) 3113 } 3114 #endif 3115 3116 /* Restore default compiler warnings */ 3117 #ifdef _MSC_VER 3118 #pragma warning(pop) 3119 #endif 3120 #endif /* !_DB_H_ */ 3121 /* DO NOT EDIT: automatically built by dist/s_apiflags. */ 3122 #define DB_AGGRESSIVE 0x00000001 3123 #define DB_ARCH_ABS 0x00000001 3124 #define DB_ARCH_DATA 0x00000002 3125 #define DB_ARCH_LOG 0x00000004 3126 #define DB_ARCH_REMOVE 0x00000008 3127 #define DB_AUTO_COMMIT 0x00000100 3128 #define DB_BACKUP_CLEAN 0x00000002 3129 #define DB_BACKUP_DEEP_COPY 0x00000008 3130 #define DB_BACKUP_FILES 0x00000010 3131 #define DB_BACKUP_NO_LOGS 0x00000020 3132 #define DB_BACKUP_SINGLE_DIR 0x00000040 3133 #define DB_BACKUP_UPDATE 0x00000080 3134 #define DB_BOOTSTRAP_HELPER 0x00000001 3135 #define DB_CDB_ALLDB 0x00000040 3136 #define DB_CHKSUM 0x00000008 3137 #define DB_CKP_INTERNAL 0x00000002 3138 #define DB_CONVERT 0x00000001 3139 #define DB_CREATE 0x00000001 3140 #define DB_CURSOR_BULK 0x00000001 3141 #define DB_CURSOR_TRANSIENT 0x00000008 3142 #define DB_CXX_NO_EXCEPTIONS 0x00000002 3143 #define DB_DATABASE_LOCKING 0x00000080 3144 #define DB_DIRECT 0x00000020 3145 #define DB_DIRECT_DB 0x00000200 3146 #define DB_DSYNC_DB 0x00000400 3147 #define DB_DUP 0x00000010 3148 #define DB_DUPSORT 0x00000002 3149 #define DB_DURABLE_UNKNOWN 0x00000040 3150 #define DB_ENCRYPT 0x00000001 3151 #define DB_ENCRYPT_AES 0x00000001 3152 #define DB_EXCL 0x00000004 3153 #define DB_EXTENT 0x00000100 3154 #define DB_FAILCHK 0x00000010 3155 #define DB_FAILCHK_ISALIVE 0x00000040 3156 #define DB_FAST_STAT 0x00000001 3157 #define DB_FCNTL_LOCKING 0x00001000 3158 #define DB_FLUSH 0x00000002 3159 #define DB_FORCE 0x00000001 3160 #define DB_FORCESYNC 0x00000001 3161 #define DB_FORCESYNCENV 0x00000002 3162 #define DB_FOREIGN_ABORT 0x00000001 3163 #define DB_FOREIGN_CASCADE 0x00000002 3164 #define DB_FOREIGN_NULLIFY 0x00000004 3165 #define DB_FREELIST_ONLY 0x00000001 3166 #define DB_FREE_SPACE 0x00000002 3167 #define DB_GROUP_CREATOR 0x00000002 3168 #define DB_HOTBACKUP_IN_PROGRESS 0x00000800 3169 #define DB_IGNORE_LEASE 0x00001000 3170 #define DB_IMMUTABLE_KEY 0x00000002 3171 #define DB_INIT_CDB 0x00000080 3172 #define DB_INIT_LOCK 0x00000100 3173 #define DB_INIT_LOG 0x00000200 3174 #define DB_INIT_MPOOL 0x00000400 3175 #define DB_INIT_MUTEX 0x00000800 3176 #define DB_INIT_REP 0x00001000 3177 #define DB_INIT_TXN 0x00002000 3178 #define DB_INORDER 0x00000020 3179 #define DB_INTERNAL_BLOB_DB 0x00002000 3180 #define DB_INTERNAL_PERSISTENT_DB 0x00004000 3181 #define DB_INTERNAL_TEMPORARY_DB 0x00008000 3182 #define DB_JOIN_NOSORT 0x00000001 3183 #define DB_LEGACY 0x00000004 3184 #define DB_LOCAL_SITE 0x00000008 3185 #define DB_LOCKDOWN 0x00004000 3186 #define DB_LOCK_CHECK 0x00000001 3187 #define DB_LOCK_IGNORE_REC 0x00000002 3188 #define DB_LOCK_NOWAIT 0x00000004 3189 #define DB_LOCK_RECORD 0x00000008 3190 #define DB_LOCK_SET_TIMEOUT 0x00000010 3191 #define DB_LOCK_SWITCH 0x00000020 3192 #define DB_LOCK_UPGRADE 0x00000040 3193 #define DB_LOG_AUTO_REMOVE 0x00000001 3194 #define DB_LOG_CHKPNT 0x00000001 3195 #define DB_LOG_COMMIT 0x00000004 3196 #define DB_LOG_DIRECT 0x00000002 3197 #define DB_LOG_DSYNC 0x00000004 3198 #define DB_LOG_EXT_FILE 0x00000008 3199 #define DB_LOG_BLOB 0x00000008 3200 #define DB_LOG_IN_MEMORY 0x00000010 3201 #define DB_LOG_NOCOPY 0x00000008 3202 #define DB_LOG_NOSYNC 0x00000020 3203 #define DB_LOG_NOT_DURABLE 0x00000010 3204 #define DB_LOG_NO_DATA 0x00000002 3205 #define DB_LOG_VERIFY_CAF 0x00000001 3206 #define DB_LOG_VERIFY_DBFILE 0x00000002 3207 #define DB_LOG_VERIFY_ERR 0x00000004 3208 #define DB_LOG_VERIFY_FORWARD 0x00000008 3209 #define DB_LOG_VERIFY_INTERR 0x00000010 3210 #define DB_LOG_VERIFY_PARTIAL 0x00000020 3211 #define DB_LOG_VERIFY_VERBOSE 0x00000040 3212 #define DB_LOG_VERIFY_WARNING 0x00000080 3213 #define DB_LOG_WRNOSYNC 0x00000020 3214 #define DB_LOG_ZERO 0x00000040 3215 #define DB_MPOOL_CREATE 0x00000001 3216 #define DB_MPOOL_DIRTY 0x00000002 3217 #define DB_MPOOL_DISCARD 0x00000001 3218 #define DB_MPOOL_EDIT 0x00000004 3219 #define DB_MPOOL_FREE 0x00000008 3220 #define DB_MPOOL_LAST 0x00000010 3221 #define DB_MPOOL_NEW 0x00000020 3222 #define DB_MPOOL_NOFILE 0x00000001 3223 #define DB_MPOOL_NOLOCK 0x00000004 3224 #define DB_MPOOL_TRY 0x00000040 3225 #define DB_MPOOL_UNLINK 0x00000002 3226 #define DB_MULTIPLE 0x00000800 3227 #define DB_MULTIPLE_KEY 0x00004000 3228 #define DB_MULTIVERSION 0x00000008 3229 #define DB_MUTEX_ALLOCATED 0x00000001 3230 #define DB_MUTEX_LOCKED 0x00000002 3231 #define DB_MUTEX_LOGICAL_LOCK 0x00000004 3232 #define DB_MUTEX_OWNER_DEAD 0x00000020 3233 #define DB_MUTEX_PROCESS_ONLY 0x00000008 3234 #define DB_MUTEX_SELF_BLOCK 0x00000010 3235 #define DB_MUTEX_SHARED 0x00000040 3236 #define DB_NOERROR 0x00010000 3237 #define DB_NOFLUSH 0x00001000 3238 #define DB_NOLOCKING 0x00002000 3239 #define DB_NOMMAP 0x00000010 3240 #define DB_NOORDERCHK 0x00000002 3241 #define DB_NOPANIC 0x00004000 3242 #define DB_NOSYNC 0x00000001 3243 #define DB_NO_AUTO_COMMIT 0x00020000 3244 #define DB_NO_CHECKPOINT 0x00008000 3245 #define DB_ODDFILESIZE 0x00000080 3246 #define DB_ORDERCHKONLY 0x00000004 3247 #define DB_OVERWRITE 0x00008000 3248 #define DB_PANIC_ENVIRONMENT 0x00010000 3249 #define DB_PRINTABLE 0x00000008 3250 #define DB_PRIVATE 0x00010000 3251 #define DB_PR_PAGE 0x00000010 3252 #define DB_PR_RECOVERYTEST 0x00000020 3253 #define DB_RDONLY 0x00000400 3254 #define DB_RDWRMASTER 0x00040000 3255 #define DB_READ_COMMITTED 0x00000400 3256 #define DB_READ_UNCOMMITTED 0x00000200 3257 #define DB_RECNUM 0x00000040 3258 #define DB_RECOVER 0x00000002 3259 #define DB_RECOVER_FATAL 0x00020000 3260 #define DB_REGION_INIT 0x00020000 3261 #define DB_REGISTER 0x00040000 3262 #define DB_RENUMBER 0x00000080 3263 #define DB_REPMGR_CONF_2SITE_STRICT 0x00000001 3264 #define DB_REPMGR_CONF_DISABLE_POLL 0x00000002 3265 #define DB_REPMGR_CONF_DISABLE_SSL 0x00000004 3266 #define DB_REPMGR_CONF_ELECTIONS 0x00000008 3267 #define DB_REPMGR_CONF_ENABLE_EPOLL 0x00000010 3268 #define DB_REPMGR_CONF_FORWARD_WRITES 0x00000020 3269 #define DB_REPMGR_CONF_PREFMAS_CLIENT 0x00000040 3270 #define DB_REPMGR_CONF_PREFMAS_MASTER 0x00000080 3271 #define DB_REPMGR_NEED_RESPONSE 0x00000001 3272 #define DB_REPMGR_PEER 0x00000010 3273 #define DB_REP_ANYWHERE 0x00000001 3274 #define DB_REP_CLIENT 0x00000001 3275 #define DB_REP_CONF_AUTOINIT 0x00000100 3276 #define DB_REP_CONF_AUTOROLLBACK 0x00000200 3277 #define DB_REP_CONF_BULK 0x00000400 3278 #define DB_REP_CONF_DELAYCLIENT 0x00000800 3279 #define DB_REP_CONF_ELECT_LOGLENGTH 0x00001000 3280 #define DB_REP_CONF_INMEM 0x00002000 3281 #define DB_REP_CONF_LEASE 0x00004000 3282 #define DB_REP_CONF_NOWAIT 0x00008000 3283 #define DB_REP_ELECTION 0x00000004 3284 #define DB_REP_MASTER 0x00000002 3285 #define DB_REP_NOBUFFER 0x00000002 3286 #define DB_REP_PERMANENT 0x00000004 3287 #define DB_REP_REREQUEST 0x00000008 3288 #define DB_REVSPLITOFF 0x00000100 3289 #define DB_RMW 0x00002000 3290 #define DB_SALVAGE 0x00000040 3291 #define DB_SA_SKIPFIRSTKEY 0x00000080 3292 #define DB_SA_UNKNOWNKEY 0x00000100 3293 #define DB_SEQ_DEC 0x00000001 3294 #define DB_SEQ_INC 0x00000002 3295 #define DB_SEQ_RANGE_SET 0x00000004 3296 #define DB_SEQ_WRAP 0x00000008 3297 #define DB_SEQ_WRAPPED 0x00000010 3298 #define DB_SET_LOCK_TIMEOUT 0x00000001 3299 #define DB_SET_MUTEX_FAILCHK_TIMEOUT 0x00000004 3300 #define DB_SET_REG_TIMEOUT 0x00000008 3301 #define DB_SET_TXN_NOW 0x00000010 3302 #define DB_SET_TXN_TIMEOUT 0x00000002 3303 #define DB_SHALLOW_DUP 0x00000100 3304 #define DB_SLICED 0x00000800 3305 #define DB_SNAPSHOT 0x00000200 3306 #define DB_STAT_ALL 0x00000004 3307 #define DB_STAT_ALLOC 0x00000008 3308 #define DB_STAT_CLEAR 0x00000001 3309 #define DB_STAT_LOCK_CONF 0x00000010 3310 #define DB_STAT_LOCK_LOCKERS 0x00000020 3311 #define DB_STAT_LOCK_OBJECTS 0x00000040 3312 #define DB_STAT_LOCK_PARAMS 0x00000080 3313 #define DB_STAT_MEMP_HASH 0x00000010 3314 #define DB_STAT_MEMP_NOERROR 0x00000020 3315 #define DB_STAT_SUBSYSTEM 0x00000002 3316 #define DB_STAT_SUMMARY 0x00000010 3317 #define DB_ST_DUPOK 0x00000200 3318 #define DB_ST_DUPSET 0x00000400 3319 #define DB_ST_DUPSORT 0x00000800 3320 #define DB_ST_IS_RECNO 0x00001000 3321 #define DB_ST_OVFL_LEAF 0x00002000 3322 #define DB_ST_RECNUM 0x00004000 3323 #define DB_ST_RELEN 0x00008000 3324 #define DB_ST_TOPLEVEL 0x00010000 3325 #define DB_SYSTEM_MEM 0x00080000 3326 #define DB_THREAD 0x00000020 3327 #define DB_TIME_NOTGRANTED 0x00040000 3328 #define DB_TRUNCATE 0x00080000 3329 #define DB_TXN_BULK 0x00000010 3330 #define DB_TXN_DISPATCH 0x00000040 3331 #define DB_TXN_FAMILY 0x00000080 3332 #define DB_TXN_NOSYNC 0x00000001 3333 #define DB_TXN_NOT_DURABLE 0x00000004 3334 #define DB_TXN_NOWAIT 0x00000002 3335 #define DB_TXN_SNAPSHOT 0x00000004 3336 #define DB_TXN_SYNC 0x00000008 3337 #define DB_TXN_WAIT 0x00000100 3338 #define DB_TXN_WRITE_NOSYNC 0x00000020 3339 #define DB_UNREF 0x00020000 3340 #define DB_UPGRADE 0x00000002 3341 #define DB_USE_ENVIRON 0x00000004 3342 #define DB_USE_ENVIRON_ROOT 0x00000008 3343 #define DB_VERB_BACKUP 0x00000001 3344 #define DB_VERB_DEADLOCK 0x00000002 3345 #define DB_VERB_FILEOPS 0x00000004 3346 #define DB_VERB_FILEOPS_ALL 0x00000008 3347 #define DB_VERB_MVCC 0x00000010 3348 #define DB_VERB_RECOVERY 0x00000020 3349 #define DB_VERB_REGISTER 0x00000040 3350 #define DB_VERB_REPLICATION 0x00000080 3351 #define DB_VERB_REPMGR_CONNFAIL 0x00000100 3352 #define DB_VERB_REPMGR_MISC 0x00000200 3353 #define DB_VERB_REPMGR_SSL_ALL 0x00000400 3354 #define DB_VERB_REPMGR_SSL_CONN 0x00000800 3355 #define DB_VERB_REPMGR_SSL_IO 0x00001000 3356 #define DB_VERB_REP_ELECT 0x00002000 3357 #define DB_VERB_REP_LEASE 0x00004000 3358 #define DB_VERB_REP_MISC 0x00008000 3359 #define DB_VERB_REP_MSGS 0x00010000 3360 #define DB_VERB_REP_SYNC 0x00020000 3361 #define DB_VERB_REP_SYSTEM 0x00040000 3362 #define DB_VERB_REP_TEST 0x00080000 3363 #define DB_VERB_SLICE 0x00100000 3364 #define DB_VERB_WAITSFOR 0x00200000 3365 #define DB_VERIFY 0x00000004 3366 #define DB_VERIFY_PARTITION 0x00040000 3367 #define DB_WRITECURSOR 0x00000010 3368 #define DB_WRITELOCK 0x00000020 3369 #define DB_WRITEOPEN 0x00100000 3370 #define DB_XA_CREATE 0x00000001 3371 #define DB_YIELDCPU 0x00080000 3372 3373 /* DO NOT EDIT: automatically built by dist/s_include. */ 3374 #ifndef _DB_EXT_PROT_IN_ 3375 #define _DB_EXT_PROT_IN_ 3376 3377 #if defined(__cplusplus) 3378 extern "C" { 3379 #endif 3380 3381 int db_copy __P((DB_ENV *, const char *, const char *, const char *)); 3382 int db_create __P((DB **, DB_ENV *, u_int32_t)); 3383 char *db_strerror __P((int)); 3384 int db_env_set_func_assert __P((void (*)(const char *, const char *, int))); 3385 int db_env_set_func_close __P((int (*)(int))); 3386 int db_env_set_func_dirfree __P((void (*)(char **, int))); 3387 int db_env_set_func_dirlist __P((int (*)(const char *, char ***, int *))); 3388 int db_env_set_func_exists __P((int (*)(const char *, int *))); 3389 int db_env_set_func_free __P((void (*)(void *))); 3390 int db_env_set_func_fsync __P((int (*)(int))); 3391 int db_env_set_func_ftruncate __P((int (*)(int, off_t))); 3392 int db_env_set_func_ioinfo __P((int (*)(const char *, int, u_int32_t *, u_int32_t *, u_int32_t *))); 3393 int db_env_set_func_malloc __P((void *(*)(size_t))); 3394 int db_env_set_func_file_map __P((int (*)(DB_ENV *, char *, size_t, int, void **), int (*)(DB_ENV *, void *))); 3395 int db_env_set_func_region_map __P((int (*)(DB_ENV *, char *, size_t, int *, void **), int (*)(DB_ENV *, void *))); 3396 int db_env_set_func_pread __P((ssize_t (*)(int, void *, size_t, off_t))); 3397 int db_env_set_func_pwrite __P((ssize_t (*)(int, const void *, size_t, off_t))); 3398 int db_env_set_func_open __P((int (*)(const char *, int, ...))); 3399 int db_env_set_func_read __P((ssize_t (*)(int, void *, size_t))); 3400 int db_env_set_func_realloc __P((void *(*)(void *, size_t))); 3401 int db_env_set_func_rename __P((int (*)(const char *, const char *))); 3402 int db_env_set_func_seek __P((int (*)(int, off_t, int))); 3403 int db_env_set_func_unlink __P((int (*)(const char *))); 3404 int db_env_set_func_write __P((ssize_t (*)(int, const void *, size_t))); 3405 int db_env_set_func_yield __P((int (*)(u_long, u_long))); 3406 int db_env_create __P((DB_ENV **, u_int32_t)); 3407 char *db_version __P((int *, int *, int *)); 3408 char *db_full_version __P((int *, int *, int *, int *, int *)); 3409 int log_compare __P((const DB_LSN *, const DB_LSN *)); 3410 #if defined(DB_WIN32) && !defined(DB_WINCE) 3411 int db_env_set_win_security __P((SECURITY_ATTRIBUTES *sa)); 3412 #endif 3413 int db_sequence_create __P((DB_SEQUENCE **, DB *, u_int32_t)); 3414 #if DB_DBM_HSEARCH != 0 3415 int __db_ndbm_clearerr __P((DBM *)); 3416 void __db_ndbm_close __P((DBM *)); 3417 int __db_ndbm_delete __P((DBM *, datum)); 3418 int __db_ndbm_dirfno __P((DBM *)); 3419 int __db_ndbm_error __P((DBM *)); 3420 datum __db_ndbm_fetch __P((DBM *, datum)); 3421 datum __db_ndbm_firstkey __P((DBM *)); 3422 datum __db_ndbm_nextkey __P((DBM *)); 3423 DBM *__db_ndbm_open __P((const char *, int, int)); 3424 int __db_ndbm_pagfno __P((DBM *)); 3425 int __db_ndbm_rdonly __P((DBM *)); 3426 int __db_ndbm_store __P((DBM *, datum, datum, int)); 3427 int __db_dbm_close __P((void)); 3428 int __db_dbm_delete __P((datum)); 3429 datum __db_dbm_fetch __P((datum)); 3430 datum __db_dbm_firstkey __P((void)); 3431 int __db_dbm_init __P((char *)); 3432 datum __db_dbm_nextkey __P((datum)); 3433 int __db_dbm_store __P((datum, datum)); 3434 #endif 3435 #if DB_DBM_HSEARCH != 0 3436 int __db_hcreate __P((size_t)); 3437 ENTRY *__db_hsearch __P((ENTRY, ACTION)); 3438 void __db_hdestroy __P((void)); 3439 #endif 3440 3441 #if defined(__cplusplus) 3442 } 3443 #endif 3444 #endif /* !_DB_EXT_PROT_IN_ */ 3445