~ubuntu-branches/ubuntu/maverick/evolution-data-server/maverick-proposed

« back to all changes in this revision

Viewing changes to libdb/build_win32/db.h

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2010-05-17 17:02:06 UTC
  • mfrom: (1.1.79 upstream) (1.6.12 experimental)
  • Revision ID: james.westby@ubuntu.com-20100517170206-4ufr52vwrhh26yh0
Tags: 2.30.1-1ubuntu1
* Merge from debian experimental. Remaining change:
  (LP: #42199, #229669, #173703, #360344, #508494)
  + debian/control:
    - add Vcs-Bzr tag
    - don't use libgnome
    - Use Breaks instead of Conflicts against evolution 2.25 and earlier.
  + debian/evolution-data-server.install,
    debian/patches/45_libcamel_providers_version.patch:
    - use the upstream versioning, not a Debian-specific one 
  + debian/libedata-book1.2-dev.install, debian/libebackend-1.2-dev.install,
    debian/libcamel1.2-dev.install, debian/libedataserverui1.2-dev.install:
    - install html documentation
  + debian/rules:
    - don't build documentation it's shipped with the tarball

Show diffs side-by-side

added added

removed removed

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