~ubuntu-branches/ubuntu/edgy/rpm/edgy

« back to all changes in this revision

Viewing changes to db/include/db.in

  • Committer: Bazaar Package Importer
  • Author(s): Joey Hess
  • Date: 2002-01-22 20:56:57 UTC
  • Revision ID: james.westby@ubuntu.com-20020122205657-l74j50mr9z8ofcl5
Tags: upstream-4.0.3
ImportĀ upstreamĀ versionĀ 4.0.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * See the file LICENSE for redistribution information.
 
3
 *
 
4
 * Copyright (c) 1996-2001
 
5
 *      Sleepycat Software.  All rights reserved.
 
6
 *
 
7
 * $Id: db.in,v 11.174 2001/07/06 20:35:14 bostic Exp $
 
8
 */
 
9
 
 
10
#ifndef _DB_H_
 
11
#define _DB_H_
 
12
 
 
13
#ifndef __NO_SYSTEM_INCLUDES
 
14
#include <sys/types.h>
 
15
 
 
16
#include <stdio.h>
 
17
#endif
 
18
 
 
19
#if defined(__cplusplus)
 
20
extern "C" {
 
21
#endif
 
22
 
 
23
/*
 
24
 * XXX
 
25
 * Handle function prototypes and the keyword "const".  This steps on name
 
26
 * space that DB doesn't control, but all of the other solutions are worse.
 
27
 *
 
28
 * XXX
 
29
 * While Microsoft's compiler is ANSI C compliant, it doesn't have _STDC_
 
30
 * defined by default, you specify a command line flag or #pragma to turn
 
31
 * it on.  Don't do that, however, because some of Microsoft's own header
 
32
 * files won't compile.
 
33
 */
 
34
#undef  __P
 
35
#if defined(__STDC__) || defined(__cplusplus) || defined(_MSC_VER)
 
36
#define __P(protos)     protos          /* ANSI C prototypes */
 
37
#else
 
38
#define const
 
39
#define __P(protos)     ()              /* K&R C preprocessor */
 
40
#endif
 
41
 
 
42
/*
 
43
 * !!!
 
44
 * DB needs basic information about specifically sized types.  If they're
 
45
 * not provided by the system, typedef them here.
 
46
 *
 
47
 * We protect them against multiple inclusion using __BIT_TYPES_DEFINED__,
 
48
 * as does BIND and Kerberos, since we don't know for sure what #include
 
49
 * files the user is using.
 
50
 *
 
51
 * !!!
 
52
 * We also provide the standard u_int, u_long etc., if they're not provided
 
53
 * by the system.
 
54
 */
 
55
#ifndef __BIT_TYPES_DEFINED__
 
56
#define __BIT_TYPES_DEFINED__
 
57
@u_int8_decl@
 
58
@int16_decl@
 
59
@u_int16_decl@
 
60
@int32_decl@
 
61
@u_int32_decl@
 
62
#endif
 
63
 
 
64
@u_char_decl@
 
65
@u_short_decl@
 
66
@u_int_decl@
 
67
@u_long_decl@
 
68
@ssize_t_decl@
 
69
 
 
70
#define DB_VERSION_MAJOR        @DB_VERSION_MAJOR@
 
71
#define DB_VERSION_MINOR        @DB_VERSION_MINOR@
 
72
#define DB_VERSION_PATCH        @DB_VERSION_PATCH@
 
73
#define DB_VERSION_STRING       @DB_VERSION_STRING@
 
74
 
 
75
typedef u_int32_t       db_pgno_t;      /* Page number type. */
 
76
typedef u_int16_t       db_indx_t;      /* Page offset type. */
 
77
#define DB_MAX_PAGES    0xffffffff      /* >= # of pages in a file */
 
78
 
 
79
typedef u_int32_t       db_recno_t;     /* Record number type. */
 
80
#define DB_MAX_RECORDS  0xffffffff      /* >= # of records in a tree */
 
81
 
 
82
/* Forward structure declarations, so applications get type checking. */
 
83
struct __db;            typedef struct __db DB;
 
84
struct __db_bt_stat;    typedef struct __db_bt_stat DB_BTREE_STAT;
 
85
struct __db_dbt;        typedef struct __db_dbt DBT;
 
86
struct __db_env;        typedef struct __db_env DB_ENV;
 
87
struct __db_h_stat;     typedef struct __db_h_stat DB_HASH_STAT;
 
88
struct __db_ilock;      typedef struct __db_ilock DB_LOCK_ILOCK;
 
89
struct __db_lock_stat;  typedef struct __db_lock_stat DB_LOCK_STAT;
 
90
struct __db_lock_u;     typedef struct __db_lock_u DB_LOCK;
 
91
struct __db_lockreq;    typedef struct __db_lockreq DB_LOCKREQ;
 
92
struct __db_log_stat;   typedef struct __db_log_stat DB_LOG_STAT;
 
93
struct __db_lsn;        typedef struct __db_lsn DB_LSN;
 
94
struct __db_mpool_finfo;typedef struct __db_mpool_finfo DB_MPOOL_FINFO;
 
95
struct __db_mpool_fstat;typedef struct __db_mpool_fstat DB_MPOOL_FSTAT;
 
96
struct __db_mpool_stat; typedef struct __db_mpool_stat DB_MPOOL_STAT;
 
97
struct __db_mpoolfile;  typedef struct __db_mpoolfile DB_MPOOLFILE;
 
98
struct __db_qam_stat;   typedef struct __db_qam_stat DB_QUEUE_STAT;
 
99
struct __db_txn;        typedef struct __db_txn DB_TXN;
 
100
struct __db_txn_active; typedef struct __db_txn_active DB_TXN_ACTIVE;
 
101
struct __db_txn_stat;   typedef struct __db_txn_stat DB_TXN_STAT;
 
102
struct __dbc;           typedef struct __dbc DBC;
 
103
struct __dbc_internal;  typedef struct __dbc_internal DBC_INTERNAL;
 
104
struct __fh_t;          typedef struct __fh_t DB_FH;
 
105
struct __key_range;     typedef struct __key_range DB_KEY_RANGE;
 
106
 
 
107
/* Key/data structure -- a Data-Base Thang. */
 
108
struct __db_dbt {
 
109
        /*
 
110
         * data/size must be fields 1 and 2 for DB 1.85 compatibility.
 
111
         */
 
112
        void     *data;                 /* Key/data */
 
113
        u_int32_t size;                 /* key/data length */
 
114
 
 
115
        u_int32_t ulen;                 /* RO: length of user buffer. */
 
116
        u_int32_t dlen;                 /* RO: get/put record length. */
 
117
        u_int32_t doff;                 /* RO: get/put record offset. */
 
118
 
 
119
#define DB_DBT_APPMALLOC        0x001   /* Callback allocated memory. */
 
120
#define DB_DBT_ISSET            0x002   /* Lower level calls set value. */
 
121
#define DB_DBT_MALLOC           0x004   /* Return in malloc'd memory. */
 
122
#define DB_DBT_PARTIAL          0x008   /* Partial put/get. */
 
123
#define DB_DBT_REALLOC          0x010   /* Return in realloc'd memory. */
 
124
#define DB_DBT_USERMEM          0x020   /* Return in user's memory. */
 
125
#define DB_DBT_DUPOK            0x040   /* Insert if duplicate. */
 
126
        u_int32_t flags;
 
127
};
 
128
 
 
129
/*
 
130
 * Macros for bulk get.  Note that wherever we use a DBT *, we explicitly
 
131
 * cast it;  this allows the same macros to work with C++ Dbt *'s, as
 
132
 * Dbt is a subclass of struct DBT in C++.
 
133
 */
 
134
#define DB_MULTIPLE_INIT(pointer, dbt)                                  \
 
135
        (pointer = (u_int8_t *)((DBT *)(dbt))->data +                   \
 
136
            ((DBT *)(dbt))->ulen - sizeof(u_int32_t))
 
137
#define DB_MULTIPLE_NEXT(pointer, dbt, retdata, retdlen)                \
 
138
        do {                                                            \
 
139
                if (*((u_int32_t *)(pointer)) == (u_int32_t)-1) {       \
 
140
                        retdata = NULL;                                 \
 
141
                        pointer = NULL;                                 \
 
142
                        break;                                          \
 
143
                }                                                       \
 
144
                retdata = (u_int8_t *)                                  \
 
145
                    ((DBT *)(dbt))->data + *(u_int32_t *)(pointer);     \
 
146
                (pointer) = (u_int32_t *)(pointer) - 1;                 \
 
147
                retdlen = *(u_int32_t *)(pointer);                      \
 
148
                (pointer) = (u_int32_t *)(pointer) - 1;                 \
 
149
                if (retdlen == 0 &&                                     \
 
150
                    retdata == (u_int8_t *)((DBT *)(dbt))->data)        \
 
151
                        retdata = NULL;                                 \
 
152
        } while (0)
 
153
#define DB_MULTIPLE_KEY_NEXT(pointer, dbt, retkey, retklen, retdata, retdlen) \
 
154
        do {                                                            \
 
155
                if (*((u_int32_t *)(pointer)) == (u_int32_t)-1) {       \
 
156
                        retdata = NULL;                                 \
 
157
                        retkey = NULL;                                  \
 
158
                        pointer = NULL;                                 \
 
159
                        break;                                          \
 
160
                }                                                       \
 
161
                retkey = (u_int8_t *)                                   \
 
162
                    ((DBT *)(dbt))->data + *(u_int32_t *)(pointer);     \
 
163
                (pointer) = (u_int32_t *)(pointer) - 1;                 \
 
164
                retklen = *(u_int32_t *)(pointer);                      \
 
165
                (pointer) = (u_int32_t *)(pointer) - 1;                 \
 
166
                retdata = (u_int8_t *)                                  \
 
167
                    ((DBT *)(dbt))->data + *(u_int32_t *)(pointer);     \
 
168
                (pointer) = (u_int32_t *)(pointer) - 1;                 \
 
169
                retdlen = *(u_int32_t *)(pointer);                      \
 
170
                (pointer) = (u_int32_t *)(pointer) - 1;                 \
 
171
        } while (0)
 
172
 
 
173
#define DB_MULTIPLE_RECNO_NEXT(pointer, dbt, recno, retdata, retdlen)   \
 
174
        do {                                                            \
 
175
                if (*((u_int32_t *)(pointer)) == (u_int32_t)-1) {       \
 
176
                        recno = 0;                                      \
 
177
                        retdata = NULL;                                 \
 
178
                        pointer = NULL;                                 \
 
179
                        break;                                          \
 
180
                }                                                       \
 
181
                recno = *(u_int32_t *)(pointer);                        \
 
182
                (pointer) = (u_int32_t *)(pointer) - 1;                 \
 
183
                retdata = (u_int8_t *)                                  \
 
184
                    ((DBT *)(dbt))->data + *(u_int32_t *)(pointer);     \
 
185
                (pointer) = (u_int32_t *)(pointer) - 1;                 \
 
186
                retdlen = *(u_int32_t *)(pointer);                      \
 
187
                (pointer) = (u_int32_t *)(pointer) - 1;                 \
 
188
        } while (0)
 
189
 
 
190
/*
 
191
 * Common flags --
 
192
 *      Interfaces which use any of these common flags should never have
 
193
 *      interface specific flags in this range.
 
194
 */
 
195
#define DB_CREATE             0x000001  /* Create file as necessary. */
 
196
#define DB_CXX_NO_EXCEPTIONS  0x000002  /* C++: return error values. */
 
197
#define DB_FORCE              0x000004  /* Force (anything). */
 
198
#define DB_NOMMAP             0x000008  /* Don't mmap underlying file. */
 
199
#define DB_RDONLY             0x000010  /* Read-only (O_RDONLY). */
 
200
#define DB_RECOVER            0x000020  /* Run normal recovery. */
 
201
#define DB_THREAD             0x000040  /* Applications are threaded. */
 
202
#define DB_TXN_NOSYNC         0x000080  /* Do not sync log on commit. */
 
203
#define DB_USE_ENVIRON        0x000100  /* Use the environment. */
 
204
#define DB_USE_ENVIRON_ROOT   0x000200  /* Use the environment if root. */
 
205
 
 
206
/* This flag is common between the open call and the command calls */
 
207
/* define       DB_DIRTY_READ         0x10000000        Support Dirty Read. */
 
208
 
 
209
/*
 
210
 * Flags private to db_env_create.
 
211
 */
 
212
#define DB_CLIENT             0x000400  /* Open for a client environment. */
 
213
 
 
214
/*
 
215
 * Flags private to db_create.
 
216
 */
 
217
#define DB_XA_CREATE          0x000400  /* Open in an XA environment. */
 
218
 
 
219
/*
 
220
 * Flags private to DBENV->open.
 
221
 */
 
222
#define DB_INIT_CDB           0x000400  /* Concurrent Access Methods. */
 
223
#define DB_INIT_LOCK          0x000800  /* Initialize locking. */
 
224
#define DB_INIT_LOG           0x001000  /* Initialize logging. */
 
225
#define DB_INIT_MPOOL         0x002000  /* Initialize mpool. */
 
226
#define DB_INIT_TXN           0x004000  /* Initialize transactions. */
 
227
#define DB_JOINENV            0x008000  /* Initialize all subsystems present. */
 
228
#define DB_LOCKDOWN           0x010000  /* Lock memory into physical core. */
 
229
#define DB_PRIVATE            0x020000  /* DB_ENV is process local. */
 
230
#define DB_RECOVER_FATAL      0x040000  /* Run catastrophic recovery. */
 
231
#define DB_SYSTEM_MEM         0x080000  /* Use system-backed memory. */
 
232
 
 
233
/*
 
234
 * Flags private to DB->open.
 
235
 */
 
236
#define DB_EXCL               0x000400  /* Exclusive open (O_EXCL). */
 
237
#define DB_FCNTL_LOCKING      0x000800  /* UNDOC: fcntl(2) locking. */
 
238
#define DB_ODDFILESIZE        0x001000  /* UNDOC: truncate to N * pgsize. */
 
239
#define DB_RDWRMASTER         0x002000  /* UNDOC: allow subdb master open R/W */
 
240
#define DB_TRUNCATE           0x004000  /* Discard existing DB (O_TRUNC). */
 
241
#define DB_EXTENT             0x008000  /* UNDOC: dealing with an extent. */
 
242
 
 
243
/*
 
244
 * Flags private to DBENV->txn_begin.
 
245
 */
 
246
#define DB_TXN_NOWAIT         0x000400  /* Do not wait for locks in this TXN. */
 
247
#define DB_TXN_SYNC           0x000800  /* Always sync log on commit. */
 
248
 
 
249
/*
 
250
 * Flags private to DBENV->set_flags.
 
251
 */
 
252
#define DB_CDB_ALLDB          0x000400  /* In CDB, lock across environment. */
 
253
 
 
254
/*
 
255
 * Flags private to DB->set_feedback's callback.
 
256
 */
 
257
#define DB_UPGRADE            0x000400  /* Upgrading. */
 
258
#define DB_VERIFY             0x000800  /* Verifying. */
 
259
 
 
260
/*
 
261
 * Flags private to DB->set_flags.
 
262
 *
 
263
 * DB->set_flags does not share common flags and so values start at 0x01.
 
264
 */
 
265
#define DB_DUP                  0x0001  /* Btree, Hash: duplicate keys. */
 
266
#define DB_DUPSORT              0x0002  /* Btree, Hash: duplicate keys. */
 
267
#define DB_RECNUM               0x0004  /* Btree: record numbers. */
 
268
#define DB_RENUMBER             0x0008  /* Recno: renumber on insert/delete. */
 
269
#define DB_REVSPLITOFF          0x0010  /* Btree: turn off reverse splits. */
 
270
#define DB_SNAPSHOT             0x0020  /* Recno: snapshot the input. */
 
271
 
 
272
/*
 
273
 * Flags private to DB->join.
 
274
 *
 
275
 * DB->join does not share common flags and so values start at 0x01.
 
276
 */
 
277
#define DB_JOIN_NOSORT          0x0001  /* Don't try to optimize join. */
 
278
 
 
279
/*
 
280
 * Flags private to DB->verify.
 
281
 *
 
282
 * DB->verify does not share common flags and so values start at 0x01.
 
283
 */
 
284
#define DB_AGGRESSIVE         0x0001  /* Salvage anything which might be data.*/
 
285
#define DB_NOORDERCHK         0x0002  /* Skip order check; subdb w/ user func */
 
286
#define DB_ORDERCHKONLY       0x0004  /* Only perform an order check on subdb */
 
287
#define DB_PR_PAGE            0x0008  /* Show page contents (-da). */
 
288
#define DB_PR_RECOVERYTEST    0x0010  /* Recovery test (-dr). */
 
289
#define DB_SALVAGE            0x0020  /* Salvage what looks like data. */
 
290
/*
 
291
 * !!!
 
292
 * These must not go over 0x8000, or they will collide with the flags
 
293
 * used by __bam_vrfy_subtree.
 
294
 */
 
295
 
 
296
/*
 
297
 * Deadlock detector modes; used in the DBENV structure to configure the
 
298
 * locking subsystem.
 
299
 */
 
300
#define DB_LOCK_NORUN           0
 
301
#define DB_LOCK_DEFAULT         1       /* Default policy. */
 
302
#define DB_LOCK_MAXLOCKS        2       /* Abort txn with maximum # of locks. */
 
303
#define DB_LOCK_MINLOCKS        3       /* Abort txn with minimum # of locks. */
 
304
#define DB_LOCK_MINWRITE        4       /* Abort txn with minimum writelocks. */
 
305
#define DB_LOCK_OLDEST          5       /* Abort oldest transaction. */
 
306
#define DB_LOCK_RANDOM          6       /* Abort random transaction. */
 
307
#define DB_LOCK_YOUNGEST        7       /* Abort youngest transaction. */
 
308
 
 
309
/*******************************************************
 
310
 * Environment.
 
311
 *******************************************************/
 
312
#define DB_REGION_MAGIC 0x120897        /* Environment magic number. */
 
313
 
 
314
typedef enum {
 
315
        DB_TXN_ABORT=0,
 
316
        DB_TXN_BACKWARD_ROLL=1,
 
317
        DB_TXN_FORWARD_ROLL=2,
 
318
        DB_TXN_OPENFILES=3,
 
319
        DB_TXN_POPENFILES=4
 
320
} db_recops;
 
321
 
 
322
#define DB_UNDO(op)     ((op) == DB_TXN_ABORT || (op) == DB_TXN_BACKWARD_ROLL)
 
323
#define DB_REDO(op)     ((op) == DB_TXN_FORWARD_ROLL)
 
324
 
 
325
struct __db_env {
 
326
        /*******************************************************
 
327
         * Public: owned by the application.
 
328
         *******************************************************/
 
329
        FILE            *db_errfile;    /* Error message file stream. */
 
330
        const char      *db_errpfx;     /* Error message prefix. */
 
331
                                        /* Callbacks. */
 
332
        void (*db_errcall) __P((const char *, char *));
 
333
        void (*db_feedback) __P((DB_ENV *, int, int));
 
334
        void (*db_paniccall) __P((DB_ENV *, int));
 
335
        int  (*db_recovery_init) __P((DB_ENV *));
 
336
 
 
337
                                        /* App-specified alloc functions. */
 
338
        void *(*db_malloc) __P((size_t));
 
339
        void *(*db_realloc) __P((void *, size_t));
 
340
        void (*db_free) __P((void *));
 
341
 
 
342
        /*
 
343
         * Currently, the verbose list is a bit field with room for 32
 
344
         * entries.  There's no reason that it needs to be limited, if
 
345
         * there are ever more than 32 entries, convert to a bit array.
 
346
         */
 
347
#define DB_VERB_CHKPOINT        0x0001  /* List checkpoints. */
 
348
#define DB_VERB_DEADLOCK        0x0002  /* Deadlock detection information. */
 
349
#define DB_VERB_RECOVERY        0x0004  /* Recovery information. */
 
350
#define DB_VERB_WAITSFOR        0x0008  /* Dump waits-for table. */
 
351
        u_int32_t        verbose;       /* Verbose output. */
 
352
 
 
353
        void            *app_private;   /* Application-private handle. */
 
354
 
 
355
        /* Locking. */
 
356
        u_int8_t        *lk_conflicts;  /* Two dimensional conflict matrix. */
 
357
        u_int32_t        lk_modes;      /* Number of lock modes in table. */
 
358
        u_int32_t        lk_max;        /* Maximum number of locks. */
 
359
        u_int32_t        lk_max_lockers;/* Maximum number of lockers. */
 
360
        u_int32_t        lk_max_objects;/* Maximum number of locked objects. */
 
361
        u_int32_t        lk_detect;     /* Deadlock detect on all conflicts. */
 
362
 
 
363
        /* Logging. */
 
364
        u_int32_t        lg_bsize;      /* Buffer size. */
 
365
        u_int32_t        lg_max;        /* Maximum file size. */
 
366
        u_int32_t        lg_regionmax;  /* Region size. */
 
367
 
 
368
        /* Memory pool. */
 
369
        u_int32_t        mp_gbytes;     /* Cachesize: GB. */
 
370
        u_int32_t        mp_bytes;      /* Cachesize: Bytes. */
 
371
        size_t           mp_size;       /* DEPRECATED: Cachesize: bytes. */
 
372
        int              mp_ncache;     /* Number of cache regions. */
 
373
        size_t           mp_mmapsize;   /* Maximum file size for mmap. */
 
374
 
 
375
        /* Transactions. */
 
376
        u_int32_t        tx_max;        /* Maximum number of transactions. */
 
377
        time_t           tx_timestamp;  /* Recover to specific timestamp. */
 
378
        int (*tx_recover)               /* Dispatch function for recovery. */
 
379
            __P((DB_ENV *, DBT *, DB_LSN *, db_recops));
 
380
 
 
381
        /*******************************************************
 
382
         * Private: owned by DB.
 
383
         *******************************************************/
 
384
        int              panic_errval;  /* Panic causing errno. */
 
385
 
 
386
        /* User files, paths. */
 
387
        char            *db_home;       /* Database home. */
 
388
        char            *db_log_dir;    /* Database log file directory. */
 
389
        char            *db_tmp_dir;    /* Database tmp file directory. */
 
390
 
 
391
        char           **db_data_dir;   /* Database data file directories. */
 
392
        int              data_cnt;      /* Database data file slots. */
 
393
        int              data_next;     /* Next Database data file slot. */
 
394
 
 
395
        int              db_mode;       /* Default open permissions. */
 
396
 
 
397
        void            *reginfo;       /* REGINFO structure reference. */
 
398
        DB_FH           *lockfhp;       /* fcntl(2) locking file handle. */
 
399
        long             shm_key;       /* shmget(2) key. */
 
400
 
 
401
        void            *lg_handle;     /* Log handle. */
 
402
 
 
403
        void            *lk_handle;     /* Lock handle. */
 
404
 
 
405
        void            *mp_handle;     /* Mpool handle. */
 
406
 
 
407
        void            *tx_handle;     /* Txn handle. */
 
408
 
 
409
        int           (**dtab)          /* Dispatch table */
 
410
                            __P((DB_ENV *, DBT *, DB_LSN *, db_recops, void *));
 
411
        size_t           dtab_size;     /* Slots in the dispatch table. */
 
412
 
 
413
        void            *cl_handle;     /* RPC: remote client handle. */
 
414
        long             cl_id;         /* RPC: remote client env id. */
 
415
 
 
416
        int              db_ref;        /* db reference count. */
 
417
        u_int32_t        db_mutexlocks; /* db_set_mutexlocks */
 
418
 
 
419
        /*
 
420
         * List of open DB handles for this DB_ENV, used for cursor
 
421
         * adjustment.  Must be protected for multi-threaded support.
 
422
         *
 
423
         * !!!
 
424
         * As this structure is allocated in per-process memory, the
 
425
         * mutex may need to be stored elsewhere on architectures unable
 
426
         * to support mutexes in heap memory, e.g. HP/UX 9.
 
427
         */
 
428
        void            *dblist_mutexp; /* Mutex. */
 
429
        /*
 
430
         * !!!
 
431
         * Explicit representation of structure in queue.h.
 
432
         * LIST_HEAD(dblist, __db);
 
433
         */
 
434
        struct {
 
435
                struct __db *lh_first;
 
436
        } dblist;
 
437
 
 
438
        /*
 
439
         * XA support.
 
440
         *
 
441
         * !!!
 
442
         * Explicit representations of structures in queue.h.
 
443
         *
 
444
         * TAILQ_ENTRY(__db_env);
 
445
         */
 
446
        struct {
 
447
                struct __db_env *tqe_next;
 
448
                struct __db_env **tqe_prev;
 
449
        } links;
 
450
        int              xa_rmid;       /* XA Resource Manager ID. */
 
451
        DB_TXN          *xa_txn;        /* XA Current transaction. */
 
452
 
 
453
        void    *cj_internal;           /* C++/Java private. */
 
454
 
 
455
                                        /* Methods. */
 
456
        int  (*close) __P((DB_ENV *, u_int32_t));
 
457
        void (*err) __P((const DB_ENV *, int, const char *, ...));
 
458
        void (*errx) __P((const DB_ENV *, const char *, ...));
 
459
        int  (*open) __P((DB_ENV *, const char *, u_int32_t, int));
 
460
        int  (*remove) __P((DB_ENV *, const char *, u_int32_t));
 
461
        int  (*set_data_dir) __P((DB_ENV *, const char *));
 
462
        int  (*set_alloc) __P((DB_ENV *, void *(*)(size_t),
 
463
                void *(*)(void *, size_t), void (*)(void *)));
 
464
        void (*set_errcall) __P((DB_ENV *, void (*)(const char *, char *)));
 
465
        void (*set_errfile) __P((DB_ENV *, FILE *));
 
466
        void (*set_errpfx) __P((DB_ENV *, const char *));
 
467
        int  (*set_feedback) __P((DB_ENV *, void (*)(DB_ENV *, int, int)));
 
468
        int  (*set_flags) __P((DB_ENV *, u_int32_t, int));
 
469
        int  (*set_mutexlocks) __P((DB_ENV *, int));
 
470
        int  (*set_paniccall) __P((DB_ENV *, void (*)(DB_ENV *, int)));
 
471
        int  (*set_recovery_init) __P((DB_ENV *, int (*)(DB_ENV *)));
 
472
        int  (*set_rpc_server) __P((DB_ENV *,
 
473
                void *, const char *, long, long, u_int32_t));
 
474
        int  (*set_server) __P((DB_ENV *, const char *, long, long, u_int32_t));
 
475
        int  (*set_shm_key) __P((DB_ENV *, long));
 
476
        int  (*set_tmp_dir) __P((DB_ENV *, const char *));
 
477
        int  (*set_verbose) __P((DB_ENV *, u_int32_t, int));
 
478
 
 
479
        int  (*set_lg_bsize) __P((DB_ENV *, u_int32_t));
 
480
        int  (*set_lg_dir) __P((DB_ENV *, const char *));
 
481
        int  (*set_lg_max) __P((DB_ENV *, u_int32_t));
 
482
        int  (*set_lg_regionmax) __P((DB_ENV *, u_int32_t));
 
483
 
 
484
        int  (*set_lk_conflicts) __P((DB_ENV *, u_int8_t *, int));
 
485
        int  (*set_lk_detect) __P((DB_ENV *, u_int32_t));
 
486
        int  (*set_lk_max) __P((DB_ENV *, u_int32_t));
 
487
        int  (*set_lk_max_locks) __P((DB_ENV *, u_int32_t));
 
488
        int  (*set_lk_max_lockers) __P((DB_ENV *, u_int32_t));
 
489
        int  (*set_lk_max_objects) __P((DB_ENV *, u_int32_t));
 
490
 
 
491
        int  (*set_mp_mmapsize) __P((DB_ENV *, size_t));
 
492
        int  (*set_cachesize) __P((DB_ENV *, u_int32_t, u_int32_t, int));
 
493
 
 
494
        int  (*set_tx_max) __P((DB_ENV *, u_int32_t));
 
495
        int  (*set_tx_recover) __P((DB_ENV *,
 
496
                int (*)(DB_ENV *, DBT *, DB_LSN *, db_recops)));
 
497
        int  (*set_tx_timestamp) __P((DB_ENV *, time_t *));
 
498
 
 
499
#ifdef CONFIG_TEST
 
500
#define DB_TEST_PREOPEN          1      /* before __os_open */
 
501
#define DB_TEST_POSTOPEN         2      /* after __os_open */
 
502
#define DB_TEST_POSTLOGMETA      3      /* after logging meta in btree */
 
503
#define DB_TEST_POSTLOG          4      /* after logging all pages */
 
504
#define DB_TEST_POSTSYNC         5      /* after syncing the log */
 
505
#define DB_TEST_PREDESTROY       6      /* before destroy op */
 
506
#define DB_TEST_POSTDESTROY      7      /* after destroy op */
 
507
        int              test_abort;    /* Abort value for testing. */
 
508
        int              test_copy;     /* Copy value for testing. */
 
509
#endif
 
510
 
 
511
#define DB_ENV_CDB              0x00001 /* DB_INIT_CDB. */
 
512
#define DB_ENV_CDB_ALLDB        0x00002 /* CDB environment wide locking. */
 
513
#define DB_ENV_CREATE           0x00004 /* DB_CREATE set. */
 
514
#define DB_ENV_DBLOCAL          0x00008 /* DB_ENV allocated for private DB. */
 
515
#define DB_ENV_LOCKDOWN         0x00010 /* DB_LOCKDOWN set. */
 
516
#define DB_ENV_NOMMAP           0x00020 /* DB_NOMMAP set. */
 
517
#define DB_ENV_OPEN_CALLED      0x00040 /* DBENV->open called (paths valid). */
 
518
#define DB_ENV_PANIC_OK         0x00080 /* Removing env, okay if panic set */
 
519
#define DB_ENV_PRIVATE          0x00100 /* DB_PRIVATE set. */
 
520
#define DB_ENV_RPCCLIENT        0x00200 /* DB_CLIENT set. */
 
521
#define DB_ENV_RPCCLIENT_GIVEN  0x00400 /* User-supplied RPC client struct */
 
522
#define DB_ENV_STANDALONE       0x00800 /* Test: freestanding environment. */
 
523
#define DB_ENV_SYSTEM_MEM       0x01000 /* DB_SYSTEM_MEM set. */
 
524
#define DB_ENV_THREAD           0x02000 /* DB_THREAD set. */
 
525
#define DB_ENV_TXN_NOSYNC       0x04000 /* DB_TXN_NOSYNC set. */
 
526
#define DB_ENV_USER_ALLOC       0x08000 /* User allocated the structure. */
 
527
        u_int32_t        flags;         /* Flags. */
 
528
};
 
529
 
 
530
/*******************************************************
 
531
 * Access methods.
 
532
 *******************************************************/
 
533
/*
 
534
 * !!!
 
535
 * Changes here must be reflected in java/src/com/sleepycat/db/Db.java.
 
536
 */
 
537
typedef enum {
 
538
        DB_BTREE=1,
 
539
        DB_HASH=2,
 
540
        DB_RECNO=3,
 
541
        DB_QUEUE=4,
 
542
        DB_UNKNOWN=5                    /* Figure it out on open. */
 
543
} DBTYPE;
 
544
 
 
545
#define DB_BTREEVERSION 8               /* Current btree version. */
 
546
#define DB_BTREEOLDVER  6               /* Oldest btree version supported. */
 
547
#define DB_BTREEMAGIC   0x053162
 
548
 
 
549
#define DB_HASHVERSION  7               /* Current hash version. */
 
550
#define DB_HASHOLDVER   4               /* Oldest hash version supported. */
 
551
#define DB_HASHMAGIC    0x061561
 
552
 
 
553
#define DB_QAMVERSION   3               /* Current queue version. */
 
554
#define DB_QAMOLDVER    1               /* Oldest queue version supported. */
 
555
#define DB_QAMMAGIC     0x042253
 
556
 
 
557
#define DB_LOGVERSION   4               /* Current log version. */
 
558
#define DB_LOGOLDVER    3               /* Oldest log version supported. */
 
559
#define DB_LOGMAGIC     0x040988
 
560
 
 
561
/*
 
562
 * DB access method and cursor operation values.  Each value is an operation
 
563
 * code to which additional bit flags are added.
 
564
 */
 
565
#define DB_AFTER                 1      /* c_put() */
 
566
#define DB_APPEND                2      /* put() */
 
567
#define DB_BEFORE                3      /* c_put() */
 
568
#define DB_CACHED_COUNTS         4      /* stat() */
 
569
#define DB_CHECKPOINT            5      /* log_put(), log_get() */
 
570
#define DB_COMMIT                6      /* log_put() (internal) */
 
571
#define DB_CONSUME               7      /* get() */
 
572
#define DB_CONSUME_WAIT  8      /* get() */
 
573
#define DB_CURLSN                9      /* log_put() */
 
574
#define DB_CURRENT              10      /* c_get(), c_put(), log_get() */
 
575
#define DB_FAST_STAT            11      /* stat() */
 
576
#define DB_FIRST                12      /* c_get(), log_get() */
 
577
#define DB_FLUSH                13      /* log_put() */
 
578
#define DB_GET_BOTH             14      /* get(), c_get() */
 
579
#define DB_GET_BOTHC            15      /* c_get() (internal) */
 
580
#define DB_GET_RECNO            16      /* c_get() */
 
581
#define DB_JOIN_ITEM            17      /* c_get(); do not do primary lookup */
 
582
#define DB_KEYFIRST             18      /* c_put() */
 
583
#define DB_KEYLAST              19      /* c_put() */
 
584
#define DB_LAST                 20      /* c_get(), log_get() */
 
585
#define DB_NEXT                 21      /* c_get(), log_get() */
 
586
#define DB_NEXT_DUP             22      /* c_get() */
 
587
#define DB_NEXT_NODUP           23      /* c_get() */
 
588
#define DB_NODUPDATA            24      /* put(), c_put() */
 
589
#define DB_NOOVERWRITE          25      /* put() */
 
590
#define DB_NOSYNC               26      /* close() */
 
591
#define DB_POSITION             27      /* c_dup() */
 
592
#define DB_POSITIONI            28      /* c_dup() (internal) */
 
593
#define DB_PREV                 29      /* c_get(), log_get() */
 
594
#define DB_PREV_NODUP           30      /* c_get(), log_get() */
 
595
#define DB_RECORDCOUNT          31      /* stat() */
 
596
#define DB_SET                  32      /* c_get(), log_get() */
 
597
#define DB_SET_RANGE            33      /* c_get() */
 
598
#define DB_SET_RECNO            34      /* get(), c_get() */
 
599
#define DB_UPDATE_SECONDARY     35      /* c_get(), c_del() (internal) */
 
600
#define DB_WRITECURSOR          36      /* cursor() */
 
601
#define DB_WRITELOCK            37      /* cursor() (internal) */
 
602
 
 
603
/* This has to change when the max opcode hits 255. */
 
604
#define DB_OPFLAGS_MASK 0x000000ff      /* Mask for operations flags. */
 
605
#define DB_DIRTY_READ   0x10000000      /* Support Dirty Read. */
 
606
#define DB_MULTIPLE     0x20000000      /* Return multiple data values. */
 
607
#define DB_MULTIPLE_KEY 0x40000000      /* Return multiple data/key pairs. */
 
608
#define DB_RMW          0x80000000      /* Acquire write flag immediately. */
 
609
 
 
610
/*
 
611
 * DB (user visible) error return codes.
 
612
 *
 
613
 * !!!
 
614
 * Changes to any of the user visible error return codes must be reflected
 
615
 * in java/src/com/sleepycat/db/Db.java.
 
616
 *
 
617
 * !!!
 
618
 * For source compatibility with DB 2.X deadlock return (EAGAIN), use the
 
619
 * following:
 
620
 *      #include <errno.h>
 
621
 *      #define DB_LOCK_DEADLOCK EAGAIN
 
622
 *
 
623
 * !!!
 
624
 * We don't want our error returns to conflict with other packages where
 
625
 * possible, so pick a base error value that's hopefully not common.  We
 
626
 * document that we own the error name space from -30,800 to -30,999.
 
627
 */
 
628
/* Public error return codes. */
 
629
#define DB_DONOTINDEX           (-30999)/* "Null" return from 2ndary callbk. */
 
630
#define DB_INCOMPLETE           (-30998)/* Sync didn't finish. */
 
631
#define DB_KEYEMPTY             (-30997)/* Key/data deleted or never created. */
 
632
#define DB_KEYEXIST             (-30996)/* The key/data pair already exists. */
 
633
#define DB_LOCK_DEADLOCK        (-30995)/* Deadlock. */
 
634
#define DB_LOCK_NOTGRANTED      (-30994)/* Lock unavailable. */
 
635
#define DB_NOSERVER             (-30993)/* Server panic return. */
 
636
#define DB_NOSERVER_HOME        (-30992)/* Bad home sent to server. */
 
637
#define DB_NOSERVER_ID          (-30991)/* Bad ID sent to server. */
 
638
#define DB_NOTFOUND             (-30990)/* Key/data pair not found (EOF). */
 
639
#define DB_OLD_VERSION          (-30989)/* Out-of-date version. */
 
640
#define DB_PAGE_NOTFOUND        (-30988)/* Requested page not found. */
 
641
#define DB_RUNRECOVERY          (-30987)/* Panic return. */
 
642
#define DB_SECONDARY_BAD        (-30986)/* Secondary index corrupt. */
 
643
#define DB_VERIFY_BAD           (-30985)/* Verify failed; bad format. */
 
644
 
 
645
/* DB (private) error return codes. */
 
646
#define DB_ALREADY_ABORTED      (-30899)
 
647
#define DB_DELETED              (-30898)/* Recovery file marked deleted. */
 
648
#define DB_JAVA_CALLBACK        (-30897)/* Exception during a java callback. */
 
649
#define DB_NEEDSPLIT            (-30896)/* Page needs to be split. */
 
650
#define DB_SURPRISE_KID         (-30895)/* Child commit, but parent doesn't
 
651
                                           know that it's a parent. */
 
652
#define DB_SWAPBYTES            (-30894)/* Database needs byte swapping. */
 
653
#define DB_TXN_CKP              (-30893)/* Encountered ckp record in log. */
 
654
#define DB_VERIFY_FATAL         (-30892)/* Fatal: DB->verify cannot proceed. */
 
655
 
 
656
#define DB_FILE_ID_LEN          20      /* DB file ID length. */
 
657
 
 
658
/* DB access method description structure. */
 
659
struct __db {
 
660
        /*******************************************************
 
661
         * Public: owned by the application.
 
662
         *******************************************************/
 
663
        u_int32_t pgsize;               /* Database logical page size. */
 
664
 
 
665
                                        /* Callbacks. */
 
666
        int (*db_append_recno) __P((DB *, DBT *, db_recno_t));
 
667
        void (*db_feedback) __P((DB *, int, int));
 
668
        int (*dup_compare) __P((DB *, const DBT *, const DBT *));
 
669
 
 
670
        void    *app_private;           /* Application-private handle. */
 
671
 
 
672
        /*******************************************************
 
673
         * Private: owned by DB.
 
674
         *******************************************************/
 
675
        DB_ENV  *dbenv;                 /* Backing environment. */
 
676
 
 
677
        DBTYPE   type;                  /* DB access method type. */
 
678
 
 
679
        DB_MPOOLFILE *mpf;              /* Backing buffer pool. */
 
680
 
 
681
        void    *mutexp;                /* Synchronization for free threading */
 
682
 
 
683
        u_int8_t fileid[DB_FILE_ID_LEN];/* File's unique ID for locking. */
 
684
 
 
685
        u_int32_t adj_fileid;           /* File's unique ID for curs. adj. */
 
686
 
 
687
#define DB_LOGFILEID_INVALID    -1
 
688
        int32_t  log_fileid;            /* File's unique ID for logging. */
 
689
        db_pgno_t meta_pgno;            /* Meta page number */
 
690
        DB_TXN  *open_txn;              /* Transaction to protect creates. */
 
691
 
 
692
        long     cl_id;                 /* RPC: remote client id. */
 
693
 
 
694
        /*
 
695
         * Returned data memory for DB->get() and friends.
 
696
         */
 
697
        DBT      my_rskey;              /* Secondary key. */
 
698
        DBT      my_rkey;               /* [Primary] key. */
 
699
        DBT      my_rdata;              /* Data. */
 
700
 
 
701
        /*
 
702
         * !!!
 
703
         * Some applications use DB but implement their own locking outside of
 
704
         * DB.  If they're using fcntl(2) locking on the underlying database
 
705
         * file, and we open and close a file descriptor for that file, we will
 
706
         * discard their locks.  The DB_FCNTL_LOCKING flag to DB->open is an
 
707
         * undocumented interface to support this usage which leaves any file
 
708
         * descriptors we open until DB->close.  This will only work with the
 
709
         * DB->open interface and simple caches, e.g., creating a transaction
 
710
         * thread may open/close file descriptors this flag doesn't protect.
 
711
         * Locking with fcntl(2) on a file that you don't own is a very, very
 
712
         * unsafe thing to do.  'Nuff said.
 
713
         */
 
714
        DB_FH   *saved_open_fhp;        /* Saved file handle. */
 
715
 
 
716
        /*
 
717
         * Linked list of DBP's, used in the log's dbentry table
 
718
         * to keep track of all open db handles for a given log id.
 
719
         * !!!
 
720
         * Explicit representations of structures in queue.h.
 
721
         *
 
722
         * TAILQ_ENTRY(__db) links;
 
723
         */
 
724
        struct {
 
725
                struct __db *tqe_next;
 
726
                struct __db **tqe_prev;
 
727
        } links;
 
728
 
 
729
        /*
 
730
         * Linked list of DBP's, linked from the DB_ENV, used to
 
731
         * keep track of all open db handles for cursor adjustment.
 
732
         *
 
733
         * XXX
 
734
         * Eventually, this should be merged with "links" above.
 
735
         *
 
736
         * !!!
 
737
         * Explicit representations of structures in queue.h.
 
738
         *
 
739
         * LIST_ENTRY(__db) dblistlinks;
 
740
         */
 
741
        struct {
 
742
                struct __db *le_next;
 
743
                struct __db **le_prev;
 
744
        } dblistlinks;
 
745
 
 
746
        /*
 
747
         * Cursor queues.
 
748
         *
 
749
         * !!!
 
750
         * Explicit representations of structures in queue.h.
 
751
         *
 
752
         * TAILQ_HEAD(free_queue, __dbc);
 
753
         * TAILQ_HEAD(active_queue, __dbc);
 
754
         * TAILQ_HEAD(join_queue, __dbc);
 
755
         */
 
756
        struct {
 
757
                struct __dbc *tqh_first;
 
758
                struct __dbc **tqh_last;
 
759
        } free_queue;
 
760
        struct {
 
761
                struct __dbc *tqh_first;
 
762
                struct __dbc **tqh_last;
 
763
        } active_queue;
 
764
        struct {
 
765
                struct __dbc *tqh_first;
 
766
                struct __dbc **tqh_last;
 
767
        } join_queue;
 
768
 
 
769
        /*
 
770
         * Secondary index support.
 
771
         *
 
772
         * !!!
 
773
         * Explicit representations of structures in queue.h.
 
774
         */
 
775
        /* Linked list of secondary indices -- set in the primary. */
 
776
        struct {
 
777
                struct __db *lh_first;
 
778
        } s_secondaries;
 
779
 
 
780
        /*
 
781
         * List entries for secondaries, and reference count of how
 
782
         * many threads are updating this secondary (see __db_c_put).
 
783
         *
 
784
         * !!!
 
785
         * Note that these are synchronized by the primary's mutex, but
 
786
         * filled in in the secondaries.
 
787
         */
 
788
        struct {
 
789
                struct __db *le_next;
 
790
                struct __db **le_prev;
 
791
        } s_links;
 
792
        u_int32_t s_refcnt;
 
793
 
 
794
        /* Secondary callback and free functions -- set in the secondary. */
 
795
        int     (*s_callback)(DB *, const DBT *, const DBT *, DBT *);
 
796
 
 
797
        /* Reference to primary -- set in the secondary. */
 
798
        DB      *s_primary;
 
799
 
 
800
        /*
 
801
         * Subsystem-private structures.
 
802
         */
 
803
 
 
804
        void    *bt_internal;           /* Btree/Recno access method private. */
 
805
        void    *cj_internal;           /* C++/Java private. */
 
806
        void    *h_internal;            /* Hash access method private. */
 
807
        void    *q_internal;            /* Queue access method private. */
 
808
        void    *xa_internal;           /* XA private. */
 
809
 
 
810
                                        /* Methods. */
 
811
        int  (*associate) __P((DB *, DB *, int (*)(DB *, const DBT *,
 
812
                const DBT *, DBT *), u_int32_t));
 
813
        int  (*close) __P((DB *, u_int32_t));
 
814
        int  (*cursor) __P((DB *, DB_TXN *, DBC **, u_int32_t));
 
815
        int  (*del) __P((DB *, DB_TXN *, DBT *, u_int32_t));
 
816
        void (*err) __P((DB *, int, const char *, ...));
 
817
        void (*errx) __P((DB *, const char *, ...));
 
818
        int  (*fd) __P((DB *, int *));
 
819
        int  (*get) __P((DB *, DB_TXN *, DBT *, DBT *, u_int32_t));
 
820
        int  (*pget) __P((DB *, DB_TXN *, DBT *, DBT *, DBT *, u_int32_t));
 
821
        int  (*get_byteswapped) __P((DB *, int *));
 
822
        int  (*get_type) __P((DB *, DBTYPE *));
 
823
        int  (*join) __P((DB *, DBC **, DBC **, u_int32_t));
 
824
        int  (*key_range) __P((DB *,
 
825
                DB_TXN *, DBT *, DB_KEY_RANGE *, u_int32_t));
 
826
        int  (*open) __P((DB *,
 
827
                const char *, const char *, DBTYPE, u_int32_t, int));
 
828
        int  (*put) __P((DB *, DB_TXN *, DBT *, DBT *, u_int32_t));
 
829
        int  (*remove) __P((DB *, const char *, const char *, u_int32_t));
 
830
        int  (*rename) __P((DB *,
 
831
            const char *, const char *, const char *, u_int32_t));
 
832
        int  (*truncate) __P((DB *, DB_TXN *, u_int32_t *, u_int32_t));
 
833
        int  (*set_append_recno) __P((DB *, int (*)(DB *, DBT *, db_recno_t)));
 
834
        int  (*set_alloc) __P((DB *, void *(*)(size_t),
 
835
                void *(*)(void *, size_t), void (*)(void *)));
 
836
        int  (*set_cachesize) __P((DB *, u_int32_t, u_int32_t, int));
 
837
        int  (*set_dup_compare) __P((DB *,
 
838
            int (*)(DB *, const DBT *, const DBT *)));
 
839
        void (*set_errcall) __P((DB *, void (*)(const char *, char *)));
 
840
        void (*set_errfile) __P((DB *, FILE *));
 
841
        void (*set_errpfx) __P((DB *, const char *));
 
842
        int  (*set_feedback) __P((DB *, void (*)(DB *, int, int)));
 
843
        int  (*set_flags) __P((DB *, u_int32_t));
 
844
        int  (*set_lorder) __P((DB *, int));
 
845
        int  (*set_pagesize) __P((DB *, u_int32_t));
 
846
        int  (*set_paniccall) __P((DB *, void (*)(DB_ENV *, int)));
 
847
        int  (*stat) __P((DB *, void *, u_int32_t));
 
848
        int  (*sync) __P((DB *, u_int32_t));
 
849
        int  (*upgrade) __P((DB *, const char *, u_int32_t));
 
850
        int  (*verify) __P((DB *,
 
851
            const char *, const char *, FILE *, u_int32_t));
 
852
 
 
853
        int  (*set_bt_compare) __P((DB *,
 
854
            int (*)(DB *, const DBT *, const DBT *)));
 
855
        int  (*set_bt_maxkey) __P((DB *, u_int32_t));
 
856
        int  (*set_bt_minkey) __P((DB *, u_int32_t));
 
857
        int  (*set_bt_prefix) __P((DB *,
 
858
            size_t (*)(DB *, const DBT *, const DBT *)));
 
859
 
 
860
        int  (*set_h_ffactor) __P((DB *, u_int32_t));
 
861
        int  (*set_h_hash) __P((DB *,
 
862
            u_int32_t (*)(DB *, const void *, u_int32_t)));
 
863
        int  (*set_h_nelem) __P((DB *, u_int32_t));
 
864
 
 
865
        int  (*set_re_delim) __P((DB *, int));
 
866
        int  (*set_re_len) __P((DB *, u_int32_t));
 
867
        int  (*set_re_pad) __P((DB *, int));
 
868
        int  (*set_re_source) __P((DB *, const char *));
 
869
        int  (*set_q_extentsize) __P((DB *, u_int32_t));
 
870
 
 
871
        int  (*db_am_remove) __P((DB *, const char *,
 
872
            const char *, DB_LSN *, int (**)(DB *, void *), void **));
 
873
        int  (*db_am_rename) __P((DB *,
 
874
            const char *, const char *, const char *));
 
875
 
 
876
        /*
 
877
         * Never called; these are a place to save function pointers
 
878
         * so that we can undo an associate.
 
879
         */
 
880
        int  (*stored_get) __P((DB *, DB_TXN *, DBT *, DBT *, u_int32_t));
 
881
        int  (*stored_close) __P((DB *, u_int32_t));
 
882
 
 
883
#define DB_OK_BTREE     0x01
 
884
#define DB_OK_HASH      0x02
 
885
#define DB_OK_QUEUE     0x04
 
886
#define DB_OK_RECNO     0x08
 
887
        u_int32_t       am_ok;          /* Legal AM choices. */
 
888
 
 
889
#define DB_AM_DIRTY     0x000001        /* Support Dirty Reads. */
 
890
#define DB_AM_DISCARD   0x000002        /* Discard any cached pages. */
 
891
#define DB_AM_DUP       0x000004        /* DB_DUP. */
 
892
#define DB_AM_DUPSORT   0x000008        /* DB_DUPSORT. */
 
893
#define DB_AM_INMEM     0x000010        /* In-memory; no sync on close. */
 
894
#define DB_AM_PGDEF     0x000020        /* Page size was defaulted. */
 
895
#define DB_AM_RDONLY    0x000040        /* Database is readonly. */
 
896
#define DB_AM_RECOVER   0x000080        /* DBP opened by recovery routine. */
 
897
#define DB_AM_SECONDARY 0x000100        /* Database is a secondary index. */
 
898
#define DB_AM_SUBDB     0x000200        /* Subdatabases supported. */
 
899
#define DB_AM_SWAP      0x000400        /* Pages need to be byte-swapped. */
 
900
#define DB_AM_TXN       0x000800        /* DBP was in a transaction. */
 
901
#define DB_AM_VERIFYING 0x001000        /* DB handle is in the verifier. */
 
902
#define DB_BT_RECNUM    0x002000        /* DB_RECNUM. */
 
903
#define DB_BT_REVSPLIT  0x004000        /* DB_REVSPLITOFF. */
 
904
#define DB_DBM_ERROR    0x008000        /* Error in DBM/NDBM database. */
 
905
#define DB_OPEN_CALLED  0x010000        /* DB->open called. */
 
906
#define DB_RE_DELIMITER 0x020000        /* Variablen length delimiter set. */
 
907
#define DB_RE_FIXEDLEN  0x040000        /* Fixed-length records. */
 
908
#define DB_RE_PAD       0x080000        /* Fixed-length record pad. */
 
909
#define DB_RE_RENUMBER  0x100000        /* DB_RENUMBER. */
 
910
#define DB_RE_SNAPSHOT  0x200000        /* DB_SNAPSHOT. */
 
911
        u_int32_t flags;
 
912
};
 
913
/*******************************************************
 
914
 * Locking
 
915
 *******************************************************/
 
916
#define DB_LOCKVERSION  1
 
917
 
 
918
/* Flag values for lock_vec(), lock_get(). */
 
919
#define DB_LOCK_NOWAIT          0x01    /* Don't wait on unavailable lock. */
 
920
#define DB_LOCK_RECORD          0x02    /* Internal: record lock. */
 
921
#define DB_LOCK_UPGRADE         0x04    /* Internal: upgrade existing lock. */
 
922
#define DB_LOCK_SWITCH          0x08    /* Internal: switch existing lock. */
 
923
 
 
924
/*
 
925
 * Request types.
 
926
 *
 
927
 * !!!
 
928
 * Changes here must be reflected in java/src/com/sleepycat/db/Db.java.
 
929
 */
 
930
typedef enum {
 
931
        DB_LOCK_DUMP=0,                 /* Display held locks. */
 
932
        DB_LOCK_GET=1,                  /* Get the lock. */
 
933
        DB_LOCK_INHERIT=2,              /* Pass locks to parent. */
 
934
        DB_LOCK_PUT=3,                  /* Release the lock. */
 
935
        DB_LOCK_PUT_ALL=4,              /* Release locker's locks. */
 
936
        DB_LOCK_PUT_OBJ=5,              /* Release locker's locks on obj. */
 
937
        DB_LOCK_UPGRADE_WRITE=6         /* Upgrade writes for dirty reads. */
 
938
} db_lockop_t;
 
939
 
 
940
/*
 
941
 * Simple R/W lock modes and for multi-granularity intention locking.
 
942
 *
 
943
 * !!!
 
944
 * These values are NOT random, as they are used as an index into the lock
 
945
 * conflicts arrays, i.e., DB_LOCK_IWRITE must be == 3, and DB_LOCK_IREAD
 
946
 * must be == 4.
 
947
 *
 
948
 * !!!
 
949
 * Changes here must be reflected in java/src/com/sleepycat/db/Db.java.
 
950
 */
 
951
typedef enum {
 
952
        DB_LOCK_NG=0,                   /* Not granted. */
 
953
        DB_LOCK_READ=1,                 /* Shared/read. */
 
954
        DB_LOCK_WRITE=2,                /* Exclusive/write. */
 
955
        DB_LOCK_WAIT=3,                 /* Wait for event */
 
956
        DB_LOCK_IWRITE=4,               /* Intent exclusive/write. */
 
957
        DB_LOCK_IREAD=5,                /* Intent to share/read. */
 
958
        DB_LOCK_IWR=6,                  /* Intent to read and write. */
 
959
        DB_LOCK_DIRTY=7,                /* Dirty Read. */
 
960
        DB_LOCK_WWRITE=8                /* Was Written. */
 
961
} db_lockmode_t;
 
962
 
 
963
/*
 
964
 * Status of a lock.
 
965
 */
 
966
typedef enum {
 
967
        DB_LSTAT_ABORTED=1,             /* Lock belongs to an aborted txn. */
 
968
        DB_LSTAT_ERR=2,                 /* Lock is bad. */
 
969
        DB_LSTAT_FREE=3,                /* Lock is unallocated. */
 
970
        DB_LSTAT_HELD=4,                /* Lock is currently held. */
 
971
        DB_LSTAT_NOGRANT=5,             /* Lock was not granted. */
 
972
        DB_LSTAT_PENDING=6,             /* Lock was waiting and has been
 
973
                                         * promoted; waiting for the owner
 
974
                                         * to run and upgrade it to held. */
 
975
        DB_LSTAT_WAITING=7              /* Lock is on the wait queue. */
 
976
} db_status_t;
 
977
 
 
978
/* Lock statistics structure. */
 
979
struct __db_lock_stat {
 
980
        u_int32_t st_lastid;            /* Last allocated locker ID. */
 
981
        u_int32_t st_maxlocks;          /* Maximum number of locks in table. */
 
982
        u_int32_t st_maxlockers;        /* Maximum num of lockers in table. */
 
983
        u_int32_t st_maxobjects;        /* Maximum num of objects in table. */
 
984
        u_int32_t st_nmodes;            /* Number of lock modes. */
 
985
        u_int32_t st_nlocks;            /* Current number of locks. */
 
986
        u_int32_t st_maxnlocks;         /* Maximum number of locks so far. */
 
987
        u_int32_t st_nlockers;          /* Current number of lockers. */
 
988
        u_int32_t st_maxnlockers;       /* Maximum number of lockers so far. */
 
989
        u_int32_t st_nobjects;          /* Current number of objects. */
 
990
        u_int32_t st_maxnobjects;       /* Maximum number of objects so far. */
 
991
        u_int32_t st_nconflicts;        /* Number of lock conflicts. */
 
992
        u_int32_t st_nrequests;         /* Number of lock gets. */
 
993
        u_int32_t st_nreleases;         /* Number of lock puts. */
 
994
        u_int32_t st_nnowaits;          /* Number of requests that would have
 
995
                                           waited, but NOWAIT was set. */
 
996
        u_int32_t st_ndeadlocks;        /* Number of lock deadlocks. */
 
997
        u_int32_t st_region_wait;       /* Region lock granted after wait. */
 
998
        u_int32_t st_region_nowait;     /* Region lock granted without wait. */
 
999
        u_int32_t st_regsize;           /* Region size. */
 
1000
};
 
1001
 
 
1002
/*
 
1003
 * DB_LOCK_ILOCK --
 
1004
 *      Internal DB access method lock.
 
1005
 */
 
1006
struct __db_ilock {
 
1007
        db_pgno_t pgno;                 /* Page being locked. */
 
1008
        u_int8_t fileid[DB_FILE_ID_LEN];/* File id. */
 
1009
#define DB_RECORD_LOCK  1
 
1010
#define DB_PAGE_LOCK    2
 
1011
        u_int8_t type;                  /* Record or Page lock */
 
1012
};
 
1013
 
 
1014
/*
 
1015
 * DB_LOCK --
 
1016
 *      The structure is allocated by the caller and filled in during a
 
1017
 *      lock_get request (or a lock_vec/DB_LOCK_GET).
 
1018
 */
 
1019
struct __db_lock_u {
 
1020
        size_t          off;            /* Offset of the lock in the region */
 
1021
        u_int32_t       ndx;            /* Index of the object referenced by
 
1022
                                         * this lock; used for locking. */
 
1023
        u_int32_t       gen;            /* Generation number of this lock. */
 
1024
        db_lockmode_t   mode;           /* mode of this lock. */
 
1025
};
 
1026
 
 
1027
/* Lock request structure. */
 
1028
struct __db_lockreq {
 
1029
        db_lockop_t      op;            /* Operation. */
 
1030
        db_lockmode_t    mode;          /* Requested mode. */
 
1031
        DBT             *obj;           /* Object being locked. */
 
1032
        DB_LOCK          lock;          /* Lock returned. */
 
1033
};
 
1034
 
 
1035
/* Cursor description structure. */
 
1036
struct __dbc {
 
1037
        DB *dbp;                        /* Related DB access method. */
 
1038
        DB_TXN   *txn;                  /* Associated transaction. */
 
1039
 
 
1040
        /*
 
1041
         * !!!
 
1042
         * Explicit representations of structures in queue.h.
 
1043
         *
 
1044
         * TAILQ_ENTRY(__dbc) links;    Active/free cursor queues.
 
1045
         */
 
1046
        struct {
 
1047
                DBC *tqe_next;
 
1048
                DBC **tqe_prev;
 
1049
        } links;
 
1050
 
 
1051
        /*
 
1052
         * The DBT *'s below are used by the cursor routines to return
 
1053
         * data to the user when DBT flags indicate that DB should manage
 
1054
         * the returned memory.  They point at a DBT containing the buffer
 
1055
         * and length that will be used, and "belonging" to the handle that
 
1056
         * should "own" this memory.  This may be a "my_*" field of this
 
1057
         * cursor--the default--or it may be the corresponding field of
 
1058
         * another cursor, a DB handle, a join cursor, etc.  In general, it
 
1059
         * will be whatever handle the user originally used for the current
 
1060
         * DB interface call.
 
1061
         */
 
1062
        DBT      *rskey;                /* Returned secondary key. */
 
1063
        DBT      *rkey;                 /* Returned [primary] key. */
 
1064
        DBT      *rdata;                /* Returned data. */
 
1065
 
 
1066
        DBT       my_rskey;             /* Space for returned secondary key. */
 
1067
        DBT       my_rkey;              /* Space for returned [primary] key. */
 
1068
        DBT       my_rdata;             /* Space for returned data. */
 
1069
 
 
1070
        u_int32_t lid;                  /* Default process' locker id. */
 
1071
        u_int32_t locker;               /* Locker for this operation. */
 
1072
        DBT       lock_dbt;             /* DBT referencing lock. */
 
1073
        DB_LOCK_ILOCK lock;             /* Object to be locked. */
 
1074
        DB_LOCK   mylock;               /* Lock held on this cursor. */
 
1075
 
 
1076
        long      cl_id;                /* Remote client id. */
 
1077
 
 
1078
        DBTYPE    dbtype;               /* Cursor type. */
 
1079
 
 
1080
        DBC_INTERNAL *internal;         /* Access method private. */
 
1081
 
 
1082
        int (*c_close) __P((DBC *));    /* Methods: public. */
 
1083
        int (*c_count) __P((DBC *, db_recno_t *, u_int32_t));
 
1084
        int (*c_del) __P((DBC *, u_int32_t));
 
1085
        int (*c_dup) __P((DBC *, DBC **, u_int32_t));
 
1086
        int (*c_get) __P((DBC *, DBT *, DBT *, u_int32_t));
 
1087
        int (*c_pget) __P((DBC *, DBT *, DBT *, DBT *, u_int32_t));
 
1088
        int (*c_put) __P((DBC *, DBT *, DBT *, u_int32_t));
 
1089
 
 
1090
                                        /* Methods: private. */
 
1091
        int (*c_am_bulk) __P((DBC *, DBT *, u_int32_t));
 
1092
        int (*c_am_close) __P((DBC *, db_pgno_t, int *));
 
1093
        int (*c_am_del) __P((DBC *));
 
1094
        int (*c_am_destroy) __P((DBC *));
 
1095
        int (*c_am_get) __P((DBC *, DBT *, DBT *, u_int32_t, db_pgno_t *));
 
1096
        int (*c_am_put) __P((DBC *, DBT *, DBT *, u_int32_t, db_pgno_t *));
 
1097
        int (*c_am_writelock) __P((DBC *));
 
1098
 
 
1099
        /* Private: for secondary indices. */
 
1100
        int (*c_real_get) __P((DBC *, DBT *, DBT *, u_int32_t));
 
1101
 
 
1102
#define DBC_ACTIVE      0x001           /* Cursor is being used. */
 
1103
#define DBC_COMPENSATE  0x002           /* Cursor is doing compensation
 
1104
                                         * do not lock.
 
1105
                                         */
 
1106
#define DBC_DIRTY_READ  0x004           /* Cursor is supporting dirty reads. */
 
1107
#define DBC_OPD         0x008           /* Cursor references off-page dups. */
 
1108
#define DBC_RECOVER     0x010           /* Cursor created by  recovery routine
 
1109
                                         * (do not log or lock).
 
1110
                                         */
 
1111
#define DBC_RMW         0x020           /* Acquire write flag in read op. */
 
1112
#define DBC_TRANSIENT   0x040           /* Cursor is transient. */
 
1113
#define DBC_WRITECURSOR 0x080           /* Cursor may be used to write (CDB). */
 
1114
#define DBC_WRITEDUP    0x100           /* idup'ed DBC_WRITECURSOR (CDB). */
 
1115
#define DBC_WRITER      0x200           /* Cursor immediately writing (CDB). */
 
1116
#define DBC_MULTIPLE    0x400           /* Return Multiple data. */
 
1117
#define DBC_MULTIPLE_KEY 0x800          /* Return Multiple keys and data. */
 
1118
        u_int32_t flags;
 
1119
};
 
1120
 
 
1121
/* Key range statistics structure */
 
1122
struct __key_range {
 
1123
        double less;
 
1124
        double equal;
 
1125
        double greater;
 
1126
};
 
1127
 
 
1128
/* Btree/Recno statistics structure. */
 
1129
struct __db_bt_stat {
 
1130
        u_int32_t bt_magic;             /* Magic number. */
 
1131
        u_int32_t bt_version;           /* Version number. */
 
1132
        u_int32_t bt_metaflags;         /* Metadata flags. */
 
1133
        u_int32_t bt_nkeys;             /* Number of unique keys. */
 
1134
        u_int32_t bt_ndata;             /* Number of data items. */
 
1135
        u_int32_t bt_pagesize;          /* Page size. */
 
1136
        u_int32_t bt_maxkey;            /* Maxkey value. */
 
1137
        u_int32_t bt_minkey;            /* Minkey value. */
 
1138
        u_int32_t bt_re_len;            /* Fixed-length record length. */
 
1139
        u_int32_t bt_re_pad;            /* Fixed-length record pad. */
 
1140
        u_int32_t bt_levels;            /* Tree levels. */
 
1141
        u_int32_t bt_int_pg;            /* Internal pages. */
 
1142
        u_int32_t bt_leaf_pg;           /* Leaf pages. */
 
1143
        u_int32_t bt_dup_pg;            /* Duplicate pages. */
 
1144
        u_int32_t bt_over_pg;           /* Overflow pages. */
 
1145
        u_int32_t bt_free;              /* Pages on the free list. */
 
1146
        u_int32_t bt_int_pgfree;        /* Bytes free in internal pages. */
 
1147
        u_int32_t bt_leaf_pgfree;       /* Bytes free in leaf pages. */
 
1148
        u_int32_t bt_dup_pgfree;        /* Bytes free in duplicate pages. */
 
1149
        u_int32_t bt_over_pgfree;       /* Bytes free in overflow pages. */
 
1150
};
 
1151
 
 
1152
/* Queue statistics structure. */
 
1153
struct __db_qam_stat {
 
1154
        u_int32_t qs_magic;             /* Magic number. */
 
1155
        u_int32_t qs_version;           /* Version number. */
 
1156
        u_int32_t qs_metaflags;         /* Metadata flags. */
 
1157
        u_int32_t qs_nkeys;             /* Number of unique keys. */
 
1158
        u_int32_t qs_ndata;             /* Number of data items. */
 
1159
        u_int32_t qs_pagesize;          /* Page size. */
 
1160
        u_int32_t qs_extentsize;        /* Pages per extent. */
 
1161
        u_int32_t qs_pages;             /* Data pages. */
 
1162
        u_int32_t qs_re_len;            /* Fixed-length record length. */
 
1163
        u_int32_t qs_re_pad;            /* Fixed-length record pad. */
 
1164
        u_int32_t qs_pgfree;            /* Bytes free in data pages. */
 
1165
        u_int32_t qs_first_recno;       /* First not deleted record. */
 
1166
        u_int32_t qs_cur_recno;         /* Last allocated record number. */
 
1167
};
 
1168
 
 
1169
/* Hash statistics structure. */
 
1170
struct __db_h_stat {
 
1171
        u_int32_t hash_magic;           /* Magic number. */
 
1172
        u_int32_t hash_version;         /* Version number. */
 
1173
        u_int32_t hash_metaflags;       /* Metadata flags. */
 
1174
        u_int32_t hash_nkeys;           /* Number of unique keys. */
 
1175
        u_int32_t hash_ndata;           /* Number of data items. */
 
1176
        u_int32_t hash_pagesize;        /* Page size. */
 
1177
        u_int32_t hash_nelem;           /* Original nelem specified. */
 
1178
        u_int32_t hash_ffactor;         /* Fill factor specified at create. */
 
1179
        u_int32_t hash_buckets;         /* Number of hash buckets. */
 
1180
        u_int32_t hash_free;            /* Pages on the free list. */
 
1181
        u_int32_t hash_bfree;           /* Bytes free on bucket pages. */
 
1182
        u_int32_t hash_bigpages;        /* Number of big key/data pages. */
 
1183
        u_int32_t hash_big_bfree;       /* Bytes free on big item pages. */
 
1184
        u_int32_t hash_overflows;       /* Number of overflow pages. */
 
1185
        u_int32_t hash_ovfl_free;       /* Bytes free on ovfl pages. */
 
1186
        u_int32_t hash_dup;             /* Number of dup pages. */
 
1187
        u_int32_t hash_dup_free;        /* Bytes free on duplicate pages. */
 
1188
};
 
1189
 
 
1190
/*******************************************************
 
1191
 * Logging.
 
1192
 *******************************************************/
 
1193
/* Flag values for log_archive(). */
 
1194
#define DB_ARCH_ABS             0x001   /* Absolute pathnames. */
 
1195
#define DB_ARCH_DATA            0x002   /* Data files. */
 
1196
#define DB_ARCH_LOG             0x004   /* Log files. */
 
1197
 
 
1198
/*
 
1199
 * A DB_LSN has two parts, a fileid which identifies a specific file, and an
 
1200
 * offset within that file.  The fileid is an unsigned 4-byte quantity that
 
1201
 * uniquely identifies a file within the log directory -- currently a simple
 
1202
 * counter inside the log.  The offset is also an unsigned 4-byte value.  The
 
1203
 * log manager guarantees the offset is never more than 4 bytes by switching
 
1204
 * to a new log file before the maximum length imposed by an unsigned 4-byte
 
1205
 * offset is reached.
 
1206
 */
 
1207
struct __db_lsn {
 
1208
        u_int32_t       file;           /* File ID. */
 
1209
        u_int32_t       offset;         /* File offset. */
 
1210
};
 
1211
 
 
1212
/* Log statistics structure. */
 
1213
struct __db_log_stat {
 
1214
        u_int32_t st_magic;             /* Log file magic number. */
 
1215
        u_int32_t st_version;           /* Log file version number. */
 
1216
        int st_mode;                    /* Log file mode. */
 
1217
        u_int32_t st_lg_bsize;          /* Log buffer size. */
 
1218
        u_int32_t st_lg_max;            /* Maximum log file size. */
 
1219
        u_int32_t st_w_bytes;           /* Bytes to log. */
 
1220
        u_int32_t st_w_mbytes;          /* Megabytes to log. */
 
1221
        u_int32_t st_wc_bytes;          /* Bytes to log since checkpoint. */
 
1222
        u_int32_t st_wc_mbytes;         /* Megabytes to log since checkpoint. */
 
1223
        u_int32_t st_wcount;            /* Total writes to the log. */
 
1224
        u_int32_t st_wcount_fill;       /* Overflow writes to the log. */
 
1225
        u_int32_t st_scount;            /* Total syncs to the log. */
 
1226
        u_int32_t st_region_wait;       /* Region lock granted after wait. */
 
1227
        u_int32_t st_region_nowait;     /* Region lock granted without wait. */
 
1228
        u_int32_t st_cur_file;          /* Current log file number. */
 
1229
        u_int32_t st_cur_offset;        /* Current log file offset. */
 
1230
        u_int32_t st_disk_file;         /* Known on disk log file number. */
 
1231
        u_int32_t st_disk_offset;       /* Known on disk log file offset. */
 
1232
        u_int32_t st_regsize;           /* Region size. */
 
1233
};
 
1234
 
 
1235
/*******************************************************
 
1236
 * Mpool
 
1237
 *******************************************************/
 
1238
/* Flag values for memp_fget(). */
 
1239
#define DB_MPOOL_CREATE         0x001   /* Create a page. */
 
1240
#define DB_MPOOL_LAST           0x002   /* Return the last page. */
 
1241
#define DB_MPOOL_NEW            0x004   /* Create a new page. */
 
1242
#define DB_MPOOL_NEW_GROUP      0x008   /* Create a group of pages. */
 
1243
 
 
1244
/* Flag values for memp_fput(), memp_fset(). */
 
1245
#define DB_MPOOL_CLEAN          0x001   /* Page is not modified. */
 
1246
#define DB_MPOOL_DIRTY          0x002   /* Page is modified. */
 
1247
#define DB_MPOOL_DISCARD        0x004   /* Don't cache the page. */
 
1248
 
 
1249
/* Mpool statistics structure. */
 
1250
struct __db_mpool_stat {
 
1251
        u_int32_t st_cache_hit;         /* Pages found in the cache. */
 
1252
        u_int32_t st_cache_miss;        /* Pages not found in the cache. */
 
1253
        u_int32_t st_map;               /* Pages from mapped files. */
 
1254
        u_int32_t st_page_create;       /* Pages created in the cache. */
 
1255
        u_int32_t st_page_in;           /* Pages read in. */
 
1256
        u_int32_t st_page_out;          /* Pages written out. */
 
1257
        u_int32_t st_ro_evict;          /* Clean pages forced from the cache. */
 
1258
        u_int32_t st_rw_evict;          /* Dirty pages forced from the cache. */
 
1259
        u_int32_t st_hash_buckets;      /* Number of hash buckets. */
 
1260
        u_int32_t st_hash_searches;     /* Total hash chain searches. */
 
1261
        u_int32_t st_hash_longest;      /* Longest hash chain searched. */
 
1262
        u_int32_t st_hash_examined;     /* Total hash entries searched. */
 
1263
        u_int32_t st_page_clean;        /* Clean pages. */
 
1264
        u_int32_t st_page_dirty;        /* Dirty pages. */
 
1265
        u_int32_t st_page_trickle;      /* Pages written by memp_trickle. */
 
1266
        u_int32_t st_region_wait;       /* Region lock granted after wait. */
 
1267
        u_int32_t st_region_nowait;     /* Region lock granted without wait. */
 
1268
        u_int32_t st_gbytes;            /* Total cache size: GB. */
 
1269
        u_int32_t st_bytes;             /* Total cache size: B. */
 
1270
        u_int32_t st_ncache;            /* Number of caches. */
 
1271
        u_int32_t st_regsize;           /* Cache size. */
 
1272
};
 
1273
 
 
1274
/* Mpool file open information structure. */
 
1275
struct __db_mpool_finfo {
 
1276
        int        ftype;               /* File type. */
 
1277
        DBT       *pgcookie;            /* Byte-string passed to pgin/pgout. */
 
1278
        u_int8_t  *fileid;              /* Unique file ID. */
 
1279
        int32_t    lsn_offset;          /* LSN offset in page. */
 
1280
        u_int32_t  clear_len;           /* Cleared length on created pages. */
 
1281
};
 
1282
 
 
1283
/* Mpool file statistics structure. */
 
1284
struct __db_mpool_fstat {
 
1285
        char *file_name;                /* File name. */
 
1286
        size_t st_pagesize;             /* Page size. */
 
1287
        u_int32_t st_cache_hit;         /* Pages found in the cache. */
 
1288
        u_int32_t st_cache_miss;        /* Pages not found in the cache. */
 
1289
        u_int32_t st_map;               /* Pages from mapped files. */
 
1290
        u_int32_t st_page_create;       /* Pages created in the cache. */
 
1291
        u_int32_t st_page_in;           /* Pages read in. */
 
1292
        u_int32_t st_page_out;          /* Pages written out. */
 
1293
};
 
1294
 
 
1295
/*******************************************************
 
1296
 * Transactions.
 
1297
 *******************************************************/
 
1298
#define DB_TXNVERSION   1
 
1299
 
 
1300
/* Transaction statistics structure. */
 
1301
struct __db_txn_active {
 
1302
        u_int32_t       txnid;          /* Transaction ID */
 
1303
        u_int32_t       parentid;       /* Transaction ID of parent */
 
1304
        DB_LSN          lsn;            /* Lsn of the begin record */
 
1305
};
 
1306
 
 
1307
struct __db_txn_stat {
 
1308
        DB_LSN    st_last_ckp;          /* lsn of the last checkpoint */
 
1309
        DB_LSN    st_pending_ckp;       /* last checkpoint did not finish */
 
1310
        time_t    st_time_ckp;          /* time of last checkpoint */
 
1311
        u_int32_t st_last_txnid;        /* last transaction id given out */
 
1312
        u_int32_t st_maxtxns;           /* maximum txns possible */
 
1313
        u_int32_t st_naborts;           /* number of aborted transactions */
 
1314
        u_int32_t st_nbegins;           /* number of begun transactions */
 
1315
        u_int32_t st_ncommits;          /* number of committed transactions */
 
1316
        u_int32_t st_nactive;           /* number of active transactions */
 
1317
        u_int32_t st_nrestores;         /* number of restored transactions
 
1318
                                           after recovery. */
 
1319
        u_int32_t st_maxnactive;        /* maximum active transactions */
 
1320
        DB_TXN_ACTIVE *st_txnarray;     /* array of active transactions */
 
1321
        u_int32_t st_region_wait;       /* Region lock granted after wait. */
 
1322
        u_int32_t st_region_nowait;     /* Region lock granted without wait. */
 
1323
        u_int32_t st_regsize;           /* Region size. */
 
1324
};
 
1325
 
 
1326
/*
 
1327
 * Structure used for two phase commit interface.  Berkeley DB support for two
 
1328
 * phase commit is compatible with the X/open XA interface.  The xa #define
 
1329
 * XIDDATASIZE defines the size of a global transaction ID.  We have our own
 
1330
 * version here which must have the same value.
 
1331
 */
 
1332
#define DB_XIDDATASIZE  128
 
1333
typedef struct db_preplist {
 
1334
        DB_TXN  *txn;
 
1335
        u_int8_t gid[DB_XIDDATASIZE];
 
1336
} DB_PREPLIST;
 
1337
 
 
1338
#ifndef DB_DBM_HSEARCH
 
1339
#define DB_DBM_HSEARCH  0               /* No historic interfaces by default. */
 
1340
#endif
 
1341
#if DB_DBM_HSEARCH != 0
 
1342
/*******************************************************
 
1343
 * Dbm/Ndbm historic interfaces.
 
1344
 *******************************************************/
 
1345
typedef struct __db DBM;
 
1346
 
 
1347
#define DBM_INSERT      0               /* Flags to dbm_store(). */
 
1348
#define DBM_REPLACE     1
 
1349
 
 
1350
/*
 
1351
 * The DB support for ndbm(3) always appends this suffix to the
 
1352
 * file name to avoid overwriting the user's original database.
 
1353
 */
 
1354
#define DBM_SUFFIX      ".db"
 
1355
 
 
1356
#if defined(_XPG4_2)
 
1357
typedef struct {
 
1358
        char *dptr;
 
1359
        size_t dsize;
 
1360
} datum;
 
1361
#else
 
1362
typedef struct {
 
1363
        char *dptr;
 
1364
        int dsize;
 
1365
} datum;
 
1366
#endif
 
1367
 
 
1368
/*******************************************************
 
1369
 * Hsearch historic interface.
 
1370
 *******************************************************/
 
1371
typedef enum {
 
1372
        FIND, ENTER
 
1373
} ACTION;
 
1374
 
 
1375
typedef struct entry {
 
1376
        char *key;
 
1377
        char *data;
 
1378
} ENTRY;
 
1379
 
 
1380
#endif /* DB_DBM_HSEARCH */
 
1381
 
 
1382
/*
 
1383
 * XXX
 
1384
 * MacOS: Reset Metrowerks C enum sizes.
 
1385
 */
 
1386
#ifdef __MWERKS__
 
1387
#pragma enumsalwaysint reset
 
1388
#endif
 
1389
 
 
1390
#if defined(__cplusplus)
 
1391
}
 
1392
#endif