2
* See the file LICENSE for redistribution information.
4
* Copyright (c) 1996-2002
5
* Sleepycat Software. All rights reserved.
9
* db.h include file layout:
11
* Database Environment.
14
* Shared buffer cache (mpool) subsystem.
15
* Transaction subsystem.
17
* Access method cursors.
18
* Dbm/Ndbm, Hsearch historic interfaces.
24
#ifndef __NO_SYSTEM_INCLUDES
25
#include <sys/types.h>
30
#if defined(__cplusplus)
36
* Handle function prototypes and the keyword "const". This steps on name
37
* space that DB doesn't control, but all of the other solutions are worse.
40
* While Microsoft's compiler is ANSI C compliant, it doesn't have _STDC_
41
* defined by default, you specify a command line flag or #pragma to turn
42
* it on. Don't do that, however, because some of Microsoft's own header
43
* files won't compile.
46
#if defined(__STDC__) || defined(__cplusplus) || defined(_MSC_VER)
47
#define __P(protos) protos /* ANSI C prototypes */
50
#define __P(protos) () /* K&R C preprocessor */
54
* Berkeley DB version information.
56
#define DB_VERSION_MAJOR @DB_VERSION_MAJOR@
57
#define DB_VERSION_MINOR @DB_VERSION_MINOR@
58
#define DB_VERSION_PATCH @DB_VERSION_PATCH@
59
#define DB_VERSION_STRING @DB_VERSION_STRING@
63
* Berkeley DB uses specifically sized types. If they're not provided by
64
* the system, typedef them here.
66
* We protect them against multiple inclusion using __BIT_TYPES_DEFINED__,
67
* as does BIND and Kerberos, since we don't know for sure what #include
68
* files the user is using.
71
* We also provide the standard u_int, u_long etc., if they're not provided
74
#ifndef __BIT_TYPES_DEFINED__
75
#define __BIT_TYPES_DEFINED__
89
/* Basic types that are exported or quasi-exported. */
90
typedef u_int32_t db_pgno_t; /* Page number type. */
91
typedef u_int16_t db_indx_t; /* Page offset type. */
92
#define DB_MAX_PAGES 0xffffffff /* >= # of pages in a file */
94
typedef u_int32_t db_recno_t; /* Record number type. */
95
#define DB_MAX_RECORDS 0xffffffff /* >= # of records in a tree */
97
typedef u_int32_t db_timeout_t; /* Type of a timeout. */
100
* Region offsets are currently limited to 32-bits. I expect that's going
101
* to have to be fixed in the not-too-distant future, since we won't want to
102
* split 100Gb memory pools into that many different regions.
104
typedef u_int32_t roff_t;
107
* Forward structure declarations, so we can declare pointers and
108
* applications can get type checking.
110
struct __db; typedef struct __db DB;
111
struct __db_bt_stat; typedef struct __db_bt_stat DB_BTREE_STAT;
112
struct __db_cipher; typedef struct __db_cipher DB_CIPHER;
113
struct __db_dbt; typedef struct __db_dbt DBT;
114
struct __db_env; typedef struct __db_env DB_ENV;
115
struct __db_h_stat; typedef struct __db_h_stat DB_HASH_STAT;
116
struct __db_ilock; typedef struct __db_ilock DB_LOCK_ILOCK;
117
struct __db_lock_stat; typedef struct __db_lock_stat DB_LOCK_STAT;
118
struct __db_lock_u; typedef struct __db_lock_u DB_LOCK;
119
struct __db_lockreq; typedef struct __db_lockreq DB_LOCKREQ;
120
struct __db_log_cursor; typedef struct __db_log_cursor DB_LOGC;
121
struct __db_log_stat; typedef struct __db_log_stat DB_LOG_STAT;
122
struct __db_lsn; typedef struct __db_lsn DB_LSN;
123
struct __db_mpool; typedef struct __db_mpool DB_MPOOL;
124
struct __db_mpool_fstat;typedef struct __db_mpool_fstat DB_MPOOL_FSTAT;
125
struct __db_mpool_stat; typedef struct __db_mpool_stat DB_MPOOL_STAT;
126
struct __db_mpoolfile; typedef struct __db_mpoolfile DB_MPOOLFILE;
127
struct __db_preplist; typedef struct __db_preplist DB_PREPLIST;
128
struct __db_qam_stat; typedef struct __db_qam_stat DB_QUEUE_STAT;
129
struct __db_rep; typedef struct __db_rep DB_REP;
130
struct __db_rep_stat; typedef struct __db_rep_stat DB_REP_STAT;
131
struct __db_txn; typedef struct __db_txn DB_TXN;
132
struct __db_txn_active; typedef struct __db_txn_active DB_TXN_ACTIVE;
133
struct __db_txn_stat; typedef struct __db_txn_stat DB_TXN_STAT;
134
struct __db_txnmgr; typedef struct __db_txnmgr DB_TXNMGR;
135
struct __dbc; typedef struct __dbc DBC;
136
struct __dbc_internal; typedef struct __dbc_internal DBC_INTERNAL;
137
struct __fh_t; typedef struct __fh_t DB_FH;
138
struct __fname; typedef struct __fname FNAME;
139
struct __key_range; typedef struct __key_range DB_KEY_RANGE;
140
struct __mpoolfile; typedef struct __mpoolfile MPOOLFILE;
141
struct __mutex_t; typedef struct __mutex_t DB_MUTEX;
143
/* Key/data structure -- a Data-Base Thang. */
146
* data/size must be fields 1 and 2 for DB 1.85 compatibility.
148
void *data; /* Key/data */
149
u_int32_t size; /* key/data length */
151
u_int32_t ulen; /* RO: length of user buffer. */
152
u_int32_t dlen; /* RO: get/put record length. */
153
u_int32_t doff; /* RO: get/put record offset. */
155
#define DB_DBT_APPMALLOC 0x001 /* Callback allocated memory. */
156
#define DB_DBT_ISSET 0x002 /* Lower level calls set value. */
157
#define DB_DBT_MALLOC 0x004 /* Return in malloc'd memory. */
158
#define DB_DBT_PARTIAL 0x008 /* Partial put/get. */
159
#define DB_DBT_REALLOC 0x010 /* Return in realloc'd memory. */
160
#define DB_DBT_USERMEM 0x020 /* Return in user's memory. */
161
#define DB_DBT_DUPOK 0x040 /* Insert if duplicate. */
167
* Interfaces which use any of these common flags should never have
168
* interface specific flags in this range.
170
#define DB_CREATE 0x000001 /* Create file as necessary. */
171
#define DB_CXX_NO_EXCEPTIONS 0x000002 /* C++: return error values. */
172
#define DB_FORCE 0x000004 /* Force (anything). */
173
#define DB_NOMMAP 0x000008 /* Don't mmap underlying file. */
174
#define DB_RDONLY 0x000010 /* Read-only (O_RDONLY). */
175
#define DB_RECOVER 0x000020 /* Run normal recovery. */
176
#define DB_THREAD 0x000040 /* Applications are threaded. */
177
#define DB_TRUNCATE 0x000080 /* Discard existing DB (O_TRUNC). */
178
#define DB_TXN_NOSYNC 0x000100 /* Do not sync log on commit. */
179
#define DB_USE_ENVIRON 0x000200 /* Use the environment. */
180
#define DB_USE_ENVIRON_ROOT 0x000400 /* Use the environment if root. */
184
* Interfaces which use any of these common flags should never have
185
* interface specific flags in this range.
188
* DB_ENV->set_flags, DB->associate, DB->del, DB->put, DB->open,
189
* DB->remove, DB->rename, DB->truncate
191
* DB->cursor, DB->get, DB->join, DB->open, DBcursor->c_get,
194
* Shared flags up to 0x000400 */
195
#define DB_AUTO_COMMIT 0x00800000 /* Implied transaction. */
196
#define DB_DIRTY_READ 0x01000000 /* Dirty Read. */
199
* Flags private to db_env_create.
201
#define DB_CLIENT 0x000001 /* Open for a client environment. */
204
* Flags private to db_create.
206
#define DB_XA_CREATE 0x000001 /* Open in an XA environment. */
209
* Flags private to DB_ENV->open.
210
* Shared flags up to 0x000400 */
211
#define DB_INIT_CDB 0x000800 /* Concurrent Access Methods. */
212
#define DB_INIT_LOCK 0x001000 /* Initialize locking. */
213
#define DB_INIT_LOG 0x002000 /* Initialize logging. */
214
#define DB_INIT_MPOOL 0x004000 /* Initialize mpool. */
215
#define DB_INIT_TXN 0x008000 /* Initialize transactions. */
216
#define DB_JOINENV 0x010000 /* Initialize all subsystems present. */
217
#define DB_LOCKDOWN 0x020000 /* Lock memory into physical core. */
218
#define DB_PRIVATE 0x040000 /* DB_ENV is process local. */
219
#define DB_RECOVER_FATAL 0x080000 /* Run catastrophic recovery. */
220
#define DB_SYSTEM_MEM 0x100000 /* Use system-backed memory. */
223
* Flags private to DB->open.
224
* Shared flags up to 0x000400 */
225
#define DB_EXCL 0x000800 /* Exclusive open (O_EXCL). */
226
#define DB_FCNTL_LOCKING 0x001000 /* UNDOC: fcntl(2) locking. */
227
#define DB_RDWRMASTER 0x002000 /* UNDOC: allow subdb master open R/W */
228
#define DB_WRITEOPEN 0x004000 /* UNDOC: open with write lock. */
231
* Flags private to DB_ENV->txn_begin.
232
* Shared flags up to 0x000400 */
233
#define DB_TXN_NOWAIT 0x000800 /* Do not wait for locks in this TXN. */
234
#define DB_TXN_SYNC 0x001000 /* Always sync log on commit. */
237
* Flags private to DB_ENV->set_encrypt.
239
#define DB_ENCRYPT_AES 0x000001 /* AES, assumes SHA1 checksum */
242
* Flags private to DB_ENV->set_flags.
243
* Shared flags up to 0x000400 */
244
#define DB_CDB_ALLDB 0x000800 /* Set CDB locking per environment. */
245
#define DB_DIRECT_DB 0x001000 /* Don't buffer databases in the OS. */
246
#define DB_DIRECT_LOG 0x002000 /* Don't buffer log files in the OS. */
247
#define DB_NOLOCKING 0x004000 /* Set locking/mutex behavior. */
248
#define DB_NOPANIC 0x008000 /* Set panic state per DB_ENV. */
249
#define DB_OVERWRITE 0x010000 /* Overwrite unlinked region files. */
250
#define DB_PANIC_ENVIRONMENT 0x020000 /* Set panic state per environment. */
251
#define DB_REGION_INIT 0x040000 /* Page-fault regions on open. */
252
#define DB_TXN_WRITE_NOSYNC 0x080000 /* Write, don't sync, on txn commit. */
253
#define DB_YIELDCPU 0x100000 /* Yield the CPU (a lot). */
256
* Flags private to DB->set_feedback's callback.
258
#define DB_UPGRADE 0x000001 /* Upgrading. */
259
#define DB_VERIFY 0x000002 /* Verifying. */
262
* Flags private to DB_MPOOLFILE->open.
263
* Shared flags up to 0x000400 */
264
#define DB_DIRECT 0x000800 /* Don't buffer the file in the OS. */
265
#define DB_EXTENT 0x001000 /* UNDOC: dealing with an extent. */
266
#define DB_ODDFILESIZE 0x002000 /* Truncate file to N * pgsize. */
269
* Flags private to DB->set_flags.
271
#define DB_CHKSUM_SHA1 0x000001 /* Use SHA1 checksumming */
272
#define DB_DUP 0x000002 /* Btree, Hash: duplicate keys. */
273
#define DB_DUPSORT 0x000004 /* Btree, Hash: duplicate keys. */
274
#define DB_ENCRYPT 0x000008 /* Btree, Hash: duplicate keys. */
275
#define DB_RECNUM 0x000010 /* Btree: record numbers. */
276
#define DB_RENUMBER 0x000020 /* Recno: renumber on insert/delete. */
277
#define DB_REVSPLITOFF 0x000040 /* Btree: turn off reverse splits. */
278
#define DB_SNAPSHOT 0x000080 /* Recno: snapshot the input. */
281
* Flags private to the DB->stat methods.
283
#define DB_STAT_CLEAR 0x000001 /* Clear stat after returning values. */
286
* Flags private to DB->join.
288
#define DB_JOIN_NOSORT 0x000001 /* Don't try to optimize join. */
291
* Flags private to DB->verify.
293
#define DB_AGGRESSIVE 0x000001 /* Salvage whatever could be data.*/
294
#define DB_NOORDERCHK 0x000002 /* Skip sort order/hashing check. */
295
#define DB_ORDERCHKONLY 0x000004 /* Only perform the order check. */
296
#define DB_PR_PAGE 0x000008 /* Show page contents (-da). */
297
#define DB_PR_RECOVERYTEST 0x000010 /* Recovery test (-dr). */
298
#define DB_PRINTABLE 0x000020 /* Use printable format for salvage. */
299
#define DB_SALVAGE 0x000040 /* Salvage what looks like data. */
302
* These must not go over 0x8000, or they will collide with the flags
303
* used by __bam_vrfy_subtree.
307
* Flags private to DB->set_rep_transport's send callback.
309
#define DB_REP_PERMANENT 0x0001 /* Important--app. may want to flush. */
311
/*******************************************************
313
*******************************************************/
314
#define DB_LOCKVERSION 1
316
#define DB_FILE_ID_LEN 20 /* Unique file ID length. */
319
* Deadlock detector modes; used in the DB_ENV structure to configure the
322
#define DB_LOCK_NORUN 0
323
#define DB_LOCK_DEFAULT 1 /* Default policy. */
324
#define DB_LOCK_EXPIRE 2 /* Only expire locks, no detection. */
325
#define DB_LOCK_MAXLOCKS 3 /* Abort txn with maximum # of locks. */
326
#define DB_LOCK_MINLOCKS 4 /* Abort txn with minimum # of locks. */
327
#define DB_LOCK_MINWRITE 5 /* Abort txn with minimum writelocks. */
328
#define DB_LOCK_OLDEST 6 /* Abort oldest transaction. */
329
#define DB_LOCK_RANDOM 7 /* Abort random transaction. */
330
#define DB_LOCK_YOUNGEST 8 /* Abort youngest transaction. */
332
/* Flag values for lock_vec(), lock_get(). */
333
#define DB_LOCK_FREE_LOCKER 0x001 /* Internal: Free locker as well. */
334
#define DB_LOCK_NOWAIT 0x002 /* Don't wait on unavailable lock. */
335
#define DB_LOCK_RECORD 0x004 /* Internal: record lock. */
336
#define DB_LOCK_REMOVE 0x008 /* Internal: flag object removed. */
337
#define DB_LOCK_SET_TIMEOUT 0x010 /* Internal: set lock timeout. */
338
#define DB_LOCK_SWITCH 0x020 /* Internal: switch existing lock. */
339
#define DB_LOCK_UPGRADE 0x040 /* Internal: upgrade existing lock. */
342
* Simple R/W lock modes and for multi-granularity intention locking.
345
* These values are NOT random, as they are used as an index into the lock
346
* conflicts arrays, i.e., DB_LOCK_IWRITE must be == 3, and DB_LOCK_IREAD
350
DB_LOCK_NG=0, /* Not granted. */
351
DB_LOCK_READ=1, /* Shared/read. */
352
DB_LOCK_WRITE=2, /* Exclusive/write. */
353
DB_LOCK_WAIT=3, /* Wait for event */
354
DB_LOCK_IWRITE=4, /* Intent exclusive/write. */
355
DB_LOCK_IREAD=5, /* Intent to share/read. */
356
DB_LOCK_IWR=6, /* Intent to read and write. */
357
DB_LOCK_DIRTY=7, /* Dirty Read. */
358
DB_LOCK_WWRITE=8 /* Was Written. */
365
DB_LOCK_DUMP=0, /* Display held locks. */
366
DB_LOCK_GET=1, /* Get the lock. */
367
DB_LOCK_GET_TIMEOUT=2, /* Get lock with a timeout. */
368
DB_LOCK_INHERIT=3, /* Pass locks to parent. */
369
DB_LOCK_PUT=4, /* Release the lock. */
370
DB_LOCK_PUT_ALL=5, /* Release locker's locks. */
371
DB_LOCK_PUT_OBJ=6, /* Release locker's locks on obj. */
372
DB_LOCK_PUT_READ=7, /* Release locker's read locks. */
373
DB_LOCK_TIMEOUT=8, /* Force a txn to timeout. */
374
DB_LOCK_TRADE=9, /* Trade locker ids on a lock. */
375
DB_LOCK_UPGRADE_WRITE=10 /* Upgrade writes for dirty reads. */
382
DB_LSTAT_ABORTED=1, /* Lock belongs to an aborted txn. */
383
DB_LSTAT_ERR=2, /* Lock is bad. */
384
DB_LSTAT_EXPIRED=3, /* Lock has expired. */
385
DB_LSTAT_FREE=4, /* Lock is unallocated. */
386
DB_LSTAT_HELD=5, /* Lock is currently held. */
387
DB_LSTAT_NOTEXIST=6, /* Object on which lock was waiting
389
DB_LSTAT_PENDING=7, /* Lock was waiting and has been
390
* promoted; waiting for the owner
391
* to run and upgrade it to held. */
392
DB_LSTAT_WAITING=8 /* Lock is on the wait queue. */
395
/* Lock statistics structure. */
396
struct __db_lock_stat {
397
u_int32_t st_id; /* Last allocated locker ID. */
398
u_int32_t st_cur_maxid; /* Current maximum unused ID. */
399
u_int32_t st_maxlocks; /* Maximum number of locks in table. */
400
u_int32_t st_maxlockers; /* Maximum num of lockers in table. */
401
u_int32_t st_maxobjects; /* Maximum num of objects in table. */
402
u_int32_t st_nmodes; /* Number of lock modes. */
403
u_int32_t st_nlocks; /* Current number of locks. */
404
u_int32_t st_maxnlocks; /* Maximum number of locks so far. */
405
u_int32_t st_nlockers; /* Current number of lockers. */
406
u_int32_t st_maxnlockers; /* Maximum number of lockers so far. */
407
u_int32_t st_nobjects; /* Current number of objects. */
408
u_int32_t st_maxnobjects; /* Maximum number of objects so far. */
409
u_int32_t st_nconflicts; /* Number of lock conflicts. */
410
u_int32_t st_nrequests; /* Number of lock gets. */
411
u_int32_t st_nreleases; /* Number of lock puts. */
412
u_int32_t st_nnowaits; /* Number of requests that would have
413
waited, but NOWAIT was set. */
414
u_int32_t st_ndeadlocks; /* Number of lock deadlocks. */
415
db_timeout_t st_locktimeout; /* Lock timeout. */
416
u_int32_t st_nlocktimeouts; /* Number of lock timeouts. */
417
db_timeout_t st_txntimeout; /* Transaction timeout. */
418
u_int32_t st_ntxntimeouts; /* Number of transaction timeouts. */
419
u_int32_t st_region_wait; /* Region lock granted after wait. */
420
u_int32_t st_region_nowait; /* Region lock granted without wait. */
421
u_int32_t st_regsize; /* Region size. */
426
* Internal DB access method lock.
429
db_pgno_t pgno; /* Page being locked. */
430
u_int8_t fileid[DB_FILE_ID_LEN];/* File id. */
431
#define DB_HANDLE_LOCK 1
432
#define DB_RECORD_LOCK 2
433
#define DB_PAGE_LOCK 3
434
#define DB_TXN_LOCK 4
435
u_int32_t type; /* Type of lock. */
440
* The structure is allocated by the caller and filled in during a
441
* lock_get request (or a lock_vec/DB_LOCK_GET).
444
size_t off; /* Offset of the lock in the region */
445
u_int32_t ndx; /* Index of the object referenced by
446
* this lock; used for locking. */
447
u_int32_t gen; /* Generation number of this lock. */
448
db_lockmode_t mode; /* mode of this lock. */
451
/* Lock request structure. */
452
struct __db_lockreq {
453
db_lockop_t op; /* Operation. */
454
db_lockmode_t mode; /* Requested mode. */
455
db_timeout_t timeout; /* Time to expire lock. */
456
DBT *obj; /* Object being locked. */
457
DB_LOCK lock; /* Lock returned. */
460
/*******************************************************
462
*******************************************************/
463
#define DB_LOGVERSION 7 /* Current log version. */
464
#define DB_LOGOLDVER 7 /* Oldest log version supported. */
465
#define DB_LOGMAGIC 0x040988
467
/* Flag values for log_archive(). */
468
#define DB_ARCH_ABS 0x001 /* Absolute pathnames. */
469
#define DB_ARCH_DATA 0x002 /* Data files. */
470
#define DB_ARCH_LOG 0x004 /* Log files. */
473
* A DB_LSN has two parts, a fileid which identifies a specific file, and an
474
* offset within that file. The fileid is an unsigned 4-byte quantity that
475
* uniquely identifies a file within the log directory -- currently a simple
476
* counter inside the log. The offset is also an unsigned 4-byte value. The
477
* log manager guarantees the offset is never more than 4 bytes by switching
478
* to a new log file before the maximum length imposed by an unsigned 4-byte
482
u_int32_t file; /* File ID. */
483
u_int32_t offset; /* File offset. */
490
struct __db_log_cursor {
491
DB_ENV *dbenv; /* Enclosing dbenv. */
493
DB_FH *c_fh; /* File handle. */
494
DB_LSN c_lsn; /* Cursor: LSN */
495
u_int32_t c_len; /* Cursor: record length */
496
u_int32_t c_prev; /* Cursor: previous record's offset */
498
DBT c_dbt; /* Return DBT. */
500
#define DB_LOGC_BUF_SIZE (32 * 1024)
501
u_int8_t *bp; /* Allocated read buffer. */
502
u_int32_t bp_size; /* Read buffer length in bytes. */
503
u_int32_t bp_rlen; /* Read buffer valid data length. */
504
DB_LSN bp_lsn; /* Read buffer first byte LSN. */
506
u_int32_t bp_maxrec; /* Max record length in the log file. */
509
int (*close) __P((DB_LOGC *, u_int32_t));
510
int (*get) __P((DB_LOGC *, DB_LSN *, DBT *, u_int32_t));
512
#define DB_LOG_DISK 0x01 /* Log record came from disk. */
513
#define DB_LOG_LOCKED 0x02 /* Log region already locked */
514
#define DB_LOG_SILENT_ERR 0x04 /* Turn-off error messages. */
518
/* Log statistics structure. */
519
struct __db_log_stat {
520
u_int32_t st_magic; /* Log file magic number. */
521
u_int32_t st_version; /* Log file version number. */
522
int st_mode; /* Log file mode. */
523
u_int32_t st_lg_bsize; /* Log buffer size. */
524
u_int32_t st_lg_size; /* Log file size. */
525
u_int32_t st_w_bytes; /* Bytes to log. */
526
u_int32_t st_w_mbytes; /* Megabytes to log. */
527
u_int32_t st_wc_bytes; /* Bytes to log since checkpoint. */
528
u_int32_t st_wc_mbytes; /* Megabytes to log since checkpoint. */
529
u_int32_t st_wcount; /* Total writes to the log. */
530
u_int32_t st_wcount_fill; /* Overflow writes to the log. */
531
u_int32_t st_scount; /* Total syncs to the log. */
532
u_int32_t st_region_wait; /* Region lock granted after wait. */
533
u_int32_t st_region_nowait; /* Region lock granted without wait. */
534
u_int32_t st_cur_file; /* Current log file number. */
535
u_int32_t st_cur_offset; /* Current log file offset. */
536
u_int32_t st_disk_file; /* Known on disk log file number. */
537
u_int32_t st_disk_offset; /* Known on disk log file offset. */
538
u_int32_t st_regsize; /* Region size. */
539
u_int32_t st_maxcommitperflush; /* Max number of commits in a flush. */
540
u_int32_t st_mincommitperflush; /* Min number of commits in a flush. */
543
/*******************************************************
544
* Shared buffer cache (mpool).
545
*******************************************************/
546
/* Flag values for DB_MPOOLFILE->get. */
547
#define DB_MPOOL_CREATE 0x001 /* Create a page. */
548
#define DB_MPOOL_LAST 0x002 /* Return the last page. */
549
#define DB_MPOOL_NEW 0x004 /* Create a new page. */
551
/* Flag values for DB_MPOOLFILE->put, DB_MPOOLFILE->set. */
552
#define DB_MPOOL_CLEAN 0x001 /* Page is not modified. */
553
#define DB_MPOOL_DIRTY 0x002 /* Page is modified. */
554
#define DB_MPOOL_DISCARD 0x004 /* Don't cache the page. */
556
/* Priority values for DB_MPOOLFILE->set_priority. */
558
DB_PRIORITY_VERY_LOW=1,
560
DB_PRIORITY_DEFAULT=3,
562
DB_PRIORITY_VERY_HIGH=5
565
/* Per-process DB_MPOOLFILE information. */
566
struct __db_mpoolfile {
567
/* These fields need to be protected for multi-threaded support. */
568
DB_MUTEX *mutexp; /* Structure thread lock. */
570
DB_FH *fhp; /* Underlying file handle. */
572
u_int32_t ref; /* Reference count. */
576
* The pinref and q fields are protected by the region lock, not the
577
* DB_MPOOLFILE structure mutex. We don't use the structure mutex
578
* because then I/O (which holds the structure lock held because of
579
* the race between the seek and write of the file descriptor) would
580
* block any other put/get calls using this DB_MPOOLFILE structure.
582
u_int32_t pinref; /* Pinned block reference count. */
586
* Explicit representations of structures from queue.h.
587
* TAILQ_ENTRY(__db_mpoolfile) q;
590
struct __db_mpoolfile *tqe_next;
591
struct __db_mpoolfile **tqe_prev;
592
} q; /* Linked list of DB_MPOOLFILE's. */
595
* These fields are not thread-protected because they are initialized
596
* when the file is opened and never modified.
598
int ftype; /* File type. */
599
DBT *pgcookie; /* Byte-string passed to pgin/pgout. */
600
u_int8_t *fileid; /* Unique file ID. */
601
int32_t lsn_offset; /* LSN offset in page. */
602
u_int32_t clear_len; /* Cleared length on created pages. */
604
DB_MPOOL *dbmp; /* Overlying DB_MPOOL. */
605
MPOOLFILE *mfp; /* Underlying MPOOLFILE. */
607
void *addr; /* Address of mmap'd region. */
608
size_t len; /* Length of mmap'd region. */
611
int (*close) __P((DB_MPOOLFILE *, u_int32_t));
612
int (*get) __P((DB_MPOOLFILE *, db_pgno_t *, u_int32_t, void *));
613
void (*get_fileid) __P((DB_MPOOLFILE *, u_int8_t *));
614
void (*last_pgno) __P((DB_MPOOLFILE *, db_pgno_t *));
615
int (*open)__P((DB_MPOOLFILE *, const char *, u_int32_t, int, size_t));
616
int (*put) __P((DB_MPOOLFILE *, void *, u_int32_t));
617
void (*refcnt) __P((DB_MPOOLFILE *, db_pgno_t *));
618
int (*set) __P((DB_MPOOLFILE *, void *, u_int32_t));
619
int (*set_clear_len) __P((DB_MPOOLFILE *, u_int32_t));
620
int (*set_fileid) __P((DB_MPOOLFILE *, u_int8_t *));
621
int (*set_ftype) __P((DB_MPOOLFILE *, int));
622
int (*set_lsn_offset) __P((DB_MPOOLFILE *, int32_t));
623
int (*set_pgcookie) __P((DB_MPOOLFILE *, DBT *));
624
int (*set_priority) __P((DB_MPOOLFILE *, DB_CACHE_PRIORITY));
625
void (*set_unlink) __P((DB_MPOOLFILE *, int));
626
int (*sync) __P((DB_MPOOLFILE *));
629
* MP_OPEN_CALLED and MP_READONLY do not need to be thread protected
630
* because they are initialized when the file is opened, and never
633
* MP_FLUSH, MP_UPGRADE and MP_UPGRADE_FAIL are thread protected
634
* becase they are potentially read by multiple threads of control.
636
#define MP_FLUSH 0x001 /* Was opened to flush a buffer. */
637
#define MP_OPEN_CALLED 0x002 /* File opened. */
638
#define MP_READONLY 0x004 /* File is readonly. */
639
#define MP_UPGRADE 0x008 /* File descriptor is readwrite. */
640
#define MP_UPGRADE_FAIL 0x010 /* Upgrade wasn't possible. */
645
* Mpool statistics structure.
647
struct __db_mpool_stat {
648
u_int32_t st_gbytes; /* Total cache size: GB. */
649
u_int32_t st_bytes; /* Total cache size: B. */
650
u_int32_t st_ncache; /* Number of caches. */
651
u_int32_t st_regsize; /* Cache size. */
652
u_int32_t st_map; /* Pages from mapped files. */
653
u_int32_t st_cache_hit; /* Pages found in the cache. */
654
u_int32_t st_cache_miss; /* Pages not found in the cache. */
655
u_int32_t st_page_create; /* Pages created in the cache. */
656
u_int32_t st_page_in; /* Pages read in. */
657
u_int32_t st_page_out; /* Pages written out. */
658
u_int32_t st_ro_evict; /* Clean pages forced from the cache. */
659
u_int32_t st_rw_evict; /* Dirty pages forced from the cache. */
660
u_int32_t st_page_trickle; /* Pages written by memp_trickle. */
661
u_int32_t st_pages; /* Total number of pages. */
662
u_int32_t st_page_clean; /* Clean pages. */
663
u_int32_t st_page_dirty; /* Dirty pages. */
664
u_int32_t st_hash_buckets; /* Number of hash buckets. */
665
u_int32_t st_hash_searches; /* Total hash chain searches. */
666
u_int32_t st_hash_longest; /* Longest hash chain searched. */
667
u_int32_t st_hash_examined; /* Total hash entries searched. */
668
u_int32_t st_hash_nowait; /* Hash lock granted with nowait. */
669
u_int32_t st_hash_wait; /* Hash lock granted after wait. */
670
u_int32_t st_hash_max_wait; /* Max hash lock granted after wait. */
671
u_int32_t st_region_nowait; /* Region lock granted with nowait. */
672
u_int32_t st_region_wait; /* Region lock granted after wait. */
673
u_int32_t st_alloc; /* Number of page allocations. */
674
u_int32_t st_alloc_buckets; /* Buckets checked during allocation. */
675
u_int32_t st_alloc_max_buckets; /* Max checked during allocation. */
676
u_int32_t st_alloc_pages; /* Pages checked during allocation. */
677
u_int32_t st_alloc_max_pages; /* Max checked during allocation. */
680
/* Mpool file statistics structure. */
681
struct __db_mpool_fstat {
682
char *file_name; /* File name. */
683
size_t st_pagesize; /* Page size. */
684
u_int32_t st_map; /* Pages from mapped files. */
685
u_int32_t st_cache_hit; /* Pages found in the cache. */
686
u_int32_t st_cache_miss; /* Pages not found in the cache. */
687
u_int32_t st_page_create; /* Pages created in the cache. */
688
u_int32_t st_page_in; /* Pages read in. */
689
u_int32_t st_page_out; /* Pages written out. */
692
/*******************************************************
693
* Transactions and recovery.
694
*******************************************************/
695
#define DB_TXNVERSION 1
698
DB_TXN_ABORT=0, /* Public. */
699
DB_TXN_APPLY=1, /* Public. */
700
DB_TXN_BACKWARD_ALLOC=2, /* Internal. */
701
DB_TXN_BACKWARD_ROLL=3, /* Public. */
702
DB_TXN_FORWARD_ROLL=4, /* Public. */
703
DB_TXN_GETPGNOS=5, /* Internal. */
704
DB_TXN_OPENFILES=6, /* Internal. */
705
DB_TXN_POPENFILES=7, /* Internal. */
706
DB_TXN_PRINT=8 /* Public. */
710
* BACKWARD_ALLOC is used during the forward pass to pick up any aborted
711
* allocations for files that were created during the forward pass.
712
* The main difference between _ALLOC and _ROLL is that the entry for
713
* the file not exist during the rollforward pass.
715
#define DB_UNDO(op) ((op) == DB_TXN_ABORT || \
716
(op) == DB_TXN_BACKWARD_ROLL || (op) == DB_TXN_BACKWARD_ALLOC)
717
#define DB_REDO(op) ((op) == DB_TXN_FORWARD_ROLL || (op) == DB_TXN_APPLY)
720
DB_TXNMGR *mgrp; /* Pointer to transaction manager. */
721
DB_TXN *parent; /* Pointer to transaction's parent. */
722
DB_LSN last_lsn; /* Lsn of last log write. */
723
u_int32_t txnid; /* Unique transaction id. */
724
roff_t off; /* Detail structure within region. */
725
db_timeout_t lock_timeout; /* Timeout for locks for this txn. */
726
db_timeout_t expire; /* Time this txn expires. */
727
void *txn_list; /* Undo information for parent. */
731
* Explicit representations of structures from queue.h.
732
* TAILQ_ENTRY(__db_txn) links;
735
struct __db_txn *tqe_next;
736
struct __db_txn **tqe_prev;
737
} links; /* Links transactions off manager. */
741
* Explicit representations of structures from queue.h.
742
* TAILQ_HEAD(__events, __txn_event) events;
745
struct __txn_event *tqh_first;
746
struct __txn_event **tqh_last;
751
* Explicit representations of structures from queue.h.
752
* TAILQ_HEAD(__kids, __db_txn) kids;
755
struct __db_txn *tqh_first;
756
struct __db_txn **tqh_last;
761
* Explicit representations of structures from queue.h.
762
* TAILQ_ENTRY(__db_txn) klinks;
765
struct __db_txn *tqe_next;
766
struct __db_txn **tqe_prev;
769
/* API-private structure: used by C++ */
772
u_int32_t cursors; /* Number of cursors open for txn */
775
int (*abort) __P((DB_TXN *));
776
int (*commit) __P((DB_TXN *, u_int32_t));
777
int (*discard) __P((DB_TXN *, u_int32_t));
778
u_int32_t (*id) __P((DB_TXN *));
779
int (*prepare) __P((DB_TXN *, u_int8_t *));
780
int (*set_timeout) __P((DB_TXN *, db_timeout_t, u_int32_t));
782
#define TXN_CHILDCOMMIT 0x01 /* Transaction that has committed. */
783
#define TXN_COMPENSATE 0x02 /* Compensating transaction. */
784
#define TXN_DIRTY_READ 0x04 /* Transaction does dirty reads. */
785
#define TXN_LOCKTIMEOUT 0x08 /* Transaction has a lock timeout. */
786
#define TXN_MALLOC 0x10 /* Structure allocated by TXN system. */
787
#define TXN_NOSYNC 0x20 /* Do not sync on prepare and commit. */
788
#define TXN_NOWAIT 0x40 /* Do not wait on locks. */
789
#define TXN_SYNC 0x80 /* Sync on prepare and commit. */
793
/* Transaction statistics structure. */
794
struct __db_txn_active {
795
u_int32_t txnid; /* Transaction ID */
796
u_int32_t parentid; /* Transaction ID of parent */
797
DB_LSN lsn; /* LSN when transaction began */
800
struct __db_txn_stat {
801
DB_LSN st_last_ckp; /* lsn of the last checkpoint */
802
time_t st_time_ckp; /* time of last checkpoint */
803
u_int32_t st_last_txnid; /* last transaction id given out */
804
u_int32_t st_maxtxns; /* maximum txns possible */
805
u_int32_t st_naborts; /* number of aborted transactions */
806
u_int32_t st_nbegins; /* number of begun transactions */
807
u_int32_t st_ncommits; /* number of committed transactions */
808
u_int32_t st_nactive; /* number of active transactions */
809
u_int32_t st_nrestores; /* number of restored transactions
811
u_int32_t st_maxnactive; /* maximum active transactions */
812
DB_TXN_ACTIVE *st_txnarray; /* array of active transactions */
813
u_int32_t st_region_wait; /* Region lock granted after wait. */
814
u_int32_t st_region_nowait; /* Region lock granted without wait. */
815
u_int32_t st_regsize; /* Region size. */
819
* Structure used for two phase commit interface. Berkeley DB support for two
820
* phase commit is compatible with the X/open XA interface. The xa #define
821
* XIDDATASIZE defines the size of a global transaction ID. We have our own
822
* version here which must have the same value.
824
#define DB_XIDDATASIZE 128
825
struct __db_preplist {
827
u_int8_t gid[DB_XIDDATASIZE];
830
/*******************************************************
832
*******************************************************/
833
/* Special, out-of-band environment IDs. */
834
#define DB_EID_BROADCAST -1
835
#define DB_EID_INVALID -2
837
/* rep_start flags values */
838
#define DB_REP_CLIENT 0x001
839
#define DB_REP_LOGSONLY 0x002
840
#define DB_REP_MASTER 0x004
842
/* Replication statistics. */
843
struct __db_rep_stat {
845
* Many replication statistics fields cannot be protected by a mutex
846
* without an unacceptable performance penalty, since most message
847
* processing is done without the need to hold a region-wide lock.
848
* Fields whose comments end with a '+' may be updated without holding
849
* the replication or log mutexes (as appropriate), and thus may be
850
* off somewhat (or, on unreasonable architectures under unlucky
851
* circumstances, garbaged).
853
u_int32_t st_status; /* Current replication status. */
854
DB_LSN st_next_lsn; /* Next LSN to use or expect. */
855
DB_LSN st_waiting_lsn; /* LSN we're awaiting, if any. */
857
u_int32_t st_dupmasters; /* # of times a duplicate master
858
condition was detected.+ */
859
int st_env_id; /* Current environment ID. */
860
int st_env_priority; /* Current environment priority. */
861
u_int32_t st_gen; /* Current generation number. */
862
u_int32_t st_log_duplicated; /* Log records received multiply.+ */
863
u_int32_t st_log_queued; /* Log records currently queued.+ */
864
u_int32_t st_log_queued_max; /* Max. log records queued at once.+ */
865
u_int32_t st_log_queued_total; /* Total # of log recs. ever queued.+ */
866
u_int32_t st_log_records; /* Log records received and put.+ */
867
u_int32_t st_log_requested; /* Log recs. missed and requested.+ */
868
int st_master; /* Env. ID of the current master. */
869
u_int32_t st_master_changes; /* # of times we've switched masters. */
870
u_int32_t st_msgs_badgen; /* Messages with a bad generation #.+ */
871
u_int32_t st_msgs_processed; /* Messages received and processed.+ */
872
u_int32_t st_msgs_recover; /* Messages ignored because this site
873
was a client in recovery.+ */
874
u_int32_t st_msgs_send_failures;/* # of failed message sends.+ */
875
u_int32_t st_msgs_sent; /* # of successful message sends.+ */
876
u_int32_t st_newsites; /* # of NEWSITE msgs. received.+ */
877
int st_nsites; /* Current number of sites we will
878
assume during elections. */
879
u_int32_t st_nthrottles; /* # of times we were throttled. */
880
u_int32_t st_outdated; /* # of times we detected and returned
881
an OUTDATED condition.+ */
882
u_int32_t st_txns_applied; /* # of transactions applied.+ */
884
/* Elections generally. */
885
u_int32_t st_elections; /* # of elections held.+ */
886
u_int32_t st_elections_won; /* # of elections won by this site.+ */
888
/* Statistics about an in-progress election. */
889
int st_election_cur_winner; /* Current front-runner. */
890
u_int32_t st_election_gen; /* Election generation number. */
891
DB_LSN st_election_lsn; /* Max. LSN of current winner. */
892
int st_election_nsites; /* # of "registered voters". */
893
int st_election_priority; /* Current election priority. */
894
int st_election_status; /* Current election status. */
895
int st_election_tiebreaker; /* Election tiebreaker value. */
896
int st_election_votes; /* Votes received in this round. */
899
/*******************************************************
901
*******************************************************/
907
DB_UNKNOWN=5 /* Figure it out on open. */
910
#define DB_RENAMEMAGIC 0x030800 /* File has been renamed. */
912
#define DB_BTREEVERSION 9 /* Current btree version. */
913
#define DB_BTREEOLDVER 8 /* Oldest btree version supported. */
914
#define DB_BTREEMAGIC 0x053162
916
#define DB_HASHVERSION 8 /* Current hash version. */
917
#define DB_HASHOLDVER 7 /* Oldest hash version supported. */
918
#define DB_HASHMAGIC 0x061561
920
#define DB_QAMVERSION 4 /* Current queue version. */
921
#define DB_QAMOLDVER 3 /* Oldest queue version supported. */
922
#define DB_QAMMAGIC 0x042253
925
* DB access method and cursor operation values. Each value is an operation
926
* code to which additional bit flags are added.
928
#define DB_AFTER 1 /* c_put() */
929
#define DB_APPEND 2 /* put() */
930
#define DB_BEFORE 3 /* c_put() */
931
#define DB_CACHED_COUNTS 4 /* stat() */
932
#define DB_COMMIT 5 /* log_put() (internal) */
933
#define DB_CONSUME 6 /* get() */
934
#define DB_CONSUME_WAIT 7 /* get() */
935
#define DB_CURRENT 8 /* c_get(), c_put(), DB_LOGC->get() */
936
#define DB_FAST_STAT 9 /* stat() */
937
#define DB_FIRST 10 /* c_get(), DB_LOGC->get() */
938
#define DB_GET_BOTH 11 /* get(), c_get() */
939
#define DB_GET_BOTHC 12 /* c_get() (internal) */
940
#define DB_GET_BOTH_RANGE 13 /* get(), c_get() */
941
#define DB_GET_RECNO 14 /* c_get() */
942
#define DB_JOIN_ITEM 15 /* c_get(); do not do primary lookup */
943
#define DB_KEYFIRST 16 /* c_put() */
944
#define DB_KEYLAST 17 /* c_put() */
945
#define DB_LAST 18 /* c_get(), DB_LOGC->get() */
946
#define DB_NEXT 19 /* c_get(), DB_LOGC->get() */
947
#define DB_NEXT_DUP 20 /* c_get() */
948
#define DB_NEXT_NODUP 21 /* c_get() */
949
#define DB_NODUPDATA 22 /* put(), c_put() */
950
#define DB_NOOVERWRITE 23 /* put() */
951
#define DB_NOSYNC 24 /* close() */
952
#define DB_POSITION 25 /* c_dup() */
953
#define DB_POSITIONI 26 /* c_dup() (internal) */
954
#define DB_PREV 27 /* c_get(), DB_LOGC->get() */
955
#define DB_PREV_NODUP 28 /* c_get(), DB_LOGC->get() */
956
#define DB_RECORDCOUNT 29 /* stat() */
957
#define DB_SET 30 /* c_get(), DB_LOGC->get() */
958
#define DB_SET_LOCK_TIMEOUT 31 /* set_timout() */
959
#define DB_SET_RANGE 32 /* c_get() */
960
#define DB_SET_RECNO 33 /* get(), c_get() */
961
#define DB_SET_TXN_NOW 34 /* set_timout() (internal) */
962
#define DB_SET_TXN_TIMEOUT 35 /* set_timout() */
963
#define DB_UPDATE_SECONDARY 36 /* c_get(), c_del() (internal) */
964
#define DB_WRITECURSOR 37 /* cursor() */
965
#define DB_WRITELOCK 38 /* cursor() (internal) */
967
/* This has to change when the max opcode hits 255. */
968
#define DB_OPFLAGS_MASK 0x000000ff /* Mask for operations flags. */
969
/* DB_DIRTY_READ 0x01000000 Dirty Read. */
970
#define DB_FLUSH 0x02000000 /* Flush data to disk. */
971
#define DB_MULTIPLE 0x04000000 /* Return multiple data values. */
972
#define DB_MULTIPLE_KEY 0x08000000 /* Return multiple data/key pairs. */
973
#define DB_NOCOPY 0x10000000 /* Don't copy data */
974
#define DB_PERMANENT 0x20000000 /* Flag record with REP_PERMANENT. */
975
#define DB_RMW 0x40000000 /* Acquire write flag immediately. */
976
#define DB_WRNOSYNC 0x80000000 /* Private: write, don't sync log_put */
979
* DB (user visible) error return codes.
982
* For source compatibility with DB 2.X deadlock return (EAGAIN), use the
985
* #define DB_LOCK_DEADLOCK EAGAIN
988
* We don't want our error returns to conflict with other packages where
989
* possible, so pick a base error value that's hopefully not common. We
990
* document that we own the error name space from -30,800 to -30,999.
992
/* DB (public) error return codes. */
993
#define DB_DONOTINDEX (-30999)/* "Null" return from 2ndary callbk. */
994
#define DB_KEYEMPTY (-30998)/* Key/data deleted or never created. */
995
#define DB_KEYEXIST (-30997)/* The key/data pair already exists. */
996
#define DB_LOCK_DEADLOCK (-30996)/* Deadlock. */
997
#define DB_LOCK_NOTGRANTED (-30995)/* Lock unavailable. */
998
#define DB_NOSERVER (-30994)/* Server panic return. */
999
#define DB_NOSERVER_HOME (-30993)/* Bad home sent to server. */
1000
#define DB_NOSERVER_ID (-30992)/* Bad ID sent to server. */
1001
#define DB_NOTFOUND (-30991)/* Key/data pair not found (EOF). */
1002
#define DB_OLD_VERSION (-30990)/* Out-of-date version. */
1003
#define DB_PAGE_NOTFOUND (-30989)/* Requested page not found. */
1004
#define DB_REP_DUPMASTER (-30988)/* There are two masters. */
1005
#define DB_REP_HOLDELECTION (-30987)/* Time to hold an election. */
1006
#define DB_REP_NEWMASTER (-30986)/* We have learned of a new master. */
1007
#define DB_REP_NEWSITE (-30985)/* New site entered system. */
1008
#define DB_REP_OUTDATED (-30984)/* Site is too far behind master. */
1009
#define DB_REP_UNAVAIL (-30983)/* Site cannot currently be reached. */
1010
#define DB_RUNRECOVERY (-30982)/* Panic return. */
1011
#define DB_SECONDARY_BAD (-30981)/* Secondary index corrupt. */
1012
#define DB_VERIFY_BAD (-30980)/* Verify failed; bad format. */
1014
/* DB (private) error return codes. */
1015
#define DB_ALREADY_ABORTED (-30899)
1016
#define DB_DELETED (-30898)/* Recovery file marked deleted. */
1017
#define DB_JAVA_CALLBACK (-30897)/* Exception during a java callback. */
1018
#define DB_LOCK_NOTEXIST (-30896)/* Object to lock is gone. */
1019
#define DB_NEEDSPLIT (-30895)/* Page needs to be split. */
1020
#define DB_SURPRISE_KID (-30894)/* Child commit where parent
1021
didn't know it was a parent. */
1022
#define DB_SWAPBYTES (-30893)/* Database needs byte swapping. */
1023
#define DB_TIMEOUT (-30892)/* Timed out waiting for election. */
1024
#define DB_TXN_CKP (-30891)/* Encountered ckp record in log. */
1025
#define DB_VERIFY_FATAL (-30890)/* DB->verify cannot proceed. */
1027
/* Database handle. */
1029
/*******************************************************
1030
* Public: owned by the application.
1031
*******************************************************/
1032
u_int32_t pgsize; /* Database logical page size. */
1035
int (*db_append_recno) __P((DB *, DBT *, db_recno_t));
1036
void (*db_feedback) __P((DB *, int, int));
1037
int (*dup_compare) __P((DB *, const DBT *, const DBT *));
1039
void *app_private; /* Application-private handle. */
1041
/*******************************************************
1042
* Private: owned by DB.
1043
*******************************************************/
1044
DB_ENV *dbenv; /* Backing environment. */
1046
DBTYPE type; /* DB access method type. */
1048
DB_MPOOLFILE *mpf; /* Backing buffer pool. */
1049
DB_CACHE_PRIORITY priority; /* Priority in the buffer pool. */
1051
DB_MUTEX *mutexp; /* Synchronization for free threading */
1053
u_int8_t fileid[DB_FILE_ID_LEN];/* File's unique ID for locking. */
1055
u_int32_t adj_fileid; /* File's unique ID for curs. adj. */
1057
#define DB_LOGFILEID_INVALID -1
1058
FNAME *log_filename; /* File's naming info for logging. */
1060
db_pgno_t meta_pgno; /* Meta page number */
1061
u_int32_t lid; /* Locker id for handle locking. */
1062
u_int32_t cur_lid; /* Current handle lock holder. */
1063
u_int32_t associate_lid; /* Locker id for DB->associate call. */
1064
DB_LOCK handle_lock; /* Lock held on this handle. */
1066
long cl_id; /* RPC: remote client id. */
1069
* Returned data memory for DB->get() and friends.
1071
DBT my_rskey; /* Secondary key. */
1072
DBT my_rkey; /* [Primary] key. */
1073
DBT my_rdata; /* Data. */
1077
* Some applications use DB but implement their own locking outside of
1078
* DB. If they're using fcntl(2) locking on the underlying database
1079
* file, and we open and close a file descriptor for that file, we will
1080
* discard their locks. The DB_FCNTL_LOCKING flag to DB->open is an
1081
* undocumented interface to support this usage which leaves any file
1082
* descriptors we open until DB->close. This will only work with the
1083
* DB->open interface and simple caches, e.g., creating a transaction
1084
* thread may open/close file descriptors this flag doesn't protect.
1085
* Locking with fcntl(2) on a file that you don't own is a very, very
1086
* unsafe thing to do. 'Nuff said.
1088
DB_FH *saved_open_fhp; /* Saved file handle. */
1091
* Linked list of DBP's, linked from the DB_ENV, used to keep track
1092
* of all open db handles for cursor adjustment.
1095
* Explicit representations of structures from queue.h.
1096
* LIST_ENTRY(__db) dblistlinks;
1099
struct __db *le_next;
1100
struct __db **le_prev;
1107
* Explicit representations of structures from queue.h.
1108
* TAILQ_HEAD(__cq_fq, __dbc) free_queue;
1109
* TAILQ_HEAD(__cq_aq, __dbc) active_queue;
1110
* TAILQ_HEAD(__cq_jq, __dbc) join_queue;
1113
struct __dbc *tqh_first;
1114
struct __dbc **tqh_last;
1117
struct __dbc *tqh_first;
1118
struct __dbc **tqh_last;
1121
struct __dbc *tqh_first;
1122
struct __dbc **tqh_last;
1126
* Secondary index support.
1128
* Linked list of secondary indices -- set in the primary.
1131
* Explicit representations of structures from queue.h.
1132
* LIST_HEAD(s_secondaries, __db);
1135
struct __db *lh_first;
1139
* List entries for secondaries, and reference count of how
1140
* many threads are updating this secondary (see __db_c_put).
1143
* Note that these are synchronized by the primary's mutex, but
1144
* filled in in the secondaries.
1147
* Explicit representations of structures from queue.h.
1148
* LIST_ENTRY(__db) s_links;
1151
struct __db *le_next;
1152
struct __db **le_prev;
1156
/* Secondary callback and free functions -- set in the secondary. */
1157
int (*s_callback) __P((DB *, const DBT *, const DBT *, DBT *));
1159
/* Reference to primary -- set in the secondary. */
1162
/* API-private structure: used by DB 1.85, C++, Java, Perl and Tcl */
1165
/* Subsystem-private structure. */
1166
void *bt_internal; /* Btree/Recno access method. */
1167
void *h_internal; /* Hash access method. */
1168
void *q_internal; /* Queue access method. */
1169
void *xa_internal; /* XA. */
1172
int (*associate) __P((DB *, DB_TXN *, DB *, int (*)(DB *, const DBT *,
1173
const DBT *, DBT *), u_int32_t));
1174
int (*close) __P((DB *, u_int32_t));
1175
int (*cursor) __P((DB *, DB_TXN *, DBC **, u_int32_t));
1176
int (*del) __P((DB *, DB_TXN *, DBT *, u_int32_t));
1177
void (*err) __P((DB *, int, const char *, ...));
1178
void (*errx) __P((DB *, const char *, ...));
1179
int (*fd) __P((DB *, int *));
1180
int (*get) __P((DB *, DB_TXN *, DBT *, DBT *, u_int32_t));
1181
int (*pget) __P((DB *, DB_TXN *, DBT *, DBT *, DBT *, u_int32_t));
1182
int (*get_byteswapped) __P((DB *, int *));
1183
int (*get_type) __P((DB *, DBTYPE *));
1184
int (*join) __P((DB *, DBC **, DBC **, u_int32_t));
1185
int (*key_range) __P((DB *,
1186
DB_TXN *, DBT *, DB_KEY_RANGE *, u_int32_t));
1187
int (*open) __P((DB *, DB_TXN *,
1188
const char *, const char *, DBTYPE, u_int32_t, int));
1189
int (*put) __P((DB *, DB_TXN *, DBT *, DBT *, u_int32_t));
1190
int (*remove) __P((DB *, const char *, const char *, u_int32_t));
1191
int (*rename) __P((DB *,
1192
const char *, const char *, const char *, u_int32_t));
1193
int (*truncate) __P((DB *, DB_TXN *, u_int32_t *, u_int32_t));
1194
int (*set_append_recno) __P((DB *, int (*)(DB *, DBT *, db_recno_t)));
1195
int (*set_alloc) __P((DB *, void *(*)(size_t),
1196
void *(*)(void *, size_t), void (*)(void *)));
1197
int (*set_cachesize) __P((DB *, u_int32_t, u_int32_t, int));
1198
int (*set_cache_priority) __P((DB *, DB_CACHE_PRIORITY));
1199
int (*set_dup_compare) __P((DB *,
1200
int (*)(DB *, const DBT *, const DBT *)));
1201
int (*set_encrypt) __P((DB *, const char *, u_int32_t));
1202
void (*set_errcall) __P((DB *, void (*)(const char *, char *)));
1203
void (*set_errfile) __P((DB *, FILE *));
1204
void (*set_errpfx) __P((DB *, const char *));
1205
int (*set_feedback) __P((DB *, void (*)(DB *, int, int)));
1206
int (*set_flags) __P((DB *, u_int32_t));
1207
int (*set_lorder) __P((DB *, int));
1208
int (*set_pagesize) __P((DB *, u_int32_t));
1209
int (*set_paniccall) __P((DB *, void (*)(DB_ENV *, int)));
1210
int (*stat) __P((DB *, void *, u_int32_t));
1211
int (*sync) __P((DB *, u_int32_t));
1212
int (*upgrade) __P((DB *, const char *, u_int32_t));
1213
int (*verify) __P((DB *,
1214
const char *, const char *, FILE *, u_int32_t));
1216
int (*set_bt_compare) __P((DB *,
1217
int (*)(DB *, const DBT *, const DBT *)));
1218
int (*set_bt_maxkey) __P((DB *, u_int32_t));
1219
int (*set_bt_minkey) __P((DB *, u_int32_t));
1220
int (*set_bt_prefix) __P((DB *,
1221
size_t (*)(DB *, const DBT *, const DBT *)));
1223
int (*set_h_ffactor) __P((DB *, u_int32_t));
1224
int (*set_h_hash) __P((DB *,
1225
u_int32_t (*)(DB *, const void *, u_int32_t)));
1226
int (*set_h_nelem) __P((DB *, u_int32_t));
1228
int (*set_re_delim) __P((DB *, int));
1229
int (*set_re_len) __P((DB *, u_int32_t));
1230
int (*set_re_pad) __P((DB *, int));
1231
int (*set_re_source) __P((DB *, const char *));
1232
int (*set_q_extentsize) __P((DB *, u_int32_t));
1234
int (*db_am_remove) __P((DB *,
1235
DB_TXN *, const char *, const char *, DB_LSN *));
1236
int (*db_am_rename) __P((DB *, DB_TXN *,
1237
const char *, const char *, const char *));
1240
* Never called; these are a place to save function pointers
1241
* so that we can undo an associate.
1243
int (*stored_get) __P((DB *, DB_TXN *, DBT *, DBT *, u_int32_t));
1244
int (*stored_close) __P((DB *, u_int32_t));
1246
#define DB_OK_BTREE 0x01
1247
#define DB_OK_HASH 0x02
1248
#define DB_OK_QUEUE 0x04
1249
#define DB_OK_RECNO 0x08
1250
u_int32_t am_ok; /* Legal AM choices. */
1252
#define DB_AM_CHKSUM 0x00000001 /* Checksumming. */
1253
#define DB_AM_CL_WRITER 0x00000002 /* Allow writes in client replica. */
1254
#define DB_AM_COMPENSATE 0x00000004 /* Created by compensating txn. */
1255
#define DB_AM_CREATED 0x00000008 /* Database was created upon open. */
1256
#define DB_AM_CREATED_MSTR 0x00000010 /* Encompassing file was created. */
1257
#define DB_AM_DBM_ERROR 0x00000020 /* Error in DBM/NDBM database. */
1258
#define DB_AM_DELIMITER 0x00000040 /* Variable length delimiter set. */
1259
#define DB_AM_DIRTY 0x00000080 /* Support Dirty Reads. */
1260
#define DB_AM_DISCARD 0x00000100 /* Discard any cached pages. */
1261
#define DB_AM_DUP 0x00000200 /* DB_DUP. */
1262
#define DB_AM_DUPSORT 0x00000400 /* DB_DUPSORT. */
1263
#define DB_AM_ENCRYPT 0x00000800 /* Encryption. */
1264
#define DB_AM_FIXEDLEN 0x00001000 /* Fixed-length records. */
1265
#define DB_AM_INMEM 0x00002000 /* In-memory; no sync on close. */
1266
#define DB_AM_IN_RENAME 0x00004000 /* File is being renamed. */
1267
#define DB_AM_OPEN_CALLED 0x00008000 /* DB->open called. */
1268
#define DB_AM_PAD 0x00010000 /* Fixed-length record pad. */
1269
#define DB_AM_PGDEF 0x00020000 /* Page size was defaulted. */
1270
#define DB_AM_RDONLY 0x00040000 /* Database is readonly. */
1271
#define DB_AM_RECNUM 0x00080000 /* DB_RECNUM. */
1272
#define DB_AM_RECOVER 0x00100000 /* DB opened by recovery routine. */
1273
#define DB_AM_RENUMBER 0x00200000 /* DB_RENUMBER. */
1274
#define DB_AM_REVSPLITOFF 0x00400000 /* DB_REVSPLITOFF. */
1275
#define DB_AM_SECONDARY 0x00800000 /* Database is a secondary index. */
1276
#define DB_AM_SNAPSHOT 0x01000000 /* DB_SNAPSHOT. */
1277
#define DB_AM_SUBDB 0x02000000 /* Subdatabases supported. */
1278
#define DB_AM_SWAP 0x04000000 /* Pages need to be byte-swapped. */
1279
#define DB_AM_TXN 0x08000000 /* Opened in a transaction. */
1280
#define DB_AM_VERIFYING 0x10000000 /* DB handle is in the verifier. */
1285
* Macros for bulk get. Note that wherever we use a DBT *, we explicitly
1286
* cast it; this allows the same macros to work with C++ Dbt *'s, as Dbt
1287
* is a subclass of struct DBT in C++.
1289
#define DB_MULTIPLE_INIT(pointer, dbt) \
1290
(pointer = (u_int8_t *)((DBT *)(dbt))->data + \
1291
((DBT *)(dbt))->ulen - sizeof(u_int32_t))
1292
#define DB_MULTIPLE_NEXT(pointer, dbt, retdata, retdlen) \
1294
if (*((u_int32_t *)(pointer)) == (u_int32_t)-1) { \
1299
retdata = (u_int8_t *) \
1300
((DBT *)(dbt))->data + *(u_int32_t *)(pointer); \
1301
(pointer) = (u_int32_t *)(pointer) - 1; \
1302
retdlen = *(u_int32_t *)(pointer); \
1303
(pointer) = (u_int32_t *)(pointer) - 1; \
1304
if (retdlen == 0 && \
1305
retdata == (u_int8_t *)((DBT *)(dbt))->data) \
1308
#define DB_MULTIPLE_KEY_NEXT(pointer, dbt, retkey, retklen, retdata, retdlen) \
1310
if (*((u_int32_t *)(pointer)) == (u_int32_t)-1) { \
1316
retkey = (u_int8_t *) \
1317
((DBT *)(dbt))->data + *(u_int32_t *)(pointer); \
1318
(pointer) = (u_int32_t *)(pointer) - 1; \
1319
retklen = *(u_int32_t *)(pointer); \
1320
(pointer) = (u_int32_t *)(pointer) - 1; \
1321
retdata = (u_int8_t *) \
1322
((DBT *)(dbt))->data + *(u_int32_t *)(pointer); \
1323
(pointer) = (u_int32_t *)(pointer) - 1; \
1324
retdlen = *(u_int32_t *)(pointer); \
1325
(pointer) = (u_int32_t *)(pointer) - 1; \
1328
#define DB_MULTIPLE_RECNO_NEXT(pointer, dbt, recno, retdata, retdlen) \
1330
if (*((u_int32_t *)(pointer)) == (u_int32_t)0) { \
1336
recno = *(u_int32_t *)(pointer); \
1337
(pointer) = (u_int32_t *)(pointer) - 1; \
1338
retdata = (u_int8_t *) \
1339
((DBT *)(dbt))->data + *(u_int32_t *)(pointer); \
1340
(pointer) = (u_int32_t *)(pointer) - 1; \
1341
retdlen = *(u_int32_t *)(pointer); \
1342
(pointer) = (u_int32_t *)(pointer) - 1; \
1345
/*******************************************************
1346
* Access method cursors.
1347
*******************************************************/
1349
DB *dbp; /* Related DB access method. */
1350
DB_TXN *txn; /* Associated transaction. */
1353
* Active/free cursor queues.
1356
* Explicit representations of structures from queue.h.
1357
* TAILQ_ENTRY(__dbc) links;
1365
* The DBT *'s below are used by the cursor routines to return
1366
* data to the user when DBT flags indicate that DB should manage
1367
* the returned memory. They point at a DBT containing the buffer
1368
* and length that will be used, and "belonging" to the handle that
1369
* should "own" this memory. This may be a "my_*" field of this
1370
* cursor--the default--or it may be the corresponding field of
1371
* another cursor, a DB handle, a join cursor, etc. In general, it
1372
* will be whatever handle the user originally used for the current
1373
* DB interface call.
1375
DBT *rskey; /* Returned secondary key. */
1376
DBT *rkey; /* Returned [primary] key. */
1377
DBT *rdata; /* Returned data. */
1379
DBT my_rskey; /* Space for returned secondary key. */
1380
DBT my_rkey; /* Space for returned [primary] key. */
1381
DBT my_rdata; /* Space for returned data. */
1383
u_int32_t lid; /* Default process' locker id. */
1384
u_int32_t locker; /* Locker for this operation. */
1385
DBT lock_dbt; /* DBT referencing lock. */
1386
DB_LOCK_ILOCK lock; /* Object to be locked. */
1387
DB_LOCK mylock; /* Lock held on this cursor. */
1389
long cl_id; /* Remote client id. */
1391
DBTYPE dbtype; /* Cursor type. */
1393
DBC_INTERNAL *internal; /* Access method private. */
1395
int (*c_close) __P((DBC *)); /* Methods: public. */
1396
int (*c_count) __P((DBC *, db_recno_t *, u_int32_t));
1397
int (*c_del) __P((DBC *, u_int32_t));
1398
int (*c_dup) __P((DBC *, DBC **, u_int32_t));
1399
int (*c_get) __P((DBC *, DBT *, DBT *, u_int32_t));
1400
int (*c_pget) __P((DBC *, DBT *, DBT *, DBT *, u_int32_t));
1401
int (*c_put) __P((DBC *, DBT *, DBT *, u_int32_t));
1403
/* Methods: private. */
1404
int (*c_am_bulk) __P((DBC *, DBT *, u_int32_t));
1405
int (*c_am_close) __P((DBC *, db_pgno_t, int *));
1406
int (*c_am_del) __P((DBC *));
1407
int (*c_am_destroy) __P((DBC *));
1408
int (*c_am_get) __P((DBC *, DBT *, DBT *, u_int32_t, db_pgno_t *));
1409
int (*c_am_put) __P((DBC *, DBT *, DBT *, u_int32_t, db_pgno_t *));
1410
int (*c_am_writelock) __P((DBC *));
1412
/* Private: for secondary indices. */
1413
int (*c_real_get) __P((DBC *, DBT *, DBT *, u_int32_t));
1415
#define DBC_ACTIVE 0x0001 /* Cursor in use. */
1416
#define DBC_COMPENSATE 0x0002 /* Cursor compensating, don't lock. */
1417
#define DBC_DIRTY_READ 0x0004 /* Cursor supports dirty reads. */
1418
#define DBC_OPD 0x0008 /* Cursor references off-page dups. */
1419
#define DBC_RECOVER 0x0010 /* Recovery cursor; don't log/lock. */
1420
#define DBC_RMW 0x0020 /* Acquire write flag in read op. */
1421
#define DBC_TRANSIENT 0x0040 /* Cursor is transient. */
1422
#define DBC_WRITECURSOR 0x0080 /* Cursor may be used to write (CDB). */
1423
#define DBC_WRITEDUP 0x0100 /* idup'ed DBC_WRITECURSOR (CDB). */
1424
#define DBC_WRITER 0x0200 /* Cursor immediately writing (CDB). */
1425
#define DBC_MULTIPLE 0x0400 /* Return Multiple data. */
1426
#define DBC_MULTIPLE_KEY 0x0800 /* Return Multiple keys and data. */
1427
#define DBC_OWN_LID 0x1000 /* Free lock id on destroy. */
1431
/* Key range statistics structure */
1432
struct __key_range {
1438
/* Btree/Recno statistics structure. */
1439
struct __db_bt_stat {
1440
u_int32_t bt_magic; /* Magic number. */
1441
u_int32_t bt_version; /* Version number. */
1442
u_int32_t bt_metaflags; /* Metadata flags. */
1443
u_int32_t bt_nkeys; /* Number of unique keys. */
1444
u_int32_t bt_ndata; /* Number of data items. */
1445
u_int32_t bt_pagesize; /* Page size. */
1446
u_int32_t bt_maxkey; /* Maxkey value. */
1447
u_int32_t bt_minkey; /* Minkey value. */
1448
u_int32_t bt_re_len; /* Fixed-length record length. */
1449
u_int32_t bt_re_pad; /* Fixed-length record pad. */
1450
u_int32_t bt_levels; /* Tree levels. */
1451
u_int32_t bt_int_pg; /* Internal pages. */
1452
u_int32_t bt_leaf_pg; /* Leaf pages. */
1453
u_int32_t bt_dup_pg; /* Duplicate pages. */
1454
u_int32_t bt_over_pg; /* Overflow pages. */
1455
u_int32_t bt_free; /* Pages on the free list. */
1456
u_int32_t bt_int_pgfree; /* Bytes free in internal pages. */
1457
u_int32_t bt_leaf_pgfree; /* Bytes free in leaf pages. */
1458
u_int32_t bt_dup_pgfree; /* Bytes free in duplicate pages. */
1459
u_int32_t bt_over_pgfree; /* Bytes free in overflow pages. */
1462
/* Hash statistics structure. */
1463
struct __db_h_stat {
1464
u_int32_t hash_magic; /* Magic number. */
1465
u_int32_t hash_version; /* Version number. */
1466
u_int32_t hash_metaflags; /* Metadata flags. */
1467
u_int32_t hash_nkeys; /* Number of unique keys. */
1468
u_int32_t hash_ndata; /* Number of data items. */
1469
u_int32_t hash_pagesize; /* Page size. */
1470
u_int32_t hash_ffactor; /* Fill factor specified at create. */
1471
u_int32_t hash_buckets; /* Number of hash buckets. */
1472
u_int32_t hash_free; /* Pages on the free list. */
1473
u_int32_t hash_bfree; /* Bytes free on bucket pages. */
1474
u_int32_t hash_bigpages; /* Number of big key/data pages. */
1475
u_int32_t hash_big_bfree; /* Bytes free on big item pages. */
1476
u_int32_t hash_overflows; /* Number of overflow pages. */
1477
u_int32_t hash_ovfl_free; /* Bytes free on ovfl pages. */
1478
u_int32_t hash_dup; /* Number of dup pages. */
1479
u_int32_t hash_dup_free; /* Bytes free on duplicate pages. */
1482
/* Queue statistics structure. */
1483
struct __db_qam_stat {
1484
u_int32_t qs_magic; /* Magic number. */
1485
u_int32_t qs_version; /* Version number. */
1486
u_int32_t qs_metaflags; /* Metadata flags. */
1487
u_int32_t qs_nkeys; /* Number of unique keys. */
1488
u_int32_t qs_ndata; /* Number of data items. */
1489
u_int32_t qs_pagesize; /* Page size. */
1490
u_int32_t qs_extentsize; /* Pages per extent. */
1491
u_int32_t qs_pages; /* Data pages. */
1492
u_int32_t qs_re_len; /* Fixed-length record length. */
1493
u_int32_t qs_re_pad; /* Fixed-length record pad. */
1494
u_int32_t qs_pgfree; /* Bytes free in data pages. */
1495
u_int32_t qs_first_recno; /* First not deleted record. */
1496
u_int32_t qs_cur_recno; /* Next available record number. */
1499
/*******************************************************
1501
*******************************************************/
1502
#define DB_REGION_MAGIC 0x120897 /* Environment magic number. */
1504
/* Database Environment handle. */
1506
/*******************************************************
1507
* Public: owned by the application.
1508
*******************************************************/
1509
FILE *db_errfile; /* Error message file stream. */
1510
const char *db_errpfx; /* Error message prefix. */
1512
void (*db_errcall) __P((const char *, char *));
1513
void (*db_feedback) __P((DB_ENV *, int, int));
1514
void (*db_paniccall) __P((DB_ENV *, int));
1516
/* App-specified alloc functions. */
1517
void *(*db_malloc) __P((size_t));
1518
void *(*db_realloc) __P((void *, size_t));
1519
void (*db_free) __P((void *));
1522
* Currently, the verbose list is a bit field with room for 32
1523
* entries. There's no reason that it needs to be limited, if
1524
* there are ever more than 32 entries, convert to a bit array.
1526
#define DB_VERB_CHKPOINT 0x0001 /* List checkpoints. */
1527
#define DB_VERB_DEADLOCK 0x0002 /* Deadlock detection information. */
1528
#define DB_VERB_RECOVERY 0x0004 /* Recovery information. */
1529
#define DB_VERB_REPLICATION 0x0008 /* Replication information. */
1530
#define DB_VERB_WAITSFOR 0x0010 /* Dump waits-for table. */
1531
u_int32_t verbose; /* Verbose output. */
1533
void *app_private; /* Application-private handle. */
1535
int (*app_dispatch) /* User-specified recovery dispatch. */
1536
__P((DB_ENV *, DBT *, DB_LSN *, db_recops));
1539
u_int8_t *lk_conflicts; /* Two dimensional conflict matrix. */
1540
u_int32_t lk_modes; /* Number of lock modes in table. */
1541
u_int32_t lk_max; /* Maximum number of locks. */
1542
u_int32_t lk_max_lockers;/* Maximum number of lockers. */
1543
u_int32_t lk_max_objects;/* Maximum number of locked objects. */
1544
u_int32_t lk_detect; /* Deadlock detect on all conflicts. */
1545
db_timeout_t lk_timeout; /* Lock timeout period. */
1548
u_int32_t lg_bsize; /* Buffer size. */
1549
u_int32_t lg_size; /* Log file size. */
1550
u_int32_t lg_regionmax; /* Region size. */
1553
u_int32_t mp_gbytes; /* Cachesize: GB. */
1554
u_int32_t mp_bytes; /* Cachesize: Bytes. */
1555
size_t mp_size; /* DEPRECATED: Cachesize: bytes. */
1556
int mp_ncache; /* Number of cache regions. */
1557
size_t mp_mmapsize; /* Maximum file size for mmap. */
1559
int rep_eid; /* environment id. */
1562
u_int32_t tx_max; /* Maximum number of transactions. */
1563
time_t tx_timestamp; /* Recover to specific timestamp. */
1564
db_timeout_t tx_timeout; /* Timeout for transactions. */
1566
/*******************************************************
1567
* Private: owned by DB.
1568
*******************************************************/
1569
int panic_errval; /* Panic causing errno. */
1571
/* User files, paths. */
1572
char *db_home; /* Database home. */
1573
char *db_log_dir; /* Database log file directory. */
1574
char *db_tmp_dir; /* Database tmp file directory. */
1576
char **db_data_dir; /* Database data file directories. */
1577
int data_cnt; /* Database data file slots. */
1578
int data_next; /* Next Database data file slot. */
1580
int db_mode; /* Default open permissions. */
1582
void *reginfo; /* REGINFO structure reference. */
1583
DB_FH *lockfhp; /* fcntl(2) locking file handle. */
1585
int (**recover_dtab) /* Dispatch table for recover funcs. */
1586
__P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
1587
size_t recover_dtab_size;
1588
/* Slots in the dispatch table. */
1590
void *cl_handle; /* RPC: remote client handle. */
1591
long cl_id; /* RPC: remote client env id. */
1593
int db_ref; /* DB reference count. */
1595
long shm_key; /* shmget(2) key. */
1596
u_int32_t tas_spins; /* test-and-set spins. */
1599
* List of open DB handles for this DB_ENV, used for cursor
1600
* adjustment. Must be protected for multi-threaded support.
1603
* As this structure is allocated in per-process memory, the
1604
* mutex may need to be stored elsewhere on architectures unable
1605
* to support mutexes in heap memory, e.g. HP/UX 9.
1608
* Explicit representation of structure in queue.h.
1609
* LIST_HEAD(dblist, __db);
1611
DB_MUTEX *dblist_mutexp; /* Mutex. */
1613
struct __db *lh_first;
1620
* Explicit representations of structures from queue.h.
1621
* TAILQ_ENTRY(__db_env) links;
1624
struct __db_env *tqe_next;
1625
struct __db_env **tqe_prev;
1627
int xa_rmid; /* XA Resource Manager ID. */
1628
DB_TXN *xa_txn; /* XA Current transaction. */
1630
/* API-private structure. */
1631
void *api1_internal; /* C++, Perl API private */
1632
void *api2_internal; /* Java API private */
1634
char *passwd; /* Cryptography support. */
1636
void *crypto_handle; /* Primary handle. */
1637
DB_MUTEX *mt_mutexp; /* Mersenne Twister mutex. */
1638
int mti; /* Mersenne Twister index. */
1639
u_long *mt; /* Mersenne Twister state vector. */
1641
/* DB_ENV Methods. */
1642
int (*close) __P((DB_ENV *, u_int32_t));
1643
int (*dbremove) __P((DB_ENV *,
1644
DB_TXN *, const char *, const char *, u_int32_t));
1645
int (*dbrename) __P((DB_ENV *, DB_TXN *,
1646
const char *, const char *, const char *, u_int32_t));
1647
void (*err) __P((const DB_ENV *, int, const char *, ...));
1648
void (*errx) __P((const DB_ENV *, const char *, ...));
1649
int (*open) __P((DB_ENV *, const char *, u_int32_t, int));
1650
int (*remove) __P((DB_ENV *, const char *, u_int32_t));
1651
int (*set_data_dir) __P((DB_ENV *, const char *));
1652
int (*set_alloc) __P((DB_ENV *, void *(*)(size_t),
1653
void *(*)(void *, size_t), void (*)(void *)));
1654
int (*set_app_dispatch) __P((DB_ENV *,
1655
int (*)(DB_ENV *, DBT *, DB_LSN *, db_recops)));
1656
int (*set_encrypt) __P((DB_ENV *, const char *, u_int32_t));
1657
void (*set_errcall) __P((DB_ENV *, void (*)(const char *, char *)));
1658
void (*set_errfile) __P((DB_ENV *, FILE *));
1659
void (*set_errpfx) __P((DB_ENV *, const char *));
1660
int (*set_feedback) __P((DB_ENV *, void (*)(DB_ENV *, int, int)));
1661
int (*set_flags) __P((DB_ENV *, u_int32_t, int));
1662
int (*set_paniccall) __P((DB_ENV *, void (*)(DB_ENV *, int)));
1663
int (*set_rpc_server) __P((DB_ENV *,
1664
void *, const char *, long, long, u_int32_t));
1665
int (*set_shm_key) __P((DB_ENV *, long));
1666
int (*set_tas_spins) __P((DB_ENV *, u_int32_t));
1667
int (*set_tmp_dir) __P((DB_ENV *, const char *));
1668
int (*set_verbose) __P((DB_ENV *, u_int32_t, int));
1670
void *lg_handle; /* Log handle and methods. */
1671
int (*set_lg_bsize) __P((DB_ENV *, u_int32_t));
1672
int (*set_lg_dir) __P((DB_ENV *, const char *));
1673
int (*set_lg_max) __P((DB_ENV *, u_int32_t));
1674
int (*set_lg_regionmax) __P((DB_ENV *, u_int32_t));
1675
int (*log_archive) __P((DB_ENV *, char **[], u_int32_t));
1676
int (*log_cursor) __P((DB_ENV *, DB_LOGC **, u_int32_t));
1677
int (*log_file) __P((DB_ENV *, const DB_LSN *, char *, size_t));
1678
int (*log_flush) __P((DB_ENV *, const DB_LSN *));
1679
int (*log_put) __P((DB_ENV *, DB_LSN *, const DBT *, u_int32_t));
1680
int (*log_stat) __P((DB_ENV *, DB_LOG_STAT **, u_int32_t));
1682
void *lk_handle; /* Lock handle and methods. */
1683
int (*set_lk_conflicts) __P((DB_ENV *, u_int8_t *, int));
1684
int (*set_lk_detect) __P((DB_ENV *, u_int32_t));
1685
int (*set_lk_max) __P((DB_ENV *, u_int32_t));
1686
int (*set_lk_max_locks) __P((DB_ENV *, u_int32_t));
1687
int (*set_lk_max_lockers) __P((DB_ENV *, u_int32_t));
1688
int (*set_lk_max_objects) __P((DB_ENV *, u_int32_t));
1689
int (*lock_detect) __P((DB_ENV *, u_int32_t, u_int32_t, int *));
1690
int (*lock_dump_region) __P((DB_ENV *, char *, FILE *));
1691
int (*lock_get) __P((DB_ENV *,
1692
u_int32_t, u_int32_t, const DBT *, db_lockmode_t, DB_LOCK *));
1693
int (*lock_put) __P((DB_ENV *, DB_LOCK *));
1694
int (*lock_id) __P((DB_ENV *, u_int32_t *));
1695
int (*lock_id_free) __P((DB_ENV *, u_int32_t));
1696
int (*lock_id_set) __P((DB_ENV *, u_int32_t, u_int32_t));
1697
int (*lock_stat) __P((DB_ENV *, DB_LOCK_STAT **, u_int32_t));
1698
int (*lock_vec) __P((DB_ENV *,
1699
u_int32_t, u_int32_t, DB_LOCKREQ *, int, DB_LOCKREQ **));
1700
int (*lock_downgrade) __P((DB_ENV *,
1701
DB_LOCK *, db_lockmode_t, u_int32_t));
1703
void *mp_handle; /* Mpool handle and methods. */
1704
int (*set_mp_mmapsize) __P((DB_ENV *, size_t));
1705
int (*set_cachesize) __P((DB_ENV *, u_int32_t, u_int32_t, int));
1706
int (*memp_dump_region) __P((DB_ENV *, char *, FILE *));
1707
int (*memp_fcreate) __P((DB_ENV *, DB_MPOOLFILE **, u_int32_t));
1708
int (*memp_nameop) __P((DB_ENV *,
1709
u_int8_t *, const char *, const char *, const char *));
1710
int (*memp_register) __P((DB_ENV *, int,
1711
int (*)(DB_ENV *, db_pgno_t, void *, DBT *),
1712
int (*)(DB_ENV *, db_pgno_t, void *, DBT *)));
1713
int (*memp_stat) __P((DB_ENV *,
1714
DB_MPOOL_STAT **, DB_MPOOL_FSTAT ***, u_int32_t));
1715
int (*memp_sync) __P((DB_ENV *, DB_LSN *));
1716
int (*memp_trickle) __P((DB_ENV *, int, int *));
1718
void *rep_handle; /* Replication handle and methods. */
1719
int (*rep_elect) __P((DB_ENV *, int, int, u_int32_t, int *));
1720
int (*rep_flush) __P((DB_ENV *));
1721
int (*rep_process_message) __P((DB_ENV *, DBT *, DBT *, int *));
1722
int (*rep_start) __P((DB_ENV *, DBT *, u_int32_t));
1723
int (*rep_stat) __P((DB_ENV *, DB_REP_STAT **, u_int32_t));
1724
int (*set_rep_election) __P((DB_ENV *,
1725
u_int32_t, u_int32_t, u_int32_t, u_int32_t));
1726
int (*set_rep_limit) __P((DB_ENV *, u_int32_t, u_int32_t));
1727
int (*set_rep_request) __P((DB_ENV *, u_int32_t, u_int32_t));
1728
int (*set_rep_timeout) __P((DB_ENV *, u_int32_t, u_int32_t));
1729
int (*set_rep_transport) __P((DB_ENV *, int,
1730
int (*) (DB_ENV *, const DBT *, const DBT *, int, u_int32_t)));
1732
void *tx_handle; /* Txn handle and methods. */
1733
int (*set_tx_max) __P((DB_ENV *, u_int32_t));
1734
int (*set_tx_timestamp) __P((DB_ENV *, time_t *));
1735
int (*txn_begin) __P((DB_ENV *, DB_TXN *, DB_TXN **, u_int32_t));
1736
int (*txn_checkpoint) __P((DB_ENV *, u_int32_t, u_int32_t, u_int32_t));
1737
int (*txn_id_set) __P((DB_ENV *, u_int32_t, u_int32_t));
1738
int (*txn_recover) __P((DB_ENV *,
1739
DB_PREPLIST *, long, long *, u_int32_t));
1740
int (*txn_stat) __P((DB_ENV *, DB_TXN_STAT **, u_int32_t));
1741
int (*set_timeout) __P((DB_ENV *, db_timeout_t, u_int32_t));
1743
#define DB_TEST_ELECTINIT 1 /* after __rep_elect_init */
1744
#define DB_TEST_ELECTSEND 2 /* after REP_ELECT msgnit */
1745
#define DB_TEST_ELECTVOTE1 3 /* after __rep_send_vote 1 */
1746
#define DB_TEST_ELECTVOTE2 4 /* after __rep_wait */
1747
#define DB_TEST_ELECTWAIT1 5 /* after REP_VOTE2 */
1748
#define DB_TEST_ELECTWAIT2 6 /* after __rep_wait 2 */
1749
#define DB_TEST_PREDESTROY 7 /* before destroy op */
1750
#define DB_TEST_PREOPEN 8 /* before __os_open */
1751
#define DB_TEST_POSTDESTROY 9 /* after destroy op */
1752
#define DB_TEST_POSTLOG 10 /* after logging all pages */
1753
#define DB_TEST_POSTLOGMETA 11 /* after logging meta in btree */
1754
#define DB_TEST_POSTOPEN 12 /* after __os_open */
1755
#define DB_TEST_POSTSYNC 13 /* after syncing the log */
1756
#define DB_TEST_SUBDB_LOCKS 14 /* subdb locking tests */
1757
int test_abort; /* Abort value for testing. */
1758
int test_copy; /* Copy value for testing. */
1760
#define DB_ENV_AUTO_COMMIT 0x0000001 /* DB_AUTO_COMMIT. */
1761
#define DB_ENV_CDB 0x0000002 /* DB_INIT_CDB. */
1762
#define DB_ENV_CDB_ALLDB 0x0000004 /* CDB environment wide locking. */
1763
#define DB_ENV_CREATE 0x0000008 /* DB_CREATE set. */
1764
#define DB_ENV_DBLOCAL 0x0000010 /* DB_ENV allocated for private DB. */
1765
#define DB_ENV_DIRECT_DB 0x0000020 /* DB_DIRECT_DB set. */
1766
#define DB_ENV_DIRECT_LOG 0x0000040 /* DB_DIRECT_LOG set. */
1767
#define DB_ENV_FATAL 0x0000080 /* Doing fatal recovery in env. */
1768
#define DB_ENV_LOCKDOWN 0x0000100 /* DB_LOCKDOWN set. */
1769
#define DB_ENV_NOLOCKING 0x0000200 /* DB_NOLOCKING set. */
1770
#define DB_ENV_NOMMAP 0x0000400 /* DB_NOMMAP set. */
1771
#define DB_ENV_NOPANIC 0x0000800 /* Okay if panic set. */
1772
#define DB_ENV_OPEN_CALLED 0x0001000 /* DB_ENV->open called. */
1773
#define DB_ENV_OVERWRITE 0x0002000 /* DB_OVERWRITE set. */
1774
#define DB_ENV_PRIVATE 0x0004000 /* DB_PRIVATE set. */
1775
#define DB_ENV_REGION_INIT 0x0008000 /* DB_REGION_INIT set. */
1776
#define DB_ENV_REP_CLIENT 0x0010000 /* Replication client. */
1777
#define DB_ENV_REP_LOGSONLY 0x0020000 /* Log files only replication site. */
1778
#define DB_ENV_REP_MASTER 0x0040000 /* Replication master. */
1779
#define DB_ENV_RPCCLIENT 0x0080000 /* DB_CLIENT set. */
1780
#define DB_ENV_RPCCLIENT_GIVEN 0x0100000 /* User-supplied RPC client struct */
1781
#define DB_ENV_SYSTEM_MEM 0x0200000 /* DB_SYSTEM_MEM set. */
1782
#define DB_ENV_THREAD 0x0400000 /* DB_THREAD set. */
1783
#define DB_ENV_TXN_NOSYNC 0x0800000 /* DB_TXN_NOSYNC set. */
1784
#define DB_ENV_TXN_WRITE_NOSYNC 0x1000000 /* DB_TXN_WRITE_NOSYNC set. */
1785
#define DB_ENV_YIELDCPU 0x2000000 /* DB_YIELDCPU set. */
1789
#ifndef DB_DBM_HSEARCH
1790
#define DB_DBM_HSEARCH 0 /* No historic interfaces by default. */
1792
#if DB_DBM_HSEARCH != 0
1793
/*******************************************************
1794
* Dbm/Ndbm historic interfaces.
1795
*******************************************************/
1796
typedef struct __db DBM;
1798
#define DBM_INSERT 0 /* Flags to dbm_store(). */
1799
#define DBM_REPLACE 1
1802
* The DB support for ndbm(3) always appends this suffix to the
1803
* file name to avoid overwriting the user's original database.
1805
#define DBM_SUFFIX ".db"
1807
#if defined(_XPG4_2)
1820
* Translate NDBM calls into DB calls so that DB doesn't step on the
1821
* application's name space.
1823
#define dbm_clearerr(a) __db_ndbm_clearerr@DB_VERSION_UNIQUE_NAME@(a)
1824
#define dbm_close(a) __db_ndbm_close@DB_VERSION_UNIQUE_NAME@(a)
1825
#define dbm_delete(a, b) __db_ndbm_delete@DB_VERSION_UNIQUE_NAME@(a, b)
1826
#define dbm_dirfno(a) __db_ndbm_dirfno@DB_VERSION_UNIQUE_NAME@(a)
1827
#define dbm_error(a) __db_ndbm_error@DB_VERSION_UNIQUE_NAME@(a)
1828
#define dbm_fetch(a, b) __db_ndbm_fetch@DB_VERSION_UNIQUE_NAME@(a, b)
1829
#define dbm_firstkey(a) __db_ndbm_firstkey@DB_VERSION_UNIQUE_NAME@(a)
1830
#define dbm_nextkey(a) __db_ndbm_nextkey@DB_VERSION_UNIQUE_NAME@(a)
1831
#define dbm_open(a, b, c) __db_ndbm_open@DB_VERSION_UNIQUE_NAME@(a, b, c)
1832
#define dbm_pagfno(a) __db_ndbm_pagfno@DB_VERSION_UNIQUE_NAME@(a)
1833
#define dbm_rdonly(a) __db_ndbm_rdonly@DB_VERSION_UNIQUE_NAME@(a)
1834
#define dbm_store(a, b, c, d) \
1835
__db_ndbm_store@DB_VERSION_UNIQUE_NAME@(a, b, c, d)
1838
* Translate DBM calls into DB calls so that DB doesn't step on the
1839
* application's name space.
1841
* The global variables dbrdonly, dirf and pagf were not retained when 4BSD
1842
* replaced the dbm interface with ndbm, and are not supported here.
1844
#define dbminit(a) __db_dbm_init@DB_VERSION_UNIQUE_NAME@(a)
1845
#define dbmclose __db_dbm_close@DB_VERSION_UNIQUE_NAME@
1846
#if !defined(__cplusplus)
1847
#define delete(a) __db_dbm_delete@DB_VERSION_UNIQUE_NAME@(a)
1849
#define fetch(a) __db_dbm_fetch@DB_VERSION_UNIQUE_NAME@(a)
1850
#define firstkey __db_dbm_firstkey@DB_VERSION_UNIQUE_NAME@
1851
#define nextkey(a) __db_dbm_nextkey@DB_VERSION_UNIQUE_NAME@(a)
1852
#define store(a, b) __db_dbm_store@DB_VERSION_UNIQUE_NAME@(a, b)
1854
/*******************************************************
1855
* Hsearch historic interface.
1856
*******************************************************/
1861
typedef struct entry {
1866
#define hcreate(a) __db_hcreate@DB_VERSION_UNIQUE_NAME@(a)
1867
#define hdestroy __db_hdestroy@DB_VERSION_UNIQUE_NAME@
1868
#define hsearch(a, b) __db_hsearch@DB_VERSION_UNIQUE_NAME@(a, b)
1870
#endif /* DB_DBM_HSEARCH */
1872
#if defined(__cplusplus)
1875
#endif /* !_DB_H_ */