diff options
Diffstat (limited to 'db/build_vxworks/db.h')
-rw-r--r-- | db/build_vxworks/db.h | 764 |
1 files changed, 433 insertions, 331 deletions
diff --git a/db/build_vxworks/db.h b/db/build_vxworks/db.h index 5a71d034e..b9aaad78e 100644 --- a/db/build_vxworks/db.h +++ b/db/build_vxworks/db.h @@ -2,10 +2,10 @@ /* * See the file LICENSE for redistribution information. * - * Copyright (c) 1996-2002 + * Copyright (c) 1996-2003 * Sleepycat Software. All rights reserved. * - * Id: db.in,v 11.323 2002/09/03 17:27:16 bostic Exp + * $Id: db.in,v 11.389 2003/10/01 21:33:58 sue Exp $ * * db.h include file layout: * General. @@ -25,6 +25,7 @@ #ifndef __NO_SYSTEM_INCLUDES #include <sys/types.h> +/* <sys/types.h> does not include <inttypes.h> on some systems. */ #include <stdio.h> #endif @@ -37,32 +38,17 @@ extern "C" { #define __vxworks #endif -/* - * XXX - * Handle function prototypes and the keyword "const". This steps on name - * space that DB doesn't control, but all of the other solutions are worse. - * - * XXX - * While Microsoft's compiler is ANSI C compliant, it doesn't have _STDC_ - * defined by default, you specify a command line flag or #pragma to turn - * it on. Don't do that, however, because some of Microsoft's own header - * files won't compile. - */ -#undef __P -#if defined(__STDC__) || defined(__cplusplus) || defined(_MSC_VER) -#define __P(protos) protos /* ANSI C prototypes */ -#else -#define const -#define __P(protos) () /* K&R C preprocessor */ -#endif + +#undef __P +#define __P(protos) protos /* * Berkeley DB version information. */ #define DB_VERSION_MAJOR 4 -#define DB_VERSION_MINOR 1 -#define DB_VERSION_PATCH 24 -#define DB_VERSION_STRING "Sleepycat Software: Berkeley DB 4.1.24: (September 13, 2002)" +#define DB_VERSION_MINOR 2 +#define DB_VERSION_PATCH 52 +#define DB_VERSION_STRING "Sleepycat Software: Berkeley DB 4.2.52: (December 3, 2003)" /* * !!! @@ -166,17 +152,18 @@ struct __db_dbt { * Interfaces which use any of these common flags should never have * interface specific flags in this range. */ -#define DB_CREATE 0x000001 /* Create file as necessary. */ -#define DB_CXX_NO_EXCEPTIONS 0x000002 /* C++: return error values. */ -#define DB_FORCE 0x000004 /* Force (anything). */ -#define DB_NOMMAP 0x000008 /* Don't mmap underlying file. */ -#define DB_RDONLY 0x000010 /* Read-only (O_RDONLY). */ -#define DB_RECOVER 0x000020 /* Run normal recovery. */ -#define DB_THREAD 0x000040 /* Applications are threaded. */ -#define DB_TRUNCATE 0x000080 /* Discard existing DB (O_TRUNC). */ -#define DB_TXN_NOSYNC 0x000100 /* Do not sync log on commit. */ -#define DB_USE_ENVIRON 0x000200 /* Use the environment. */ -#define DB_USE_ENVIRON_ROOT 0x000400 /* Use the environment if root. */ +#define DB_CREATE 0x0000001 /* Create file as necessary. */ +#define DB_CXX_NO_EXCEPTIONS 0x0000002 /* C++: return error values. */ +#define DB_FORCE 0x0000004 /* Force (anything). */ +#define DB_NOMMAP 0x0000008 /* Don't mmap underlying file. */ +#define DB_RDONLY 0x0000010 /* Read-only (O_RDONLY). */ +#define DB_RECOVER 0x0000020 /* Run normal recovery. */ +#define DB_THREAD 0x0000040 /* Applications are threaded. */ +#define DB_TRUNCATE 0x0000080 /* Discard existing DB (O_TRUNC). */ +#define DB_TXN_NOSYNC 0x0000100 /* Do not sync log on commit. */ +#define DB_TXN_NOT_DURABLE 0x0000200 /* Do not log changes. */ +#define DB_USE_ENVIRON 0x0000400 /* Use the environment. */ +#define DB_USE_ENVIRON_ROOT 0x0000800 /* Use the environment if root. */ /* * Common flags -- @@ -189,113 +176,125 @@ struct __db_dbt { * DB_DIRTY_READ: * DB->cursor, DB->get, DB->join, DB->open, DBcursor->c_get, * DB_ENV->txn_begin + * DB_NOAUTO_COMMIT + * DB->associate, DB->del, DB->put, DB->open, + * DB->remove, DB->rename, DB->truncate * - * Shared flags up to 0x000400 */ -#define DB_AUTO_COMMIT 0x00800000 /* Implied transaction. */ -#define DB_DIRTY_READ 0x01000000 /* Dirty Read. */ + * !!! + * The DB_DIRTY_READ bit mask can't be changed without also changing the + * masks for the flags that can be OR'd into DB access method and cursor + * operation values. + */ +#define DB_AUTO_COMMIT 0x1000000 /* Implied transaction. */ +#define DB_DIRTY_READ 0x2000000 /* Dirty Read. */ +#define DB_NO_AUTO_COMMIT 0x4000000 /* Override env-wide AUTO-COMMIT. */ /* * Flags private to db_env_create. */ -#define DB_CLIENT 0x000001 /* Open for a client environment. */ +#define DB_RPCCLIENT 0x0000001 /* An RPC client environment. */ /* * Flags private to db_create. */ -#define DB_XA_CREATE 0x000001 /* Open in an XA environment. */ +#define DB_REP_CREATE 0x0000001 /* Open of an internal rep database. */ +#define DB_XA_CREATE 0x0000002 /* Open in an XA environment. */ /* * Flags private to DB_ENV->open. - * Shared flags up to 0x000400 */ -#define DB_INIT_CDB 0x000800 /* Concurrent Access Methods. */ -#define DB_INIT_LOCK 0x001000 /* Initialize locking. */ -#define DB_INIT_LOG 0x002000 /* Initialize logging. */ -#define DB_INIT_MPOOL 0x004000 /* Initialize mpool. */ -#define DB_INIT_TXN 0x008000 /* Initialize transactions. */ -#define DB_JOINENV 0x010000 /* Initialize all subsystems present. */ -#define DB_LOCKDOWN 0x020000 /* Lock memory into physical core. */ -#define DB_PRIVATE 0x040000 /* DB_ENV is process local. */ -#define DB_RECOVER_FATAL 0x080000 /* Run catastrophic recovery. */ -#define DB_SYSTEM_MEM 0x100000 /* Use system-backed memory. */ + * Shared flags up to 0x0000800 */ +#define DB_INIT_CDB 0x0001000 /* Concurrent Access Methods. */ +#define DB_INIT_LOCK 0x0002000 /* Initialize locking. */ +#define DB_INIT_LOG 0x0004000 /* Initialize logging. */ +#define DB_INIT_MPOOL 0x0008000 /* Initialize mpool. */ +#define DB_INIT_REP 0x0010000 /* Initialize replication. */ +#define DB_INIT_TXN 0x0020000 /* Initialize transactions. */ +#define DB_JOINENV 0x0040000 /* Initialize all subsystems present. */ +#define DB_LOCKDOWN 0x0080000 /* Lock memory into physical core. */ +#define DB_PRIVATE 0x0100000 /* DB_ENV is process local. */ +#define DB_RECOVER_FATAL 0x0200000 /* Run catastrophic recovery. */ +#define DB_SYSTEM_MEM 0x0400000 /* Use system-backed memory. */ /* * Flags private to DB->open. - * Shared flags up to 0x000400 */ -#define DB_EXCL 0x000800 /* Exclusive open (O_EXCL). */ -#define DB_FCNTL_LOCKING 0x001000 /* UNDOC: fcntl(2) locking. */ -#define DB_RDWRMASTER 0x002000 /* UNDOC: allow subdb master open R/W */ -#define DB_WRITEOPEN 0x004000 /* UNDOC: open with write lock. */ + * Shared flags up to 0x0000800 */ +#define DB_EXCL 0x0001000 /* Exclusive open (O_EXCL). */ +#define DB_FCNTL_LOCKING 0x0002000 /* UNDOC: fcntl(2) locking. */ +#define DB_RDWRMASTER 0x0004000 /* UNDOC: allow subdb master open R/W */ +#define DB_WRITEOPEN 0x0008000 /* UNDOC: open with write lock. */ /* * Flags private to DB_ENV->txn_begin. - * Shared flags up to 0x000400 */ -#define DB_TXN_NOWAIT 0x000800 /* Do not wait for locks in this TXN. */ -#define DB_TXN_SYNC 0x001000 /* Always sync log on commit. */ + * Shared flags up to 0x0000800 */ +#define DB_TXN_NOWAIT 0x0001000 /* Do not wait for locks in this TXN. */ +#define DB_TXN_SYNC 0x0002000 /* Always sync log on commit. */ /* * Flags private to DB_ENV->set_encrypt. */ -#define DB_ENCRYPT_AES 0x000001 /* AES, assumes SHA1 checksum */ +#define DB_ENCRYPT_AES 0x0000001 /* AES, assumes SHA1 checksum */ /* * Flags private to DB_ENV->set_flags. - * Shared flags up to 0x000400 */ -#define DB_CDB_ALLDB 0x000800 /* Set CDB locking per environment. */ -#define DB_DIRECT_DB 0x001000 /* Don't buffer databases in the OS. */ -#define DB_DIRECT_LOG 0x002000 /* Don't buffer log files in the OS. */ -#define DB_NOLOCKING 0x004000 /* Set locking/mutex behavior. */ -#define DB_NOPANIC 0x008000 /* Set panic state per DB_ENV. */ -#define DB_OVERWRITE 0x010000 /* Overwrite unlinked region files. */ -#define DB_PANIC_ENVIRONMENT 0x020000 /* Set panic state per environment. */ -#define DB_REGION_INIT 0x040000 /* Page-fault regions on open. */ -#define DB_TXN_WRITE_NOSYNC 0x080000 /* Write, don't sync, on txn commit. */ -#define DB_YIELDCPU 0x100000 /* Yield the CPU (a lot). */ + * Shared flags up to 0x0000800 */ +#define DB_CDB_ALLDB 0x0001000 /* Set CDB locking per environment. */ +#define DB_DIRECT_DB 0x0002000 /* Don't buffer databases in the OS. */ +#define DB_DIRECT_LOG 0x0004000 /* Don't buffer log files in the OS. */ +#define DB_LOG_AUTOREMOVE 0x0008000 /* Automatically remove log files. */ +#define DB_NOLOCKING 0x0010000 /* Set locking/mutex behavior. */ +#define DB_NOPANIC 0x0020000 /* Set panic state per DB_ENV. */ +#define DB_OVERWRITE 0x0040000 /* Overwrite unlinked region files. */ +#define DB_PANIC_ENVIRONMENT 0x0080000 /* Set panic state per environment. */ +#define DB_REGION_INIT 0x0100000 /* Page-fault regions on open. */ +#define DB_TIME_NOTGRANTED 0x0200000 /* Return NOTGRANTED on timeout. */ +#define DB_TXN_WRITE_NOSYNC 0x0400000 /* Write, don't sync, on txn commit. */ +#define DB_YIELDCPU 0x0800000 /* Yield the CPU (a lot). */ /* * Flags private to DB->set_feedback's callback. */ -#define DB_UPGRADE 0x000001 /* Upgrading. */ -#define DB_VERIFY 0x000002 /* Verifying. */ +#define DB_UPGRADE 0x0000001 /* Upgrading. */ +#define DB_VERIFY 0x0000002 /* Verifying. */ /* * Flags private to DB_MPOOLFILE->open. - * Shared flags up to 0x000400 */ -#define DB_DIRECT 0x000800 /* Don't buffer the file in the OS. */ -#define DB_EXTENT 0x001000 /* UNDOC: dealing with an extent. */ -#define DB_ODDFILESIZE 0x002000 /* Truncate file to N * pgsize. */ + * Shared flags up to 0x0000800 */ +#define DB_DIRECT 0x0001000 /* Don't buffer the file in the OS. */ +#define DB_EXTENT 0x0002000 /* UNDOC: dealing with an extent. */ +#define DB_ODDFILESIZE 0x0004000 /* Truncate file to N * pgsize. */ /* * Flags private to DB->set_flags. */ -#define DB_CHKSUM_SHA1 0x000001 /* Use SHA1 checksumming */ -#define DB_DUP 0x000002 /* Btree, Hash: duplicate keys. */ -#define DB_DUPSORT 0x000004 /* Btree, Hash: duplicate keys. */ -#define DB_ENCRYPT 0x000008 /* Btree, Hash: duplicate keys. */ -#define DB_RECNUM 0x000010 /* Btree: record numbers. */ -#define DB_RENUMBER 0x000020 /* Recno: renumber on insert/delete. */ -#define DB_REVSPLITOFF 0x000040 /* Btree: turn off reverse splits. */ -#define DB_SNAPSHOT 0x000080 /* Recno: snapshot the input. */ +#define DB_CHKSUM 0x0000001 /* Do checksumming */ +#define DB_DUP 0x0000002 /* Btree, Hash: duplicate keys. */ +#define DB_DUPSORT 0x0000004 /* Btree, Hash: duplicate keys. */ +#define DB_ENCRYPT 0x0000008 /* Btree, Hash: duplicate keys. */ +#define DB_RECNUM 0x0000010 /* Btree: record numbers. */ +#define DB_RENUMBER 0x0000020 /* Recno: renumber on insert/delete. */ +#define DB_REVSPLITOFF 0x0000040 /* Btree: turn off reverse splits. */ +#define DB_SNAPSHOT 0x0000080 /* Recno: snapshot the input. */ /* * Flags private to the DB->stat methods. */ -#define DB_STAT_CLEAR 0x000001 /* Clear stat after returning values. */ +#define DB_STAT_CLEAR 0x0000001 /* Clear stat after returning values. */ /* * Flags private to DB->join. */ -#define DB_JOIN_NOSORT 0x000001 /* Don't try to optimize join. */ +#define DB_JOIN_NOSORT 0x0000001 /* Don't try to optimize join. */ /* * Flags private to DB->verify. */ -#define DB_AGGRESSIVE 0x000001 /* Salvage whatever could be data.*/ -#define DB_NOORDERCHK 0x000002 /* Skip sort order/hashing check. */ -#define DB_ORDERCHKONLY 0x000004 /* Only perform the order check. */ -#define DB_PR_PAGE 0x000008 /* Show page contents (-da). */ -#define DB_PR_RECOVERYTEST 0x000010 /* Recovery test (-dr). */ -#define DB_PRINTABLE 0x000020 /* Use printable format for salvage. */ -#define DB_SALVAGE 0x000040 /* Salvage what looks like data. */ +#define DB_AGGRESSIVE 0x0000001 /* Salvage whatever could be data.*/ +#define DB_NOORDERCHK 0x0000002 /* Skip sort order/hashing check. */ +#define DB_ORDERCHKONLY 0x0000004 /* Only perform the order check. */ +#define DB_PR_PAGE 0x0000008 /* Show page contents (-da). */ +#define DB_PR_RECOVERYTEST 0x0000010 /* Recovery test (-dr). */ +#define DB_PRINTABLE 0x0000020 /* Use printable format for salvage. */ +#define DB_SALVAGE 0x0000040 /* Salvage what looks like data. */ /* * !!! * These must not go over 0x8000, or they will collide with the flags @@ -305,7 +304,8 @@ struct __db_dbt { /* * Flags private to DB->set_rep_transport's send callback. */ -#define DB_REP_PERMANENT 0x0001 /* Important--app. may want to flush. */ +#define DB_REP_NOBUFFER 0x0000001 /* Do not buffer this message. */ +#define DB_REP_PERMANENT 0x0000002 /* Important--app. may want to flush. */ /******************************************************* * Locking. @@ -329,13 +329,12 @@ struct __db_dbt { #define DB_LOCK_YOUNGEST 8 /* Abort youngest transaction. */ /* Flag values for lock_vec(), lock_get(). */ -#define DB_LOCK_FREE_LOCKER 0x001 /* Internal: Free locker as well. */ -#define DB_LOCK_NOWAIT 0x002 /* Don't wait on unavailable lock. */ -#define DB_LOCK_RECORD 0x004 /* Internal: record lock. */ -#define DB_LOCK_REMOVE 0x008 /* Internal: flag object removed. */ -#define DB_LOCK_SET_TIMEOUT 0x010 /* Internal: set lock timeout. */ -#define DB_LOCK_SWITCH 0x020 /* Internal: switch existing lock. */ -#define DB_LOCK_UPGRADE 0x040 /* Internal: upgrade existing lock. */ +#define DB_LOCK_NOWAIT 0x001 /* Don't wait on unavailable lock. */ +#define DB_LOCK_RECORD 0x002 /* Internal: record lock. */ +#define DB_LOCK_REMOVE 0x004 /* Internal: flag object removed. */ +#define DB_LOCK_SET_TIMEOUT 0x008 /* Internal: set lock timeout. */ +#define DB_LOCK_SWITCH 0x010 /* Internal: switch existing lock. */ +#define DB_LOCK_UPGRADE 0x020 /* Internal: upgrade existing lock. */ /* * Simple R/W lock modes and for multi-granularity intention locking. @@ -430,7 +429,6 @@ struct __db_ilock { #define DB_HANDLE_LOCK 1 #define DB_RECORD_LOCK 2 #define DB_PAGE_LOCK 3 -#define DB_TXN_LOCK 4 u_int32_t type; /* Type of lock. */ }; @@ -459,14 +457,24 @@ struct __db_lockreq { /******************************************************* * Logging. *******************************************************/ -#define DB_LOGVERSION 7 /* Current log version. */ -#define DB_LOGOLDVER 7 /* Oldest log version supported. */ +#define DB_LOGVERSION 8 /* Current log version. */ +#define DB_LOGOLDVER 8 /* Oldest log version supported. */ #define DB_LOGMAGIC 0x040988 -/* Flag values for log_archive(). */ -#define DB_ARCH_ABS 0x001 /* Absolute pathnames. */ -#define DB_ARCH_DATA 0x002 /* Data files. */ -#define DB_ARCH_LOG 0x004 /* Log files. */ +/* Flag values for DB_ENV->log_archive(). */ +#define DB_ARCH_ABS 0x001 /* Absolute pathnames. */ +#define DB_ARCH_DATA 0x002 /* Data files. */ +#define DB_ARCH_LOG 0x004 /* Log files. */ +#define DB_ARCH_REMOVE 0x008 /* Remove log files. */ + +/* Flag values for DB_ENV->log_put(). */ +#define DB_FLUSH 0x001 /* Flush data to disk (public). */ +#define DB_LOG_CHKPNT 0x002 /* Flush supports a checkpoint */ +#define DB_LOG_COMMIT 0x004 /* Flush supports a commit */ +#define DB_LOG_NOCOPY 0x008 /* Don't copy data */ +#define DB_LOG_NOT_DURABLE 0x010 /* Do not log; keep in memory */ +#define DB_LOG_PERM 0x020 /* Flag record with REP_PERMANENT */ +#define DB_LOG_WRNOSYNC 0x040 /* Write, don't sync log_put */ /* * A DB_LSN has two parts, a fileid which identifies a specific file, and an @@ -483,13 +491,25 @@ struct __db_lsn { }; /* + * Application-specified log record types start at DB_user_BEGIN, and must not + * equal or exceed DB_debug_FLAG. + * + * DB_debug_FLAG is the high-bit of the u_int32_t that specifies a log record + * type. If the flag is set, it's a log record that was logged for debugging + * purposes only, even if it reflects a database change -- the change was part + * of a non-durable transaction. + */ +#define DB_user_BEGIN 10000 +#define DB_debug_FLAG 0x80000000 + +/* * DB_LOGC -- * Log cursor. */ struct __db_log_cursor { DB_ENV *dbenv; /* Enclosing dbenv. */ - DB_FH *c_fh; /* File handle. */ + DB_FH *c_fhp; /* File handle. */ DB_LSN c_lsn; /* Cursor: LSN */ u_int32_t c_len; /* Cursor: record length */ u_int32_t c_prev; /* Cursor: previous record's offset */ @@ -552,6 +572,10 @@ struct __db_log_stat { #define DB_MPOOL_DIRTY 0x002 /* Page is modified. */ #define DB_MPOOL_DISCARD 0x004 /* Don't cache the page. */ +/* Flags values for DB_MPOOLFILE->set_flags. */ +#define DB_MPOOL_NOFILE 0x001 /* Never open a backing file. */ +#define DB_MPOOL_UNLINK 0x002 /* Unlink the file on last close. */ + /* Priority values for DB_MPOOLFILE->set_priority. */ typedef enum { DB_PRIORITY_VERY_LOW=1, @@ -563,21 +587,14 @@ typedef enum { /* Per-process DB_MPOOLFILE information. */ struct __db_mpoolfile { - /* These fields need to be protected for multi-threaded support. */ - DB_MUTEX *mutexp; /* Structure thread lock. */ - DB_FH *fhp; /* Underlying file handle. */ - u_int32_t ref; /* Reference count. */ - /* * !!! - * The pinref and q fields are protected by the region lock, not the - * DB_MPOOLFILE structure mutex. We don't use the structure mutex - * because then I/O (which holds the structure lock held because of - * the race between the seek and write of the file descriptor) would - * block any other put/get calls using this DB_MPOOLFILE structure. + * The ref, pinref and q fields are protected by the region lock. */ + u_int32_t ref; /* Reference count. */ + u_int32_t pinref; /* Pinned block reference count. */ /* @@ -591,52 +608,69 @@ struct __db_mpoolfile { } q; /* Linked list of DB_MPOOLFILE's. */ /* - * These fields are not thread-protected because they are initialized - * when the file is opened and never modified. + * !!! + * The rest of the fields (with the exception of the MP_FLUSH flag) + * are not thread-protected, even when they may be modified at any + * time by the application. The reason is the DB_MPOOLFILE handle + * is single-threaded from the viewpoint of the application, and so + * the only fields needing to be thread-protected are those accessed + * by checkpoint or sync threads when using DB_MPOOLFILE structures + * to flush buffers from the cache. */ - int ftype; /* File type. */ - DBT *pgcookie; /* Byte-string passed to pgin/pgout. */ - u_int8_t *fileid; /* Unique file ID. */ - int32_t lsn_offset; /* LSN offset in page. */ - u_int32_t clear_len; /* Cleared length on created pages. */ + DB_ENV *dbenv; /* Overlying DB_ENV. */ + MPOOLFILE *mfp; /* Underlying MPOOLFILE. */ - DB_MPOOL *dbmp; /* Overlying DB_MPOOL. */ - MPOOLFILE *mfp; /* Underlying MPOOLFILE. */ + u_int32_t clear_len; /* Cleared length on created pages. */ + u_int8_t /* Unique file ID. */ + fileid[DB_FILE_ID_LEN]; + int ftype; /* File type. */ + int32_t lsn_offset; /* LSN offset in page. */ + u_int32_t gbytes, bytes; /* Maximum file size. */ + DBT *pgcookie; /* Byte-string passed to pgin/pgout. */ + DB_CACHE_PRIORITY /* Cache priority. */ + priority; - void *addr; /* Address of mmap'd region. */ - size_t len; /* Length of mmap'd region. */ + void *addr; /* Address of mmap'd region. */ + size_t len; /* Length of mmap'd region. */ + + u_int32_t config_flags; /* Flags to DB_MPOOLFILE->set_flags. */ /* Methods. */ - int (*close) __P((DB_MPOOLFILE *, u_int32_t)); - int (*get) __P((DB_MPOOLFILE *, db_pgno_t *, u_int32_t, void *)); - void (*get_fileid) __P((DB_MPOOLFILE *, u_int8_t *)); - void (*last_pgno) __P((DB_MPOOLFILE *, db_pgno_t *)); - int (*open)__P((DB_MPOOLFILE *, const char *, u_int32_t, int, size_t)); - int (*put) __P((DB_MPOOLFILE *, void *, u_int32_t)); - void (*refcnt) __P((DB_MPOOLFILE *, db_pgno_t *)); - int (*set) __P((DB_MPOOLFILE *, void *, u_int32_t)); - int (*set_clear_len) __P((DB_MPOOLFILE *, u_int32_t)); - int (*set_fileid) __P((DB_MPOOLFILE *, u_int8_t *)); - int (*set_ftype) __P((DB_MPOOLFILE *, int)); - int (*set_lsn_offset) __P((DB_MPOOLFILE *, int32_t)); - int (*set_pgcookie) __P((DB_MPOOLFILE *, DBT *)); - int (*set_priority) __P((DB_MPOOLFILE *, DB_CACHE_PRIORITY)); - void (*set_unlink) __P((DB_MPOOLFILE *, int)); - int (*sync) __P((DB_MPOOLFILE *)); + int (*close) __P((DB_MPOOLFILE *, u_int32_t)); + int (*get) __P((DB_MPOOLFILE *, db_pgno_t *, u_int32_t, void *)); + int (*open)__P((DB_MPOOLFILE *, const char *, u_int32_t, int, size_t)); + int (*put) __P((DB_MPOOLFILE *, void *, u_int32_t)); + int (*set) __P((DB_MPOOLFILE *, void *, u_int32_t)); + int (*get_clear_len) __P((DB_MPOOLFILE *, u_int32_t *)); + int (*set_clear_len) __P((DB_MPOOLFILE *, u_int32_t)); + int (*get_fileid) __P((DB_MPOOLFILE *, u_int8_t *)); + int (*set_fileid) __P((DB_MPOOLFILE *, u_int8_t *)); + int (*get_flags) __P((DB_MPOOLFILE *, u_int32_t *)); + int (*set_flags) __P((DB_MPOOLFILE *, u_int32_t, int)); + int (*get_ftype) __P((DB_MPOOLFILE *, int *)); + int (*set_ftype) __P((DB_MPOOLFILE *, int)); + int (*get_lsn_offset) __P((DB_MPOOLFILE *, int32_t *)); + int (*set_lsn_offset) __P((DB_MPOOLFILE *, int32_t)); + int (*get_maxsize) __P((DB_MPOOLFILE *, u_int32_t *, u_int32_t *)); + int (*set_maxsize) __P((DB_MPOOLFILE *, u_int32_t, u_int32_t)); + int (*get_pgcookie) __P((DB_MPOOLFILE *, DBT *)); + int (*set_pgcookie) __P((DB_MPOOLFILE *, DBT *)); + int (*get_priority) __P((DB_MPOOLFILE *, DB_CACHE_PRIORITY *)); + int (*set_priority) __P((DB_MPOOLFILE *, DB_CACHE_PRIORITY)); + int (*sync) __P((DB_MPOOLFILE *)); /* - * MP_OPEN_CALLED and MP_READONLY do not need to be thread protected - * because they are initialized when the file is opened, and never - * modified. + * MP_FILEID_SET, MP_OPEN_CALLED and MP_READONLY do not need to be + * thread protected because they are initialized before the file is + * linked onto the per-process lists, and never modified. * - * MP_FLUSH, MP_UPGRADE and MP_UPGRADE_FAIL are thread protected - * becase they are potentially read by multiple threads of control. + * MP_FLUSH is thread protected becase it is potentially read/set by + * multiple threads of control. */ -#define MP_FLUSH 0x001 /* Was opened to flush a buffer. */ -#define MP_OPEN_CALLED 0x002 /* File opened. */ -#define MP_READONLY 0x004 /* File is readonly. */ -#define MP_UPGRADE 0x008 /* File descriptor is readwrite. */ -#define MP_UPGRADE_FAIL 0x010 /* Upgrade wasn't possible. */ +#define MP_FILEID_SET 0x001 /* Application supplied a file ID. */ +#define MP_FLUSH 0x002 /* Was opened to flush a buffer. */ +#define MP_OPEN_CALLED 0x004 /* File opened. */ +#define MP_READONLY 0x008 /* File is readonly. */ u_int32_t flags; }; @@ -720,6 +754,7 @@ struct __db_txn { DB_TXN *parent; /* Pointer to transaction's parent. */ DB_LSN last_lsn; /* Lsn of last log write. */ u_int32_t txnid; /* Unique transaction id. */ + u_int32_t tid; /* Thread id for use in MT XA. */ roff_t off; /* Detail structure within region. */ db_timeout_t lock_timeout; /* Timeout for locks for this txn. */ db_timeout_t expire; /* Time this txn expires. */ @@ -729,11 +764,16 @@ struct __db_txn { * !!! * Explicit representations of structures from queue.h. * TAILQ_ENTRY(__db_txn) links; + * TAILQ_ENTRY(__db_txn) xalinks; */ struct { struct __db_txn *tqe_next; struct __db_txn **tqe_prev; } links; /* Links transactions off manager. */ + struct { + struct __db_txn *tqe_next; + struct __db_txn **tqe_prev; + } xalinks; /* Links active XA transactions. */ /* * !!! @@ -748,6 +788,16 @@ struct __db_txn { /* * !!! * Explicit representations of structures from queue.h. + * STAILQ_HEAD(__logrec, __txn_logrec) logs; + */ + struct { + struct __txn_logrec *stqh_first; + struct __txn_logrec **stqh_last; + } logs; /* Links deferred events. */ + + /* + * !!! + * Explicit representations of structures from queue.h. * TAILQ_HEAD(__kids, __db_txn) kids; */ struct __kids { @@ -778,22 +828,39 @@ struct __db_txn { int (*prepare) __P((DB_TXN *, u_int8_t *)); int (*set_timeout) __P((DB_TXN *, db_timeout_t, u_int32_t)); -#define TXN_CHILDCOMMIT 0x01 /* Transaction that has committed. */ -#define TXN_COMPENSATE 0x02 /* Compensating transaction. */ -#define TXN_DIRTY_READ 0x04 /* Transaction does dirty reads. */ -#define TXN_LOCKTIMEOUT 0x08 /* Transaction has a lock timeout. */ -#define TXN_MALLOC 0x10 /* Structure allocated by TXN system. */ -#define TXN_NOSYNC 0x20 /* Do not sync on prepare and commit. */ -#define TXN_NOWAIT 0x40 /* Do not wait on locks. */ -#define TXN_SYNC 0x80 /* Sync on prepare and commit. */ +#define TXN_CHILDCOMMIT 0x001 /* Transaction that has committed. */ +#define TXN_COMPENSATE 0x002 /* Compensating transaction. */ +#define TXN_DIRTY_READ 0x004 /* Transaction does dirty reads. */ +#define TXN_LOCKTIMEOUT 0x008 /* Transaction has a lock timeout. */ +#define TXN_MALLOC 0x010 /* Structure allocated by TXN system. */ +#define TXN_NOSYNC 0x020 /* Do not sync on prepare and commit. */ +#define TXN_NOWAIT 0x040 /* Do not wait on locks. */ +#define TXN_RESTORED 0x080 /* Transaction has been restored. */ +#define TXN_SYNC 0x100 /* Sync on prepare and commit. */ u_int32_t flags; }; +/* + * Structure used for two phase commit interface. Berkeley DB support for two + * phase commit is compatible with the X/open XA interface. + * + * The XA #define XIDDATASIZE defines the size of a global transaction ID. We + * have our own version here (for name space reasons) which must have the same + * value. + */ +#define DB_XIDDATASIZE 128 +struct __db_preplist { + DB_TXN *txn; + u_int8_t gid[DB_XIDDATASIZE]; +}; + /* Transaction statistics structure. */ struct __db_txn_active { - u_int32_t txnid; /* Transaction ID */ - u_int32_t parentid; /* Transaction ID of parent */ - DB_LSN lsn; /* LSN when transaction began */ + u_int32_t txnid; /* Transaction ID */ + u_int32_t parentid; /* Transaction ID of parent */ + DB_LSN lsn; /* LSN when transaction began */ + u_int32_t xa_status; /* XA status */ + u_int8_t xid[DB_XIDDATASIZE]; /* XA global transaction ID */ }; struct __db_txn_stat { @@ -814,18 +881,6 @@ struct __db_txn_stat { u_int32_t st_regsize; /* Region size. */ }; -/* - * Structure used for two phase commit interface. Berkeley DB support for two - * phase commit is compatible with the X/open XA interface. The xa #define - * XIDDATASIZE defines the size of a global transaction ID. We have our own - * version here which must have the same value. - */ -#define DB_XIDDATASIZE 128 -struct __db_preplist { - DB_TXN *txn; - u_int8_t gid[DB_XIDDATASIZE]; -}; - /******************************************************* * Replication. *******************************************************/ @@ -858,6 +913,7 @@ struct __db_rep_stat { int st_env_id; /* Current environment ID. */ int st_env_priority; /* Current environment priority. */ u_int32_t st_gen; /* Current generation number. */ + u_int32_t st_in_recovery; /* This site is in client sync-up. */ u_int32_t st_log_duplicated; /* Log records received multiply.+ */ u_int32_t st_log_queued; /* Log records currently queued.+ */ u_int32_t st_log_queued_max; /* Max. log records queued at once.+ */ @@ -928,51 +984,50 @@ typedef enum { #define DB_APPEND 2 /* put() */ #define DB_BEFORE 3 /* c_put() */ #define DB_CACHED_COUNTS 4 /* stat() */ -#define DB_COMMIT 5 /* log_put() (internal) */ -#define DB_CONSUME 6 /* get() */ -#define DB_CONSUME_WAIT 7 /* get() */ -#define DB_CURRENT 8 /* c_get(), c_put(), DB_LOGC->get() */ -#define DB_FAST_STAT 9 /* stat() */ -#define DB_FIRST 10 /* c_get(), DB_LOGC->get() */ -#define DB_GET_BOTH 11 /* get(), c_get() */ -#define DB_GET_BOTHC 12 /* c_get() (internal) */ -#define DB_GET_BOTH_RANGE 13 /* get(), c_get() */ -#define DB_GET_RECNO 14 /* c_get() */ -#define DB_JOIN_ITEM 15 /* c_get(); do not do primary lookup */ -#define DB_KEYFIRST 16 /* c_put() */ -#define DB_KEYLAST 17 /* c_put() */ -#define DB_LAST 18 /* c_get(), DB_LOGC->get() */ -#define DB_NEXT 19 /* c_get(), DB_LOGC->get() */ -#define DB_NEXT_DUP 20 /* c_get() */ -#define DB_NEXT_NODUP 21 /* c_get() */ -#define DB_NODUPDATA 22 /* put(), c_put() */ -#define DB_NOOVERWRITE 23 /* put() */ -#define DB_NOSYNC 24 /* close() */ -#define DB_POSITION 25 /* c_dup() */ -#define DB_POSITIONI 26 /* c_dup() (internal) */ -#define DB_PREV 27 /* c_get(), DB_LOGC->get() */ -#define DB_PREV_NODUP 28 /* c_get(), DB_LOGC->get() */ -#define DB_RECORDCOUNT 29 /* stat() */ -#define DB_SET 30 /* c_get(), DB_LOGC->get() */ -#define DB_SET_LOCK_TIMEOUT 31 /* set_timout() */ -#define DB_SET_RANGE 32 /* c_get() */ -#define DB_SET_RECNO 33 /* get(), c_get() */ -#define DB_SET_TXN_NOW 34 /* set_timout() (internal) */ -#define DB_SET_TXN_TIMEOUT 35 /* set_timout() */ -#define DB_UPDATE_SECONDARY 36 /* c_get(), c_del() (internal) */ -#define DB_WRITECURSOR 37 /* cursor() */ -#define DB_WRITELOCK 38 /* cursor() (internal) */ +#define DB_CONSUME 5 /* get() */ +#define DB_CONSUME_WAIT 6 /* get() */ +#define DB_CURRENT 7 /* c_get(), c_put(), DB_LOGC->get() */ +#define DB_FAST_STAT 8 /* stat() */ +#define DB_FIRST 9 /* c_get(), DB_LOGC->get() */ +#define DB_GET_BOTH 10 /* get(), c_get() */ +#define DB_GET_BOTHC 11 /* c_get() (internal) */ +#define DB_GET_BOTH_RANGE 12 /* get(), c_get() */ +#define DB_GET_RECNO 13 /* c_get() */ +#define DB_JOIN_ITEM 14 /* c_get(); do not do primary lookup */ +#define DB_KEYFIRST 15 /* c_put() */ +#define DB_KEYLAST 16 /* c_put() */ +#define DB_LAST 17 /* c_get(), DB_LOGC->get() */ +#define DB_NEXT 18 /* c_get(), DB_LOGC->get() */ +#define DB_NEXT_DUP 19 /* c_get() */ +#define DB_NEXT_NODUP 20 /* c_get() */ +#define DB_NODUPDATA 21 /* put(), c_put() */ +#define DB_NOOVERWRITE 22 /* put() */ +#define DB_NOSYNC 23 /* close() */ +#define DB_POSITION 24 /* c_dup() */ +#define DB_PREV 25 /* c_get(), DB_LOGC->get() */ +#define DB_PREV_NODUP 26 /* c_get(), DB_LOGC->get() */ +#define DB_RECORDCOUNT 27 /* stat() */ +#define DB_SET 28 /* c_get(), DB_LOGC->get() */ +#define DB_SET_LOCK_TIMEOUT 29 /* set_timout() */ +#define DB_SET_RANGE 30 /* c_get() */ +#define DB_SET_RECNO 31 /* get(), c_get() */ +#define DB_SET_TXN_NOW 32 /* set_timout() (internal) */ +#define DB_SET_TXN_TIMEOUT 33 /* set_timout() */ +#define DB_UPDATE_SECONDARY 34 /* c_get(), c_del() (internal) */ +#define DB_WRITECURSOR 35 /* cursor() */ +#define DB_WRITELOCK 36 /* cursor() (internal) */ /* This has to change when the max opcode hits 255. */ #define DB_OPFLAGS_MASK 0x000000ff /* Mask for operations flags. */ -/* DB_DIRTY_READ 0x01000000 Dirty Read. */ -#define DB_FLUSH 0x02000000 /* Flush data to disk. */ + +/* + * Masks for flags that can be OR'd into DB access method and cursor + * operation values. + * + * DB_DIRTY_READ 0x02000000 Dirty Read. */ #define DB_MULTIPLE 0x04000000 /* Return multiple data values. */ #define DB_MULTIPLE_KEY 0x08000000 /* Return multiple data/key pairs. */ -#define DB_NOCOPY 0x10000000 /* Don't copy data */ -#define DB_PERMANENT 0x20000000 /* Flag record with REP_PERMANENT. */ -#define DB_RMW 0x40000000 /* Acquire write flag immediately. */ -#define DB_WRNOSYNC 0x80000000 /* Private: write, don't sync log_put */ +#define DB_RMW 0x10000000 /* Acquire write flag immediately. */ /* * DB (user visible) error return codes. @@ -990,38 +1045,41 @@ typedef enum { */ /* DB (public) error return codes. */ #define DB_DONOTINDEX (-30999)/* "Null" return from 2ndary callbk. */ -#define DB_KEYEMPTY (-30998)/* Key/data deleted or never created. */ -#define DB_KEYEXIST (-30997)/* The key/data pair already exists. */ -#define DB_LOCK_DEADLOCK (-30996)/* Deadlock. */ -#define DB_LOCK_NOTGRANTED (-30995)/* Lock unavailable. */ -#define DB_NOSERVER (-30994)/* Server panic return. */ -#define DB_NOSERVER_HOME (-30993)/* Bad home sent to server. */ -#define DB_NOSERVER_ID (-30992)/* Bad ID sent to server. */ -#define DB_NOTFOUND (-30991)/* Key/data pair not found (EOF). */ -#define DB_OLD_VERSION (-30990)/* Out-of-date version. */ -#define DB_PAGE_NOTFOUND (-30989)/* Requested page not found. */ -#define DB_REP_DUPMASTER (-30988)/* There are two masters. */ -#define DB_REP_HOLDELECTION (-30987)/* Time to hold an election. */ -#define DB_REP_NEWMASTER (-30986)/* We have learned of a new master. */ -#define DB_REP_NEWSITE (-30985)/* New site entered system. */ -#define DB_REP_OUTDATED (-30984)/* Site is too far behind master. */ -#define DB_REP_UNAVAIL (-30983)/* Site cannot currently be reached. */ -#define DB_RUNRECOVERY (-30982)/* Panic return. */ -#define DB_SECONDARY_BAD (-30981)/* Secondary index corrupt. */ -#define DB_VERIFY_BAD (-30980)/* Verify failed; bad format. */ +#define DB_FILEOPEN (-30998)/* Rename/remove while file is open. */ +#define DB_KEYEMPTY (-30997)/* Key/data deleted or never created. */ +#define DB_KEYEXIST (-30996)/* The key/data pair already exists. */ +#define DB_LOCK_DEADLOCK (-30995)/* Deadlock. */ +#define DB_LOCK_NOTGRANTED (-30994)/* Lock unavailable. */ +#define DB_NOSERVER (-30993)/* Server panic return. */ +#define DB_NOSERVER_HOME (-30992)/* Bad home sent to server. */ +#define DB_NOSERVER_ID (-30991)/* Bad ID sent to server. */ +#define DB_NOTFOUND (-30990)/* Key/data pair not found (EOF). */ +#define DB_OLD_VERSION (-30989)/* Out-of-date version. */ +#define DB_PAGE_NOTFOUND (-30988)/* Requested page not found. */ +#define DB_REP_DUPMASTER (-30987)/* There are two masters. */ +#define DB_REP_HANDLE_DEAD (-30986)/* Rolled back a commit. */ +#define DB_REP_HOLDELECTION (-30985)/* Time to hold an election. */ +#define DB_REP_ISPERM (-30984)/* Cached not written perm written.*/ +#define DB_REP_NEWMASTER (-30983)/* We have learned of a new master. */ +#define DB_REP_NEWSITE (-30982)/* New site entered system. */ +#define DB_REP_NOTPERM (-30981)/* Permanent log record not written. */ +#define DB_REP_OUTDATED (-30980)/* Site is too far behind master. */ +#define DB_REP_UNAVAIL (-30979)/* Site cannot currently be reached. */ +#define DB_RUNRECOVERY (-30978)/* Panic return. */ +#define DB_SECONDARY_BAD (-30977)/* Secondary index corrupt. */ +#define DB_VERIFY_BAD (-30976)/* Verify failed; bad format. */ /* DB (private) error return codes. */ #define DB_ALREADY_ABORTED (-30899) #define DB_DELETED (-30898)/* Recovery file marked deleted. */ -#define DB_JAVA_CALLBACK (-30897)/* Exception during a java callback. */ -#define DB_LOCK_NOTEXIST (-30896)/* Object to lock is gone. */ -#define DB_NEEDSPLIT (-30895)/* Page needs to be split. */ -#define DB_SURPRISE_KID (-30894)/* Child commit where parent +#define DB_LOCK_NOTEXIST (-30897)/* Object to lock is gone. */ +#define DB_NEEDSPLIT (-30896)/* Page needs to be split. */ +#define DB_SURPRISE_KID (-30895)/* Child commit where parent didn't know it was a parent. */ -#define DB_SWAPBYTES (-30893)/* Database needs byte swapping. */ -#define DB_TIMEOUT (-30892)/* Timed out waiting for election. */ -#define DB_TXN_CKP (-30891)/* Encountered ckp record in log. */ -#define DB_VERIFY_FATAL (-30890)/* DB->verify cannot proceed. */ +#define DB_SWAPBYTES (-30894)/* Database needs byte swapping. */ +#define DB_TIMEOUT (-30893)/* Timed out waiting for election. */ +#define DB_TXN_CKP (-30892)/* Encountered ckp record in log. */ +#define DB_VERIFY_FATAL (-30891)/* DB->verify cannot proceed. */ /* Database handle. */ struct __db { @@ -1045,10 +1103,12 @@ struct __db { DBTYPE type; /* DB access method type. */ DB_MPOOLFILE *mpf; /* Backing buffer pool. */ - DB_CACHE_PRIORITY priority; /* Priority in the buffer pool. */ DB_MUTEX *mutexp; /* Synchronization for free threading */ + char *fname, *dname; /* File/database passed to DB->open. */ + u_int32_t open_flags; /* Flags passed to DB->open. */ + u_int8_t fileid[DB_FILE_ID_LEN];/* File's unique ID for locking. */ u_int32_t adj_fileid; /* File's unique ID for curs. adj. */ @@ -1064,6 +1124,8 @@ struct __db { long cl_id; /* RPC: remote client id. */ + time_t timestamp; /* Handle timestamp for replication. */ + /* * Returned data memory for DB->get() and friends. */ @@ -1179,6 +1241,17 @@ struct __db { int (*get) __P((DB *, DB_TXN *, DBT *, DBT *, u_int32_t)); int (*pget) __P((DB *, DB_TXN *, DBT *, DBT *, DBT *, u_int32_t)); int (*get_byteswapped) __P((DB *, int *)); + int (*get_cachesize) __P((DB *, u_int32_t *, u_int32_t *, int *)); + int (*get_dbname) __P((DB *, const char **, const char **)); + int (*get_encrypt_flags) __P((DB *, u_int32_t *)); + int (*get_env) __P((DB *, DB_ENV **)); + void (*get_errfile) __P((DB *, FILE **)); + void (*get_errpfx) __P((DB *, const char **)); + int (*get_flags) __P((DB *, u_int32_t *)); + int (*get_lorder) __P((DB *, int *)); + int (*get_open_flags) __P((DB *, u_int32_t *)); + int (*get_pagesize) __P((DB *, u_int32_t *)); + int (*get_transactional) __P((DB *, int *)); int (*get_type) __P((DB *, DBTYPE *)); int (*join) __P((DB *, DBC **, DBC **, u_int32_t)); int (*key_range) __P((DB *, @@ -1194,7 +1267,6 @@ struct __db { int (*set_alloc) __P((DB *, void *(*)(size_t), void *(*)(void *, size_t), void (*)(void *))); int (*set_cachesize) __P((DB *, u_int32_t, u_int32_t, int)); - int (*set_cache_priority) __P((DB *, DB_CACHE_PRIORITY)); int (*set_dup_compare) __P((DB *, int (*)(DB *, const DBT *, const DBT *))); int (*set_encrypt) __P((DB *, const char *, u_int32_t)); @@ -1212,6 +1284,7 @@ struct __db { int (*verify) __P((DB *, const char *, const char *, FILE *, u_int32_t)); + int (*get_bt_minkey) __P((DB *, u_int32_t *)); int (*set_bt_compare) __P((DB *, int (*)(DB *, const DBT *, const DBT *))); int (*set_bt_maxkey) __P((DB *, u_int32_t)); @@ -1219,15 +1292,23 @@ struct __db { int (*set_bt_prefix) __P((DB *, size_t (*)(DB *, const DBT *, const DBT *))); + int (*get_h_ffactor) __P((DB *, u_int32_t *)); + int (*get_h_nelem) __P((DB *, u_int32_t *)); int (*set_h_ffactor) __P((DB *, u_int32_t)); int (*set_h_hash) __P((DB *, u_int32_t (*)(DB *, const void *, u_int32_t))); int (*set_h_nelem) __P((DB *, u_int32_t)); + int (*get_re_delim) __P((DB *, int *)); + int (*get_re_len) __P((DB *, u_int32_t *)); + int (*get_re_pad) __P((DB *, int *)); + int (*get_re_source) __P((DB *, const char **)); int (*set_re_delim) __P((DB *, int)); int (*set_re_len) __P((DB *, u_int32_t)); int (*set_re_pad) __P((DB *, int)); int (*set_re_source) __P((DB *, const char *)); + + int (*get_q_extentsize) __P((DB *, u_int32_t *)); int (*set_q_extentsize) __P((DB *, u_int32_t)); int (*db_am_remove) __P((DB *, @@ -1263,31 +1344,33 @@ struct __db { #define DB_AM_FIXEDLEN 0x00001000 /* Fixed-length records. */ #define DB_AM_INMEM 0x00002000 /* In-memory; no sync on close. */ #define DB_AM_IN_RENAME 0x00004000 /* File is being renamed. */ -#define DB_AM_OPEN_CALLED 0x00008000 /* DB->open called. */ -#define DB_AM_PAD 0x00010000 /* Fixed-length record pad. */ -#define DB_AM_PGDEF 0x00020000 /* Page size was defaulted. */ -#define DB_AM_RDONLY 0x00040000 /* Database is readonly. */ -#define DB_AM_RECNUM 0x00080000 /* DB_RECNUM. */ -#define DB_AM_RECOVER 0x00100000 /* DB opened by recovery routine. */ -#define DB_AM_RENUMBER 0x00200000 /* DB_RENUMBER. */ -#define DB_AM_REVSPLITOFF 0x00400000 /* DB_REVSPLITOFF. */ -#define DB_AM_SECONDARY 0x00800000 /* Database is a secondary index. */ -#define DB_AM_SNAPSHOT 0x01000000 /* DB_SNAPSHOT. */ -#define DB_AM_SUBDB 0x02000000 /* Subdatabases supported. */ -#define DB_AM_SWAP 0x04000000 /* Pages need to be byte-swapped. */ -#define DB_AM_TXN 0x08000000 /* Opened in a transaction. */ -#define DB_AM_VERIFYING 0x10000000 /* DB handle is in the verifier. */ +#define DB_AM_NOT_DURABLE 0x00008000 /* Do not log changes. */ +#define DB_AM_OPEN_CALLED 0x00010000 /* DB->open called. */ +#define DB_AM_PAD 0x00020000 /* Fixed-length record pad. */ +#define DB_AM_PGDEF 0x00040000 /* Page size was defaulted. */ +#define DB_AM_RDONLY 0x00080000 /* Database is readonly. */ +#define DB_AM_RECNUM 0x00100000 /* DB_RECNUM. */ +#define DB_AM_RECOVER 0x00200000 /* DB opened by recovery routine. */ +#define DB_AM_RENUMBER 0x00400000 /* DB_RENUMBER. */ +#define DB_AM_REPLICATION 0x00800000 /* An internal replication file. */ +#define DB_AM_REVSPLITOFF 0x01000000 /* DB_REVSPLITOFF. */ +#define DB_AM_SECONDARY 0x02000000 /* Database is a secondary index. */ +#define DB_AM_SNAPSHOT 0x04000000 /* DB_SNAPSHOT. */ +#define DB_AM_SUBDB 0x08000000 /* Subdatabases supported. */ +#define DB_AM_SWAP 0x10000000 /* Pages need to be byte-swapped. */ +#define DB_AM_TXN 0x20000000 /* Opened in a transaction. */ +#define DB_AM_VERIFYING 0x40000000 /* DB handle is in the verifier. */ + u_int32_t orig_flags; /* Flags at open, for refresh. */ u_int32_t flags; }; /* - * Macros for bulk get. Note that wherever we use a DBT *, we explicitly - * cast it; this allows the same macros to work with C++ Dbt *'s, as Dbt - * is a subclass of struct DBT in C++. + * Macros for bulk get. These are only intended for the C API. + * For C++, use DbMultiple*Iterator. */ #define DB_MULTIPLE_INIT(pointer, dbt) \ - (pointer = (u_int8_t *)((DBT *)(dbt))->data + \ - ((DBT *)(dbt))->ulen - sizeof(u_int32_t)) + (pointer = (u_int8_t *)(dbt)->data + \ + (dbt)->ulen - sizeof(u_int32_t)) #define DB_MULTIPLE_NEXT(pointer, dbt, retdata, retdlen) \ do { \ if (*((u_int32_t *)(pointer)) == (u_int32_t)-1) { \ @@ -1296,12 +1379,12 @@ struct __db { break; \ } \ retdata = (u_int8_t *) \ - ((DBT *)(dbt))->data + *(u_int32_t *)(pointer); \ + (dbt)->data + *(u_int32_t *)(pointer); \ (pointer) = (u_int32_t *)(pointer) - 1; \ retdlen = *(u_int32_t *)(pointer); \ (pointer) = (u_int32_t *)(pointer) - 1; \ if (retdlen == 0 && \ - retdata == (u_int8_t *)((DBT *)(dbt))->data) \ + retdata == (u_int8_t *)(dbt)->data) \ retdata = NULL; \ } while (0) #define DB_MULTIPLE_KEY_NEXT(pointer, dbt, retkey, retklen, retdata, retdlen) \ @@ -1313,12 +1396,12 @@ struct __db { break; \ } \ retkey = (u_int8_t *) \ - ((DBT *)(dbt))->data + *(u_int32_t *)(pointer); \ + (dbt)->data + *(u_int32_t *)(pointer); \ (pointer) = (u_int32_t *)(pointer) - 1; \ retklen = *(u_int32_t *)(pointer); \ (pointer) = (u_int32_t *)(pointer) - 1; \ retdata = (u_int8_t *) \ - ((DBT *)(dbt))->data + *(u_int32_t *)(pointer); \ + (dbt)->data + *(u_int32_t *)(pointer); \ (pointer) = (u_int32_t *)(pointer) - 1; \ retdlen = *(u_int32_t *)(pointer); \ (pointer) = (u_int32_t *)(pointer) - 1; \ @@ -1335,7 +1418,7 @@ struct __db { recno = *(u_int32_t *)(pointer); \ (pointer) = (u_int32_t *)(pointer) - 1; \ retdata = (u_int8_t *) \ - ((DBT *)(dbt))->data + *(u_int32_t *)(pointer); \ + (dbt)->data + *(u_int32_t *)(pointer); \ (pointer) = (u_int32_t *)(pointer) - 1; \ retdlen = *(u_int32_t *)(pointer); \ (pointer) = (u_int32_t *)(pointer) - 1; \ @@ -1383,7 +1466,7 @@ struct __dbc { u_int32_t locker; /* Locker for this operation. */ DBT lock_dbt; /* DBT referencing lock. */ DB_LOCK_ILOCK lock; /* Object to be locked. */ - DB_LOCK mylock; /* Lock held on this cursor. */ + DB_LOCK mylock; /* CDB lock held on this cursor. */ long cl_id; /* Remote client id. */ @@ -1408,9 +1491,6 @@ struct __dbc { int (*c_am_put) __P((DBC *, DBT *, DBT *, u_int32_t, db_pgno_t *)); int (*c_am_writelock) __P((DBC *)); - /* Private: for secondary indices. */ - int (*c_real_get) __P((DBC *, DBT *, DBT *, u_int32_t)); - #define DBC_ACTIVE 0x0001 /* Cursor in use. */ #define DBC_COMPENSATE 0x0002 /* Cursor compensating, don't lock. */ #define DBC_DIRTY_READ 0x0004 /* Cursor supports dirty reads. */ @@ -1419,11 +1499,10 @@ struct __dbc { #define DBC_RMW 0x0020 /* Acquire write flag in read op. */ #define DBC_TRANSIENT 0x0040 /* Cursor is transient. */ #define DBC_WRITECURSOR 0x0080 /* Cursor may be used to write (CDB). */ -#define DBC_WRITEDUP 0x0100 /* idup'ed DBC_WRITECURSOR (CDB). */ -#define DBC_WRITER 0x0200 /* Cursor immediately writing (CDB). */ -#define DBC_MULTIPLE 0x0400 /* Return Multiple data. */ -#define DBC_MULTIPLE_KEY 0x0800 /* Return Multiple keys and data. */ -#define DBC_OWN_LID 0x1000 /* Free lock id on destroy. */ +#define DBC_WRITER 0x0100 /* Cursor immediately writing (CDB). */ +#define DBC_MULTIPLE 0x0200 /* Return Multiple data. */ +#define DBC_MULTIPLE_KEY 0x0400 /* Return Multiple keys and data. */ +#define DBC_OWN_LID 0x0800 /* Free lock id on destroy. */ u_int32_t flags; }; @@ -1554,8 +1633,15 @@ struct __db_env { size_t mp_size; /* DEPRECATED: Cachesize: bytes. */ int mp_ncache; /* Number of cache regions. */ size_t mp_mmapsize; /* Maximum file size for mmap. */ + int mp_maxwrite; /* Maximum buffers to write. */ + int /* Sleep after writing max buffers. */ + mp_maxwrite_sleep; + /* Replication */ int rep_eid; /* environment id. */ + int (*rep_send) /* Send function. */ + __P((DB_ENV *, const DBT *, const DBT *, + const DB_LSN *, int, u_int32_t)); /* Transactions. */ u_int32_t tx_max; /* Maximum number of transactions. */ @@ -1565,8 +1651,6 @@ struct __db_env { /******************************************************* * Private: owned by DB. *******************************************************/ - int panic_errval; /* Panic causing errno. */ - /* User files, paths. */ char *db_home; /* Database home. */ char *db_log_dir; /* Database log file directory. */ @@ -1577,6 +1661,7 @@ struct __db_env { int data_next; /* Next Database data file slot. */ int db_mode; /* Default open permissions. */ + u_int32_t open_flags; /* Flags passed to DB_ENV->open. */ void *reginfo; /* REGINFO structure reference. */ DB_FH *lockfhp; /* fcntl(2) locking file handle. */ @@ -1618,13 +1703,17 @@ struct __db_env { * !!! * Explicit representations of structures from queue.h. * TAILQ_ENTRY(__db_env) links; + * TAILQ_HEAD(xa_txn, __db_txn); */ struct { struct __db_env *tqe_next; struct __db_env **tqe_prev; } links; + struct __xa_txn { /* XA Active Transactions. */ + struct __db_txn *tqh_first; + struct __db_txn **tqh_last; + } xa_txn; int xa_rmid; /* XA Resource Manager ID. */ - DB_TXN *xa_txn; /* XA Current transaction. */ /* API-private structure. */ void *api1_internal; /* C++, Perl API private */ @@ -1640,36 +1729,51 @@ struct __db_env { /* DB_ENV Methods. */ int (*close) __P((DB_ENV *, u_int32_t)); int (*dbremove) __P((DB_ENV *, - DB_TXN *, const char *, const char *, u_int32_t)); + DB_TXN *, const char *, const char *, u_int32_t)); int (*dbrename) __P((DB_ENV *, DB_TXN *, - const char *, const char *, const char *, u_int32_t)); + const char *, const char *, const char *, u_int32_t)); void (*err) __P((const DB_ENV *, int, const char *, ...)); void (*errx) __P((const DB_ENV *, const char *, ...)); + int (*get_home) __P((DB_ENV *, const char **)); + int (*get_open_flags) __P((DB_ENV *, u_int32_t *)); int (*open) __P((DB_ENV *, const char *, u_int32_t, int)); int (*remove) __P((DB_ENV *, const char *, u_int32_t)); - int (*set_data_dir) __P((DB_ENV *, const char *)); int (*set_alloc) __P((DB_ENV *, void *(*)(size_t), void *(*)(void *, size_t), void (*)(void *))); int (*set_app_dispatch) __P((DB_ENV *, int (*)(DB_ENV *, DBT *, DB_LSN *, db_recops))); + int (*get_data_dirs) __P((DB_ENV *, const char ***)); + int (*set_data_dir) __P((DB_ENV *, const char *)); + int (*get_encrypt_flags) __P((DB_ENV *, u_int32_t *)); int (*set_encrypt) __P((DB_ENV *, const char *, u_int32_t)); void (*set_errcall) __P((DB_ENV *, void (*)(const char *, char *))); + void (*get_errfile) __P((DB_ENV *, FILE **)); void (*set_errfile) __P((DB_ENV *, FILE *)); + void (*get_errpfx) __P((DB_ENV *, const char **)); void (*set_errpfx) __P((DB_ENV *, const char *)); int (*set_feedback) __P((DB_ENV *, void (*)(DB_ENV *, int, int))); + int (*get_flags) __P((DB_ENV *, u_int32_t *)); int (*set_flags) __P((DB_ENV *, u_int32_t, int)); int (*set_paniccall) __P((DB_ENV *, void (*)(DB_ENV *, int))); int (*set_rpc_server) __P((DB_ENV *, void *, const char *, long, long, u_int32_t)); + int (*get_shm_key) __P((DB_ENV *, long *)); int (*set_shm_key) __P((DB_ENV *, long)); + int (*get_tas_spins) __P((DB_ENV *, u_int32_t *)); int (*set_tas_spins) __P((DB_ENV *, u_int32_t)); + int (*get_tmp_dir) __P((DB_ENV *, const char **)); int (*set_tmp_dir) __P((DB_ENV *, const char *)); + int (*get_verbose) __P((DB_ENV *, u_int32_t, int *)); int (*set_verbose) __P((DB_ENV *, u_int32_t, int)); void *lg_handle; /* Log handle and methods. */ + int (*get_lg_bsize) __P((DB_ENV *, u_int32_t *)); int (*set_lg_bsize) __P((DB_ENV *, u_int32_t)); + int (*get_lg_dir) __P((DB_ENV *, const char **)); int (*set_lg_dir) __P((DB_ENV *, const char *)); + int (*get_lg_max) __P((DB_ENV *, u_int32_t *)); int (*set_lg_max) __P((DB_ENV *, u_int32_t)); + int (*get_lg_regionmax) __P((DB_ENV *, u_int32_t *)); int (*set_lg_regionmax) __P((DB_ENV *, u_int32_t)); int (*log_archive) __P((DB_ENV *, char **[], u_int32_t)); int (*log_cursor) __P((DB_ENV *, DB_LOGC **, u_int32_t)); @@ -1679,33 +1783,37 @@ struct __db_env { int (*log_stat) __P((DB_ENV *, DB_LOG_STAT **, u_int32_t)); void *lk_handle; /* Lock handle and methods. */ + int (*get_lk_conflicts) __P((DB_ENV *, const u_int8_t **, int *)); int (*set_lk_conflicts) __P((DB_ENV *, u_int8_t *, int)); + int (*get_lk_detect) __P((DB_ENV *, u_int32_t *)); int (*set_lk_detect) __P((DB_ENV *, u_int32_t)); int (*set_lk_max) __P((DB_ENV *, u_int32_t)); + int (*get_lk_max_locks) __P((DB_ENV *, u_int32_t *)); int (*set_lk_max_locks) __P((DB_ENV *, u_int32_t)); + int (*get_lk_max_lockers) __P((DB_ENV *, u_int32_t *)); int (*set_lk_max_lockers) __P((DB_ENV *, u_int32_t)); + int (*get_lk_max_objects) __P((DB_ENV *, u_int32_t *)); int (*set_lk_max_objects) __P((DB_ENV *, u_int32_t)); int (*lock_detect) __P((DB_ENV *, u_int32_t, u_int32_t, int *)); - int (*lock_dump_region) __P((DB_ENV *, char *, FILE *)); + int (*lock_dump_region) __P((DB_ENV *, const char *, FILE *)); int (*lock_get) __P((DB_ENV *, u_int32_t, u_int32_t, const DBT *, db_lockmode_t, DB_LOCK *)); int (*lock_put) __P((DB_ENV *, DB_LOCK *)); int (*lock_id) __P((DB_ENV *, u_int32_t *)); int (*lock_id_free) __P((DB_ENV *, u_int32_t)); - int (*lock_id_set) __P((DB_ENV *, u_int32_t, u_int32_t)); int (*lock_stat) __P((DB_ENV *, DB_LOCK_STAT **, u_int32_t)); int (*lock_vec) __P((DB_ENV *, u_int32_t, u_int32_t, DB_LOCKREQ *, int, DB_LOCKREQ **)); - int (*lock_downgrade) __P((DB_ENV *, - DB_LOCK *, db_lockmode_t, u_int32_t)); void *mp_handle; /* Mpool handle and methods. */ - int (*set_mp_mmapsize) __P((DB_ENV *, size_t)); + int (*get_cachesize) __P((DB_ENV *, u_int32_t *, u_int32_t *, int *)); int (*set_cachesize) __P((DB_ENV *, u_int32_t, u_int32_t, int)); - int (*memp_dump_region) __P((DB_ENV *, char *, FILE *)); + int (*get_mp_mmapsize) __P((DB_ENV *, size_t *)); + int (*set_mp_mmapsize) __P((DB_ENV *, size_t)); + int (*get_mp_maxwrite) __P((DB_ENV *, int *, int *)); + int (*set_mp_maxwrite) __P((DB_ENV *, int, int)); + int (*memp_dump_region) __P((DB_ENV *, const char *, FILE *)); int (*memp_fcreate) __P((DB_ENV *, DB_MPOOLFILE **, u_int32_t)); - int (*memp_nameop) __P((DB_ENV *, - u_int8_t *, const char *, const char *, const char *)); int (*memp_register) __P((DB_ENV *, int, int (*)(DB_ENV *, db_pgno_t, void *, DBT *), int (*)(DB_ENV *, db_pgno_t, void *, DBT *))); @@ -1717,42 +1825,39 @@ struct __db_env { void *rep_handle; /* Replication handle and methods. */ int (*rep_elect) __P((DB_ENV *, int, int, u_int32_t, int *)); int (*rep_flush) __P((DB_ENV *)); - int (*rep_process_message) __P((DB_ENV *, DBT *, DBT *, int *)); + int (*rep_process_message) __P((DB_ENV *, DBT *, DBT *, + int *, DB_LSN *)); int (*rep_start) __P((DB_ENV *, DBT *, u_int32_t)); int (*rep_stat) __P((DB_ENV *, DB_REP_STAT **, u_int32_t)); - int (*set_rep_election) __P((DB_ENV *, - u_int32_t, u_int32_t, u_int32_t, u_int32_t)); + int (*get_rep_limit) __P((DB_ENV *, u_int32_t *, u_int32_t *)); int (*set_rep_limit) __P((DB_ENV *, u_int32_t, u_int32_t)); int (*set_rep_request) __P((DB_ENV *, u_int32_t, u_int32_t)); - int (*set_rep_timeout) __P((DB_ENV *, u_int32_t, u_int32_t)); int (*set_rep_transport) __P((DB_ENV *, int, - int (*) (DB_ENV *, const DBT *, const DBT *, int, u_int32_t))); + int (*) (DB_ENV *, const DBT *, const DBT *, const DB_LSN *, + int, u_int32_t))); void *tx_handle; /* Txn handle and methods. */ + int (*get_tx_max) __P((DB_ENV *, u_int32_t *)); int (*set_tx_max) __P((DB_ENV *, u_int32_t)); + int (*get_tx_timestamp) __P((DB_ENV *, time_t *)); int (*set_tx_timestamp) __P((DB_ENV *, time_t *)); int (*txn_begin) __P((DB_ENV *, DB_TXN *, DB_TXN **, u_int32_t)); int (*txn_checkpoint) __P((DB_ENV *, u_int32_t, u_int32_t, u_int32_t)); - int (*txn_id_set) __P((DB_ENV *, u_int32_t, u_int32_t)); int (*txn_recover) __P((DB_ENV *, DB_PREPLIST *, long, long *, u_int32_t)); int (*txn_stat) __P((DB_ENV *, DB_TXN_STAT **, u_int32_t)); + int (*get_timeout) __P((DB_ENV *, db_timeout_t *, u_int32_t)); int (*set_timeout) __P((DB_ENV *, db_timeout_t, u_int32_t)); #define DB_TEST_ELECTINIT 1 /* after __rep_elect_init */ -#define DB_TEST_ELECTSEND 2 /* after REP_ELECT msgnit */ -#define DB_TEST_ELECTVOTE1 3 /* after __rep_send_vote 1 */ -#define DB_TEST_ELECTVOTE2 4 /* after __rep_wait */ -#define DB_TEST_ELECTWAIT1 5 /* after REP_VOTE2 */ -#define DB_TEST_ELECTWAIT2 6 /* after __rep_wait 2 */ +#define DB_TEST_POSTDESTROY 2 /* after destroy op */ +#define DB_TEST_POSTLOG 3 /* after logging all pages */ +#define DB_TEST_POSTLOGMETA 4 /* after logging meta in btree */ +#define DB_TEST_POSTOPEN 5 /* after __os_open */ +#define DB_TEST_POSTSYNC 6 /* after syncing the log */ #define DB_TEST_PREDESTROY 7 /* before destroy op */ #define DB_TEST_PREOPEN 8 /* before __os_open */ -#define DB_TEST_POSTDESTROY 9 /* after destroy op */ -#define DB_TEST_POSTLOG 10 /* after logging all pages */ -#define DB_TEST_POSTLOGMETA 11 /* after logging meta in btree */ -#define DB_TEST_POSTOPEN 12 /* after __os_open */ -#define DB_TEST_POSTSYNC 13 /* after syncing the log */ -#define DB_TEST_SUBDB_LOCKS 14 /* subdb locking tests */ +#define DB_TEST_SUBDB_LOCKS 9 /* subdb locking tests */ int test_abort; /* Abort value for testing. */ int test_copy; /* Copy value for testing. */ @@ -1765,21 +1870,21 @@ struct __db_env { #define DB_ENV_DIRECT_LOG 0x0000040 /* DB_DIRECT_LOG set. */ #define DB_ENV_FATAL 0x0000080 /* Doing fatal recovery in env. */ #define DB_ENV_LOCKDOWN 0x0000100 /* DB_LOCKDOWN set. */ -#define DB_ENV_NOLOCKING 0x0000200 /* DB_NOLOCKING set. */ -#define DB_ENV_NOMMAP 0x0000400 /* DB_NOMMAP set. */ -#define DB_ENV_NOPANIC 0x0000800 /* Okay if panic set. */ -#define DB_ENV_OPEN_CALLED 0x0001000 /* DB_ENV->open called. */ -#define DB_ENV_OVERWRITE 0x0002000 /* DB_OVERWRITE set. */ -#define DB_ENV_PRIVATE 0x0004000 /* DB_PRIVATE set. */ -#define DB_ENV_REGION_INIT 0x0008000 /* DB_REGION_INIT set. */ -#define DB_ENV_REP_CLIENT 0x0010000 /* Replication client. */ -#define DB_ENV_REP_LOGSONLY 0x0020000 /* Log files only replication site. */ -#define DB_ENV_REP_MASTER 0x0040000 /* Replication master. */ -#define DB_ENV_RPCCLIENT 0x0080000 /* DB_CLIENT set. */ -#define DB_ENV_RPCCLIENT_GIVEN 0x0100000 /* User-supplied RPC client struct */ -#define DB_ENV_SYSTEM_MEM 0x0200000 /* DB_SYSTEM_MEM set. */ -#define DB_ENV_THREAD 0x0400000 /* DB_THREAD set. */ -#define DB_ENV_TXN_NOSYNC 0x0800000 /* DB_TXN_NOSYNC set. */ +#define DB_ENV_LOG_AUTOREMOVE 0x0000200 /* DB_LOG_AUTOREMOVE set. */ +#define DB_ENV_NOLOCKING 0x0000400 /* DB_NOLOCKING set. */ +#define DB_ENV_NOMMAP 0x0000800 /* DB_NOMMAP set. */ +#define DB_ENV_NOPANIC 0x0001000 /* Okay if panic set. */ +#define DB_ENV_OPEN_CALLED 0x0002000 /* DB_ENV->open called. */ +#define DB_ENV_OVERWRITE 0x0004000 /* DB_OVERWRITE set. */ +#define DB_ENV_PRIVATE 0x0008000 /* DB_PRIVATE set. */ +#define DB_ENV_REGION_INIT 0x0010000 /* DB_REGION_INIT set. */ +#define DB_ENV_RPCCLIENT 0x0020000 /* DB_RPCCLIENT set. */ +#define DB_ENV_RPCCLIENT_GIVEN 0x0040000 /* User-supplied RPC client struct */ +#define DB_ENV_SYSTEM_MEM 0x0080000 /* DB_SYSTEM_MEM set. */ +#define DB_ENV_THREAD 0x0100000 /* DB_THREAD set. */ +#define DB_ENV_TIME_NOTGRANTED 0x0200000 /* DB_TIME_NOTGRANTED set. */ +#define DB_ENV_TXN_NOSYNC 0x0400000 /* DB_TXN_NOSYNC set. */ +#define DB_ENV_TXN_NOT_DURABLE 0x0800000 /* DB_TXN_NOT_DURABLE set. */ #define DB_ENV_TXN_WRITE_NOSYNC 0x1000000 /* DB_TXN_WRITE_NOSYNC set. */ #define DB_ENV_YIELDCPU 0x2000000 /* DB_YIELDCPU set. */ u_int32_t flags; @@ -1875,7 +1980,7 @@ typedef struct entry { /* DO NOT EDIT: automatically built by dist/s_rpc. */ #define DB_RPC_SERVERPROG ((unsigned long)(351457)) -#define DB_RPC_SERVERVERS ((unsigned long)(4001)) +#define DB_RPC_SERVERVERS ((unsigned long)(4002)) /* DO NOT EDIT: automatically built by dist/s_include. */ #ifndef _DB_EXT_PROT_IN_ @@ -1909,9 +2014,6 @@ int db_env_set_func_unlink __P((int (*)(const char *))); int db_env_set_func_unmap __P((int (*)(void *, size_t))); int db_env_set_func_write __P((ssize_t (*)(int, const void *, size_t))); int db_env_set_func_yield __P((int (*)(void))); -int txn_abort __P((DB_TXN *)); -int txn_begin __P((DB_ENV *, DB_TXN *, DB_TXN **, u_int32_t)); -int txn_commit __P((DB_TXN *, u_int32_t)); #if DB_DBM_HSEARCH != 0 int __db_ndbm_clearerr __P((DBM *)); void __db_ndbm_close __P((DBM *)); |