1*7c478bd9Sstevel@tonic-gate /*- 2*7c478bd9Sstevel@tonic-gate * See the file LICENSE for redistribution information. 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * Copyright (c) 1996, 1997, 1998 5*7c478bd9Sstevel@tonic-gate * Sleepycat Software. All rights reserved. 6*7c478bd9Sstevel@tonic-gate * 7*7c478bd9Sstevel@tonic-gate * @(#)db.h 10.174 (Sleepycat) 1/3/99 8*7c478bd9Sstevel@tonic-gate */ 9*7c478bd9Sstevel@tonic-gate 10*7c478bd9Sstevel@tonic-gate #ifndef _DB_H_ 11*7c478bd9Sstevel@tonic-gate #define _DB_H_ 12*7c478bd9Sstevel@tonic-gate 13*7c478bd9Sstevel@tonic-gate #ifndef __NO_SYSTEM_INCLUDES 14*7c478bd9Sstevel@tonic-gate #include <sys/types.h> 15*7c478bd9Sstevel@tonic-gate 16*7c478bd9Sstevel@tonic-gate #include <stdio.h> 17*7c478bd9Sstevel@tonic-gate #endif 18*7c478bd9Sstevel@tonic-gate 19*7c478bd9Sstevel@tonic-gate /* 20*7c478bd9Sstevel@tonic-gate * XXX 21*7c478bd9Sstevel@tonic-gate * MacOS: ensure that Metrowerks C makes enumeration types int sized. 22*7c478bd9Sstevel@tonic-gate */ 23*7c478bd9Sstevel@tonic-gate #ifdef __MWERKS__ 24*7c478bd9Sstevel@tonic-gate #pragma enumsalwaysint on 25*7c478bd9Sstevel@tonic-gate #endif 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate /* 28*7c478bd9Sstevel@tonic-gate * XXX 29*7c478bd9Sstevel@tonic-gate * Handle function prototypes and the keyword "const". This steps on name 30*7c478bd9Sstevel@tonic-gate * space that DB doesn't control, but all of the other solutions are worse. 31*7c478bd9Sstevel@tonic-gate * 32*7c478bd9Sstevel@tonic-gate * XXX 33*7c478bd9Sstevel@tonic-gate * While Microsoft's compiler is ANSI C compliant, it doesn't have _STDC_ 34*7c478bd9Sstevel@tonic-gate * defined by default, you specify a command line flag or #pragma to turn 35*7c478bd9Sstevel@tonic-gate * it on. Don't do that, however, because some of Microsoft's own header 36*7c478bd9Sstevel@tonic-gate * files won't compile. 37*7c478bd9Sstevel@tonic-gate */ 38*7c478bd9Sstevel@tonic-gate #undef __P 39*7c478bd9Sstevel@tonic-gate #if defined(__STDC__) || defined(__cplusplus) || defined(_MSC_VER) 40*7c478bd9Sstevel@tonic-gate #define __P(protos) protos /* ANSI C prototypes */ 41*7c478bd9Sstevel@tonic-gate #else 42*7c478bd9Sstevel@tonic-gate #define const 43*7c478bd9Sstevel@tonic-gate #define __P(protos) () /* K&R C preprocessor */ 44*7c478bd9Sstevel@tonic-gate #endif 45*7c478bd9Sstevel@tonic-gate 46*7c478bd9Sstevel@tonic-gate /* 47*7c478bd9Sstevel@tonic-gate * !!! 48*7c478bd9Sstevel@tonic-gate * DB needs basic information about specifically sized types. If they're 49*7c478bd9Sstevel@tonic-gate * not provided by the system, typedef them here. 50*7c478bd9Sstevel@tonic-gate * 51*7c478bd9Sstevel@tonic-gate * We protect them against multiple inclusion using __BIT_TYPES_DEFINED__, 52*7c478bd9Sstevel@tonic-gate * as does BIND and Kerberos, since we don't know for sure what #include 53*7c478bd9Sstevel@tonic-gate * files the user is using. 54*7c478bd9Sstevel@tonic-gate * 55*7c478bd9Sstevel@tonic-gate * !!! 56*7c478bd9Sstevel@tonic-gate * We also provide the standard u_int, u_long etc., if they're not provided 57*7c478bd9Sstevel@tonic-gate * by the system. 58*7c478bd9Sstevel@tonic-gate */ 59*7c478bd9Sstevel@tonic-gate #ifndef __BIT_TYPES_DEFINED__ 60*7c478bd9Sstevel@tonic-gate #define __BIT_TYPES_DEFINED__ 61*7c478bd9Sstevel@tonic-gate typedef unsigned char u_int8_t; 62*7c478bd9Sstevel@tonic-gate 63*7c478bd9Sstevel@tonic-gate typedef unsigned short u_int16_t; 64*7c478bd9Sstevel@tonic-gate 65*7c478bd9Sstevel@tonic-gate typedef unsigned int u_int32_t; 66*7c478bd9Sstevel@tonic-gate #endif 67*7c478bd9Sstevel@tonic-gate 68*7c478bd9Sstevel@tonic-gate 69*7c478bd9Sstevel@tonic-gate 70*7c478bd9Sstevel@tonic-gate 71*7c478bd9Sstevel@tonic-gate 72*7c478bd9Sstevel@tonic-gate 73*7c478bd9Sstevel@tonic-gate #define DB_VERSION_MAJOR 2 74*7c478bd9Sstevel@tonic-gate #define DB_VERSION_MINOR 7 75*7c478bd9Sstevel@tonic-gate #define DB_VERSION_PATCH 7 76*7c478bd9Sstevel@tonic-gate #define DB_VERSION_STRING "Sleepycat Software: Berkeley DB 2.7.7: (08/20/99)" 77*7c478bd9Sstevel@tonic-gate 78*7c478bd9Sstevel@tonic-gate typedef u_int32_t db_pgno_t; /* Page number type. */ 79*7c478bd9Sstevel@tonic-gate typedef u_int16_t db_indx_t; /* Page offset type. */ 80*7c478bd9Sstevel@tonic-gate #define DB_MAX_PAGES 0xffffffff /* >= # of pages in a file */ 81*7c478bd9Sstevel@tonic-gate 82*7c478bd9Sstevel@tonic-gate typedef u_int32_t db_recno_t; /* Record number type. */ 83*7c478bd9Sstevel@tonic-gate #define DB_MAX_RECORDS 0xffffffff /* >= # of records in a tree */ 84*7c478bd9Sstevel@tonic-gate 85*7c478bd9Sstevel@tonic-gate typedef size_t DB_LOCK; /* Object returned by lock manager. */ 86*7c478bd9Sstevel@tonic-gate 87*7c478bd9Sstevel@tonic-gate /* Forward structure declarations, so applications get type checking. */ 88*7c478bd9Sstevel@tonic-gate struct __db; typedef struct __db DB; 89*7c478bd9Sstevel@tonic-gate #ifdef DB_DBM_HSEARCH 90*7c478bd9Sstevel@tonic-gate typedef struct __db DBM; 91*7c478bd9Sstevel@tonic-gate #endif 92*7c478bd9Sstevel@tonic-gate struct __db_bt_stat; typedef struct __db_bt_stat DB_BTREE_STAT; 93*7c478bd9Sstevel@tonic-gate struct __db_dbt; typedef struct __db_dbt DBT; 94*7c478bd9Sstevel@tonic-gate struct __db_env; typedef struct __db_env DB_ENV; 95*7c478bd9Sstevel@tonic-gate struct __db_ilock; typedef struct __db_ilock DB_LOCK_ILOCK; 96*7c478bd9Sstevel@tonic-gate struct __db_info; typedef struct __db_info DB_INFO; 97*7c478bd9Sstevel@tonic-gate struct __db_lock_stat; typedef struct __db_lock_stat DB_LOCK_STAT; 98*7c478bd9Sstevel@tonic-gate struct __db_lockregion; typedef struct __db_lockregion DB_LOCKREGION; 99*7c478bd9Sstevel@tonic-gate struct __db_lockreq; typedef struct __db_lockreq DB_LOCKREQ; 100*7c478bd9Sstevel@tonic-gate struct __db_locktab; typedef struct __db_locktab DB_LOCKTAB; 101*7c478bd9Sstevel@tonic-gate struct __db_log; typedef struct __db_log DB_LOG; 102*7c478bd9Sstevel@tonic-gate struct __db_log_stat; typedef struct __db_log_stat DB_LOG_STAT; 103*7c478bd9Sstevel@tonic-gate struct __db_lsn; typedef struct __db_lsn DB_LSN; 104*7c478bd9Sstevel@tonic-gate struct __db_mpool; typedef struct __db_mpool DB_MPOOL; 105*7c478bd9Sstevel@tonic-gate struct __db_mpool_finfo;typedef struct __db_mpool_finfo DB_MPOOL_FINFO; 106*7c478bd9Sstevel@tonic-gate struct __db_mpool_fstat;typedef struct __db_mpool_fstat DB_MPOOL_FSTAT; 107*7c478bd9Sstevel@tonic-gate struct __db_mpool_stat; typedef struct __db_mpool_stat DB_MPOOL_STAT; 108*7c478bd9Sstevel@tonic-gate struct __db_mpoolfile; typedef struct __db_mpoolfile DB_MPOOLFILE; 109*7c478bd9Sstevel@tonic-gate struct __db_txn; typedef struct __db_txn DB_TXN; 110*7c478bd9Sstevel@tonic-gate struct __db_txn_active; typedef struct __db_txn_active DB_TXN_ACTIVE; 111*7c478bd9Sstevel@tonic-gate struct __db_txn_stat; typedef struct __db_txn_stat DB_TXN_STAT; 112*7c478bd9Sstevel@tonic-gate struct __db_txnmgr; typedef struct __db_txnmgr DB_TXNMGR; 113*7c478bd9Sstevel@tonic-gate struct __db_txnregion; typedef struct __db_txnregion DB_TXNREGION; 114*7c478bd9Sstevel@tonic-gate struct __dbc; typedef struct __dbc DBC; 115*7c478bd9Sstevel@tonic-gate 116*7c478bd9Sstevel@tonic-gate /* Key/data structure -- a Data-Base Thang. */ 117*7c478bd9Sstevel@tonic-gate struct __db_dbt { 118*7c478bd9Sstevel@tonic-gate void *data; /* key/data */ 119*7c478bd9Sstevel@tonic-gate u_int32_t size; /* key/data length */ 120*7c478bd9Sstevel@tonic-gate u_int32_t ulen; /* RO: length of user buffer. */ 121*7c478bd9Sstevel@tonic-gate u_int32_t dlen; /* RO: get/put record length. */ 122*7c478bd9Sstevel@tonic-gate u_int32_t doff; /* RO: get/put record offset. */ 123*7c478bd9Sstevel@tonic-gate 124*7c478bd9Sstevel@tonic-gate #define DB_DBT_INTERNAL 0x01 /* Ignore user's malloc (internal). */ 125*7c478bd9Sstevel@tonic-gate #define DB_DBT_MALLOC 0x02 /* Return in allocated memory. */ 126*7c478bd9Sstevel@tonic-gate #define DB_DBT_PARTIAL 0x04 /* Partial put/get. */ 127*7c478bd9Sstevel@tonic-gate #define DB_DBT_USERMEM 0x08 /* Return in user's memory. */ 128*7c478bd9Sstevel@tonic-gate u_int32_t flags; 129*7c478bd9Sstevel@tonic-gate }; 130*7c478bd9Sstevel@tonic-gate 131*7c478bd9Sstevel@tonic-gate /* 132*7c478bd9Sstevel@tonic-gate * DB run-time interface configuration. 133*7c478bd9Sstevel@tonic-gate * 134*7c478bd9Sstevel@tonic-gate * There are a set of functions that the application can replace with its 135*7c478bd9Sstevel@tonic-gate * own versions, and some other knobs which can be turned at run-time. 136*7c478bd9Sstevel@tonic-gate */ 137*7c478bd9Sstevel@tonic-gate #define DB_FUNC_CLOSE 1 /* POSIX 1003.1 close. */ 138*7c478bd9Sstevel@tonic-gate #define DB_FUNC_DIRFREE 2 /* DB: free directory list. */ 139*7c478bd9Sstevel@tonic-gate #define DB_FUNC_DIRLIST 3 /* DB: create directory list. */ 140*7c478bd9Sstevel@tonic-gate #define DB_FUNC_EXISTS 4 /* DB: return if file exists. */ 141*7c478bd9Sstevel@tonic-gate #define DB_FUNC_FREE 5 /* ANSI C free. */ 142*7c478bd9Sstevel@tonic-gate #define DB_FUNC_FSYNC 6 /* POSIX 1003.1 fsync. */ 143*7c478bd9Sstevel@tonic-gate #define DB_FUNC_IOINFO 7 /* DB: return file I/O information. */ 144*7c478bd9Sstevel@tonic-gate #define DB_FUNC_MALLOC 8 /* ANSI C malloc. */ 145*7c478bd9Sstevel@tonic-gate #define DB_FUNC_MAP 9 /* DB: map file into shared memory. */ 146*7c478bd9Sstevel@tonic-gate #define DB_FUNC_OPEN 10 /* POSIX 1003.1 open. */ 147*7c478bd9Sstevel@tonic-gate #define DB_FUNC_READ 11 /* POSIX 1003.1 read. */ 148*7c478bd9Sstevel@tonic-gate #define DB_FUNC_REALLOC 12 /* ANSI C realloc. */ 149*7c478bd9Sstevel@tonic-gate #define DB_FUNC_RUNLINK 13 /* DB: remove a shared region. */ 150*7c478bd9Sstevel@tonic-gate #define DB_FUNC_SEEK 14 /* POSIX 1003.1 lseek. */ 151*7c478bd9Sstevel@tonic-gate #define DB_FUNC_SLEEP 15 /* DB: sleep secs/usecs. */ 152*7c478bd9Sstevel@tonic-gate #define DB_FUNC_UNLINK 16 /* POSIX 1003.1 unlink. */ 153*7c478bd9Sstevel@tonic-gate #define DB_FUNC_UNMAP 17 /* DB: unmap shared memory file. */ 154*7c478bd9Sstevel@tonic-gate #define DB_FUNC_WRITE 18 /* POSIX 1003.1 write. */ 155*7c478bd9Sstevel@tonic-gate #define DB_FUNC_YIELD 19 /* DB: yield thread to scheduler. */ 156*7c478bd9Sstevel@tonic-gate #define DB_MUTEXLOCKS 20 /* DB: turn off all mutex locks. */ 157*7c478bd9Sstevel@tonic-gate #define DB_PAGEYIELD 21 /* DB: yield the CPU on pool get. */ 158*7c478bd9Sstevel@tonic-gate #define DB_REGION_ANON 22 /* DB: anonymous, unnamed regions. */ 159*7c478bd9Sstevel@tonic-gate #define DB_REGION_INIT 23 /* DB: page-fault regions in create. */ 160*7c478bd9Sstevel@tonic-gate #define DB_REGION_NAME 24 /* DB: anonymous, named regions. */ 161*7c478bd9Sstevel@tonic-gate #define DB_TSL_SPINS 25 /* DB: initialize spin count. */ 162*7c478bd9Sstevel@tonic-gate 163*7c478bd9Sstevel@tonic-gate /* 164*7c478bd9Sstevel@tonic-gate * Database configuration and initialization. 165*7c478bd9Sstevel@tonic-gate */ 166*7c478bd9Sstevel@tonic-gate /* 167*7c478bd9Sstevel@tonic-gate * Flags understood by both db_open(3) and db_appinit(3). 168*7c478bd9Sstevel@tonic-gate */ 169*7c478bd9Sstevel@tonic-gate #define DB_CREATE 0x000001 /* O_CREAT: create file as necessary. */ 170*7c478bd9Sstevel@tonic-gate #define DB_NOMMAP 0x000002 /* Don't mmap underlying file. */ 171*7c478bd9Sstevel@tonic-gate #define DB_THREAD 0x000004 /* Free-thread DB package handles. */ 172*7c478bd9Sstevel@tonic-gate 173*7c478bd9Sstevel@tonic-gate /* 174*7c478bd9Sstevel@tonic-gate * Flags understood by db_appinit(3). 175*7c478bd9Sstevel@tonic-gate */ 176*7c478bd9Sstevel@tonic-gate /* 0x000007 COMMON MASK. */ 177*7c478bd9Sstevel@tonic-gate #define DB_INIT_CDB 0x000008 /* Concurrent Access Methods. */ 178*7c478bd9Sstevel@tonic-gate #define DB_INIT_LOCK 0x000010 /* Initialize locking. */ 179*7c478bd9Sstevel@tonic-gate #define DB_INIT_LOG 0x000020 /* Initialize logging. */ 180*7c478bd9Sstevel@tonic-gate #define DB_INIT_MPOOL 0x000040 /* Initialize mpool. */ 181*7c478bd9Sstevel@tonic-gate #define DB_INIT_TXN 0x000080 /* Initialize transactions. */ 182*7c478bd9Sstevel@tonic-gate #define DB_MPOOL_PRIVATE 0x000100 /* Mpool: private memory pool. */ 183*7c478bd9Sstevel@tonic-gate #define DB_RECOVER 0x000200 /* Run normal recovery. */ 184*7c478bd9Sstevel@tonic-gate #define DB_RECOVER_FATAL 0x000400 /* Run catastrophic recovery. */ 185*7c478bd9Sstevel@tonic-gate #define DB_TXN_NOSYNC 0x000800 /* Do not sync log on commit. */ 186*7c478bd9Sstevel@tonic-gate #define DB_USE_ENVIRON 0x001000 /* Use the environment. */ 187*7c478bd9Sstevel@tonic-gate #define DB_USE_ENVIRON_ROOT 0x002000 /* Use the environment if root. */ 188*7c478bd9Sstevel@tonic-gate 189*7c478bd9Sstevel@tonic-gate /* 190*7c478bd9Sstevel@tonic-gate * Flags understood by db_open(3). 191*7c478bd9Sstevel@tonic-gate * 192*7c478bd9Sstevel@tonic-gate * DB_EXCL and DB_TEMPORARY are internal only, and are not documented. 193*7c478bd9Sstevel@tonic-gate * DB_SEQUENTIAL is currently internal, but may be exported some day. 194*7c478bd9Sstevel@tonic-gate */ 195*7c478bd9Sstevel@tonic-gate /* 0x000007 COMMON MASK. */ 196*7c478bd9Sstevel@tonic-gate /* 0x001fff ALREADY USED. */ 197*7c478bd9Sstevel@tonic-gate #define DB_EXCL 0x002000 /* O_EXCL: exclusive open (internal). */ 198*7c478bd9Sstevel@tonic-gate #define DB_RDONLY 0x004000 /* O_RDONLY: read-only. */ 199*7c478bd9Sstevel@tonic-gate #define DB_SEQUENTIAL 0x008000 /* Sequential access (internal). */ 200*7c478bd9Sstevel@tonic-gate #define DB_TEMPORARY 0x010000 /* Remove on last close (internal). */ 201*7c478bd9Sstevel@tonic-gate #define DB_TRUNCATE 0x020000 /* O_TRUNCATE: replace existing DB. */ 202*7c478bd9Sstevel@tonic-gate #define DB_FCNTL_LOCKING 0x040000 /* Undocumented: fcntl(2) locking. */ 203*7c478bd9Sstevel@tonic-gate 204*7c478bd9Sstevel@tonic-gate /* 205*7c478bd9Sstevel@tonic-gate * Deadlock detector modes; used in the DBENV structure to configure the 206*7c478bd9Sstevel@tonic-gate * locking subsystem. 207*7c478bd9Sstevel@tonic-gate */ 208*7c478bd9Sstevel@tonic-gate #define DB_LOCK_NORUN 0 209*7c478bd9Sstevel@tonic-gate #define DB_LOCK_DEFAULT 1 /* Default policy. */ 210*7c478bd9Sstevel@tonic-gate #define DB_LOCK_OLDEST 2 /* Abort oldest transaction. */ 211*7c478bd9Sstevel@tonic-gate #define DB_LOCK_RANDOM 3 /* Abort random transaction. */ 212*7c478bd9Sstevel@tonic-gate #define DB_LOCK_YOUNGEST 4 /* Abort youngest transaction. */ 213*7c478bd9Sstevel@tonic-gate 214*7c478bd9Sstevel@tonic-gate struct __db_env { 215*7c478bd9Sstevel@tonic-gate int db_lorder; /* Byte order. */ 216*7c478bd9Sstevel@tonic-gate 217*7c478bd9Sstevel@tonic-gate /* Error message callback. */ 218*7c478bd9Sstevel@tonic-gate void (*db_errcall) __P((const char *, char *)); 219*7c478bd9Sstevel@tonic-gate FILE *db_errfile; /* Error message file stream. */ 220*7c478bd9Sstevel@tonic-gate const char *db_errpfx; /* Error message prefix. */ 221*7c478bd9Sstevel@tonic-gate int db_verbose; /* Generate debugging messages. */ 222*7c478bd9Sstevel@tonic-gate int db_panic; /* Panic flag, callback function. */ 223*7c478bd9Sstevel@tonic-gate void (*db_paniccall) __P((DB_ENV *, int)); 224*7c478bd9Sstevel@tonic-gate 225*7c478bd9Sstevel@tonic-gate /* User paths. */ 226*7c478bd9Sstevel@tonic-gate char *db_home; /* Database home. */ 227*7c478bd9Sstevel@tonic-gate char *db_log_dir; /* Database log file directory. */ 228*7c478bd9Sstevel@tonic-gate char *db_tmp_dir; /* Database tmp file directory. */ 229*7c478bd9Sstevel@tonic-gate 230*7c478bd9Sstevel@tonic-gate char **db_data_dir; /* Database data file directories. */ 231*7c478bd9Sstevel@tonic-gate int data_cnt; /* Database data file slots. */ 232*7c478bd9Sstevel@tonic-gate int data_next; /* Next Database data file slot. */ 233*7c478bd9Sstevel@tonic-gate 234*7c478bd9Sstevel@tonic-gate /* Locking. */ 235*7c478bd9Sstevel@tonic-gate DB_LOCKTAB *lk_info; /* Return from lock_open(). */ 236*7c478bd9Sstevel@tonic-gate const u_int8_t *lk_conflicts; /* Two dimensional conflict matrix. */ 237*7c478bd9Sstevel@tonic-gate u_int32_t lk_modes; /* Number of lock modes in table. */ 238*7c478bd9Sstevel@tonic-gate u_int32_t lk_max; /* Maximum number of locks. */ 239*7c478bd9Sstevel@tonic-gate u_int32_t lk_detect; /* Deadlock detect on all conflicts. */ 240*7c478bd9Sstevel@tonic-gate 241*7c478bd9Sstevel@tonic-gate /* Logging. */ 242*7c478bd9Sstevel@tonic-gate DB_LOG *lg_info; /* Return from log_open(). */ 243*7c478bd9Sstevel@tonic-gate u_int32_t lg_max; /* Maximum file size. */ 244*7c478bd9Sstevel@tonic-gate 245*7c478bd9Sstevel@tonic-gate /* Memory pool. */ 246*7c478bd9Sstevel@tonic-gate DB_MPOOL *mp_info; /* Return from memp_open(). */ 247*7c478bd9Sstevel@tonic-gate size_t mp_mmapsize; /* Maximum file size for mmap. */ 248*7c478bd9Sstevel@tonic-gate size_t mp_size; /* Bytes in the mpool cache. */ 249*7c478bd9Sstevel@tonic-gate 250*7c478bd9Sstevel@tonic-gate /* Transactions. */ 251*7c478bd9Sstevel@tonic-gate DB_TXNMGR *tx_info; /* Return from txn_open(). */ 252*7c478bd9Sstevel@tonic-gate u_int32_t tx_max; /* Maximum number of transactions. */ 253*7c478bd9Sstevel@tonic-gate int (*tx_recover) /* Dispatch function for recovery. */ 254*7c478bd9Sstevel@tonic-gate __P((DB_LOG *, DBT *, DB_LSN *, int, void *)); 255*7c478bd9Sstevel@tonic-gate 256*7c478bd9Sstevel@tonic-gate /* 257*7c478bd9Sstevel@tonic-gate * XA support. 258*7c478bd9Sstevel@tonic-gate * 259*7c478bd9Sstevel@tonic-gate * !!! 260*7c478bd9Sstevel@tonic-gate * Explicit representations of structures in queue.h. 261*7c478bd9Sstevel@tonic-gate * 262*7c478bd9Sstevel@tonic-gate * TAILQ_ENTRY(__db_env); 263*7c478bd9Sstevel@tonic-gate */ 264*7c478bd9Sstevel@tonic-gate struct { 265*7c478bd9Sstevel@tonic-gate struct __db_env *tqe_next; 266*7c478bd9Sstevel@tonic-gate struct __db_env **tqe_prev; 267*7c478bd9Sstevel@tonic-gate } links; 268*7c478bd9Sstevel@tonic-gate int xa_rmid; /* XA Resource Manager ID. */ 269*7c478bd9Sstevel@tonic-gate DB_TXN *xa_txn; /* XA Current transaction. */ 270*7c478bd9Sstevel@tonic-gate 271*7c478bd9Sstevel@tonic-gate #define DB_ENV_APPINIT 0x01 /* Paths initialized by db_appinit(). */ 272*7c478bd9Sstevel@tonic-gate #define DB_ENV_CDB 0x02 /* Concurrent DB product. */ 273*7c478bd9Sstevel@tonic-gate #define DB_ENV_STANDALONE 0x04 /* Test: freestanding environment. */ 274*7c478bd9Sstevel@tonic-gate #define DB_ENV_THREAD 0x08 /* DB_ENV is multi-threaded. */ 275*7c478bd9Sstevel@tonic-gate u_int32_t flags; /* Flags. */ 276*7c478bd9Sstevel@tonic-gate }; 277*7c478bd9Sstevel@tonic-gate 278*7c478bd9Sstevel@tonic-gate /******************************************************* 279*7c478bd9Sstevel@tonic-gate * Access methods. 280*7c478bd9Sstevel@tonic-gate *******************************************************/ 281*7c478bd9Sstevel@tonic-gate /* 282*7c478bd9Sstevel@tonic-gate * !!! 283*7c478bd9Sstevel@tonic-gate * Changes here must be reflected in java/src/com/sleepycat/db/Db.java. 284*7c478bd9Sstevel@tonic-gate */ 285*7c478bd9Sstevel@tonic-gate typedef enum { 286*7c478bd9Sstevel@tonic-gate DB_BTREE=1, /* B+tree. */ 287*7c478bd9Sstevel@tonic-gate DB_HASH, /* Extended Linear Hashing. */ 288*7c478bd9Sstevel@tonic-gate DB_RECNO, /* Fixed and variable-length records. */ 289*7c478bd9Sstevel@tonic-gate DB_UNKNOWN /* Figure it out on open. */ 290*7c478bd9Sstevel@tonic-gate } DBTYPE; 291*7c478bd9Sstevel@tonic-gate 292*7c478bd9Sstevel@tonic-gate #define DB_BTREEVERSION 6 /* Current btree version. */ 293*7c478bd9Sstevel@tonic-gate #define DB_BTREEOLDVER 6 /* Oldest btree version supported. */ 294*7c478bd9Sstevel@tonic-gate #define DB_BTREEMAGIC 0x053162 295*7c478bd9Sstevel@tonic-gate 296*7c478bd9Sstevel@tonic-gate #define DB_HASHVERSION 5 /* Current hash version. */ 297*7c478bd9Sstevel@tonic-gate #define DB_HASHOLDVER 4 /* Oldest hash version supported. */ 298*7c478bd9Sstevel@tonic-gate #define DB_HASHMAGIC 0x061561 299*7c478bd9Sstevel@tonic-gate 300*7c478bd9Sstevel@tonic-gate #define DB_LOGVERSION 2 /* Current log version. */ 301*7c478bd9Sstevel@tonic-gate #define DB_LOGOLDVER 2 /* Oldest log version supported. */ 302*7c478bd9Sstevel@tonic-gate #define DB_LOGMAGIC 0x040988 303*7c478bd9Sstevel@tonic-gate 304*7c478bd9Sstevel@tonic-gate struct __db_info { 305*7c478bd9Sstevel@tonic-gate int db_lorder; /* Byte order. */ 306*7c478bd9Sstevel@tonic-gate size_t db_cachesize; /* Underlying cache size. */ 307*7c478bd9Sstevel@tonic-gate size_t db_pagesize; /* Underlying page size. */ 308*7c478bd9Sstevel@tonic-gate 309*7c478bd9Sstevel@tonic-gate /* Local heap allocation. */ 310*7c478bd9Sstevel@tonic-gate void *(*db_malloc) __P((size_t)); 311*7c478bd9Sstevel@tonic-gate int (*dup_compare) /* Duplicate compare function. */ 312*7c478bd9Sstevel@tonic-gate __P((const DBT *, const DBT *)); 313*7c478bd9Sstevel@tonic-gate 314*7c478bd9Sstevel@tonic-gate /* Btree access method. */ 315*7c478bd9Sstevel@tonic-gate u_int32_t bt_maxkey; /* Maximum keys per page. */ 316*7c478bd9Sstevel@tonic-gate u_int32_t bt_minkey; /* Minimum keys per page. */ 317*7c478bd9Sstevel@tonic-gate int (*bt_compare) /* Comparison function. */ 318*7c478bd9Sstevel@tonic-gate __P((const DBT *, const DBT *)); 319*7c478bd9Sstevel@tonic-gate size_t (*bt_prefix) /* Prefix function. */ 320*7c478bd9Sstevel@tonic-gate __P((const DBT *, const DBT *)); 321*7c478bd9Sstevel@tonic-gate 322*7c478bd9Sstevel@tonic-gate /* Hash access method. */ 323*7c478bd9Sstevel@tonic-gate u_int32_t h_ffactor; /* Fill factor. */ 324*7c478bd9Sstevel@tonic-gate u_int32_t h_nelem; /* Number of elements. */ 325*7c478bd9Sstevel@tonic-gate u_int32_t (*h_hash) /* Hash function. */ 326*7c478bd9Sstevel@tonic-gate __P((const void *, u_int32_t)); 327*7c478bd9Sstevel@tonic-gate 328*7c478bd9Sstevel@tonic-gate /* Recno access method. */ 329*7c478bd9Sstevel@tonic-gate int re_pad; /* Fixed-length padding byte. */ 330*7c478bd9Sstevel@tonic-gate int re_delim; /* Variable-length delimiting byte. */ 331*7c478bd9Sstevel@tonic-gate u_int32_t re_len; /* Length for fixed-length records. */ 332*7c478bd9Sstevel@tonic-gate char *re_source; /* Source file name. */ 333*7c478bd9Sstevel@tonic-gate 334*7c478bd9Sstevel@tonic-gate #define DB_DELIMITER 0x0001 /* Recno: re_delim set. */ 335*7c478bd9Sstevel@tonic-gate #define DB_DUP 0x0002 /* Btree, Hash: duplicate keys. */ 336*7c478bd9Sstevel@tonic-gate #define DB_DUPSORT 0x0004 /* Btree, Hash: duplicate keys. */ 337*7c478bd9Sstevel@tonic-gate #define DB_FIXEDLEN 0x0008 /* Recno: fixed-length records. */ 338*7c478bd9Sstevel@tonic-gate #define DB_PAD 0x0010 /* Recno: re_pad set. */ 339*7c478bd9Sstevel@tonic-gate #define DB_RECNUM 0x0020 /* Btree: record numbers. */ 340*7c478bd9Sstevel@tonic-gate #define DB_RENUMBER 0x0040 /* Recno: renumber on insert/delete. */ 341*7c478bd9Sstevel@tonic-gate #define DB_SNAPSHOT 0x0080 /* Recno: snapshot the input. */ 342*7c478bd9Sstevel@tonic-gate u_int32_t flags; 343*7c478bd9Sstevel@tonic-gate }; 344*7c478bd9Sstevel@tonic-gate 345*7c478bd9Sstevel@tonic-gate /* 346*7c478bd9Sstevel@tonic-gate * DB access method and cursor operation values. Each value is an operation 347*7c478bd9Sstevel@tonic-gate * code to which additional bit flags are added. 348*7c478bd9Sstevel@tonic-gate */ 349*7c478bd9Sstevel@tonic-gate #define DB_AFTER 1 /* c_put() */ 350*7c478bd9Sstevel@tonic-gate #define DB_APPEND 2 /* put() */ 351*7c478bd9Sstevel@tonic-gate #define DB_BEFORE 3 /* c_put() */ 352*7c478bd9Sstevel@tonic-gate #define DB_CHECKPOINT 4 /* log_put(), log_get() */ 353*7c478bd9Sstevel@tonic-gate #define DB_CURLSN 5 /* log_put() */ 354*7c478bd9Sstevel@tonic-gate #define DB_CURRENT 6 /* c_get(), c_put(), log_get() */ 355*7c478bd9Sstevel@tonic-gate #define DB_FIRST 7 /* c_get(), log_get() */ 356*7c478bd9Sstevel@tonic-gate #define DB_FLUSH 8 /* log_put() */ 357*7c478bd9Sstevel@tonic-gate #define DB_GET_BOTH 9 /* get(), c_get() */ 358*7c478bd9Sstevel@tonic-gate #define DB_GET_RECNO 10 /* c_get() */ 359*7c478bd9Sstevel@tonic-gate #define DB_JOIN_ITEM 11 /* c_get(); do not do primary lookup */ 360*7c478bd9Sstevel@tonic-gate #define DB_KEYFIRST 12 /* c_put() */ 361*7c478bd9Sstevel@tonic-gate #define DB_KEYLAST 13 /* c_put() */ 362*7c478bd9Sstevel@tonic-gate #define DB_LAST 14 /* c_get(), log_get() */ 363*7c478bd9Sstevel@tonic-gate #define DB_NEXT 15 /* c_get(), log_get() */ 364*7c478bd9Sstevel@tonic-gate #define DB_NEXT_DUP 16 /* c_get() */ 365*7c478bd9Sstevel@tonic-gate #define DB_NOOVERWRITE 17 /* put() */ 366*7c478bd9Sstevel@tonic-gate #define DB_NOSYNC 18 /* close() */ 367*7c478bd9Sstevel@tonic-gate #define DB_PREV 19 /* c_get(), log_get() */ 368*7c478bd9Sstevel@tonic-gate #define DB_RECORDCOUNT 20 /* stat() */ 369*7c478bd9Sstevel@tonic-gate #define DB_SET 21 /* c_get(), log_get() */ 370*7c478bd9Sstevel@tonic-gate #define DB_SET_RANGE 22 /* c_get() */ 371*7c478bd9Sstevel@tonic-gate #define DB_SET_RECNO 23 /* get(), c_get() */ 372*7c478bd9Sstevel@tonic-gate #define DB_WRITELOCK 24 /* cursor() (internal) */ 373*7c478bd9Sstevel@tonic-gate 374*7c478bd9Sstevel@tonic-gate #define DB_OPFLAGS_MASK 0x1f /* Mask for operations flags. */ 375*7c478bd9Sstevel@tonic-gate #define DB_RMW 0x80000000 /* Acquire write flag immediately. */ 376*7c478bd9Sstevel@tonic-gate 377*7c478bd9Sstevel@tonic-gate /* 378*7c478bd9Sstevel@tonic-gate * DB (user visible) error return codes. 379*7c478bd9Sstevel@tonic-gate * 380*7c478bd9Sstevel@tonic-gate * !!! 381*7c478bd9Sstevel@tonic-gate * Changes to any of the user visible error return codes must be reflected 382*7c478bd9Sstevel@tonic-gate * in java/src/com/sleepycat/db/Db.java. 383*7c478bd9Sstevel@tonic-gate */ 384*7c478bd9Sstevel@tonic-gate #define DB_INCOMPLETE ( -1) /* Sync didn't finish. */ 385*7c478bd9Sstevel@tonic-gate #define DB_KEYEMPTY ( -2) /* The key/data pair was deleted or 386*7c478bd9Sstevel@tonic-gate was never created by the user. */ 387*7c478bd9Sstevel@tonic-gate #define DB_KEYEXIST ( -3) /* The key/data pair already exists. */ 388*7c478bd9Sstevel@tonic-gate #define DB_LOCK_DEADLOCK ( -4) /* Locker killed to resolve deadlock. */ 389*7c478bd9Sstevel@tonic-gate #define DB_LOCK_NOTGRANTED ( -5) /* Lock unavailable, no-wait set. */ 390*7c478bd9Sstevel@tonic-gate #define DB_LOCK_NOTHELD ( -6) /* Lock not held by locker. */ 391*7c478bd9Sstevel@tonic-gate #define DB_NOTFOUND ( -7) /* Key/data pair not found (EOF). */ 392*7c478bd9Sstevel@tonic-gate #define DB_RUNRECOVERY ( -8) /* Panic return. */ 393*7c478bd9Sstevel@tonic-gate 394*7c478bd9Sstevel@tonic-gate /* DB (private) error return codes. */ 395*7c478bd9Sstevel@tonic-gate #define DB_DELETED ( -9) /* Recovery file marked deleted. */ 396*7c478bd9Sstevel@tonic-gate #define DB_NEEDSPLIT (-10) /* Page needs to be split. */ 397*7c478bd9Sstevel@tonic-gate #define DB_SWAPBYTES (-11) /* Database needs byte swapping. */ 398*7c478bd9Sstevel@tonic-gate #define DB_TXN_CKP (-12) /* Encountered ckp record in log. */ 399*7c478bd9Sstevel@tonic-gate 400*7c478bd9Sstevel@tonic-gate #define DB_FILE_ID_LEN 20 /* DB file ID length. */ 401*7c478bd9Sstevel@tonic-gate 402*7c478bd9Sstevel@tonic-gate /* DB access method description structure. */ 403*7c478bd9Sstevel@tonic-gate struct __db { 404*7c478bd9Sstevel@tonic-gate void *mutexp; /* Synchronization for free threading */ 405*7c478bd9Sstevel@tonic-gate 406*7c478bd9Sstevel@tonic-gate /* Documented, returned information. */ 407*7c478bd9Sstevel@tonic-gate DBTYPE type; /* DB access method. */ 408*7c478bd9Sstevel@tonic-gate int byteswapped; /* Database byte order is swapped. */ 409*7c478bd9Sstevel@tonic-gate int saved_open_fd; /* For fcntl lock preservation. */ 410*7c478bd9Sstevel@tonic-gate 411*7c478bd9Sstevel@tonic-gate DB_ENV *dbenv; /* DB_ENV structure. */ 412*7c478bd9Sstevel@tonic-gate DB_ENV *mp_dbenv; /* DB_ENV for local mpool creation. */ 413*7c478bd9Sstevel@tonic-gate 414*7c478bd9Sstevel@tonic-gate void *internal; /* Access method private. */ 415*7c478bd9Sstevel@tonic-gate 416*7c478bd9Sstevel@tonic-gate DB_MPOOL *mp; /* The access method's mpool. */ 417*7c478bd9Sstevel@tonic-gate DB_MPOOLFILE *mpf; /* The access method's mpool file. */ 418*7c478bd9Sstevel@tonic-gate 419*7c478bd9Sstevel@tonic-gate /* 420*7c478bd9Sstevel@tonic-gate * !!! 421*7c478bd9Sstevel@tonic-gate * Explicit representations of structures in queue.h. 422*7c478bd9Sstevel@tonic-gate * 423*7c478bd9Sstevel@tonic-gate * TAILQ_HEAD(free_queue, __dbc); 424*7c478bd9Sstevel@tonic-gate * TAILQ_HEAD(active_queue, __dbc); 425*7c478bd9Sstevel@tonic-gate */ 426*7c478bd9Sstevel@tonic-gate struct { 427*7c478bd9Sstevel@tonic-gate struct __dbc *tqh_first; 428*7c478bd9Sstevel@tonic-gate struct __dbc **tqh_last; 429*7c478bd9Sstevel@tonic-gate } free_queue; 430*7c478bd9Sstevel@tonic-gate struct { 431*7c478bd9Sstevel@tonic-gate struct __dbc *tqh_first; 432*7c478bd9Sstevel@tonic-gate struct __dbc **tqh_last; 433*7c478bd9Sstevel@tonic-gate } active_queue; 434*7c478bd9Sstevel@tonic-gate 435*7c478bd9Sstevel@tonic-gate u_int8_t fileid[DB_FILE_ID_LEN]; /* Uniquely identify this file for 436*7c478bd9Sstevel@tonic-gate locking. */ 437*7c478bd9Sstevel@tonic-gate u_int32_t log_fileid; /* Logging file id. */ 438*7c478bd9Sstevel@tonic-gate size_t pgsize; /* Logical page size of file. */ 439*7c478bd9Sstevel@tonic-gate 440*7c478bd9Sstevel@tonic-gate /* Local heap allocation. */ 441*7c478bd9Sstevel@tonic-gate void *(*db_malloc) __P((size_t)); 442*7c478bd9Sstevel@tonic-gate int (*dup_compare) /* Duplicate compare function. */ 443*7c478bd9Sstevel@tonic-gate __P((const DBT *, const DBT *)); 444*7c478bd9Sstevel@tonic-gate u_int32_t (*h_hash) /* Hash function. */ 445*7c478bd9Sstevel@tonic-gate __P((const void *, u_int32_t)); 446*7c478bd9Sstevel@tonic-gate 447*7c478bd9Sstevel@tonic-gate /* Functions. */ 448*7c478bd9Sstevel@tonic-gate int (*am_close) __P((DB *)); 449*7c478bd9Sstevel@tonic-gate int (*close) __P((DB *, u_int32_t)); 450*7c478bd9Sstevel@tonic-gate int (*cursor) __P((DB *, DB_TXN *, DBC **, u_int32_t)); 451*7c478bd9Sstevel@tonic-gate int (*del) __P((DB *, DB_TXN *, DBT *, u_int32_t)); 452*7c478bd9Sstevel@tonic-gate int (*fd) __P((DB *, int *)); 453*7c478bd9Sstevel@tonic-gate int (*get) __P((DB *, DB_TXN *, DBT *, DBT *, u_int32_t)); 454*7c478bd9Sstevel@tonic-gate int (*join) __P((DB *, DBC **, u_int32_t, DBC **)); 455*7c478bd9Sstevel@tonic-gate int (*put) __P((DB *, DB_TXN *, DBT *, DBT *, u_int32_t)); 456*7c478bd9Sstevel@tonic-gate int (*stat) __P((DB *, void *, void *(*)(size_t), u_int32_t)); 457*7c478bd9Sstevel@tonic-gate int (*sync) __P((DB *, u_int32_t)); 458*7c478bd9Sstevel@tonic-gate 459*7c478bd9Sstevel@tonic-gate #define DB_AM_CDB 0x000001 /* Concurrent Access Methods. */ 460*7c478bd9Sstevel@tonic-gate #define DB_AM_DUP 0x000002 /* DB_DUP (internal). */ 461*7c478bd9Sstevel@tonic-gate #define DB_AM_INMEM 0x000004 /* In-memory; no sync on close. */ 462*7c478bd9Sstevel@tonic-gate #define DB_AM_LOCKING 0x000008 /* Perform locking. */ 463*7c478bd9Sstevel@tonic-gate #define DB_AM_LOGGING 0x000010 /* Perform logging. */ 464*7c478bd9Sstevel@tonic-gate #define DB_AM_MLOCAL 0x000020 /* Database memory pool is local. */ 465*7c478bd9Sstevel@tonic-gate #define DB_AM_PGDEF 0x000040 /* Page size was defaulted. */ 466*7c478bd9Sstevel@tonic-gate #define DB_AM_RDONLY 0x000080 /* Database is readonly. */ 467*7c478bd9Sstevel@tonic-gate #define DB_AM_SWAP 0x000100 /* Pages need to be byte-swapped. */ 468*7c478bd9Sstevel@tonic-gate #define DB_AM_THREAD 0x000200 /* DB is multi-threaded. */ 469*7c478bd9Sstevel@tonic-gate #define DB_BT_RECNUM 0x000400 /* DB_RECNUM (internal). */ 470*7c478bd9Sstevel@tonic-gate #define DB_DBM_ERROR 0x000800 /* Error in DBM/NDBM database. */ 471*7c478bd9Sstevel@tonic-gate #define DB_RE_DELIMITER 0x001000 /* DB_DELIMITER (internal). */ 472*7c478bd9Sstevel@tonic-gate #define DB_RE_FIXEDLEN 0x002000 /* DB_FIXEDLEN (internal). */ 473*7c478bd9Sstevel@tonic-gate #define DB_RE_PAD 0x004000 /* DB_PAD (internal). */ 474*7c478bd9Sstevel@tonic-gate #define DB_RE_RENUMBER 0x008000 /* DB_RENUMBER (internal). */ 475*7c478bd9Sstevel@tonic-gate #define DB_RE_SNAPSHOT 0x010000 /* DB_SNAPSHOT (internal). */ 476*7c478bd9Sstevel@tonic-gate u_int32_t flags; 477*7c478bd9Sstevel@tonic-gate }; 478*7c478bd9Sstevel@tonic-gate 479*7c478bd9Sstevel@tonic-gate struct __db_ilock { /* Internal DB access method lock. */ 480*7c478bd9Sstevel@tonic-gate db_pgno_t pgno; /* Page being locked. */ 481*7c478bd9Sstevel@tonic-gate u_int8_t fileid[DB_FILE_ID_LEN];/* File id. */ 482*7c478bd9Sstevel@tonic-gate }; 483*7c478bd9Sstevel@tonic-gate 484*7c478bd9Sstevel@tonic-gate /* Cursor description structure. */ 485*7c478bd9Sstevel@tonic-gate struct __dbc { 486*7c478bd9Sstevel@tonic-gate DB *dbp; /* Related DB access method. */ 487*7c478bd9Sstevel@tonic-gate DB_TXN *txn; /* Associated transaction. */ 488*7c478bd9Sstevel@tonic-gate 489*7c478bd9Sstevel@tonic-gate /* 490*7c478bd9Sstevel@tonic-gate * !!! 491*7c478bd9Sstevel@tonic-gate * Explicit representations of structures in queue.h. 492*7c478bd9Sstevel@tonic-gate * 493*7c478bd9Sstevel@tonic-gate * TAILQ_ENTRY(__dbc); 494*7c478bd9Sstevel@tonic-gate */ 495*7c478bd9Sstevel@tonic-gate struct { 496*7c478bd9Sstevel@tonic-gate struct __dbc *tqe_next; 497*7c478bd9Sstevel@tonic-gate struct __dbc **tqe_prev; 498*7c478bd9Sstevel@tonic-gate } links; 499*7c478bd9Sstevel@tonic-gate 500*7c478bd9Sstevel@tonic-gate u_int32_t lid; /* Default process' locker id. */ 501*7c478bd9Sstevel@tonic-gate u_int32_t locker; /* Locker for this operation. */ 502*7c478bd9Sstevel@tonic-gate DBT lock_dbt; /* DBT referencing lock. */ 503*7c478bd9Sstevel@tonic-gate DB_LOCK_ILOCK lock; /* Object to be locked. */ 504*7c478bd9Sstevel@tonic-gate DB_LOCK mylock; /* Lock held on this cursor. */ 505*7c478bd9Sstevel@tonic-gate 506*7c478bd9Sstevel@tonic-gate DBT rkey; /* Returned key. */ 507*7c478bd9Sstevel@tonic-gate DBT rdata; /* Returned data. */ 508*7c478bd9Sstevel@tonic-gate 509*7c478bd9Sstevel@tonic-gate int (*c_am_close) __P((DBC *)); 510*7c478bd9Sstevel@tonic-gate int (*c_am_destroy) __P((DBC *)); 511*7c478bd9Sstevel@tonic-gate int (*c_close) __P((DBC *)); 512*7c478bd9Sstevel@tonic-gate int (*c_del) __P((DBC *, u_int32_t)); 513*7c478bd9Sstevel@tonic-gate int (*c_get) __P((DBC *, DBT *, DBT *, u_int32_t)); 514*7c478bd9Sstevel@tonic-gate int (*c_put) __P((DBC *, DBT *, DBT *, u_int32_t)); 515*7c478bd9Sstevel@tonic-gate 516*7c478bd9Sstevel@tonic-gate void *internal; /* Access method private. */ 517*7c478bd9Sstevel@tonic-gate 518*7c478bd9Sstevel@tonic-gate #define DBC_CONTINUE 0x001 /* Continue dup search: next item. */ 519*7c478bd9Sstevel@tonic-gate #define DBC_KEYSET 0x002 /* Continue dup search: current item. */ 520*7c478bd9Sstevel@tonic-gate #define DBC_RECOVER 0x004 /* In recovery (do not log or lock). */ 521*7c478bd9Sstevel@tonic-gate #define DBC_RMW 0x008 /* Acquire write flag in read op. */ 522*7c478bd9Sstevel@tonic-gate #define DBC_WRITER 0x010 /* Cursor immediately writing (CDB). */ 523*7c478bd9Sstevel@tonic-gate u_int32_t flags; 524*7c478bd9Sstevel@tonic-gate }; 525*7c478bd9Sstevel@tonic-gate 526*7c478bd9Sstevel@tonic-gate /* Btree/recno statistics structure. */ 527*7c478bd9Sstevel@tonic-gate struct __db_bt_stat { 528*7c478bd9Sstevel@tonic-gate u_int32_t bt_flags; /* Open flags. */ 529*7c478bd9Sstevel@tonic-gate u_int32_t bt_maxkey; /* Maxkey value. */ 530*7c478bd9Sstevel@tonic-gate u_int32_t bt_minkey; /* Minkey value. */ 531*7c478bd9Sstevel@tonic-gate u_int32_t bt_re_len; /* Fixed-length record length. */ 532*7c478bd9Sstevel@tonic-gate u_int32_t bt_re_pad; /* Fixed-length record pad. */ 533*7c478bd9Sstevel@tonic-gate u_int32_t bt_pagesize; /* Page size. */ 534*7c478bd9Sstevel@tonic-gate u_int32_t bt_levels; /* Tree levels. */ 535*7c478bd9Sstevel@tonic-gate u_int32_t bt_nrecs; /* Number of records. */ 536*7c478bd9Sstevel@tonic-gate u_int32_t bt_int_pg; /* Internal pages. */ 537*7c478bd9Sstevel@tonic-gate u_int32_t bt_leaf_pg; /* Leaf pages. */ 538*7c478bd9Sstevel@tonic-gate u_int32_t bt_dup_pg; /* Duplicate pages. */ 539*7c478bd9Sstevel@tonic-gate u_int32_t bt_over_pg; /* Overflow pages. */ 540*7c478bd9Sstevel@tonic-gate u_int32_t bt_free; /* Pages on the free list. */ 541*7c478bd9Sstevel@tonic-gate u_int32_t bt_int_pgfree; /* Bytes free in internal pages. */ 542*7c478bd9Sstevel@tonic-gate u_int32_t bt_leaf_pgfree; /* Bytes free in leaf pages. */ 543*7c478bd9Sstevel@tonic-gate u_int32_t bt_dup_pgfree; /* Bytes free in duplicate pages. */ 544*7c478bd9Sstevel@tonic-gate u_int32_t bt_over_pgfree; /* Bytes free in overflow pages. */ 545*7c478bd9Sstevel@tonic-gate u_int32_t bt_magic; /* Magic number. */ 546*7c478bd9Sstevel@tonic-gate u_int32_t bt_version; /* Version number. */ 547*7c478bd9Sstevel@tonic-gate }; 548*7c478bd9Sstevel@tonic-gate 549*7c478bd9Sstevel@tonic-gate /* Hash statistics structure. */ 550*7c478bd9Sstevel@tonic-gate struct __db_h_stat { 551*7c478bd9Sstevel@tonic-gate u_int32_t hash_accesses; /* Number of accesses to this table. */ 552*7c478bd9Sstevel@tonic-gate u_int32_t hash_collisions; /* Number of collisions on search. */ 553*7c478bd9Sstevel@tonic-gate u_int32_t hash_expansions; /* Number of times we added a bucket. */ 554*7c478bd9Sstevel@tonic-gate u_int32_t hash_overflows; /* Number of overflow pages. */ 555*7c478bd9Sstevel@tonic-gate u_int32_t hash_bigpages; /* Number of big key/data pages. */ 556*7c478bd9Sstevel@tonic-gate u_int32_t hash_dup; /* Number of dup pages. */ 557*7c478bd9Sstevel@tonic-gate u_int32_t hash_free; /* Pages on the free list. */ 558*7c478bd9Sstevel@tonic-gate u_int32_t hash_bfree; /* Bytes free on bucket pages. */ 559*7c478bd9Sstevel@tonic-gate u_int32_t hash_dup_free; /* Bytes free on duplicate pages. */ 560*7c478bd9Sstevel@tonic-gate u_int32_t hash_big_bfree; /* Bytes free on big item pages. */ 561*7c478bd9Sstevel@tonic-gate u_int32_t hash_buckets; /* Number of hash buckets. */ 562*7c478bd9Sstevel@tonic-gate u_int32_t hash_put; /* Number of puts. */ 563*7c478bd9Sstevel@tonic-gate u_int32_t hash_deleted; /* Number of deletes. */ 564*7c478bd9Sstevel@tonic-gate u_int32_t hash_get; /* Number of gets. */ 565*7c478bd9Sstevel@tonic-gate u_int32_t hash_magic; /* Magic number. */ 566*7c478bd9Sstevel@tonic-gate u_int32_t hash_version; /* Version number. */ 567*7c478bd9Sstevel@tonic-gate u_int32_t hash_pagesize; /* Page size. */ 568*7c478bd9Sstevel@tonic-gate u_int32_t hash_nrecs; /* Number of records. */ 569*7c478bd9Sstevel@tonic-gate }; 570*7c478bd9Sstevel@tonic-gate 571*7c478bd9Sstevel@tonic-gate #if defined(__cplusplus) 572*7c478bd9Sstevel@tonic-gate extern "C" { 573*7c478bd9Sstevel@tonic-gate #endif 574*7c478bd9Sstevel@tonic-gate int db_appinit __P((const char *, char * const *, DB_ENV *, u_int32_t)); 575*7c478bd9Sstevel@tonic-gate int db_appexit __P((DB_ENV *)); 576*7c478bd9Sstevel@tonic-gate int db_jump_set __P((void *, int)); 577*7c478bd9Sstevel@tonic-gate int db_open __P((const char *, 578*7c478bd9Sstevel@tonic-gate DBTYPE, u_int32_t, int, DB_ENV *, DB_INFO *, DB **)); 579*7c478bd9Sstevel@tonic-gate int db_value_set __P((int, int)); 580*7c478bd9Sstevel@tonic-gate char *db_version __P((int *, int *, int *)); 581*7c478bd9Sstevel@tonic-gate int db_xa_open __P((const char *, 582*7c478bd9Sstevel@tonic-gate DBTYPE, u_int32_t, int, DB_INFO *, DB **)); 583*7c478bd9Sstevel@tonic-gate #if defined(__cplusplus) 584*7c478bd9Sstevel@tonic-gate } 585*7c478bd9Sstevel@tonic-gate #endif 586*7c478bd9Sstevel@tonic-gate 587*7c478bd9Sstevel@tonic-gate /******************************************************* 588*7c478bd9Sstevel@tonic-gate * Locking 589*7c478bd9Sstevel@tonic-gate *******************************************************/ 590*7c478bd9Sstevel@tonic-gate #define DB_LOCKVERSION 1 591*7c478bd9Sstevel@tonic-gate #define DB_LOCKMAGIC 0x090193 592*7c478bd9Sstevel@tonic-gate 593*7c478bd9Sstevel@tonic-gate /* Flag values for lock_vec(), lock_get(). */ 594*7c478bd9Sstevel@tonic-gate #define DB_LOCK_NOWAIT 0x01 /* Don't wait on unavailable lock. */ 595*7c478bd9Sstevel@tonic-gate #define DB_LOCK_UPGRADE 0x02 /* Upgrade an existing lock instead 596*7c478bd9Sstevel@tonic-gate of granting a new one (internal). */ 597*7c478bd9Sstevel@tonic-gate 598*7c478bd9Sstevel@tonic-gate /* Flag values for lock_detect(). */ 599*7c478bd9Sstevel@tonic-gate #define DB_LOCK_CONFLICT 0x01 /* Run on any conflict. */ 600*7c478bd9Sstevel@tonic-gate 601*7c478bd9Sstevel@tonic-gate /* 602*7c478bd9Sstevel@tonic-gate * Request types. 603*7c478bd9Sstevel@tonic-gate * 604*7c478bd9Sstevel@tonic-gate * !!! 605*7c478bd9Sstevel@tonic-gate * Changes here must be reflected in java/src/com/sleepycat/db/Db.java. 606*7c478bd9Sstevel@tonic-gate */ 607*7c478bd9Sstevel@tonic-gate typedef enum { 608*7c478bd9Sstevel@tonic-gate DB_LOCK_DUMP=0, /* Display held locks. */ 609*7c478bd9Sstevel@tonic-gate DB_LOCK_GET, /* Get the lock. */ 610*7c478bd9Sstevel@tonic-gate DB_LOCK_INHERIT, /* Pass locks to parent. */ 611*7c478bd9Sstevel@tonic-gate DB_LOCK_PUT, /* Release the lock. */ 612*7c478bd9Sstevel@tonic-gate DB_LOCK_PUT_ALL, /* Release locker's locks. */ 613*7c478bd9Sstevel@tonic-gate DB_LOCK_PUT_OBJ /* Release locker's locks on obj. */ 614*7c478bd9Sstevel@tonic-gate } db_lockop_t; 615*7c478bd9Sstevel@tonic-gate 616*7c478bd9Sstevel@tonic-gate /* 617*7c478bd9Sstevel@tonic-gate * Simple R/W lock modes and for multi-granularity intention locking. 618*7c478bd9Sstevel@tonic-gate * 619*7c478bd9Sstevel@tonic-gate * !!! 620*7c478bd9Sstevel@tonic-gate * These values are NOT random, as they are used as an index into the lock 621*7c478bd9Sstevel@tonic-gate * conflicts arrays, i.e., DB_LOCK_IWRITE must be == 3, and DB_LOCK_IREAD 622*7c478bd9Sstevel@tonic-gate * must be == 4. 623*7c478bd9Sstevel@tonic-gate * 624*7c478bd9Sstevel@tonic-gate * !!! 625*7c478bd9Sstevel@tonic-gate * Changes here must be reflected in java/src/com/sleepycat/db/Db.java. 626*7c478bd9Sstevel@tonic-gate */ 627*7c478bd9Sstevel@tonic-gate typedef enum { 628*7c478bd9Sstevel@tonic-gate DB_LOCK_NG=0, /* Not granted. */ 629*7c478bd9Sstevel@tonic-gate DB_LOCK_READ, /* Shared/read. */ 630*7c478bd9Sstevel@tonic-gate DB_LOCK_WRITE, /* Exclusive/write. */ 631*7c478bd9Sstevel@tonic-gate DB_LOCK_IWRITE, /* Intent exclusive/write. */ 632*7c478bd9Sstevel@tonic-gate DB_LOCK_IREAD, /* Intent to share/read. */ 633*7c478bd9Sstevel@tonic-gate DB_LOCK_IWR /* Intent to read and write. */ 634*7c478bd9Sstevel@tonic-gate } db_lockmode_t; 635*7c478bd9Sstevel@tonic-gate 636*7c478bd9Sstevel@tonic-gate /* 637*7c478bd9Sstevel@tonic-gate * Status of a lock. 638*7c478bd9Sstevel@tonic-gate */ 639*7c478bd9Sstevel@tonic-gate typedef enum { 640*7c478bd9Sstevel@tonic-gate DB_LSTAT_ABORTED, /* Lock belongs to an aborted txn. */ 641*7c478bd9Sstevel@tonic-gate DB_LSTAT_ERR, /* Lock is bad. */ 642*7c478bd9Sstevel@tonic-gate DB_LSTAT_FREE, /* Lock is unallocated. */ 643*7c478bd9Sstevel@tonic-gate DB_LSTAT_HELD, /* Lock is currently held. */ 644*7c478bd9Sstevel@tonic-gate DB_LSTAT_NOGRANT, /* Lock was not granted. */ 645*7c478bd9Sstevel@tonic-gate DB_LSTAT_PENDING, /* Lock was waiting and has been 646*7c478bd9Sstevel@tonic-gate * promoted; waiting for the owner 647*7c478bd9Sstevel@tonic-gate * to run and upgrade it to held. */ 648*7c478bd9Sstevel@tonic-gate DB_LSTAT_WAITING /* Lock is on the wait queue. */ 649*7c478bd9Sstevel@tonic-gate } db_status_t; 650*7c478bd9Sstevel@tonic-gate 651*7c478bd9Sstevel@tonic-gate /* Lock request structure. */ 652*7c478bd9Sstevel@tonic-gate struct __db_lockreq { 653*7c478bd9Sstevel@tonic-gate db_lockop_t op; /* Operation. */ 654*7c478bd9Sstevel@tonic-gate db_lockmode_t mode; /* Requested mode. */ 655*7c478bd9Sstevel@tonic-gate u_int32_t locker; /* Locker identity. */ 656*7c478bd9Sstevel@tonic-gate DBT *obj; /* Object being locked. */ 657*7c478bd9Sstevel@tonic-gate DB_LOCK lock; /* Lock returned. */ 658*7c478bd9Sstevel@tonic-gate }; 659*7c478bd9Sstevel@tonic-gate 660*7c478bd9Sstevel@tonic-gate /* 661*7c478bd9Sstevel@tonic-gate * Commonly used conflict matrices. 662*7c478bd9Sstevel@tonic-gate * 663*7c478bd9Sstevel@tonic-gate * Standard Read/Write (or exclusive/shared) locks. 664*7c478bd9Sstevel@tonic-gate */ 665*7c478bd9Sstevel@tonic-gate #define DB_LOCK_RW_N 3 666*7c478bd9Sstevel@tonic-gate extern const u_int8_t db_rw_conflicts[]; 667*7c478bd9Sstevel@tonic-gate 668*7c478bd9Sstevel@tonic-gate /* Multi-granularity locking. */ 669*7c478bd9Sstevel@tonic-gate #define DB_LOCK_RIW_N 6 670*7c478bd9Sstevel@tonic-gate extern const u_int8_t db_riw_conflicts[]; 671*7c478bd9Sstevel@tonic-gate 672*7c478bd9Sstevel@tonic-gate struct __db_lock_stat { 673*7c478bd9Sstevel@tonic-gate u_int32_t st_magic; /* Lock file magic number. */ 674*7c478bd9Sstevel@tonic-gate u_int32_t st_version; /* Lock file version number. */ 675*7c478bd9Sstevel@tonic-gate u_int32_t st_maxlocks; /* Maximum number of locks in table. */ 676*7c478bd9Sstevel@tonic-gate u_int32_t st_nmodes; /* Number of lock modes. */ 677*7c478bd9Sstevel@tonic-gate u_int32_t st_numobjs; /* Number of objects. */ 678*7c478bd9Sstevel@tonic-gate u_int32_t st_nlockers; /* Number of lockers. */ 679*7c478bd9Sstevel@tonic-gate u_int32_t st_nconflicts; /* Number of lock conflicts. */ 680*7c478bd9Sstevel@tonic-gate u_int32_t st_nrequests; /* Number of lock gets. */ 681*7c478bd9Sstevel@tonic-gate u_int32_t st_nreleases; /* Number of lock puts. */ 682*7c478bd9Sstevel@tonic-gate u_int32_t st_ndeadlocks; /* Number of lock deadlocks. */ 683*7c478bd9Sstevel@tonic-gate u_int32_t st_region_wait; /* Region lock granted after wait. */ 684*7c478bd9Sstevel@tonic-gate u_int32_t st_region_nowait; /* Region lock granted without wait. */ 685*7c478bd9Sstevel@tonic-gate u_int32_t st_refcnt; /* Region reference count. */ 686*7c478bd9Sstevel@tonic-gate u_int32_t st_regsize; /* Region size. */ 687*7c478bd9Sstevel@tonic-gate }; 688*7c478bd9Sstevel@tonic-gate 689*7c478bd9Sstevel@tonic-gate #if defined(__cplusplus) 690*7c478bd9Sstevel@tonic-gate extern "C" { 691*7c478bd9Sstevel@tonic-gate #endif 692*7c478bd9Sstevel@tonic-gate int lock_close __P((DB_LOCKTAB *)); 693*7c478bd9Sstevel@tonic-gate int lock_detect __P((DB_LOCKTAB *, u_int32_t, u_int32_t)); 694*7c478bd9Sstevel@tonic-gate int lock_get __P((DB_LOCKTAB *, 695*7c478bd9Sstevel@tonic-gate u_int32_t, u_int32_t, const DBT *, db_lockmode_t, DB_LOCK *)); 696*7c478bd9Sstevel@tonic-gate int lock_id __P((DB_LOCKTAB *, u_int32_t *)); 697*7c478bd9Sstevel@tonic-gate int lock_open __P((const char *, 698*7c478bd9Sstevel@tonic-gate u_int32_t, int, DB_ENV *, DB_LOCKTAB **)); 699*7c478bd9Sstevel@tonic-gate int lock_put __P((DB_LOCKTAB *, DB_LOCK)); 700*7c478bd9Sstevel@tonic-gate int lock_tget __P((DB_LOCKTAB *, 701*7c478bd9Sstevel@tonic-gate DB_TXN *, u_int32_t, const DBT *, db_lockmode_t, DB_LOCK *)); 702*7c478bd9Sstevel@tonic-gate int lock_stat __P((DB_LOCKTAB *, DB_LOCK_STAT **, void *(*)(size_t))); 703*7c478bd9Sstevel@tonic-gate int lock_unlink __P((const char *, int, DB_ENV *)); 704*7c478bd9Sstevel@tonic-gate int lock_vec __P((DB_LOCKTAB *, 705*7c478bd9Sstevel@tonic-gate u_int32_t, u_int32_t, DB_LOCKREQ *, int, DB_LOCKREQ **)); 706*7c478bd9Sstevel@tonic-gate int lock_tvec __P((DB_LOCKTAB *, 707*7c478bd9Sstevel@tonic-gate DB_TXN *, u_int32_t, DB_LOCKREQ *, int, DB_LOCKREQ **)); 708*7c478bd9Sstevel@tonic-gate #if defined(__cplusplus) 709*7c478bd9Sstevel@tonic-gate } 710*7c478bd9Sstevel@tonic-gate #endif 711*7c478bd9Sstevel@tonic-gate 712*7c478bd9Sstevel@tonic-gate /******************************************************* 713*7c478bd9Sstevel@tonic-gate * Logging. 714*7c478bd9Sstevel@tonic-gate *******************************************************/ 715*7c478bd9Sstevel@tonic-gate /* Flag values for log_archive(). */ 716*7c478bd9Sstevel@tonic-gate #define DB_ARCH_ABS 0x001 /* Absolute pathnames. */ 717*7c478bd9Sstevel@tonic-gate #define DB_ARCH_DATA 0x002 /* Data files. */ 718*7c478bd9Sstevel@tonic-gate #define DB_ARCH_LOG 0x004 /* Log files. */ 719*7c478bd9Sstevel@tonic-gate 720*7c478bd9Sstevel@tonic-gate /* 721*7c478bd9Sstevel@tonic-gate * A DB_LSN has two parts, a fileid which identifies a specific file, and an 722*7c478bd9Sstevel@tonic-gate * offset within that file. The fileid is an unsigned 4-byte quantity that 723*7c478bd9Sstevel@tonic-gate * uniquely identifies a file within the log directory -- currently a simple 724*7c478bd9Sstevel@tonic-gate * counter inside the log. The offset is also an unsigned 4-byte value. The 725*7c478bd9Sstevel@tonic-gate * log manager guarantees the offset is never more than 4 bytes by switching 726*7c478bd9Sstevel@tonic-gate * to a new log file before the maximum length imposed by an unsigned 4-byte 727*7c478bd9Sstevel@tonic-gate * offset is reached. 728*7c478bd9Sstevel@tonic-gate */ 729*7c478bd9Sstevel@tonic-gate struct __db_lsn { 730*7c478bd9Sstevel@tonic-gate u_int32_t file; /* File ID. */ 731*7c478bd9Sstevel@tonic-gate u_int32_t offset; /* File offset. */ 732*7c478bd9Sstevel@tonic-gate }; 733*7c478bd9Sstevel@tonic-gate 734*7c478bd9Sstevel@tonic-gate /* Log statistics structure. */ 735*7c478bd9Sstevel@tonic-gate struct __db_log_stat { 736*7c478bd9Sstevel@tonic-gate u_int32_t st_magic; /* Log file magic number. */ 737*7c478bd9Sstevel@tonic-gate u_int32_t st_version; /* Log file version number. */ 738*7c478bd9Sstevel@tonic-gate int st_mode; /* Log file mode. */ 739*7c478bd9Sstevel@tonic-gate u_int32_t st_lg_max; /* Maximum log file size. */ 740*7c478bd9Sstevel@tonic-gate u_int32_t st_w_bytes; /* Bytes to log. */ 741*7c478bd9Sstevel@tonic-gate u_int32_t st_w_mbytes; /* Megabytes to log. */ 742*7c478bd9Sstevel@tonic-gate u_int32_t st_wc_bytes; /* Bytes to log since checkpoint. */ 743*7c478bd9Sstevel@tonic-gate u_int32_t st_wc_mbytes; /* Megabytes to log since checkpoint. */ 744*7c478bd9Sstevel@tonic-gate u_int32_t st_wcount; /* Total syncs to the log. */ 745*7c478bd9Sstevel@tonic-gate u_int32_t st_scount; /* Total writes to the log. */ 746*7c478bd9Sstevel@tonic-gate u_int32_t st_region_wait; /* Region lock granted after wait. */ 747*7c478bd9Sstevel@tonic-gate u_int32_t st_region_nowait; /* Region lock granted without wait. */ 748*7c478bd9Sstevel@tonic-gate u_int32_t st_cur_file; /* Current log file number. */ 749*7c478bd9Sstevel@tonic-gate u_int32_t st_cur_offset; /* Current log file offset. */ 750*7c478bd9Sstevel@tonic-gate u_int32_t st_refcnt; /* Region reference count. */ 751*7c478bd9Sstevel@tonic-gate u_int32_t st_regsize; /* Region size. */ 752*7c478bd9Sstevel@tonic-gate }; 753*7c478bd9Sstevel@tonic-gate 754*7c478bd9Sstevel@tonic-gate #if defined(__cplusplus) 755*7c478bd9Sstevel@tonic-gate extern "C" { 756*7c478bd9Sstevel@tonic-gate #endif 757*7c478bd9Sstevel@tonic-gate int log_archive __P((DB_LOG *, char **[], u_int32_t, void *(*)(size_t))); 758*7c478bd9Sstevel@tonic-gate int log_close __P((DB_LOG *)); 759*7c478bd9Sstevel@tonic-gate int log_compare __P((const DB_LSN *, const DB_LSN *)); 760*7c478bd9Sstevel@tonic-gate int log_file __P((DB_LOG *, const DB_LSN *, char *, size_t)); 761*7c478bd9Sstevel@tonic-gate int log_flush __P((DB_LOG *, const DB_LSN *)); 762*7c478bd9Sstevel@tonic-gate int log_get __P((DB_LOG *, DB_LSN *, DBT *, u_int32_t)); 763*7c478bd9Sstevel@tonic-gate int log_open __P((const char *, u_int32_t, int, DB_ENV *, DB_LOG **)); 764*7c478bd9Sstevel@tonic-gate int log_put __P((DB_LOG *, DB_LSN *, const DBT *, u_int32_t)); 765*7c478bd9Sstevel@tonic-gate int log_register __P((DB_LOG *, DB *, const char *, DBTYPE, u_int32_t *)); 766*7c478bd9Sstevel@tonic-gate int log_stat __P((DB_LOG *, DB_LOG_STAT **, void *(*)(size_t))); 767*7c478bd9Sstevel@tonic-gate int log_unlink __P((const char *, int, DB_ENV *)); 768*7c478bd9Sstevel@tonic-gate int log_unregister __P((DB_LOG *, u_int32_t)); 769*7c478bd9Sstevel@tonic-gate #if defined(__cplusplus) 770*7c478bd9Sstevel@tonic-gate } 771*7c478bd9Sstevel@tonic-gate #endif 772*7c478bd9Sstevel@tonic-gate 773*7c478bd9Sstevel@tonic-gate /******************************************************* 774*7c478bd9Sstevel@tonic-gate * Mpool 775*7c478bd9Sstevel@tonic-gate *******************************************************/ 776*7c478bd9Sstevel@tonic-gate /* Flag values for memp_fget(). */ 777*7c478bd9Sstevel@tonic-gate #define DB_MPOOL_CREATE 0x001 /* Create a page. */ 778*7c478bd9Sstevel@tonic-gate #define DB_MPOOL_LAST 0x002 /* Return the last page. */ 779*7c478bd9Sstevel@tonic-gate #define DB_MPOOL_NEW 0x004 /* Create a new page. */ 780*7c478bd9Sstevel@tonic-gate 781*7c478bd9Sstevel@tonic-gate /* Flag values for memp_fput(), memp_fset(). */ 782*7c478bd9Sstevel@tonic-gate #define DB_MPOOL_CLEAN 0x001 /* Clear modified bit. */ 783*7c478bd9Sstevel@tonic-gate #define DB_MPOOL_DIRTY 0x002 /* Page is modified. */ 784*7c478bd9Sstevel@tonic-gate #define DB_MPOOL_DISCARD 0x004 /* Don't cache the page. */ 785*7c478bd9Sstevel@tonic-gate 786*7c478bd9Sstevel@tonic-gate /* Mpool statistics structure. */ 787*7c478bd9Sstevel@tonic-gate struct __db_mpool_stat { 788*7c478bd9Sstevel@tonic-gate size_t st_cachesize; /* Cache size. */ 789*7c478bd9Sstevel@tonic-gate u_int32_t st_cache_hit; /* Pages found in the cache. */ 790*7c478bd9Sstevel@tonic-gate u_int32_t st_cache_miss; /* Pages not found in the cache. */ 791*7c478bd9Sstevel@tonic-gate u_int32_t st_map; /* Pages from mapped files. */ 792*7c478bd9Sstevel@tonic-gate u_int32_t st_page_create; /* Pages created in the cache. */ 793*7c478bd9Sstevel@tonic-gate u_int32_t st_page_in; /* Pages read in. */ 794*7c478bd9Sstevel@tonic-gate u_int32_t st_page_out; /* Pages written out. */ 795*7c478bd9Sstevel@tonic-gate u_int32_t st_ro_evict; /* Clean pages forced from the cache. */ 796*7c478bd9Sstevel@tonic-gate u_int32_t st_rw_evict; /* Dirty pages forced from the cache. */ 797*7c478bd9Sstevel@tonic-gate u_int32_t st_hash_buckets; /* Number of hash buckets. */ 798*7c478bd9Sstevel@tonic-gate u_int32_t st_hash_searches; /* Total hash chain searches. */ 799*7c478bd9Sstevel@tonic-gate u_int32_t st_hash_longest; /* Longest hash chain searched. */ 800*7c478bd9Sstevel@tonic-gate u_int32_t st_hash_examined; /* Total hash entries searched. */ 801*7c478bd9Sstevel@tonic-gate u_int32_t st_page_clean; /* Clean pages. */ 802*7c478bd9Sstevel@tonic-gate u_int32_t st_page_dirty; /* Dirty pages. */ 803*7c478bd9Sstevel@tonic-gate u_int32_t st_page_trickle; /* Pages written by memp_trickle. */ 804*7c478bd9Sstevel@tonic-gate u_int32_t st_region_wait; /* Region lock granted after wait. */ 805*7c478bd9Sstevel@tonic-gate u_int32_t st_region_nowait; /* Region lock granted without wait. */ 806*7c478bd9Sstevel@tonic-gate u_int32_t st_refcnt; /* Region reference count. */ 807*7c478bd9Sstevel@tonic-gate u_int32_t st_regsize; /* Region size. */ 808*7c478bd9Sstevel@tonic-gate }; 809*7c478bd9Sstevel@tonic-gate 810*7c478bd9Sstevel@tonic-gate /* Mpool file open information structure. */ 811*7c478bd9Sstevel@tonic-gate struct __db_mpool_finfo { 812*7c478bd9Sstevel@tonic-gate int ftype; /* File type. */ 813*7c478bd9Sstevel@tonic-gate DBT *pgcookie; /* Byte-string passed to pgin/pgout. */ 814*7c478bd9Sstevel@tonic-gate u_int8_t *fileid; /* Unique file ID. */ 815*7c478bd9Sstevel@tonic-gate int32_t lsn_offset; /* LSN offset in page. */ 816*7c478bd9Sstevel@tonic-gate u_int32_t clear_len; /* Cleared length on created pages. */ 817*7c478bd9Sstevel@tonic-gate }; 818*7c478bd9Sstevel@tonic-gate 819*7c478bd9Sstevel@tonic-gate /* Mpool file statistics structure. */ 820*7c478bd9Sstevel@tonic-gate struct __db_mpool_fstat { 821*7c478bd9Sstevel@tonic-gate char *file_name; /* File name. */ 822*7c478bd9Sstevel@tonic-gate size_t st_pagesize; /* Page size. */ 823*7c478bd9Sstevel@tonic-gate u_int32_t st_cache_hit; /* Pages found in the cache. */ 824*7c478bd9Sstevel@tonic-gate u_int32_t st_cache_miss; /* Pages not found in the cache. */ 825*7c478bd9Sstevel@tonic-gate u_int32_t st_map; /* Pages from mapped files. */ 826*7c478bd9Sstevel@tonic-gate u_int32_t st_page_create; /* Pages created in the cache. */ 827*7c478bd9Sstevel@tonic-gate u_int32_t st_page_in; /* Pages read in. */ 828*7c478bd9Sstevel@tonic-gate u_int32_t st_page_out; /* Pages written out. */ 829*7c478bd9Sstevel@tonic-gate }; 830*7c478bd9Sstevel@tonic-gate 831*7c478bd9Sstevel@tonic-gate #if defined(__cplusplus) 832*7c478bd9Sstevel@tonic-gate extern "C" { 833*7c478bd9Sstevel@tonic-gate #endif 834*7c478bd9Sstevel@tonic-gate int memp_close __P((DB_MPOOL *)); 835*7c478bd9Sstevel@tonic-gate int memp_fclose __P((DB_MPOOLFILE *)); 836*7c478bd9Sstevel@tonic-gate int memp_fget __P((DB_MPOOLFILE *, db_pgno_t *, u_int32_t, void *)); 837*7c478bd9Sstevel@tonic-gate int memp_fopen __P((DB_MPOOL *, const char *, 838*7c478bd9Sstevel@tonic-gate u_int32_t, int, size_t, DB_MPOOL_FINFO *, DB_MPOOLFILE **)); 839*7c478bd9Sstevel@tonic-gate int memp_fput __P((DB_MPOOLFILE *, void *, u_int32_t)); 840*7c478bd9Sstevel@tonic-gate int memp_fset __P((DB_MPOOLFILE *, void *, u_int32_t)); 841*7c478bd9Sstevel@tonic-gate int memp_fsync __P((DB_MPOOLFILE *)); 842*7c478bd9Sstevel@tonic-gate int memp_open __P((const char *, u_int32_t, int, DB_ENV *, DB_MPOOL **)); 843*7c478bd9Sstevel@tonic-gate int memp_register __P((DB_MPOOL *, int, 844*7c478bd9Sstevel@tonic-gate int (*)(db_pgno_t, void *, DBT *), 845*7c478bd9Sstevel@tonic-gate int (*)(db_pgno_t, void *, DBT *))); 846*7c478bd9Sstevel@tonic-gate int memp_stat __P((DB_MPOOL *, 847*7c478bd9Sstevel@tonic-gate DB_MPOOL_STAT **, DB_MPOOL_FSTAT ***, void *(*)(size_t))); 848*7c478bd9Sstevel@tonic-gate int memp_sync __P((DB_MPOOL *, DB_LSN *)); 849*7c478bd9Sstevel@tonic-gate int memp_trickle __P((DB_MPOOL *, int, int *)); 850*7c478bd9Sstevel@tonic-gate int memp_unlink __P((const char *, int, DB_ENV *)); 851*7c478bd9Sstevel@tonic-gate #if defined(__cplusplus) 852*7c478bd9Sstevel@tonic-gate } 853*7c478bd9Sstevel@tonic-gate #endif 854*7c478bd9Sstevel@tonic-gate 855*7c478bd9Sstevel@tonic-gate /******************************************************* 856*7c478bd9Sstevel@tonic-gate * Transactions. 857*7c478bd9Sstevel@tonic-gate *******************************************************/ 858*7c478bd9Sstevel@tonic-gate #define DB_TXNVERSION 1 859*7c478bd9Sstevel@tonic-gate #define DB_TXNMAGIC 0x041593 860*7c478bd9Sstevel@tonic-gate 861*7c478bd9Sstevel@tonic-gate /* Operations values to the tx_recover() function. */ 862*7c478bd9Sstevel@tonic-gate #define DB_TXN_BACKWARD_ROLL 1 /* Read the log backwards. */ 863*7c478bd9Sstevel@tonic-gate #define DB_TXN_FORWARD_ROLL 2 /* Read the log forwards. */ 864*7c478bd9Sstevel@tonic-gate #define DB_TXN_OPENFILES 3 /* Read for open files. */ 865*7c478bd9Sstevel@tonic-gate #define DB_TXN_REDO 4 /* Redo the operation. */ 866*7c478bd9Sstevel@tonic-gate #define DB_TXN_UNDO 5 /* Undo the operation. */ 867*7c478bd9Sstevel@tonic-gate 868*7c478bd9Sstevel@tonic-gate /* Internal transaction status values. */ 869*7c478bd9Sstevel@tonic-gate 870*7c478bd9Sstevel@tonic-gate /* Transaction statistics structure. */ 871*7c478bd9Sstevel@tonic-gate struct __db_txn_active { 872*7c478bd9Sstevel@tonic-gate u_int32_t txnid; /* Transaction ID */ 873*7c478bd9Sstevel@tonic-gate DB_LSN lsn; /* Lsn of the begin record */ 874*7c478bd9Sstevel@tonic-gate }; 875*7c478bd9Sstevel@tonic-gate 876*7c478bd9Sstevel@tonic-gate struct __db_txn_stat { 877*7c478bd9Sstevel@tonic-gate DB_LSN st_last_ckp; /* lsn of the last checkpoint */ 878*7c478bd9Sstevel@tonic-gate DB_LSN st_pending_ckp; /* last checkpoint did not finish */ 879*7c478bd9Sstevel@tonic-gate time_t st_time_ckp; /* time of last checkpoint */ 880*7c478bd9Sstevel@tonic-gate u_int32_t st_last_txnid; /* last transaction id given out */ 881*7c478bd9Sstevel@tonic-gate u_int32_t st_maxtxns; /* maximum number of active txns */ 882*7c478bd9Sstevel@tonic-gate u_int32_t st_naborts; /* number of aborted transactions */ 883*7c478bd9Sstevel@tonic-gate u_int32_t st_nbegins; /* number of begun transactions */ 884*7c478bd9Sstevel@tonic-gate u_int32_t st_ncommits; /* number of committed transactions */ 885*7c478bd9Sstevel@tonic-gate u_int32_t st_nactive; /* number of active transactions */ 886*7c478bd9Sstevel@tonic-gate DB_TXN_ACTIVE 887*7c478bd9Sstevel@tonic-gate *st_txnarray; /* array of active transactions */ 888*7c478bd9Sstevel@tonic-gate u_int32_t st_region_wait; /* Region lock granted after wait. */ 889*7c478bd9Sstevel@tonic-gate u_int32_t st_region_nowait; /* Region lock granted without wait. */ 890*7c478bd9Sstevel@tonic-gate u_int32_t st_refcnt; /* Region reference count. */ 891*7c478bd9Sstevel@tonic-gate u_int32_t st_regsize; /* Region size. */ 892*7c478bd9Sstevel@tonic-gate }; 893*7c478bd9Sstevel@tonic-gate 894*7c478bd9Sstevel@tonic-gate #if defined(__cplusplus) 895*7c478bd9Sstevel@tonic-gate extern "C" { 896*7c478bd9Sstevel@tonic-gate #endif 897*7c478bd9Sstevel@tonic-gate int txn_abort __P((DB_TXN *)); 898*7c478bd9Sstevel@tonic-gate int txn_begin __P((DB_TXNMGR *, DB_TXN *, DB_TXN **)); 899*7c478bd9Sstevel@tonic-gate int txn_checkpoint __P((const DB_TXNMGR *, u_int32_t, u_int32_t)); 900*7c478bd9Sstevel@tonic-gate int txn_commit __P((DB_TXN *)); 901*7c478bd9Sstevel@tonic-gate int txn_close __P((DB_TXNMGR *)); 902*7c478bd9Sstevel@tonic-gate u_int32_t txn_id __P((DB_TXN *)); 903*7c478bd9Sstevel@tonic-gate int txn_open __P((const char *, u_int32_t, int, DB_ENV *, DB_TXNMGR **)); 904*7c478bd9Sstevel@tonic-gate int txn_prepare __P((DB_TXN *)); 905*7c478bd9Sstevel@tonic-gate int txn_stat __P((DB_TXNMGR *, DB_TXN_STAT **, void *(*)(size_t))); 906*7c478bd9Sstevel@tonic-gate int txn_unlink __P((const char *, int, DB_ENV *)); 907*7c478bd9Sstevel@tonic-gate #if defined(__cplusplus) 908*7c478bd9Sstevel@tonic-gate } 909*7c478bd9Sstevel@tonic-gate #endif 910*7c478bd9Sstevel@tonic-gate 911*7c478bd9Sstevel@tonic-gate #ifndef DB_DBM_HSEARCH 912*7c478bd9Sstevel@tonic-gate #define DB_DBM_HSEARCH 0 /* No historic interfaces by default. */ 913*7c478bd9Sstevel@tonic-gate #endif 914*7c478bd9Sstevel@tonic-gate #if DB_DBM_HSEARCH != 0 915*7c478bd9Sstevel@tonic-gate /******************************************************* 916*7c478bd9Sstevel@tonic-gate * Dbm/Ndbm historic interfaces. 917*7c478bd9Sstevel@tonic-gate *******************************************************/ 918*7c478bd9Sstevel@tonic-gate #define DBM_INSERT 0 /* Flags to dbm_store(). */ 919*7c478bd9Sstevel@tonic-gate #define DBM_REPLACE 1 920*7c478bd9Sstevel@tonic-gate 921*7c478bd9Sstevel@tonic-gate /* 922*7c478bd9Sstevel@tonic-gate * The db(3) support for ndbm(3) always appends this suffix to the 923*7c478bd9Sstevel@tonic-gate * file name to avoid overwriting the user's original database. 924*7c478bd9Sstevel@tonic-gate */ 925*7c478bd9Sstevel@tonic-gate #define DBM_SUFFIX ".db" 926*7c478bd9Sstevel@tonic-gate 927*7c478bd9Sstevel@tonic-gate #if defined(_XPG4_2) 928*7c478bd9Sstevel@tonic-gate typedef struct { 929*7c478bd9Sstevel@tonic-gate char *dptr; 930*7c478bd9Sstevel@tonic-gate size_t dsize; 931*7c478bd9Sstevel@tonic-gate } datum; 932*7c478bd9Sstevel@tonic-gate #else 933*7c478bd9Sstevel@tonic-gate typedef struct { 934*7c478bd9Sstevel@tonic-gate char *dptr; 935*7c478bd9Sstevel@tonic-gate int dsize; 936*7c478bd9Sstevel@tonic-gate } datum; 937*7c478bd9Sstevel@tonic-gate #endif 938*7c478bd9Sstevel@tonic-gate 939*7c478bd9Sstevel@tonic-gate /* 940*7c478bd9Sstevel@tonic-gate * Translate DBM calls into DB calls so that DB doesn't step on the 941*7c478bd9Sstevel@tonic-gate * application's name space. 942*7c478bd9Sstevel@tonic-gate * 943*7c478bd9Sstevel@tonic-gate * The global variables dbrdonly, dirf and pagf were not retained when 944*7c478bd9Sstevel@tonic-gate * 4BSD replaced the dbm interface with ndbm, and are not support here. 945*7c478bd9Sstevel@tonic-gate */ 946*7c478bd9Sstevel@tonic-gate #define dbminit(a) __db_dbm_init(a) 947*7c478bd9Sstevel@tonic-gate #define dbmclose __db_dbm_close 948*7c478bd9Sstevel@tonic-gate #if !defined(__cplusplus) 949*7c478bd9Sstevel@tonic-gate #define delete(a) __db_dbm_delete(a) 950*7c478bd9Sstevel@tonic-gate #endif 951*7c478bd9Sstevel@tonic-gate #define fetch(a) __db_dbm_fetch(a) 952*7c478bd9Sstevel@tonic-gate #define firstkey __db_dbm_firstkey 953*7c478bd9Sstevel@tonic-gate #define nextkey(a) __db_dbm_nextkey(a) 954*7c478bd9Sstevel@tonic-gate #define store(a, b) __db_dbm_store(a, b) 955*7c478bd9Sstevel@tonic-gate 956*7c478bd9Sstevel@tonic-gate /* Prototype the DB calls. */ 957*7c478bd9Sstevel@tonic-gate #if defined(__cplusplus) 958*7c478bd9Sstevel@tonic-gate extern "C" { 959*7c478bd9Sstevel@tonic-gate #endif 960*7c478bd9Sstevel@tonic-gate int __db_dbm_close __P((void)); 961*7c478bd9Sstevel@tonic-gate int __db_dbm_dbrdonly __P((void)); 962*7c478bd9Sstevel@tonic-gate int __db_dbm_delete __P((datum)); 963*7c478bd9Sstevel@tonic-gate int __db_dbm_dirf __P((void)); 964*7c478bd9Sstevel@tonic-gate datum __db_dbm_fetch __P((datum)); 965*7c478bd9Sstevel@tonic-gate datum __db_dbm_firstkey __P((void)); 966*7c478bd9Sstevel@tonic-gate int __db_dbm_init __P((char *)); 967*7c478bd9Sstevel@tonic-gate datum __db_dbm_nextkey __P((datum)); 968*7c478bd9Sstevel@tonic-gate int __db_dbm_pagf __P((void)); 969*7c478bd9Sstevel@tonic-gate int __db_dbm_store __P((datum, datum)); 970*7c478bd9Sstevel@tonic-gate #if defined(__cplusplus) 971*7c478bd9Sstevel@tonic-gate } 972*7c478bd9Sstevel@tonic-gate #endif 973*7c478bd9Sstevel@tonic-gate 974*7c478bd9Sstevel@tonic-gate /* 975*7c478bd9Sstevel@tonic-gate * Translate NDBM calls into DB calls so that DB doesn't step on the 976*7c478bd9Sstevel@tonic-gate * application's name space. 977*7c478bd9Sstevel@tonic-gate */ 978*7c478bd9Sstevel@tonic-gate #define dbm_clearerr(a) __db_ndbm_clearerr(a) 979*7c478bd9Sstevel@tonic-gate #define dbm_close(a) __db_ndbm_close(a) 980*7c478bd9Sstevel@tonic-gate #define dbm_delete(a, b) __db_ndbm_delete(a, b) 981*7c478bd9Sstevel@tonic-gate #define dbm_dirfno(a) __db_ndbm_dirfno(a) 982*7c478bd9Sstevel@tonic-gate #define dbm_error(a) __db_ndbm_error(a) 983*7c478bd9Sstevel@tonic-gate #define dbm_fetch(a, b) __db_ndbm_fetch(a, b) 984*7c478bd9Sstevel@tonic-gate #define dbm_firstkey(a) __db_ndbm_firstkey(a) 985*7c478bd9Sstevel@tonic-gate #define dbm_nextkey(a) __db_ndbm_nextkey(a) 986*7c478bd9Sstevel@tonic-gate #define dbm_open(a, b, c) __db_ndbm_open(a, b, c) 987*7c478bd9Sstevel@tonic-gate #define dbm_pagfno(a) __db_ndbm_pagfno(a) 988*7c478bd9Sstevel@tonic-gate #define dbm_rdonly(a) __db_ndbm_rdonly(a) 989*7c478bd9Sstevel@tonic-gate #define dbm_store(a, b, c, d) __db_ndbm_store(a, b, c, d) 990*7c478bd9Sstevel@tonic-gate 991*7c478bd9Sstevel@tonic-gate /* Prototype the DB calls. */ 992*7c478bd9Sstevel@tonic-gate #if defined(__cplusplus) 993*7c478bd9Sstevel@tonic-gate extern "C" { 994*7c478bd9Sstevel@tonic-gate #endif 995*7c478bd9Sstevel@tonic-gate int __db_ndbm_clearerr __P((DBM *)); 996*7c478bd9Sstevel@tonic-gate void __db_ndbm_close __P((DBM *)); 997*7c478bd9Sstevel@tonic-gate int __db_ndbm_delete __P((DBM *, datum)); 998*7c478bd9Sstevel@tonic-gate int __db_ndbm_dirfno __P((DBM *)); 999*7c478bd9Sstevel@tonic-gate int __db_ndbm_error __P((DBM *)); 1000*7c478bd9Sstevel@tonic-gate datum __db_ndbm_fetch __P((DBM *, datum)); 1001*7c478bd9Sstevel@tonic-gate datum __db_ndbm_firstkey __P((DBM *)); 1002*7c478bd9Sstevel@tonic-gate datum __db_ndbm_nextkey __P((DBM *)); 1003*7c478bd9Sstevel@tonic-gate DBM *__db_ndbm_open __P((const char *, int, int)); 1004*7c478bd9Sstevel@tonic-gate int __db_ndbm_pagfno __P((DBM *)); 1005*7c478bd9Sstevel@tonic-gate int __db_ndbm_rdonly __P((DBM *)); 1006*7c478bd9Sstevel@tonic-gate int __db_ndbm_store __P((DBM *, datum, datum, int)); 1007*7c478bd9Sstevel@tonic-gate #if defined(__cplusplus) 1008*7c478bd9Sstevel@tonic-gate } 1009*7c478bd9Sstevel@tonic-gate #endif 1010*7c478bd9Sstevel@tonic-gate 1011*7c478bd9Sstevel@tonic-gate /******************************************************* 1012*7c478bd9Sstevel@tonic-gate * Hsearch historic interface. 1013*7c478bd9Sstevel@tonic-gate *******************************************************/ 1014*7c478bd9Sstevel@tonic-gate typedef enum { 1015*7c478bd9Sstevel@tonic-gate FIND, ENTER 1016*7c478bd9Sstevel@tonic-gate } ACTION; 1017*7c478bd9Sstevel@tonic-gate 1018*7c478bd9Sstevel@tonic-gate typedef struct entry { 1019*7c478bd9Sstevel@tonic-gate char *key; 1020*7c478bd9Sstevel@tonic-gate char *data; 1021*7c478bd9Sstevel@tonic-gate } ENTRY; 1022*7c478bd9Sstevel@tonic-gate 1023*7c478bd9Sstevel@tonic-gate /* 1024*7c478bd9Sstevel@tonic-gate * Translate HSEARCH calls into DB calls so that DB doesn't step on the 1025*7c478bd9Sstevel@tonic-gate * application's name space. 1026*7c478bd9Sstevel@tonic-gate */ 1027*7c478bd9Sstevel@tonic-gate #define hcreate(a) __db_hcreate(a) 1028*7c478bd9Sstevel@tonic-gate #define hdestroy __db_hdestroy 1029*7c478bd9Sstevel@tonic-gate #define hsearch(a, b) __db_hsearch(a, b) 1030*7c478bd9Sstevel@tonic-gate 1031*7c478bd9Sstevel@tonic-gate /* Prototype the DB calls. */ 1032*7c478bd9Sstevel@tonic-gate #if defined(__cplusplus) 1033*7c478bd9Sstevel@tonic-gate extern "C" { 1034*7c478bd9Sstevel@tonic-gate #endif 1035*7c478bd9Sstevel@tonic-gate int __db_hcreate __P((size_t)); 1036*7c478bd9Sstevel@tonic-gate void __db_hdestroy __P((void)); 1037*7c478bd9Sstevel@tonic-gate ENTRY *__db_hsearch __P((ENTRY, ACTION)); 1038*7c478bd9Sstevel@tonic-gate #if defined(__cplusplus) 1039*7c478bd9Sstevel@tonic-gate } 1040*7c478bd9Sstevel@tonic-gate #endif 1041*7c478bd9Sstevel@tonic-gate #endif /* DB_DBM_HSEARCH */ 1042*7c478bd9Sstevel@tonic-gate 1043*7c478bd9Sstevel@tonic-gate /* 1044*7c478bd9Sstevel@tonic-gate * XXX 1045*7c478bd9Sstevel@tonic-gate * MacOS: Reset Metrowerks C enum sizes. 1046*7c478bd9Sstevel@tonic-gate */ 1047*7c478bd9Sstevel@tonic-gate #ifdef __MWERKS__ 1048*7c478bd9Sstevel@tonic-gate #pragma enumsalwaysint reset 1049*7c478bd9Sstevel@tonic-gate #endif 1050*7c478bd9Sstevel@tonic-gate #endif /* !_DB_H_ */ 1051