diff options
132 files changed, 3456 insertions, 2734 deletions
diff --git a/db/dist/aclocal/types.ac b/db/dist/aclocal/types.ac index 4e432d832..905203104 100644 --- a/db/dist/aclocal/types.ac +++ b/db/dist/aclocal/types.ac @@ -1,167 +1,146 @@ -# Id: types.ac,v 11.8 2001/09/27 13:18:19 bostic Exp +# Id: types.ac,v 11.10 2001/12/10 14:16:49 bostic Exp + +# db.h includes <sys/types.h> and <stdio.h>, not the other default includes +# autoconf usually includes. For that reason, we specify a set of includes +# for all type checking tests. [#5060] +AC_DEFUN(DB_INCLUDES, [[ +#include <sys/types.h> +#include <stdio.h>]]) + +# Check the sizes we know about, and see if any of them match what's needed. +# +# Prefer ints to anything else, because read, write and others historically +# returned an int. +AC_DEFUN(AM_SEARCH_USIZES, [ + case "$3" in + "$ac_cv_sizeof_unsigned_int") + $1="typedef unsigned int $2;";; + "$ac_cv_sizeof_unsigned_char") + $1="typedef unsigned char $2;";; + "$ac_cv_sizeof_unsigned_short") + $1="typedef unsigned short $2;";; + "$ac_cv_sizeof_unsigned_long") + $1="typedef unsigned long $2;";; + *) + AC_MSG_ERROR([No unsigned $3-byte integral type]);; + esac]) +AC_DEFUN(AM_SEARCH_SSIZES, [ + case "$3" in + "$ac_cv_sizeof_int") + $1="typedef int $2;";; + "$ac_cv_sizeof_char") + $1="typedef char $2;";; + "$ac_cv_sizeof_short") + $1="typedef short $2;";; + "$ac_cv_sizeof_long") + $1="typedef long $2;";; + *) + AC_MSG_ERROR([No signed $3-byte integral type]);; + esac]) # Check for the standard system types. AC_DEFUN(AM_TYPES, [ -AC_TYPE_OFF_T +# We need to know the sizes of various objects on this system. +# We don't use the SIZEOF_XXX values created by autoconf. +AC_CHECK_SIZEOF(char,, DB_INCLUDES) +AC_CHECK_SIZEOF(unsigned char,, DB_INCLUDES) +AC_CHECK_SIZEOF(short,, DB_INCLUDES) +AC_CHECK_SIZEOF(unsigned short,, DB_INCLUDES) +AC_CHECK_SIZEOF(int,, DB_INCLUDES) +AC_CHECK_SIZEOF(unsigned int,, DB_INCLUDES) +AC_CHECK_SIZEOF(long,, DB_INCLUDES) +AC_CHECK_SIZEOF(unsigned long,, DB_INCLUDES) +AC_CHECK_SIZEOF(size_t,, DB_INCLUDES) +AC_CHECK_SIZEOF(char *,, DB_INCLUDES) + +# We require off_t and size_t, and we don't try to substitute our own +# if we can't find them. +AC_CHECK_TYPE(off_t,,, DB_INCLUDES) if test "$ac_cv_type_off_t" = no; then AC_MSG_ERROR([No off_t type.]) fi -AC_TYPE_PID_T -if test "$ac_cv_type_pid_t" = no; then - AC_MSG_ERROR([No pid_t type.]) -fi -AC_TYPE_SIZE_T + +AC_CHECK_TYPE(size_t,,, DB_INCLUDES) if test "$ac_cv_type_size_t" = no; then AC_MSG_ERROR([No size_t type.]) fi +# We look for u_char, u_short, u_int, u_long -- if we can't find them, +# we create our own. AC_SUBST(u_char_decl) -AC_CACHE_CHECK([for u_char], db_cv_uchar, [ -AC_TRY_COMPILE([#include <sys/types.h>], u_char foo;, - [db_cv_uchar=yes], [db_cv_uchar=no])]) -if test "$db_cv_uchar" = no; then +AC_CHECK_TYPE(u_char,,, DB_INCLUDES) +if test "$ac_cv_type_u_char" = no; then u_char_decl="typedef unsigned char u_char;" fi AC_SUBST(u_short_decl) -AC_CACHE_CHECK([for u_short], db_cv_ushort, [ -AC_TRY_COMPILE([#include <sys/types.h>], u_short foo;, - [db_cv_ushort=yes], [db_cv_ushort=no])]) -if test "$db_cv_ushort" = no; then +AC_CHECK_TYPE(u_short,,, DB_INCLUDES) +if test "$ac_cv_type_u_short" = no; then u_short_decl="typedef unsigned short u_short;" fi AC_SUBST(u_int_decl) -AC_CACHE_CHECK([for u_int], db_cv_uint, [ -AC_TRY_COMPILE([#include <sys/types.h>], u_int foo;, - [db_cv_uint=yes], [db_cv_uint=no])]) -if test "$db_cv_uint" = no; then +AC_CHECK_TYPE(u_int,,, DB_INCLUDES) +if test "$ac_cv_type_u_int" = no; then u_int_decl="typedef unsigned int u_int;" fi AC_SUBST(u_long_decl) -AC_CACHE_CHECK([for u_long], db_cv_ulong, [ -AC_TRY_COMPILE([#include <sys/types.h>], u_long foo;, - [db_cv_ulong=yes], [db_cv_ulong=no])]) -if test "$db_cv_ulong" = no; then +AC_CHECK_TYPE(u_long,,, DB_INCLUDES) +if test "$ac_cv_type_u_long" = no; then u_long_decl="typedef unsigned long u_long;" fi -# DB/Vi use specific integer sizes. AC_SUBST(u_int8_decl) -AC_CACHE_CHECK([for u_int8_t], db_cv_uint8, [ -AC_TRY_COMPILE([#include <sys/types.h>], u_int8_t foo;, - [db_cv_uint8=yes], -AC_TRY_RUN([main(){exit(sizeof(unsigned char) != 1);}], - [db_cv_uint8="unsigned char"], [db_cv_uint8=no]))]) -if test "$db_cv_uint8" = no; then - AC_MSG_ERROR([No unsigned 8-bit integral type.]) -fi -if test "$db_cv_uint8" != yes; then - u_int8_decl="typedef $db_cv_uint8 u_int8_t;" +AC_CHECK_TYPE(u_int8_t,,, DB_INCLUDES) +if test "$ac_cv_type_u_int8_t" = no; then + AM_SEARCH_USIZES(u_int8_decl, u_int8_t, 1) fi AC_SUBST(u_int16_decl) -AC_CACHE_CHECK([for u_int16_t], db_cv_uint16, [ -AC_TRY_COMPILE([#include <sys/types.h>], u_int16_t foo;, - [db_cv_uint16=yes], -AC_TRY_RUN([main(){exit(sizeof(unsigned short) != 2);}], - [db_cv_uint16="unsigned short"], -AC_TRY_RUN([main(){exit(sizeof(unsigned int) != 2);}], - [db_cv_uint16="unsigned int"], [db_cv_uint16=no])))]) -if test "$db_cv_uint16" = no; then - AC_MSG_ERROR([No unsigned 16-bit integral type.]) -fi -if test "$db_cv_uint16" != yes; then - u_int16_decl="typedef $db_cv_uint16 u_int16_t;" +AC_CHECK_TYPE(u_int16_t,,, DB_INCLUDES) +if test "$ac_cv_type_u_int16_t" = no; then + AM_SEARCH_USIZES(u_int16_decl, u_int16_t, 2) fi AC_SUBST(int16_decl) -AC_CACHE_CHECK([for int16_t], db_cv_int16, [ -AC_TRY_COMPILE([#include <sys/types.h>], int16_t foo;, - [db_cv_int16=yes], -AC_TRY_RUN([main(){exit(sizeof(short) != 2);}], - [db_cv_int16="short"], -AC_TRY_RUN([main(){exit(sizeof(int) != 2);}], - [db_cv_int16="int"], [db_cv_int16=no])))]) -if test "$db_cv_int16" = no; then - AC_MSG_ERROR([No signed 16-bit integral type.]) -fi -if test "$db_cv_int16" != yes; then - int16_decl="typedef $db_cv_int16 int16_t;" +AC_CHECK_TYPE(int16_t,,, DB_INCLUDES) +if test "$ac_cv_type_int16_t" = no; then + AM_SEARCH_SSIZES(int16_decl, int16_t, 2) fi AC_SUBST(u_int32_decl) -AC_CACHE_CHECK([for u_int32_t], db_cv_uint32, [ -AC_TRY_COMPILE([#include <sys/types.h>], u_int32_t foo;, - [db_cv_uint32=yes], -AC_TRY_RUN([main(){exit(sizeof(unsigned int) != 4);}], - [db_cv_uint32="unsigned int"], -AC_TRY_RUN([main(){exit(sizeof(unsigned long) != 4);}], - [db_cv_uint32="unsigned long"], [db_cv_uint32=no])))]) -if test "$db_cv_uint32" = no; then - AC_MSG_ERROR([No unsigned 32-bit integral type.]) -fi -if test "$db_cv_uint32" != yes; then - u_int32_decl="typedef $db_cv_uint32 u_int32_t;" +AC_CHECK_TYPE(u_int32_t,,, DB_INCLUDES) +if test "$ac_cv_type_u_int32_t" = no; then + AM_SEARCH_USIZES(u_int32_decl, u_int32_t, 4) fi AC_SUBST(int32_decl) -AC_CACHE_CHECK([for int32_t], db_cv_int32, [ -AC_TRY_COMPILE([#include <sys/types.h>], int32_t foo;, - [db_cv_int32=yes], -AC_TRY_RUN([main(){exit(sizeof(int) != 4);}], - [db_cv_int32="int"], -AC_TRY_RUN([main(){exit(sizeof(long) != 4);}], - [db_cv_int32="long"], [db_cv_int32=no])))]) -if test "$db_cv_int32" = no; then - AC_MSG_ERROR([No signed 32-bit integral type.]) -fi -if test "$db_cv_int32" != yes; then - int32_decl="typedef $db_cv_int32 int32_t;" +AC_CHECK_TYPE(int32_t,,, DB_INCLUDES) +if test "$ac_cv_type_int32_t" = no; then + AM_SEARCH_SSIZES(int32_decl, int32_t, 4) fi # Check for ssize_t -- if none exists, find a signed integral type that's -# the same size as a size_t. Prefer int over anything else, because read, -# write and others historically returned an int. +# the same size as a size_t. AC_SUBST(ssize_t_decl) -AC_CACHE_CHECK([for ssize_t], db_cv_ssize_t, [ -AC_TRY_COMPILE([#include <sys/types.h>], ssize_t foo;, - [db_cv_ssize_t=yes], -AC_TRY_RUN([ - #include <sys/types.h> - main(){exit(sizeof(size_t) != sizeof(int));}], - [db_cv_ssize_t="int"], -AC_TRY_RUN([ - #include <sys/types.h> - main(){exit(sizeof(size_t) != sizeof(long long));}], - [db_cv_ssize_t="long long"], -AC_TRY_RUN([ - #include <sys/types.h> - main(){exit(sizeof(size_t) != sizeof(long));}], - [db_cv_ssize_t="long"], [db_cv_ssize_t="int"]))))]) -if test "$db_cv_ssize_t" != yes; then - ssize_t_decl="typedef $db_cv_ssize_t ssize_t;" +AC_CHECK_TYPE(ssize_t,,, DB_INCLUDES) +if test "$ac_cv_type_ssize_t" = no; then + AM_SEARCH_SSIZES(ssize_t_decl, ssize_t, $ac_cv_sizeof_size_t) fi # Find the largest integral type. AC_SUBST(db_align_t_decl) -AC_CACHE_CHECK([for largest integral type], db_cv_align_t, [ -AC_TRY_COMPILE([#include <sys/types.h>], long long foo;, - [db_cv_align_t="unsigned long long"], [db_cv_align_t="unsigned long"])]) -db_align_t_decl="typedef $db_cv_align_t db_align_t;" +AC_CHECK_TYPE(unsigned long long,,, DB_INCLUDES) +if test "$ac_cv_type_unsigned_long_long" = no; then + db_align_t_decl="typedef unsigned long db_align_t;" +else + db_align_t_decl="typedef unsigned long long db_align_t;" +fi -# Find the integral type which is the same size as a pointer. +# Find an integral type which is the same size as a pointer. AC_SUBST(db_alignp_t_decl) -AC_CACHE_CHECK([for integral type equal to pointer size], db_cv_alignp_t, [ -db_cv_alignp_t=$db_cv_align_t -AC_TRY_RUN([main(){exit(sizeof(unsigned int) != sizeof(char *));}], - [db_cv_alignp_t="unsigned int"]) -AC_TRY_RUN([main(){exit(sizeof(unsigned long) != sizeof(char *));}], - [db_cv_alignp_t="unsigned long"]) -AC_TRY_RUN([main(){exit(sizeof(unsigned long long) != sizeof(char *));}], - [db_cv_alignp_t="unsigned long long"])]) -db_alignp_t_decl="typedef $db_cv_alignp_t db_alignp_t;" +AM_SEARCH_USIZES(db_alignp_t_decl, db_alignp_t, $ac_cv_sizeof_char_p) ]) diff --git a/db/dist/aclocal_java/ac_jni_include_dirs.ac b/db/dist/aclocal_java/ac_jni_include_dirs.ac index 66e777b47..0435b555b 100644 --- a/db/dist/aclocal_java/ac_jni_include_dirs.ac +++ b/db/dist/aclocal_java/ac_jni_include_dirs.ac @@ -28,15 +28,20 @@ dnl Note: This macro can work with the autoconf M4 macros for Java programs. dnl This particular macro is not part of the original set of macros. dnl dnl @author Don Anderson <dda@sleepycat.com> -dnl @version Id: ac_jni_include_dirs.ac,v 1.5 2001/09/17 18:48:28 bostic Exp +dnl @version Id: ac_jni_include_dirs.ac,v 1.7 2002/02/11 14:00:50 bostic Exp dnl AC_DEFUN(AC_JNI_INCLUDE_DIR,[ JNI_INCLUDE_DIRS="" test "x$JAVAC" = x && AC_MSG_ERROR(['$JAVAC' undefined]) -AC_PATH_PROG(_ACJNI_JAVAC, $JAVAC, no) -test "x$_ACJNI_JAVAC" = xno && AC_MSG_ERROR([$JAVAC could not be found in path]) +AC_PATH_PROG(_ACJNI_JAVAC, $JAVAC, $JAVAC) +test ! -x "$_ACJNI_JAVAC" && AC_MSG_ERROR([$JAVAC could not be found in path]) +AC_MSG_CHECKING(absolute path of $JAVAC) +case "$_ACJNI_JAVAC" in +/*) AC_MSG_RESULT($_ACJNI_JAVAC);; +*) AC_MSG_ERROR([$_ACJNI_JAVAC is not an absolute path name]);; +esac _ACJNI_FOLLOW_SYMLINKS("$_ACJNI_JAVAC") _JTOPDIR=`echo "$_ACJNI_FOLLOWED" | sed -e 's://*:/:g' -e 's:/[[^/]]*$::'` diff --git a/db/dist/vx_setup/LICENSE.TXT b/db/dist/vx_setup/LICENSE.TXT index 92600c424..7814c679c 100644 --- a/db/dist/vx_setup/LICENSE.TXT +++ b/db/dist/vx_setup/LICENSE.TXT @@ -1,3 +1,3 @@ -Copyright (c) 1996-2001 +Copyright (c) 1996-2002 Sleepycat Software. All rights reserved. See the file LICENSE for redistribution information. diff --git a/db/docs/api_c/env_set_timeout.html b/db/docs/api_c/env_set_timeout.html index e55e1450f..dfe94bda6 100644 --- a/db/docs/api_c/env_set_timeout.html +++ b/db/docs/api_c/env_set_timeout.html @@ -1,6 +1,7 @@ -<!--Id: env_set_timeout.so,v 10.3 2001/10/22 15:24:31 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: env_set_timeout.so,v 10.6 2002/06/24 14:49:21 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB: DB_ENV->set_timeout</title> @@ -59,40 +60,57 @@ detection is performed. <p>Timeout values specified for the database environment may be overridden on a per-lock or per-transaction basis. See <a href="../api_c/lock_vec.html">DB_ENV->lock_vec</a> and <a href="../api_c/txn_set_timeout.html">DB_TXN->set_timeout</a> for more information. -<p>The DB_ENV->set_timeout interface may be used only to configure Berkeley DB before -the <a href="../api_c/env_open.html">DB_ENV->open</a> interface is called. +<p>The DB_ENV->set_timeout function configures a database environment, not only operations +performed using the specified <a href="../api_c/env_create.html">DB_ENV</a> handle. +<p>The DB_ENV->set_timeout interface may be called at any time during the life of +the application. <p>The DB_ENV->set_timeout function returns a non-zero error value on failure and 0 on success. <h1>Errors</h1> <p>The DB_ENV->set_timeout function may fail and return a non-zero error for the following conditions: <p><dl compact> <p><dt>EINVAL<dd>An invalid flag value or parameter was specified. -<p>Called after <a href="../api_c/env_open.html">DB_ENV->open</a> was called. </dl> <p>The DB_ENV->set_timeout function may fail and return a non-zero error for errors specified for other Berkeley DB and C library or system functions. -If a catastrophic error has occurred, the DB_ENV->set_timeout function may fail and return -<a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, in which case all subsequent Berkeley DB calls will fail -in the same way. +If a catastrophic error has occurred, the DB_ENV->set_timeout function may fail and +return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, +in which case all subsequent Berkeley DB calls will fail in the same way. <h1>See Also</h1> <a href="../api_c/env_create.html">db_env_create</a>, <a href="../api_c/env_close.html">DB_ENV->close</a>, -<a href="../api_c/env_err.html">DB_ENV->err</a>, <a href="../api_c/env_err.html">DB_ENV->errx</a> +<a href="../api_c/env_dbremove.html">DB_ENV->dbremove</a>, +<a href="../api_c/env_dbrename.html">DB_ENV->dbrename</a>, +<a href="../api_c/env_err.html">DB_ENV->err</a>, +<a href="../api_c/env_err.html">DB_ENV->errx</a>, <a href="../api_c/env_open.html">DB_ENV->open</a>, <a href="../api_c/env_remove.html">DB_ENV->remove</a>, <a href="../api_c/env_set_alloc.html">DB_ENV->set_alloc</a>, +<a href="../api_c/env_set_app_dispatch.html">DB_ENV->set_app_dispatch</a>, <a href="../api_c/env_set_cachesize.html">DB_ENV->set_cachesize</a>, <a href="../api_c/env_set_data_dir.html">DB_ENV->set_data_dir</a>, +<a href="../api_c/env_set_encrypt.html">DB_ENV->set_encrypt</a>, <a href="../api_c/env_set_errcall.html">DB_ENV->set_errcall</a>, <a href="../api_c/env_set_errfile.html">DB_ENV->set_errfile</a>, <a href="../api_c/env_set_errpfx.html">DB_ENV->set_errpfx</a>, <a href="../api_c/env_set_feedback.html">DB_ENV->set_feedback</a>, <a href="../api_c/env_set_flags.html">DB_ENV->set_flags</a>, +<a href="../api_c/env_set_lg_bsize.html">DB_ENV->set_lg_bsize</a>, +<a href="../api_c/env_set_lg_dir.html">DB_ENV->set_lg_dir</a>, +<a href="../api_c/env_set_lg_max.html">DB_ENV->set_lg_max</a>, +<a href="../api_c/env_set_lg_regionmax.html">DB_ENV->set_lg_regionmax</a>, +<a href="../api_c/env_set_lk_conflicts.html">DB_ENV->set_lk_conflicts</a>, +<a href="../api_c/env_set_lk_detect.html">DB_ENV->set_lk_detect</a>, +<a href="../api_c/env_set_lk_max_lockers.html">DB_ENV->set_lk_max_lockers</a>, +<a href="../api_c/env_set_lk_max_locks.html">DB_ENV->set_lk_max_locks</a>, +<a href="../api_c/env_set_lk_max_objects.html">DB_ENV->set_lk_max_objects</a>, +<a href="../api_c/env_set_mp_mmapsize.html">DB_ENV->set_mp_mmapsize</a>, <a href="../api_c/env_set_paniccall.html">DB_ENV->set_paniccall</a>, -<a href="../api_c/env_set_rec_init.html">DB_ENV->set_recovery_init</a>, <a href="../api_c/env_set_rpc_server.html">DB_ENV->set_rpc_server</a>, <a href="../api_c/env_set_shm_key.html">DB_ENV->set_shm_key</a>, <a href="../api_c/env_set_tas_spins.html">DB_ENV->set_tas_spins</a>, -<a href="../api_c/env_set_tmp_dir.html">DB_ENV->set_tmp_dir</a>, <a href="../api_c/env_set_timeout.html">DB_ENV->set_timeout</a>, +<a href="../api_c/env_set_tmp_dir.html">DB_ENV->set_tmp_dir</a>, +<a href="../api_c/env_set_tx_max.html">DB_ENV->set_tx_max</a>, +<a href="../api_c/env_set_tx_timestamp.html">DB_ENV->set_tx_timestamp</a>, <a href="../api_c/env_set_verbose.html">DB_ENV->set_verbose</a>, <a href="../api_c/env_strerror.html">db_strerror</a> and diff --git a/db/docs/api_c/lock_id_free.html b/db/docs/api_c/lock_id_free.html index 0f32651a5..73e8a31d2 100644 --- a/db/docs/api_c/lock_id_free.html +++ b/db/docs/api_c/lock_id_free.html @@ -1,6 +1,7 @@ -<!--Id: lock_id_free.so,v 10.2 2001/10/22 15:24:32 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: lock_id_free.so,v 10.4 2002/06/24 14:49:23 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB: DB_ENV->lock_id_free</title> @@ -34,9 +35,9 @@ DB_ENV->lock_id function. <p>The locker ID is invalid or locks are still held by this locker ID. </dl> <p>The DB_ENV->lock_id_free function may fail and return a non-zero error for errors specified for other Berkeley DB and C library or system functions. -If a catastrophic error has occurred, the DB_ENV->lock_id_free function may fail and return -<a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, in which case all subsequent Berkeley DB calls will fail -in the same way. +If a catastrophic error has occurred, the DB_ENV->lock_id_free function may fail and +return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, +in which case all subsequent Berkeley DB calls will fail in the same way. <h1>See Also</h1> <a href="../api_c/env_set_lk_conflicts.html">DB_ENV->set_lk_conflicts</a>, <a href="../api_c/env_set_lk_detect.html">DB_ENV->set_lk_detect</a>, @@ -48,7 +49,7 @@ in the same way. <a href="../api_c/lock_id.html">DB_ENV->lock_id</a>, <a href="../api_c/lock_id_free.html">DB_ENV->lock_id_free</a>, <a href="../api_c/lock_put.html">DB_ENV->lock_put</a>, -<a href="../api_c/lock_stat.html">DB_ENV->lock_stat</a>, +<a href="../api_c/lock_stat.html">DB_ENV->lock_stat</a> and <a href="../api_c/lock_vec.html">DB_ENV->lock_vec</a>. </tt> diff --git a/db/docs/api_c/log_cursor.html b/db/docs/api_c/log_cursor.html index 0bf50ab34..33e0f5173 100644 --- a/db/docs/api_c/log_cursor.html +++ b/db/docs/api_c/log_cursor.html @@ -1,6 +1,7 @@ -<!--Id: log_cursor.so,v 10.2 2001/10/22 15:24:33 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: log_cursor.so,v 10.3 2002/06/24 14:49:24 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB: DB_ENV->log_cursor</title> @@ -36,34 +37,37 @@ creates a log cursor and copies a pointer to it into the memory to which <p><dt>EINVAL<dd>An invalid flag value or parameter was specified. </dl> <p>The DB_ENV->log_cursor function may fail and return a non-zero error for errors specified for other Berkeley DB and C library or system functions. -If a catastrophic error has occurred, the DB_ENV->log_cursor function may fail and return -<a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, in which case all subsequent Berkeley DB calls will fail -in the same way. +If a catastrophic error has occurred, the DB_ENV->log_cursor function may fail and +return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, +in which case all subsequent Berkeley DB calls will fail in the same way. <h1>See Also</h1> <a href="../api_c/db_create.html">db_create</a>, +<a href="../api_c/db_set_alloc.html">DB->set_alloc</a>, <a href="../api_c/db_associate.html">DB->associate</a>, <a href="../api_c/db_close.html">DB->close</a>, <a href="../api_c/db_cursor.html">DB->cursor</a>, <a href="../api_c/db_del.html">DB->del</a>, -<a href="../api_c/db_err.html">DB->err</a>, <a href="../api_c/db_err.html">DB->errx</a> +<a href="../api_c/db_err.html">DB->err</a>, +<a href="../api_c/db_err.html">DB->errx</a>, <a href="../api_c/db_fd.html">DB->fd</a>, <a href="../api_c/db_get.html">DB->get</a>, -<a href="../api_c/db_get.html">DB->pget</a>, <a href="../api_c/db_get_byteswapped.html">DB->get_byteswapped</a>, <a href="../api_c/db_get_type.html">DB->get_type</a>, <a href="../api_c/db_join.html">DB->join</a>, <a href="../api_c/db_key_range.html">DB->key_range</a>, <a href="../api_c/db_open.html">DB->open</a>, +<a href="../api_c/db_get.html">DB->pget</a>, <a href="../api_c/db_put.html">DB->put</a>, <a href="../api_c/db_remove.html">DB->remove</a>, <a href="../api_c/db_rename.html">DB->rename</a>, -<a href="../api_c/db_set_alloc.html">DB->set_alloc</a>, <a href="../api_c/db_set_append_recno.html">DB->set_append_recno</a>, <a href="../api_c/db_set_bt_compare.html">DB->set_bt_compare</a>, <a href="../api_c/db_set_bt_minkey.html">DB->set_bt_minkey</a>, <a href="../api_c/db_set_bt_prefix.html">DB->set_bt_prefix</a>, +<a href="../api_c/db_set_cache_priority.html">DB->set_cache_priority</a>, <a href="../api_c/db_set_cachesize.html">DB->set_cachesize</a>, <a href="../api_c/db_set_dup_compare.html">DB->set_dup_compare</a>, +<a href="../api_c/db_set_encrypt.html">DB->set_encrypt</a>, <a href="../api_c/db_set_errcall.html">DB->set_errcall</a>, <a href="../api_c/db_set_errfile.html">DB->set_errfile</a>, <a href="../api_c/db_set_errpfx.html">DB->set_errpfx</a>, @@ -83,7 +87,7 @@ in the same way. <a href="../api_c/db_stat.html">DB->stat</a>, <a href="../api_c/db_sync.html">DB->sync</a>, <a href="../api_c/db_truncate.html">DB->truncate</a>, -<a href="../api_c/db_upgrade.html">DB->upgrade</a>, +<a href="../api_c/db_upgrade.html">DB->upgrade</a> and <a href="../api_c/db_verify.html">DB->verify</a>. </tt> diff --git a/db/docs/api_c/logc_close.html b/db/docs/api_c/logc_close.html index 6747f34ef..59cf31bd5 100644 --- a/db/docs/api_c/logc_close.html +++ b/db/docs/api_c/logc_close.html @@ -1,6 +1,7 @@ -<!--Id: logc_close.so,v 10.4 2001/10/22 15:24:35 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: logc_close.so,v 10.5 2002/06/24 14:49:25 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB: DB_LOGC->close</title> @@ -37,23 +38,23 @@ used again. <p>The cursor was previously closed. </dl> <p>The DB_LOGC->close function may fail and return a non-zero error for errors specified for other Berkeley DB and C library or system functions. -If a catastrophic error has occurred, the DB_LOGC->close function may fail and return -<a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, in which case all subsequent Berkeley DB calls will fail -in the same way. +If a catastrophic error has occurred, the DB_LOGC->close function may fail and +return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, +in which case all subsequent Berkeley DB calls will fail in the same way. <h1>See Also</h1> -<a href="../api_c/env_set_lg_bsize.html">DB_ENV->set_lg_bsize</a>, -<a href="../api_c/env_set_lg_dir.html">DB_ENV->set_lg_dir</a>, -<a href="../api_c/env_set_lg_max.html">DB_ENV->set_lg_max</a>, -<a href="../api_c/env_set_lg_regionmax.html">DB_ENV->set_lg_regionmax</a>, <a href="../api_c/log_archive.html">DB_ENV->log_archive</a>, -<a href="../api_c/log_compare.html">log_compare</a>, -<a href="../api_c/log_cursor.html">DB_ENV->log_cursor</a>, <a href="../api_c/log_file.html">DB_ENV->log_file</a>, <a href="../api_c/log_flush.html">DB_ENV->log_flush</a>, <a href="../api_c/log_put.html">DB_ENV->log_put</a>, -<a href="../api_c/log_register.html">DB_ENV->log_register</a>, <a href="../api_c/log_stat.html">DB_ENV->log_stat</a>, -<a href="../api_c/log_unregister.html">DB_ENV->log_unregister</a>, +<a href="../api_c/env_set_lg_bsize.html">DB_ENV->set_lg_bsize</a>, +<a href="../api_c/env_set_lg_dir.html">DB_ENV->set_lg_dir</a>, +<a href="../api_c/env_set_lg_max.html">DB_ENV->set_lg_max</a>, +<a href="../api_c/env_set_lg_regionmax.html">DB_ENV->set_lg_regionmax</a>, +and +<a href="../api_c/log_compare.html">log_compare</a>. +<p> +<a href="../api_c/log_cursor.html">DB_ENV->log_cursor</a>, <a href="../api_c/logc_close.html">DB_LOGC->close</a> and <a href="../api_c/logc_get.html">DB_LOGC->get</a>. diff --git a/db/docs/api_c/logc_get.html b/db/docs/api_c/logc_get.html index 4284db1b6..074763029 100644 --- a/db/docs/api_c/logc_get.html +++ b/db/docs/api_c/logc_get.html @@ -1,6 +1,7 @@ -<!--Id: logc_get.so,v 10.31 2001/10/22 15:24:35 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: logc_get.so,v 10.36 2002/07/01 16:52:26 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB: DB_LOGC->get</title> @@ -35,41 +36,38 @@ record. See <a href="../api_c/dbt.html">DBT</a> for a description of other fiel for any <a href="../api_c/dbt.html">DBT</a> used for data retrieval. <p>The <b>flags</b> value must be set to one of the following values: <p><dl compact> -<p><dt><a name="DB_CHECKPOINT">DB_CHECKPOINT</a><dd>The last record written with the DB_CHECKPOINT flag specified to the -<a href="../api_c/log_put.html">DB_ENV->log_put</a> function is returned in the <b>data</b> argument. The -<b>lsn</b> argument is overwritten with the <a href="../api_c/db_lsn.html">DB_LSN</a> of the record -returned. If no record has been previously written with the DB_CHECKPOINT -flag specified, the first record in the log is returned. -<p>If the log is empty, the DB_LOGC->get function will return <a href="../ref/program/errorret.html#DB_NOTFOUND">DB_NOTFOUND</a>. <p><dt><a name="DB_FIRST">DB_FIRST</a><dd>The first record from any of the log files found in the log directory is returned in the <b>data</b> argument. The <b>lsn</b> argument is overwritten with the <a href="../api_c/db_lsn.html">DB_LSN</a> of the record returned. -<p>If the log is empty, the DB_LOGC->get function will return <a href="../ref/program/errorret.html#DB_NOTFOUND">DB_NOTFOUND</a>. +<p> +If the log is empty, the DB_LOGC->get function will return DB_NOTFOUND. <p><dt><a name="DB_LAST">DB_LAST</a><dd>The last record in the log is returned in the <b>data</b> argument. The <b>lsn</b> argument is overwritten with the <a href="../api_c/db_lsn.html">DB_LSN</a> of the record returned. -<p>If the log is empty, the DB_LOGC->get function will return <a href="../ref/program/errorret.html#DB_NOTFOUND">DB_NOTFOUND</a>. +<p> +If the log is empty, the DB_LOGC->get function will return DB_NOTFOUND. <p><dt><a name="DB_NEXT">DB_NEXT</a>, <a name="DB_PREV">DB_PREV</a><dd>The current log position is advanced to the next (previous) record in the log, and that record is returned in the <b>data</b> argument. The <b>lsn</b> argument is overwritten with the <a href="../api_c/db_lsn.html">DB_LSN</a> of the record returned. -<p>If the pointer has not been initialized via DB_FIRST, DB_LAST, DB_SET, +<p>If the cursor has not been initialized via DB_FIRST, DB_LAST, DB_SET, DB_NEXT, or DB_PREV, DB_LOGC->get will return the first (last) record -in the log. If the last (first) log record has already been returned -or the log is empty, the DB_LOGC->get function will return <a href="../ref/program/errorret.html#DB_NOTFOUND">DB_NOTFOUND</a>. -<p>If the log was opened with the DB_THREAD flag set, calls to -DB_LOGC->get with the DB_NEXT (DB_PREV) flag set will return -EINVAL. +in the log. +If the last (first) log record has already been returned or the log is +empty, the DB_LOGC->get function will return DB_NOTFOUND. +If the log was opened with the DB_THREAD flag set, calls to +DB_LOGC->get with the DB_NEXT (DB_PREV) flag set, the DB_LOGC->get function will return EINVAL. <p><dt><a name="DB_CURRENT">DB_CURRENT</a><dd>Return the log record to which the log currently refers. -<p>If the log pointer has not been initialized via DB_FIRST, DB_LAST, +If the log cursor has not been initialized via DB_FIRST, DB_LAST, DB_SET, DB_NEXT, or DB_PREV, or if the log was opened with the DB_THREAD -flag set, DB_LOGC->get will return EINVAL. -<p><dt><a name="DB_SET">DB_SET</a><dd>Retrieve the record specified by the <b>lsn</b> argument. If the -specified <a href="../api_c/db_lsn.html">DB_LSN</a> is invalid (for example, it does not appear in -the log) DB_LOGC->get will return EINVAL. +flag set, the DB_LOGC->get function will return EINVAL. +<p><dt><a name="DB_SET">DB_SET</a><dd>Retrieve the record specified by the <b>lsn</b> argument. +If the specified <a href="../api_c/db_lsn.html">DB_LSN</a> is invalid (for example, it does not +appear in the log), the DB_LOGC->get function will return EINVAL. </dl> -<p>Otherwise, the DB_LOGC->get function returns a non-zero error value on failure and 0 on success. +<p> +Otherwise, the DB_LOGC->get function returns a non-zero error value on failure and 0 on success. <h1>Errors</h1> <p>The DB_LOGC->get function may fail and return a non-zero error for the following conditions: <p><dl compact> @@ -80,23 +78,23 @@ initialized. exist. </dl> <p>The DB_LOGC->get function may fail and return a non-zero error for errors specified for other Berkeley DB and C library or system functions. -If a catastrophic error has occurred, the DB_LOGC->get function may fail and return -<a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, in which case all subsequent Berkeley DB calls will fail -in the same way. +If a catastrophic error has occurred, the DB_LOGC->get function may fail and +return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, +in which case all subsequent Berkeley DB calls will fail in the same way. <h1>See Also</h1> -<a href="../api_c/env_set_lg_bsize.html">DB_ENV->set_lg_bsize</a>, -<a href="../api_c/env_set_lg_dir.html">DB_ENV->set_lg_dir</a>, -<a href="../api_c/env_set_lg_max.html">DB_ENV->set_lg_max</a>, -<a href="../api_c/env_set_lg_regionmax.html">DB_ENV->set_lg_regionmax</a>, <a href="../api_c/log_archive.html">DB_ENV->log_archive</a>, -<a href="../api_c/log_compare.html">log_compare</a>, -<a href="../api_c/log_cursor.html">DB_ENV->log_cursor</a>, <a href="../api_c/log_file.html">DB_ENV->log_file</a>, <a href="../api_c/log_flush.html">DB_ENV->log_flush</a>, <a href="../api_c/log_put.html">DB_ENV->log_put</a>, -<a href="../api_c/log_register.html">DB_ENV->log_register</a>, <a href="../api_c/log_stat.html">DB_ENV->log_stat</a>, -<a href="../api_c/log_unregister.html">DB_ENV->log_unregister</a>, +<a href="../api_c/env_set_lg_bsize.html">DB_ENV->set_lg_bsize</a>, +<a href="../api_c/env_set_lg_dir.html">DB_ENV->set_lg_dir</a>, +<a href="../api_c/env_set_lg_max.html">DB_ENV->set_lg_max</a>, +<a href="../api_c/env_set_lg_regionmax.html">DB_ENV->set_lg_regionmax</a>, +and +<a href="../api_c/log_compare.html">log_compare</a>. +<p> +<a href="../api_c/log_cursor.html">DB_ENV->log_cursor</a>, <a href="../api_c/logc_close.html">DB_LOGC->close</a> and <a href="../api_c/logc_get.html">DB_LOGC->get</a>. diff --git a/db/docs/api_c/memp_fcreate.html b/db/docs/api_c/memp_fcreate.html index 169c64051..34ab2e92b 100644 --- a/db/docs/api_c/memp_fcreate.html +++ b/db/docs/api_c/memp_fcreate.html @@ -1,6 +1,7 @@ -<!--Id: memp_fcreate.so,v 10.4 2001/10/22 15:24:35 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: memp_fcreate.so,v 10.5 2002/06/24 14:49:26 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB: DB_ENV->memp_fcreate</title> @@ -33,29 +34,30 @@ Calling the <a href="../api_c/memp_fclose.html">DB_MPOOLFILE->close</a> funct <p>The DB_ENV->memp_fcreate function returns a non-zero error value on failure and 0 on success. <h1>Errors</h1> <p>The DB_ENV->memp_fcreate function may fail and return a non-zero error for errors specified for other Berkeley DB and C library or system functions. -If a catastrophic error has occurred, the DB_ENV->memp_fcreate function may fail and return -<a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, in which case all subsequent Berkeley DB calls will fail -in the same way. +If a catastrophic error has occurred, the DB_ENV->memp_fcreate function may fail and +return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, +in which case all subsequent Berkeley DB calls will fail in the same way. <h1>See Also</h1> <a href="../api_c/env_set_cachesize.html">DB_ENV->set_cachesize</a>, <a href="../api_c/env_set_mp_mmapsize.html">DB_ENV->set_mp_mmapsize</a>, +<a href="../api_c/memp_register.html">DB_ENV->memp_register</a>, +<a href="../api_c/memp_stat.html">DB_ENV->memp_stat</a>, +<a href="../api_c/memp_sync.html">DB_ENV->memp_sync</a>, +<a href="../api_c/memp_trickle.html">DB_ENV->memp_trickle</a>, +<p> <a href="../api_c/memp_fcreate.html">DB_ENV->memp_fcreate</a>, <a href="../api_c/memp_fclose.html">DB_MPOOLFILE->close</a>, <a href="../api_c/memp_fget.html">DB_MPOOLFILE->get</a>, <a href="../api_c/memp_fopen.html">DB_MPOOLFILE->open</a>, <a href="../api_c/memp_fput.html">DB_MPOOLFILE->put</a>, <a href="../api_c/memp_fset.html">DB_MPOOLFILE->set</a>, -<a href="../api_c/memp_fsync.html">DB_MPOOLFILE->sync</a>, -<a href="../api_c/memp_register.html">DB_ENV->memp_register</a>, -<a href="../api_c/memp_set_clear_len.html">DB_MPOOLFILE->set_clear_len</a>, <a href="../api_c/memp_set_fileid.html">DB_MPOOLFILE->set_fileid</a>, +<a href="../api_c/memp_set_clear_len.html">DB_MPOOLFILE->set_clear_len</a>, <a href="../api_c/memp_set_ftype.html">DB_MPOOLFILE->set_ftype</a>, <a href="../api_c/memp_set_lsn_offset.html">DB_MPOOLFILE->set_lsn_offset</a>, -<a href="../api_c/memp_set_pgcookie.html">DB_MPOOLFILE->set_pgcookie</a>, -<a href="../api_c/memp_stat.html">DB_ENV->memp_stat</a>, -<a href="../api_c/memp_sync.html">DB_ENV->memp_sync</a>, +<a href="../api_c/memp_set_pgcookie.html">DB_MPOOLFILE->set_pgcookie</a> and -<a href="../api_c/memp_trickle.html">DB_ENV->memp_trickle</a>. +<a href="../api_c/memp_fsync.html">DB_MPOOLFILE->sync</a>. </tt> <table width="100%"><tr><td><br></td><td align=right> <a href="../api_c/c_index.html"><img src="../images/api.gif" alt="API"></a><a href="../reftoc.html"><img src="../images/ref.gif" alt="Ref"></a> diff --git a/db/docs/api_c/memp_set_clear_len.html b/db/docs/api_c/memp_set_clear_len.html index 02a90a849..e5de7ab2d 100644 --- a/db/docs/api_c/memp_set_clear_len.html +++ b/db/docs/api_c/memp_set_clear_len.html @@ -1,6 +1,7 @@ -<!--Id: memp_set_clear_len.so,v 10.2 2001/10/22 15:24:36 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: memp_set_clear_len.so,v 10.4 2002/06/24 14:49:27 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB: DB_MPOOLFILE->set_clear_len</title> @@ -30,32 +31,41 @@ page that should be set to nul when the page is created as a result of the <a href="../api_c/memp_fget.html#DB_MPOOL_CREATE">DB_MPOOL_CREATE</a> or <a href="../api_c/memp_fget.html#DB_MPOOL_NEW">DB_MPOOL_NEW</a> flags being specified to <a href="../api_c/memp_fget.html">DB_MPOOLFILE->get</a>. If no value is specified, or <b>len</b> is 0, the entire page is cleared. +<p>The DB_MPOOLFILE->set_clear_len function configures a file in the memory pool, not only +operations performed using the specified <a href="../api_c/memp_fcreate.html">DB_MPOOLFILE</a> handle. +<p>The DB_MPOOLFILE->set_clear_len interface may not be called after the <a href="../api_c/memp_fopen.html">DB_MPOOLFILE->open</a> +interface is called. +If the file is already open in the memory pool when +<a href="../api_c/memp_fopen.html">DB_MPOOLFILE->open</a> is called, the information specified to DB_MPOOLFILE->set_clear_len +must be consistent with the existing file or an error will be +returned. <p>The DB_MPOOLFILE->set_clear_len function returns a non-zero error value on failure and 0 on success. <h1>Errors</h1> <p>The DB_MPOOLFILE->set_clear_len function may fail and return a non-zero error for errors specified for other Berkeley DB and C library or system functions. -If a catastrophic error has occurred, the DB_MPOOLFILE->set_clear_len function may fail and return -<a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, in which case all subsequent Berkeley DB calls will fail -in the same way. +If a catastrophic error has occurred, the DB_MPOOLFILE->set_clear_len function may fail and +return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, +in which case all subsequent Berkeley DB calls will fail in the same way. <h1>See Also</h1> <a href="../api_c/env_set_cachesize.html">DB_ENV->set_cachesize</a>, <a href="../api_c/env_set_mp_mmapsize.html">DB_ENV->set_mp_mmapsize</a>, +<a href="../api_c/memp_register.html">DB_ENV->memp_register</a>, +<a href="../api_c/memp_stat.html">DB_ENV->memp_stat</a>, +<a href="../api_c/memp_sync.html">DB_ENV->memp_sync</a>, +<a href="../api_c/memp_trickle.html">DB_ENV->memp_trickle</a>, +<p> <a href="../api_c/memp_fcreate.html">DB_ENV->memp_fcreate</a>, <a href="../api_c/memp_fclose.html">DB_MPOOLFILE->close</a>, <a href="../api_c/memp_fget.html">DB_MPOOLFILE->get</a>, <a href="../api_c/memp_fopen.html">DB_MPOOLFILE->open</a>, <a href="../api_c/memp_fput.html">DB_MPOOLFILE->put</a>, <a href="../api_c/memp_fset.html">DB_MPOOLFILE->set</a>, -<a href="../api_c/memp_fsync.html">DB_MPOOLFILE->sync</a>, -<a href="../api_c/memp_register.html">DB_ENV->memp_register</a>, -<a href="../api_c/memp_set_clear_len.html">DB_MPOOLFILE->set_clear_len</a>, <a href="../api_c/memp_set_fileid.html">DB_MPOOLFILE->set_fileid</a>, +<a href="../api_c/memp_set_clear_len.html">DB_MPOOLFILE->set_clear_len</a>, <a href="../api_c/memp_set_ftype.html">DB_MPOOLFILE->set_ftype</a>, <a href="../api_c/memp_set_lsn_offset.html">DB_MPOOLFILE->set_lsn_offset</a>, -<a href="../api_c/memp_set_pgcookie.html">DB_MPOOLFILE->set_pgcookie</a>, -<a href="../api_c/memp_stat.html">DB_ENV->memp_stat</a>, -<a href="../api_c/memp_sync.html">DB_ENV->memp_sync</a>, +<a href="../api_c/memp_set_pgcookie.html">DB_MPOOLFILE->set_pgcookie</a> and -<a href="../api_c/memp_trickle.html">DB_ENV->memp_trickle</a>. +<a href="../api_c/memp_fsync.html">DB_MPOOLFILE->sync</a>. </tt> <table width="100%"><tr><td><br></td><td align=right> <a href="../api_c/c_index.html"><img src="../images/api.gif" alt="API"></a><a href="../reftoc.html"><img src="../images/ref.gif" alt="Ref"></a> diff --git a/db/docs/api_c/memp_set_fileid.html b/db/docs/api_c/memp_set_fileid.html index 90a73171a..2bfb51996 100644 --- a/db/docs/api_c/memp_set_fileid.html +++ b/db/docs/api_c/memp_set_fileid.html @@ -1,6 +1,7 @@ -<!--Id: memp_set_fileid.so,v 10.2 2001/10/22 15:24:36 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: memp_set_fileid.so,v 10.4 2002/06/24 14:49:27 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB: DB_MPOOLFILE->set_fileid</title> @@ -51,32 +52,37 @@ using the Berkeley DB access methods instead of calling the pool functions explicitly, or if the files in the memory pool are stored on filesystems in which the default values as described previously are invariant between process and across system reboots. +<p>The DB_MPOOLFILE->set_fileid function configures a file in the memory pool, not only +operations performed using the specified <a href="../api_c/memp_fcreate.html">DB_MPOOLFILE</a> handle. +<p>The DB_MPOOLFILE->set_fileid interface may not be called after the <a href="../api_c/memp_fopen.html">DB_MPOOLFILE->open</a> +interface is called. <p>The DB_MPOOLFILE->set_fileid function returns a non-zero error value on failure and 0 on success. <h1>Errors</h1> <p>The DB_MPOOLFILE->set_fileid function may fail and return a non-zero error for errors specified for other Berkeley DB and C library or system functions. -If a catastrophic error has occurred, the DB_MPOOLFILE->set_fileid function may fail and return -<a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, in which case all subsequent Berkeley DB calls will fail -in the same way. +If a catastrophic error has occurred, the DB_MPOOLFILE->set_fileid function may fail and +return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, +in which case all subsequent Berkeley DB calls will fail in the same way. <h1>See Also</h1> <a href="../api_c/env_set_cachesize.html">DB_ENV->set_cachesize</a>, <a href="../api_c/env_set_mp_mmapsize.html">DB_ENV->set_mp_mmapsize</a>, +<a href="../api_c/memp_register.html">DB_ENV->memp_register</a>, +<a href="../api_c/memp_stat.html">DB_ENV->memp_stat</a>, +<a href="../api_c/memp_sync.html">DB_ENV->memp_sync</a>, +<a href="../api_c/memp_trickle.html">DB_ENV->memp_trickle</a>, +<p> <a href="../api_c/memp_fcreate.html">DB_ENV->memp_fcreate</a>, <a href="../api_c/memp_fclose.html">DB_MPOOLFILE->close</a>, <a href="../api_c/memp_fget.html">DB_MPOOLFILE->get</a>, <a href="../api_c/memp_fopen.html">DB_MPOOLFILE->open</a>, <a href="../api_c/memp_fput.html">DB_MPOOLFILE->put</a>, <a href="../api_c/memp_fset.html">DB_MPOOLFILE->set</a>, -<a href="../api_c/memp_fsync.html">DB_MPOOLFILE->sync</a>, -<a href="../api_c/memp_register.html">DB_ENV->memp_register</a>, -<a href="../api_c/memp_set_clear_len.html">DB_MPOOLFILE->set_clear_len</a>, <a href="../api_c/memp_set_fileid.html">DB_MPOOLFILE->set_fileid</a>, +<a href="../api_c/memp_set_clear_len.html">DB_MPOOLFILE->set_clear_len</a>, <a href="../api_c/memp_set_ftype.html">DB_MPOOLFILE->set_ftype</a>, <a href="../api_c/memp_set_lsn_offset.html">DB_MPOOLFILE->set_lsn_offset</a>, -<a href="../api_c/memp_set_pgcookie.html">DB_MPOOLFILE->set_pgcookie</a>, -<a href="../api_c/memp_stat.html">DB_ENV->memp_stat</a>, -<a href="../api_c/memp_sync.html">DB_ENV->memp_sync</a>, +<a href="../api_c/memp_set_pgcookie.html">DB_MPOOLFILE->set_pgcookie</a> and -<a href="../api_c/memp_trickle.html">DB_ENV->memp_trickle</a>. +<a href="../api_c/memp_fsync.html">DB_MPOOLFILE->sync</a>. </tt> <table width="100%"><tr><td><br></td><td align=right> <a href="../api_c/c_index.html"><img src="../images/api.gif" alt="API"></a><a href="../reftoc.html"><img src="../images/ref.gif" alt="Ref"></a> diff --git a/db/docs/api_c/memp_set_ftype.html b/db/docs/api_c/memp_set_ftype.html index 512cb34ef..19b81b6be 100644 --- a/db/docs/api_c/memp_set_ftype.html +++ b/db/docs/api_c/memp_set_ftype.html @@ -1,6 +1,7 @@ -<!--Id: memp_set_ftype.so,v 10.2 2001/10/22 15:24:37 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: memp_set_ftype.so,v 10.4 2002/06/24 14:49:27 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB: DB_MPOOLFILE->set_ftype</title> @@ -31,32 +32,40 @@ written to, the backing filesystem store. The <b>ftype</b> argument must be the same as a <b>ftype</b> argument previously specified to the <a href="../api_c/memp_register.html">DB_ENV->memp_register</a> function. (See the <a href="../api_c/memp_register.html">DB_ENV->memp_register</a> documentation for more information.) +<p>The DB_MPOOLFILE->set_ftype function configures a file in the memory pool, not only +operations performed using the specified <a href="../api_c/memp_fcreate.html">DB_MPOOLFILE</a> handle. +<p>The DB_MPOOLFILE->set_ftype interface may not be called after the <a href="../api_c/memp_fopen.html">DB_MPOOLFILE->open</a> +interface is called. +If the file is already open in the memory pool when +<a href="../api_c/memp_fopen.html">DB_MPOOLFILE->open</a> is called, the information specified to DB_MPOOLFILE->set_ftype +will replace the existing information. <p>The DB_MPOOLFILE->set_ftype function returns a non-zero error value on failure and 0 on success. <h1>Errors</h1> <p>The DB_MPOOLFILE->set_ftype function may fail and return a non-zero error for errors specified for other Berkeley DB and C library or system functions. -If a catastrophic error has occurred, the DB_MPOOLFILE->set_ftype function may fail and return -<a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, in which case all subsequent Berkeley DB calls will fail -in the same way. +If a catastrophic error has occurred, the DB_MPOOLFILE->set_ftype function may fail and +return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, +in which case all subsequent Berkeley DB calls will fail in the same way. <h1>See Also</h1> <a href="../api_c/env_set_cachesize.html">DB_ENV->set_cachesize</a>, <a href="../api_c/env_set_mp_mmapsize.html">DB_ENV->set_mp_mmapsize</a>, +<a href="../api_c/memp_register.html">DB_ENV->memp_register</a>, +<a href="../api_c/memp_stat.html">DB_ENV->memp_stat</a>, +<a href="../api_c/memp_sync.html">DB_ENV->memp_sync</a>, +<a href="../api_c/memp_trickle.html">DB_ENV->memp_trickle</a>, +<p> <a href="../api_c/memp_fcreate.html">DB_ENV->memp_fcreate</a>, <a href="../api_c/memp_fclose.html">DB_MPOOLFILE->close</a>, <a href="../api_c/memp_fget.html">DB_MPOOLFILE->get</a>, <a href="../api_c/memp_fopen.html">DB_MPOOLFILE->open</a>, <a href="../api_c/memp_fput.html">DB_MPOOLFILE->put</a>, <a href="../api_c/memp_fset.html">DB_MPOOLFILE->set</a>, -<a href="../api_c/memp_fsync.html">DB_MPOOLFILE->sync</a>, -<a href="../api_c/memp_register.html">DB_ENV->memp_register</a>, -<a href="../api_c/memp_set_clear_len.html">DB_MPOOLFILE->set_clear_len</a>, <a href="../api_c/memp_set_fileid.html">DB_MPOOLFILE->set_fileid</a>, +<a href="../api_c/memp_set_clear_len.html">DB_MPOOLFILE->set_clear_len</a>, <a href="../api_c/memp_set_ftype.html">DB_MPOOLFILE->set_ftype</a>, <a href="../api_c/memp_set_lsn_offset.html">DB_MPOOLFILE->set_lsn_offset</a>, -<a href="../api_c/memp_set_pgcookie.html">DB_MPOOLFILE->set_pgcookie</a>, -<a href="../api_c/memp_stat.html">DB_ENV->memp_stat</a>, -<a href="../api_c/memp_sync.html">DB_ENV->memp_sync</a>, +<a href="../api_c/memp_set_pgcookie.html">DB_MPOOLFILE->set_pgcookie</a> and -<a href="../api_c/memp_trickle.html">DB_ENV->memp_trickle</a>. +<a href="../api_c/memp_fsync.html">DB_MPOOLFILE->sync</a>. </tt> <table width="100%"><tr><td><br></td><td align=right> <a href="../api_c/c_index.html"><img src="../images/api.gif" alt="API"></a><a href="../reftoc.html"><img src="../images/ref.gif" alt="Ref"></a> diff --git a/db/docs/api_c/memp_set_lsn_offset.html b/db/docs/api_c/memp_set_lsn_offset.html index 40941e6ea..fbc6e8a22 100644 --- a/db/docs/api_c/memp_set_lsn_offset.html +++ b/db/docs/api_c/memp_set_lsn_offset.html @@ -1,6 +1,7 @@ -<!--Id: memp_set_lsn_offset.so,v 10.2 2001/10/22 15:24:37 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: memp_set_lsn_offset.so,v 10.4 2002/06/24 14:49:28 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB: DB_MPOOLFILE->set_lsn_offset</title> @@ -29,32 +30,41 @@ DB_MPOOLFILE->set_lsn_offset(DB_MPOOLFILE *mpf, int32_t lsn_offset); of a log sequence number (<a href="../api_c/db_lsn.html">DB_LSN</a>) on the file's pages, for the purposes of page-flushing as part of transaction checkpoint. (See the <a href="../api_c/memp_sync.html">DB_ENV->memp_sync</a> documentation for more information.) +<p>The DB_MPOOLFILE->set_lsn_offset function configures a file in the memory pool, not only +operations performed using the specified <a href="../api_c/memp_fcreate.html">DB_MPOOLFILE</a> handle. +<p>The DB_MPOOLFILE->set_lsn_offset interface may not be called after the <a href="../api_c/memp_fopen.html">DB_MPOOLFILE->open</a> +interface is called. +If the file is already open in the memory pool when +<a href="../api_c/memp_fopen.html">DB_MPOOLFILE->open</a> is called, the information specified to DB_MPOOLFILE->set_lsn_offset +must be consistent with the existing file or an error will be +returned. <p>The DB_MPOOLFILE->set_lsn_offset function returns a non-zero error value on failure and 0 on success. <h1>Errors</h1> <p>The DB_MPOOLFILE->set_lsn_offset function may fail and return a non-zero error for errors specified for other Berkeley DB and C library or system functions. -If a catastrophic error has occurred, the DB_MPOOLFILE->set_lsn_offset function may fail and return -<a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, in which case all subsequent Berkeley DB calls will fail -in the same way. +If a catastrophic error has occurred, the DB_MPOOLFILE->set_lsn_offset function may fail and +return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, +in which case all subsequent Berkeley DB calls will fail in the same way. <h1>See Also</h1> <a href="../api_c/env_set_cachesize.html">DB_ENV->set_cachesize</a>, <a href="../api_c/env_set_mp_mmapsize.html">DB_ENV->set_mp_mmapsize</a>, +<a href="../api_c/memp_register.html">DB_ENV->memp_register</a>, +<a href="../api_c/memp_stat.html">DB_ENV->memp_stat</a>, +<a href="../api_c/memp_sync.html">DB_ENV->memp_sync</a>, +<a href="../api_c/memp_trickle.html">DB_ENV->memp_trickle</a>, +<p> <a href="../api_c/memp_fcreate.html">DB_ENV->memp_fcreate</a>, <a href="../api_c/memp_fclose.html">DB_MPOOLFILE->close</a>, <a href="../api_c/memp_fget.html">DB_MPOOLFILE->get</a>, <a href="../api_c/memp_fopen.html">DB_MPOOLFILE->open</a>, <a href="../api_c/memp_fput.html">DB_MPOOLFILE->put</a>, <a href="../api_c/memp_fset.html">DB_MPOOLFILE->set</a>, -<a href="../api_c/memp_fsync.html">DB_MPOOLFILE->sync</a>, -<a href="../api_c/memp_register.html">DB_ENV->memp_register</a>, -<a href="../api_c/memp_set_clear_len.html">DB_MPOOLFILE->set_clear_len</a>, <a href="../api_c/memp_set_fileid.html">DB_MPOOLFILE->set_fileid</a>, +<a href="../api_c/memp_set_clear_len.html">DB_MPOOLFILE->set_clear_len</a>, <a href="../api_c/memp_set_ftype.html">DB_MPOOLFILE->set_ftype</a>, <a href="../api_c/memp_set_lsn_offset.html">DB_MPOOLFILE->set_lsn_offset</a>, -<a href="../api_c/memp_set_pgcookie.html">DB_MPOOLFILE->set_pgcookie</a>, -<a href="../api_c/memp_stat.html">DB_ENV->memp_stat</a>, -<a href="../api_c/memp_sync.html">DB_ENV->memp_sync</a>, +<a href="../api_c/memp_set_pgcookie.html">DB_MPOOLFILE->set_pgcookie</a> and -<a href="../api_c/memp_trickle.html">DB_ENV->memp_trickle</a>. +<a href="../api_c/memp_fsync.html">DB_MPOOLFILE->sync</a>. </tt> <table width="100%"><tr><td><br></td><td align=right> <a href="../api_c/c_index.html"><img src="../images/api.gif" alt="API"></a><a href="../reftoc.html"><img src="../images/ref.gif" alt="Ref"></a> diff --git a/db/docs/api_c/memp_set_pgcookie.html b/db/docs/api_c/memp_set_pgcookie.html index bcfaa8e12..7e9e76133 100644 --- a/db/docs/api_c/memp_set_pgcookie.html +++ b/db/docs/api_c/memp_set_pgcookie.html @@ -1,6 +1,7 @@ -<!--Id: memp_set_pgcookie.so,v 10.2 2001/10/22 15:24:37 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: memp_set_pgcookie.so,v 10.4 2002/06/24 14:49:28 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB: DB_MPOOLFILE->set_pgcookie</title> @@ -30,32 +31,40 @@ to the functions registered to do input or output processing of the file's pages as they are read from or written to, the backing filesystem store. (See the <a href="../api_c/memp_register.html">DB_ENV->memp_register</a> documentation for more information.) +<p>The DB_MPOOLFILE->set_pgcookie function configures a file in the memory pool, not only +operations performed using the specified <a href="../api_c/memp_fcreate.html">DB_MPOOLFILE</a> handle. +<p>The DB_MPOOLFILE->set_pgcookie interface may not be called after the <a href="../api_c/memp_fopen.html">DB_MPOOLFILE->open</a> +interface is called. +If the file is already open in the memory pool when +<a href="../api_c/memp_fopen.html">DB_MPOOLFILE->open</a> is called, the information specified to DB_MPOOLFILE->set_pgcookie +will replace the existing information. <p>The DB_MPOOLFILE->set_pgcookie function returns a non-zero error value on failure and 0 on success. <h1>Errors</h1> <p>The DB_MPOOLFILE->set_pgcookie function may fail and return a non-zero error for errors specified for other Berkeley DB and C library or system functions. -If a catastrophic error has occurred, the DB_MPOOLFILE->set_pgcookie function may fail and return -<a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, in which case all subsequent Berkeley DB calls will fail -in the same way. +If a catastrophic error has occurred, the DB_MPOOLFILE->set_pgcookie function may fail and +return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, +in which case all subsequent Berkeley DB calls will fail in the same way. <h1>See Also</h1> <a href="../api_c/env_set_cachesize.html">DB_ENV->set_cachesize</a>, <a href="../api_c/env_set_mp_mmapsize.html">DB_ENV->set_mp_mmapsize</a>, +<a href="../api_c/memp_register.html">DB_ENV->memp_register</a>, +<a href="../api_c/memp_stat.html">DB_ENV->memp_stat</a>, +<a href="../api_c/memp_sync.html">DB_ENV->memp_sync</a>, +<a href="../api_c/memp_trickle.html">DB_ENV->memp_trickle</a>, +<p> <a href="../api_c/memp_fcreate.html">DB_ENV->memp_fcreate</a>, <a href="../api_c/memp_fclose.html">DB_MPOOLFILE->close</a>, <a href="../api_c/memp_fget.html">DB_MPOOLFILE->get</a>, <a href="../api_c/memp_fopen.html">DB_MPOOLFILE->open</a>, <a href="../api_c/memp_fput.html">DB_MPOOLFILE->put</a>, <a href="../api_c/memp_fset.html">DB_MPOOLFILE->set</a>, -<a href="../api_c/memp_fsync.html">DB_MPOOLFILE->sync</a>, -<a href="../api_c/memp_register.html">DB_ENV->memp_register</a>, -<a href="../api_c/memp_set_clear_len.html">DB_MPOOLFILE->set_clear_len</a>, <a href="../api_c/memp_set_fileid.html">DB_MPOOLFILE->set_fileid</a>, +<a href="../api_c/memp_set_clear_len.html">DB_MPOOLFILE->set_clear_len</a>, <a href="../api_c/memp_set_ftype.html">DB_MPOOLFILE->set_ftype</a>, <a href="../api_c/memp_set_lsn_offset.html">DB_MPOOLFILE->set_lsn_offset</a>, -<a href="../api_c/memp_set_pgcookie.html">DB_MPOOLFILE->set_pgcookie</a>, -<a href="../api_c/memp_stat.html">DB_ENV->memp_stat</a>, -<a href="../api_c/memp_sync.html">DB_ENV->memp_sync</a>, +<a href="../api_c/memp_set_pgcookie.html">DB_MPOOLFILE->set_pgcookie</a> and -<a href="../api_c/memp_trickle.html">DB_ENV->memp_trickle</a>. +<a href="../api_c/memp_fsync.html">DB_MPOOLFILE->sync</a>. </tt> <table width="100%"><tr><td><br></td><td align=right> <a href="../api_c/c_index.html"><img src="../images/api.gif" alt="API"></a><a href="../reftoc.html"><img src="../images/ref.gif" alt="Ref"></a> diff --git a/db/docs/api_c/rep_elect.html b/db/docs/api_c/rep_elect.html index 609eae899..76b396dc3 100644 --- a/db/docs/api_c/rep_elect.html +++ b/db/docs/api_c/rep_elect.html @@ -1,6 +1,7 @@ -<!--Id: rep_elect.so,v 1.4 2001/10/26 13:57:00 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: rep_elect.so,v 1.6 2002/06/24 14:49:30 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB: DB_ENV->rep_elect</title> @@ -64,13 +65,13 @@ incoming messages is necessary to successfully complete an election. <p><dt>DB_REP_UNAVAIL<dd>The replication group was unable to elect a master. </dl> <p>The DB_ENV->rep_elect function may fail and return a non-zero error for errors specified for other Berkeley DB and C library or system functions. -If a catastrophic error has occurred, the DB_ENV->rep_elect function may fail and return -<a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, in which case all subsequent Berkeley DB calls will fail -in the same way. +If a catastrophic error has occurred, the DB_ENV->rep_elect function may fail and +return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, +in which case all subsequent Berkeley DB calls will fail in the same way. <h1>See Also</h1> <a href="../api_c/rep_start.html">DB_ENV->rep_start</a>, <a href="../api_c/rep_elect.html">DB_ENV->rep_elect</a>, -<a href="../api_c/rep_message.html">DB_ENV->rep_process_message</a>, +<a href="../api_c/rep_message.html">DB_ENV->rep_process_message</a> and <a href="../api_c/rep_transport.html">DB_ENV->set_rep_transport</a>. </tt> diff --git a/db/docs/api_c/rep_message.html b/db/docs/api_c/rep_message.html index ef61b5e49..56d7c8078 100644 --- a/db/docs/api_c/rep_message.html +++ b/db/docs/api_c/rep_message.html @@ -1,6 +1,7 @@ -<!--Id: rep_message.so,v 1.4 2001/10/25 20:15:23 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: rep_message.so,v 1.9 2002/07/02 15:22:24 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB: DB_ENV->rep_process_message</title> @@ -40,37 +41,43 @@ information). processed using the same <a href="../api_c/env_create.html">DB_ENV</a> handle. It is not required that a single thread of control process all messages, only that all threads of control processing messages use the same handle. -<p>The DB_ENV->rep_process_message function may return one of several special conditions: -<p><dl compact> -<p><dt><a name="DB_REP_DUPMASTER">DB_REP_DUPMASTER</a><dd>The replication group has more than one master; the application should -reconfigure itself as a client by calling the <a href="../api_c/rep_start.html">DB_ENV->rep_start</a> function, and -then call for an election by calling <a href="../api_c/rep_elect.html">DB_ENV->rep_elect</a>. -<p><dt><a name="DB_REP_HOLDELECTION">DB_REP_HOLDELECTION</a><dd>An election is needed, the application should call for an election by -calling <a href="../api_c/rep_elect.html">DB_ENV->rep_elect</a>. -<p><dt><a name="DB_REP_NEWMASTER">DB_REP_NEWMASTER</a><dd>A new master has been elected. The memory location referenced by the -<b>envid</b> parameter contains the environment ID of the new master. -If the recipient of this error return has been made master, it is the -application's responsibility to begin acting as the master environment. -<p><dt><a name="DB_REP_NEWSITE">DB_REP_NEWSITE</a><dd>The system received contact information from a new environment. The -<b>rec</b> parameter contains the opaque data specified in the +<p> +If a new master has been elected, the DB_ENV->rep_process_message function will return DB_REP_NEWMASTER. +The <b>envid</b> parameter contains the environment ID of the new +master. If the recipient of this error return has been made master, it +is the application's responsibility to begin acting as the master +environment. +<p> +If the system received contact information from a new environment, the DB_ENV->rep_process_message function will return DB_REP_NEWSITE. +The <b>rec</b> parameter contains the opaque data specified in the <b>cdata</b> parameter to the <a href="../api_c/rep_start.html">DB_ENV->rep_start</a>. The application should take whatever action is needed to establish a communication channel with this new environment. -<p><dt><a name="DB_REP_OUTDATED">DB_REP_OUTDATED</a><dd>The current environment's logs are too far out of date with respect to -the master to be automatically synchronized. The application should -copy over a hot backup of the environment, run recovery, and restart -the client. -</dl> -<p>Otherwise, the DB_ENV->rep_process_message function returns a non-zero error value on failure and 0 on success. +<p> +If the replication group has more than one master, the DB_ENV->rep_process_message function will return DB_REP_DUPMASTER. +The application should reconfigure itself as a client by calling the +<a href="../api_c/rep_start.html">DB_ENV->rep_start</a> function, and then call for an election by calling +<a href="../api_c/rep_elect.html">DB_ENV->rep_elect</a>. +<p> +If an election is needed, the DB_ENV->rep_process_message function will return DB_REP_HOLDELECTION. +The application should call for an election by +calling <a href="../api_c/rep_elect.html">DB_ENV->rep_elect</a>. +<p> +If the current environment's logs are too far out of date with respect +to the master to be automatically synchronized, the DB_ENV->rep_process_message function will return DB_REP_OUTDATED. The +application should copy over a hot backup of the environment, run +recovery, and restart the client. +<p> +Otherwise, the DB_ENV->rep_process_message function returns a non-zero error value on failure and 0 on success. <h1>Errors</h1> <p>The DB_ENV->rep_process_message function may fail and return a non-zero error for errors specified for other Berkeley DB and C library or system functions. -If a catastrophic error has occurred, the DB_ENV->rep_process_message function may fail and return -<a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, in which case all subsequent Berkeley DB calls will fail -in the same way. +If a catastrophic error has occurred, the DB_ENV->rep_process_message function may fail and +return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, +in which case all subsequent Berkeley DB calls will fail in the same way. <h1>See Also</h1> <a href="../api_c/rep_start.html">DB_ENV->rep_start</a>, <a href="../api_c/rep_elect.html">DB_ENV->rep_elect</a>, -<a href="../api_c/rep_message.html">DB_ENV->rep_process_message</a>, +<a href="../api_c/rep_message.html">DB_ENV->rep_process_message</a> and <a href="../api_c/rep_transport.html">DB_ENV->set_rep_transport</a>. </tt> diff --git a/db/docs/api_c/rep_start.html b/db/docs/api_c/rep_start.html index b4b7be4c5..ab320ccbd 100644 --- a/db/docs/api_c/rep_start.html +++ b/db/docs/api_c/rep_start.html @@ -1,6 +1,7 @@ -<!--Id: rep_start.so,v 1.2 2001/10/25 14:08:43 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: rep_start.so,v 1.3 2002/06/24 14:49:30 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB: DB_ENV->rep_start</title> @@ -56,13 +57,13 @@ replication group by a call to <a href="../api_c/rep_transport.html">DB_ENV-> <p>The environment was not already opened. </dl> <p>The DB_ENV->rep_start function may fail and return a non-zero error for errors specified for other Berkeley DB and C library or system functions. -If a catastrophic error has occurred, the DB_ENV->rep_start function may fail and return -<a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, in which case all subsequent Berkeley DB calls will fail -in the same way. +If a catastrophic error has occurred, the DB_ENV->rep_start function may fail and +return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, +in which case all subsequent Berkeley DB calls will fail in the same way. <h1>See Also</h1> <a href="../api_c/rep_start.html">DB_ENV->rep_start</a>, <a href="../api_c/rep_elect.html">DB_ENV->rep_elect</a>, -<a href="../api_c/rep_message.html">DB_ENV->rep_process_message</a>, +<a href="../api_c/rep_message.html">DB_ENV->rep_process_message</a> and <a href="../api_c/rep_transport.html">DB_ENV->set_rep_transport</a>. </tt> diff --git a/db/docs/api_c/rep_transport.html b/db/docs/api_c/rep_transport.html index ac3d59f18..dd935940a 100644 --- a/db/docs/api_c/rep_transport.html +++ b/db/docs/api_c/rep_transport.html @@ -1,6 +1,7 @@ -<!--Id: rep_transport.so,v 1.4 2001/10/26 23:51:06 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: rep_transport.so,v 1.7 2002/06/24 14:49:30 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB: DB_ENV->set_rep_transport</title> @@ -51,7 +52,7 @@ The special identifier DB_EID_BROADCAST indicates that a message should be broadcast to every environment in the replication group. The application may use a true broadcast protocol, or may send the message in sequence to each machine with which it is in communication. -<p><dt>flag<dd> +<p><dt>flags<dd> <p>The <b>flags</b> value must be set to 0 or by bitwise inclusively <b>OR</b>'ing together one or more of the following values: <p><dl compact> @@ -70,17 +71,21 @@ otherwise, any error from the <b>send</b> interface will be ignored. <p>It may sometimes be useful to pass application-specific data to the <b>send</b> interface; see <a href="../ref/env/faq.html">Environment FAQ</a> for a discussion on how to do this. -<p>The <b>flags</b> parameter is currently unused, and must be set to 0. +<p>The DB_ENV->set_rep_transport function configures operations performed using the specified +<a href="../api_c/env_create.html">DB_ENV</a> handle, not all operations performed on the underlying +database environment. +<p>The DB_ENV->set_rep_transport interface may be called at any time during the life of +the application. <p>The DB_ENV->set_rep_transport function returns a non-zero error value on failure and 0 on success. <h1>Errors</h1> <p>The DB_ENV->set_rep_transport function may fail and return a non-zero error for errors specified for other Berkeley DB and C library or system functions. -If a catastrophic error has occurred, the DB_ENV->set_rep_transport function may fail and return -<a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, in which case all subsequent Berkeley DB calls will fail -in the same way. +If a catastrophic error has occurred, the DB_ENV->set_rep_transport function may fail and +return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, +in which case all subsequent Berkeley DB calls will fail in the same way. <h1>See Also</h1> <a href="../api_c/rep_start.html">DB_ENV->rep_start</a>, <a href="../api_c/rep_elect.html">DB_ENV->rep_elect</a>, -<a href="../api_c/rep_message.html">DB_ENV->rep_process_message</a>, +<a href="../api_c/rep_message.html">DB_ENV->rep_process_message</a> and <a href="../api_c/rep_transport.html">DB_ENV->set_rep_transport</a>. </tt> diff --git a/db/docs/api_c/txn_set_timeout.html b/db/docs/api_c/txn_set_timeout.html index 4bd06a7a6..6c008523c 100644 --- a/db/docs/api_c/txn_set_timeout.html +++ b/db/docs/api_c/txn_set_timeout.html @@ -1,6 +1,7 @@ -<!--Id: txn_set_timeout.so,v 10.3 2001/10/22 15:24:39 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: txn_set_timeout.so,v 10.6 2002/06/24 14:49:36 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB: DB_TXN->set_timeout</title> @@ -46,6 +47,11 @@ is performed, the accuracy of the timeout depends on how often deadlock detection is performed. <p>Timeout values may be specified for the database environment as a whole. See <a href="../api_c/env_set_timeout.html">DB_ENV->set_timeout</a> and for more information. +<p>The DB_TXN->set_timeout function configures operations performed on the underlying +transaction, not only operations performed using the specified +<a href="../api_c/txn_begin.html">DB_TXN</a> handle. +<p>The DB_TXN->set_timeout interface may be called at any time during the life of +the application. <p>The DB_TXN->set_timeout function returns a non-zero error value on failure and 0 on success. <h1>Errors</h1> <p>The DB_TXN->set_timeout function may fail and return a non-zero error for the following conditions: @@ -53,24 +59,25 @@ See <a href="../api_c/env_set_timeout.html">DB_ENV->set_timeout</a> and for m <p><dt>EINVAL<dd>An invalid flag value or parameter was specified. </dl> <p>The DB_TXN->set_timeout function may fail and return a non-zero error for errors specified for other Berkeley DB and C library or system functions. -If a catastrophic error has occurred, the DB_TXN->set_timeout function may fail and return -<a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, in which case all subsequent Berkeley DB calls will fail -in the same way. +If a catastrophic error has occurred, the DB_TXN->set_timeout function may fail and +return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, +in which case all subsequent Berkeley DB calls will fail in the same way. <h1>See Also</h1> <a href="../api_c/env_set_tx_max.html">DB_ENV->set_tx_max</a>, -<a href="../api_c/env_set_tx_recover.html">DB_ENV->set_tx_recover</a>, <a href="../api_c/env_set_tx_timestamp.html">DB_ENV->set_tx_timestamp</a>, -<a href="../api_c/txn_abort.html">DB_TXN->abort</a>, <a href="../api_c/txn_begin.html">DB_ENV->txn_begin</a>, <a href="../api_c/txn_checkpoint.html">DB_ENV->txn_checkpoint</a>, +<a href="../api_c/txn_recover.html">DB_ENV->txn_recover</a> +and +<a href="../api_c/txn_stat.html">DB_ENV->txn_stat</a>. +<p> +<a href="../api_c/txn_abort.html">DB_TXN->abort</a>, <a href="../api_c/txn_commit.html">DB_TXN->commit</a>, <a href="../api_c/txn_discard.html">DB_TXN->discard</a>, <a href="../api_c/txn_id.html">DB_TXN->id</a>, -<a href="../api_c/txn_prepare.html">DB_TXN->prepare</a>, -<a href="../api_c/txn_recover.html">DB_ENV->txn_recover</a>, -<a href="../api_c/txn_set_timeout.html">DB_TXN->set_timeout</a> +<a href="../api_c/txn_prepare.html">DB_TXN->prepare</a> and -<a href="../api_c/txn_stat.html">DB_ENV->txn_stat</a>. +<a href="../api_c/txn_set_timeout.html">DB_TXN->set_timeout</a>. </tt> <table width="100%"><tr><td><br></td><td align=right> <a href="../api_c/c_index.html"><img src="../images/api.gif" alt="API"></a><a href="../reftoc.html"><img src="../images/ref.gif" alt="Ref"></a> diff --git a/db/docs/api_cxx/c_index.html b/db/docs/api_cxx/c_index.html index 8aba44c15..3958b8f0a 100644 --- a/db/docs/api_cxx/c_index.html +++ b/db/docs/api_cxx/c_index.html @@ -1,24 +1,31 @@ -<!--Id: c_index.so,v 10.80 2001/10/13 19:56:20 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: c_index.so,v 10.96 2002/07/24 05:06:08 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> -<title>Berkeley DB: C++ Interface</title> +<title>Berkeley DB: Berkeley DB: C++ Interface</title> <meta name="description" content="Berkeley DB: An embedded database programmatic toolkit."> <meta name="keywords" content="embedded,database,programmatic,toolkit,b+tree,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,java,C,C++"> </head> <body bgcolor=white> -<h1 align=center>C++ Interface</h1> +<h1 align=center>Berkeley DB: C++ Interface</h1> <p><table border=1 align=center> <tr><th>Section</th><th>Class/Method</th><th>Description</th></tr> <tr><td><b>Database Environment</b></td><td><a href="../api_cxx/dbenv_class.html">DbEnv</a></td><td>Create an environment handle</td></tr> <tr><td><br></td><td><a href="../api_cxx/env_close.html">DbEnv::close</a></td><td>Close an environment</td></tr> +<tr><td><br></td><td><a href="../api_cxx/env_dbremove.html">DbEnv::dbremove</a></td><td>Remove a database</td></tr> +<tr><td><br></td><td><a href="../api_cxx/env_dbrename.html">DbEnv::dbrename</a></td><td>Rename a database</td></tr> <tr><td><br></td><td><a href="../api_cxx/env_err.html">DbEnv::err</a></td><td>Error message with error string</td></tr> <tr><td><br></td><td><a href="../api_cxx/env_err.html">DbEnv::errx</a></td><td>Error message</td></tr> <tr><td><br></td><td><a href="../api_cxx/env_open.html">DbEnv::open</a></td><td>Open an environment</td></tr> <tr><td><br></td><td><a href="../api_cxx/env_remove.html">DbEnv::remove</a></td><td>Remove an environment</td></tr> +<tr><td><br></td><td><a href="../api_cxx/env_strerror.html">DbEnv::strerror</a></td><td>Error strings</td></tr> +<tr><td><br></td><td><a href="../api_cxx/env_version.html">DbEnv::version</a></td><td>Return version information</td></tr> +<tr><td><b>Environment Configuration</b></td><td><a href="../api_cxx/env_set_app_dispatch.html">DbEnv::set_app_dispatch</a></td><td>Configure application recovery interface</td></tr> <tr><td><br></td><td><a href="../api_cxx/env_set_alloc.html">DbEnv::set_alloc</a></td><td>Set local space allocation functions</td></tr> <tr><td><br></td><td><a href="../api_cxx/env_set_data_dir.html">DbEnv::set_data_dir</a></td><td>Set the environment data directory</td></tr> +<tr><td><br></td><td><a href="../api_cxx/env_set_encrypt.html">DbEnv::set_encrypt</a></td><td>Set the environment cryptographic key</td></tr> <tr><td><br></td><td><a href="../api_cxx/env_set_errcall.html">DbEnv::set_errcall</a></td><td>Set error message callback</td></tr> <tr><td><br></td><td><a href="../api_cxx/env_set_errfile.html">DbEnv::set_errfile</a></td><td>Set error message FILE</td></tr> <tr><td><br></td><td><a href="../api_cxx/env_set_error_stream.html">DbEnv::set_error_stream</a></td><td>Set error message output stream</td></tr> @@ -26,19 +33,18 @@ <tr><td><br></td><td><a href="../api_cxx/env_set_feedback.html">DbEnv::set_feedback</a></td><td>Set feedback callback</td></tr> <tr><td><br></td><td><a href="../api_cxx/env_set_flags.html">DbEnv::set_flags</a></td><td>Environment configuration</td></tr> <tr><td><br></td><td><a href="../api_cxx/env_set_paniccall.html">DbEnv::set_paniccall</a></td><td>Set panic callback</td></tr> -<tr><td><br></td><td><a href="../api_cxx/env_set_rec_init.html">DbEnv::set_recovery_init</a></td><td>Set recovery initialization callback</td></tr> <tr><td><br></td><td><a href="../api_cxx/env_set_rpc_server.html">DbEnv::set_rpc_server</a></td><td>Establish an RPC server connection</td></tr> <tr><td><br></td><td><a href="../api_cxx/env_set_shm_key.html">DbEnv::set_shm_key</a></td><td>Set system memory shared segment ID</td></tr> <tr><td><br></td><td><a href="../api_cxx/env_set_tas_spins.html">DbEnv::set_tas_spins</a></td><td>Set the number of test-and-set spins</td></tr> <tr><td><br></td><td><a href="../api_cxx/env_set_tmp_dir.html">DbEnv::set_tmp_dir</a></td><td>Set the environment temporary file directory</td></tr> <tr><td><br></td><td><a href="../api_cxx/env_set_timeout.html">DbEnv::set_timeout</a></td><td>Set lock and transaction timeout</td></tr> <tr><td><br></td><td><a href="../api_cxx/env_set_verbose.html">DbEnv::set_verbose</a></td><td>Set verbose messages</td></tr> -<tr><td><br></td><td><a href="../api_cxx/env_strerror.html">DbEnv::strerror</a></td><td>Error strings</td></tr> -<tr><td><br></td><td><a href="../api_cxx/env_version.html">DbEnv::version</a></td><td>Return version information</td></tr> <tr><td><b>Database Operations</b></td><td><a href="../api_cxx/db_class.html">Db</a></td><td>Create a database handle</td></tr> <tr><td><br></td><td><a href="../api_cxx/db_associate.html">Db::associate</a></td><td>Associate a secondary index</td></tr> <tr><td><br></td><td><a href="../api_cxx/db_close.html">Db::close</a></td><td>Close a database</td></tr> <tr><td><br></td><td><a href="../api_cxx/db_del.html">Db::del</a></td><td>Delete items from a database</td></tr> +<tr><td><br></td><td><a href="../api_cxx/db_err.html">Db::err</a></td><td>Error message with error string</td></tr> +<tr><td><br></td><td><a href="../api_cxx/db_err.html">Db::errx</a></td><td>Error message</td></tr> <tr><td><br></td><td><a href="../api_cxx/db_fd.html">Db::fd</a></td><td>Return a file descriptor from a database</td></tr> <tr><td><br></td><td><a href="../api_cxx/db_get.html">Db::get</a>, <a href="../api_cxx/db_get.html">Db::pget</a></td><td>Get items from a database</td></tr> <tr><td><br></td><td><a href="../api_cxx/db_get_byteswapped.html">Db::get_byteswapped</a></td><td>Return if the underlying database is in host order</td></tr> @@ -54,16 +60,17 @@ <tr><td><br></td><td><a href="../api_cxx/db_truncate.html">Db::truncate</a></td><td>Empty a database</td></tr> <tr><td><br></td><td><a href="../api_cxx/db_upgrade.html">Db::upgrade</a></td><td>Upgrade a database</td></tr> <tr><td><br></td><td><a href="../api_cxx/db_verify.html">Db::verify</a></td><td>Verify/salvage a database</td></tr> -<tr><td><b>Database Configuration</b></td><td><a href="../api_cxx/db_err.html">Db::err</a></td><td>Error message with error string</td></tr> -<tr><td><br></td><td><a href="../api_cxx/db_err.html">Db::errx</a></td><td>Error message</td></tr> -<tr><td><br></td><td><a href="../api_cxx/db_set_alloc.html">Db::set_alloc</a></td><td>Set local space allocation functions</td></tr> +<tr><td><b>Database Configuration</b></td><td><a href="../api_cxx/db_set_alloc.html">Db::set_alloc</a></td><td>Set local space allocation functions</td></tr> +<tr><td><br></td><td><a href="../api_cxx/db_set_cache_priority.html">Db::set_cache_priority</a></td><td>Set the database cache priority</td></tr> <tr><td><br></td><td><a href="../api_cxx/db_set_cachesize.html">Db::set_cachesize</a></td><td>Set the database cache size</td></tr> <tr><td><br></td><td><a href="../api_cxx/db_set_dup_compare.html">Db::set_dup_compare</a></td><td>Set a duplicate comparison function</td></tr> +<tr><td><br></td><td><a href="../api_cxx/db_set_encrypt.html">Db::set_encrypt</a></td><td>Set the database cryptographic key</td></tr> <tr><td><br></td><td><a href="../api_cxx/db_set_errcall.html">Db::set_errcall</a></td><td>Set error message callback</td></tr> <tr><td><br></td><td><a href="../api_cxx/db_set_errfile.html">Db::set_errfile</a></td><td>Set error message FILE</td></tr> <tr><td><br></td><td><a href="../api_cxx/db_set_errpfx.html">Db::set_errpfx</a></td><td>Set error message prefix</td></tr> <tr><td><br></td><td><a href="../api_cxx/db_set_feedback.html">Db::set_feedback</a></td><td>Set feedback callback</td></tr> <tr><td><br></td><td><a href="../api_cxx/db_set_flags.html">Db::set_flags</a></td><td>General database configuration</td></tr> +<tr><td><br></td><td><a href="../api_cxx/db_set_lorder.html">Db::set_lorder</a></td><td>Set the database byte order</td></tr> <tr><td><br></td><td><a href="../api_cxx/db_set_pagesize.html">Db::set_pagesize</a></td><td>Set the underlying database page size</td></tr> <tr><td><br></td><td><a href="../api_cxx/db_set_paniccall.html">Db::set_paniccall</a></td><td>Set panic callback</td></tr> <tr><td><b>Btree/Recno Configuration</b></td><td><a href="../api_cxx/db_set_append_recno.html">Db::set_append_recno</a></td><td>Set record append callback</td></tr> @@ -77,7 +84,6 @@ <tr><td><b>Hash Configuration</b></td><td><a href="../api_cxx/db_set_h_ffactor.html">Db::set_h_ffactor</a></td><td>Set the Hash table density</td></tr> <tr><td><br></td><td><a href="../api_cxx/db_set_h_hash.html">Db::set_h_hash</a></td><td>Set a hashing function</td></tr> <tr><td><br></td><td><a href="../api_cxx/db_set_h_nelem.html">Db::set_h_nelem</a></td><td>Set the Hash table size</td></tr> -<tr><td><br></td><td><a href="../api_cxx/db_set_lorder.html">Db::set_lorder</a></td><td>Set the database byte order</td></tr> <tr><td><b>Queue Configuration</b></td><td><a href="../api_cxx/db_set_q_extentsize.html">Db::set_q_extentsize</a></td><td>Set Queue database extent size</td></tr> <tr><td><b>Database Cursor Operations</b></td><td><a href="../api_cxx/dbc_class.html">Dbc</a></td><td><b>Cursor class</b></td></tr> <tr><td><br></td><td><a href="../api_cxx/db_cursor.html">Db::cursor</a></td><td>Create a cursor handle</td></tr> @@ -109,13 +115,11 @@ <tr><td><br></td><td><a href="../api_cxx/log_file.html">DbEnv::log_file</a></td><td>Map Log Sequence Numbers to log files</td></tr> <tr><td><br></td><td><a href="../api_cxx/log_flush.html">DbEnv::log_flush</a></td><td>Flush log records</td></tr> <tr><td><br></td><td><a href="../api_cxx/log_put.html">DbEnv::log_put</a></td><td>Write a log record</td></tr> -<tr><td><br></td><td><a href="../api_cxx/log_register.html">DbEnv::log_register</a></td><td>Register a filename with the log manager</td></tr> <tr><td><br></td><td><a href="../api_cxx/log_stat.html">DbEnv::log_stat</a></td><td>Return log subsystem statistics</td></tr> -<tr><td><br></td><td><a href="../api_cxx/log_unregister.html">DbEnv::log_unregister</a></td><td>Unregister a filename with the log manager</td></tr> <tr><td><b>Log Cursor Operations</b></td><td><a href="../api_cxx/logc_class.html">DbLogc</a></td><td><b>Log cursor class</b></td></tr> <tr><td><br></td><td><a href="../api_cxx/log_cursor.html">DbEnv::log_cursor</a></td><td>Create a log cursor handle</td></tr> -<tr><td><br></td><td><a href="../api_cxx/logc_close.html">DbLogc::logc_close</a></td><td>Close a log cursor</td></tr> -<tr><td><br></td><td><a href="../api_cxx/logc_get.html">DbLogc::logc_get</a></td><td>Retrieve a log record</td></tr> +<tr><td><br></td><td><a href="../api_cxx/logc_close.html">DbLogc::close</a></td><td>Close a log cursor</td></tr> +<tr><td><br></td><td><a href="../api_cxx/logc_get.html">DbLogc::get</a></td><td>Retrieve a log record</td></tr> <tr><td><b>Log Sequence Numbers</b></td><td><a href="../api_cxx/lsn_class.html">DbLsn</a></td><td><br></td></tr> <tr><td><br></td><td><a href="../api_cxx/log_compare.html">DbEnv::log_compare</a></td><td>Compare two Log Sequence Numbers</td></tr> <tr><td><b>Memory Pool Subsystem</b></td><td><a href="../api_cxx/env_set_cachesize.html">DbEnv::set_cachesize</a></td><td>Set the environment cache size</td></tr> @@ -138,7 +142,6 @@ <tr><td><br></td><td><a href="../api_cxx/memp_set_lsn_offset.html">DbMpoolFile::set_lsn_offset</a></td><td>Set file log-sequence-number offset</td></tr> <tr><td><br></td><td><a href="../api_cxx/memp_set_pgcookie.html">DbMpoolFile::set_pgcookie</a></td><td>Set file cookie for pgin/pgout</td></tr> <tr><td><b>Transaction Subsystem</b></td><td><a href="../api_cxx/env_set_tx_max.html">DbEnv::set_tx_max</a></td><td>Set maximum number of transactions</td></tr> -<tr><td><br></td><td><a href="../api_cxx/env_set_tx_recover.html">DbEnv::set_tx_recover</a></td><td>Set transaction abort recover function</td></tr> <tr><td><br></td><td><a href="../api_cxx/env_set_tx_timestamp.html">DbEnv::set_tx_timestamp</a></td><td>Set recovery timestamp</td></tr> <tr><td><br></td><td><a href="../api_cxx/txn_checkpoint.html">DbEnv::txn_checkpoint</a></td><td>Checkpoint the transaction subsystem</td></tr> <tr><td><br></td><td><a href="../api_cxx/txn_recover.html">DbEnv::txn_recover</a></td><td>Distributed transaction recovery</td></tr> @@ -153,13 +156,17 @@ <tr><td><br></td><td><a href="../api_cxx/txn_set_timeout.html">DbTxn::set_timeout</a></td><td>Set transaction timeout</td></tr> <tr><td><b>Replication</b></td><td><a href="../api_cxx/rep_transport.html">DbEnv::set_rep_transport</a></td><td>Configure replication transport</td></tr> <tr><td><br></td><td><a href="../api_cxx/rep_elect.html">DbEnv::rep_elect</a></td><td>Hold a replication election</td></tr> +<tr><td><br></td><td><a href="../api_cxx/rep_limit.html">DbEnv::set_rep_limit</a></td><td>Limit data sent in response to a single message</td></tr> <tr><td><br></td><td><a href="../api_cxx/rep_message.html">DbEnv::rep_process_message</a></td><td>Process a replication message</td></tr> <tr><td><br></td><td><a href="../api_cxx/rep_start.html">DbEnv::rep_start</a></td><td>Configure an environment for replication</td></tr> +<tr><td><br></td><td><a href="../api_cxx/rep_stat.html">DbEnv::rep_stat</a></td><td>Replication statistics</td></tr> <tr><td><b>Exceptions</b></td><td><a href="../api_cxx/except_class.html">DbException</a></td><td><b>Exception Class for Berkeley DB Activity</b></td></tr> <tr><td><br></td><td><a href="../api_cxx/get_errno.html">DbException::get_errno</a></td><td>Get the error value</td></tr> <tr><td><br></td><td><a href="../api_cxx/what.html">DbException::what</a></td><td>Get the error string</td></tr> +<tr><td><br></td><td><a href="../api_cxx/deadlock_class.html">DbDeadlockException</a></td><td><b>Exception Class for deadlocks</b></td></tr> +<tr><td><br></td><td><a href="../api_cxx/lockng_class.html">DbLockNotGrantedException</a></td><td><b>Exception Class for lock request failures</b></td></tr> <tr><td><br></td><td><a href="../api_cxx/mem_class.html">DbMemoryException</a></td><td><b>Exception Class for insufficient memory</b></td></tr> -<tr><td><br></td><td><a href="../api_cxx/get_dbt.html">DbMemoryException::get_dbt</a></td><td>Get the failing Dbt</td></tr> +<tr><td><br></td><td><a href="../api_cxx/runrec_class.html">DbRunRecoveryException</a></td><td><b>Exception Class for failures requiring recovery</b></td></tr> </table> <p><font size=1><a href="http://www.sleepycat.com">Copyright Sleepycat Software</a></font> </body> diff --git a/db/docs/api_cxx/env_set_timeout.html b/db/docs/api_cxx/env_set_timeout.html index a04ec7d33..26a6b719c 100644 --- a/db/docs/api_cxx/env_set_timeout.html +++ b/db/docs/api_cxx/env_set_timeout.html @@ -1,6 +1,7 @@ -<!--Id: env_set_timeout.so,v 10.3 2001/10/22 15:24:31 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: env_set_timeout.so,v 10.6 2002/06/24 14:49:21 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB: DbEnv::set_timeout</title> @@ -59,44 +60,61 @@ detection is performed. <p>Timeout values specified for the database environment may be overridden on a per-lock or per-transaction basis. See <a href="../api_cxx/lock_vec.html">DbEnv::lock_vec</a> and <a href="../api_cxx/txn_set_timeout.html">DbTxn::set_timeout</a> for more information. -<p>The DbEnv::set_timeout interface may be used only to configure Berkeley DB before -the <a href="../api_cxx/env_open.html">DbEnv::open</a> interface is called. +<p>The DbEnv::set_timeout method configures a database environment, not only operations +performed using the specified <a href="../api_cxx/dbenv_class.html">DbEnv</a> handle. +<p>The DbEnv::set_timeout interface may be called at any time during the life of +the application. <p>The DbEnv::set_timeout method either returns a non-zero error value or throws an exception that encapsulates a non-zero error value on failure, and returns 0 on success. <h1>Errors</h1> <p>The DbEnv::set_timeout method may fail and throw an exception or return a non-zero error for the following conditions: <p><dl compact> <p><dt>EINVAL<dd>An invalid flag value or parameter was specified. -<p>Called after <a href="../api_cxx/env_open.html">DbEnv::open</a> was called. </dl> <p>The DbEnv::set_timeout method may fail and throw an exception or return a non-zero error for errors specified for other Berkeley DB and C library or system methods. -If a catastrophic error has occurred, the DbEnv::set_timeout method may fail and either -return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a> or throw an exception encapsulating -<a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, in which case all subsequent Berkeley DB calls will fail -in the same way. +If a catastrophic error has occurred, the DbEnv::set_timeout method may fail and +either return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a> or throw a +<a href="../api_cxx/runrec_class.html">DbRunRecoveryException</a>, +in which case all subsequent Berkeley DB calls will fail in the same way. <h1>Class</h1> <a href="../api_cxx/dbenv_class.html">DbEnv</a> <h1>See Also</h1> <a href="../api_cxx/env_close.html">DbEnv::close</a>, -<a href="../api_cxx/env_err.html">DbEnv::err</a>, <a href="../api_cxx/env_err.html">DbEnv::errx</a> +<a href="../api_cxx/env_dbremove.html">DbEnv::dbremove</a>, +<a href="../api_cxx/env_dbrename.html">DbEnv::dbrename</a>, +<a href="../api_cxx/env_err.html">DbEnv::err</a>, +<a href="../api_cxx/env_err.html">DbEnv::errx</a>, <a href="../api_cxx/env_open.html">DbEnv::open</a>, <a href="../api_cxx/env_remove.html">DbEnv::remove</a>, <a href="../api_cxx/env_set_alloc.html">DbEnv::set_alloc</a>, +<a href="../api_cxx/env_set_app_dispatch.html">DbEnv::set_app_dispatch</a>, <a href="../api_cxx/env_set_cachesize.html">DbEnv::set_cachesize</a>, <a href="../api_cxx/env_set_data_dir.html">DbEnv::set_data_dir</a>, +<a href="../api_cxx/env_set_encrypt.html">DbEnv::set_encrypt</a>, <a href="../api_cxx/env_set_errcall.html">DbEnv::set_errcall</a>, <a href="../api_cxx/env_set_errfile.html">DbEnv::set_errfile</a>, <a href="../api_cxx/env_set_error_stream.html">DbEnv::set_error_stream</a>, <a href="../api_cxx/env_set_errpfx.html">DbEnv::set_errpfx</a>, <a href="../api_cxx/env_set_feedback.html">DbEnv::set_feedback</a>, <a href="../api_cxx/env_set_flags.html">DbEnv::set_flags</a>, +<a href="../api_cxx/env_set_lg_bsize.html">DbEnv::set_lg_bsize</a>, +<a href="../api_cxx/env_set_lg_dir.html">DbEnv::set_lg_dir</a>, +<a href="../api_cxx/env_set_lg_max.html">DbEnv::set_lg_max</a>, +<a href="../api_cxx/env_set_lg_regionmax.html">DbEnv::set_lg_regionmax</a>, +<a href="../api_cxx/env_set_lk_conflicts.html">DbEnv::set_lk_conflicts</a>, +<a href="../api_cxx/env_set_lk_detect.html">DbEnv::set_lk_detect</a>, +<a href="../api_cxx/env_set_lk_max_lockers.html">DbEnv::set_lk_max_lockers</a>, +<a href="../api_cxx/env_set_lk_max_locks.html">DbEnv::set_lk_max_locks</a>, +<a href="../api_cxx/env_set_lk_max_objects.html">DbEnv::set_lk_max_objects</a>, +<a href="../api_cxx/env_set_mp_mmapsize.html">DbEnv::set_mp_mmapsize</a>, <a href="../api_cxx/env_set_paniccall.html">DbEnv::set_paniccall</a>, -<a href="../api_cxx/env_set_rec_init.html">DbEnv::set_recovery_init</a>, <a href="../api_cxx/env_set_rpc_server.html">DbEnv::set_rpc_server</a>, <a href="../api_cxx/env_set_shm_key.html">DbEnv::set_shm_key</a>, <a href="../api_cxx/env_set_tas_spins.html">DbEnv::set_tas_spins</a>, -<a href="../api_cxx/env_set_tmp_dir.html">DbEnv::set_tmp_dir</a>, <a href="../api_cxx/env_set_timeout.html">DbEnv::set_timeout</a>, +<a href="../api_cxx/env_set_tmp_dir.html">DbEnv::set_tmp_dir</a>, +<a href="../api_cxx/env_set_tx_max.html">DbEnv::set_tx_max</a>, +<a href="../api_cxx/env_set_tx_timestamp.html">DbEnv::set_tx_timestamp</a>, <a href="../api_cxx/env_set_verbose.html">DbEnv::set_verbose</a>, <a href="../api_cxx/env_strerror.html">DbEnv::strerror</a> and diff --git a/db/docs/api_cxx/lock_id_free.html b/db/docs/api_cxx/lock_id_free.html index e6e8f8f36..ee463e484 100644 --- a/db/docs/api_cxx/lock_id_free.html +++ b/db/docs/api_cxx/lock_id_free.html @@ -1,6 +1,7 @@ -<!--Id: lock_id_free.so,v 10.2 2001/10/22 15:24:32 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: lock_id_free.so,v 10.4 2002/06/24 14:49:23 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB: DbEnv::lock_id_free</title> @@ -35,10 +36,10 @@ encapsulates a non-zero error value on failure, and returns 0 on success. <p>The locker ID is invalid or locks are still held by this locker ID. </dl> <p>The DbEnv::lock_id_free method may fail and throw an exception or return a non-zero error for errors specified for other Berkeley DB and C library or system methods. -If a catastrophic error has occurred, the DbEnv::lock_id_free method may fail and either -return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a> or throw an exception encapsulating -<a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, in which case all subsequent Berkeley DB calls will fail -in the same way. +If a catastrophic error has occurred, the DbEnv::lock_id_free method may fail and +either return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a> or throw a +<a href="../api_cxx/runrec_class.html">DbRunRecoveryException</a>, +in which case all subsequent Berkeley DB calls will fail in the same way. <h1>Class</h1> <a href="../api_cxx/dbenv_class.html">DbEnv</a>, <a href="../api_cxx/lock_class.html">DbLock</a> <h1>See Also</h1> @@ -52,7 +53,7 @@ in the same way. <a href="../api_cxx/lock_id.html">DbEnv::lock_id</a>, <a href="../api_cxx/lock_id_free.html">DbEnv::lock_id_free</a>, <a href="../api_cxx/lock_put.html">DbEnv::lock_put</a>, -<a href="../api_cxx/lock_stat.html">DbEnv::lock_stat</a>, +<a href="../api_cxx/lock_stat.html">DbEnv::lock_stat</a> and <a href="../api_cxx/lock_vec.html">DbEnv::lock_vec</a>. </tt> diff --git a/db/docs/api_cxx/log_cursor.html b/db/docs/api_cxx/log_cursor.html index b6a877ba3..083920d55 100644 --- a/db/docs/api_cxx/log_cursor.html +++ b/db/docs/api_cxx/log_cursor.html @@ -1,6 +1,7 @@ -<!--Id: log_cursor.so,v 10.2 2001/10/22 15:24:33 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: log_cursor.so,v 10.3 2002/06/24 14:49:24 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB: DbEnv::log_cursor</title> @@ -37,36 +38,39 @@ encapsulates a non-zero error value on failure, and returns 0 on success. <p><dt>EINVAL<dd>An invalid flag value or parameter was specified. </dl> <p>The DbEnv::log_cursor method may fail and throw an exception or return a non-zero error for errors specified for other Berkeley DB and C library or system methods. -If a catastrophic error has occurred, the DbEnv::log_cursor method may fail and either -return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a> or throw an exception encapsulating -<a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, in which case all subsequent Berkeley DB calls will fail -in the same way. +If a catastrophic error has occurred, the DbEnv::log_cursor method may fail and +either return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a> or throw a +<a href="../api_cxx/runrec_class.html">DbRunRecoveryException</a>, +in which case all subsequent Berkeley DB calls will fail in the same way. <h1>Class</h1> <a href="../api_cxx/db_class.html">Db</a> <h1>See Also</h1> +<a href="../api_cxx/db_set_alloc.html">Db::set_alloc</a>, <a href="../api_cxx/db_associate.html">Db::associate</a>, <a href="../api_cxx/db_close.html">Db::close</a>, <a href="../api_cxx/db_cursor.html">Db::cursor</a>, <a href="../api_cxx/db_del.html">Db::del</a>, -<a href="../api_cxx/db_err.html">Db::err</a>, <a href="../api_cxx/db_err.html">Db::errx</a> +<a href="../api_cxx/db_err.html">Db::err</a>, +<a href="../api_cxx/db_err.html">Db::errx</a>, <a href="../api_cxx/db_fd.html">Db::fd</a>, <a href="../api_cxx/db_get.html">Db::get</a>, -<a href="../api_cxx/db_get.html">Db::pget</a>, <a href="../api_cxx/db_get_byteswapped.html">Db::get_byteswapped</a>, <a href="../api_cxx/db_get_type.html">Db::get_type</a>, <a href="../api_cxx/db_join.html">Db::join</a>, <a href="../api_cxx/db_key_range.html">Db::key_range</a>, <a href="../api_cxx/db_open.html">Db::open</a>, +<a href="../api_cxx/db_get.html">Db::pget</a>, <a href="../api_cxx/db_put.html">Db::put</a>, <a href="../api_cxx/db_remove.html">Db::remove</a>, <a href="../api_cxx/db_rename.html">Db::rename</a>, -<a href="../api_cxx/db_set_alloc.html">Db::set_alloc</a>, <a href="../api_cxx/db_set_append_recno.html">Db::set_append_recno</a>, <a href="../api_cxx/db_set_bt_compare.html">Db::set_bt_compare</a>, <a href="../api_cxx/db_set_bt_minkey.html">Db::set_bt_minkey</a>, <a href="../api_cxx/db_set_bt_prefix.html">Db::set_bt_prefix</a>, +<a href="../api_cxx/db_set_cache_priority.html">Db::set_cache_priority</a>, <a href="../api_cxx/db_set_cachesize.html">Db::set_cachesize</a>, <a href="../api_cxx/db_set_dup_compare.html">Db::set_dup_compare</a>, +<a href="../api_cxx/db_set_encrypt.html">Db::set_encrypt</a>, <a href="../api_cxx/db_set_errcall.html">Db::set_errcall</a>, <a href="../api_cxx/db_set_errfile.html">Db::set_errfile</a>, <a href="../api_cxx/db_set_errpfx.html">Db::set_errpfx</a>, @@ -86,7 +90,7 @@ in the same way. <a href="../api_cxx/db_stat.html">Db::stat</a>, <a href="../api_cxx/db_sync.html">Db::sync</a>, <a href="../api_cxx/db_truncate.html">Db::truncate</a>, -<a href="../api_cxx/db_upgrade.html">Db::upgrade</a>, +<a href="../api_cxx/db_upgrade.html">Db::upgrade</a> and <a href="../api_cxx/db_verify.html">Db::verify</a>. </tt> diff --git a/db/docs/api_cxx/logc_class.html b/db/docs/api_cxx/logc_class.html index c83c12e95..de5b7d81b 100644 --- a/db/docs/api_cxx/logc_class.html +++ b/db/docs/api_cxx/logc_class.html @@ -1,6 +1,7 @@ -<!--Id: logc_class.so,v 1.1 2001/09/28 15:09:37 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: logc_class.so,v 1.3 2002/06/27 19:10:06 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB: DbLogc</title> @@ -30,24 +31,24 @@ which provides cursor support for log files. sequential access to the records stored in log files. Cursors are created by calling the <a href="../api_cxx/log_cursor.html">DbEnv::log_cursor</a> method which returns a pointer to a DbLogc object. <h1>Class</h1> -<a href="../api_cxx/dbenv_class.html">DbEnv</a> +<a href="../api_cxx/dbenv_class.html">DbEnv</a>, <a href="../api_cxx/logc_class.html">DbLogc</a> <h1>See Also</h1> -<a href="../api_cxx/env_set_lg_bsize.html">DbEnv::set_lg_bsize</a>, -<a href="../api_cxx/env_set_lg_dir.html">DbEnv::set_lg_dir</a>, -<a href="../api_cxx/env_set_lg_max.html">DbEnv::set_lg_max</a>, -<a href="../api_cxx/env_set_lg_regionmax.html">DbEnv::set_lg_regionmax</a>, <a href="../api_cxx/log_archive.html">DbEnv::log_archive</a>, -<a href="../api_cxx/log_compare.html">DbEnv::log_compare</a>, -<a href="../api_cxx/log_cursor.html">DbEnv::log_cursor</a>, <a href="../api_cxx/log_file.html">DbEnv::log_file</a>, <a href="../api_cxx/log_flush.html">DbEnv::log_flush</a>, <a href="../api_cxx/log_put.html">DbEnv::log_put</a>, -<a href="../api_cxx/log_register.html">DbEnv::log_register</a>, <a href="../api_cxx/log_stat.html">DbEnv::log_stat</a>, -<a href="../api_cxx/log_unregister.html">DbEnv::log_unregister</a>, -<a href="../api_cxx/logc_close.html">DbLogc::logc_close</a> +<a href="../api_cxx/env_set_lg_bsize.html">DbEnv::set_lg_bsize</a>, +<a href="../api_cxx/env_set_lg_dir.html">DbEnv::set_lg_dir</a>, +<a href="../api_cxx/env_set_lg_max.html">DbEnv::set_lg_max</a>, +<a href="../api_cxx/env_set_lg_regionmax.html">DbEnv::set_lg_regionmax</a>, +and +<a href="../api_cxx/log_compare.html">DbEnv::log_compare</a>. +<p> +<a href="../api_cxx/log_cursor.html">DbEnv::log_cursor</a>, +<a href="../api_cxx/logc_close.html">DbLogc::close</a> and -<a href="../api_cxx/logc_get.html">DbLogc::logc_get</a>. +<a href="../api_cxx/logc_get.html">DbLogc::get</a>. </tt> <table width="100%"><tr><td><br></td><td align=right> <a href="../api_cxx/c_index.html"><img src="../images/api.gif" alt="API"></a><a href="../reftoc.html"><img src="../images/ref.gif" alt="Ref"></a> diff --git a/db/docs/api_cxx/logc_close.html b/db/docs/api_cxx/logc_close.html index b3ad0fc69..20c55bb79 100644 --- a/db/docs/api_cxx/logc_close.html +++ b/db/docs/api_cxx/logc_close.html @@ -1,9 +1,10 @@ -<!--Id: logc_close.so,v 10.4 2001/10/22 15:24:35 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: logc_close.so,v 10.5 2002/06/24 14:49:25 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> -<title>Berkeley DB: DbLogc::logc_close</title> +<title>Berkeley DB: DbLogc::close</title> <meta name="description" content="Berkeley DB: An embedded database programmatic toolkit."> <meta name="keywords" content="embedded,database,programmatic,toolkit,b+tree,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,java,C,C++"> </head> @@ -11,7 +12,7 @@ <a name="2"><!--meow--></a> <table width="100%"><tr valign=top> <td> -<h1>DbLogc::logc_close</h1> +<h1>DbLogc::close</h1> </td> <td align=right> <a href="../api_cxx/c_index.html"><img src="../images/api.gif" alt="API"></a><a href="../reftoc.html"><img src="../images/ref.gif" alt="Ref"></a> @@ -25,42 +26,42 @@ int DbLogc::close(u_int32_t flags); </pre></h3> <h1>Description</h1> -<p>The DbLogc::logc_close method discards the log cursor. After DbLogc::logc_close +<p>The DbLogc::close method discards the log cursor. After DbLogc::close has been called, regardless of its return, the cursor handle may not be used again. <p>The <b>flags</b> parameter is currently unused, and must be set to 0. -<p>The DbLogc::logc_close method either returns a non-zero error value or throws an exception that +<p>The DbLogc::close method either returns a non-zero error value or throws an exception that encapsulates a non-zero error value on failure, and returns 0 on success. <h1>Errors</h1> -<p>The DbLogc::logc_close method may fail and throw an exception or return a non-zero error for the following conditions: +<p>The DbLogc::close method may fail and throw an exception or return a non-zero error for the following conditions: <p><dl compact> <p><dt>EINVAL<dd>An invalid flag value or parameter was specified. <p>The cursor was previously closed. </dl> -<p>The DbLogc::logc_close method may fail and throw an exception or return a non-zero error for errors specified for other Berkeley DB and C library or system methods. -If a catastrophic error has occurred, the DbLogc::logc_close method may fail and either -return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a> or throw an exception encapsulating -<a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, in which case all subsequent Berkeley DB calls will fail -in the same way. +<p>The DbLogc::close method may fail and throw an exception or return a non-zero error for errors specified for other Berkeley DB and C library or system methods. +If a catastrophic error has occurred, the DbLogc::close method may fail and +either return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a> or throw a +<a href="../api_cxx/runrec_class.html">DbRunRecoveryException</a>, +in which case all subsequent Berkeley DB calls will fail in the same way. <h1>Class</h1> -<a href="../api_cxx/dbenv_class.html">DbEnv</a> +<a href="../api_cxx/dbenv_class.html">DbEnv</a>, <a href="../api_cxx/logc_class.html">DbLogc</a> <h1>See Also</h1> -<a href="../api_cxx/env_set_lg_bsize.html">DbEnv::set_lg_bsize</a>, -<a href="../api_cxx/env_set_lg_dir.html">DbEnv::set_lg_dir</a>, -<a href="../api_cxx/env_set_lg_max.html">DbEnv::set_lg_max</a>, -<a href="../api_cxx/env_set_lg_regionmax.html">DbEnv::set_lg_regionmax</a>, <a href="../api_cxx/log_archive.html">DbEnv::log_archive</a>, -<a href="../api_cxx/log_compare.html">DbEnv::log_compare</a>, -<a href="../api_cxx/log_cursor.html">DbEnv::log_cursor</a>, <a href="../api_cxx/log_file.html">DbEnv::log_file</a>, <a href="../api_cxx/log_flush.html">DbEnv::log_flush</a>, <a href="../api_cxx/log_put.html">DbEnv::log_put</a>, -<a href="../api_cxx/log_register.html">DbEnv::log_register</a>, <a href="../api_cxx/log_stat.html">DbEnv::log_stat</a>, -<a href="../api_cxx/log_unregister.html">DbEnv::log_unregister</a>, -<a href="../api_cxx/logc_close.html">DbLogc::logc_close</a> +<a href="../api_cxx/env_set_lg_bsize.html">DbEnv::set_lg_bsize</a>, +<a href="../api_cxx/env_set_lg_dir.html">DbEnv::set_lg_dir</a>, +<a href="../api_cxx/env_set_lg_max.html">DbEnv::set_lg_max</a>, +<a href="../api_cxx/env_set_lg_regionmax.html">DbEnv::set_lg_regionmax</a>, +and +<a href="../api_cxx/log_compare.html">DbEnv::log_compare</a>. +<p> +<a href="../api_cxx/log_cursor.html">DbEnv::log_cursor</a>, +<a href="../api_cxx/logc_close.html">DbLogc::close</a> and -<a href="../api_cxx/logc_get.html">DbLogc::logc_get</a>. +<a href="../api_cxx/logc_get.html">DbLogc::get</a>. </tt> <table width="100%"><tr><td><br></td><td align=right> <a href="../api_cxx/c_index.html"><img src="../images/api.gif" alt="API"></a><a href="../reftoc.html"><img src="../images/ref.gif" alt="Ref"></a> diff --git a/db/docs/api_cxx/logc_get.html b/db/docs/api_cxx/logc_get.html index 73d6e9f46..cbfef46d0 100644 --- a/db/docs/api_cxx/logc_get.html +++ b/db/docs/api_cxx/logc_get.html @@ -1,9 +1,10 @@ -<!--Id: logc_get.so,v 10.31 2001/10/22 15:24:35 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: logc_get.so,v 10.36 2002/07/01 16:52:26 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> -<title>Berkeley DB: DbLogc::logc_get</title> +<title>Berkeley DB: DbLogc::get</title> <meta name="description" content="Berkeley DB: An embedded database programmatic toolkit."> <meta name="keywords" content="embedded,database,programmatic,toolkit,b+tree,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,java,C,C++"> </head> @@ -11,7 +12,7 @@ <a name="2"><!--meow--></a> <table width="100%"><tr valign=top> <td> -<h1>DbLogc::logc_get</h1> +<h1>DbLogc::get</h1> </td> <td align=right> <a href="../api_cxx/c_index.html"><img src="../images/api.gif" alt="API"></a><a href="../reftoc.html"><img src="../images/ref.gif" alt="Ref"></a> @@ -25,7 +26,7 @@ int DbLogc::get(DbLsn *lsn, Dbt *data, u_int32_t flags); </pre></h3> <h1>Description</h1> -<p>The DbLogc::logc_get method retrieve records from the log according to the +<p>The DbLogc::get method retrieve records from the log according to the <b>lsn</b> and <b>flags</b> arguments. <p>The data field of the <b>data</b> structure is set to the record retrieved, and the size field indicates the number of bytes in the @@ -35,44 +36,41 @@ record. See <a href="../api_cxx/dbt_class.html">Dbt</a> for a description of ot for any <a href="../api_cxx/dbt_class.html">Dbt</a> used for data retrieval. <p>The <b>flags</b> value must be set to one of the following values: <p><dl compact> -<p><dt><a name="DB_CHECKPOINT">DB_CHECKPOINT</a><dd>The last record written with the DB_CHECKPOINT flag specified to the -<a href="../api_cxx/log_put.html">DbEnv::log_put</a> method is returned in the <b>data</b> argument. The -<b>lsn</b> argument is overwritten with the <a href="../api_cxx/lsn_class.html">DbLsn</a> of the record -returned. If no record has been previously written with the DB_CHECKPOINT -flag specified, the first record in the log is returned. -<p>If the log is empty, the DbLogc::logc_get method will return <a href="../ref/program/errorret.html#DB_NOTFOUND">DB_NOTFOUND</a>. <p><dt><a name="DB_FIRST">DB_FIRST</a><dd>The first record from any of the log files found in the log directory is returned in the <b>data</b> argument. The <b>lsn</b> argument is overwritten with the <a href="../api_cxx/lsn_class.html">DbLsn</a> of the record returned. -<p>If the log is empty, the DbLogc::logc_get method will return <a href="../ref/program/errorret.html#DB_NOTFOUND">DB_NOTFOUND</a>. +<p> +If the log is empty, the DbLogc::get method will return DB_NOTFOUND. <p><dt><a name="DB_LAST">DB_LAST</a><dd>The last record in the log is returned in the <b>data</b> argument. The <b>lsn</b> argument is overwritten with the <a href="../api_cxx/lsn_class.html">DbLsn</a> of the record returned. -<p>If the log is empty, the DbLogc::logc_get method will return <a href="../ref/program/errorret.html#DB_NOTFOUND">DB_NOTFOUND</a>. +<p> +If the log is empty, the DbLogc::get method will return DB_NOTFOUND. <p><dt><a name="DB_NEXT">DB_NEXT</a>, <a name="DB_PREV">DB_PREV</a><dd>The current log position is advanced to the next (previous) record in the log, and that record is returned in the <b>data</b> argument. The <b>lsn</b> argument is overwritten with the <a href="../api_cxx/lsn_class.html">DbLsn</a> of the record returned. -<p>If the pointer has not been initialized via DB_FIRST, DB_LAST, DB_SET, -DB_NEXT, or DB_PREV, DbLogc::logc_get will return the first (last) record -in the log. If the last (first) log record has already been returned -or the log is empty, the DbLogc::logc_get method will return <a href="../ref/program/errorret.html#DB_NOTFOUND">DB_NOTFOUND</a>. -<p>If the log was opened with the DB_THREAD flag set, calls to -DbLogc::logc_get with the DB_NEXT (DB_PREV) flag set will return -EINVAL. +<p>If the cursor has not been initialized via DB_FIRST, DB_LAST, DB_SET, +DB_NEXT, or DB_PREV, DbLogc::get will return the first (last) record +in the log. +If the last (first) log record has already been returned or the log is +empty, the DbLogc::get method will return DB_NOTFOUND. +If the log was opened with the DB_THREAD flag set, calls to +DbLogc::get with the DB_NEXT (DB_PREV) flag set, the DbLogc::get method either returns EINVAL or throws an exception that encapsulates EINVAL. <p><dt><a name="DB_CURRENT">DB_CURRENT</a><dd>Return the log record to which the log currently refers. -<p>If the log pointer has not been initialized via DB_FIRST, DB_LAST, +If the log cursor has not been initialized via DB_FIRST, DB_LAST, DB_SET, DB_NEXT, or DB_PREV, or if the log was opened with the DB_THREAD -flag set, DbLogc::logc_get will return EINVAL. -<p><dt><a name="DB_SET">DB_SET</a><dd>Retrieve the record specified by the <b>lsn</b> argument. If the -specified <a href="../api_cxx/lsn_class.html">DbLsn</a> is invalid (for example, it does not appear in -the log) DbLogc::logc_get will return EINVAL. +flag set, the DbLogc::get method either returns EINVAL or throws an exception that encapsulates EINVAL. +<p><dt><a name="DB_SET">DB_SET</a><dd>Retrieve the record specified by the <b>lsn</b> argument. +If the specified <a href="../api_cxx/lsn_class.html">DbLsn</a> is invalid (for example, it does not +appear in the log), the DbLogc::get method either returns EINVAL or throws an exception that encapsulates EINVAL. </dl> -<p>Otherwise, the DbLogc::logc_get method either returns a non-zero error value or throws an exception that +<p> +Otherwise, the DbLogc::get method either returns a non-zero error value or throws an exception that encapsulates a non-zero error value on failure, and returns 0 on success. <h1>Errors</h1> -<p>The DbLogc::logc_get method may fail and throw an exception or return a non-zero error for the following conditions: +<p>The DbLogc::get method may fail and throw an exception or return a non-zero error for the following conditions: <p><dl compact> <p><dt>EINVAL<dd>An invalid flag value or parameter was specified. <p>The DB_CURRENT flag was set and the log pointer had not yet been @@ -80,30 +78,30 @@ initialized. <p>The DB_SET flag was set and the specified log sequence number does not exist. </dl> -<p>The DbLogc::logc_get method may fail and throw an exception or return a non-zero error for errors specified for other Berkeley DB and C library or system methods. -If a catastrophic error has occurred, the DbLogc::logc_get method may fail and either -return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a> or throw an exception encapsulating -<a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, in which case all subsequent Berkeley DB calls will fail -in the same way. +<p>The DbLogc::get method may fail and throw an exception or return a non-zero error for errors specified for other Berkeley DB and C library or system methods. +If a catastrophic error has occurred, the DbLogc::get method may fail and +either return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a> or throw a +<a href="../api_cxx/runrec_class.html">DbRunRecoveryException</a>, +in which case all subsequent Berkeley DB calls will fail in the same way. <h1>Class</h1> -<a href="../api_cxx/dbenv_class.html">DbEnv</a> +<a href="../api_cxx/dbenv_class.html">DbEnv</a>, <a href="../api_cxx/logc_class.html">DbLogc</a> <h1>See Also</h1> -<a href="../api_cxx/env_set_lg_bsize.html">DbEnv::set_lg_bsize</a>, -<a href="../api_cxx/env_set_lg_dir.html">DbEnv::set_lg_dir</a>, -<a href="../api_cxx/env_set_lg_max.html">DbEnv::set_lg_max</a>, -<a href="../api_cxx/env_set_lg_regionmax.html">DbEnv::set_lg_regionmax</a>, <a href="../api_cxx/log_archive.html">DbEnv::log_archive</a>, -<a href="../api_cxx/log_compare.html">DbEnv::log_compare</a>, -<a href="../api_cxx/log_cursor.html">DbEnv::log_cursor</a>, <a href="../api_cxx/log_file.html">DbEnv::log_file</a>, <a href="../api_cxx/log_flush.html">DbEnv::log_flush</a>, <a href="../api_cxx/log_put.html">DbEnv::log_put</a>, -<a href="../api_cxx/log_register.html">DbEnv::log_register</a>, <a href="../api_cxx/log_stat.html">DbEnv::log_stat</a>, -<a href="../api_cxx/log_unregister.html">DbEnv::log_unregister</a>, -<a href="../api_cxx/logc_close.html">DbLogc::logc_close</a> +<a href="../api_cxx/env_set_lg_bsize.html">DbEnv::set_lg_bsize</a>, +<a href="../api_cxx/env_set_lg_dir.html">DbEnv::set_lg_dir</a>, +<a href="../api_cxx/env_set_lg_max.html">DbEnv::set_lg_max</a>, +<a href="../api_cxx/env_set_lg_regionmax.html">DbEnv::set_lg_regionmax</a>, +and +<a href="../api_cxx/log_compare.html">DbEnv::log_compare</a>. +<p> +<a href="../api_cxx/log_cursor.html">DbEnv::log_cursor</a>, +<a href="../api_cxx/logc_close.html">DbLogc::close</a> and -<a href="../api_cxx/logc_get.html">DbLogc::logc_get</a>. +<a href="../api_cxx/logc_get.html">DbLogc::get</a>. </tt> <table width="100%"><tr><td><br></td><td align=right> <a href="../api_cxx/c_index.html"><img src="../images/api.gif" alt="API"></a><a href="../reftoc.html"><img src="../images/ref.gif" alt="Ref"></a> diff --git a/db/docs/api_cxx/memp_fcreate.html b/db/docs/api_cxx/memp_fcreate.html index 6a6a202f3..25da222d0 100644 --- a/db/docs/api_cxx/memp_fcreate.html +++ b/db/docs/api_cxx/memp_fcreate.html @@ -1,6 +1,7 @@ -<!--Id: memp_fcreate.so,v 10.4 2001/10/22 15:24:35 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: memp_fcreate.so,v 10.5 2002/06/24 14:49:26 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB: DbEnv::memp_fcreate</title> @@ -34,32 +35,33 @@ Calling the <a href="../api_cxx/memp_fclose.html">DbMpoolFile::close</a> method encapsulates a non-zero error value on failure, and returns 0 on success. <h1>Errors</h1> <p>The DbEnv::memp_fcreate method may fail and throw an exception or return a non-zero error for errors specified for other Berkeley DB and C library or system methods. -If a catastrophic error has occurred, the DbEnv::memp_fcreate method may fail and either -return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a> or throw an exception encapsulating -<a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, in which case all subsequent Berkeley DB calls will fail -in the same way. +If a catastrophic error has occurred, the DbEnv::memp_fcreate method may fail and +either return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a> or throw a +<a href="../api_cxx/runrec_class.html">DbRunRecoveryException</a>, +in which case all subsequent Berkeley DB calls will fail in the same way. <h1>Class</h1> <a href="../api_cxx/dbenv_class.html">DbEnv</a>, <a href="../api_cxx/mempfile_class.html">DbMpoolFile</a> <h1>See Also</h1> <a href="../api_cxx/env_set_cachesize.html">DbEnv::set_cachesize</a>, <a href="../api_cxx/env_set_mp_mmapsize.html">DbEnv::set_mp_mmapsize</a>, +<a href="../api_cxx/memp_register.html">DbEnv::memp_register</a>, +<a href="../api_cxx/memp_stat.html">DbEnv::memp_stat</a>, +<a href="../api_cxx/memp_sync.html">DbEnv::memp_sync</a>, +<a href="../api_cxx/memp_trickle.html">DbEnv::memp_trickle</a>, +<p> <a href="../api_cxx/memp_fcreate.html">DbEnv::memp_fcreate</a>, <a href="../api_cxx/memp_fclose.html">DbMpoolFile::close</a>, <a href="../api_cxx/memp_fget.html">DbMpoolFile::get</a>, <a href="../api_cxx/memp_fopen.html">DbMpoolFile::open</a>, <a href="../api_cxx/memp_fput.html">DbMpoolFile::put</a>, <a href="../api_cxx/memp_fset.html">DbMpoolFile::set</a>, -<a href="../api_cxx/memp_fsync.html">DbMpoolFile::sync</a>, -<a href="../api_cxx/memp_register.html">DbEnv::memp_register</a>, -<a href="../api_cxx/memp_set_clear_len.html">DbMpoolFile::set_clear_len</a>, <a href="../api_cxx/memp_set_fileid.html">DbMpoolFile::set_fileid</a>, +<a href="../api_cxx/memp_set_clear_len.html">DbMpoolFile::set_clear_len</a>, <a href="../api_cxx/memp_set_ftype.html">DbMpoolFile::set_ftype</a>, <a href="../api_cxx/memp_set_lsn_offset.html">DbMpoolFile::set_lsn_offset</a>, -<a href="../api_cxx/memp_set_pgcookie.html">DbMpoolFile::set_pgcookie</a>, -<a href="../api_cxx/memp_stat.html">DbEnv::memp_stat</a>, -<a href="../api_cxx/memp_sync.html">DbEnv::memp_sync</a>, +<a href="../api_cxx/memp_set_pgcookie.html">DbMpoolFile::set_pgcookie</a> and -<a href="../api_cxx/memp_trickle.html">DbEnv::memp_trickle</a>. +<a href="../api_cxx/memp_fsync.html">DbMpoolFile::sync</a>. </tt> <table width="100%"><tr><td><br></td><td align=right> <a href="../api_cxx/c_index.html"><img src="../images/api.gif" alt="API"></a><a href="../reftoc.html"><img src="../images/ref.gif" alt="Ref"></a> diff --git a/db/docs/api_cxx/memp_set_clear_len.html b/db/docs/api_cxx/memp_set_clear_len.html index 56017cc18..98ed67676 100644 --- a/db/docs/api_cxx/memp_set_clear_len.html +++ b/db/docs/api_cxx/memp_set_clear_len.html @@ -1,6 +1,7 @@ -<!--Id: memp_set_clear_len.so,v 10.2 2001/10/22 15:24:36 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: memp_set_clear_len.so,v 10.4 2002/06/24 14:49:27 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB: DbMpoolFile::set_clear_len</title> @@ -30,36 +31,45 @@ page that should be set to nul when the page is created as a result of the <a href="../api_cxx/memp_fget.html#DB_MPOOL_CREATE">DB_MPOOL_CREATE</a> or <a href="../api_cxx/memp_fget.html#DB_MPOOL_NEW">DB_MPOOL_NEW</a> flags being specified to <a href="../api_cxx/memp_fget.html">DbMpoolFile::get</a>. If no value is specified, or <b>len</b> is 0, the entire page is cleared. +<p>The DbMpoolFile::set_clear_len method configures a file in the memory pool, not only +operations performed using the specified <a href="../api_cxx/mempfile_class.html">DbMpoolFile</a> handle. +<p>The DbMpoolFile::set_clear_len interface may not be called after the <a href="../api_cxx/memp_fopen.html">DbMpoolFile::open</a> +interface is called. +If the file is already open in the memory pool when +<a href="../api_cxx/memp_fopen.html">DbMpoolFile::open</a> is called, the information specified to DbMpoolFile::set_clear_len +must be consistent with the existing file or an error will be +returned. <p>The DbMpoolFile::set_clear_len method either returns a non-zero error value or throws an exception that encapsulates a non-zero error value on failure, and returns 0 on success. <h1>Errors</h1> <p>The DbMpoolFile::set_clear_len method may fail and throw an exception or return a non-zero error for errors specified for other Berkeley DB and C library or system methods. -If a catastrophic error has occurred, the DbMpoolFile::set_clear_len method may fail and either -return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a> or throw an exception encapsulating -<a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, in which case all subsequent Berkeley DB calls will fail -in the same way. +If a catastrophic error has occurred, the DbMpoolFile::set_clear_len method may fail and +either return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a> or throw a +<a href="../api_cxx/runrec_class.html">DbRunRecoveryException</a>, +in which case all subsequent Berkeley DB calls will fail in the same way. <h1>Class</h1> <a href="../api_cxx/dbenv_class.html">DbEnv</a>, <a href="../api_cxx/mempfile_class.html">DbMpoolFile</a> <h1>See Also</h1> <a href="../api_cxx/env_set_cachesize.html">DbEnv::set_cachesize</a>, <a href="../api_cxx/env_set_mp_mmapsize.html">DbEnv::set_mp_mmapsize</a>, +<a href="../api_cxx/memp_register.html">DbEnv::memp_register</a>, +<a href="../api_cxx/memp_stat.html">DbEnv::memp_stat</a>, +<a href="../api_cxx/memp_sync.html">DbEnv::memp_sync</a>, +<a href="../api_cxx/memp_trickle.html">DbEnv::memp_trickle</a>, +<p> <a href="../api_cxx/memp_fcreate.html">DbEnv::memp_fcreate</a>, <a href="../api_cxx/memp_fclose.html">DbMpoolFile::close</a>, <a href="../api_cxx/memp_fget.html">DbMpoolFile::get</a>, <a href="../api_cxx/memp_fopen.html">DbMpoolFile::open</a>, <a href="../api_cxx/memp_fput.html">DbMpoolFile::put</a>, <a href="../api_cxx/memp_fset.html">DbMpoolFile::set</a>, -<a href="../api_cxx/memp_fsync.html">DbMpoolFile::sync</a>, -<a href="../api_cxx/memp_register.html">DbEnv::memp_register</a>, -<a href="../api_cxx/memp_set_clear_len.html">DbMpoolFile::set_clear_len</a>, <a href="../api_cxx/memp_set_fileid.html">DbMpoolFile::set_fileid</a>, +<a href="../api_cxx/memp_set_clear_len.html">DbMpoolFile::set_clear_len</a>, <a href="../api_cxx/memp_set_ftype.html">DbMpoolFile::set_ftype</a>, <a href="../api_cxx/memp_set_lsn_offset.html">DbMpoolFile::set_lsn_offset</a>, -<a href="../api_cxx/memp_set_pgcookie.html">DbMpoolFile::set_pgcookie</a>, -<a href="../api_cxx/memp_stat.html">DbEnv::memp_stat</a>, -<a href="../api_cxx/memp_sync.html">DbEnv::memp_sync</a>, +<a href="../api_cxx/memp_set_pgcookie.html">DbMpoolFile::set_pgcookie</a> and -<a href="../api_cxx/memp_trickle.html">DbEnv::memp_trickle</a>. +<a href="../api_cxx/memp_fsync.html">DbMpoolFile::sync</a>. </tt> <table width="100%"><tr><td><br></td><td align=right> <a href="../api_cxx/c_index.html"><img src="../images/api.gif" alt="API"></a><a href="../reftoc.html"><img src="../images/ref.gif" alt="Ref"></a> diff --git a/db/docs/api_cxx/memp_set_fileid.html b/db/docs/api_cxx/memp_set_fileid.html index 50c179a2e..d63738fcc 100644 --- a/db/docs/api_cxx/memp_set_fileid.html +++ b/db/docs/api_cxx/memp_set_fileid.html @@ -1,6 +1,7 @@ -<!--Id: memp_set_fileid.so,v 10.2 2001/10/22 15:24:36 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: memp_set_fileid.so,v 10.4 2002/06/24 14:49:27 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB: DbMpoolFile::set_fileid</title> @@ -51,36 +52,41 @@ using the Berkeley DB access methods instead of calling the pool functions explicitly, or if the files in the memory pool are stored on filesystems in which the default values as described previously are invariant between process and across system reboots. +<p>The DbMpoolFile::set_fileid method configures a file in the memory pool, not only +operations performed using the specified <a href="../api_cxx/mempfile_class.html">DbMpoolFile</a> handle. +<p>The DbMpoolFile::set_fileid interface may not be called after the <a href="../api_cxx/memp_fopen.html">DbMpoolFile::open</a> +interface is called. <p>The DbMpoolFile::set_fileid method either returns a non-zero error value or throws an exception that encapsulates a non-zero error value on failure, and returns 0 on success. <h1>Errors</h1> <p>The DbMpoolFile::set_fileid method may fail and throw an exception or return a non-zero error for errors specified for other Berkeley DB and C library or system methods. -If a catastrophic error has occurred, the DbMpoolFile::set_fileid method may fail and either -return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a> or throw an exception encapsulating -<a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, in which case all subsequent Berkeley DB calls will fail -in the same way. +If a catastrophic error has occurred, the DbMpoolFile::set_fileid method may fail and +either return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a> or throw a +<a href="../api_cxx/runrec_class.html">DbRunRecoveryException</a>, +in which case all subsequent Berkeley DB calls will fail in the same way. <h1>Class</h1> <a href="../api_cxx/dbenv_class.html">DbEnv</a>, <a href="../api_cxx/mempfile_class.html">DbMpoolFile</a> <h1>See Also</h1> <a href="../api_cxx/env_set_cachesize.html">DbEnv::set_cachesize</a>, <a href="../api_cxx/env_set_mp_mmapsize.html">DbEnv::set_mp_mmapsize</a>, +<a href="../api_cxx/memp_register.html">DbEnv::memp_register</a>, +<a href="../api_cxx/memp_stat.html">DbEnv::memp_stat</a>, +<a href="../api_cxx/memp_sync.html">DbEnv::memp_sync</a>, +<a href="../api_cxx/memp_trickle.html">DbEnv::memp_trickle</a>, +<p> <a href="../api_cxx/memp_fcreate.html">DbEnv::memp_fcreate</a>, <a href="../api_cxx/memp_fclose.html">DbMpoolFile::close</a>, <a href="../api_cxx/memp_fget.html">DbMpoolFile::get</a>, <a href="../api_cxx/memp_fopen.html">DbMpoolFile::open</a>, <a href="../api_cxx/memp_fput.html">DbMpoolFile::put</a>, <a href="../api_cxx/memp_fset.html">DbMpoolFile::set</a>, -<a href="../api_cxx/memp_fsync.html">DbMpoolFile::sync</a>, -<a href="../api_cxx/memp_register.html">DbEnv::memp_register</a>, -<a href="../api_cxx/memp_set_clear_len.html">DbMpoolFile::set_clear_len</a>, <a href="../api_cxx/memp_set_fileid.html">DbMpoolFile::set_fileid</a>, +<a href="../api_cxx/memp_set_clear_len.html">DbMpoolFile::set_clear_len</a>, <a href="../api_cxx/memp_set_ftype.html">DbMpoolFile::set_ftype</a>, <a href="../api_cxx/memp_set_lsn_offset.html">DbMpoolFile::set_lsn_offset</a>, -<a href="../api_cxx/memp_set_pgcookie.html">DbMpoolFile::set_pgcookie</a>, -<a href="../api_cxx/memp_stat.html">DbEnv::memp_stat</a>, -<a href="../api_cxx/memp_sync.html">DbEnv::memp_sync</a>, +<a href="../api_cxx/memp_set_pgcookie.html">DbMpoolFile::set_pgcookie</a> and -<a href="../api_cxx/memp_trickle.html">DbEnv::memp_trickle</a>. +<a href="../api_cxx/memp_fsync.html">DbMpoolFile::sync</a>. </tt> <table width="100%"><tr><td><br></td><td align=right> <a href="../api_cxx/c_index.html"><img src="../images/api.gif" alt="API"></a><a href="../reftoc.html"><img src="../images/ref.gif" alt="Ref"></a> diff --git a/db/docs/api_cxx/memp_set_ftype.html b/db/docs/api_cxx/memp_set_ftype.html index 04195c00a..7dd394def 100644 --- a/db/docs/api_cxx/memp_set_ftype.html +++ b/db/docs/api_cxx/memp_set_ftype.html @@ -1,6 +1,7 @@ -<!--Id: memp_set_ftype.so,v 10.2 2001/10/22 15:24:37 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: memp_set_ftype.so,v 10.4 2002/06/24 14:49:27 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB: DbMpoolFile::set_ftype</title> @@ -31,36 +32,44 @@ written to, the backing filesystem store. The <b>ftype</b> argument must be the same as a <b>ftype</b> argument previously specified to the <a href="../api_cxx/memp_register.html">DbEnv::memp_register</a> method. (See the <a href="../api_cxx/memp_register.html">DbEnv::memp_register</a> documentation for more information.) +<p>The DbMpoolFile::set_ftype method configures a file in the memory pool, not only +operations performed using the specified <a href="../api_cxx/mempfile_class.html">DbMpoolFile</a> handle. +<p>The DbMpoolFile::set_ftype interface may not be called after the <a href="../api_cxx/memp_fopen.html">DbMpoolFile::open</a> +interface is called. +If the file is already open in the memory pool when +<a href="../api_cxx/memp_fopen.html">DbMpoolFile::open</a> is called, the information specified to DbMpoolFile::set_ftype +will replace the existing information. <p>The DbMpoolFile::set_ftype method either returns a non-zero error value or throws an exception that encapsulates a non-zero error value on failure, and returns 0 on success. <h1>Errors</h1> <p>The DbMpoolFile::set_ftype method may fail and throw an exception or return a non-zero error for errors specified for other Berkeley DB and C library or system methods. -If a catastrophic error has occurred, the DbMpoolFile::set_ftype method may fail and either -return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a> or throw an exception encapsulating -<a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, in which case all subsequent Berkeley DB calls will fail -in the same way. +If a catastrophic error has occurred, the DbMpoolFile::set_ftype method may fail and +either return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a> or throw a +<a href="../api_cxx/runrec_class.html">DbRunRecoveryException</a>, +in which case all subsequent Berkeley DB calls will fail in the same way. <h1>Class</h1> <a href="../api_cxx/dbenv_class.html">DbEnv</a>, <a href="../api_cxx/mempfile_class.html">DbMpoolFile</a> <h1>See Also</h1> <a href="../api_cxx/env_set_cachesize.html">DbEnv::set_cachesize</a>, <a href="../api_cxx/env_set_mp_mmapsize.html">DbEnv::set_mp_mmapsize</a>, +<a href="../api_cxx/memp_register.html">DbEnv::memp_register</a>, +<a href="../api_cxx/memp_stat.html">DbEnv::memp_stat</a>, +<a href="../api_cxx/memp_sync.html">DbEnv::memp_sync</a>, +<a href="../api_cxx/memp_trickle.html">DbEnv::memp_trickle</a>, +<p> <a href="../api_cxx/memp_fcreate.html">DbEnv::memp_fcreate</a>, <a href="../api_cxx/memp_fclose.html">DbMpoolFile::close</a>, <a href="../api_cxx/memp_fget.html">DbMpoolFile::get</a>, <a href="../api_cxx/memp_fopen.html">DbMpoolFile::open</a>, <a href="../api_cxx/memp_fput.html">DbMpoolFile::put</a>, <a href="../api_cxx/memp_fset.html">DbMpoolFile::set</a>, -<a href="../api_cxx/memp_fsync.html">DbMpoolFile::sync</a>, -<a href="../api_cxx/memp_register.html">DbEnv::memp_register</a>, -<a href="../api_cxx/memp_set_clear_len.html">DbMpoolFile::set_clear_len</a>, <a href="../api_cxx/memp_set_fileid.html">DbMpoolFile::set_fileid</a>, +<a href="../api_cxx/memp_set_clear_len.html">DbMpoolFile::set_clear_len</a>, <a href="../api_cxx/memp_set_ftype.html">DbMpoolFile::set_ftype</a>, <a href="../api_cxx/memp_set_lsn_offset.html">DbMpoolFile::set_lsn_offset</a>, -<a href="../api_cxx/memp_set_pgcookie.html">DbMpoolFile::set_pgcookie</a>, -<a href="../api_cxx/memp_stat.html">DbEnv::memp_stat</a>, -<a href="../api_cxx/memp_sync.html">DbEnv::memp_sync</a>, +<a href="../api_cxx/memp_set_pgcookie.html">DbMpoolFile::set_pgcookie</a> and -<a href="../api_cxx/memp_trickle.html">DbEnv::memp_trickle</a>. +<a href="../api_cxx/memp_fsync.html">DbMpoolFile::sync</a>. </tt> <table width="100%"><tr><td><br></td><td align=right> <a href="../api_cxx/c_index.html"><img src="../images/api.gif" alt="API"></a><a href="../reftoc.html"><img src="../images/ref.gif" alt="Ref"></a> diff --git a/db/docs/api_cxx/memp_set_lsn_offset.html b/db/docs/api_cxx/memp_set_lsn_offset.html index 05891ba4c..74c76d4f8 100644 --- a/db/docs/api_cxx/memp_set_lsn_offset.html +++ b/db/docs/api_cxx/memp_set_lsn_offset.html @@ -1,6 +1,7 @@ -<!--Id: memp_set_lsn_offset.so,v 10.2 2001/10/22 15:24:37 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: memp_set_lsn_offset.so,v 10.4 2002/06/24 14:49:28 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB: DbMpoolFile::set_lsn_offset</title> @@ -29,36 +30,45 @@ DbMpoolFile::set(int32_t lsn_offset); of a log sequence number (<a href="../api_cxx/lsn_class.html">DbLsn</a>) on the file's pages, for the purposes of page-flushing as part of transaction checkpoint. (See the <a href="../api_cxx/memp_sync.html">DbEnv::memp_sync</a> documentation for more information.) +<p>The DbMpoolFile::set_lsn_offset method configures a file in the memory pool, not only +operations performed using the specified <a href="../api_cxx/mempfile_class.html">DbMpoolFile</a> handle. +<p>The DbMpoolFile::set_lsn_offset interface may not be called after the <a href="../api_cxx/memp_fopen.html">DbMpoolFile::open</a> +interface is called. +If the file is already open in the memory pool when +<a href="../api_cxx/memp_fopen.html">DbMpoolFile::open</a> is called, the information specified to DbMpoolFile::set_lsn_offset +must be consistent with the existing file or an error will be +returned. <p>The DbMpoolFile::set_lsn_offset method either returns a non-zero error value or throws an exception that encapsulates a non-zero error value on failure, and returns 0 on success. <h1>Errors</h1> <p>The DbMpoolFile::set_lsn_offset method may fail and throw an exception or return a non-zero error for errors specified for other Berkeley DB and C library or system methods. -If a catastrophic error has occurred, the DbMpoolFile::set_lsn_offset method may fail and either -return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a> or throw an exception encapsulating -<a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, in which case all subsequent Berkeley DB calls will fail -in the same way. +If a catastrophic error has occurred, the DbMpoolFile::set_lsn_offset method may fail and +either return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a> or throw a +<a href="../api_cxx/runrec_class.html">DbRunRecoveryException</a>, +in which case all subsequent Berkeley DB calls will fail in the same way. <h1>Class</h1> <a href="../api_cxx/dbenv_class.html">DbEnv</a>, <a href="../api_cxx/mempfile_class.html">DbMpoolFile</a> <h1>See Also</h1> <a href="../api_cxx/env_set_cachesize.html">DbEnv::set_cachesize</a>, <a href="../api_cxx/env_set_mp_mmapsize.html">DbEnv::set_mp_mmapsize</a>, +<a href="../api_cxx/memp_register.html">DbEnv::memp_register</a>, +<a href="../api_cxx/memp_stat.html">DbEnv::memp_stat</a>, +<a href="../api_cxx/memp_sync.html">DbEnv::memp_sync</a>, +<a href="../api_cxx/memp_trickle.html">DbEnv::memp_trickle</a>, +<p> <a href="../api_cxx/memp_fcreate.html">DbEnv::memp_fcreate</a>, <a href="../api_cxx/memp_fclose.html">DbMpoolFile::close</a>, <a href="../api_cxx/memp_fget.html">DbMpoolFile::get</a>, <a href="../api_cxx/memp_fopen.html">DbMpoolFile::open</a>, <a href="../api_cxx/memp_fput.html">DbMpoolFile::put</a>, <a href="../api_cxx/memp_fset.html">DbMpoolFile::set</a>, -<a href="../api_cxx/memp_fsync.html">DbMpoolFile::sync</a>, -<a href="../api_cxx/memp_register.html">DbEnv::memp_register</a>, -<a href="../api_cxx/memp_set_clear_len.html">DbMpoolFile::set_clear_len</a>, <a href="../api_cxx/memp_set_fileid.html">DbMpoolFile::set_fileid</a>, +<a href="../api_cxx/memp_set_clear_len.html">DbMpoolFile::set_clear_len</a>, <a href="../api_cxx/memp_set_ftype.html">DbMpoolFile::set_ftype</a>, <a href="../api_cxx/memp_set_lsn_offset.html">DbMpoolFile::set_lsn_offset</a>, -<a href="../api_cxx/memp_set_pgcookie.html">DbMpoolFile::set_pgcookie</a>, -<a href="../api_cxx/memp_stat.html">DbEnv::memp_stat</a>, -<a href="../api_cxx/memp_sync.html">DbEnv::memp_sync</a>, +<a href="../api_cxx/memp_set_pgcookie.html">DbMpoolFile::set_pgcookie</a> and -<a href="../api_cxx/memp_trickle.html">DbEnv::memp_trickle</a>. +<a href="../api_cxx/memp_fsync.html">DbMpoolFile::sync</a>. </tt> <table width="100%"><tr><td><br></td><td align=right> <a href="../api_cxx/c_index.html"><img src="../images/api.gif" alt="API"></a><a href="../reftoc.html"><img src="../images/ref.gif" alt="Ref"></a> diff --git a/db/docs/api_cxx/memp_set_pgcookie.html b/db/docs/api_cxx/memp_set_pgcookie.html index 945f729f0..6c89916e8 100644 --- a/db/docs/api_cxx/memp_set_pgcookie.html +++ b/db/docs/api_cxx/memp_set_pgcookie.html @@ -1,6 +1,7 @@ -<!--Id: memp_set_pgcookie.so,v 10.2 2001/10/22 15:24:37 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: memp_set_pgcookie.so,v 10.4 2002/06/24 14:49:28 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB: DbMpoolFile::set_pgcookie</title> @@ -30,36 +31,44 @@ to the functions registered to do input or output processing of the file's pages as they are read from or written to, the backing filesystem store. (See the <a href="../api_cxx/memp_register.html">DbEnv::memp_register</a> documentation for more information.) +<p>The DbMpoolFile::set_pgcookie method configures a file in the memory pool, not only +operations performed using the specified <a href="../api_cxx/mempfile_class.html">DbMpoolFile</a> handle. +<p>The DbMpoolFile::set_pgcookie interface may not be called after the <a href="../api_cxx/memp_fopen.html">DbMpoolFile::open</a> +interface is called. +If the file is already open in the memory pool when +<a href="../api_cxx/memp_fopen.html">DbMpoolFile::open</a> is called, the information specified to DbMpoolFile::set_pgcookie +will replace the existing information. <p>The DbMpoolFile::set_pgcookie method either returns a non-zero error value or throws an exception that encapsulates a non-zero error value on failure, and returns 0 on success. <h1>Errors</h1> <p>The DbMpoolFile::set_pgcookie method may fail and throw an exception or return a non-zero error for errors specified for other Berkeley DB and C library or system methods. -If a catastrophic error has occurred, the DbMpoolFile::set_pgcookie method may fail and either -return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a> or throw an exception encapsulating -<a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, in which case all subsequent Berkeley DB calls will fail -in the same way. +If a catastrophic error has occurred, the DbMpoolFile::set_pgcookie method may fail and +either return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a> or throw a +<a href="../api_cxx/runrec_class.html">DbRunRecoveryException</a>, +in which case all subsequent Berkeley DB calls will fail in the same way. <h1>Class</h1> <a href="../api_cxx/dbenv_class.html">DbEnv</a>, <a href="../api_cxx/mempfile_class.html">DbMpoolFile</a> <h1>See Also</h1> <a href="../api_cxx/env_set_cachesize.html">DbEnv::set_cachesize</a>, <a href="../api_cxx/env_set_mp_mmapsize.html">DbEnv::set_mp_mmapsize</a>, +<a href="../api_cxx/memp_register.html">DbEnv::memp_register</a>, +<a href="../api_cxx/memp_stat.html">DbEnv::memp_stat</a>, +<a href="../api_cxx/memp_sync.html">DbEnv::memp_sync</a>, +<a href="../api_cxx/memp_trickle.html">DbEnv::memp_trickle</a>, +<p> <a href="../api_cxx/memp_fcreate.html">DbEnv::memp_fcreate</a>, <a href="../api_cxx/memp_fclose.html">DbMpoolFile::close</a>, <a href="../api_cxx/memp_fget.html">DbMpoolFile::get</a>, <a href="../api_cxx/memp_fopen.html">DbMpoolFile::open</a>, <a href="../api_cxx/memp_fput.html">DbMpoolFile::put</a>, <a href="../api_cxx/memp_fset.html">DbMpoolFile::set</a>, -<a href="../api_cxx/memp_fsync.html">DbMpoolFile::sync</a>, -<a href="../api_cxx/memp_register.html">DbEnv::memp_register</a>, -<a href="../api_cxx/memp_set_clear_len.html">DbMpoolFile::set_clear_len</a>, <a href="../api_cxx/memp_set_fileid.html">DbMpoolFile::set_fileid</a>, +<a href="../api_cxx/memp_set_clear_len.html">DbMpoolFile::set_clear_len</a>, <a href="../api_cxx/memp_set_ftype.html">DbMpoolFile::set_ftype</a>, <a href="../api_cxx/memp_set_lsn_offset.html">DbMpoolFile::set_lsn_offset</a>, -<a href="../api_cxx/memp_set_pgcookie.html">DbMpoolFile::set_pgcookie</a>, -<a href="../api_cxx/memp_stat.html">DbEnv::memp_stat</a>, -<a href="../api_cxx/memp_sync.html">DbEnv::memp_sync</a>, +<a href="../api_cxx/memp_set_pgcookie.html">DbMpoolFile::set_pgcookie</a> and -<a href="../api_cxx/memp_trickle.html">DbEnv::memp_trickle</a>. +<a href="../api_cxx/memp_fsync.html">DbMpoolFile::sync</a>. </tt> <table width="100%"><tr><td><br></td><td align=right> <a href="../api_cxx/c_index.html"><img src="../images/api.gif" alt="API"></a><a href="../reftoc.html"><img src="../images/ref.gif" alt="Ref"></a> diff --git a/db/docs/api_cxx/rep_elect.html b/db/docs/api_cxx/rep_elect.html index 7aac497e7..a15408235 100644 --- a/db/docs/api_cxx/rep_elect.html +++ b/db/docs/api_cxx/rep_elect.html @@ -1,6 +1,7 @@ -<!--Id: rep_elect.so,v 1.4 2001/10/26 13:57:00 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: rep_elect.so,v 1.6 2002/06/24 14:49:30 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB: DbEnv::rep_elect</title> @@ -65,14 +66,14 @@ encapsulates a non-zero error value on failure, and returns 0 on success. <p><dt>DB_REP_UNAVAIL<dd>The replication group was unable to elect a master. </dl> <p>The DbEnv::rep_elect method may fail and throw an exception or return a non-zero error for errors specified for other Berkeley DB and C library or system methods. -If a catastrophic error has occurred, the DbEnv::rep_elect method may fail and either -return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a> or throw an exception encapsulating -<a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, in which case all subsequent Berkeley DB calls will fail -in the same way. +If a catastrophic error has occurred, the DbEnv::rep_elect method may fail and +either return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a> or throw a +<a href="../api_cxx/runrec_class.html">DbRunRecoveryException</a>, +in which case all subsequent Berkeley DB calls will fail in the same way. <h1>See Also</h1> <a href="../api_cxx/rep_start.html">DbEnv::rep_start</a>, <a href="../api_cxx/rep_elect.html">DbEnv::rep_elect</a>, -<a href="../api_cxx/rep_message.html">DbEnv::rep_process_message</a>, +<a href="../api_cxx/rep_message.html">DbEnv::rep_process_message</a> and <a href="../api_cxx/rep_transport.html">DbEnv::set_rep_transport</a>. </tt> diff --git a/db/docs/api_cxx/rep_message.html b/db/docs/api_cxx/rep_message.html index 4004c3f0e..a11cd9566 100644 --- a/db/docs/api_cxx/rep_message.html +++ b/db/docs/api_cxx/rep_message.html @@ -1,6 +1,7 @@ -<!--Id: rep_message.so,v 1.4 2001/10/25 20:15:23 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: rep_message.so,v 1.9 2002/07/02 15:22:24 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB: DbEnv::rep_process_message</title> @@ -39,39 +40,45 @@ information). processed using the same <a href="../api_cxx/dbenv_class.html">DbEnv</a> handle. It is not required that a single thread of control process all messages, only that all threads of control processing messages use the same handle. -<p>The DbEnv::rep_process_message method may return one of several special conditions: -<p><dl compact> -<p><dt><a name="DB_REP_DUPMASTER">DB_REP_DUPMASTER</a><dd>The replication group has more than one master; the application should -reconfigure itself as a client by calling the <a href="../api_cxx/rep_start.html">DbEnv::rep_start</a> method, and -then call for an election by calling <a href="../api_cxx/rep_elect.html">DbEnv::rep_elect</a>. -<p><dt><a name="DB_REP_HOLDELECTION">DB_REP_HOLDELECTION</a><dd>An election is needed, the application should call for an election by -calling <a href="../api_cxx/rep_elect.html">DbEnv::rep_elect</a>. -<p><dt><a name="DB_REP_NEWMASTER">DB_REP_NEWMASTER</a><dd>A new master has been elected. The memory location referenced by the -<b>envid</b> parameter contains the environment ID of the new master. -If the recipient of this error return has been made master, it is the -application's responsibility to begin acting as the master environment. -<p><dt><a name="DB_REP_NEWSITE">DB_REP_NEWSITE</a><dd>The system received contact information from a new environment. The -<b>rec</b> parameter contains the opaque data specified in the +<p> +If a new master has been elected, the DbEnv::rep_process_message method will return DB_REP_NEWMASTER. +The <b>envid</b> parameter contains the environment ID of the new +master. If the recipient of this error return has been made master, it +is the application's responsibility to begin acting as the master +environment. +<p> +If the system received contact information from a new environment, the DbEnv::rep_process_message method will return DB_REP_NEWSITE. +The <b>rec</b> parameter contains the opaque data specified in the <b>cdata</b> parameter to the <a href="../api_cxx/rep_start.html">DbEnv::rep_start</a>. The application should take whatever action is needed to establish a communication channel with this new environment. -<p><dt><a name="DB_REP_OUTDATED">DB_REP_OUTDATED</a><dd>The current environment's logs are too far out of date with respect to -the master to be automatically synchronized. The application should -copy over a hot backup of the environment, run recovery, and restart -the client. -</dl> -<p>Otherwise, the DbEnv::rep_process_message method either returns a non-zero error value or throws an exception that +<p> +If the replication group has more than one master, the DbEnv::rep_process_message method either returns DB_REP_DUPMASTER or throws an exception that encapsulates DB_REP_DUPMASTER. +The application should reconfigure itself as a client by calling the +<a href="../api_cxx/rep_start.html">DbEnv::rep_start</a> method, and then call for an election by calling +<a href="../api_cxx/rep_elect.html">DbEnv::rep_elect</a>. +<p> +If an election is needed, the DbEnv::rep_process_message method either returns DB_REP_HOLDELECTION or throws an exception that encapsulates DB_REP_HOLDELECTION. +The application should call for an election by +calling <a href="../api_cxx/rep_elect.html">DbEnv::rep_elect</a>. +<p> +If the current environment's logs are too far out of date with respect +to the master to be automatically synchronized, the DbEnv::rep_process_message method either returns DB_REP_OUTDATED or throws an exception that encapsulates DB_REP_OUTDATED. The +application should copy over a hot backup of the environment, run +recovery, and restart the client. +<p> +Otherwise, the DbEnv::rep_process_message method either returns a non-zero error value or throws an exception that encapsulates a non-zero error value on failure, and returns 0 on success. <h1>Errors</h1> <p>The DbEnv::rep_process_message method may fail and throw an exception or return a non-zero error for errors specified for other Berkeley DB and C library or system methods. -If a catastrophic error has occurred, the DbEnv::rep_process_message method may fail and either -return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a> or throw an exception encapsulating -<a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, in which case all subsequent Berkeley DB calls will fail -in the same way. +If a catastrophic error has occurred, the DbEnv::rep_process_message method may fail and +either return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a> or throw a +<a href="../api_cxx/runrec_class.html">DbRunRecoveryException</a>, +in which case all subsequent Berkeley DB calls will fail in the same way. <h1>See Also</h1> <a href="../api_cxx/rep_start.html">DbEnv::rep_start</a>, <a href="../api_cxx/rep_elect.html">DbEnv::rep_elect</a>, -<a href="../api_cxx/rep_message.html">DbEnv::rep_process_message</a>, +<a href="../api_cxx/rep_message.html">DbEnv::rep_process_message</a> and <a href="../api_cxx/rep_transport.html">DbEnv::set_rep_transport</a>. </tt> diff --git a/db/docs/api_cxx/rep_start.html b/db/docs/api_cxx/rep_start.html index 3be75a427..7a81b6fcf 100644 --- a/db/docs/api_cxx/rep_start.html +++ b/db/docs/api_cxx/rep_start.html @@ -1,6 +1,7 @@ -<!--Id: rep_start.so,v 1.2 2001/10/25 14:08:43 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: rep_start.so,v 1.3 2002/06/24 14:49:30 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB: DbEnv::rep_start</title> @@ -57,14 +58,14 @@ replication group by a call to <a href="../api_cxx/rep_transport.html">DbEnv::se <p>The environment was not already opened. </dl> <p>The DbEnv::rep_start method may fail and throw an exception or return a non-zero error for errors specified for other Berkeley DB and C library or system methods. -If a catastrophic error has occurred, the DbEnv::rep_start method may fail and either -return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a> or throw an exception encapsulating -<a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, in which case all subsequent Berkeley DB calls will fail -in the same way. +If a catastrophic error has occurred, the DbEnv::rep_start method may fail and +either return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a> or throw a +<a href="../api_cxx/runrec_class.html">DbRunRecoveryException</a>, +in which case all subsequent Berkeley DB calls will fail in the same way. <h1>See Also</h1> <a href="../api_cxx/rep_start.html">DbEnv::rep_start</a>, <a href="../api_cxx/rep_elect.html">DbEnv::rep_elect</a>, -<a href="../api_cxx/rep_message.html">DbEnv::rep_process_message</a>, +<a href="../api_cxx/rep_message.html">DbEnv::rep_process_message</a> and <a href="../api_cxx/rep_transport.html">DbEnv::set_rep_transport</a>. </tt> diff --git a/db/docs/api_cxx/rep_transport.html b/db/docs/api_cxx/rep_transport.html index 6998e11cd..19fb8d233 100644 --- a/db/docs/api_cxx/rep_transport.html +++ b/db/docs/api_cxx/rep_transport.html @@ -1,6 +1,7 @@ -<!--Id: rep_transport.so,v 1.4 2001/10/26 23:51:06 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: rep_transport.so,v 1.7 2002/06/24 14:49:30 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB: DbEnv::set_rep_transport</title> @@ -51,7 +52,7 @@ The special identifier DB_EID_BROADCAST indicates that a message should be broadcast to every environment in the replication group. The application may use a true broadcast protocol, or may send the message in sequence to each machine with which it is in communication. -<p><dt>flag<dd> +<p><dt>flags<dd> <p>The <b>flags</b> value must be set to 0 or by bitwise inclusively <b>OR</b>'ing together one or more of the following values: <p><dl compact> @@ -70,19 +71,23 @@ otherwise, any error from the <b>send</b> interface will be ignored. <p>It may sometimes be useful to pass application-specific data to the <b>send</b> interface; see <a href="../ref/env/faq.html">Environment FAQ</a> for a discussion on how to do this. -<p>The <b>flags</b> parameter is currently unused, and must be set to 0. +<p>The DbEnv::set_rep_transport method configures operations performed using the specified +<a href="../api_cxx/dbenv_class.html">DbEnv</a> handle, not all operations performed on the underlying +database environment. +<p>The DbEnv::set_rep_transport interface may be called at any time during the life of +the application. <p>The DbEnv::set_rep_transport method either returns a non-zero error value or throws an exception that encapsulates a non-zero error value on failure, and returns 0 on success. <h1>Errors</h1> <p>The DbEnv::set_rep_transport method may fail and throw an exception or return a non-zero error for errors specified for other Berkeley DB and C library or system methods. -If a catastrophic error has occurred, the DbEnv::set_rep_transport method may fail and either -return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a> or throw an exception encapsulating -<a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, in which case all subsequent Berkeley DB calls will fail -in the same way. +If a catastrophic error has occurred, the DbEnv::set_rep_transport method may fail and +either return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a> or throw a +<a href="../api_cxx/runrec_class.html">DbRunRecoveryException</a>, +in which case all subsequent Berkeley DB calls will fail in the same way. <h1>See Also</h1> <a href="../api_cxx/rep_start.html">DbEnv::rep_start</a>, <a href="../api_cxx/rep_elect.html">DbEnv::rep_elect</a>, -<a href="../api_cxx/rep_message.html">DbEnv::rep_process_message</a>, +<a href="../api_cxx/rep_message.html">DbEnv::rep_process_message</a> and <a href="../api_cxx/rep_transport.html">DbEnv::set_rep_transport</a>. </tt> diff --git a/db/docs/api_cxx/txn_set_timeout.html b/db/docs/api_cxx/txn_set_timeout.html index f67020601..29e675587 100644 --- a/db/docs/api_cxx/txn_set_timeout.html +++ b/db/docs/api_cxx/txn_set_timeout.html @@ -1,6 +1,7 @@ -<!--Id: txn_set_timeout.so,v 10.3 2001/10/22 15:24:39 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: txn_set_timeout.so,v 10.6 2002/06/24 14:49:36 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB: DbTxn::set_timeout</title> @@ -46,6 +47,11 @@ is performed, the accuracy of the timeout depends on how often deadlock detection is performed. <p>Timeout values may be specified for the database environment as a whole. See <a href="../api_cxx/env_set_timeout.html">DbEnv::set_timeout</a> and for more information. +<p>The DbTxn::set_timeout method configures operations performed on the underlying +transaction, not only operations performed using the specified +<a href="../api_cxx/txn_class.html">DbTxn</a> handle. +<p>The DbTxn::set_timeout interface may be called at any time during the life of +the application. <p>The DbTxn::set_timeout method either returns a non-zero error value or throws an exception that encapsulates a non-zero error value on failure, and returns 0 on success. <h1>Errors</h1> @@ -54,27 +60,28 @@ encapsulates a non-zero error value on failure, and returns 0 on success. <p><dt>EINVAL<dd>An invalid flag value or parameter was specified. </dl> <p>The DbTxn::set_timeout method may fail and throw an exception or return a non-zero error for errors specified for other Berkeley DB and C library or system methods. -If a catastrophic error has occurred, the DbTxn::set_timeout method may fail and either -return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a> or throw an exception encapsulating -<a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a>, in which case all subsequent Berkeley DB calls will fail -in the same way. +If a catastrophic error has occurred, the DbTxn::set_timeout method may fail and +either return <a href="../ref/program/errorret.html#DB_RUNRECOVERY">DB_RUNRECOVERY</a> or throw a +<a href="../api_cxx/runrec_class.html">DbRunRecoveryException</a>, +in which case all subsequent Berkeley DB calls will fail in the same way. <h1>Class</h1> <a href="../api_cxx/dbenv_class.html">DbEnv</a>, <a href="../api_cxx/txn_class.html">DbTxn</a> <h1>See Also</h1> <a href="../api_cxx/env_set_tx_max.html">DbEnv::set_tx_max</a>, -<a href="../api_cxx/env_set_tx_recover.html">DbEnv::set_tx_recover</a>, <a href="../api_cxx/env_set_tx_timestamp.html">DbEnv::set_tx_timestamp</a>, -<a href="../api_cxx/txn_abort.html">DbTxn::abort</a>, <a href="../api_cxx/txn_begin.html">DbEnv::txn_begin</a>, <a href="../api_cxx/txn_checkpoint.html">DbEnv::txn_checkpoint</a>, +<a href="../api_cxx/txn_recover.html">DbEnv::txn_recover</a> +and +<a href="../api_cxx/txn_stat.html">DbEnv::txn_stat</a>. +<p> +<a href="../api_cxx/txn_abort.html">DbTxn::abort</a>, <a href="../api_cxx/txn_commit.html">DbTxn::commit</a>, <a href="../api_cxx/txn_discard.html">DbTxn::discard</a>, <a href="../api_cxx/txn_id.html">DbTxn::id</a>, -<a href="../api_cxx/txn_prepare.html">DbTxn::prepare</a>, -<a href="../api_cxx/txn_recover.html">DbEnv::txn_recover</a>, -<a href="../api_cxx/txn_set_timeout.html">DbTxn::set_timeout</a> +<a href="../api_cxx/txn_prepare.html">DbTxn::prepare</a> and -<a href="../api_cxx/txn_stat.html">DbEnv::txn_stat</a>. +<a href="../api_cxx/txn_set_timeout.html">DbTxn::set_timeout</a>. </tt> <table width="100%"><tr><td><br></td><td align=right> <a href="../api_cxx/c_index.html"><img src="../images/api.gif" alt="API"></a><a href="../reftoc.html"><img src="../images/ref.gif" alt="Ref"></a> diff --git a/db/docs/api_java/c_index.html b/db/docs/api_java/c_index.html index 2647f7042..73c9cbb1f 100644 --- a/db/docs/api_java/c_index.html +++ b/db/docs/api_java/c_index.html @@ -1,39 +1,47 @@ -<!--Id: c_index.so,v 10.80 2001/10/13 19:56:20 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: c_index.so,v 10.96 2002/07/24 05:06:08 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> -<title>Berkeley DB: Java Interface</title> +<title>Berkeley DB: Berkeley DB: Java Interface</title> <meta name="description" content="Berkeley DB: An embedded database programmatic toolkit."> <meta name="keywords" content="embedded,database,programmatic,toolkit,b+tree,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,java,C,C++"> </head> <body bgcolor=white> -<h1 align=center>Java Interface</h1> +<h1 align=center>Berkeley DB: Java Interface</h1> <p><table border=1 align=center> <tr><th>Section</th><th>Class/Method</th><th>Description</th></tr> <tr><td><b>Database Environment</b></td><td><a href="../api_java/dbenv_class.html">DbEnv</a></td><td>Create an environment handle</td></tr> <tr><td><br></td><td><a href="../api_java/env_close.html">DbEnv.close</a></td><td>Close an environment</td></tr> +<tr><td><br></td><td><a href="../api_java/env_dbremove.html">DbEnv.dbremove</a></td><td>Remove a database</td></tr> +<tr><td><br></td><td><a href="../api_java/env_dbrename.html">DbEnv.dbrename</a></td><td>Rename a database</td></tr> +<tr><td><br></td><td><a href="../api_java/env_err.html">DbEnv.err</a></td><td>Error message with error string</td></tr> +<tr><td><br></td><td><a href="../api_java/env_err.html">DbEnv.errx</a></td><td>Error message</td></tr> <tr><td><br></td><td><a href="../api_java/env_open.html">DbEnv.open</a></td><td>Open an environment</td></tr> <tr><td><br></td><td><a href="../api_java/env_remove.html">DbEnv.remove</a></td><td>Remove an environment</td></tr> +<tr><td><br></td><td><a href="../api_java/env_strerror.html">DbEnv.strerror</a></td><td>Error strings</td></tr> +<tr><td><br></td><td><a href="../api_java/env_version.html">DbEnv.version</a></td><td>Return version information</td></tr> +<tr><td><b>Environment Configuration</b></td><td><a href="../api_java/env_set_app_dispatch.html">DbEnv.set_app_dispatch</a></td><td>Configure application recovery interface</td></tr> <tr><td><br></td><td><a href="../api_java/env_set_data_dir.html">DbEnv.set_data_dir</a></td><td>Set the environment data directory</td></tr> +<tr><td><br></td><td><a href="../api_java/env_set_encrypt.html">DbEnv.set_encrypt</a></td><td>Set the environment cryptographic key</td></tr> <tr><td><br></td><td><a href="../api_java/env_set_errcall.html">DbEnv.set_errcall</a></td><td>Set error message callback</td></tr> <tr><td><br></td><td><a href="../api_java/env_set_error_stream.html">DbEnv.set_error_stream</a></td><td>Set error message output stream</td></tr> <tr><td><br></td><td><a href="../api_java/env_set_errpfx.html">DbEnv.set_errpfx</a></td><td>Set error message prefix</td></tr> <tr><td><br></td><td><a href="../api_java/env_set_feedback.html">DbEnv.set_feedback</a></td><td>Set feedback callback</td></tr> <tr><td><br></td><td><a href="../api_java/env_set_flags.html">DbEnv.set_flags</a></td><td>Environment configuration</td></tr> -<tr><td><br></td><td><a href="../api_java/env_set_rec_init.html">DbEnv.set_recovery_init</a></td><td>Set recovery initialization callback</td></tr> <tr><td><br></td><td><a href="../api_java/env_set_rpc_server.html">DbEnv.set_rpc_server</a></td><td>Establish an RPC server connection</td></tr> <tr><td><br></td><td><a href="../api_java/env_set_shm_key.html">DbEnv.set_shm_key</a></td><td>Set system memory shared segment ID</td></tr> <tr><td><br></td><td><a href="../api_java/env_set_tas_spins.html">DbEnv.set_tas_spins</a></td><td>Set the number of test-and-set spins</td></tr> <tr><td><br></td><td><a href="../api_java/env_set_tmp_dir.html">DbEnv.set_tmp_dir</a></td><td>Set the environment temporary file directory</td></tr> <tr><td><br></td><td><a href="../api_java/env_set_timeout.html">DbEnv.set_timeout</a></td><td>Set lock and transaction timeout</td></tr> <tr><td><br></td><td><a href="../api_java/env_set_verbose.html">DbEnv.set_verbose</a></td><td>Set verbose messages</td></tr> -<tr><td><br></td><td><a href="../api_java/env_strerror.html">DbEnv.strerror</a></td><td>Error strings</td></tr> -<tr><td><br></td><td><a href="../api_java/env_version.html">DbEnv.version</a></td><td>Return version information</td></tr> <tr><td><b>Database Operations</b></td><td><a href="../api_java/db_class.html">Db</a></td><td>Create a database handle</td></tr> <tr><td><br></td><td><a href="../api_java/db_associate.html">Db.associate</a></td><td>Associate a secondary index</td></tr> <tr><td><br></td><td><a href="../api_java/db_close.html">Db.close</a></td><td>Close a database</td></tr> <tr><td><br></td><td><a href="../api_java/db_del.html">Db.del</a></td><td>Delete items from a database</td></tr> +<tr><td><br></td><td><a href="../api_java/db_err.html">Db.err</a></td><td>Error message with error string</td></tr> +<tr><td><br></td><td><a href="../api_java/db_err.html">Db.errx</a></td><td>Error message</td></tr> <tr><td><br></td><td><a href="../api_java/db_fd.html">Db.fd</a></td><td>Return a file descriptor from a database</td></tr> <tr><td><br></td><td><a href="../api_java/db_get.html">Db.get</a>, <a href="../api_java/db_get.html">Db.pget</a></td><td>Get items from a database</td></tr> <tr><td><br></td><td><a href="../api_java/db_get_byteswapped.html">Db.get_byteswapped</a></td><td>Return if the underlying database is in host order</td></tr> @@ -49,12 +57,15 @@ <tr><td><br></td><td><a href="../api_java/db_truncate.html">Db.truncate</a></td><td>Empty a database</td></tr> <tr><td><br></td><td><a href="../api_java/db_upgrade.html">Db.upgrade</a></td><td>Upgrade a database</td></tr> <tr><td><br></td><td><a href="../api_java/db_verify.html">Db.verify</a></td><td>Verify/salvage a database</td></tr> -<tr><td><b>Database Configuration</b></td><td><a href="../api_java/db_set_cachesize.html">Db.set_cachesize</a></td><td>Set the database cache size</td></tr> +<tr><td><b>Database Configuration</b></td><td><a href="../api_java/db_set_cache_priority.html">Db.set_cache_priority</a></td><td>Set the database cache priority</td></tr> +<tr><td><br></td><td><a href="../api_java/db_set_cachesize.html">Db.set_cachesize</a></td><td>Set the database cache size</td></tr> <tr><td><br></td><td><a href="../api_java/db_set_dup_compare.html">Db.set_dup_compare</a></td><td>Set a duplicate comparison function</td></tr> +<tr><td><br></td><td><a href="../api_java/db_set_encrypt.html">Db.set_encrypt</a></td><td>Set the database cryptographic key</td></tr> <tr><td><br></td><td><a href="../api_java/db_set_errcall.html">Db.set_errcall</a></td><td>Set error message callback</td></tr> <tr><td><br></td><td><a href="../api_java/db_set_errpfx.html">Db.set_errpfx</a></td><td>Set error message prefix</td></tr> <tr><td><br></td><td><a href="../api_java/db_set_feedback.html">Db.set_feedback</a></td><td>Set feedback callback</td></tr> <tr><td><br></td><td><a href="../api_java/db_set_flags.html">Db.set_flags</a></td><td>General database configuration</td></tr> +<tr><td><br></td><td><a href="../api_java/db_set_lorder.html">Db.set_lorder</a></td><td>Set the database byte order</td></tr> <tr><td><br></td><td><a href="../api_java/db_set_pagesize.html">Db.set_pagesize</a></td><td>Set the underlying database page size</td></tr> <tr><td><b>Btree/Recno Configuration</b></td><td><a href="../api_java/db_set_append_recno.html">Db.set_append_recno</a></td><td>Set record append callback</td></tr> <tr><td><br></td><td><a href="../api_java/db_set_bt_compare.html">Db.set_bt_compare</a></td><td>Set a Btree comparison function</td></tr> @@ -67,7 +78,6 @@ <tr><td><b>Hash Configuration</b></td><td><a href="../api_java/db_set_h_ffactor.html">Db.set_h_ffactor</a></td><td>Set the Hash table density</td></tr> <tr><td><br></td><td><a href="../api_java/db_set_h_hash.html">Db.set_h_hash</a></td><td>Set a hashing function</td></tr> <tr><td><br></td><td><a href="../api_java/db_set_h_nelem.html">Db.set_h_nelem</a></td><td>Set the Hash table size</td></tr> -<tr><td><br></td><td><a href="../api_java/db_set_lorder.html">Db.set_lorder</a></td><td>Set the database byte order</td></tr> <tr><td><b>Queue Configuration</b></td><td><a href="../api_java/db_set_q_extentsize.html">Db.set_q_extentsize</a></td><td>Set Queue database extent size</td></tr> <tr><td><b>Database Cursor Operations</b></td><td><a href="../api_java/dbc_class.html">Dbc</a></td><td><b>Cursor class</b></td></tr> <tr><td><br></td><td><a href="../api_java/db_cursor.html">Db.cursor</a></td><td>Create a cursor handle</td></tr> @@ -92,6 +102,7 @@ <tr><td><br></td><td><a href="../api_java/lock_id_free.html">DbEnv.lock_id_free</a></td><td>Release a locker ID</td></tr> <tr><td><br></td><td><a href="../api_java/lock_put.html">DbEnv.lock_put</a></td><td>Release a lock</td></tr> <tr><td><br></td><td><a href="../api_java/lock_stat.html">DbEnv.lock_stat</a></td><td>Return lock subsystem statistics</td></tr> +<tr><td><br></td><td><a href="../api_java/lock_vec.html">DbEnv.lock_vec</a></td><td>Acquire/release locks</td></tr> <tr><td><b>Log Subsystem</b></td><td><a href="../api_java/env_set_lg_bsize.html">DbEnv.set_lg_bsize</a></td><td>Set log buffer size</td></tr> <tr><td><br></td><td><a href="../api_java/env_set_lg_dir.html">DbEnv.set_lg_dir</a></td><td>Set the environment logging directory</td></tr> <tr><td><br></td><td><a href="../api_java/env_set_lg_max.html">DbEnv.set_lg_max</a></td><td>Set log file size</td></tr> @@ -100,22 +111,18 @@ <tr><td><br></td><td><a href="../api_java/log_file.html">DbEnv.log_file</a></td><td>Map Log Sequence Numbers to log files</td></tr> <tr><td><br></td><td><a href="../api_java/log_flush.html">DbEnv.log_flush</a></td><td>Flush log records</td></tr> <tr><td><br></td><td><a href="../api_java/log_put.html">DbEnv.log_put</a></td><td>Write a log record</td></tr> -<tr><td><br></td><td><a href="../api_java/log_register.html">DbEnv.log_register</a></td><td>Register a filename with the log manager</td></tr> <tr><td><br></td><td><a href="../api_java/log_stat.html">DbEnv.log_stat</a></td><td>Return log subsystem statistics</td></tr> -<tr><td><br></td><td><a href="../api_java/log_unregister.html">DbEnv.log_unregister</a></td><td>Unregister a filename with the log manager</td></tr> <tr><td><b>Log Cursor Operations</b></td><td><a href="../api_java/logc_class.html">DbLogc</a></td><td><b>Log cursor class</b></td></tr> <tr><td><br></td><td><a href="../api_java/log_cursor.html">DbEnv.log_cursor</a></td><td>Create a log cursor handle</td></tr> -<tr><td><br></td><td><a href="../api_java/logc_close.html">DbLogc.logc_close</a></td><td>Close a log cursor</td></tr> -<tr><td><br></td><td><a href="../api_java/logc_get.html">DbLogc.logc_get</a></td><td>Retrieve a log record</td></tr> +<tr><td><br></td><td><a href="../api_java/logc_close.html">DbLogc.close</a></td><td>Close a log cursor</td></tr> +<tr><td><br></td><td><a href="../api_java/logc_get.html">DbLogc.get</a></td><td>Retrieve a log record</td></tr> <tr><td><b>Log Sequence Numbers</b></td><td><a href="../api_java/lsn_class.html">DbLsn</a></td><td><br></td></tr> <tr><td><br></td><td><a href="../api_java/log_compare.html">DbEnv.log_compare</a></td><td>Compare two Log Sequence Numbers</td></tr> <tr><td><b>Memory Pool Subsystem</b></td><td><a href="../api_java/env_set_cachesize.html">DbEnv.set_cachesize</a></td><td>Set the environment cache size</td></tr> <tr><td><br></td><td><a href="../api_java/env_set_mp_mmapsize.html">DbEnv.set_mp_mmapsize</a></td><td>Set maximum mapped-in database file size</td></tr> -<tr><td><br></td><td><a href="../api_java/memp_stat.html">DbEnv.memp_stat</a></td><td>Return memory pool statistics</td></tr> +<tr><td><br></td><td><a href="../api_java/memp_stat.html">DbEnv.memp_stat</a>, <a href="../api_java/memp_stat.html">DbEnv.memp_fstat</a></td><td>Return memory pool statistics</td></tr> <tr><td><br></td><td><a href="../api_java/memp_trickle.html">DbEnv.memp_trickle</a></td><td>Trickle flush pages from a memory pool</td></tr> -<tr><td><br></td><td><a href="../api_java/memp_stat.html">DbEnv.memp_fstat</a></td><td>Return memory pool statistics</td></tr> <tr><td><b>Transaction Subsystem</b></td><td><a href="../api_java/env_set_tx_max.html">DbEnv.set_tx_max</a></td><td>Set maximum number of transactions</td></tr> -<tr><td><br></td><td><a href="../api_java/env_set_tx_recover.html">DbEnv.set_tx_recover</a></td><td>Set transaction abort recover function</td></tr> <tr><td><br></td><td><a href="../api_java/env_set_tx_timestamp.html">DbEnv.set_tx_timestamp</a></td><td>Set recovery timestamp</td></tr> <tr><td><br></td><td><a href="../api_java/txn_checkpoint.html">DbEnv.txn_checkpoint</a></td><td>Checkpoint the transaction subsystem</td></tr> <tr><td><br></td><td><a href="../api_java/txn_recover.html">DbEnv.txn_recover</a></td><td>Distributed transaction recovery</td></tr> @@ -130,13 +137,15 @@ <tr><td><br></td><td><a href="../api_java/txn_set_timeout.html">DbTxn.set_timeout</a></td><td>Set transaction timeout</td></tr> <tr><td><b>Replication</b></td><td><a href="../api_java/rep_transport.html">DbEnv.set_rep_transport</a></td><td>Configure replication transport</td></tr> <tr><td><br></td><td><a href="../api_java/rep_elect.html">DbEnv.rep_elect</a></td><td>Hold a replication election</td></tr> +<tr><td><br></td><td><a href="../api_java/rep_limit.html">DbEnv.set_rep_limit</a></td><td>Limit data sent in response to a single message</td></tr> <tr><td><br></td><td><a href="../api_java/rep_message.html">DbEnv.rep_process_message</a></td><td>Process a replication message</td></tr> <tr><td><br></td><td><a href="../api_java/rep_start.html">DbEnv.rep_start</a></td><td>Configure an environment for replication</td></tr> +<tr><td><br></td><td><a href="../api_java/rep_stat.html">DbEnv.rep_stat</a></td><td>Replication statistics</td></tr> <tr><td><b>Exceptions</b></td><td><a href="../api_java/except_class.html">DbException</a></td><td><b>Exception Class for Berkeley DB Activity</b></td></tr> <tr><td><br></td><td><a href="../api_java/get_errno.html">DbException.get_errno</a></td><td>Get the error value</td></tr> <tr><td><br></td><td><a href="../api_java/deadlock_class.html">DbDeadlockException</a></td><td><b>Exception Class for deadlocks</b></td></tr> +<tr><td><br></td><td><a href="../api_java/lockng_class.html">DbLockNotGrantedException</a></td><td><b>Exception Class for lock request failures</b></td></tr> <tr><td><br></td><td><a href="../api_java/mem_class.html">DbMemoryException</a></td><td><b>Exception Class for insufficient memory</b></td></tr> -<tr><td><br></td><td><a href="../api_java/get_dbt.html">DbMemoryException.get_dbt</a></td><td>Get the failing Dbt</td></tr> <tr><td><br></td><td><a href="../api_java/runrec_class.html">DbRunRecoveryException</a></td><td><b>Exception Class for failures requiring recovery</b></td></tr> </table> <p><font size=1><a href="http://www.sleepycat.com">Copyright Sleepycat Software</a></font> diff --git a/db/docs/api_java/dbt_bulk_class.html b/db/docs/api_java/dbt_bulk_class.html index 51bb116e6..e58524221 100644 --- a/db/docs/api_java/dbt_bulk_class.html +++ b/db/docs/api_java/dbt_bulk_class.html @@ -1,6 +1,7 @@ -<!--Id: dbt_bulk_class.so,v 1.2 2001/07/02 01:03:13 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: dbt_bulk_class.so,v 1.4 2002/06/27 19:35:20 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB: DbMultipleDataIterator</title> diff --git a/db/docs/api_java/env_set_timeout.html b/db/docs/api_java/env_set_timeout.html index 809bfdd48..2657643c4 100644 --- a/db/docs/api_java/env_set_timeout.html +++ b/db/docs/api_java/env_set_timeout.html @@ -1,6 +1,7 @@ -<!--Id: env_set_timeout.so,v 10.3 2001/10/22 15:24:31 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: env_set_timeout.so,v 10.6 2002/06/24 14:49:21 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB: DbEnv.set_timeout</title> @@ -59,42 +60,61 @@ detection is performed. <p>Timeout values specified for the database environment may be overridden on a per-lock or per-transaction basis. See <a href="../api_java/lock_vec.html">DbEnv.lock_vec</a> and <a href="../api_java/txn_set_timeout.html">DbTxn.set_timeout</a> for more information. -<p>The DbEnv.set_timeout interface may be used only to configure Berkeley DB before -the <a href="../api_java/env_open.html">DbEnv.open</a> interface is called. +<p>The DbEnv.set_timeout method configures a database environment, not only operations +performed using the specified <a href="../api_java/dbenv_class.html">DbEnv</a> handle. +<p>The DbEnv.set_timeout interface may be called at any time during the life of +the application. <p>The DbEnv.set_timeout method throws an exception that encapsulates a non-zero error value on failure. <h1>Errors</h1> <p>The DbEnv.set_timeout method may fail and throw an exception encapsulating a non-zero error for the following conditions: <p><dl compact> <p><dt>EINVAL<dd>An invalid flag value or parameter was specified. -<p>Called after <a href="../api_java/env_open.html">DbEnv.open</a> was called. </dl> <p>The DbEnv.set_timeout method may fail and throw an exception for errors specified for other Berkeley DB and C library or system methods. -If a catastrophic error has occurred, the DbEnv.set_timeout method may fail and throw -a <a href="../api_java/runrec_class.html">DbRunRecoveryException</a>, in which case all subsequent Berkeley DB calls -will fail in the same way. +If a catastrophic error has occurred, the DbEnv.set_timeout method may fail and +throw a <a href="../api_java/runrec_class.html">DbRunRecoveryException</a>, +in which case all subsequent Berkeley DB calls will fail in the same way. <h1>Class</h1> <a href="../api_java/dbenv_class.html">DbEnv</a> <h1>See Also</h1> <a href="../api_java/env_close.html">DbEnv.close</a>, +<a href="../api_java/env_dbremove.html">DbEnv.dbremove</a>, +<a href="../api_java/env_dbrename.html">DbEnv.dbrename</a>, +<a href="../api_java/env_err.html">DbEnv.err</a>, +<a href="../api_java/env_err.html">DbEnv.errx</a>, <a href="../api_java/env_version.html">DbEnv.get_version_string</a>, <a href="../api_java/env_open.html">DbEnv.open</a>, <a href="../api_java/env_remove.html">DbEnv.remove</a>, +<a href="../api_java/env_set_app_dispatch.html">DbEnv.set_app_dispatch</a>, <a href="../api_java/env_set_cachesize.html">DbEnv.set_cachesize</a>, <a href="../api_java/env_set_data_dir.html">DbEnv.set_data_dir</a>, +<a href="../api_java/env_set_encrypt.html">DbEnv.set_encrypt</a>, <a href="../api_java/env_set_errcall.html">DbEnv.set_errcall</a>, <a href="../api_java/env_set_error_stream.html">DbEnv.set_error_stream</a>, <a href="../api_java/env_set_errpfx.html">DbEnv.set_errpfx</a>, <a href="../api_java/env_set_feedback.html">DbEnv.set_feedback</a>, <a href="../api_java/env_set_flags.html">DbEnv.set_flags</a>, -<a href="../api_java/env_set_rec_init.html">DbEnv.set_recovery_init</a>, +<a href="../api_java/env_set_lg_bsize.html">DbEnv.set_lg_bsize</a>, +<a href="../api_java/env_set_lg_dir.html">DbEnv.set_lg_dir</a>, +<a href="../api_java/env_set_lg_max.html">DbEnv.set_lg_max</a>, +<a href="../api_java/env_set_lg_regionmax.html">DbEnv.set_lg_regionmax</a>, +<a href="../api_java/env_set_lk_conflicts.html">DbEnv.set_lk_conflicts</a>, +<a href="../api_java/env_set_lk_detect.html">DbEnv.set_lk_detect</a>, +<a href="../api_java/env_set_lk_max_lockers.html">DbEnv.set_lk_max_lockers</a>, +<a href="../api_java/env_set_lk_max_locks.html">DbEnv.set_lk_max_locks</a>, +<a href="../api_java/env_set_lk_max_objects.html">DbEnv.set_lk_max_objects</a>, +<a href="../api_java/env_set_mp_mmapsize.html">DbEnv.set_mp_mmapsize</a>, <a href="../api_java/env_set_rpc_server.html">DbEnv.set_rpc_server</a>, <a href="../api_java/env_set_shm_key.html">DbEnv.set_shm_key</a>, <a href="../api_java/env_set_tas_spins.html">DbEnv.set_tas_spins</a>, -<a href="../api_java/env_set_tmp_dir.html">DbEnv.set_tmp_dir</a>, <a href="../api_java/env_set_timeout.html">DbEnv.set_timeout</a>, -<a href="../api_java/env_set_verbose.html">DbEnv.set_verbose</a>, -and <a href="../api_java/env_strerror.html">DbEnv.strerror</a>. +<a href="../api_java/env_set_tmp_dir.html">DbEnv.set_tmp_dir</a>, +<a href="../api_java/env_set_tx_max.html">DbEnv.set_tx_max</a>, +<a href="../api_java/env_set_tx_timestamp.html">DbEnv.set_tx_timestamp</a>, +<a href="../api_java/env_set_verbose.html">DbEnv.set_verbose</a> +and +<a href="../api_java/env_strerror.html">DbEnv.strerror</a>. </tt> <table width="100%"><tr><td><br></td><td align=right> <a href="../api_java/c_index.html"><img src="../images/api.gif" alt="API"></a><a href="../reftoc.html"><img src="../images/ref.gif" alt="Ref"></a> diff --git a/db/docs/api_java/lock_id_free.html b/db/docs/api_java/lock_id_free.html index f275643a3..57b47f026 100644 --- a/db/docs/api_java/lock_id_free.html +++ b/db/docs/api_java/lock_id_free.html @@ -1,6 +1,7 @@ -<!--Id: lock_id_free.so,v 10.2 2001/10/22 15:24:32 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: lock_id_free.so,v 10.4 2002/06/24 14:49:23 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB: DbEnv.lock_id_free</title> @@ -21,7 +22,7 @@ <h3><pre> import com.sleepycat.db.*; <p> -public int lock_id_free(int id) +public void lock_id_free(int id) throws DbException; </pre></h3> <h1>Description</h1> @@ -35,9 +36,9 @@ failure. <p>The locker ID is invalid or locks are still held by this locker ID. </dl> <p>The DbEnv.lock_id_free method may fail and throw an exception for errors specified for other Berkeley DB and C library or system methods. -If a catastrophic error has occurred, the DbEnv.lock_id_free method may fail and throw -a <a href="../api_java/runrec_class.html">DbRunRecoveryException</a>, in which case all subsequent Berkeley DB calls -will fail in the same way. +If a catastrophic error has occurred, the DbEnv.lock_id_free method may fail and +throw a <a href="../api_java/runrec_class.html">DbRunRecoveryException</a>, +in which case all subsequent Berkeley DB calls will fail in the same way. <h1>Class</h1> <a href="../api_java/dbenv_class.html">DbEnv</a>, <a href="../api_java/lock_class.html">DbLock</a> <h1>See Also</h1> @@ -50,7 +51,7 @@ will fail in the same way. <a href="../api_java/lock_get.html">DbEnv.lock_get</a>, <a href="../api_java/lock_id.html">DbEnv.lock_id</a>, <a href="../api_java/lock_id_free.html">DbEnv.lock_id_free</a>, -<a href="../api_java/lock_put.html">DbEnv.lock_put</a>, +<a href="../api_java/lock_put.html">DbEnv.lock_put</a> and <a href="../api_java/lock_stat.html">DbEnv.lock_stat</a>. </tt> diff --git a/db/docs/api_java/log_cursor.html b/db/docs/api_java/log_cursor.html index 6c3acd5f7..9542433af 100644 --- a/db/docs/api_java/log_cursor.html +++ b/db/docs/api_java/log_cursor.html @@ -1,6 +1,7 @@ -<!--Id: log_cursor.so,v 10.2 2001/10/22 15:24:33 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: log_cursor.so,v 10.3 2002/06/24 14:49:24 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB: DbEnv.log_cursor</title> @@ -36,9 +37,9 @@ failure. <p><dt>EINVAL<dd>An invalid flag value or parameter was specified. </dl> <p>The DbEnv.log_cursor method may fail and throw an exception for errors specified for other Berkeley DB and C library or system methods. -If a catastrophic error has occurred, the DbEnv.log_cursor method may fail and throw -a <a href="../api_java/runrec_class.html">DbRunRecoveryException</a>, in which case all subsequent Berkeley DB calls -will fail in the same way. +If a catastrophic error has occurred, the DbEnv.log_cursor method may fail and +throw a <a href="../api_java/runrec_class.html">DbRunRecoveryException</a>, +in which case all subsequent Berkeley DB calls will fail in the same way. <h1>Class</h1> <a href="../api_java/db_class.html">Db</a> <h1>See Also</h1> @@ -46,20 +47,24 @@ will fail in the same way. <a href="../api_java/db_close.html">Db.close</a>, <a href="../api_java/db_cursor.html">Db.cursor</a>, <a href="../api_java/db_del.html">Db.del</a>, +<a href="../api_java/db_err.html">Db.err</a>, +<a href="../api_java/db_err.html">Db.errx</a>, <a href="../api_java/db_fd.html">Db.fd</a>, <a href="../api_java/db_get.html">Db.get</a>, -<a href="../api_java/db_get.html">Db.pget</a>, <a href="../api_java/db_get_byteswapped.html">Db.get_byteswapped</a>, <a href="../api_java/db_get_type.html">Db.get_type</a>, <a href="../api_java/db_join.html">Db.join</a>, <a href="../api_java/db_key_range.html">Db.key_range</a>, <a href="../api_java/db_open.html">Db.open</a>, +<a href="../api_java/db_get.html">Db.pget</a>, <a href="../api_java/db_put.html">Db.put</a>, <a href="../api_java/db_remove.html">Db.remove</a>, <a href="../api_java/db_rename.html">Db.rename</a>, <a href="../api_java/db_set_append_recno.html">Db.set_append_recno</a>, <a href="../api_java/db_set_bt_minkey.html">Db.set_bt_minkey</a>, +<a href="../api_java/db_set_cache_priority.html">Db.set_cache_priority</a>, <a href="../api_java/db_set_cachesize.html">Db.set_cachesize</a>, +<a href="../api_java/db_set_encrypt.html">Db.set_encrypt</a>, <a href="../api_java/db_set_errcall.html">Db.set_errcall</a>, <a href="../api_java/db_set_errpfx.html">Db.set_errpfx</a>, <a href="../api_java/db_set_feedback.html">Db.set_feedback</a>, @@ -76,7 +81,7 @@ will fail in the same way. <a href="../api_java/db_stat.html">Db.stat</a>, <a href="../api_java/db_sync.html">Db.sync</a>, <a href="../api_java/db_truncate.html">Db.truncate</a>, -<a href="../api_java/db_upgrade.html">Db.upgrade</a>, +<a href="../api_java/db_upgrade.html">Db.upgrade</a> and <a href="../api_java/db_verify.html">Db.verify</a>. </tt> diff --git a/db/docs/api_java/logc_class.html b/db/docs/api_java/logc_class.html index f079cb494..5cefe0f34 100644 --- a/db/docs/api_java/logc_class.html +++ b/db/docs/api_java/logc_class.html @@ -1,6 +1,7 @@ -<!--Id: logc_class.so,v 1.1 2001/09/28 15:09:37 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: logc_class.so,v 1.3 2002/06/27 19:10:06 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB: DbLogc</title> @@ -30,24 +31,24 @@ which provides cursor support for log files. sequential access to the records stored in log files. Cursors are created by calling the <a href="../api_java/log_cursor.html">DbEnv.log_cursor</a> method which returns a DbLogc object. <h1>Class</h1> -<a href="../api_java/dbenv_class.html">DbEnv</a> +<a href="../api_java/dbenv_class.html">DbEnv</a>, <a href="../api_java/logc_class.html">DbLogc</a> <h1>See Also</h1> -<a href="../api_java/env_set_lg_bsize.html">DbEnv.set_lg_bsize</a>, -<a href="../api_java/env_set_lg_dir.html">DbEnv.set_lg_dir</a>, -<a href="../api_java/env_set_lg_max.html">DbEnv.set_lg_max</a>, -<a href="../api_java/env_set_lg_regionmax.html">DbEnv.set_lg_regionmax</a>, <a href="../api_java/log_archive.html">DbEnv.log_archive</a>, -<a href="../api_java/log_compare.html">DbEnv.log_compare</a>, -<a href="../api_java/log_cursor.html">DbEnv.log_cursor</a>, <a href="../api_java/log_file.html">DbEnv.log_file</a>, <a href="../api_java/log_flush.html">DbEnv.log_flush</a>, <a href="../api_java/log_put.html">DbEnv.log_put</a>, -<a href="../api_java/log_register.html">DbEnv.log_register</a>, <a href="../api_java/log_stat.html">DbEnv.log_stat</a>, -<a href="../api_java/log_unregister.html">DbEnv.log_unregister</a>, -<a href="../api_java/logc_close.html">DbLogc.logc_close</a> +<a href="../api_java/env_set_lg_bsize.html">DbEnv.set_lg_bsize</a>, +<a href="../api_java/env_set_lg_dir.html">DbEnv.set_lg_dir</a>, +<a href="../api_java/env_set_lg_max.html">DbEnv.set_lg_max</a>, +<a href="../api_java/env_set_lg_regionmax.html">DbEnv.set_lg_regionmax</a>, +and +<a href="../api_java/log_compare.html">DbEnv.log_compare</a>. +<p> +<a href="../api_java/log_cursor.html">DbEnv.log_cursor</a>, +<a href="../api_java/logc_close.html">DbLogc.close</a> and -<a href="../api_java/logc_get.html">DbLogc.logc_get</a>. +<a href="../api_java/logc_get.html">DbLogc.get</a>. </tt> <table width="100%"><tr><td><br></td><td align=right> <a href="../api_java/c_index.html"><img src="../images/api.gif" alt="API"></a><a href="../reftoc.html"><img src="../images/ref.gif" alt="Ref"></a> diff --git a/db/docs/api_java/logc_close.html b/db/docs/api_java/logc_close.html index 90f13965c..cabdf6ebb 100644 --- a/db/docs/api_java/logc_close.html +++ b/db/docs/api_java/logc_close.html @@ -1,9 +1,10 @@ -<!--Id: logc_close.so,v 10.4 2001/10/22 15:24:35 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: logc_close.so,v 10.5 2002/06/24 14:49:25 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> -<title>Berkeley DB: DbLogc.logc_close</title> +<title>Berkeley DB: DbLogc.close</title> <meta name="description" content="Berkeley DB: An embedded database programmatic toolkit."> <meta name="keywords" content="embedded,database,programmatic,toolkit,b+tree,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,java,C,C++"> </head> @@ -11,7 +12,7 @@ <a name="2"><!--meow--></a> <table width="100%"><tr valign=top> <td> -<h1>DbLogc.logc_close</h1> +<h1>DbLogc.close</h1> </td> <td align=right> <a href="../api_java/c_index.html"><img src="../images/api.gif" alt="API"></a><a href="../reftoc.html"><img src="../images/ref.gif" alt="Ref"></a> @@ -25,41 +26,41 @@ public void close(int flags) throws DbException; </pre></h3> <h1>Description</h1> -<p>The DbLogc.logc_close method discards the log cursor. After DbLogc.logc_close +<p>The DbLogc.close method discards the log cursor. After DbLogc.close has been called, regardless of its return, the cursor handle may not be used again. <p>The <b>flags</b> parameter is currently unused, and must be set to 0. -<p>The DbLogc.logc_close method throws an exception that encapsulates a non-zero error value on +<p>The DbLogc.close method throws an exception that encapsulates a non-zero error value on failure. <h1>Errors</h1> -<p>The DbLogc.logc_close method may fail and throw an exception encapsulating a non-zero error for the following conditions: +<p>The DbLogc.close method may fail and throw an exception encapsulating a non-zero error for the following conditions: <p><dl compact> <p><dt>EINVAL<dd>An invalid flag value or parameter was specified. <p>The cursor was previously closed. </dl> -<p>The DbLogc.logc_close method may fail and throw an exception for errors specified for other Berkeley DB and C library or system methods. -If a catastrophic error has occurred, the DbLogc.logc_close method may fail and throw -a <a href="../api_java/runrec_class.html">DbRunRecoveryException</a>, in which case all subsequent Berkeley DB calls -will fail in the same way. +<p>The DbLogc.close method may fail and throw an exception for errors specified for other Berkeley DB and C library or system methods. +If a catastrophic error has occurred, the DbLogc.close method may fail and +throw a <a href="../api_java/runrec_class.html">DbRunRecoveryException</a>, +in which case all subsequent Berkeley DB calls will fail in the same way. <h1>Class</h1> -<a href="../api_java/dbenv_class.html">DbEnv</a> +<a href="../api_java/dbenv_class.html">DbEnv</a>, <a href="../api_java/logc_class.html">DbLogc</a> <h1>See Also</h1> -<a href="../api_java/env_set_lg_bsize.html">DbEnv.set_lg_bsize</a>, -<a href="../api_java/env_set_lg_dir.html">DbEnv.set_lg_dir</a>, -<a href="../api_java/env_set_lg_max.html">DbEnv.set_lg_max</a>, -<a href="../api_java/env_set_lg_regionmax.html">DbEnv.set_lg_regionmax</a>, <a href="../api_java/log_archive.html">DbEnv.log_archive</a>, -<a href="../api_java/log_compare.html">DbEnv.log_compare</a>, -<a href="../api_java/log_cursor.html">DbEnv.log_cursor</a>, <a href="../api_java/log_file.html">DbEnv.log_file</a>, <a href="../api_java/log_flush.html">DbEnv.log_flush</a>, <a href="../api_java/log_put.html">DbEnv.log_put</a>, -<a href="../api_java/log_register.html">DbEnv.log_register</a>, <a href="../api_java/log_stat.html">DbEnv.log_stat</a>, -<a href="../api_java/log_unregister.html">DbEnv.log_unregister</a>, -<a href="../api_java/logc_close.html">DbLogc.logc_close</a> +<a href="../api_java/env_set_lg_bsize.html">DbEnv.set_lg_bsize</a>, +<a href="../api_java/env_set_lg_dir.html">DbEnv.set_lg_dir</a>, +<a href="../api_java/env_set_lg_max.html">DbEnv.set_lg_max</a>, +<a href="../api_java/env_set_lg_regionmax.html">DbEnv.set_lg_regionmax</a>, +and +<a href="../api_java/log_compare.html">DbEnv.log_compare</a>. +<p> +<a href="../api_java/log_cursor.html">DbEnv.log_cursor</a>, +<a href="../api_java/logc_close.html">DbLogc.close</a> and -<a href="../api_java/logc_get.html">DbLogc.logc_get</a>. +<a href="../api_java/logc_get.html">DbLogc.get</a>. </tt> <table width="100%"><tr><td><br></td><td align=right> <a href="../api_java/c_index.html"><img src="../images/api.gif" alt="API"></a><a href="../reftoc.html"><img src="../images/ref.gif" alt="Ref"></a> diff --git a/db/docs/api_java/logc_get.html b/db/docs/api_java/logc_get.html index 0ae8791e1..c9288d3e3 100644 --- a/db/docs/api_java/logc_get.html +++ b/db/docs/api_java/logc_get.html @@ -1,9 +1,10 @@ -<!--Id: logc_get.so,v 10.31 2001/10/22 15:24:35 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: logc_get.so,v 10.36 2002/07/01 16:52:26 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> -<title>Berkeley DB: DbLogc.logc_get</title> +<title>Berkeley DB: DbLogc.get</title> <meta name="description" content="Berkeley DB: An embedded database programmatic toolkit."> <meta name="keywords" content="embedded,database,programmatic,toolkit,b+tree,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,java,C,C++"> </head> @@ -11,7 +12,7 @@ <a name="2"><!--meow--></a> <table width="100%"><tr valign=top> <td> -<h1>DbLogc.logc_get</h1> +<h1>DbLogc.get</h1> </td> <td align=right> <a href="../api_java/c_index.html"><img src="../images/api.gif" alt="API"></a><a href="../reftoc.html"><img src="../images/ref.gif" alt="Ref"></a> @@ -25,7 +26,7 @@ public int get(DbLsn lsn, Dbt data, int flags) throws DbException; </pre></h3> <h1>Description</h1> -<p>The DbLogc.logc_get method retrieve records from the log according to the +<p>The DbLogc.get method retrieve records from the log according to the <b>lsn</b> and <b>flags</b> arguments. <p>The data field of the <b>data</b> structure is set to the record retrieved, and the size field indicates the number of bytes in the @@ -35,44 +36,41 @@ record. See <a href="../api_java/dbt_class.html">Dbt</a> for a description of o for any <a href="../api_java/dbt_class.html">Dbt</a> used for data retrieval. <p>The <b>flags</b> value must be set to one of the following values: <p><dl compact> -<p><dt><a name="Db.DB_CHECKPOINT">Db.DB_CHECKPOINT</a><dd>The last record written with the DB_CHECKPOINT flag specified to the -<a href="../api_java/log_put.html">DbEnv.log_put</a> method is returned in the <b>data</b> argument. The -<b>lsn</b> argument is overwritten with the <a href="../api_java/lsn_class.html">DbLsn</a> of the record -returned. If no record has been previously written with the DB_CHECKPOINT -flag specified, the first record in the log is returned. -<p>If the log is empty, the DbLogc.logc_get method will return <a href="../ref/program/errorret.html#DB_NOTFOUND">Db.DB_NOTFOUND</a>. <p><dt><a name="Db.DB_FIRST">Db.DB_FIRST</a><dd>The first record from any of the log files found in the log directory is returned in the <b>data</b> argument. The <b>lsn</b> argument is overwritten with the <a href="../api_java/lsn_class.html">DbLsn</a> of the record returned. -<p>If the log is empty, the DbLogc.logc_get method will return <a href="../ref/program/errorret.html#DB_NOTFOUND">Db.DB_NOTFOUND</a>. +<p> +If the log is empty, the DbLogc.get method will return Db.DB_NOTFOUND. <p><dt><a name="Db.DB_LAST">Db.DB_LAST</a><dd>The last record in the log is returned in the <b>data</b> argument. The <b>lsn</b> argument is overwritten with the <a href="../api_java/lsn_class.html">DbLsn</a> of the record returned. -<p>If the log is empty, the DbLogc.logc_get method will return <a href="../ref/program/errorret.html#DB_NOTFOUND">Db.DB_NOTFOUND</a>. +<p> +If the log is empty, the DbLogc.get method will return Db.DB_NOTFOUND. <p><dt><a name="Db.DB_NEXT">Db.DB_NEXT</a>, <a name="Db.DB_PREV">Db.DB_PREV</a><dd>The current log position is advanced to the next (previous) record in the log, and that record is returned in the <b>data</b> argument. The <b>lsn</b> argument is overwritten with the <a href="../api_java/lsn_class.html">DbLsn</a> of the record returned. -<p>If the pointer has not been initialized via DB_FIRST, DB_LAST, DB_SET, -DB_NEXT, or DB_PREV, DbLogc.logc_get will return the first (last) record -in the log. If the last (first) log record has already been returned -or the log is empty, the DbLogc.logc_get method will return <a href="../ref/program/errorret.html#DB_NOTFOUND">Db.DB_NOTFOUND</a>. -<p>If the log was opened with the DB_THREAD flag set, calls to -DbLogc.logc_get with the DB_NEXT (DB_PREV) flag set will return -EINVAL. +<p>If the cursor has not been initialized via DB_FIRST, DB_LAST, DB_SET, +DB_NEXT, or DB_PREV, DbLogc.get will return the first (last) record +in the log. +If the last (first) log record has already been returned or the log is +empty, the DbLogc.get method will return Db.DB_NOTFOUND. +If the log was opened with the DB_THREAD flag set, calls to +DbLogc.get with the DB_NEXT (DB_PREV) flag set, the DbLogc.get method throws an exception that encapsulates Db.EINVAL. <p><dt><a name="Db.DB_CURRENT">Db.DB_CURRENT</a><dd>Return the log record to which the log currently refers. -<p>If the log pointer has not been initialized via DB_FIRST, DB_LAST, +If the log cursor has not been initialized via DB_FIRST, DB_LAST, DB_SET, DB_NEXT, or DB_PREV, or if the log was opened with the DB_THREAD -flag set, DbLogc.logc_get will return EINVAL. -<p><dt><a name="Db.DB_SET">Db.DB_SET</a><dd>Retrieve the record specified by the <b>lsn</b> argument. If the -specified <a href="../api_java/lsn_class.html">DbLsn</a> is invalid (for example, it does not appear in -the log) DbLogc.logc_get will return EINVAL. +flag set, the DbLogc.get method throws an exception that encapsulates Db.EINVAL. +<p><dt><a name="Db.DB_SET">Db.DB_SET</a><dd>Retrieve the record specified by the <b>lsn</b> argument. +If the specified <a href="../api_java/lsn_class.html">DbLsn</a> is invalid (for example, it does not +appear in the log), the DbLogc.get method throws an exception that encapsulates Db.EINVAL. </dl> -<p>Otherwise, the DbLogc.logc_get method throws an exception that encapsulates a non-zero error value on +<p> +Otherwise, the DbLogc.get method throws an exception that encapsulates a non-zero error value on failure. <h1>Errors</h1> -<p>The DbLogc.logc_get method may fail and throw an exception encapsulating a non-zero error for the following conditions: +<p>The DbLogc.get method may fail and throw an exception encapsulating a non-zero error for the following conditions: <p><dl compact> <p><dt>EINVAL<dd>An invalid flag value or parameter was specified. <p>The DB_CURRENT flag was set and the log pointer had not yet been @@ -80,29 +78,29 @@ initialized. <p>The DB_SET flag was set and the specified log sequence number does not exist. </dl> -<p>The DbLogc.logc_get method may fail and throw an exception for errors specified for other Berkeley DB and C library or system methods. -If a catastrophic error has occurred, the DbLogc.logc_get method may fail and throw -a <a href="../api_java/runrec_class.html">DbRunRecoveryException</a>, in which case all subsequent Berkeley DB calls -will fail in the same way. +<p>The DbLogc.get method may fail and throw an exception for errors specified for other Berkeley DB and C library or system methods. +If a catastrophic error has occurred, the DbLogc.get method may fail and +throw a <a href="../api_java/runrec_class.html">DbRunRecoveryException</a>, +in which case all subsequent Berkeley DB calls will fail in the same way. <h1>Class</h1> -<a href="../api_java/dbenv_class.html">DbEnv</a> +<a href="../api_java/dbenv_class.html">DbEnv</a>, <a href="../api_java/logc_class.html">DbLogc</a> <h1>See Also</h1> -<a href="../api_java/env_set_lg_bsize.html">DbEnv.set_lg_bsize</a>, -<a href="../api_java/env_set_lg_dir.html">DbEnv.set_lg_dir</a>, -<a href="../api_java/env_set_lg_max.html">DbEnv.set_lg_max</a>, -<a href="../api_java/env_set_lg_regionmax.html">DbEnv.set_lg_regionmax</a>, <a href="../api_java/log_archive.html">DbEnv.log_archive</a>, -<a href="../api_java/log_compare.html">DbEnv.log_compare</a>, -<a href="../api_java/log_cursor.html">DbEnv.log_cursor</a>, <a href="../api_java/log_file.html">DbEnv.log_file</a>, <a href="../api_java/log_flush.html">DbEnv.log_flush</a>, <a href="../api_java/log_put.html">DbEnv.log_put</a>, -<a href="../api_java/log_register.html">DbEnv.log_register</a>, <a href="../api_java/log_stat.html">DbEnv.log_stat</a>, -<a href="../api_java/log_unregister.html">DbEnv.log_unregister</a>, -<a href="../api_java/logc_close.html">DbLogc.logc_close</a> +<a href="../api_java/env_set_lg_bsize.html">DbEnv.set_lg_bsize</a>, +<a href="../api_java/env_set_lg_dir.html">DbEnv.set_lg_dir</a>, +<a href="../api_java/env_set_lg_max.html">DbEnv.set_lg_max</a>, +<a href="../api_java/env_set_lg_regionmax.html">DbEnv.set_lg_regionmax</a>, +and +<a href="../api_java/log_compare.html">DbEnv.log_compare</a>. +<p> +<a href="../api_java/log_cursor.html">DbEnv.log_cursor</a>, +<a href="../api_java/logc_close.html">DbLogc.close</a> and -<a href="../api_java/logc_get.html">DbLogc.logc_get</a>. +<a href="../api_java/logc_get.html">DbLogc.get</a>. </tt> <table width="100%"><tr><td><br></td><td align=right> <a href="../api_java/c_index.html"><img src="../images/api.gif" alt="API"></a><a href="../reftoc.html"><img src="../images/ref.gif" alt="Ref"></a> diff --git a/db/docs/api_java/rep_elect.html b/db/docs/api_java/rep_elect.html index 6d68a98fd..d68435a9c 100644 --- a/db/docs/api_java/rep_elect.html +++ b/db/docs/api_java/rep_elect.html @@ -1,6 +1,7 @@ -<!--Id: rep_elect.so,v 1.4 2001/10/26 13:57:00 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: rep_elect.so,v 1.6 2002/06/24 14:49:30 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB: DbEnv.rep_elect</title> @@ -21,8 +22,7 @@ <h3><pre> import com.sleepycat.db.*; <p> -public int rep_elect(int nsites, - int priority, int timeout, int *envid); +public int rep_elect(int nsites, int pri, int timeout); throws DbException; </pre></h3> <h1>Description</h1> @@ -65,13 +65,13 @@ failure. <p><dt>DB_REP_UNAVAIL<dd>The replication group was unable to elect a master. </dl> <p>The DbEnv.rep_elect method may fail and throw an exception for errors specified for other Berkeley DB and C library or system methods. -If a catastrophic error has occurred, the DbEnv.rep_elect method may fail and throw -a <a href="../api_java/runrec_class.html">DbRunRecoveryException</a>, in which case all subsequent Berkeley DB calls -will fail in the same way. +If a catastrophic error has occurred, the DbEnv.rep_elect method may fail and +throw a <a href="../api_java/runrec_class.html">DbRunRecoveryException</a>, +in which case all subsequent Berkeley DB calls will fail in the same way. <h1>See Also</h1> <a href="../api_java/rep_start.html">DbEnv.rep_start</a>, <a href="../api_java/rep_elect.html">DbEnv.rep_elect</a>, -<a href="../api_java/rep_message.html">DbEnv.rep_process_message</a>, +<a href="../api_java/rep_message.html">DbEnv.rep_process_message</a> and <a href="../api_java/rep_transport.html">DbEnv.set_rep_transport</a>. </tt> diff --git a/db/docs/api_java/rep_message.html b/db/docs/api_java/rep_message.html index 8c553b309..c127df371 100644 --- a/db/docs/api_java/rep_message.html +++ b/db/docs/api_java/rep_message.html @@ -1,6 +1,7 @@ -<!--Id: rep_message.so,v 1.4 2001/10/25 20:15:23 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: rep_message.so,v 1.9 2002/07/02 15:22:24 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB: DbEnv.rep_process_message</title> @@ -21,7 +22,11 @@ <h3><pre> import com.sleepycat.db.*; <p> -public void rep_process_message(Dbt *control, Dbt *rec, int *envid) +public static class RepProcessMessage { + public int envid; +} +public int rep_process_message( + Dbt control, Dbt rec, DbEnv.RepProcessMessage envid) throws DbException; </pre></h3> <h1>Description</h1> @@ -39,38 +44,44 @@ information). processed using the same <a href="../api_java/dbenv_class.html">DbEnv</a> handle. It is not required that a single thread of control process all messages, only that all threads of control processing messages use the same handle. -<p>The DbEnv.rep_process_message method may return one of several special conditions: -<p><dl compact> -<p><dt><a name="Db.DB_REP_DUPMASTER">Db.DB_REP_DUPMASTER</a><dd>The replication group has more than one master; the application should -reconfigure itself as a client by calling the <a href="../api_java/rep_start.html">DbEnv.rep_start</a> method, and -then call for an election by calling <a href="../api_java/rep_elect.html">DbEnv.rep_elect</a>. -<p><dt><a name="Db.DB_REP_HOLDELECTION">Db.DB_REP_HOLDELECTION</a><dd>An election is needed, the application should call for an election by -calling <a href="../api_java/rep_elect.html">DbEnv.rep_elect</a>. -<p><dt><a name="Db.DB_REP_NEWMASTER">Db.DB_REP_NEWMASTER</a><dd>A new master has been elected. The memory location referenced by the -<b>envid</b> parameter contains the environment ID of the new master. -If the recipient of this error return has been made master, it is the -application's responsibility to begin acting as the master environment. -<p><dt><a name="Db.DB_REP_NEWSITE">Db.DB_REP_NEWSITE</a><dd>The system received contact information from a new environment. The -<b>rec</b> parameter contains the opaque data specified in the +<p> +If a new master has been elected, the DbEnv.rep_process_message method will return Db.DB_REP_NEWMASTER. +The <b>envid</b> parameter contains the environment ID of the new +master. If the recipient of this error return has been made master, it +is the application's responsibility to begin acting as the master +environment. +<p> +If the system received contact information from a new environment, the DbEnv.rep_process_message method will return Db.DB_REP_NEWSITE. +The <b>rec</b> parameter contains the opaque data specified in the <b>cdata</b> parameter to the <a href="../api_java/rep_start.html">DbEnv.rep_start</a>. The application should take whatever action is needed to establish a communication channel with this new environment. -<p><dt><a name="Db.DB_REP_OUTDATED">Db.DB_REP_OUTDATED</a><dd>The current environment's logs are too far out of date with respect to -the master to be automatically synchronized. The application should -copy over a hot backup of the environment, run recovery, and restart -the client. -</dl> -<p>Otherwise, the DbEnv.rep_process_message method throws an exception that encapsulates a non-zero error value on +<p> +If the replication group has more than one master, the DbEnv.rep_process_message method throws an exception that encapsulates Db.DB_REP_DUPMASTER. +The application should reconfigure itself as a client by calling the +<a href="../api_java/rep_start.html">DbEnv.rep_start</a> method, and then call for an election by calling +<a href="../api_java/rep_elect.html">DbEnv.rep_elect</a>. +<p> +If an election is needed, the DbEnv.rep_process_message method throws an exception that encapsulates Db.DB_REP_HOLDELECTION. +The application should call for an election by +calling <a href="../api_java/rep_elect.html">DbEnv.rep_elect</a>. +<p> +If the current environment's logs are too far out of date with respect +to the master to be automatically synchronized, the DbEnv.rep_process_message method throws an exception that encapsulates Db.DB_REP_OUTDATED. The +application should copy over a hot backup of the environment, run +recovery, and restart the client. +<p> +Otherwise, the DbEnv.rep_process_message method throws an exception that encapsulates a non-zero error value on failure. <h1>Errors</h1> <p>The DbEnv.rep_process_message method may fail and throw an exception for errors specified for other Berkeley DB and C library or system methods. -If a catastrophic error has occurred, the DbEnv.rep_process_message method may fail and throw -a <a href="../api_java/runrec_class.html">DbRunRecoveryException</a>, in which case all subsequent Berkeley DB calls -will fail in the same way. +If a catastrophic error has occurred, the DbEnv.rep_process_message method may fail and +throw a <a href="../api_java/runrec_class.html">DbRunRecoveryException</a>, +in which case all subsequent Berkeley DB calls will fail in the same way. <h1>See Also</h1> <a href="../api_java/rep_start.html">DbEnv.rep_start</a>, <a href="../api_java/rep_elect.html">DbEnv.rep_elect</a>, -<a href="../api_java/rep_message.html">DbEnv.rep_process_message</a>, +<a href="../api_java/rep_message.html">DbEnv.rep_process_message</a> and <a href="../api_java/rep_transport.html">DbEnv.set_rep_transport</a>. </tt> diff --git a/db/docs/api_java/rep_start.html b/db/docs/api_java/rep_start.html index a3c0f3750..f0d5e3273 100644 --- a/db/docs/api_java/rep_start.html +++ b/db/docs/api_java/rep_start.html @@ -1,6 +1,7 @@ -<!--Id: rep_start.so,v 1.2 2001/10/25 14:08:43 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: rep_start.so,v 1.3 2002/06/24 14:49:30 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB: DbEnv.rep_start</title> @@ -57,13 +58,13 @@ replication group by a call to <a href="../api_java/rep_transport.html">DbEnv.se <p>The environment was not already opened. </dl> <p>The DbEnv.rep_start method may fail and throw an exception for errors specified for other Berkeley DB and C library or system methods. -If a catastrophic error has occurred, the DbEnv.rep_start method may fail and throw -a <a href="../api_java/runrec_class.html">DbRunRecoveryException</a>, in which case all subsequent Berkeley DB calls -will fail in the same way. +If a catastrophic error has occurred, the DbEnv.rep_start method may fail and +throw a <a href="../api_java/runrec_class.html">DbRunRecoveryException</a>, +in which case all subsequent Berkeley DB calls will fail in the same way. <h1>See Also</h1> <a href="../api_java/rep_start.html">DbEnv.rep_start</a>, <a href="../api_java/rep_elect.html">DbEnv.rep_elect</a>, -<a href="../api_java/rep_message.html">DbEnv.rep_process_message</a>, +<a href="../api_java/rep_message.html">DbEnv.rep_process_message</a> and <a href="../api_java/rep_transport.html">DbEnv.set_rep_transport</a>. </tt> diff --git a/db/docs/api_java/rep_transport.html b/db/docs/api_java/rep_transport.html index f27039c86..0b263947a 100644 --- a/db/docs/api_java/rep_transport.html +++ b/db/docs/api_java/rep_transport.html @@ -1,6 +1,7 @@ -<!--Id: rep_transport.so,v 1.4 2001/10/26 23:51:06 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: rep_transport.so,v 1.7 2002/06/24 14:49:30 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB: DbEnv.set_rep_transport</title> @@ -58,7 +59,7 @@ The special identifier Db.DB_EID_BROADCAST indicates that a message should be broadcast to every environment in the replication group. The application may use a true broadcast protocol, or may send the message in sequence to each machine with which it is in communication. -<p><dt>flag<dd> +<p><dt>flags<dd> <p>The <b>flags</b> value must be set to 0 or by bitwise inclusively <b>OR</b>'ing together one or more of the following values: <p><dl compact> @@ -77,18 +78,22 @@ otherwise, any error from the <b>send</b> interface will be ignored. <p>It may sometimes be useful to pass application-specific data to the <b>send</b> interface; see <a href="../ref/env/faq.html">Environment FAQ</a> for a discussion on how to do this. -<p>The <b>flags</b> parameter is currently unused, and must be set to 0. +<p>The DbEnv.set_rep_transport method configures operations performed using the specified +<a href="../api_java/dbenv_class.html">DbEnv</a> handle, not all operations performed on the underlying +database environment. +<p>The DbEnv.set_rep_transport interface may be called at any time during the life of +the application. <p>The DbEnv.set_rep_transport method throws an exception that encapsulates a non-zero error value on failure. <h1>Errors</h1> <p>The DbEnv.set_rep_transport method may fail and throw an exception for errors specified for other Berkeley DB and C library or system methods. -If a catastrophic error has occurred, the DbEnv.set_rep_transport method may fail and throw -a <a href="../api_java/runrec_class.html">DbRunRecoveryException</a>, in which case all subsequent Berkeley DB calls -will fail in the same way. +If a catastrophic error has occurred, the DbEnv.set_rep_transport method may fail and +throw a <a href="../api_java/runrec_class.html">DbRunRecoveryException</a>, +in which case all subsequent Berkeley DB calls will fail in the same way. <h1>See Also</h1> <a href="../api_java/rep_start.html">DbEnv.rep_start</a>, <a href="../api_java/rep_elect.html">DbEnv.rep_elect</a>, -<a href="../api_java/rep_message.html">DbEnv.rep_process_message</a>, +<a href="../api_java/rep_message.html">DbEnv.rep_process_message</a> and <a href="../api_java/rep_transport.html">DbEnv.set_rep_transport</a>. </tt> diff --git a/db/docs/api_java/txn_set_timeout.html b/db/docs/api_java/txn_set_timeout.html index 78a1df76d..5b44a390b 100644 --- a/db/docs/api_java/txn_set_timeout.html +++ b/db/docs/api_java/txn_set_timeout.html @@ -1,6 +1,7 @@ -<!--Id: txn_set_timeout.so,v 10.3 2001/10/22 15:24:39 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: txn_set_timeout.so,v 10.6 2002/06/24 14:49:36 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB: DbTxn.set_timeout</title> @@ -21,7 +22,7 @@ <h3><pre> import com.sleepycat.db.*; <p> -public int set_timeout(long timeout, int flags) +public void set_timeout(long timeout, int flags) throws DbException; </pre></h3> <h1>Description</h1> @@ -46,6 +47,11 @@ is performed, the accuracy of the timeout depends on how often deadlock detection is performed. <p>Timeout values may be specified for the database environment as a whole. See <a href="../api_java/env_set_timeout.html">DbEnv.set_timeout</a> and for more information. +<p>The DbTxn.set_timeout method configures operations performed on the underlying +transaction, not only operations performed using the specified +<a href="../api_java/txn_class.html">DbTxn</a> handle. +<p>The DbTxn.set_timeout interface may be called at any time during the life of +the application. <p>The DbTxn.set_timeout method throws an exception that encapsulates a non-zero error value on failure. <h1>Errors</h1> @@ -54,25 +60,27 @@ failure. <p><dt>EINVAL<dd>An invalid flag value or parameter was specified. </dl> <p>The DbTxn.set_timeout method may fail and throw an exception for errors specified for other Berkeley DB and C library or system methods. -If a catastrophic error has occurred, the DbTxn.set_timeout method may fail and throw -a <a href="../api_java/runrec_class.html">DbRunRecoveryException</a>, in which case all subsequent Berkeley DB calls -will fail in the same way. +If a catastrophic error has occurred, the DbTxn.set_timeout method may fail and +throw a <a href="../api_java/runrec_class.html">DbRunRecoveryException</a>, +in which case all subsequent Berkeley DB calls will fail in the same way. <h1>Class</h1> <a href="../api_java/dbenv_class.html">DbEnv</a>, <a href="../api_java/txn_class.html">DbTxn</a> <h1>See Also</h1> <a href="../api_java/env_set_tx_max.html">DbEnv.set_tx_max</a>, <a href="../api_java/env_set_tx_timestamp.html">DbEnv.set_tx_timestamp</a>, -<a href="../api_java/txn_abort.html">DbTxn.abort</a>, <a href="../api_java/txn_begin.html">DbEnv.txn_begin</a>, <a href="../api_java/txn_checkpoint.html">DbEnv.txn_checkpoint</a>, +<a href="../api_java/txn_recover.html">DbEnv.txn_recover</a> +and +<a href="../api_java/txn_stat.html">DbEnv.txn_stat</a>. +<p> +<a href="../api_java/txn_abort.html">DbTxn.abort</a>, <a href="../api_java/txn_commit.html">DbTxn.commit</a>, <a href="../api_java/txn_discard.html">DbTxn.discard</a>, <a href="../api_java/txn_id.html">DbTxn.id</a>, -<a href="../api_java/txn_prepare.html">DbTxn.prepare</a>, -<a href="../api_java/txn_recover.html">DbEnv.txn_recover</a>, -<a href="../api_java/txn_set_timeout.html">DbTxn.set_timeout</a> +<a href="../api_java/txn_prepare.html">DbTxn.prepare</a> and -<a href="../api_java/txn_stat.html">DbEnv.txn_stat</a>. +<a href="../api_java/txn_set_timeout.html">DbTxn.set_timeout</a>. </tt> <table width="100%"><tr><td><br></td><td align=right> <a href="../api_java/c_index.html"><img src="../images/api.gif" alt="API"></a><a href="../reftoc.html"><img src="../images/ref.gif" alt="Ref"></a> diff --git a/db/docs/ref/am_misc/get_bulk.html b/db/docs/ref/am_misc/get_bulk.html index 267b8e88c..eb340ae3b 100644 --- a/db/docs/ref/am_misc/get_bulk.html +++ b/db/docs/ref/am_misc/get_bulk.html @@ -1,6 +1,7 @@ -<!--Id: get_bulk.so,v 10.2 2001/05/30 14:54:37 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: get_bulk.so,v 10.3 2002/06/24 14:50:33 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB Reference Guide: Retrieving records in bulk</title> diff --git a/db/docs/ref/build_unix/macosx.html b/db/docs/ref/build_unix/macosx.html index 783a41140..202d5191e 100644 --- a/db/docs/ref/build_unix/macosx.html +++ b/db/docs/ref/build_unix/macosx.html @@ -1,6 +1,7 @@ -<!--Id: macosx.so,v 11.1 2001/09/21 16:23:52 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: macosx.so,v 11.4 2002/06/20 14:43:40 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB Reference Guide: Mac OS X</title> @@ -16,10 +17,16 @@ <p> <h1 align=center>Mac OS X</h1> <p><ol> -<p><li><b>I can't use the Berkeley DB Tcl and Java APIs on Mac OS X.</b> +<p><li><b>I can't use the Java API on Mac OS X.</b> <p>The Berkeley DB configuration and build procedure is unable to dynamically -load libraries on Mac OS X. This restriction is expected to be removed -in future Berkeley DB releases. +load some libraries on Mac OS X. This restriction is expected to be +removed in future Berkeley DB releases. +<p>There is a workaround for Java. Mac OS X normally requires Java +loadable libraries to end with a .jnilib extension. Libtool, used by +our build procedure, does not support this extension. To work around +this, you must add a -D option to your Java command line to specify the +complete pathname of the installed library: +<p><blockquote><pre>% java -Dsleepycat.db.libfile=/full/path/to/libdb_java-VERSION.so</pre></blockquote> </ol> <table width="100%"><tr><td><br></td><td align=right><a href="../../ref/build_unix/linux.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../../reftoc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../../ref/build_unix/osf1.html"><img src="../../images/next.gif" alt="Next"></a> </td></tr></table> diff --git a/db/docs/ref/build_vxworks/introae.html b/db/docs/ref/build_vxworks/introae.html index 34b24671e..b0a8b8b70 100644 --- a/db/docs/ref/build_vxworks/introae.html +++ b/db/docs/ref/build_vxworks/introae.html @@ -1,6 +1,7 @@ -<!--Id: introae.so,v 1.4 2001/11/05 21:05:19 sue Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: introae.so,v 1.6 2002/03/26 15:20:29 sue Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB Reference Guide: Building for VxWorks AE</title> @@ -25,7 +26,7 @@ all component files are named <i>component.wpj</i>. <p><table border=1 align=center> <tr><th>File</th><th>Description</th></tr> <tr> <td align=left>Berkeley DB/</td> <td align=left>Berkeley DB component directory</td> </tr> -<tr> <td align=left>demo/demo</td> <td align=left><a href="../../ref/build_vxworks/notes.html">Demo program</a> component directory</td> </tr> +<tr> <td align=left>dbdemo/dbdemo</td> <td align=left><a href="../../ref/build_vxworks/notes.html">Demo program</a> component directory</td> </tr> <tr> <td align=left>db_*/db_*</td> <td align=left><a href="../../ref/build_vxworks/notes.html">Support utilities</a> component directories</td> </tr> </table> <h3>Building With Tornado 3.1</h3> @@ -114,9 +115,6 @@ macro, which is the Berkeley DB subdirectory of <i>build_vxworks</i>. Then, click OK. The typical addition of include directories will look like: <p><blockquote><pre>-I$(PRJ_DIR)/.. -I$(PRJ_DIR)/../../include -I$(PRJ_DIR)/../../include_auto</pre></blockquote> -<p>If the architecture for this new build has the most significant byte -first, you also need to edit the <i>db_config.h</i> file in the -build directory and define <b>WORDS_BIGENDIAN</b>. <p>To build and download the Berkeley DB downloadable application for the first time requires several steps: <p><ol> diff --git a/db/docs/ref/lock/timeout.html b/db/docs/ref/lock/timeout.html index 063f9fce2..a6da96ca6 100644 --- a/db/docs/ref/lock/timeout.html +++ b/db/docs/ref/lock/timeout.html @@ -1,6 +1,7 @@ -<!--Id: timeout.so,v 1.1 2001/08/18 17:05:29 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: timeout.so,v 1.2 2002/06/01 23:42:12 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB Reference Guide: Deadlock detection using timers</title> @@ -11,7 +12,7 @@ <a name="2"><!--meow--></a><a name="3"><!--meow--></a> <table width="100%"><tr valign=top> <td><h3><dl><dt>Berkeley DB Reference Guide:<dd>Locking Subsystem</dl></h3></td> -<td align=right><a href="../../ref/lock/dead.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../../reftoc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../../ref/lock/page.html"><img src="../../images/next.gif" alt="Next"></a> +<td align=right><a href="../../ref/lock/dead.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../../reftoc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../../ref/lock/deaddbg.html"><img src="../../images/next.gif" alt="Next"></a> </td></tr></table> <p> <h1 align=center>Deadlock detection using timers</h1> @@ -51,7 +52,7 @@ out if it blocks waiting for a lock after 8ms. By default, any lock request in this system will be timed out if it blocks longer than 10ms, and the specific lock described will be timed out if it blocks longer than 4ms. -<table width="100%"><tr><td><br></td><td align=right><a href="../../ref/lock/dead.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../../reftoc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../../ref/lock/page.html"><img src="../../images/next.gif" alt="Next"></a> +<table width="100%"><tr><td><br></td><td align=right><a href="../../ref/lock/dead.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../../reftoc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../../ref/lock/deaddbg.html"><img src="../../images/next.gif" alt="Next"></a> </td></tr></table> <p><font size=1><a href="http://www.sleepycat.com">Copyright Sleepycat Software</a></font> </body> diff --git a/db/docs/ref/rep/app.html b/db/docs/ref/rep/app.html index abc26fdd0..cb05fc5a6 100644 --- a/db/docs/ref/rep/app.html +++ b/db/docs/ref/rep/app.html @@ -1,6 +1,7 @@ -<!--Id: app.so,v 1.3 2001/10/25 21:17:51 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: app.so,v 1.5 2002/07/13 18:09:09 margo Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB Reference Guide: Building replicated applications</title> @@ -16,10 +17,11 @@ <h1 align=center>Building replicated applications</h1> <p>The simplest way to build a replicated Berkeley DB application is to first build (and debug!) the transactional version of the same application. -Then, add a thin replication layer to the application. Highly available +Then, add a thin replication layer to the application. All highly available applications use the following additional four Berkeley DB methods: <a href="../../api_c/rep_elect.html">DB_ENV->rep_elect</a>, <a href="../../api_c/rep_message.html">DB_ENV->rep_process_message</a>, <a href="../../api_c/rep_start.html">DB_ENV->rep_start</a> and -<a href="../../api_c/rep_transport.html">DB_ENV->set_rep_transport</a>: +<a href="../../api_c/rep_transport.html">DB_ENV->set_rep_transport</a> and may also use the configuration method +<a href="../../api_c/rep_limit.html">DB_ENV->set_rep_limit</a>: <p><dl compact> <p><dt><a href="../../api_c/rep_transport.html">DB_ENV->set_rep_transport</a><dd>The <a href="../../api_c/rep_transport.html">DB_ENV->set_rep_transport</a> function configures the replication system's communications infrastructure. @@ -34,13 +36,14 @@ protocol for dealing with lost messages), and permitting new clients to join an active replication group. <p><dt><a href="../../api_c/rep_elect.html">DB_ENV->rep_elect</a><dd>The <a href="../../api_c/rep_elect.html">DB_ENV->rep_elect</a> function causes the replication group to elect a new master; it is called whenever contact with the master is lost. +<p><dt><a href="../../api_c/rep_limit.html">DB_ENV->set_rep_limit</a><dd>The <a href="../../api_c/rep_limit.html">DB_ENV->set_rep_limit</a> imposes an upper bound on the amount of data +that will be sent in response to a single call to <a href="../../api_c/rep_message.html">DB_ENV->rep_process_message</a>. </dl> <p>To add replication to a Berkeley DB application, application initialization -must be changed, and some new code, the application's communications -infrastructure, must be written. The application initialization changes -are relatively simple, but the communications infrastructure code is -fairly complex. -<p>During application initialization, the application must perform two +must be changed and the application's communications infrastructure must +be written. The application initialization changes are relatively +simple, but the communications infrastructure code can be complex. +<p>During application initialization, the application performs two additional tasks: first, it must provide Berkeley DB information about its communications infrastructure, and second, it must start the Berkeley DB replication system. Generally, a replicated application will do normal @@ -58,6 +61,20 @@ application. master, or the declaration of the local environment as the master. If a master has not been discovered after a reasonable amount of time, the application should call <a href="../../api_c/rep_elect.html">DB_ENV->rep_elect</a> to call for an election. +<p>In the case of multiple processes accessing a replicated environment, +all of the threads of control expecting to modify databases in the +environment or process replication messages must call the +<a href="../../api_c/rep_start.html">DB_ENV->rep_start</a> function. Note that not all processes running in replicated +environments need to call <a href="../../api_c/rep_transport.html">DB_ENV->set_rep_transport</a> or <a href="../../api_c/rep_start.html">DB_ENV->rep_start</a>. +Read-only processes running in a master environment do not need to be +configured for replication in any way. Processes running in a client +environment are read-only by definition, and so do not need to be +configured for replication either (although, in the case of clients that +may become masters, it is usually simplest to configure for replication +on process startup rather than trying to reconfigure when the client +becomes a master). Obviously, at least one thread of control on each +client must be configured for replication as messages must be passed +between the master and the client. <p>Databases are generally opened read-write on both clients and masters in order to simplify upgrading replication clients to be masters. (If databases are opened read-only on clients, and the client is then diff --git a/db/docs/ref/rep/comm.html b/db/docs/ref/rep/comm.html index d7f550b7f..26a47734f 100644 --- a/db/docs/ref/rep/comm.html +++ b/db/docs/ref/rep/comm.html @@ -1,6 +1,7 @@ -<!--Id: comm.so,v 1.3 2001/10/25 20:05:34 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: comm.so,v 1.4 2002/05/09 20:38:15 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB Reference Guide: Building the communications infrastructure</title> @@ -14,7 +15,7 @@ </td></tr></table> <p> <h1 align=center>Building the communications infrastructure</h1> -<p>The replication portion of an application is typically written with one +<p>The replication support in an application is typically written with one or more threads of control looping on one or more communication channels, receiving and sending messages. These threads accept messages from remote environments for the local database environment, and accept @@ -23,8 +24,9 @@ from remote environments are passed to the local database environment using the <a href="../../api_c/rep_message.html">DB_ENV->rep_process_message</a> function. Messages from the local environment are passed to the application for transmission using the callback interface specified to the <a href="../../api_c/rep_transport.html">DB_ENV->set_rep_transport</a> function. -<p>Both clients and servers establish communication channels by calling -the <a href="../../api_c/rep_transport.html">DB_ENV->set_rep_transport</a> function. This method specifies the <b>send</b> +<p>Processes establish communication channels by calling the +<a href="../../api_c/rep_transport.html">DB_ENV->set_rep_transport</a> function, regardless of whether they are running in client +or server environments. This method specifies the <b>send</b> interface, a callback interface used by Berkeley DB for sending messages to other database environments in the replication group. The <b>send</b> interface takes an environment ID and two opaque data objects. It is diff --git a/db/docs/ref/rep/elect.html b/db/docs/ref/rep/elect.html index c0b2ed9ac..a811d4fd1 100644 --- a/db/docs/ref/rep/elect.html +++ b/db/docs/ref/rep/elect.html @@ -1,6 +1,7 @@ <!--Id: elect.so,v 1.5 2001/10/25 21:20:01 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB Reference Guide: Elections</title> diff --git a/db/docs/ref/rep/ex.html b/db/docs/ref/rep/ex.html index d0e38e0f5..b9f89921c 100644 --- a/db/docs/ref/rep/ex.html +++ b/db/docs/ref/rep/ex.html @@ -1,6 +1,7 @@ -<!--Id: ex.so,v 1.3 2001/11/18 15:17:22 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: ex.so,v 1.4 2002/06/24 14:50:47 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB Reference Guide: Ex_repquote: a replication example</title> diff --git a/db/docs/ref/rep/ex_comm.html b/db/docs/ref/rep/ex_comm.html index 2e41aeb72..bc0f2dcc0 100644 --- a/db/docs/ref/rep/ex_comm.html +++ b/db/docs/ref/rep/ex_comm.html @@ -1,6 +1,7 @@ -<!--Id: ex_comm.so,v 1.5 2001/11/18 15:32:21 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: ex_comm.so,v 1.6 2002/06/24 14:50:48 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB Reference Guide: Ex_repquote: a TCP/IP based communication infrastructure</title> @@ -76,7 +77,7 @@ quote_send(dbenv, control, rec, eid, flags) <p> machtab = (machtab_t *)dbenv->app_private; <p> - /* + /* * If this is a broadcast, call a separate function to * iterate through the table of environment (a/k/a * machine) IDs and call quote_send_one on each. @@ -113,7 +114,7 @@ quote_send(dbenv, control, rec, eid, flags) return (ret); } <p> -static int +int quote_send_broadcast(machtab, rec, control, flags) machtab_t *machtab; const DBT *rec, *control; diff --git a/db/docs/ref/rep/ex_rq.html b/db/docs/ref/rep/ex_rq.html index 84d0e83ba..6d83e98aa 100644 --- a/db/docs/ref/rep/ex_rq.html +++ b/db/docs/ref/rep/ex_rq.html @@ -1,6 +1,7 @@ -<!--Id: ex_rq.so,v 1.3 2001/11/18 15:17:23 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: ex_rq.so,v 1.4 2002/06/24 14:50:48 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB Reference Guide: Ex_repquote: putting it all together</title> @@ -53,7 +54,7 @@ addition to the normal functionality of any database application). infrastructure is initialized, the application signals that it is ready for replication and joins a replication group by calling <a href="../../api_c/rep_start.html">DB_ENV->rep_start</a>: -<pre><p><blockquote>if (whoami == MASTER) { +<pre><p><blockquote>if (whoami == MASTER) { if ((ret = dbenv->rep_start(dbenv, NULL, DB_REP_MASTER)) != 0) { /* Complain and exit on error. */ } @@ -94,7 +95,7 @@ DBT rec, control; /* Structures encapsulating a received message. */ elect_args *ea; /* Parameters to the elect thread. */ machtab_t *tab; /* The environment ID to fd mapping table. */ pthread_t elect_thr; /* Election thread spawned. */ -site_t self; /* My host and port identification. */ +repsite_t self; /* My host and port identification. */ int eid; /* Environment from whom I am receiving messages. */ int fd; /* FD on which I am receiving messages. */ int master_eid; /* Global indicating the current master eid. */ @@ -136,8 +137,8 @@ for (ret = 0; ret == 0;) { break; <p> master_eid = DB_EID_INVALID; - /* - * In ex_repquote, the environment ID table stores + /* + * In ex_repquote, the environment ID table stores * election parameters. */ machtab_parm(tab, &n, &pri, &timeout); diff --git a/db/docs/ref/rep/faq.html b/db/docs/ref/rep/faq.html index 83ed42e96..bd0e421a3 100644 --- a/db/docs/ref/rep/faq.html +++ b/db/docs/ref/rep/faq.html @@ -1,6 +1,7 @@ -<!--Id: faq.so,v 1.5 2001/11/17 16:59:33 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: faq.so,v 1.6 2002/05/09 20:38:15 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB Reference Guide: Replication FAQ</title> @@ -49,6 +50,47 @@ for the message. This will likely require a global numbering scheme, however, as the Berkeley DB library has to be able to send specific log records to clients apart from the general broadcast of new log records intended for all members of a replication group. +<p><li><b>Does every one of my threads of control on the master have to +set up its own connection to every client? And, does every one of my +threads of control on the client have to set up its own connection to +every master?</b> +<p>This is not always necessary. In the Berkeley DB replication model, any +thread of control which modifies a database in the master environment +must be prepared to send a message to the client environments, and any +thread of control which delivers a message to a client environment must +be prepared to send a message to the master. There are many ways in +which these requirements can be satisfied. +<p>The simplest case is probably a single, multithreaded process running +on the master and clients. The process running on the master would +require a single write connection to each client and a single read +connection from each client. A process running on each client would +require a single read connection from the master and a single write +connection to the master. Threads running in these processes on the +master and clients would use the same network connections to pass +messages back and forth. +<p>A common complication is when there are multiple processes running on +the master and clients. A straight-forward solution is to increase the +numbers of connections on the master -- each process running on the +master has its own write connection to each client. However, this +requires only one additional connection for each possible client in the +master process. The master environment still requires only a single +read connection from each client (this can be done by allocating a +separate thread of control which does nothing other than receive client +messages and forward them into the database). Similarly, each client +still only requires a single thread of control that receives master +messages and forwards them into the database, and which also takes +database messages and forwards them back to the master. This model +requires the networking infrastructure support many-to-one +writers-to-readers, of course. +<p>If the number of network connections is a problem in the multiprocess +model, and inter-process communication on the system is inexpensive +enough, an alternative is have a single process which communicates +between the master the each client, and whenever a process' +<b>send</b> function is called, the process passes the message to the +communications process which is responsible for forwarding the message +to the appropriate client. Alternatively, a broadcast mechanism will +simplify the entire networking infrastructure, as processes will likely +no longer have to maintain their own specific network connections. <p><li><b>Can I use replication to replicate just the database environment's log files?</b> <p>Yes. If the <a href="../../api_c/rep_start.html#DB_REP_LOGSONLY">DB_REP_LOGSONLY</a> flag is specified to diff --git a/db/docs/ref/rep/id.html b/db/docs/ref/rep/id.html index 572fcc1d6..9cae04d06 100644 --- a/db/docs/ref/rep/id.html +++ b/db/docs/ref/rep/id.html @@ -1,6 +1,7 @@ -<!--Id: id.so,v 1.5 2001/11/05 17:24:27 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: id.so,v 1.6 2002/05/09 20:38:15 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB Reference Guide: Replication environment IDs</title> @@ -21,8 +22,8 @@ each database environment can assign local identifiers to members of the replication group as it encounters them. For example, given three sites: A, B and C, site A might assign the identifiers 1 and 2 to sites B and C respectively, while site B might assign the identifiers 301 and -302 to sites A and C respectively. Note, it is not wrong to have global -identifiers, of course, it is just not necessary. +302 to sites A and C respectively. Note that it is not wrong to have +global identifiers, it is just not a requirement. <p>It is the responsibility of the application to label each incoming replication message passed to <a href="../../api_c/rep_message.html">DB_ENV->rep_process_message</a> function with the appropriate identifier. Subsequently, Berkeley DB will label outgoing messages to the diff --git a/db/docs/ref/rep/init.html b/db/docs/ref/rep/init.html index 46a784c12..9901967ba 100644 --- a/db/docs/ref/rep/init.html +++ b/db/docs/ref/rep/init.html @@ -1,6 +1,7 @@ <!--Id: init.so,v 1.2 2001/11/05 17:24:27 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB Reference Guide: Initializing a new site</title> diff --git a/db/docs/ref/rep/intro.html b/db/docs/ref/rep/intro.html index 439937cd1..d300cd27e 100644 --- a/db/docs/ref/rep/intro.html +++ b/db/docs/ref/rep/intro.html @@ -1,6 +1,7 @@ -<!--Id: intro.so,v 1.3 2001/10/24 19:06:38 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: intro.so,v 1.4 2002/05/09 20:38:15 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB Reference Guide: Introduction</title> @@ -26,28 +27,35 @@ new master. The database environments might be on separate computers, on separate hardware partitions in a non-uniform memory access (NUMA) system, or on separate disks in a single server. As always with Berkeley DB environments, any number of concurrent processes or threads may access -a database environment. +a database environment. In the case of a master environment, any number +of threads of control may read and write the environment, and in the +case of a client environment, any number of threads of control may read +the environment. <p>Applications may be written to provide various degrees of consistency between the master and clients. The system can be run synchronously such that replicas are guaranteed to be up-to-date with all committed transactions, but doing so may incur a significant performance penalty. Higher performance solutions sacrifice total consistency, allowing the clients to be out of date for an application-controlled amount of time. -<p>While Berkeley DB includes the tools necessary to construct highly available -database environments, applications must provide several critical -components. First, the application is responsible for providing the -communication infrastructure. Applications may use whatever wire -protocol is appropriate for their application (for example, RPC, TCP/IP, -UDP, VI, message-passing over the backplane, etc.). Second, the -application is responsible for naming. Berkeley DB refers to the members of -a replication group using an application-provided ID, and applications -must map that ID to a particular database environment or communication -channel. Third, the application is responsible for monitoring the status -of the master and clients, and identifying any unavailable database -environments. Finally, the application must provide whatever security -policies are needed. For example, the application may choose to encrypt -data, use a secure socket layer, or do nothing at all. The level of -security is left to the sole discretion of the application. +<p>While Berkeley DB includes the database infrastructure necessary to construct +highly available database environments, applications must still provide +some critical components: +<p><ol> +<p><li>The application is responsible for providing the communication +infrastructure. Applications may use whatever wire protocol is +appropriate for their application (for example, RPC, TCP/IP, UDP, VI or +message-passing over the backplane). +<p><li>The application is responsible for naming. Berkeley DB refers to the members +of a replication group using an application-provided ID, and +applications must map that ID to a particular database environment or +communication channel. +<p><li>The application is responsible for monitoring the status of the master +and clients, and identifying any unavailable database environments. +<p><li>The application must provide whatever security policies are needed. +For example, the application may choose to encrypt data, use a secure +socket layer, or do nothing at all. The level of security is left to +the sole discretion of the application. +</ol> <table width="100%"><tr><td><br></td><td align=right><a href="../../ref/transapp/faq.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../../reftoc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../../ref/rep/id.html"><img src="../../images/next.gif" alt="Next"></a> </td></tr></table> <p><font size=1><a href="http://www.sleepycat.com">Copyright Sleepycat Software</a></font> diff --git a/db/docs/ref/rep/logonly.html b/db/docs/ref/rep/logonly.html index 70860f10d..e3f26ac2e 100644 --- a/db/docs/ref/rep/logonly.html +++ b/db/docs/ref/rep/logonly.html @@ -1,6 +1,7 @@ -<!--Id: logonly.so,v 1.4 2001/11/06 22:20:11 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: logonly.so,v 1.6 2002/08/08 15:46:02 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB Reference Guide: Log file only clients</title> @@ -17,20 +18,30 @@ <p>Applications wanting to use replication to support recovery after catastrophic failure of the master may want to configure a site as a logs-file-only replica. Such clients cannot respond to read (or write) -queries but still receive a complete copy the log files, so that in the -event of master failure, catastrophic recovery can be run. +queries but they still receive a complete copy the log files, so that in the +event of master failure, a copy of the logs is available. <p>Log file only clients are configured like other client sites, except they should specify the <a href="../../api_c/rep_start.html#DB_REP_LOGSONLY">DB_REP_LOGSONLY</a> flag to the <a href="../../api_c/rep_start.html">DB_ENV->rep_start</a> function and should specify a priority of 0 to the <a href="../../api_c/rep_elect.html">DB_ENV->rep_elect</a> function. -<p>To recover using a log-file-only replica, recovery must be run on the -log files accumulated by the replica. If the log files are entirely +<p>There are two ways to recover using a log-file-only replica. +The simplest way is to copy the log files from the log-file-only +replica onto another site (either master or replica) and run catastrophic +recovery there. If that is not an option, then +recovery must be run on the log-file-only replica, using the log files +that have accumulated there. +If the log files are entirely self-contained, that is, they start with log file number 1, then a log replica can simply run catastrophic recovery. Obviously, if there are a large number of log files in this case, recovery may take a long time. If the log files are not self-contained, an archival copy of the databases must first be restored onto the replica before running -catastrophic recovery. +catastrophic recovery. In the latter case (that is, running recovery +on the log-file-only replica), once the site returns to being a log-file-only +replica, the database files on the log-file-only replica should be removed, +and if the log files do not begin with log file number 1, +a new set of archival databases should be created from +the current master. <p>More specifically, the log files accumulating on the log-file-only replica can take the place of the log files described in <i>catastrophic recovery</i> section of the diff --git a/db/docs/ref/rep/newsite.html b/db/docs/ref/rep/newsite.html index ace77acf7..cdd6afaf2 100644 --- a/db/docs/ref/rep/newsite.html +++ b/db/docs/ref/rep/newsite.html @@ -1,6 +1,7 @@ <!--Id: newsite.so,v 1.2 2001/10/25 14:58:49 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB Reference Guide: Connecting to a new site</title> diff --git a/db/docs/ref/rep/partition.html b/db/docs/ref/rep/partition.html index 1b9cc8e41..e4d678ddd 100644 --- a/db/docs/ref/rep/partition.html +++ b/db/docs/ref/rep/partition.html @@ -1,6 +1,7 @@ <!--Id: partition.so,v 1.1 2001/10/25 20:05:34 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB Reference Guide: Network partitions</title> diff --git a/db/docs/ref/rep/pri.html b/db/docs/ref/rep/pri.html index cd92c9b13..e3d7a8f9d 100644 --- a/db/docs/ref/rep/pri.html +++ b/db/docs/ref/rep/pri.html @@ -1,6 +1,7 @@ <!--Id: pri.so,v 1.3 2001/11/05 17:24:27 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB Reference Guide: Replication environment priorities</title> diff --git a/db/docs/ref/rep/trans.html b/db/docs/ref/rep/trans.html index 4dac09dee..64e033d85 100644 --- a/db/docs/ref/rep/trans.html +++ b/db/docs/ref/rep/trans.html @@ -1,6 +1,7 @@ -<!--Id: trans.so,v 1.5 2001/11/05 17:24:27 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: trans.so,v 1.6 2002/05/11 18:00:23 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB Reference Guide: Transactional guarantees</title> @@ -57,34 +58,34 @@ of the <b>send</b> interface returning failure is to flush the local database environment's log as necessary to ensure that any information critical to database integrity is not lost. Because this flush is an expensive operation in terms of database performance, applications will -want to avoid returning an error from the <b>send</b> interface, unless -it is absolutely necessary. +want to avoid returning an error from the <b>send</b> interface, if at +all possible: <p>First, there is no reason for the <b>send</b> interface to ever return failure unless the <a href="../../api_c/rep_transport.html#DB_REP_PERMANENT">DB_REP_PERMANENT</a> flag is specified. Messages without that flag do not make visible changes to databases, and therefore the application's <b>send</b> interface can return success -to Berkeley DB immediately after it has sent the message (or even simply -copied the message to its local memory). +to Berkeley DB for such messages as soon as the message has been sent or even +just copied to local memory. <p>Further, unless the master's database environment has been configured to not synchronously flush the log on transaction commit, there is no reason for the <b>send</b> interface to ever return failure, as any information critical to database integrity has already been flushed to the local log before <b>send</b> was called. Again, the <b>send</b> interface should return success to Berkeley DB as soon as possible. However, -in such cases, in order to avoid potential loss of information after -the master database environment fails, the master database environment +in this case, in order to avoid potential loss of information after the +master database environment fails, the master database environment should be recovered before holding an election, as only the master database environment is guaranteed to have the most up-to-date logs. <p>To sum up, the only reason for the <b>send</b> interface to return failure is when the master database environment has been configured to not synchronously flush the log on transaction commit, the -<a href="../../api_c/rep_transport.html#DB_REP_PERMANENT">DB_REP_PERMANENT</a> flag is specified, and the <b>send</b> -interface was unable to determine that some number of clients have -received the current message (and all messages preceding the current -message). How many clients should receive the message before the -<b>send</b> interface can return success is an application choice, and, -in fact, may not depend as much on a specific number of clients -reporting success as one or more geographically distributed clients. +<a href="../../api_c/rep_transport.html#DB_REP_PERMANENT">DB_REP_PERMANENT</a> flag is specified for the message, and the +<b>send</b> interface was unable to determine that some number of +clients have received the current message (and all messages preceding +the current message). How many clients should receive the message +before the <b>send</b> interface can return success is an application +choice (and may not depend as much on a specific number of clients +reporting success as one or more geographically distributed clients). <p>Of course, it is important to ensure that the replicated master and client environments are truly independent of each other. For example, it does not help matters that a client has acknowledged receipt of a diff --git a/db/docs/ref/transapp/faq.html b/db/docs/ref/transapp/faq.html index c41ba2870..1a94344a6 100644 --- a/db/docs/ref/transapp/faq.html +++ b/db/docs/ref/transapp/faq.html @@ -1,6 +1,7 @@ -<!--Id: faq.so,v 10.3 2001/10/13 19:56:25 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: faq.so,v 10.5 2002/05/14 15:01:45 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB Reference Guide: Transaction FAQ</title> @@ -66,18 +67,14 @@ database will first be referenced in the log. If we copy the database first, then we can also know that any inconsistency in the database will be described in the log files, and so we know that we can fix everything up during recovery. -<p><li><b>Why happens if my database page size isn't the same size as the -block size used by the system for filesystem I/O?</b> -<p>Berkeley DB does not do checksums across database pages, it relies on bytes -found in a single part of each database page to decide during recovery -if a page needs to be modified or if the page is correct and no changes -are required. If the operating system wrote a large page in two parts, -or the underlying hardware could fail in some way so that those bytes -were written, but the rest of the page was not, then it would be -possible for recovery to not correctly update the page. This is an -unlikely failure scenario, but a possible one. -<p>See <a href="../../ref/transapp/reclimit.html">Berkeley DB recoverability</a> -for more detailed information. +<p><li><b>How can I move a database from one transactional environment +into another?</b> +<p>Because database pages contain references to log records, databases +cannot be simply moved into different database environments. To move +a database into a different environment, dump and reload the database +before moving it. If the database is too large to dump and reload, the +database may be prepared in place by setting the first eight bytes of +each page in the file to 0. </ol> <table width="100%"><tr><td><br></td><td align=right><a href="../../ref/transapp/throughput.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../../reftoc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../../ref/rep/intro.html"><img src="../../images/next.gif" alt="Next"></a> </td></tr></table> diff --git a/db/docs/ref/transapp/hotfail.html b/db/docs/ref/transapp/hotfail.html index 469a826b1..5caea831a 100644 --- a/db/docs/ref/transapp/hotfail.html +++ b/db/docs/ref/transapp/hotfail.html @@ -1,6 +1,7 @@ <!--Id: hotfail.so,v 10.2 2001/07/28 01:45:07 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB Reference Guide: Hot failover</title> diff --git a/db/docs/ref/upgrade.3.3/bigfile.html b/db/docs/ref/upgrade.3.3/bigfile.html index 0630c21fe..29b018ed5 100644 --- a/db/docs/ref/upgrade.3.3/bigfile.html +++ b/db/docs/ref/upgrade.3.3/bigfile.html @@ -1,6 +1,7 @@ <!--Id: bigfile.so,v 1.2 2001/06/07 19:03:21 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB Reference Guide: Release 3.3: --disable-bigfile</title> diff --git a/db/docs/ref/upgrade.3.3/getswap.html b/db/docs/ref/upgrade.3.3/getswap.html index 49f3757cd..17a2e004b 100644 --- a/db/docs/ref/upgrade.3.3/getswap.html +++ b/db/docs/ref/upgrade.3.3/getswap.html @@ -1,6 +1,7 @@ <!--Id: getswap.so,v 1.1 2001/06/07 19:00:21 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB Reference Guide: Release 3.3: DB->get_byteswapped</title> diff --git a/db/docs/ref/upgrade.3.3/gettype.html b/db/docs/ref/upgrade.3.3/gettype.html index 2dc203de0..883bc2149 100644 --- a/db/docs/ref/upgrade.3.3/gettype.html +++ b/db/docs/ref/upgrade.3.3/gettype.html @@ -1,6 +1,7 @@ <!--Id: gettype.so,v 1.1 2001/06/07 19:00:21 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB Reference Guide: Release 3.3: DB->get_type</title> diff --git a/db/docs/ref/upgrade.3.3/shared.html b/db/docs/ref/upgrade.3.3/shared.html index 770bd21ab..48fc16a9c 100644 --- a/db/docs/ref/upgrade.3.3/shared.html +++ b/db/docs/ref/upgrade.3.3/shared.html @@ -1,6 +1,7 @@ <!--Id: shared.so,v 1.2 2001/07/10 13:16:34 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB Reference Guide: Release 3.3: --enable-dynamic, --enable-shared</title> diff --git a/db/docs/ref/upgrade.4.0/asr.html b/db/docs/ref/upgrade.4.0/asr.html index 36d6efa09..78db8a1e4 100644 --- a/db/docs/ref/upgrade.4.0/asr.html +++ b/db/docs/ref/upgrade.4.0/asr.html @@ -1,6 +1,7 @@ <!--Id: asr.so,v 1.2 2001/11/14 02:27:11 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB Reference Guide: Release 4.0: application-specific recovery</title> @@ -23,11 +24,11 @@ included in the Berkeley DB distribution. against the code generated by the last release in which you built a template file. Any changes in the templates should be incorporated into the recovery routines you have written. -<p>Third, if your recovery functions refer to <a href="../../api_c/env_set_tx_recover.html#DB_TXN_FORWARD_ROLL">DB_TXN_FORWARD_ROLL</a> +<p>Third, if your recovery functions refer to <a href="../../api_c/env_set_app_dispatch.html#DB_TXN_FORWARD_ROLL">DB_TXN_FORWARD_ROLL</a> (that is, your code checks for that particular operation code), you should replace it with DB_REDO(op) which compares the operation code to -both <a href="../../api_c/env_set_tx_recover.html#DB_TXN_FORWARD_ROLL">DB_TXN_FORWARD_ROLL</a> and <a href="../../api_c/env_set_tx_recover.html#DB_TXN_APPLY">DB_TXN_APPLY</a>. -(<a href="../../api_c/env_set_tx_recover.html#DB_TXN_APPLY">DB_TXN_APPLY</a> is a potential value for the operation code as of +both <a href="../../api_c/env_set_app_dispatch.html#DB_TXN_FORWARD_ROLL">DB_TXN_FORWARD_ROLL</a> and <a href="../../api_c/env_set_app_dispatch.html#DB_TXN_APPLY">DB_TXN_APPLY</a>. +(<a href="../../api_c/env_set_app_dispatch.html#DB_TXN_APPLY">DB_TXN_APPLY</a> is a potential value for the operation code as of the 4.0 release.) <p>Finally, if you have created your own logging and recovery routines, we recommend that you contact Sleepycat support and ask us to review those diff --git a/db/docs/ref/upgrade.4.0/cxx.html b/db/docs/ref/upgrade.4.0/cxx.html index 410b0cf06..d077cf8d1 100644 --- a/db/docs/ref/upgrade.4.0/cxx.html +++ b/db/docs/ref/upgrade.4.0/cxx.html @@ -1,6 +1,7 @@ <!--Id: cxx.so,v 1.2 2001/11/16 16:49:43 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB Reference Guide: Release 4.0: C++ ostream objects</title> diff --git a/db/docs/ref/upgrade.4.0/deadlock.html b/db/docs/ref/upgrade.4.0/deadlock.html index 9fb8dbff5..2c12a9a77 100644 --- a/db/docs/ref/upgrade.4.0/deadlock.html +++ b/db/docs/ref/upgrade.4.0/deadlock.html @@ -1,6 +1,7 @@ <!--Id: deadlock.so,v 1.1 2001/09/07 16:55:56 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB Reference Guide: Release 4.0: db_deadlock</title> diff --git a/db/docs/ref/upgrade.4.0/disk.html b/db/docs/ref/upgrade.4.0/disk.html index 230840167..eba0d30cb 100644 --- a/db/docs/ref/upgrade.4.0/disk.html +++ b/db/docs/ref/upgrade.4.0/disk.html @@ -1,6 +1,7 @@ -<!--Id: disk.so,v 1.10 2001/11/09 22:11:29 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: disk.so,v 1.11 2001/12/10 15:14:06 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB Reference Guide: Release 4.0: upgrade requirements</title> @@ -10,7 +11,7 @@ <body bgcolor=white> <table width="100%"><tr valign=top> <td><h3><dl><dt>Berkeley DB Reference Guide:<dd>Upgrading Berkeley DB Applications</dl></h3></td> -<td align=right><a href="../../ref/upgrade.4.0/asr.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../../reftoc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../../ref/test/run.html"><img src="../../images/next.gif" alt="Next"></a> +<td align=right><a href="../../ref/upgrade.4.0/asr.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../../reftoc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../../ref/upgrade.4.1/intro.html"><img src="../../images/next.gif" alt="Next"></a> </td></tr></table> <p> <h1 align=center>Release 4.0: upgrade requirements</h1> @@ -18,7 +19,7 @@ formats changed in the Berkeley DB 4.0 release. <p>For further information on upgrading Berkeley DB installations, see <a href="../../ref/upgrade/process.html">Upgrading Berkeley DB installations</a>. -<table width="100%"><tr><td><br></td><td align=right><a href="../../ref/upgrade.4.0/asr.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../../reftoc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../../ref/test/run.html"><img src="../../images/next.gif" alt="Next"></a> +<table width="100%"><tr><td><br></td><td align=right><a href="../../ref/upgrade.4.0/asr.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../../reftoc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../../ref/upgrade.4.1/intro.html"><img src="../../images/next.gif" alt="Next"></a> </td></tr></table> <p><font size=1><a href="http://www.sleepycat.com">Copyright Sleepycat Software</a></font> </body> diff --git a/db/docs/ref/upgrade.4.0/env.html b/db/docs/ref/upgrade.4.0/env.html index d7c6bbaa6..e506bdc51 100644 --- a/db/docs/ref/upgrade.4.0/env.html +++ b/db/docs/ref/upgrade.4.0/env.html @@ -1,6 +1,7 @@ <!--Id: env.so,v 1.5 2001/08/07 01:42:35 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB Reference Guide: Release 4.0: db_env_set_XXX</title> diff --git a/db/docs/ref/upgrade.4.0/intro.html b/db/docs/ref/upgrade.4.0/intro.html index 6284e4bf5..edd2bf9bb 100644 --- a/db/docs/ref/upgrade.4.0/intro.html +++ b/db/docs/ref/upgrade.4.0/intro.html @@ -1,6 +1,7 @@ <!--Id: intro.so,v 1.5 2001/09/28 15:10:29 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB Reference Guide: Release 4.0: introduction</title> diff --git a/db/docs/ref/upgrade.4.0/java.html b/db/docs/ref/upgrade.4.0/java.html index 788620b18..74ec217fd 100644 --- a/db/docs/ref/upgrade.4.0/java.html +++ b/db/docs/ref/upgrade.4.0/java.html @@ -1,6 +1,7 @@ <!--Id: java.so,v 1.6 2001/11/14 02:27:12 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB Reference Guide: Release 4.0: Java CLASSPATH environment variable</title> @@ -19,7 +20,7 @@ release, the <b>CLASSPATH</b> environment variable must change to include at least the <b>db.jar</b> file. It can optionally include the <b>dbexamples.jar</b> file if you want to run the examples. For example, on UNIX: -<p><blockquote><pre>export CLASSPATH="/usr/local/BerkeleyDB.4.0/lib/db.jar:/usr/local/BerkeleyDB.4.0/lib/dbexamples.jar"</pre></blockquote> +<p><blockquote><pre>export CLASSPATH="/usr/local/BerkeleyDB.4.1/lib/db.jar:/usr/local/BerkeleyDB.4.1/lib/dbexamples.jar"</pre></blockquote> <p>For example, on Windows: <p><blockquote><pre>set CLASSPATH="D:\db\build_win32\Release\db.jar;D:\db\build_win32\Release\dbexamples.jar"</pre></blockquote> <p>For more information on Java configuration, please see diff --git a/db/docs/ref/upgrade.4.0/lock.html b/db/docs/ref/upgrade.4.0/lock.html index 118f2d884..d7dcf1d1f 100644 --- a/db/docs/ref/upgrade.4.0/lock.html +++ b/db/docs/ref/upgrade.4.0/lock.html @@ -1,6 +1,7 @@ <!--Id: lock.so,v 1.6 2001/09/27 02:25:51 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB Reference Guide: Release 4.0: lock_XXX</title> diff --git a/db/docs/ref/upgrade.4.0/lock_id_free.html b/db/docs/ref/upgrade.4.0/lock_id_free.html index fb1b56a3c..0fe47ad6b 100644 --- a/db/docs/ref/upgrade.4.0/lock_id_free.html +++ b/db/docs/ref/upgrade.4.0/lock_id_free.html @@ -1,6 +1,7 @@ <!--Id: lock_id_free.so,v 1.1 2001/09/25 21:05:24 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB Reference Guide: Release 4.0: DB_ENV->lock_id_free</title> diff --git a/db/docs/ref/upgrade.4.0/log.html b/db/docs/ref/upgrade.4.0/log.html index dfae570ab..41ae96de8 100644 --- a/db/docs/ref/upgrade.4.0/log.html +++ b/db/docs/ref/upgrade.4.0/log.html @@ -1,6 +1,7 @@ -<!--Id: log.so,v 1.3 2001/09/28 15:09:42 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Id: log.so,v 1.4 2001/12/31 21:07:00 bostic Exp --> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB Reference Guide: Release 4.0: log_XXX</title> @@ -23,9 +24,9 @@ release as follows: <tr><td>log_flush</td><td><a href="../../api_c/log_flush.html">DB_ENV->log_flush</a></td></tr> <tr><td>log_get</td><td><a href="../../api_c/log_cursor.html">DB_ENV->log_cursor</a>, <a href="../../api_c/logc_get.html">DB_LOGC->get</a>, <a href="../../api_c/logc_close.html">DB_LOGC->close</a></td></tr> <tr><td>log_put</td><td><a href="../../api_c/log_put.html">DB_ENV->log_put</a></td></tr> -<tr><td>log_register</td><td><a href="../../api_c/log_register.html">DB_ENV->log_register</a></td></tr> +<tr><td>log_register</td><td>DB_ENV->log_register</td></tr> <tr><td>log_stat</td><td><a href="../../api_c/log_stat.html">DB_ENV->log_stat</a></td></tr> -<tr><td>log_unregister</td><td><a href="../../api_c/log_unregister.html">DB_ENV->log_unregister</a></td></tr> +<tr><td>log_unregister</td><td>DB_ENV->log_unregister</td></tr> </table> <p>Applications calling any of these functions should update their calls to use the enclosing <a href="../../api_c/env_create.html">DB_ENV</a> handle's method (in all cases other diff --git a/db/docs/ref/upgrade.4.0/mp.html b/db/docs/ref/upgrade.4.0/mp.html index c99a47863..bbd8b7ebe 100644 --- a/db/docs/ref/upgrade.4.0/mp.html +++ b/db/docs/ref/upgrade.4.0/mp.html @@ -1,6 +1,7 @@ <!--Id: mp.so,v 1.2 2001/09/27 02:25:52 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB Reference Guide: Release 4.0: memp_XXX</title> diff --git a/db/docs/ref/upgrade.4.0/rpc.html b/db/docs/ref/upgrade.4.0/rpc.html index b273750fa..50f4cf074 100644 --- a/db/docs/ref/upgrade.4.0/rpc.html +++ b/db/docs/ref/upgrade.4.0/rpc.html @@ -1,6 +1,7 @@ <!--Id: rpc.so,v 1.5 2001/07/27 23:18:47 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB Reference Guide: Release 4.0: DB_ENV->set_server</title> diff --git a/db/docs/ref/upgrade.4.0/set_lk_max.html b/db/docs/ref/upgrade.4.0/set_lk_max.html index 020b379e7..e2605de58 100644 --- a/db/docs/ref/upgrade.4.0/set_lk_max.html +++ b/db/docs/ref/upgrade.4.0/set_lk_max.html @@ -1,6 +1,7 @@ <!--Id: set_lk_max.so,v 1.3 2001/09/25 21:05:25 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB Reference Guide: Release 4.0: DB_ENV->set_lk_max</title> diff --git a/db/docs/ref/upgrade.4.0/toc.html b/db/docs/ref/upgrade.4.0/toc.html index ad2033946..f0c3138ea 100644 --- a/db/docs/ref/upgrade.4.0/toc.html +++ b/db/docs/ref/upgrade.4.0/toc.html @@ -1,6 +1,7 @@ <!--Id: toc.so,v 1.15 2001/11/14 02:27:12 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB Reference Guide: Upgrading Berkeley DB 3.3.X applications to Berkeley DB 4.0</title> diff --git a/db/docs/ref/upgrade.4.0/txn.html b/db/docs/ref/upgrade.4.0/txn.html index 23e15227a..913f06334 100644 --- a/db/docs/ref/upgrade.4.0/txn.html +++ b/db/docs/ref/upgrade.4.0/txn.html @@ -1,6 +1,7 @@ <!--Id: txn.so,v 1.5 2001/09/27 02:25:52 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB Reference Guide: Release 4.0: txn_XXX</title> diff --git a/db/docs/ref/upgrade/version.html b/db/docs/ref/upgrade/version.html index 26ffd4e99..53c09b559 100644 --- a/db/docs/ref/upgrade/version.html +++ b/db/docs/ref/upgrade/version.html @@ -1,6 +1,7 @@ <!--Id: version.so,v 10.19 2001/06/25 13:29:43 bostic Exp --> -<!--Copyright 1997-2001 by Sleepycat Software, Inc.--> +<!--Copyright 1997-2002 by Sleepycat Software, Inc.--> <!--All rights reserved.--> +<!--See the file LICENSE for redistribution information.--> <html> <head> <title>Berkeley DB Reference Guide: Library version information</title> diff --git a/db/examples_c/bench_001.c b/db/examples_c/bench_001.c index a8faccc45..b35a6f806 100644 --- a/db/examples_c/bench_001.c +++ b/db/examples_c/bench_001.c @@ -1,6 +1,8 @@ /*- - * Copyright (c) 2001 + * Copyright (c) 2001-2002 * Sleepycat Software. All rights reserved. + * + * Id: bench_001.c,v 1.12 2002/08/06 06:11:23 bostic Exp */ /* @@ -127,7 +129,7 @@ get(dbp, txn, datalen, num, dups, iter, countp) else while (pointer != NULL) { DB_MULTIPLE_KEY_NEXT(pointer, - &data, kp, klen, dp, len); + &data, kp, klen, dp, len); if (kp != NULL) count++; } @@ -142,13 +144,19 @@ get(dbp, txn, datalen, num, dups, iter, countp) /* * fill - fill a db + * Since we open/created the db with transactions (potentially), + * we need to populate it with transactions. We'll bundle the puts + * 10 to a transaction. */ +#define PUTS_PER_TXN 10 int -fill(dbp, datalen, num, dups) +fill(dbenv, dbp, txn, datalen, num, dups) + DB_ENV *dbenv; DB *dbp; - int datalen, num, dups; + int txn, datalen, num, dups; { DBT key, data; + DB_TXN *txnp; struct data { int id; char str[1]; @@ -158,6 +166,8 @@ fill(dbp, datalen, num, dups) * Insert records into the database, where the key is the user * input and the data is the user input in reverse order. */ + txnp = NULL; + ret = 0; count = 0; memset(&key, 0, sizeof(DBT)); memset(&data, 0, sizeof(DBT)); @@ -170,22 +180,40 @@ fill(dbp, datalen, num, dups) data.flags = DB_DBT_USERMEM; for (i = 0; i < num; i++) { + if (txn != 0 && i % PUTS_PER_TXN == 0) { + if (txnp != NULL) { + ret = txnp->commit(txnp, 0); + txnp = NULL; + if (ret != 0) + goto err; + } + if ((ret = + dbenv->txn_begin(dbenv, NULL, &txnp, 0)) != 0) + goto err; + } data_val->id = 0; do { switch (ret = - dbp->put(dbp, NULL, &key, &data, 0)) { + dbp->put(dbp, txnp, &key, &data, 0)) { case 0: count++; break; default: dbp->err(dbp, ret, "DB->put"); - return (ret); + goto err; break; } } while (++data_val->id < dups); } + if (txnp != NULL) + ret = txnp->commit(txnp, 0); + printf("%d\n", count); - return (0); + return (ret); + +err: if (txnp != NULL) + (void)txnp->abort(txnp); + return (ret); } int @@ -197,6 +225,7 @@ main(argc, argv) extern int optind; DB *dbp; DB_ENV *dbenv; + DB_TXN *txnp; struct timeval start_time, end_time; double secs; int ch, count, env, ret; @@ -211,6 +240,8 @@ main(argc, argv) dups = 0; init = 0; txn = 0; + txnp = NULL; + while ((ch = getopt(argc, argv, "c:d:EIi:l:n:p:RT")) != EOF) switch (ch) { case 'c': @@ -290,12 +321,25 @@ main(argc, argv) dbp->err(dbp, ret, "set_flags"); goto err1; } - if ((ret = dbp->open(dbp, - DATABASE, NULL, DB_BTREE, DB_CREATE, 0664)) != 0) { + + if (txn != 0) + if ((ret = dbenv->txn_begin(dbenv, NULL, &txnp, 0)) != 0) + goto err1; + + if ((ret = dbp->open( + dbp, txnp, DATABASE, NULL, DB_BTREE, DB_CREATE, 0664)) != 0) { dbp->err(dbp, ret, "%s: open", DATABASE); + if (txnp != NULL) + (void)txnp->abort(txnp); goto err1; } + if (txnp != NULL) + ret = txnp->commit(txnp, 0); + txnp = NULL; + if (ret != 0) + goto err1; + if (read) { /* If no environment, fill the cache. */ if (!env && (ret = @@ -316,7 +360,7 @@ main(argc, argv) count, iter, secs); printf("%.0f records/second\n", (double)count / secs); - } else if ((ret = fill(dbp, datalen, num, dups)) != 0) + } else if ((ret = fill(dbenv, dbp, txn, datalen, num, dups)) != 0) goto err1; /* Close everything down. */ @@ -325,7 +369,7 @@ main(argc, argv) "%s: DB->close: %s\n", progname, db_strerror(ret)); return (1); } - return (0); + return (ret); err1: (void)dbp->close(dbp, 0); return (1); @@ -335,7 +379,7 @@ void usage() { (void)fprintf(stderr, "usage: %s %s\n\t%s\n", - progname, "[-EIRT] [-c cachesize] [-d dups]", - "[-i iterations] [-l datalen] [-n keys] [-p pagesize]"); + progname, "[-EIRT] [-c cachesize] [-d dups]", + "[-i iterations] [-l datalen] [-n keys] [-p pagesize]"); exit(EXIT_FAILURE); } diff --git a/db/examples_c/ex_repquote/ex_repquote.h b/db/examples_c/ex_repquote/ex_repquote.h index 75edbcc3c..61457d049 100644 --- a/db/examples_c/ex_repquote/ex_repquote.h +++ b/db/examples_c/ex_repquote/ex_repquote.h @@ -1,10 +1,10 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2001 + * Copyright (c) 2001-2002 * Sleepycat Software. All rights reserved. * - * Id: ex_repquote.h,v 1.24 2001/10/28 15:45:39 bostic Exp + * Id: ex_repquote.h,v 1.27 2002/04/23 04:27:50 krinsky Exp */ #ifndef _EX_REPQUOTE_H_ @@ -15,7 +15,7 @@ typedef struct { char *host; /* Host name. */ u_int32_t port; /* Port on which to connect to this site. */ -} site_t; +} repsite_t; /* Globals */ extern int master_eid; @@ -27,18 +27,18 @@ struct __machtab; typedef struct __machtab machtab_t; /* Arguments for the connect_all thread. */ typedef struct { DB_ENV *dbenv; - char *progname; - char *home; + const char *progname; + const char *home; machtab_t *machtab; - site_t *sites; + repsite_t *sites; int nsites; } all_args; /* Arguments for the connect_loop thread. */ typedef struct { DB_ENV *dbenv; - char * home; - char * progname; + const char * home; + const char * progname; machtab_t *machtab; int port; } connect_args; @@ -49,13 +49,13 @@ typedef struct { void *connect_all __P((void *args)); void *connect_thread __P((void *args)); -int doclient __P((DB_ENV *, char *, machtab_t *)); -int domaster __P((DB_ENV *, char *)); -int get_accepted_socket __P((char *, int)); -int get_connected_socket __P((machtab_t *, char *, char *, int, int *, int *)); +int doclient __P((DB_ENV *, const char *, machtab_t *)); +int domaster __P((DB_ENV *, const char *)); +int get_accepted_socket __P((const char *, int)); +int get_connected_socket __P((machtab_t *, const char *, const char *, int, int *, int *)); int get_next_message __P((int, DBT *, DBT *)); -int listen_socket_init __P((char *, int)); -int listen_socket_accept __P((machtab_t *, char *, int, int *)); +int listen_socket_init __P((const char *, int)); +int listen_socket_accept __P((machtab_t *, const char *, int, int *)); int machtab_getinfo __P((machtab_t *, int, u_int32_t *, int *)); int machtab_init __P((machtab_t **, int, int)); void machtab_parm __P((machtab_t *, int *, int *, u_int32_t *)); diff --git a/db/examples_c/ex_repquote/ex_rq_client.c b/db/examples_c/ex_repquote/ex_rq_client.c index a6d4b143c..f8a291451 100644 --- a/db/examples_c/ex_repquote/ex_rq_client.c +++ b/db/examples_c/ex_repquote/ex_rq_client.c @@ -1,10 +1,10 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2001 + * Copyright (c) 2001-2002 * Sleepycat Software. All rights reserved. * - * Id: ex_rq_client.c,v 1.25 2001/11/18 01:29:07 margo Exp + * Id: ex_rq_client.c,v 1.29 2002/01/23 15:33:19 bostic Exp */ #include <sys/types.h> @@ -27,7 +27,7 @@ static void *display_loop __P((void *)); static int print_stocks __P((DBC *)); typedef struct { - char *progname; + const char *progname; DB_ENV *dbenv; } disploop_args; @@ -39,7 +39,7 @@ typedef struct { int doclient(dbenv, progname, machtab) DB_ENV *dbenv; - char *progname; + const char *progname; machtab_t *machtab; { checkloop_args cargs; @@ -135,7 +135,7 @@ display_loop(args) DB *dbp; DB_ENV *dbenv; DBC *dbc; - char *progname; + const char *progname; disploop_args *dargs; int ret, rval; @@ -157,7 +157,7 @@ display_loop(args) return ((void *)EXIT_FAILURE); } - if ((ret = dbp->open(dbp, + if ((ret = dbp->open(dbp, NULL, DATABASE, NULL, DB_BTREE, DB_RDONLY, 0)) != 0) { if (ret == ENOENT) { printf( diff --git a/db/examples_c/ex_repquote/ex_rq_main.c b/db/examples_c/ex_repquote/ex_rq_main.c index f9adbacad..318da6cad 100644 --- a/db/examples_c/ex_repquote/ex_rq_main.c +++ b/db/examples_c/ex_repquote/ex_rq_main.c @@ -1,10 +1,10 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2001 + * Copyright (c) 2001-2002 * Sleepycat Software. All rights reserved. * - * Id: ex_rq_main.c,v 1.18 2001/11/18 01:29:07 margo Exp + * Id: ex_rq_main.c,v 1.23 2002/08/06 05:39:03 bostic Exp */ #include <sys/types.h> @@ -26,8 +26,9 @@ int master_eid; char *myaddr; -static int env_init __P((char *, char *, DB_ENV **, machtab_t *, u_int32_t)); -static void usage __P((char *)); +static int env_init __P((const char *, const char *, DB_ENV **, machtab_t *, + u_int32_t)); +static void usage __P((const char *)); int main(argc, argv) @@ -43,10 +44,11 @@ main(argc, argv) connect_args ca; machtab_t *machtab; pthread_t all_thr, conn_thr; - site_t site, *sitep, self, *selfp; + repsite_t site, *sitep, self, *selfp; struct sigaction sigact; int maxsites, nsites, ret, priority, totalsites; - char *c, ch, *home, *progname; + char *c, ch; + const char *home, *progname; void *astatus, *cstatus; master_eid = DB_EID_INVALID; @@ -101,7 +103,7 @@ main(argc, argv) if (sitep == NULL || nsites >= maxsites) { maxsites = maxsites == 0 ? 10 : 2 * maxsites; if ((sitep = realloc(sitep, - maxsites * sizeof(site_t))) == NULL) { + maxsites * sizeof(repsite_t))) == NULL) { fprintf(stderr, "System error %s\n", strerror(errno)); goto err; @@ -250,9 +252,9 @@ err: if (machtab != NULL) */ static void usage(progname) - char *progname; + const char *progname; { - fprintf(stderr, "usage: %s ", progname); + fprintf(stderr, "usage: %s ", progname); fprintf(stderr, "[-CM][-h home][-o host:port][-m host:port]%s", "[-n nsites][-p priority]\n"); exit(EXIT_FAILURE); @@ -261,7 +263,7 @@ usage(progname) /* Open and configure an environment. */ int env_init(progname, home, dbenvp, machtab, flags) - char *progname, *home; + const char *progname, *home; DB_ENV **dbenvp; machtab_t *machtab; u_int32_t flags; @@ -284,7 +286,7 @@ env_init(progname, home, dbenvp, machtab, flags) } dbenv->set_errfile(dbenv, stderr); dbenv->set_errpfx(dbenv, prefix); - (void)dbenv->set_verbose(dbenv, DB_VERB_REPLICATION, 1); + /* (void)dbenv->set_verbose(dbenv, DB_VERB_REPLICATION, 1); */ (void)dbenv->set_cachesize(dbenv, 0, CACHESIZE, 0); /* (void)dbenv->set_flags(dbenv, DB_TXN_NOSYNC, 1); */ @@ -299,4 +301,3 @@ env_init(progname, home, dbenvp, machtab, flags) *dbenvp = dbenv; return (ret); } - diff --git a/db/examples_c/ex_repquote/ex_rq_master.c b/db/examples_c/ex_repquote/ex_rq_master.c index 713a1dec6..de7e81220 100644 --- a/db/examples_c/ex_repquote/ex_rq_master.c +++ b/db/examples_c/ex_repquote/ex_rq_master.c @@ -2,17 +2,16 @@ * #include <pthread.h> * See the file LICENSE for redistribution information. * - * Copyright (c) 2001 + * Copyright (c) 2001-2002 * Sleepycat Software. All rights reserved. * - * Id: ex_rq_master.c,v 1.16 2001/10/26 19:19:43 margo Exp + * Id: ex_rq_master.c,v 1.22 2002/08/06 05:39:03 bostic Exp */ #include <sys/types.h> #include <errno.h> #include <pthread.h> -#include <queue.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -29,7 +28,7 @@ static void *master_loop __P((void *)); int domaster(dbenv, progname) DB_ENV *dbenv; - char *progname; + const char *progname; { int ret, t_ret; pthread_t interface_thr; @@ -84,9 +83,17 @@ master_loop(dbenvv) if ((ret = db_create(&dbp, dbenv, 0)) != 0) return ((void *)ret); - if ((ret = dbp->open(dbp, DATABASE, + if ((ret = dbenv->txn_begin(dbenv, NULL, &txn, 0)) != 0) + goto err; + if ((ret = dbp->open(dbp, txn, DATABASE, NULL, DB_BTREE, DB_CREATE /* | DB_THREAD */, 0)) != 0) goto err; + ret = txn->commit(txn, 0); + txn = NULL; + if (ret != 0) { + dbp = NULL; + goto err; + } #ifdef NOTDEF } else { @@ -156,4 +163,3 @@ err: if (txn != NULL) return ((void *)ret); } - diff --git a/db/examples_c/ex_repquote/ex_rq_net.c b/db/examples_c/ex_repquote/ex_rq_net.c index 0ef216f49..1816157af 100644 --- a/db/examples_c/ex_repquote/ex_rq_net.c +++ b/db/examples_c/ex_repquote/ex_rq_net.c @@ -1,10 +1,10 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2001 + * Copyright (c) 2001-2002 * Sleepycat Software. All rights reserved. * - * Id: ex_rq_net.c,v 1.30 2001/11/18 01:29:07 margo Exp + * Id: ex_rq_net.c,v 1.37 2002/08/06 05:39:04 bostic Exp */ #include <sys/types.h> @@ -17,7 +17,6 @@ #include <errno.h> #include <netdb.h> #include <pthread.h> -#include <queue.h> #include <signal.h> #include <stdio.h> #include <stdlib.h> @@ -25,12 +24,12 @@ #include <unistd.h> #include <db.h> +#include <dbinc/queue.h> /* !!!: for the LIST_XXX macros. */ -#include "mutex.h" -#include "rep.h" #include "ex_repquote.h" int machtab_add __P((machtab_t *, int, u_int32_t, int, int *)); +ssize_t readn __P((int, void *, size_t)); /* * This file defines the communication infrastructure for the ex_repquote @@ -269,7 +268,7 @@ machtab_parm(machtab, nump, prip, timeoutp) */ int listen_socket_init(progname, port) - char *progname; + const char *progname; int port; { int s; @@ -308,11 +307,11 @@ err: fprintf(stderr, "%s: %s", progname, strerror(errno)); int listen_socket_accept(machtab, progname, s, eidp) machtab_t *machtab; - char *progname; + const char *progname; int s, *eidp; { struct sockaddr_in si; - socklen_t si_len; + int si_len; int host, ns, port, ret; COMPQUIET(progname, NULL); @@ -342,12 +341,12 @@ err: close(ns); */ int get_accepted_socket(progname, port) - char *progname; + const char *progname; int port; { struct protoent *proto; struct sockaddr_in si; - socklen_t si_len; + int si_len; int s, ns; if ((proto = getprotobyname("tcp")) == NULL) @@ -389,7 +388,7 @@ err: fprintf(stderr, "%s: %s", progname, strerror(errno)); int get_connected_socket(machtab, progname, remotehost, port, is_open, eidp) machtab_t *machtab; - char *progname, *remotehost; + const char *progname, *remotehost; int port, *is_open, *eidp; { int ret, s; @@ -441,7 +440,7 @@ get_connected_socket(machtab, progname, remotehost, port, is_open, eidp) * Read a single message from the specified file descriptor, and * return it in the format used by rep functions (two DBTs and a type). * - * This function is called in a loop by both clients and masters, and + * This function is called in a loop by both clients and masters, and * the resulting DBTs are manually dispatched to DB_ENV->rep_process_message(). */ int @@ -449,7 +448,7 @@ get_next_message(fd, rec, control) int fd; DBT *rec, *control; { - size_t nr, nleft; + size_t nr; u_int32_t rsize, csize; u_int8_t *recbuf, *controlbuf; @@ -463,7 +462,7 @@ get_next_message(fd, rec, control) */ /* Read rec->size. */ - nr = read(fd, &rsize, 4); + nr = readn(fd, &rsize, 4); if (nr != 4) return (1); @@ -471,15 +470,8 @@ get_next_message(fd, rec, control) if (rsize > 0) { if (rec->size < rsize) rec->data = realloc(rec->data, rsize); - nleft = rsize; recbuf = rec->data; - while (nleft > 0) { - nr = read(fd, recbuf, nleft); - if (nr <= 0) - return (1); - nleft -= nr; - recbuf += nr; - } + nr = readn(fd, recbuf, rsize); } else { if (rec->data != NULL) free(rec->data); @@ -488,7 +480,7 @@ get_next_message(fd, rec, control) rec->size = rsize; /* Read control->size. */ - nr = read(fd, &csize, 4); + nr = readn(fd, &csize, 4); if (nr != 4) return (1); @@ -497,7 +489,7 @@ get_next_message(fd, rec, control) controlbuf = control->data; if (control->size < csize) controlbuf = realloc(controlbuf, csize); - nr = read(fd, controlbuf, csize); + nr = readn(fd, controlbuf, csize); if (nr != csize) return (1); } else { @@ -508,13 +500,47 @@ get_next_message(fd, rec, control) control->data = controlbuf; control->size = csize; -fprintf(stderr, "%lx Received %d\n", (long)pthread_self(), -((REP_CONTROL *)controlbuf)->rectype ); - return (0); } /* + * readn -- + * Read a full n characters from a file descriptor, unless we get an error + * or EOF. + */ +ssize_t +readn(fd, vptr, n) + int fd; + void *vptr; + size_t n; +{ + size_t nleft; + ssize_t nread; + char *ptr; + + ptr = vptr; + nleft = n; + while (nleft > 0) { + if ( (nread = read(fd, ptr, nleft)) < 0) { + /* + * Call read() again on interrupted system call; + * on other errors, bail. + */ + if (errno == EINTR) + nread = 0; + else + return (-1); + } else if (nread == 0) + break; /* EOF */ + + nleft -= nread; + ptr += nread; + } + + return (n - nleft); +} + +/* * quote_send -- * The f_send function for DB_ENV->set_rep_transport. */ @@ -662,7 +688,5 @@ quote_send_one(rec, control, fd, flags) if (nw != (ssize_t)control->size) return (DB_REP_UNAVAIL); } -fprintf(stderr, "%lx Sent %d\n", (long)pthread_self(), -((REP_CONTROL *)control->data)->rectype ); return (0); } diff --git a/db/examples_c/ex_repquote/ex_rq_util.c b/db/examples_c/ex_repquote/ex_rq_util.c index 9fbb3eb10..d2e16f460 100644 --- a/db/examples_c/ex_repquote/ex_rq_util.c +++ b/db/examples_c/ex_repquote/ex_rq_util.c @@ -1,10 +1,10 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2001 + * Copyright (c) 2001-2002 * Sleepycat Software. All rights reserved. * - * Id: ex_rq_util.c,v 1.14 2001/10/28 15:45:39 bostic Exp + * Id: ex_rq_util.c,v 1.20 2002/08/06 05:39:04 bostic Exp */ #include <sys/types.h> @@ -20,8 +20,8 @@ #include "ex_repquote.h" -static int connect_site __P((DB_ENV *, machtab_t *, char *, - site_t *, int *, int *)); +static int connect_site __P((DB_ENV *, machtab_t *, const char *, + repsite_t *, int *, int *)); void * elect_thread __P((void *)); typedef struct { @@ -31,8 +31,8 @@ typedef struct { typedef struct { DB_ENV *dbenv; - char *progname; - char *home; + const char *progname; + const char *home; int fd; u_int32_t eid; machtab_t *tab; @@ -49,14 +49,14 @@ hm_loop(args) { DB_ENV *dbenv; DBT rec, control; - char *c, *home, *progname; + const char *c, *home, *progname; int fd, eid, n, newm; int open, pri, r, ret, t_ret, tmpid; elect_args *ea; hm_loop_args *ha; machtab_t *tab; pthread_t elect_thr; - site_t self; + repsite_t self; u_int32_t timeout; void *status; @@ -182,7 +182,7 @@ hm_loop(args) case 0: break; default: - dbenv->err(dbenv, r, "DBENV->rep_process_message"); + dbenv->err(dbenv, r, "DB_ENV->rep_process_message"); break; } } @@ -207,8 +207,7 @@ connect_thread(args) void *args; { DB_ENV *dbenv; - char *home; - char *progname; + const char *home, *progname; int fd, i, eid, ns, port, ret; hm_loop_args *ha; connect_args *cargs; @@ -279,11 +278,11 @@ connect_all(args) { DB_ENV *dbenv; all_args *aa; - char *home, *progname; + const char *home, *progname; hm_loop_args *ha; int failed, i, eid, nsites, open, ret, *success; machtab_t *machtab; - site_t *sites; + repsite_t *sites; ha = NULL; aa = (all_args *)args; @@ -295,7 +294,9 @@ connect_all(args) sites = aa->sites; ret = 0; - if ((success = calloc(nsites, sizeof(int))) == NULL) { + + /* Some implementations of calloc are sad about alloc'ing 0 things. */ + if ((success = calloc(nsites > 0 ? nsites : 1, sizeof(int))) == NULL) { dbenv->err(dbenv, errno, "connect_all"); ret = 1; goto err; @@ -339,8 +340,8 @@ int connect_site(dbenv, machtab, progname, site, is_open, eidp) DB_ENV *dbenv; machtab_t *machtab; - char *progname; - site_t *site; + const char *progname; + repsite_t *site; int *is_open; int *eidp; { diff --git a/db/hash/hash_dup.c b/db/hash/hash_dup.c index ad06c522c..cb760148f 100644 --- a/db/hash/hash_dup.c +++ b/db/hash/hash_dup.c @@ -1,7 +1,7 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1996-2001 + * Copyright (c) 1996-2002 * Sleepycat Software. All rights reserved. */ /* @@ -38,20 +38,14 @@ #include "db_config.h" #ifndef lint -static const char revid[] = "Id: hash_dup.c,v 11.65 2001/08/13 19:11:37 bostic Exp "; +static const char revid[] = "Id: hash_dup.c,v 11.76 2002/08/06 05:34:40 bostic Exp "; #endif /* not lint */ /* * PACKAGE: hashing * * DESCRIPTION: - * Manipulation of duplicates for the hash package. - * - * ROUTINES: - * - * External - * __add_dup - * Internal + * Manipulation of duplicates for the hash package. */ #ifndef NO_SYSTEM_INCLUDES @@ -61,10 +55,9 @@ static const char revid[] = "Id: hash_dup.c,v 11.65 2001/08/13 19:11:37 bostic E #endif #include "db_int.h" -#include "db_page.h" -#include "hash.h" -#include "btree.h" -#include "txn.h" +#include "dbinc/db_page.h" +#include "dbinc/hash.h" +#include "dbinc/btree.h" static int __ham_c_chgpg __P((DBC *, db_pgno_t, u_int32_t, db_pgno_t, u_int32_t)); @@ -122,12 +115,12 @@ __ham_add_dup(dbc, nval, flags, pgnop) * hcp->dndx is the first free ndx or the index of the * current pointer into the duplicate set. */ - hk = H_PAIRDATA(hcp->page, hcp->indx); + hk = H_PAIRDATA(dbp, hcp->page, hcp->indx); /* Add the len bytes to the current singleton. */ if (HPAGE_PTYPE(hk) != H_DUPLICATE) add_bytes += DUP_SIZE(0); new_size = - LEN_HKEYDATA(hcp->page, dbp->pgsize, H_DATAINDEX(hcp->indx)) + + LEN_HKEYDATA(dbp, hcp->page, dbp->pgsize, H_DATAINDEX(hcp->indx)) + add_bytes; /* @@ -137,7 +130,7 @@ __ham_add_dup(dbc, nval, flags, pgnop) */ if (HPAGE_PTYPE(hk) != H_OFFDUP && (HPAGE_PTYPE(hk) == H_OFFPAGE || ISBIG(hcp, new_size) || - add_bytes > P_FREESPACE(hcp->page))) { + add_bytes > P_FREESPACE(dbp, hcp->page))) { if ((ret = __ham_dup_convert(dbc)) != 0) return (ret); @@ -150,14 +143,14 @@ __ham_add_dup(dbc, nval, flags, pgnop) if (HPAGE_PTYPE(hk) != H_DUPLICATE) { pval.flags = 0; pval.data = HKEYDATA_DATA(hk); - pval.size = LEN_HDATA(hcp->page, dbp->pgsize, + pval.size = LEN_HDATA(dbp, hcp->page, dbp->pgsize, hcp->indx); if ((ret = __ham_make_dup(dbp->dbenv, &pval, &tmp_val, &dbc->my_rdata.data, &dbc->my_rdata.ulen)) != 0 || (ret = __ham_replpair(dbc, &tmp_val, 1)) != 0) return (ret); - hk = H_PAIRDATA(hcp->page, hcp->indx); + hk = H_PAIRDATA(dbp, hcp->page, hcp->indx); HPAGE_PTYPE(hk) = H_DUPLICATE; /* @@ -188,7 +181,7 @@ __ham_add_dup(dbc, nval, flags, pgnop) if (cmp == 0) return (__db_duperr(dbp, flags)); } else { - hcp->dup_tlen = LEN_HDATA(hcp->page, + hcp->dup_tlen = LEN_HDATA(dbp, hcp->page, dbp->pgsize, hcp->indx); hcp->dup_len = nval->size; F_SET(hcp, H_ISDUP); @@ -218,12 +211,12 @@ __ham_add_dup(dbc, nval, flags, pgnop) case DB_AFTER: hcp->dup_off += DUP_SIZE(hcp->dup_len); hcp->dup_len = nval->size; - hcp->dup_tlen += DUP_SIZE(nval->size); + hcp->dup_tlen += (db_indx_t)DUP_SIZE(nval->size); break; case DB_KEYFIRST: case DB_KEYLAST: case DB_BEFORE: - hcp->dup_tlen += DUP_SIZE(nval->size); + hcp->dup_tlen += (db_indx_t)DUP_SIZE(nval->size); hcp->dup_len = nval->size; break; } @@ -235,8 +228,8 @@ __ham_add_dup(dbc, nval, flags, pgnop) * If we get here, then we're on duplicate pages; set pgnop and * return so the common code can handle it. */ - memcpy(pgnop, - HOFFDUP_PGNO(H_PAIRDATA(hcp->page, hcp->indx)), sizeof(db_pgno_t)); + memcpy(pgnop, HOFFDUP_PGNO(H_PAIRDATA(dbp, hcp->page, hcp->indx)), + sizeof(db_pgno_t)); return (ret); } @@ -287,18 +280,18 @@ __ham_dup_convert(dbc) * Now put the duplicates onto the new page. */ dbt.flags = 0; - switch (HPAGE_PTYPE(H_PAIRDATA(hcp->page, hcp->indx))) { + switch (HPAGE_PTYPE(H_PAIRDATA(dbp, hcp->page, hcp->indx))) { case H_KEYDATA: /* Simple case, one key on page; move it to dup page. */ - dbt.size = LEN_HDATA(hcp->page, dbp->pgsize, hcp->indx); - dbt.data = HKEYDATA_DATA(H_PAIRDATA(hcp->page, hcp->indx)); + dbt.size = LEN_HDATA(dbp, hcp->page, dbp->pgsize, hcp->indx); + dbt.data = HKEYDATA_DATA(H_PAIRDATA(dbp, hcp->page, hcp->indx)); ret = __db_pitem(dbc, dp, 0, BKEYDATA_SIZE(dbt.size), NULL, &dbt); goto finish; case H_OFFPAGE: /* Simple case, one key on page; move it to dup page. */ - memcpy(&ho, - P_ENTRY(hcp->page, H_DATAINDEX(hcp->indx)), HOFFPAGE_SIZE); + memcpy(&ho, P_ENTRY(dbp, hcp->page, H_DATAINDEX(hcp->indx)), + HOFFPAGE_SIZE); UMRW_SET(bo.unused1); B_TSET(bo.type, ho.type, 0); UMRW_SET(bo.unused2); @@ -313,11 +306,10 @@ finish: if (ret == 0) { break; /* Update any other cursors. */ - if (hcs != NULL && DB_LOGGING(dbc) - && IS_SUBTRANSACTION(dbc->txn)) { - if ((ret = __ham_chgpg_log(dbp->dbenv, - dbc->txn, &lsn, 0, dbp->log_fileid, - DB_HAM_DUP, PGNO(hcp->page), + if (hcs != NULL && DBC_LOGGING(dbc) && + IS_SUBTRANSACTION(dbc->txn)) { + if ((ret = __ham_chgpg_log(dbp, dbc->txn, + &lsn, 0, DB_HAM_DUP, PGNO(hcp->page), PGNO(dp), hcp->indx, 0)) != 0) break; } @@ -328,9 +320,9 @@ finish: if (ret == 0) { } break; case H_DUPLICATE: - p = HKEYDATA_DATA(H_PAIRDATA(hcp->page, hcp->indx)); + p = HKEYDATA_DATA(H_PAIRDATA(dbp, hcp->page, hcp->indx)); pend = p + - LEN_HDATA(hcp->page, dbp->pgsize, hcp->indx); + LEN_HDATA(dbp, hcp->page, dbp->pgsize, hcp->indx); /* * We need to maintain the duplicate cursor position. @@ -350,11 +342,10 @@ finish: if (ret == 0) { break; /* Update any other cursors */ - if (hcs != NULL && DB_LOGGING(dbc) - && IS_SUBTRANSACTION(dbc->txn)) { - if ((ret = __ham_chgpg_log(dbp->dbenv, - dbc->txn, &lsn, 0, dbp->log_fileid, - DB_HAM_DUP, PGNO(hcp->page), + if (hcs != NULL && DBC_LOGGING(dbc) && + IS_SUBTRANSACTION(dbc->txn)) { + if ((ret = __ham_chgpg_log(dbp, dbc->txn, + &lsn, 0, DB_HAM_DUP, PGNO(hcp->page), PGNO(dp), hcp->indx, i)) != 0) break; } @@ -390,7 +381,7 @@ err: if (ret == 0) hcp->dup_tlen = hcp->dup_off = hcp->dup_len = 0; if (hcs != NULL) - __os_free(dbp->dbenv, hcs, 0); + __os_free(dbp->dbenv, hcs); return (ret); } @@ -472,7 +463,7 @@ __ham_check_move(dbc, add_len) mpf = dbp->mpf; hcp = (HASH_CURSOR *)dbc->internal; - hk = H_PAIRDATA(hcp->page, hcp->indx); + hk = H_PAIRDATA(dbp, hcp->page, hcp->indx); /* * If the item is already off page duplicates or an offpage item, @@ -481,7 +472,7 @@ __ham_check_move(dbc, add_len) if (HPAGE_PTYPE(hk) == H_OFFDUP || HPAGE_PTYPE(hk) == H_OFFPAGE) return (0); - old_len = LEN_HITEM(hcp->page, dbp->pgsize, H_DATAINDEX(hcp->indx)); + old_len = LEN_HITEM(dbp, hcp->page, dbp->pgsize, H_DATAINDEX(hcp->indx)); new_datalen = old_len - HKEYDATA_SIZE(0) + add_len; if (HPAGE_PTYPE(hk) != H_DUPLICATE) new_datalen += DUP_SIZE(0); @@ -495,10 +486,10 @@ __ham_check_move(dbc, add_len) * If neither of these is true, then we can return. */ if (ISBIG(hcp, new_datalen) && (old_len > HOFFDUP_SIZE || - HOFFDUP_SIZE - old_len <= P_FREESPACE(hcp->page))) + HOFFDUP_SIZE - old_len <= P_FREESPACE(dbp, hcp->page))) return (0); - if (!ISBIG(hcp, new_datalen) && add_len <= P_FREESPACE(hcp->page)) + if (!ISBIG(hcp, new_datalen) && add_len <= P_FREESPACE(dbp, hcp->page)) return (0); /* @@ -510,7 +501,7 @@ __ham_check_move(dbc, add_len) new_datalen = ISBIG(hcp, new_datalen) ? HOFFDUP_SIZE : HKEYDATA_SIZE(new_datalen); - new_datalen += LEN_HITEM(hcp->page, dbp->pgsize, H_KEYINDEX(hcp->indx)); + new_datalen += LEN_HITEM(dbp, hcp->page, dbp->pgsize, H_KEYINDEX(hcp->indx)); next_pagep = NULL; for (next_pgno = NEXT_PGNO(hcp->page); next_pgno != PGNO_INVALID; @@ -523,7 +514,7 @@ __ham_check_move(dbc, add_len) &next_pgno, DB_MPOOL_CREATE, &next_pagep)) != 0) return (ret); - if (P_FREESPACE(next_pagep) >= new_datalen) + if (P_FREESPACE(dbp, next_pagep) >= new_datalen) break; } @@ -533,44 +524,45 @@ __ham_check_move(dbc, add_len) return (ret); /* Add new page at the end of the chain. */ - if (P_FREESPACE(next_pagep) < new_datalen && (ret = + if (P_FREESPACE(dbp, next_pagep) < new_datalen && (ret = __ham_add_ovflpage(dbc, next_pagep, 1, &next_pagep)) != 0) { (void)mpf->put(mpf, next_pagep, 0); return (ret); } /* Copy the item to the new page. */ - if (DB_LOGGING(dbc)) { + if (DBC_LOGGING(dbc)) { rectype = PUTPAIR; k.flags = 0; d.flags = 0; if (HPAGE_PTYPE( - H_PAIRKEY(hcp->page, hcp->indx)) == H_OFFPAGE) { + H_PAIRKEY(dbp, hcp->page, hcp->indx)) == H_OFFPAGE) { rectype |= PAIR_KEYMASK; - k.data = H_PAIRKEY(hcp->page, hcp->indx); + k.data = H_PAIRKEY(dbp, hcp->page, hcp->indx); k.size = HOFFPAGE_SIZE; } else { k.data = - HKEYDATA_DATA(H_PAIRKEY(hcp->page, hcp->indx)); - k.size = LEN_HKEY(hcp->page, dbp->pgsize, hcp->indx); + HKEYDATA_DATA(H_PAIRKEY(dbp, hcp->page, hcp->indx)); + k.size = + LEN_HKEY(dbp, hcp->page, dbp->pgsize, hcp->indx); } if (HPAGE_PTYPE(hk) == H_OFFPAGE) { rectype |= PAIR_DATAMASK; - d.data = H_PAIRDATA(hcp->page, hcp->indx); + d.data = H_PAIRDATA(dbp, hcp->page, hcp->indx); d.size = HOFFPAGE_SIZE; } else { - if (HPAGE_PTYPE(H_PAIRDATA(hcp->page, hcp->indx)) + if (HPAGE_PTYPE(H_PAIRDATA(dbp, hcp->page, hcp->indx)) == H_DUPLICATE) rectype |= PAIR_DUPMASK; d.data = - HKEYDATA_DATA(H_PAIRDATA(hcp->page, hcp->indx)); - d.size = LEN_HDATA(hcp->page, dbp->pgsize, hcp->indx); + HKEYDATA_DATA(H_PAIRDATA(dbp, hcp->page, hcp->indx)); + d.size = LEN_HDATA(dbp, hcp->page, + dbp->pgsize, hcp->indx); } - if ((ret = __ham_insdel_log(dbp->dbenv, - dbc->txn, &new_lsn, 0, rectype, - dbp->log_fileid, PGNO(next_pagep), + if ((ret = __ham_insdel_log(dbp, + dbc->txn, &new_lsn, 0, rectype, PGNO(next_pagep), (u_int32_t)NUM_ENT(next_pagep), &LSN(next_pagep), &k, &d)) != 0) { (void)mpf->put(mpf, next_pagep, 0); @@ -582,10 +574,8 @@ __ham_check_move(dbc, add_len) /* Move lsn onto page. */ LSN(next_pagep) = new_lsn; /* Structure assignment. */ - __ham_copy_item(dbp->pgsize, - hcp->page, H_KEYINDEX(hcp->indx), next_pagep); - __ham_copy_item(dbp->pgsize, - hcp->page, H_DATAINDEX(hcp->indx), next_pagep); + __ham_copy_item(dbp, hcp->page, H_KEYINDEX(hcp->indx), next_pagep); + __ham_copy_item(dbp, hcp->page, H_DATAINDEX(hcp->indx), next_pagep); /* * We've just manually inserted a key and set of data onto @@ -654,7 +644,7 @@ __ham_move_offpage(dbc, pagep, ndx, pgno) DBT new_dbt; DBT old_dbt; HOFFDUP od; - db_indx_t i; + db_indx_t i, *inp; int32_t shrink; u_int8_t *src; int ret; @@ -667,34 +657,34 @@ __ham_move_offpage(dbc, pagep, ndx, pgno) od.pgno = pgno; ret = 0; - if (DB_LOGGING(dbc)) { + if (DBC_LOGGING(dbc)) { new_dbt.data = &od; new_dbt.size = HOFFDUP_SIZE; - old_dbt.data = P_ENTRY(pagep, ndx); - old_dbt.size = LEN_HITEM(pagep, dbp->pgsize, ndx); - if ((ret = __ham_replace_log(dbp->dbenv, - dbc->txn, &LSN(pagep), 0, dbp->log_fileid, + old_dbt.data = P_ENTRY(dbp, pagep, ndx); + old_dbt.size = LEN_HITEM(dbp, pagep, dbp->pgsize, ndx); + if ((ret = __ham_replace_log(dbp, dbc->txn, &LSN(pagep), 0, PGNO(pagep), (u_int32_t)ndx, &LSN(pagep), -1, &old_dbt, &new_dbt, 0)) != 0) return (ret); } else LSN_NOT_LOGGED(LSN(pagep)); - shrink = LEN_HITEM(pagep, dbp->pgsize, ndx) - HOFFDUP_SIZE; + shrink = LEN_HITEM(dbp, pagep, dbp->pgsize, ndx) - HOFFDUP_SIZE; + inp = P_INP(dbp, pagep); if (shrink != 0) { /* Copy data. */ src = (u_int8_t *)(pagep) + HOFFSET(pagep); - memmove(src + shrink, src, pagep->inp[ndx] - HOFFSET(pagep)); + memmove(src + shrink, src, inp[ndx] - HOFFSET(pagep)); HOFFSET(pagep) += shrink; /* Update index table. */ for (i = ndx; i < NUM_ENT(pagep); i++) - pagep->inp[i] += shrink; + inp[i] += shrink; } /* Now copy the offdup entry onto the page. */ - memcpy(P_ENTRY(pagep, ndx), &od, HOFFDUP_SIZE); + memcpy(P_ENTRY(dbp, pagep, ndx), &od, HOFFDUP_SIZE); return (ret); } @@ -725,8 +715,8 @@ __ham_dsearch(dbc, dbt, offp, cmpp, flags) func = dbp->dup_compare == NULL ? __bam_defcmp : dbp->dup_compare; i = F_ISSET(hcp, H_CONTINUE) ? hcp->dup_off: 0; - data = HKEYDATA_DATA(H_PAIRDATA(hcp->page, hcp->indx)) + i; - hcp->dup_tlen = LEN_HDATA(hcp->page, dbp->pgsize, hcp->indx); + data = HKEYDATA_DATA(H_PAIRDATA(dbp, hcp->page, hcp->indx)) + i; + hcp->dup_tlen = LEN_HDATA(dbp, hcp->page, dbp->pgsize, hcp->indx); while (i < hcp->dup_tlen) { memcpy(&len, data, sizeof(db_indx_t)); data += sizeof(db_indx_t); @@ -794,17 +784,17 @@ __ham_dcursor(dbc, pgno, indx) u_int32_t indx; { DB *dbp; - DBC *dbc_nopd; HASH_CURSOR *hcp; BTREE_CURSOR *dcp; int ret; dbp = dbc->dbp; + hcp = (HASH_CURSOR *)dbc->internal; - if ((ret = __db_c_newopd(dbc, pgno, &dbc_nopd)) != 0) + if ((ret = __db_c_newopd(dbc, pgno, hcp->opd, &hcp->opd)) != 0) return (ret); - dcp = (BTREE_CURSOR *)dbc_nopd->internal; + dcp = (BTREE_CURSOR *)hcp->opd->internal; dcp->pgno = pgno; dcp->indx = indx; @@ -821,15 +811,11 @@ __ham_dcursor(dbc, pgno, indx) * Transfer the deleted flag from the top-level cursor to the * created one. */ - hcp = (HASH_CURSOR *)dbc->internal; if (F_ISSET(hcp, H_DELETED)) { F_SET(dcp, C_DELETED); F_CLR(hcp, H_DELETED); } - /* Stack the cursors and reset the initial cursor's index. */ - hcp->opd = dbc_nopd; - return (0); } @@ -896,10 +882,9 @@ __ham_c_chgpg(dbc, old_pgno, old_index, new_pgno, new_index) } MUTEX_THREAD_UNLOCK(dbenv, dbenv->dblist_mutexp); - if (found != 0 && DB_LOGGING(dbc)) { - if ((ret = __ham_chgpg_log(dbenv, - my_txn, &lsn, 0, dbp->log_fileid, DB_HAM_CHGPG, - old_pgno, new_pgno, old_index, new_index)) != 0) + if (found != 0 && DBC_LOGGING(dbc)) { + if ((ret = __ham_chgpg_log(dbp, my_txn, &lsn, 0, DB_HAM_CHGPG, + old_pgno, new_pgno, old_index, new_index)) != 0) return (ret); } return (0); diff --git a/db/hash/hash_page.c b/db/hash/hash_page.c index a7bc1cd1b..301e9bab5 100644 --- a/db/hash/hash_page.c +++ b/db/hash/hash_page.c @@ -1,7 +1,7 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1996-2001 + * Copyright (c) 1996-2002 * Sleepycat Software. All rights reserved. */ /* @@ -43,23 +43,14 @@ #include "db_config.h" #ifndef lint -static const char revid[] = "Id: hash_page.c,v 11.74 2001/10/20 20:10:01 bostic Exp "; +static const char revid[] = "Id: hash_page.c,v 11.85 2002/08/06 06:11:27 bostic Exp "; #endif /* not lint */ /* * PACKAGE: hashing * * DESCRIPTION: - * Page manipulation for hashing package. - * - * ROUTINES: - * - * External - * __get_page - * __add_ovflpage - * __overflow_page - * Internal - * open_temp + * Page manipulation for hashing package. */ #ifndef NO_SYSTEM_INCLUDES @@ -69,11 +60,10 @@ static const char revid[] = "Id: hash_page.c,v 11.74 2001/10/20 20:10:01 bostic #endif #include "db_int.h" -#include "db_page.h" -#include "db_shash.h" -#include "hash.h" -#include "lock.h" -#include "txn.h" +#include "dbinc/db_page.h" +#include "dbinc/db_shash.h" +#include "dbinc/hash.h" +#include "dbinc/lock.h" static int __ham_c_delpg __P((DBC *, db_pgno_t, db_pgno_t, u_int32_t, db_ham_mode, u_int32_t *)); @@ -107,15 +97,15 @@ __ham_item(dbc, mode, pgnop) recheck: /* Check if we are looking for space in which to insert an item. */ - if (hcp->seek_size && hcp->seek_found_page == PGNO_INVALID - && hcp->seek_size < P_FREESPACE(hcp->page)) + if (hcp->seek_size && hcp->seek_found_page == PGNO_INVALID && + hcp->seek_size < P_FREESPACE(dbp, hcp->page)) hcp->seek_found_page = hcp->pgno; /* Check for off-page duplicates. */ if (hcp->indx < NUM_ENT(hcp->page) && - HPAGE_TYPE(hcp->page, H_DATAINDEX(hcp->indx)) == H_OFFDUP) { + HPAGE_TYPE(dbp, hcp->page, H_DATAINDEX(hcp->indx)) == H_OFFDUP) { memcpy(pgnop, - HOFFDUP_PGNO(H_PAIRDATA(hcp->page, hcp->indx)), + HOFFDUP_PGNO(H_PAIRDATA(dbp, hcp->page, hcp->indx)), sizeof(db_pgno_t)); F_SET(hcp, H_OK); return (0); @@ -129,7 +119,7 @@ recheck: * pointer to be the beginning of the datum. */ memcpy(&hcp->dup_len, - HKEYDATA_DATA(H_PAIRDATA(hcp->page, hcp->indx)) + + HKEYDATA_DATA(H_PAIRDATA(dbp, hcp->page, hcp->indx)) + hcp->dup_off, sizeof(db_indx_t)); if (hcp->indx >= (db_indx_t)NUM_ENT(hcp->page)) { @@ -269,11 +259,13 @@ __ham_item_prev(dbc, mode, pgnop) db_lockmode_t mode; db_pgno_t *pgnop; { + DB *dbp; HASH_CURSOR *hcp; db_pgno_t next_pgno; int ret; hcp = (HASH_CURSOR *)dbc->internal; + dbp = dbc->dbp; /* * There are 5 cases for backing up in a hash file. @@ -295,9 +287,10 @@ __ham_item_prev(dbc, mode, pgnop) * to handle backing up through keys. */ if (!F_ISSET(hcp, H_NEXT_NODUP) && F_ISSET(hcp, H_ISDUP)) { - if (HPAGE_TYPE(hcp->page, H_DATAINDEX(hcp->indx)) == H_OFFDUP) { + if (HPAGE_TYPE(dbp, hcp->page, H_DATAINDEX(hcp->indx)) == + H_OFFDUP) { memcpy(pgnop, - HOFFDUP_PGNO(H_PAIRDATA(hcp->page, hcp->indx)), + HOFFDUP_PGNO(H_PAIRDATA(dbp, hcp->page, hcp->indx)), sizeof(db_pgno_t)); F_SET(hcp, H_OK); return (0); @@ -306,7 +299,7 @@ __ham_item_prev(dbc, mode, pgnop) /* Duplicates are on-page. */ if (hcp->dup_off != 0) { memcpy(&hcp->dup_len, HKEYDATA_DATA( - H_PAIRDATA(hcp->page, hcp->indx)) + H_PAIRDATA(dbp, hcp->page, hcp->indx)) + hcp->dup_off - sizeof(db_indx_t), sizeof(db_indx_t)); hcp->dup_off -= @@ -400,7 +393,7 @@ __ham_item_next(dbc, mode, pgnop) if (F_ISSET(hcp, H_DELETED)) { if (hcp->indx != NDX_INVALID && F_ISSET(hcp, H_ISDUP) && - HPAGE_TYPE(hcp->page, H_DATAINDEX(hcp->indx)) + HPAGE_TYPE(dbc->dbp, hcp->page, H_DATAINDEX(hcp->indx)) == H_DUPLICATE && hcp->dup_tlen == hcp->dup_off) { if (F_ISSET(hcp, H_DUPONLY)) { F_CLR(hcp, H_OK); @@ -451,7 +444,7 @@ __ham_item_next(dbc, mode, pgnop) } /* - * PUBLIC: void __ham_putitem __P((PAGE *p, const DBT *, int)); + * PUBLIC: void __ham_putitem __P((DB *, PAGE *p, const DBT *, int)); * * This is a little bit sleazy in that we're overloading the meaning * of the H_OFFPAGE type here. When we recover deletes, we have the @@ -460,24 +453,27 @@ __ham_item_next(dbc, mode, pgnop) * an H_KEYDATA around it. */ void -__ham_putitem(p, dbt, type) +__ham_putitem(dbp, p, dbt, type) + DB *dbp; PAGE *p; const DBT *dbt; int type; { u_int16_t n, off; + db_indx_t *inp; n = NUM_ENT(p); + inp = P_INP(dbp, p); /* Put the item element on the page. */ if (type == H_OFFPAGE) { off = HOFFSET(p) - dbt->size; - HOFFSET(p) = p->inp[n] = off; - memcpy(P_ENTRY(p, n), dbt->data, dbt->size); + HOFFSET(p) = inp[n] = off; + memcpy(P_ENTRY(dbp, p, n), dbt->data, dbt->size); } else { off = HOFFSET(p) - HKEYDATA_SIZE(dbt->size); - HOFFSET(p) = p->inp[n] = off; - PUT_HKEYDATA(P_ENTRY(p, n), dbt->data, dbt->size, type); + HOFFSET(p) = inp[n] = off; + PUT_HKEYDATA(P_ENTRY(dbp, p, n), dbt->data, dbt->size, type); } /* Adjust page info. */ @@ -485,8 +481,8 @@ __ham_putitem(p, dbt, type) } /* - * PUBLIC: void __ham_reputpair - * PUBLIC: __P((PAGE *p, u_int32_t, u_int32_t, const DBT *, const DBT *)); + * PUBLIC: void __ham_reputpair __P((DB *, PAGE *, + * PUBLIC: u_int32_t, const DBT *, const DBT *)); * * This is a special case to restore a key/data pair to its original * location during recovery. We are guaranteed that the pair fits @@ -494,17 +490,21 @@ __ham_putitem(p, dbt, type) * the last pair, the normal insert works). */ void -__ham_reputpair(p, psize, ndx, key, data) +__ham_reputpair(dbp, p, ndx, key, data) + DB *dbp; PAGE *p; - u_int32_t psize, ndx; + u_int32_t ndx; const DBT *key, *data; { - db_indx_t i, movebytes, newbytes; + db_indx_t i, *inp, movebytes, newbytes; + size_t psize; u_int8_t *from; + psize = dbp->pgsize; + inp = P_INP(dbp, p); /* First shuffle the existing items up on the page. */ - movebytes = - (ndx == 0 ? psize : p->inp[H_DATAINDEX(ndx - 2)]) - HOFFSET(p); + movebytes = (db_indx_t)( + (ndx == 0 ? psize : inp[H_DATAINDEX(ndx - 2)]) - HOFFSET(p)); newbytes = key->size + data->size; from = (u_int8_t *)p + HOFFSET(p); memmove(from - newbytes, from, movebytes); @@ -515,17 +515,17 @@ __ham_reputpair(p, psize, ndx, key, data) * we are dealing with index 0 (db_indx_t's are unsigned). */ for (i = NUM_ENT(p) - 1; ; i-- ) { - p->inp[i + 2] = p->inp[i] - newbytes; + inp[i + 2] = inp[i] - newbytes; if (i == H_KEYINDEX(ndx)) break; } /* Put the key and data on the page. */ - p->inp[H_KEYINDEX(ndx)] = - (ndx == 0 ? psize : p->inp[H_DATAINDEX(ndx - 2)]) - key->size; - p->inp[H_DATAINDEX(ndx)] = p->inp[H_KEYINDEX(ndx)] - data->size; - memcpy(P_ENTRY(p, H_KEYINDEX(ndx)), key->data, key->size); - memcpy(P_ENTRY(p, H_DATAINDEX(ndx)), data->data, data->size); + inp[H_KEYINDEX(ndx)] = (db_indx_t)( + (ndx == 0 ? psize : inp[H_DATAINDEX(ndx - 2)]) - key->size); + inp[H_DATAINDEX(ndx)] = inp[H_KEYINDEX(ndx)] - data->size; + memcpy(P_ENTRY(dbp, p, H_KEYINDEX(ndx)), key->data, key->size); + memcpy(P_ENTRY(dbp, p, H_DATAINDEX(ndx)), data->data, data->size); /* Adjust page info. */ HOFFSET(p) -= newbytes; @@ -573,17 +573,17 @@ __ham_del_pair(dbc, reclaim_page) * entry referring to the big item. */ ret = 0; - if (HPAGE_PTYPE(H_PAIRKEY(p, ndx)) == H_OFFPAGE) { - memcpy(&pgno, HOFFPAGE_PGNO(P_ENTRY(p, H_KEYINDEX(ndx))), + if (HPAGE_PTYPE(H_PAIRKEY(dbp, p, ndx)) == H_OFFPAGE) { + memcpy(&pgno, HOFFPAGE_PGNO(P_ENTRY(dbp, p, H_KEYINDEX(ndx))), sizeof(db_pgno_t)); ret = __db_doff(dbc, pgno); } if (ret == 0) - switch (HPAGE_PTYPE(H_PAIRDATA(p, ndx))) { + switch (HPAGE_PTYPE(H_PAIRDATA(dbp, p, ndx))) { case H_OFFPAGE: memcpy(&pgno, - HOFFPAGE_PGNO(P_ENTRY(p, H_DATAINDEX(ndx))), + HOFFPAGE_PGNO(P_ENTRY(dbp, p, H_DATAINDEX(ndx))), sizeof(db_pgno_t)); ret = __db_doff(dbc, pgno); break; @@ -602,15 +602,14 @@ __ham_del_pair(dbc, reclaim_page) return (ret); /* Now log the delete off this page. */ - if (DB_LOGGING(dbc)) { - key_dbt.data = P_ENTRY(p, H_KEYINDEX(ndx)); - key_dbt.size = LEN_HITEM(p, dbp->pgsize, H_KEYINDEX(ndx)); - data_dbt.data = P_ENTRY(p, H_DATAINDEX(ndx)); - data_dbt.size = LEN_HITEM(p, dbp->pgsize, H_DATAINDEX(ndx)); - - if ((ret = __ham_insdel_log(dbenv, - dbc->txn, &new_lsn, 0, DELPAIR, - dbp->log_fileid, PGNO(p), (u_int32_t)ndx, + if (DBC_LOGGING(dbc)) { + key_dbt.data = P_ENTRY(dbp, p, H_KEYINDEX(ndx)); + key_dbt.size = LEN_HITEM(dbp, p, dbp->pgsize, H_KEYINDEX(ndx)); + data_dbt.data = P_ENTRY(dbp, p, H_DATAINDEX(ndx)); + data_dbt.size = LEN_HITEM(dbp, p, dbp->pgsize, H_DATAINDEX(ndx)); + + if ((ret = __ham_insdel_log(dbp, + dbc->txn, &new_lsn, 0, DELPAIR, PGNO(p), (u_int32_t)ndx, &LSN(p), &key_dbt, &data_dbt)) != 0) return (ret); } else @@ -674,11 +673,11 @@ __ham_del_pair(dbc, reclaim_page) mpf->get(mpf, &NEXT_PGNO(n_pagep), 0, &nn_pagep)) != 0) goto err; - if (DB_LOGGING(dbc)) { + if (DBC_LOGGING(dbc)) { key_dbt.data = n_pagep; key_dbt.size = dbp->pgsize; - if ((ret = __ham_copypage_log(dbenv, - dbc->txn, &new_lsn, 0, dbp->log_fileid, PGNO(p), + if ((ret = __ham_copypage_log(dbp, + dbc->txn, &new_lsn, 0, PGNO(p), &LSN(p), PGNO(n_pagep), &LSN(n_pagep), NEXT_PGNO(n_pagep), nn_pagep == NULL ? NULL : &LSN(nn_pagep), @@ -748,10 +747,9 @@ __ham_del_pair(dbc, reclaim_page) if (n_pagep != NULL) PREV_PGNO(n_pagep) = PGNO(p_pagep); - if (DB_LOGGING(dbc)) { - if ((ret = __ham_newpage_log(dbenv, - dbc->txn, &new_lsn, 0, DELOVFL, - dbp->log_fileid, PREV_PGNO(p), &LSN(p_pagep), + if (DBC_LOGGING(dbc)) { + if ((ret = __ham_newpage_log(dbp, dbc->txn, + &new_lsn, 0, DELOVFL, PREV_PGNO(p), &LSN(p_pagep), PGNO(p), &LSN(p), NEXT_PGNO(p), n_lsn)) != 0) goto err; } else @@ -866,20 +864,21 @@ __ham_replpair(dbc, dbt, make_dup) */ change = dbt->size - dbt->dlen; - hk = H_PAIRDATA(hcp->page, hcp->indx); + hk = H_PAIRDATA(dbp, hcp->page, hcp->indx); is_big = HPAGE_PTYPE(hk) == H_OFFPAGE; if (is_big) memcpy(&len, HOFFPAGE_TLEN(hk), sizeof(u_int32_t)); else - len = LEN_HKEYDATA(hcp->page, + len = LEN_HKEYDATA(dbp, hcp->page, dbp->pgsize, H_DATAINDEX(hcp->indx)); beyond_eor = dbt->doff + dbt->dlen > len; if (beyond_eor) change += dbt->doff + dbt->dlen - len; - if (change > (int32_t)P_FREESPACE(hcp->page) || beyond_eor || is_big) { + if (change > (int32_t)P_FREESPACE(dbp, hcp->page) || + beyond_eor || is_big) { /* * Case 3 -- two subcases. * A. This is not really a partial operation, but an overwrite. @@ -917,14 +916,14 @@ __ham_replpair(dbc, dbt, make_dup) /* Now we can delete the item. */ if ((ret = __ham_del_pair(dbc, 0)) != 0) { - __os_free(dbp->dbenv, memp, memsize); + __os_free(dbp->dbenv, memp); goto err; } /* Now shift old data around to make room for new. */ if (change > 0) { - if ((ret = __os_realloc(dbp->dbenv, - tdata.size + change, &tdata.data)) != 0) + if ((ret = __os_realloc(dbp->dbenv, + tdata.size + change, &tdata.data)) != 0) return (ret); memp = tdata.data; memsize = tdata.size + change; @@ -945,7 +944,7 @@ __ham_replpair(dbc, dbt, make_dup) /* Now add the pair. */ ret = __ham_add_el(dbc, &tmp, &tdata, type); - __os_free(dbp->dbenv, memp, memsize); + __os_free(dbp->dbenv, memp); } F_SET(hcp, dup_flag); err: return (ret); @@ -955,7 +954,7 @@ err: return (ret); * Set up pointer into existing data. Do it before the log * message so we can use it inside of the log setup. */ - beg = HKEYDATA_DATA(H_PAIRDATA(hcp->page, hcp->indx)); + beg = HKEYDATA_DATA(H_PAIRDATA(dbp, hcp->page, hcp->indx)); beg += dbt->doff; /* @@ -963,11 +962,11 @@ err: return (ret); * all the parameters here. Then log the call before moving * anything around. */ - if (DB_LOGGING(dbc)) { + if (DBC_LOGGING(dbc)) { old_dbt.data = beg; old_dbt.size = dbt->dlen; - if ((ret = __ham_replace_log(dbp->dbenv, - dbc->txn, &new_lsn, 0, dbp->log_fileid, PGNO(hcp->page), + if ((ret = __ham_replace_log(dbp, + dbc->txn, &new_lsn, 0, PGNO(hcp->page), (u_int32_t)H_DATAINDEX(hcp->indx), &LSN(hcp->page), (u_int32_t)dbt->doff, &old_dbt, dbt, make_dup)) != 0) return (ret); @@ -977,8 +976,8 @@ err: return (ret); LSN(hcp->page) = new_lsn; /* Structure assignment. */ - __ham_onpage_replace(hcp->page, dbp->pgsize, - (u_int32_t)H_DATAINDEX(hcp->indx), (int32_t)dbt->doff, change, dbt); + __ham_onpage_replace(dbp, hcp->page, (u_int32_t)H_DATAINDEX(hcp->indx), + (int32_t)dbt->doff, change, dbt); return (0); } @@ -994,34 +993,41 @@ err: return (ret); * off: Offset at which we are beginning the replacement. * change: the number of bytes (+ or -) that the element is growing/shrinking. * dbt: the new data that gets written at beg. - * PUBLIC: void __ham_onpage_replace __P((PAGE *, size_t, u_int32_t, int32_t, - * PUBLIC: int32_t, DBT *)); + * + * PUBLIC: void __ham_onpage_replace __P((DB *, PAGE *, u_int32_t, + * PUBLIC: int32_t, int32_t, DBT *)); */ void -__ham_onpage_replace(pagep, pgsize, ndx, off, change, dbt) +__ham_onpage_replace(dbp, pagep, ndx, off, change, dbt) + DB *dbp; PAGE *pagep; - size_t pgsize; u_int32_t ndx; int32_t off; int32_t change; DBT *dbt; { - db_indx_t i; + db_indx_t i, *inp; int32_t len; + size_t pgsize; u_int8_t *src, *dest; int zero_me; + pgsize = dbp->pgsize; + inp = P_INP(dbp, pagep); if (change != 0) { zero_me = 0; src = (u_int8_t *)(pagep) + HOFFSET(pagep); if (off < 0) - len = pagep->inp[ndx] - HOFFSET(pagep); - else if ((u_int32_t)off >= LEN_HKEYDATA(pagep, pgsize, ndx)) { - len = HKEYDATA_DATA(P_ENTRY(pagep, ndx)) + - LEN_HKEYDATA(pagep, pgsize, ndx) - src; + len = inp[ndx] - HOFFSET(pagep); + else if ((u_int32_t)off >= + LEN_HKEYDATA(dbp, pagep, pgsize, ndx)) { + len = (int32_t)(HKEYDATA_DATA(P_ENTRY(dbp, pagep, ndx)) + + LEN_HKEYDATA(dbp, pagep, pgsize, ndx) - src); zero_me = 1; } else - len = (HKEYDATA_DATA(P_ENTRY(pagep, ndx)) + off) - src; + len = (int32_t)( + (HKEYDATA_DATA(P_ENTRY(dbp, pagep, ndx)) + off) - + src); dest = src - change; memmove(dest, src, len); if (zero_me) @@ -1029,14 +1035,14 @@ __ham_onpage_replace(pagep, pgsize, ndx, off, change, dbt) /* Now update the indices. */ for (i = ndx; i < NUM_ENT(pagep); i++) - pagep->inp[i] -= change; + inp[i] -= change; HOFFSET(pagep) -= change; } if (off >= 0) - memcpy(HKEYDATA_DATA(P_ENTRY(pagep, ndx)) + off, + memcpy(HKEYDATA_DATA(P_ENTRY(dbp, pagep, ndx)) + off, dbt->data, dbt->size); else - memcpy(P_ENTRY(pagep, ndx), dbt->data, dbt->size); + memcpy(P_ENTRY(dbp, pagep, ndx), dbt->data, dbt->size); } /* @@ -1088,11 +1094,11 @@ __ham_split_page(dbc, obucket, nbucket) temp_pagep = hcp->split_buf; memcpy(temp_pagep, old_pagep, dbp->pgsize); - if (DB_LOGGING(dbc)) { + if (DBC_LOGGING(dbc)) { page_dbt.size = dbp->pgsize; page_dbt.data = old_pagep; - if ((ret = __ham_splitdata_log(dbenv, - dbc->txn, &new_lsn, 0, dbp->log_fileid, SPLITOLD, + if ((ret = __ham_splitdata_log(dbp, + dbc->txn, &new_lsn, 0, SPLITOLD, PGNO(old_pagep), &page_dbt, &LSN(old_pagep))) != 0) goto err; } else @@ -1125,19 +1131,18 @@ __ham_split_page(dbc, obucket, nbucket) * Figure out how many bytes we need on the new * page to store the key/data pair. */ - len = LEN_HITEM(temp_pagep, dbp->pgsize, + len = LEN_HITEM(dbp, temp_pagep, dbp->pgsize, H_DATAINDEX(n)) + - LEN_HITEM(temp_pagep, dbp->pgsize, + LEN_HITEM(dbp, temp_pagep, dbp->pgsize, H_KEYINDEX(n)) + 2 * sizeof(db_indx_t); - if (P_FREESPACE(*pp) < len) { - if (DB_LOGGING(dbc)) { + if (P_FREESPACE(dbp, *pp) < len) { + if (DBC_LOGGING(dbc)) { page_dbt.size = dbp->pgsize; page_dbt.data = *pp; - if ((ret = __ham_splitdata_log( - dbenv, dbc->txn, - &new_lsn, 0, dbp->log_fileid, + if ((ret = __ham_splitdata_log(dbp, + dbc->txn, &new_lsn, 0, SPLITNEW, PGNO(*pp), &page_dbt, &LSN(*pp))) != 0) goto err; @@ -1155,28 +1160,25 @@ __ham_split_page(dbc, obucket, nbucket) for (i = 0; carray[i] != NULL; i++) { cp = (HASH_CURSOR *)carray[i]->internal; - if (cp->pgno == PGNO(temp_pagep) - && cp->indx == n) { + if (cp->pgno == PGNO(temp_pagep) && + cp->indx == n) { cp->pgno = PGNO(*pp); cp->indx = NUM_ENT(*pp); found = 1; } } - if (found && DB_LOGGING(dbc) - && IS_SUBTRANSACTION(dbc->txn)) { + if (found && DBC_LOGGING(dbc) && + IS_SUBTRANSACTION(dbc->txn)) { if ((ret = - __ham_chgpg_log(dbp->dbenv, + __ham_chgpg_log(dbp, dbc->txn, &new_lsn, 0, - dbp->log_fileid, DB_HAM_SPLIT, PGNO(temp_pagep), PGNO(*pp), n, NUM_ENT(*pp))) != 0) goto err; } } - __ham_copy_item(dbp->pgsize, - temp_pagep, H_KEYINDEX(n), *pp); - __ham_copy_item(dbp->pgsize, - temp_pagep, H_DATAINDEX(n), *pp); + __ham_copy_item(dbp, temp_pagep, H_KEYINDEX(n), *pp); + __ham_copy_item(dbp, temp_pagep, H_DATAINDEX(n), *pp); } next_pgno = NEXT_PGNO(temp_pagep); @@ -1194,11 +1196,11 @@ __ham_split_page(dbc, obucket, nbucket) goto err; if (temp_pagep != NULL) { - if (DB_LOGGING(dbc)) { + if (DBC_LOGGING(dbc)) { page_dbt.size = dbp->pgsize; page_dbt.data = temp_pagep; - if ((ret = __ham_splitdata_log(dbenv, - dbc->txn, &new_lsn, 0, dbp->log_fileid, + if ((ret = __ham_splitdata_log(dbp, + dbc->txn, &new_lsn, 0, SPLITOLD, PGNO(temp_pagep), &page_dbt, &LSN(temp_pagep))) != 0) goto err; @@ -1208,11 +1210,11 @@ __ham_split_page(dbc, obucket, nbucket) } if (carray != NULL) /* We never knew its size. */ - __os_free(dbp->dbenv, carray, 0); + __os_free(dbp->dbenv, carray); carray = NULL; } if (big_buf != NULL) - __os_free(dbenv, big_buf, big_len); + __os_free(dbenv, big_buf); /* * If the original bucket spanned multiple pages, then we've got @@ -1228,18 +1230,18 @@ __ham_split_page(dbc, obucket, nbucket) /* * Write new buckets out. */ - if (DB_LOGGING(dbc)) { + if (DBC_LOGGING(dbc)) { page_dbt.size = dbp->pgsize; page_dbt.data = old_pagep; - if ((ret = __ham_splitdata_log(dbenv, dbc->txn, &new_lsn, 0, - dbp->log_fileid, SPLITNEW, PGNO(old_pagep), &page_dbt, + if ((ret = __ham_splitdata_log(dbp, dbc->txn, + &new_lsn, 0, SPLITNEW, PGNO(old_pagep), &page_dbt, &LSN(old_pagep))) != 0) goto err; LSN(old_pagep) = new_lsn; page_dbt.data = new_pagep; - if ((ret = __ham_splitdata_log(dbenv, dbc->txn, &new_lsn, 0, - dbp->log_fileid, SPLITNEW, PGNO(new_pagep), &page_dbt, + if ((ret = __ham_splitdata_log(dbp, dbc->txn, &new_lsn, 0, + SPLITNEW, PGNO(new_pagep), &page_dbt, &LSN(new_pagep))) != 0) goto err; LSN(new_pagep) = new_lsn; @@ -1264,7 +1266,7 @@ err: if (old_pagep != NULL) if (LOCK_ISSET(block)) __TLPUT(dbc, block); if (carray != NULL) /* We never knew its size. */ - __os_free(dbp->dbenv, carray, 0); + __os_free(dbp->dbenv, carray); return (ret); } @@ -1324,7 +1326,7 @@ __ham_add_el(dbc, key, val, type) * anyway. Check if it's a bigpair that fits or a regular * pair that fits. */ - if (P_FREESPACE(hcp->page) >= pairsize) + if (P_FREESPACE(dbp, hcp->page) >= pairsize) break; next_pgno = NEXT_PGNO(hcp->page); if ((ret = __ham_next_cpage(dbc, next_pgno, 0)) != 0) @@ -1334,7 +1336,7 @@ __ham_add_el(dbc, key, val, type) /* * Check if we need to allocate a new page. */ - if (P_FREESPACE(hcp->page) < pairsize) { + if (P_FREESPACE(dbp, hcp->page) < pairsize) { do_expand = 1; if ((ret = __ham_add_ovflpage(dbc, (PAGE *)hcp->page, 1, (PAGE **)&hcp->page)) != 0) @@ -1381,7 +1383,7 @@ __ham_add_el(dbc, key, val, type) data_type = type; } - if (DB_LOGGING(dbc)) { + if (DBC_LOGGING(dbc)) { rectype = PUTPAIR; if (is_databig) rectype |= PAIR_DATAMASK; @@ -1390,10 +1392,9 @@ __ham_add_el(dbc, key, val, type) if (type == H_DUPLICATE) rectype |= PAIR_DUPMASK; - if ((ret = __ham_insdel_log(dbp->dbenv, dbc->txn, &new_lsn, 0, - rectype, dbp->log_fileid, PGNO(hcp->page), - (u_int32_t)NUM_ENT(hcp->page), &LSN(hcp->page), pkey, - pdata)) != 0) + if ((ret = __ham_insdel_log(dbp, dbc->txn, &new_lsn, 0, + rectype, PGNO(hcp->page), (u_int32_t)NUM_ENT(hcp->page), + &LSN(hcp->page), pkey, pdata)) != 0) return (ret); } else LSN_NOT_LOGGED(new_lsn); @@ -1401,8 +1402,8 @@ __ham_add_el(dbc, key, val, type) /* Move lsn onto page. */ LSN(hcp->page) = new_lsn; /* Structure assignment. */ - __ham_putitem(hcp->page, pkey, key_type); - __ham_putitem(hcp->page, pdata, data_type); + __ham_putitem(dbp, hcp->page, pkey, key_type); + __ham_putitem(dbp, hcp->page, pdata, data_type); /* * For splits, we are going to update item_info's page number @@ -1435,28 +1436,32 @@ __ham_add_el(dbc, key, val, type) * H_DUPLICATE, H_OFFDUP). Since we log splits at a high level, we * do not need to do any logging here. * - * PUBLIC: void __ham_copy_item __P((size_t, PAGE *, u_int32_t, PAGE *)); + * PUBLIC: void __ham_copy_item __P((DB *, PAGE *, u_int32_t, PAGE *)); */ void -__ham_copy_item(pgsize, src_page, src_ndx, dest_page) - size_t pgsize; +__ham_copy_item(dbp, src_page, src_ndx, dest_page) + DB *dbp; PAGE *src_page; u_int32_t src_ndx; PAGE *dest_page; { u_int32_t len; + size_t pgsize; void *src, *dest; + db_indx_t *inp; + pgsize = dbp->pgsize; + inp = P_INP(dbp, dest_page); /* * Copy the key and data entries onto this new page. */ - src = P_ENTRY(src_page, src_ndx); + src = P_ENTRY(dbp, src_page, src_ndx); /* Set up space on dest. */ - len = LEN_HITEM(src_page, pgsize, src_ndx); + len = (u_int32_t)LEN_HITEM(dbp, src_page, pgsize, src_ndx); HOFFSET(dest_page) -= len; - dest_page->inp[NUM_ENT(dest_page)] = HOFFSET(dest_page); - dest = P_ENTRY(dest_page, NUM_ENT(dest_page)); + inp[NUM_ENT(dest_page)] = HOFFSET(dest_page); + dest = P_ENTRY(dbp, dest_page, NUM_ENT(dest_page)); NUM_ENT(dest_page)++; memcpy(dest, src, len); @@ -1465,8 +1470,8 @@ __ham_copy_item(pgsize, src_page, src_ndx, dest_page) /* * * Returns: - * pointer on success - * NULL on error + * pointer on success + * NULL on error * * PUBLIC: int __ham_add_ovflpage __P((DBC *, PAGE *, int, PAGE **)); */ @@ -1489,9 +1494,9 @@ __ham_add_ovflpage(dbc, pagep, release, pp) if ((ret = __db_new(dbc, P_HASH, &new_pagep)) != 0) return (ret); - if (DB_LOGGING(dbc)) { - if ((ret = __ham_newpage_log(dbp->dbenv, dbc->txn, &new_lsn, 0, - PUTOVFL, dbp->log_fileid, PGNO(pagep), &LSN(pagep), + if (DBC_LOGGING(dbc)) { + if ((ret = __ham_newpage_log(dbp, dbc->txn, &new_lsn, 0, + PUTOVFL, PGNO(pagep), &LSN(pagep), PGNO(new_pagep), &LSN(new_pagep), PGNO_INVALID, NULL)) != 0) return (ret); } else @@ -1668,15 +1673,16 @@ __ham_dpair(dbp, p, indx) PAGE *p; u_int32_t indx; { - db_indx_t delta, n; + db_indx_t delta, n, *inp; u_int8_t *dest, *src; + inp = P_INP(dbp, p); /* * Compute "delta", the amount we have to shift all of the * offsets. To find the delta, we just need to calculate * the size of the pair of elements we are removing. */ - delta = H_PAIRSIZE(p, dbp->pgsize, indx); + delta = H_PAIRSIZE(dbp, p, dbp->pgsize, indx); /* * The hard case: we want to remove something other than @@ -1695,7 +1701,7 @@ __ham_dpair(dbp, p, indx) * be an overlapping copy, so we have to use memmove. */ dest = src + delta; - memmove(dest, src, p->inp[H_DATAINDEX(indx)] - HOFFSET(p)); + memmove(dest, src, inp[H_DATAINDEX(indx)] - HOFFSET(p)); } /* Adjust page metadata. */ @@ -1704,7 +1710,7 @@ __ham_dpair(dbp, p, indx) /* Adjust the offsets. */ for (n = (db_indx_t)indx; n < (db_indx_t)(NUM_ENT(p)); n++) - p->inp[n] = p->inp[n + 2] + delta; + inp[n] = inp[n + 2] + delta; } @@ -1846,13 +1852,11 @@ __ham_c_delpg(dbc, old_pgno, new_pgno, num_ent, op, orderp) } MUTEX_THREAD_UNLOCK(dbenv, dbenv->dblist_mutexp); - if (found != 0 && DB_LOGGING(dbc)) { - if ((ret = __ham_chgpg_log(dbenv, - my_txn, &lsn, 0, dbp->log_fileid, op, - old_pgno, new_pgno, indx, order)) != 0) + if (found != 0 && DBC_LOGGING(dbc)) { + if ((ret = __ham_chgpg_log(dbp, my_txn, &lsn, 0, op, + old_pgno, new_pgno, indx, order)) != 0) return (ret); } *orderp = order; return (0); } - diff --git a/db/hash/hash_verify.c b/db/hash/hash_verify.c index f0d45335d..de1b9e9c5 100644 --- a/db/hash/hash_verify.c +++ b/db/hash/hash_verify.c @@ -1,16 +1,16 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1999-2001 + * Copyright (c) 1999-2002 * Sleepycat Software. All rights reserved. * - * Id: hash_verify.c,v 1.41 2001/07/25 21:59:31 krinsky Exp + * $Id: hash_verify.c,v 1.53 2002/08/06 05:35:02 bostic Exp $ */ #include "db_config.h" #ifndef lint -static const char revid[] = "Id: hash_verify.c,v 1.41 2001/07/25 21:59:31 krinsky Exp "; +static const char revid[] = "Id: hash_verify.c,v 1.53 2002/08/06 05:35:02 bostic Exp "; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -20,10 +20,10 @@ static const char revid[] = "Id: hash_verify.c,v 1.41 2001/07/25 21:59:31 krinsk #endif #include "db_int.h" -#include "db_page.h" -#include "db_verify.h" -#include "btree.h" -#include "hash.h" +#include "dbinc/db_page.h" +#include "dbinc/db_verify.h" +#include "dbinc/btree.h" +#include "dbinc/hash.h" static int __ham_dups_unsorted __P((DB *, u_int8_t *, u_int32_t)); static int __ham_vrfy_bucket __P((DB *, VRFY_DBINFO *, HMETA *, u_int32_t, @@ -83,8 +83,8 @@ __ham_vrfy_meta(dbp, vdp, m, pgno, flags) if (!LF_ISSET(DB_NOORDERCHK)) if (m->h_charkey != hfunc(dbp, CHARKEY, sizeof(CHARKEY))) { EPRINT((dbp->dbenv, -"Database has different custom hash function; reverify with DB_NOORDERCHK set" - )); +"Page %lu: database has different custom hash function; reverify with DB_NOORDERCHK set", + (u_long)pgno)); /* * Return immediately; this is probably a sign * of user error rather than database corruption, so @@ -97,8 +97,8 @@ __ham_vrfy_meta(dbp, vdp, m, pgno, flags) /* max_bucket must be less than the last pgno. */ if (m->max_bucket > vdp->last_pgno) { EPRINT((dbp->dbenv, - "Impossible max_bucket %lu on meta page %lu", - (u_long)m->max_bucket, (u_long)pgno)); + "Page %lu: Impossible max_bucket %lu on meta page", + (u_long)pgno, (u_long)m->max_bucket)); /* * Most other fields depend somehow on max_bucket, so * we just return--there will be lots of extraneous @@ -118,15 +118,15 @@ __ham_vrfy_meta(dbp, vdp, m, pgno, flags) pwr = (m->max_bucket == 0) ? 1 : 1 << __db_log2(m->max_bucket + 1); if (m->high_mask != pwr - 1) { EPRINT((dbp->dbenv, - "Incorrect high_mask %lu on page %lu, should be %lu", - (u_long)m->high_mask, (u_long)pgno, (u_long)pwr - 1)); + "Page %lu: incorrect high_mask %lu, should be %lu", + (u_long)pgno, (u_long)m->high_mask, (u_long)pwr - 1)); isbad = 1; } pwr >>= 1; if (m->low_mask != pwr - 1) { EPRINT((dbp->dbenv, - "Incorrect low_mask %lu on page %lu, should be %lu", - (u_long)m->low_mask, (u_long)pgno, (u_long)pwr - 1)); + "Page %lu: incorrect low_mask %lu, should be %lu", + (u_long)pgno, (u_long)m->low_mask, (u_long)pwr - 1)); isbad = 1; } @@ -140,8 +140,8 @@ __ham_vrfy_meta(dbp, vdp, m, pgno, flags) */ if (m->nelem > 0x80000000) { EPRINT((dbp->dbenv, - "Suspiciously high nelem of %lu on page %lu", - (u_long)m->nelem, (u_long)pgno)); + "Page %lu: suspiciously high nelem of %lu", + (u_long)pgno, (u_long)m->nelem)); isbad = 1; pip->h_nelem = 0; } else @@ -164,8 +164,8 @@ __ham_vrfy_meta(dbp, vdp, m, pgno, flags) mbucket = (1 << i) - 1; if (BS_TO_PAGE(mbucket, m->spares) > vdp->last_pgno) { EPRINT((dbp->dbenv, - "Spares array entry %d, page %lu is invalid", - i, (u_long)pgno)); + "Page %lu: spares array entry %d is invalid", + (u_long)pgno, i)); isbad = 1; } } @@ -193,6 +193,7 @@ __ham_vrfy(dbp, vdp, h, pgno, flags) { VRFY_PAGEINFO *pip; u_int32_t ent, himark, inpend; + db_indx_t *inp; int isbad, ret, t_ret; isbad = 0; @@ -227,24 +228,25 @@ __ham_vrfy(dbp, vdp, h, pgno, flags) * In any case, we return immediately if things are bad, as it would * be unsafe to proceed. */ + inp = P_INP(dbp, h); for (ent = 0, himark = dbp->pgsize, - inpend = (u_int8_t *)h->inp - (u_int8_t *)h; + inpend = (u_int32_t)((u_int8_t *)inp - (u_int8_t *)h); ent < NUM_ENT(h); ent++) - if (h->inp[ent] >= himark) { + if (inp[ent] >= himark) { EPRINT((dbp->dbenv, - "Item %lu on page %lu out of order or nonsensical", - (u_long)ent, (u_long)pgno)); + "Page %lu: item %lu is out of order or nonsensical", + (u_long)pgno, (u_long)ent)); isbad = 1; goto err; } else if (inpend >= himark) { EPRINT((dbp->dbenv, - "inp array collided with data on page %lu", + "Page %lu: entries array collided with data", (u_long)pgno)); isbad = 1; goto err; } else { - himark = h->inp[ent]; + himark = inp[ent]; inpend += sizeof(db_indx_t); if ((ret = __ham_vrfy_item( dbp, vdp, pgno, h, ent, flags)) != 0) @@ -281,7 +283,7 @@ __ham_vrfy_item(dbp, vdp, pgno, h, i, flags) if ((ret = __db_vrfy_getpageinfo(vdp, pgno, &pip)) != 0) return (ret); - switch (HPAGE_TYPE(h, i)) { + switch (HPAGE_TYPE(dbp, h, i)) { case H_KEYDATA: /* Nothing to do here--everything but the type field is data */ break; @@ -289,7 +291,7 @@ __ham_vrfy_item(dbp, vdp, pgno, h, i, flags) /* Are we a datum or a key? Better be the former. */ if (i % 2 == 0) { EPRINT((dbp->dbenv, - "Hash key stored as duplicate at page %lu item %lu", + "Page %lu: hash key stored as duplicate item %lu", (u_long)pip->pgno, (u_long)i)); } /* @@ -302,16 +304,16 @@ __ham_vrfy_item(dbp, vdp, pgno, h, i, flags) * Note that at this point, we've verified item i-1, so * it's safe to use LEN_HKEYDATA (which looks at inp[i-1]). */ - len = LEN_HKEYDATA(h, dbp->pgsize, i); - databuf = HKEYDATA_DATA(P_ENTRY(h, i)); + len = LEN_HKEYDATA(dbp, h, dbp->pgsize, i); + databuf = HKEYDATA_DATA(P_ENTRY(dbp, h, i)); for (offset = 0; offset < len; offset += DUP_SIZE(dlen)) { memcpy(&dlen, databuf + offset, sizeof(db_indx_t)); /* Make sure the length is plausible. */ if (offset + DUP_SIZE(dlen) > len) { EPRINT((dbp->dbenv, - "Duplicate item %lu, page %lu has bad length", - (u_long)i, (u_long)pip->pgno)); + "Page %lu: duplicate item %lu has bad length", + (u_long)pip->pgno, (u_long)i)); ret = DB_VERIFY_BAD; goto err; } @@ -325,8 +327,8 @@ __ham_vrfy_item(dbp, vdp, pgno, h, i, flags) sizeof(db_indx_t)); if (elen != dlen) { EPRINT((dbp->dbenv, - "Duplicate item %lu, page %lu has two different lengths", - (u_long)i, (u_long)pip->pgno)); + "Page %lu: duplicate item %lu has two different lengths", + (u_long)pip->pgno, (u_long)i)); ret = DB_VERIFY_BAD; goto err; } @@ -338,12 +340,12 @@ __ham_vrfy_item(dbp, vdp, pgno, h, i, flags) break; case H_OFFPAGE: /* Offpage item. Make sure pgno is sane, save off. */ - memcpy(&hop, P_ENTRY(h, i), HOFFPAGE_SIZE); + memcpy(&hop, P_ENTRY(dbp, h, i), HOFFPAGE_SIZE); if (!IS_VALID_PGNO(hop.pgno) || hop.pgno == pip->pgno || hop.pgno == PGNO_INVALID) { EPRINT((dbp->dbenv, - "Offpage item %lu, page %lu has bad pgno %lu", - (u_long)i, (u_long)pip->pgno, (u_long)hop.pgno)); + "Page %lu: offpage item %lu has bad pgno %lu", + (u_long)pip->pgno, (u_long)i, (u_long)hop.pgno)); ret = DB_VERIFY_BAD; goto err; } @@ -356,12 +358,12 @@ __ham_vrfy_item(dbp, vdp, pgno, h, i, flags) break; case H_OFFDUP: /* Offpage duplicate item. Same drill. */ - memcpy(&hod, P_ENTRY(h, i), HOFFDUP_SIZE); + memcpy(&hod, P_ENTRY(dbp, h, i), HOFFDUP_SIZE); if (!IS_VALID_PGNO(hod.pgno) || hod.pgno == pip->pgno || hod.pgno == PGNO_INVALID) { EPRINT((dbp->dbenv, - "Offpage item %lu, page %lu has bad page number", - (u_long)i, (u_long)pip->pgno)); + "Page %lu: offpage item %lu has bad page number", + (u_long)pip->pgno, (u_long)i)); ret = DB_VERIFY_BAD; goto err; } @@ -374,8 +376,8 @@ __ham_vrfy_item(dbp, vdp, pgno, h, i, flags) break; default: EPRINT((dbp->dbenv, - "Item %i, page %lu has bad type", - (u_long)i, (u_long)pip->pgno)); + "Page %lu: item %i has bad type", + (u_long)pip->pgno, (u_long)i)); ret = DB_VERIFY_BAD; break; } @@ -418,7 +420,8 @@ __ham_vrfy_structure(dbp, vdp, meta_pgno, flags) return (ret); if (p != 0) { EPRINT((dbp->dbenv, - "Hash meta page %lu referenced twice", (u_long)meta_pgno)); + "Page %lu: Hash meta page referenced twice", + (u_long)meta_pgno)); return (DB_VERIFY_BAD); } if ((ret = __db_vrfy_pgset_inc(pgset, meta_pgno)) != 0) @@ -460,14 +463,22 @@ __ham_vrfy_structure(dbp, vdp, meta_pgno, flags) /* It's okay if these pages are totally zeroed; unmark it. */ F_CLR(pip, VRFY_IS_ALLZEROES); + /* It's also OK if this page is simply invalid. */ + if (pip->type == P_INVALID) { + if ((ret = __db_vrfy_putpageinfo(dbp->dbenv, + vdp, pip)) != 0) + goto err; + continue; + } + if (pip->type != P_HASH) { EPRINT((dbp->dbenv, - "Hash bucket %lu maps to non-hash page %lu", - (u_long)bucket, (u_long)pgno)); + "Page %lu: hash bucket %lu maps to non-hash page", + (u_long)pgno, (u_long)bucket)); isbad = 1; } else if (pip->entries != 0) { EPRINT((dbp->dbenv, - "Non-empty page %lu in unused hash bucket %lu", + "Page %lu: non-empty page in unused hash bucket %lu", (u_long)pgno, (u_long)bucket)); isbad = 1; } else { @@ -475,7 +486,7 @@ __ham_vrfy_structure(dbp, vdp, meta_pgno, flags) goto err; if (p != 0) { EPRINT((dbp->dbenv, - "Hash page %lu above max_bucket referenced", + "Page %lu: above max_bucket referenced", (u_long)pgno)); isbad = 1; } else { @@ -541,8 +552,9 @@ __ham_vrfy_bucket(dbp, vdp, m, bucket, flags) /* Make sure we got a plausible page number. */ if (pgno > vdp->last_pgno || pip->type != P_HASH) { - EPRINT((dbp->dbenv, "Bucket %lu has impossible first page %lu", - (u_long)bucket, (u_long)pgno)); + EPRINT((dbp->dbenv, + "Page %lu: impossible first page in bucket %lu", + (u_long)pgno, (u_long)bucket)); /* Unsafe to continue. */ isbad = 1; goto err; @@ -550,8 +562,8 @@ __ham_vrfy_bucket(dbp, vdp, m, bucket, flags) if (pip->prev_pgno != PGNO_INVALID) { EPRINT((dbp->dbenv, - "First hash page %lu in bucket %lu has a prev_pgno", - (u_long)pgno)); + "Page %lu: first page in hash bucket %lu has a prev_pgno", + (u_long)pgno, (u_long)bucket)); isbad = 1; } @@ -571,7 +583,8 @@ __ham_vrfy_bucket(dbp, vdp, m, bucket, flags) goto err; if (p != 0) { EPRINT((dbp->dbenv, - "Hash page %lu referenced twice", (u_long)pgno)); + "Page %lu: hash page referenced twice", + (u_long)pgno)); isbad = 1; /* Unsafe to continue. */ goto err; @@ -591,10 +604,10 @@ __ham_vrfy_bucket(dbp, vdp, m, bucket, flags) F_CLR(pip, VRFY_IS_ALLZEROES); /* If we have dups, our meta page had better know about it. */ - if (F_ISSET(pip, VRFY_HAS_DUPS) - && !F_ISSET(mip, VRFY_HAS_DUPS)) { + if (F_ISSET(pip, VRFY_HAS_DUPS) && + !F_ISSET(mip, VRFY_HAS_DUPS)) { EPRINT((dbp->dbenv, - "Duplicates present in non-duplicate database, page %lu", + "Page %lu: duplicates present in non-duplicate database", (u_long)pgno)); isbad = 1; } @@ -606,7 +619,7 @@ __ham_vrfy_bucket(dbp, vdp, m, bucket, flags) if (F_ISSET(mip, VRFY_HAS_DUPSORT) && F_ISSET(pip, VRFY_DUPS_UNSORTED)) { EPRINT((dbp->dbenv, - "Unsorted dups in sorted-dup database, page %lu", + "Page %lu: unsorted dups in sorted-dup database", (u_long)pgno)); isbad = 1; } @@ -632,8 +645,8 @@ __ham_vrfy_bucket(dbp, vdp, m, bucket, flags) } if ((ret = __bam_vrfy_subtree(dbp, vdp, child->pgno, NULL, NULL, - flags | ST_RECNUM | ST_DUPSET, NULL, - NULL, NULL)) != 0) { + flags | ST_RECNUM | ST_DUPSET | ST_TOPLEVEL, + NULL, NULL, NULL)) != 0) { if (ret == DB_VERIFY_BAD) isbad = 1; else @@ -668,7 +681,8 @@ __ham_vrfy_bucket(dbp, vdp, m, bucket, flags) if (!IS_VALID_PGNO(next_pgno)) { DB_ASSERT(0); EPRINT((dbp->dbenv, - "Hash page %lu has bad next_pgno", (u_long)pgno)); + "Page %lu: hash page has bad next_pgno", + (u_long)pgno)); isbad = 1; goto err; } @@ -677,7 +691,8 @@ __ham_vrfy_bucket(dbp, vdp, m, bucket, flags) goto err; if (pip->prev_pgno != pgno) { - EPRINT((dbp->dbenv, "Hash page %lu has bad prev_pgno", + EPRINT((dbp->dbenv, + "Page %lu: hash page has bad prev_pgno", (u_long)next_pgno)); isbad = 1; } @@ -748,14 +763,14 @@ __ham_vrfy_hashing(dbp, nentries, m, thisbucket, pgno, flags, hfunc) if (bucket != thisbucket) { EPRINT((dbp->dbenv, - "Item %lu on page %lu hashes incorrectly", - (u_long)i, (u_long)pgno)); + "Page %lu: item %lu hashes incorrectly", + (u_long)pgno, (u_long)i)); isbad = 1; } } err: if (dbt.data != NULL) - __os_free(dbp->dbenv, dbt.data, 0); + __os_ufree(dbp->dbenv, dbt.data); if ((t_ret = mpf->put(mpf, h, 0)) != 0) return (t_ret); @@ -792,7 +807,7 @@ __ham_salvage(dbp, vdp, pgno, h, handle, callback, flags) dbt.flags = DB_DBT_REALLOC; memset(&unkdbt, 0, sizeof(DBT)); - unkdbt.size = strlen("UNKNOWN") + 1; + unkdbt.size = (u_int32_t)strlen("UNKNOWN") + 1; unkdbt.data = "UNKNOWN"; err_ret = 0; @@ -818,8 +833,8 @@ __ham_salvage(dbp, vdp, pgno, h, handle, callback, flags) break; if (ret == 0) { - hk = P_ENTRY(h, i); - len = LEN_HKEYDATA(h, dbp->pgsize, i); + hk = P_ENTRY(dbp, h, i); + len = LEN_HKEYDATA(dbp, h, dbp->pgsize, i); if ((u_int32_t)(hk + len - (u_int8_t *)h) > dbp->pgsize) { /* @@ -927,7 +942,7 @@ keydata: memcpy(buf, HKEYDATA_DATA(hk), len); } } - __os_free(dbp->dbenv, buf, 0); + __os_free(dbp->dbenv, buf); if ((t_ret = __db_salvage_markdone(vdp, pgno)) != 0) return (t_ret); return ((ret == 0 && err_ret != 0) ? err_ret : ret); diff --git a/db/java/src/com/sleepycat/db/DbLockNotGrantedException.java b/db/java/src/com/sleepycat/db/DbLockNotGrantedException.java index 6eab84302..788943daa 100644 --- a/db/java/src/com/sleepycat/db/DbLockNotGrantedException.java +++ b/db/java/src/com/sleepycat/db/DbLockNotGrantedException.java @@ -1,10 +1,10 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1997-2001 + * Copyright (c) 1997-2002 * Sleepycat Software. All rights reserved. * - * Id: DbLockNotGrantedException.java,v 11.2 2001/10/05 02:36:06 bostic Exp + * Id: DbLockNotGrantedException.java,v 11.3 2002/01/11 15:52:36 bostic Exp */ package com.sleepycat.db; diff --git a/db/java/src/com/sleepycat/db/DbLockRequest.java b/db/java/src/com/sleepycat/db/DbLockRequest.java index 4cd5c6290..46f4c349e 100644 --- a/db/java/src/com/sleepycat/db/DbLockRequest.java +++ b/db/java/src/com/sleepycat/db/DbLockRequest.java @@ -1,10 +1,10 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1997-2001 + * Copyright (c) 1997-2002 * Sleepycat Software. All rights reserved. * - * Id: DbLockRequest.java,v 11.2 2001/10/05 02:36:06 bostic Exp + * Id: DbLockRequest.java,v 11.4 2002/01/16 07:45:24 mjc Exp */ package com.sleepycat.db; @@ -59,8 +59,9 @@ public class DbLockRequest this.lock = lock; } - private int op; - private int mode; + private /* db_lockop_t */ int op; + private /* db_lockmode_t */ int mode; + private /* db_timeout_t */ int timeout; private Dbt obj; private DbLock lock; } diff --git a/db/java/src/com/sleepycat/db/DbLogc.java b/db/java/src/com/sleepycat/db/DbLogc.java index d3395f883..fb9e0f87c 100644 --- a/db/java/src/com/sleepycat/db/DbLogc.java +++ b/db/java/src/com/sleepycat/db/DbLogc.java @@ -1,10 +1,10 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1997-2001 + * Copyright (c) 1997-2002 * Sleepycat Software. All rights reserved. * - * Id: DbLogc.java,v 11.2 2001/10/02 13:36:27 dda Exp + * Id: DbLogc.java,v 11.3 2002/01/11 15:52:37 bostic Exp */ package com.sleepycat.db; diff --git a/db/java/src/com/sleepycat/db/DbRepTransport.java b/db/java/src/com/sleepycat/db/DbRepTransport.java index 80b91d6ca..0794305fe 100644 --- a/db/java/src/com/sleepycat/db/DbRepTransport.java +++ b/db/java/src/com/sleepycat/db/DbRepTransport.java @@ -1,10 +1,10 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2001 + * Copyright (c) 2001-2002 * Sleepycat Software. All rights reserved. * - * Id: DbRepTransport.java,v 11.1 2001/10/04 04:59:15 krinsky Exp + * Id: DbRepTransport.java,v 11.2 2002/01/11 15:52:40 bostic Exp */ package com.sleepycat.db; diff --git a/db/libdb_java/com_sleepycat_db_DbLogc.h b/db/libdb_java/com_sleepycat_db_DbLogc.h index a6fbb670d..8d029c761 100644 --- a/db/libdb_java/com_sleepycat_db_DbLogc.h +++ b/db/libdb_java/com_sleepycat_db_DbLogc.h @@ -3,14 +3,14 @@ /* Header for class com_sleepycat_db_DbLogc */ #ifndef _Included_com_sleepycat_db_DbLogc -#define _Included_com_sleepycat_db_DbLogc +#define _Included_com_sleepycat_db_DbLogc #ifdef __cplusplus extern "C" { #endif /* * Class: com_sleepycat_db_DbLogc * Method: close - * Signature: ()V + * Signature: (I)V */ JNIEXPORT void JNICALL Java_com_sleepycat_db_DbLogc_close (JNIEnv *, jobject, jint); diff --git a/db/libdb_java/java_DbLogc.c b/db/libdb_java/java_DbLogc.c index 63b3e0eb3..928a9dce9 100644 --- a/db/libdb_java/java_DbLogc.c +++ b/db/libdb_java/java_DbLogc.c @@ -1,13 +1,13 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1997-2001 + * Copyright (c) 1997-2002 * Sleepycat Software. All rights reserved. */ #include "db_config.h" #ifndef lint -static const char revid[] = "Id: java_DbLogc.c,v 11.2 2001/10/02 01:33:40 bostic Exp "; +static const char revid[] = "Id: java_DbLogc.c,v 11.6 2002/07/02 12:03:03 mjc Exp "; #endif /* not lint */ #include <jni.h> @@ -46,7 +46,8 @@ JNIEXPORT jint JNICALL Java_com_sleepycat_db_DbLogc_get LOCKED_DBT ldata; OpKind dataop; - /* Depending on flags, the user may be supplying the key, + /* + * Depending on flags, the user may be supplying the key, * or else we may have to retrieve it. */ err = 0; @@ -54,7 +55,7 @@ JNIEXPORT jint JNICALL Java_com_sleepycat_db_DbLogc_get dblogc = get_DB_LOGC(jnienv, jthis); dblsn = get_DB_LSN(jnienv, lsn); - if (locked_dbt_get(&ldata, jnienv, data, dataop) != 0) + if (locked_dbt_get(&ldata, jnienv, dblogc->dbenv, data, dataop) != 0) goto out1; if (!verify_non_null(jnienv, dblogc)) @@ -63,17 +64,18 @@ JNIEXPORT jint JNICALL Java_com_sleepycat_db_DbLogc_get for (retry = 0; retry < 3; retry++) { err = dblogc->get(dblogc, dblsn, &ldata.javainfo->dbt, flags); - /* If we failed due to lack of memory in our DBT arrays, + /* + * If we failed due to lack of memory in our DBT arrays, * retry. */ if (err != ENOMEM) break; - if (!locked_dbt_realloc(&ldata, jnienv)) + if (!locked_dbt_realloc(&ldata, jnienv, dblogc->dbenv)) break; } out1: - locked_dbt_put(&ldata, jnienv); - if (err != 0 && err != DB_NOTFOUND) { + locked_dbt_put(&ldata, jnienv, dblogc->dbenv); + if (!DB_RETOK_LGGET(err)) { if (verify_dbt(jnienv, err, &ldata)) verify_return(jnienv, err, 0); } @@ -83,7 +85,8 @@ JNIEXPORT jint JNICALL Java_com_sleepycat_db_DbLogc_get JNIEXPORT void JNICALL Java_com_sleepycat_db_DbLogc_finalize (JNIEnv *jnienv, jobject jthis) { - /* Free any data related to DB_LOGC here. + /* + * Free any data related to DB_LOGC here. * If we ever have java-only data embedded in the DB_LOGC * and need to do this, we'll have to track DbLogc's * according to which DbEnv owns them, just as diff --git a/db/log/log.c b/db/log/log.c index 3ea4acd2d..fdbb84e5a 100644 --- a/db/log/log.c +++ b/db/log/log.c @@ -1,13 +1,13 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1996-2001 + * Copyright (c) 1996-2002 * Sleepycat Software. All rights reserved. */ #include "db_config.h" #ifndef lint -static const char revid[] = "Id: log.c,v 11.73 2001/11/16 16:29:33 bostic Exp "; +static const char revid[] = "Id: log.c,v 11.110 2002/08/13 17:51:13 sue Exp "; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -20,14 +20,15 @@ static const char revid[] = "Id: log.c,v 11.73 2001/11/16 16:29:33 bostic Exp "; #endif #include "db_int.h" -#include "log.h" -#include "db_dispatch.h" -#include "txn.h" -#include "txn_auto.h" +#include "dbinc/crypto.h" +#include "dbinc/hmac.h" +#include "dbinc/log.h" +#include "dbinc/txn.h" static int __log_init __P((DB_ENV *, DB_LOG *)); static int __log_recover __P((DB_LOG *)); static size_t __log_region_size __P((DB_ENV *)); +static int __log_zero __P((DB_ENV *, DB_LSN *, DB_LSN *)); /* * __log_open -- @@ -72,15 +73,10 @@ __log_open(dbenv) * If the region is threaded, then we have to lock both the handles * and the region, and we need to allocate a mutex for that purpose. */ - if (F_ISSET(dbenv, DB_ENV_THREAD)) { - if ((ret = __db_mutex_alloc( - dbenv, &dblp->reginfo, 1, &dblp->mutexp)) != 0) - goto err; - if ((ret = __db_shmutex_init(dbenv, dblp->mutexp, 0, - MUTEX_THREAD, &dblp->reginfo, - (REGMAINT *)R_ADDR(&dblp->reginfo, lp->maint_off))) != 0) - goto err; - } + if (F_ISSET(dbenv, DB_ENV_THREAD) && + (ret = __db_mutex_setup(dbenv, &dblp->reginfo, &dblp->mutexp, + MUTEX_ALLOC | MUTEX_NO_RLOCK)) != 0) + goto err; /* Initialize the rest of the structure. */ dblp->bufp = R_ADDR(&dblp->reginfo, lp->buffer_off); @@ -89,13 +85,36 @@ __log_open(dbenv) * Set the handle -- we may be about to run recovery, which allocates * log cursors. Log cursors require logging be already configured, * and the handle being set is what demonstrates that. + * + * If we created the region, run recovery. If that fails, make sure + * we reset the log handle before cleaning up, otherwise we will try + * and clean up again in the mainline DB_ENV initialization code. */ dbenv->lg_handle = dblp; - /* If we created the region, run recovery. */ - if (F_ISSET(&dblp->reginfo, REGION_CREATE)) - if ((ret = __log_recover(dblp)) != 0) + if (F_ISSET(&dblp->reginfo, REGION_CREATE)) { + if ((ret = __log_recover(dblp)) != 0) { + dbenv->lg_handle = NULL; goto err; + } + + /* + * We first take the log file size from the environment, if + * specified. If that wasn't set, recovery may have set it + * from the persistent information in a log file header. If + * that didn't set it either, we default. + */ + if (lp->log_size == 0) + lp->log_size = lp->log_nsize = LG_MAX_DEFAULT; + } else { + /* + * A process joining the region may have reset the log file + * size, too. If so, it only affects the next log file we + * create. + */ + if (dbenv->lg_size != 0) + lp->log_nsize = dbenv->lg_size; + } R_UNLOCK(dbenv, &dblp->reginfo); return (0); @@ -110,7 +129,7 @@ err: if (dblp->reginfo.addr != NULL) { if (dblp->mutexp != NULL) __db_mutex_free(dbenv, &dblp->reginfo, dblp->mutexp); - __os_free(dbenv, dblp, sizeof(*dblp)); + __os_free(dbenv, dblp); return (ret); } @@ -124,10 +143,11 @@ __log_init(dbenv, dblp) DB_ENV *dbenv; DB_LOG *dblp; { + DB_MUTEX *flush_mutexp; LOG *region; int ret; void *p; -#ifdef MUTEX_SYSTEM_RESOURCES +#ifdef HAVE_MUTEX_SYSTEM_RESOURCES u_int8_t *addr; #endif @@ -139,11 +159,10 @@ __log_init(dbenv, dblp) region = dblp->reginfo.primary; memset(region, 0, sizeof(*region)); - region->persist.lg_max = dbenv->lg_max; - region->persist.magic = DB_LOGMAGIC; - region->persist.version = DB_LOGVERSION; - region->persist.mode = dbenv->db_mode; + region->fid_max = 0; SH_TAILQ_INIT(®ion->fq); + region->free_fid_stack = INVALID_ROFF; + region->free_fids = region->free_fids_alloced = 0; /* Initialize LOG LSNs. */ INIT_LSN(region->lsn); @@ -157,8 +176,15 @@ __log_init(dbenv, dblp) */ ZERO_LSN(region->waiting_lsn); -#ifdef MUTEX_SYSTEM_RESOURCES - /* Allocate room for the txn maintenance info and initialize it. */ + /* + * Log makes note of the fact that it ran into a checkpoint on + * startup if it did so, as a recovery optimization. A zero + * LSN signifies that it hasn't found one [yet]. + */ + ZERO_LSN(region->cached_ckp_lsn); + +#ifdef HAVE_MUTEX_SYSTEM_RESOURCES + /* Allocate room for the log maintenance info and initialize it. */ if ((ret = __db_shalloc(dblp->reginfo.addr, sizeof(REGMAINT) + LG_MAINT_SIZE, 0, &addr)) != 0) goto mem_err; @@ -166,11 +192,23 @@ __log_init(dbenv, dblp) region->maint_off = R_OFFSET(&dblp->reginfo, addr); #endif - if ((ret = __db_shmutex_init(dbenv, ®ion->flush, 0, - 0, &dblp->reginfo, - (REGMAINT *)R_ADDR(&dblp->reginfo, region->maint_off))) != 0) + if ((ret = __db_mutex_setup(dbenv, &dblp->reginfo, ®ion->fq_mutex, + MUTEX_NO_RLOCK)) != 0) return (ret); + /* + * We must create a place for the flush mutex separately; mutexes have + * to be aligned to MUTEX_ALIGN, and the only way to guarantee that is + * to make sure they're at the beginning of a shalloc'ed chunk. + */ + if ((ret = __db_shalloc(dblp->reginfo.addr, + sizeof(DB_MUTEX), MUTEX_ALIGN, &flush_mutexp)) != 0) + goto mem_err; + if ((ret = __db_mutex_setup(dbenv, &dblp->reginfo, flush_mutexp, + MUTEX_NO_RLOCK)) != 0) + return (ret); + region->flush_mutex_off = R_OFFSET(&dblp->reginfo, flush_mutexp); + /* Initialize the buffer. */ if ((ret = __db_shalloc(dblp->reginfo.addr, dbenv->lg_bsize, 0, &p)) != 0) { @@ -179,12 +217,22 @@ mem_err: __db_err(dbenv, "Unable to allocate memory for the log buffer"); } region->buffer_size = dbenv->lg_bsize; region->buffer_off = R_OFFSET(&dblp->reginfo, p); + region->log_size = region->log_nsize = dbenv->lg_size; /* Initialize the commit Queue. */ SH_TAILQ_INIT(®ion->free_commits); SH_TAILQ_INIT(®ion->commits); region->ncommit = 0; + /* + * Fill in the log's persistent header. Don't fill in the log file + * sizes, as they may change at any time and so have to be filled in + * as each log file is created. + */ + region->persist.magic = DB_LOGMAGIC; + region->persist.version = DB_LOGVERSION; + region->persist.mode = (u_int32_t)dbenv->db_mode; + return (0); } @@ -201,11 +249,12 @@ __log_recover(dblp) DB_LOGC *logc; DB_LSN lsn; LOG *lp; - int cnt, found_checkpoint, ret; - u_int32_t chk; + u_int32_t cnt, rectype; + int ret; logfile_validity status; logc = NULL; + dbenv = dblp->dbenv; lp = dblp->reginfo.primary; /* @@ -219,8 +268,9 @@ __log_recover(dblp) /* * If the last file is an old version, readable or no, start a new - * file. Don't bother finding checkpoints; if we didn't take a - * checkpoint right before upgrading, the user screwed up anyway. + * file. Don't bother finding the end of the last log file; + * we assume that it's valid in its entirety, since the user + * should have shut down cleanly or run recovery before upgrading. */ if (status == DB_LV_OLD_READABLE || status == DB_LV_OLD_UNREADABLE) { lp->lsn.file = lp->s_lsn.file = cnt + 1; @@ -244,7 +294,6 @@ __log_recover(dblp) * Allocate a cursor and set it to the first record. This shouldn't * fail, leave error messages on. */ - dbenv = dblp->dbenv; if ((ret = dbenv->log_cursor(dbenv, &logc, 0)) != 0) return (ret); F_SET(logc, DB_LOG_LOCKED); @@ -253,19 +302,21 @@ __log_recover(dblp) goto err; /* - * Read to the end of the file, looking for checkpoints. This will - * fail at some point, so turn off error messages. + * Read to the end of the file. This may fail at some point, so + * turn off error messages. */ F_SET(logc, DB_LOG_SILENT_ERR); - found_checkpoint = 0; while (logc->get(logc, &lsn, &dbt, DB_NEXT) == 0) { if (dbt.size < sizeof(u_int32_t)) continue; - memcpy(&chk, dbt.data, sizeof(u_int32_t)); - if (chk == DB_txn_ckp) { - lp->chkpt_lsn = lsn; - found_checkpoint = 1; - } + memcpy(&rectype, dbt.data, sizeof(u_int32_t)); + if (rectype == DB___txn_ckp) + /* + * If we happen to run into a checkpoint, cache its + * LSN so that the transaction system doesn't have + * to walk this log file again looking for it. + */ + lp->cached_ckp_lsn = lsn; } F_CLR(logc, DB_LOG_SILENT_ERR); @@ -284,43 +335,9 @@ __log_recover(dblp) lp->b_off = 0; lp->w_off = lp->lsn.offset; - /* - * It's possible that we didn't find a checkpoint because there wasn't - * one in the last log file. Start searching. - */ - if (!found_checkpoint && cnt > 1) { - lsn.file = cnt; - lsn.offset = 0; - - /* Set the cursor; shouldn't fail, leave error messages on. */ - if ((ret = logc->get(logc, &lsn, &dbt, DB_SET)) != 0) - goto err; - - /* - * Read to the end of the file, looking for checkpoints. This - * can fail if there are no checkpoints in any log file, so we - * turn off error messages. - */ - F_SET(logc, DB_LOG_SILENT_ERR); - while (logc->get(logc, &lsn, &dbt, DB_PREV) == 0) { - if (dbt.size < sizeof(u_int32_t)) - continue; - memcpy(&chk, dbt.data, sizeof(u_int32_t)); - if (chk == DB_txn_ckp) { - lp->chkpt_lsn = lsn; - found_checkpoint = 1; - break; - } - } - F_CLR(logc, DB_LOG_SILENT_ERR); - } - - /* If we never find a checkpoint, that's okay, just 0 it out. */ - if (!found_checkpoint) -skipsearch: ZERO_LSN(lp->chkpt_lsn); - - if (FLD_ISSET(dblp->dbenv->verbose, DB_VERB_RECOVERY)) - __db_err(dblp->dbenv, +skipsearch: + if (FLD_ISSET(dbenv->verbose, DB_VERB_RECOVERY)) + __db_err(dbenv, "Finding last valid log LSN: file: %lu offset %lu", (u_long)lp->lsn.file, (u_long)lp->lsn.offset); @@ -336,20 +353,23 @@ err: if (logc != NULL) * the number of the first readable log file, else it will contain the number * of the last log file (which may be too old to read). * - * PUBLIC: int __log_find __P((DB_LOG *, int, int *, logfile_validity *)); + * PUBLIC: int __log_find __P((DB_LOG *, int, u_int32_t *, logfile_validity *)); */ int __log_find(dblp, find_first, valp, statusp) DB_LOG *dblp; - int find_first, *valp; + int find_first; + u_int32_t *valp; logfile_validity *statusp; { - char *c, **names, *p, *q, savech; - const char *dir; - int cnt, fcnt, ret; + DB_ENV *dbenv; logfile_validity logval_status, status; u_int32_t clv, logval; + int cnt, fcnt, ret; + const char *dir; + char *c, **names, *p, *q, savech; + dbenv = dblp->dbenv; logval_status = status = DB_LV_NONEXISTENT; /* Return a value of 0 as the log file number on failure. */ @@ -368,7 +388,7 @@ __log_find(dblp, find_first, valp, statusp) } /* Get the list of file names. */ - ret = __os_dirlist(dblp->dbenv, dir, &names, &fcnt); + ret = __os_dirlist(dbenv, dir, &names, &fcnt); /* * !!! @@ -380,8 +400,8 @@ __log_find(dblp, find_first, valp, statusp) *q = savech; if (ret != 0) { - __db_err(dblp->dbenv, "%s: %s", dir, db_strerror(ret)); - __os_freestr(dblp->dbenv, p); + __db_err(dbenv, "%s: %s", dir, db_strerror(ret)); + __os_free(dbenv, p); return (ret); } @@ -405,73 +425,78 @@ __log_find(dblp, find_first, valp, statusp) * log file name won't fit. */ clv = atol(names[cnt] + (sizeof(LFPREFIX) - 1)); + + /* + * If searching for the first log file, we want to return the + * oldest log file we can read, or, if no readable log files + * exist, the newest log file we can't read (the crossover + * point between the old and new versions of the log file). + * + * If we're searching for the last log file, we want to return + * the newest log file, period. + * + * Readable log files should never preceede unreadable log + * files, that would mean the admin seriously screwed up. + */ if (find_first) { - if (logval != 0 && clv > logval) + if (logval != 0 && + status != DB_LV_OLD_UNREADABLE && clv > logval) continue; } else if (logval != 0 && clv < logval) continue; - /* - * Take note of whether the log file logval is - * an old version or incompletely initialized. - */ if ((ret = __log_valid(dblp, clv, 1, &status)) != 0) { - __db_err(dblp->dbenv, "Invalid log file: %s: %s", + __db_err(dbenv, "Invalid log file: %s: %s", names[cnt], db_strerror(ret)); goto err; } switch (status) { + case DB_LV_NONEXISTENT: + /* __log_valid never returns DB_LV_NONEXISTENT. */ + DB_ASSERT(0); + break; case DB_LV_INCOMPLETE: /* - * It's acceptable for the last log file to - * have been incompletely initialized--it's possible - * to create a log file but not write anything to it, - * and recovery needs to gracefully handle this. - * - * Just ignore it; we don't want to return this - * as a valid log file. + * The last log file may not have been initialized -- + * it's possible to create a log file but not write + * anything to it. If performing recovery (that is, + * if find_first isn't set), ignore the file, it's + * not interesting. If we're searching for the first + * log record, return the file (assuming we don't find + * something better), as the "real" first log record + * is likely to be in the log buffer, and we want to + * set the file LSN for our return. */ + if (find_first) + goto found; break; - case DB_LV_NONEXISTENT: - /* Should never happen. */ - DB_ASSERT(0); + case DB_LV_OLD_UNREADABLE: + /* + * If we're searching for the first log file, then we + * only want this file if we don't yet have a file or + * already have an unreadable file and this one is + * newer than that one. If we're searching for the + * last log file, we always want this file because we + * wouldn't be here if it wasn't newer than our current + * choice. + */ + if (!find_first || logval == 0 || + (status == DB_LV_OLD_UNREADABLE && clv > logval)) + goto found; break; case DB_LV_NORMAL: case DB_LV_OLD_READABLE: - logval = clv; +found: logval = clv; logval_status = status; break; - case DB_LV_OLD_UNREADABLE: - /* - * Continue; we want the oldest valid log, - * and clv is too old to be useful. We don't - * want it to supplant logval if we're looking for - * the oldest valid log, but we do want to return - * it if it's the last log file--we want the very - * last file number, so that our caller can - * start a new file after it. - * - * The code here assumes that there will never - * be a too-old log that's preceded by a log - * of the current version, but in order to - * attain that state of affairs the user - * would have had to really seriously screw - * up; I think we can safely assume this won't - * happen. - */ - if (!find_first) { - logval = clv; - logval_status = status; - } - break; } } *valp = logval; -err: __os_dirfree(dblp->dbenv, names, fcnt); - __os_freestr(dblp->dbenv, p); +err: __os_dirfree(dbenv, names, fcnt); + __os_free(dbenv, p); *statusp = logval_status; return (ret); @@ -494,30 +519,48 @@ __log_valid(dblp, number, set_persist, statusp) int set_persist; logfile_validity *statusp; { + DB_CIPHER *db_cipher; + DB_ENV *dbenv; DB_FH fh; + HDR *hdr; LOG *region; - LOGP persist; - char *fname; - int ret; + LOGP *persist; logfile_validity status; - size_t nw; + size_t hdrsize, nw, recsize; + int is_hmac, need_free, ret; + u_int8_t *tmp; + char *fname; + dbenv = dblp->dbenv; + db_cipher = dbenv->crypto_handle; + persist = NULL; status = DB_LV_NORMAL; /* Try to open the log file. */ if ((ret = __log_name(dblp, number, &fname, &fh, DB_OSO_RDONLY | DB_OSO_SEQ)) != 0) { - __os_freestr(dblp->dbenv, fname); + __os_free(dbenv, fname); return (ret); } + need_free = 0; + hdrsize = HDR_NORMAL_SZ; + is_hmac = 0; + recsize = sizeof(LOGP); + if (CRYPTO_ON(dbenv)) { + hdrsize = HDR_CRYPTO_SZ; + recsize = sizeof(LOGP); + recsize += db_cipher->adj_size(recsize); + is_hmac = 1; + } + if ((ret = __os_calloc(dbenv, 1, recsize + hdrsize, &tmp)) != 0) + return (ret); + need_free = 1; + hdr = (HDR *)tmp; + persist = (LOGP *)(tmp + hdrsize); /* Try to read the header. */ - if ((ret = - __os_seek(dblp->dbenv, - &fh, 0, 0, sizeof(HDR), 0, DB_OS_SEEK_SET)) != 0 || - (ret = - __os_read(dblp->dbenv, &fh, &persist, sizeof(LOGP), &nw)) != 0 || - nw != sizeof(LOGP)) { + if ((ret = __os_read(dbenv, &fh, tmp, recsize + hdrsize, &nw)) != 0 || + nw != recsize + hdrsize) { if (ret == 0) status = DB_LV_INCOMPLETE; else @@ -525,19 +568,63 @@ __log_valid(dblp, number, set_persist, statusp) * The error was a fatal read error, not just an * incompletely initialized log file. */ - __db_err(dblp->dbenv, "Ignoring log file: %s: %s", + __db_err(dbenv, "Ignoring log file: %s: %s", fname, db_strerror(ret)); - (void)__os_closehandle(&fh); + (void)__os_closehandle(dbenv, &fh); goto err; } - (void)__os_closehandle(&fh); + (void)__os_closehandle(dbenv, &fh); + + /* + * Now we have to validate the persistent record. We have + * several scenarios we have to deal with: + * + * 1. User has crypto turned on: + * - They're reading an old, unencrypted log file + * . We will fail the record size match check below. + * - They're reading a current, unencrypted log file + * . We will fail the record size match check below. + * - They're reading an old, encrypted log file [NOT YET] + * . After decryption we'll fail the version check. [NOT YET] + * - They're reading a current, encrypted log file + * . We should proceed as usual. + * 2. User has crypto turned off: + * - They're reading an old, unencrypted log file + * . We will fail the version check. + * - They're reading a current, unencrypted log file + * . We should proceed as usual. + * - They're reading an old, encrypted log file [NOT YET] + * . We'll fail the magic number check (it is encrypted). + * - They're reading a current, encrypted log file + * . We'll fail the magic number check (it is encrypted). + */ + if (CRYPTO_ON(dbenv)) { + /* + * If we are trying to decrypt an unencrypted log + * we can only detect that by having an unreasonable + * data length for our persistent data. + */ + if ((hdr->len - hdrsize) != sizeof(LOGP)) { + __db_err(dbenv, "log record size mismatch"); + goto err; + } + /* Check the checksum and decrypt. */ + if ((ret = __db_check_chksum(dbenv, db_cipher, &hdr->chksum[0], + (u_int8_t *)persist, hdr->len - hdrsize, is_hmac)) != 0) { + __db_err(dbenv, "log record checksum mismatch"); + goto err; + } + if ((ret = db_cipher->decrypt(dbenv, db_cipher->data, + &hdr->iv[0], (u_int8_t *)persist, hdr->len - hdrsize)) != 0) + goto err; + } /* Validate the header. */ - if (persist.magic != DB_LOGMAGIC) { - __db_err(dblp->dbenv, + if (persist->magic != DB_LOGMAGIC) { + __db_err(dbenv, "Ignoring log file: %s: magic number %lx, not %lx", - fname, (u_long)persist.magic, (u_long)DB_LOGMAGIC); + fname, (u_long)persist->magic, (u_long)DB_LOGMAGIC); ret = EINVAL; goto err; } @@ -547,35 +634,60 @@ __log_valid(dblp, number, set_persist, statusp) * belongs to an unreadable or readable old version; leave it * alone if and only if the log file version is the current one. */ - if (persist.version > DB_LOGVERSION) { + if (persist->version > DB_LOGVERSION) { /* This is a fatal error--the log file is newer than DB. */ - __db_err(dblp->dbenv, + __db_err(dbenv, "Ignoring log file: %s: unsupported log version %lu", - fname, (u_long)persist.version); + fname, (u_long)persist->version); ret = EINVAL; goto err; - } else if (persist.version < DB_LOGOLDVER) { + } else if (persist->version < DB_LOGOLDVER) { status = DB_LV_OLD_UNREADABLE; /* * We don't want to set persistent info based on an * unreadable region, so jump to "err". */ goto err; - } else if (persist.version < DB_LOGVERSION) + } else if (persist->version < DB_LOGVERSION) status = DB_LV_OLD_READABLE; /* - * If the log is thus far readable and we're doing system - * initialization, set the region's persistent information - * based on the headers. + * Only if we have a current log do we verify the checksum. + * We could not check the checksum before checking the magic + * and version because old log hdrs have the length and checksum + * in a different location. + */ + if (!CRYPTO_ON(dbenv) && ((ret = __db_check_chksum(dbenv, + db_cipher, &hdr->chksum[0], (u_int8_t *)persist, + hdr->len - hdrsize, is_hmac)) != 0)) { + __db_err(dbenv, "log record checksum mismatch"); + goto err; + } + + /* + * If the log is readable so far and we're doing system initialization, + * set the region's persistent information based on the headers. + * + * Always set the current log file size. Only set the next log file's + * size if the application hasn't set it already. + * + * XXX + * Always use the persistent header's mode, regardless of what was set + * in the current environment. We've always done it this way, but it's + * probably a bug -- I can't think of a way not-changing the mode would + * be a problem, though. */ if (set_persist) { region = dblp->reginfo.primary; - region->persist.lg_max = persist.lg_max; - region->persist.mode = persist.mode; + region->log_size = persist->log_size; + if (region->log_nsize == 0) + region->log_nsize = persist->log_size; + region->persist.mode = persist->mode; } -err: __os_freestr(dblp->dbenv, fname); +err: __os_free(dbenv, fname); + if (need_free) + __os_free(dbenv, tmp); *statusp = status; return (ret); } @@ -598,24 +710,25 @@ __log_dbenv_refresh(dbenv) /* We may have opened files as part of XA; if so, close them. */ F_SET(dblp, DBLOG_RECOVER); - __log_close_files(dbenv); + ret = __dbreg_close_files(dbenv); /* Discard the per-thread lock. */ if (dblp->mutexp != NULL) __db_mutex_free(dbenv, &dblp->reginfo, dblp->mutexp); /* Detach from the region. */ - ret = __db_r_detach(dbenv, &dblp->reginfo, 0); + if ((t_ret = + __db_r_detach(dbenv, &dblp->reginfo, 0)) != 0 && ret == 0) + ret = t_ret; /* Close open files, release allocated memory. */ if (F_ISSET(&dblp->lfh, DB_FH_VALID) && - (t_ret = __os_closehandle(&dblp->lfh)) != 0 && ret == 0) + (t_ret = __os_closehandle(dbenv, &dblp->lfh)) != 0 && ret == 0) ret = t_ret; if (dblp->dbentry != NULL) - __os_free(dbenv, dblp->dbentry, - (dblp->dbentry_cnt * sizeof(DB_ENTRY))); + __os_free(dbenv, dblp->dbentry); - __os_free(dbenv, dblp, sizeof(*dblp)); + __os_free(dbenv, dblp); dbenv->lg_handle = NULL; return (ret); @@ -663,7 +776,7 @@ __log_stat(dbenv, statp, flags) stats->st_version = region->persist.version; stats->st_mode = region->persist.mode; stats->st_lg_bsize = region->buffer_size; - stats->st_lg_max = region->persist.lg_max; + stats->st_lg_size = region->log_nsize; stats->st_region_wait = dblp->reginfo.rp->mutex.mutex_set_wait; stats->st_region_nowait = dblp->reginfo.rp->mutex.mutex_set_nowait; @@ -685,24 +798,25 @@ __log_stat(dbenv, statp, flags) } /* - * __log_lastckp -- - * Return the current chkpt_lsn, so that we can store it in - * the transaction region and keep the chain of checkpoints - * unbroken across environment recreates. + * __log_get_cached_ckp_lsn -- + * Retrieve any last checkpoint LSN that we may have found on startup. * - * PUBLIC: int __log_lastckp __P((DB_ENV *, DB_LSN *)); + * PUBLIC: void __log_get_cached_ckp_lsn __P((DB_ENV *, DB_LSN *)); */ -int -__log_lastckp(dbenv, lsnp) +void +__log_get_cached_ckp_lsn(dbenv, ckp_lsnp) DB_ENV *dbenv; - DB_LSN *lsnp; + DB_LSN *ckp_lsnp; { + DB_LOG *dblp; LOG *lp; - lp = (LOG *)(((DB_LOG *)dbenv->lg_handle)->reginfo.primary); + dblp = (DB_LOG *)dbenv->lg_handle; + lp = (LOG *)dblp->reginfo.primary; - *lsnp = lp->chkpt_lsn; - return (0); + R_LOCK(dbenv, &dblp->reginfo); + *ckp_lsnp = lp->cached_ckp_lsn; + R_UNLOCK(dbenv, &dblp->reginfo); } /* @@ -720,7 +834,7 @@ __log_region_size(dbenv) size_t s; s = dbenv->lg_regionmax + dbenv->lg_bsize; -#ifdef MUTEX_SYSTEM_RESOURCES +#ifdef HAVE_MUTEX_SYSTEM_RESOURCES if (F_ISSET(dbenv, DB_ENV_THREAD)) s += sizeof(REGMAINT) + LG_MAINT_SIZE; #endif @@ -764,6 +878,7 @@ __log_vtruncate(dbenv, lsn, ckplsn) DB_FH fh; DB_LOG *dblp; DB_LOGC *logc; + DB_LSN end_lsn; LOG *lp; u_int32_t bytes, c_len; int fn, ret, t_ret; @@ -785,10 +900,10 @@ __log_vtruncate(dbenv, lsn, ckplsn) lp = (LOG *)dblp->reginfo.primary; R_LOCK(dbenv, &dblp->reginfo); + end_lsn = lp->lsn; lp->lsn = *lsn; lp->len = c_len; lp->lsn.offset += lp->len; - lp->chkpt_lsn = *ckplsn; /* * I am going to assume that the number of bytes written since @@ -797,9 +912,9 @@ __log_vtruncate(dbenv, lsn, ckplsn) DB_ASSERT(lp->lsn.file >= ckplsn->file); bytes = 0; if (ckplsn->file != lp->lsn.file) { - bytes = lp->persist.lg_max - ckplsn->offset; + bytes = lp->log_size - ckplsn->offset; if (lp->lsn.file > ckplsn->file + 1) - bytes += lp->persist.lg_max * + bytes += lp->log_size * (lp->lsn.file - ckplsn->file - 1); bytes += lp->lsn.offset; } else @@ -816,12 +931,13 @@ __log_vtruncate(dbenv, lsn, ckplsn) lp->s_lsn = lp->lsn; /* - * If the new end of log is in the middle of the - * buffer, don't change the w_off. If the new end - * is before the w_off then reset w_off to the new + * If the new end of log is in the middle of the buffer, + * don't change the w_off or f_lsn. If the new end is + * before the w_off then reset w_off and f_lsn to the new * end of log. */ if (lp->w_off >= lp->lsn.offset) { + lp->f_lsn = lp->lsn; lp->w_off = lp->lsn.offset; lp->b_off = 0; } else @@ -829,18 +945,25 @@ __log_vtruncate(dbenv, lsn, ckplsn) ZERO_LSN(lp->waiting_lsn); lp->ready_lsn = lp->lsn; - lp->f_lsn = lp->lsn; + lp->wait_recs = 0; + lp->rcvd_recs = 0; /* Now throw away any extra log files that we have around. */ for (fn = lp->lsn.file + 1;; fn++) { if (__log_name(dblp, fn, &fname, &fh, DB_OSO_RDONLY) != 0) break; - (void)__os_closehandle(&fh); - if ((ret = __os_unlink(dbenv, fname)) != 0) - break; - __os_freestr(dbenv, fname); + (void)__os_closehandle(dbenv, &fh); + ret = __os_unlink(dbenv, fname); + __os_free(dbenv, fname); + if (ret != 0) + goto err; } - R_UNLOCK(dbenv, &dblp->reginfo); + + /* Truncate the log to the new point. */ + if ((ret = __log_zero(dbenv, &lp->lsn, &end_lsn)) != 0) + goto err; + +err: R_UNLOCK(dbenv, &dblp->reginfo); return (ret); } @@ -852,7 +975,7 @@ __log_vtruncate(dbenv, lsn, ckplsn) * lower-numbered than the current logs, the we return *outdatedp non * zero, else we return it 0. * - * PUBLIC: int __log_is_outdated __P((DB_ENV *dbenv, + * PUBLIC: int __log_is_outdated __P((DB_ENV *dbenv, * PUBLIC: u_int32_t fnum, int *outdatedp)); */ int @@ -889,6 +1012,71 @@ __log_is_outdated(dbenv, fnum, outdatedp) if (cfile > fnum) *outdatedp = 1; -out: __os_freestr(dbenv, name); +out: __os_free(dbenv, name); return (ret); } + +/* + * __log_zero -- + * Zero out the tail of a log after a truncate. + */ +static int +__log_zero(dbenv, from_lsn, to_lsn) + DB_ENV *dbenv; + DB_LSN *from_lsn, *to_lsn; +{ + char *lname; + DB_LOG *dblp; + LOG *lp; + int ret; + size_t nbytes, len, nw; + u_int8_t buf[4096]; + u_int32_t mbytes, bytes; + + dblp = dbenv->lg_handle; + lp = (LOG *)dblp->reginfo.primary; + lname = NULL; + + if (dblp->lfname != lp->lsn.file) { + if (F_ISSET(&dblp->lfh, DB_FH_VALID)) + (void)__os_closehandle(dbenv, &dblp->lfh); + dblp->lfname = lp->lsn.file; + } + + if (from_lsn->file != to_lsn->file) { + /* We removed some log files; have to 0 to end of file. */ + if (!F_ISSET(&dblp->lfh, DB_FH_VALID) && (ret = + __log_name(dblp, dblp->lfname, &lname, &dblp->lfh, 0)) != 0) + return (ret); + if ((ret = __os_ioinfo(dbenv, + NULL, &dblp->lfh, &mbytes, &bytes, NULL)) != 0) + goto err; + len = mbytes * MEGABYTE + bytes - from_lsn->offset; + } else if (to_lsn->offset <= from_lsn->offset) + return (0); + else + len = to_lsn->offset = from_lsn->offset; + + memset(buf, 0, sizeof(buf)); + + /* Initialize the write position. */ + if (!F_ISSET(&dblp->lfh, DB_FH_VALID) && + (ret = __log_name(dblp, dblp->lfname, &lname, &dblp->lfh, 0)) != 0) + goto err; + + if ((ret = __os_seek(dbenv, + &dblp->lfh, 0, 0, from_lsn->offset, 0, DB_OS_SEEK_SET)) != 0) + return (ret); + + while (len > 0) { + nbytes = len > sizeof(buf) ? sizeof(buf) : len; + if ((ret = + __os_write(dbenv, &dblp->lfh, buf, nbytes, &nw)) != 0) + return (ret); + len -= nbytes; + } +err: if (lname != NULL) + __os_free(dbenv, lname); + + return (0); +} diff --git a/db/mp/mp_bh.c b/db/mp/mp_bh.c index 5c438b202..24f14ab1d 100644 --- a/db/mp/mp_bh.c +++ b/db/mp/mp_bh.c @@ -1,13 +1,13 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1996-2001 + * Copyright (c) 1996-2002 * Sleepycat Software. All rights reserved. */ #include "db_config.h" #ifndef lint -static const char revid[] = "Id: mp_bh.c,v 11.45 2001/07/26 19:53:31 bostic Exp "; +static const char revid[] = "Id: mp_bh.c,v 11.68 2002/05/03 15:21:16 bostic Exp "; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -18,43 +18,41 @@ static const char revid[] = "Id: mp_bh.c,v 11.45 2001/07/26 19:53:31 bostic Exp #endif #include "db_int.h" -#include "db_shash.h" -#include "mp.h" -#include "log.h" -#include "db_page.h" +#include "dbinc/db_shash.h" +#include "dbinc/mp.h" +#include "dbinc/log.h" +#include "dbinc/db_page.h" +static int __memp_pgwrite + __P((DB_MPOOL *, DB_MPOOLFILE *, DB_MPOOL_HASH *, BH *)); static int __memp_upgrade __P((DB_MPOOL *, DB_MPOOLFILE *, MPOOLFILE *)); /* * __memp_bhwrite -- - * Write the page associated with a given bucket header. + * Write the page associated with a given buffer header. * - * PUBLIC: int __memp_bhwrite - * PUBLIC: __P((DB_MPOOL *, MPOOLFILE *, BH *, int, int *, int *)); + * PUBLIC: int __memp_bhwrite __P((DB_MPOOL *, + * PUBLIC: DB_MPOOL_HASH *, MPOOLFILE *, BH *, int)); */ int -__memp_bhwrite(dbmp, mfp, bhp, open_extents, restartp, wrotep) +__memp_bhwrite(dbmp, hp, mfp, bhp, open_extents) DB_MPOOL *dbmp; + DB_MPOOL_HASH *hp; MPOOLFILE *mfp; BH *bhp; - int open_extents, *restartp, *wrotep; + int open_extents; { DB_ENV *dbenv; DB_MPOOLFILE *dbmfp; DB_MPREG *mpreg; - int incremented, ret; + int local_open, incremented, ret; dbenv = dbmp->dbenv; - - if (restartp != NULL) - *restartp = 0; - if (wrotep != NULL) - *wrotep = 0; - incremented = 0; + local_open = incremented = 0; /* - * If the file has been removed or is a closed temporary file, Jump - * right ahead and pretend that we've found the file we want-- the + * If the file has been removed or is a closed temporary file, jump + * right ahead and pretend that we've found the file we want -- the * page-write function knows how to handle the fact that we don't have * (or need!) any real file descriptor information. */ @@ -74,25 +72,35 @@ __memp_bhwrite(dbmp, mfp, bhp, open_extents, restartp, wrotep) dbmfp != NULL; dbmfp = TAILQ_NEXT(dbmfp, q)) if (dbmfp->mfp == mfp) { if (F_ISSET(dbmfp, MP_READONLY) && - __memp_upgrade(dbmp, dbmfp, mfp)) { + !F_ISSET(dbmfp, MP_UPGRADE) && + (F_ISSET(dbmfp, MP_UPGRADE_FAIL) || + __memp_upgrade(dbmp, dbmfp, mfp))) { MUTEX_THREAD_UNLOCK(dbenv, dbmp->mutexp); - return (0); + return (EPERM); } /* * Increment the reference count -- see the comment in - * memp_fclose(). + * __memp_fclose_int(). */ ++dbmfp->ref; incremented = 1; break; } MUTEX_THREAD_UNLOCK(dbenv, dbmp->mutexp); + if (dbmfp != NULL) goto found; /* * !!! + * It's the caller's choice if we're going to open extent files. + */ + if (!open_extents && F_ISSET(mfp, MP_EXTENT)) + return (EPERM); + + /* + * !!! * Don't try to attach to temporary files. There are two problems in * trying to do that. First, if we have different privileges than the * process that "owns" the temporary file, we might create the backing @@ -107,15 +115,12 @@ __memp_bhwrite(dbmp, mfp, bhp, open_extents, restartp, wrotep) * with resource starvation, and the memp_trickle thread couldn't do * anything about it. That's a pretty unlikely scenario, though. * - * Note that we should never get here when the temporary file - * in question has already been closed in another process, in which - * case it should be marked MP_DEADFILE. + * Note we should never get here when the temporary file in question + * has already been closed in another process, in which case it should + * be marked MP_DEADFILE. */ - if (F_ISSET(mfp, MP_TEMP) - || (F_ISSET(mfp, MP_EXTENT) && !open_extents)) { - DB_ASSERT(!F_ISSET(mfp, MP_DEADFILE)); - return (0); - } + if (F_ISSET(mfp, MP_TEMP)) + return (EPERM); /* * It's not a page from a file we've opened. If the file requires @@ -131,7 +136,7 @@ __memp_bhwrite(dbmp, mfp, bhp, open_extents, restartp, wrotep) break; MUTEX_THREAD_UNLOCK(dbenv, dbmp->mutexp); if (mpreg == NULL) - return (0); + return (EPERM); } /* @@ -142,25 +147,24 @@ __memp_bhwrite(dbmp, mfp, bhp, open_extents, restartp, wrotep) * There's no negative cache, so we may repeatedly try and open files * that we have previously tried (and failed) to open. */ - if (dbenv->memp_fcreate(dbenv, &dbmfp, 0) != 0) - return (0); - if (__memp_fopen_int(dbmfp, mfp, + if ((ret = dbenv->memp_fcreate(dbenv, &dbmfp, 0)) != 0) + return (ret); + if ((ret = __memp_fopen_int(dbmfp, mfp, R_ADDR(dbmp->reginfo, mfp->path_off), - 0, 0, mfp->stat.st_pagesize, 0) != 0) { + 0, 0, mfp->stat.st_pagesize)) != 0) { (void)dbmfp->close(dbmfp, 0); - return (0); + return (ret); } - F_SET(dbmfp, MP_FLUSH); - if (F_ISSET(mfp, MP_EXTENT)) - dbmp->extents = 1; + local_open = 1; -found: ret = __memp_pgwrite(dbmp, dbmfp, bhp, restartp, wrotep); +found: ret = __memp_pgwrite(dbmp, dbmfp, hp, bhp) == 0 ? 0 : 1; - if (incremented) { - MUTEX_THREAD_LOCK(dbenv, dbmp->mutexp); + MUTEX_THREAD_LOCK(dbenv, dbmp->mutexp); + if (incremented) --dbmfp->ref; - MUTEX_THREAD_UNLOCK(dbenv, dbmp->mutexp); - } + else if (local_open) + F_SET(dbmfp, MP_FLUSH); + MUTEX_THREAD_UNLOCK(dbenv, dbmp->mutexp); return (ret); } @@ -169,11 +173,12 @@ found: ret = __memp_pgwrite(dbmp, dbmfp, bhp, restartp, wrotep); * __memp_pgread -- * Read a page from a file. * - * PUBLIC: int __memp_pgread __P((DB_MPOOLFILE *, BH *, int)); + * PUBLIC: int __memp_pgread __P((DB_MPOOLFILE *, DB_MUTEX *, BH *, int)); */ int -__memp_pgread(dbmfp, bhp, can_create) +__memp_pgread(dbmfp, mutexp, bhp, can_create) DB_MPOOLFILE *dbmfp; + DB_MUTEX *mutexp; BH *bhp; int can_create; { @@ -181,19 +186,21 @@ __memp_pgread(dbmfp, bhp, can_create) DB_ENV *dbenv; DB_MPOOL *dbmp; MPOOLFILE *mfp; - size_t len, pagesize; - size_t nr; - int created, ret; + size_t len, nr, pagesize; + int ret; dbmp = dbmfp->dbmp; dbenv = dbmp->dbenv; mfp = dbmfp->mfp; pagesize = mfp->stat.st_pagesize; - created = 0; + /* We should never be called with a dirty or a locked buffer. */ + DB_ASSERT(!F_ISSET(bhp, BH_DIRTY | BH_DIRTY_CREATE | BH_LOCKED)); + + /* Lock the buffer and swap the hash bucket lock for the buffer lock. */ F_SET(bhp, BH_LOCKED | BH_TRASH); - MUTEX_LOCK(dbenv, &bhp->mutex, dbenv->lockfhp); - R_UNLOCK(dbenv, dbmp->reginfo); + MUTEX_LOCK(dbenv, &bhp->mutex); + MUTEX_UNLOCK(dbenv, mutexp); /* * Temporary files may not yet have been created. We don't create @@ -208,125 +215,101 @@ __memp_pgread(dbmfp, bhp, can_create) db_io.buf = bhp->buf; /* - * The page may not exist; if it doesn't, nr may well be 0, + * The page may not exist; if it doesn't, nr may well be 0, * but we expect the underlying OS calls not to return an * error code in this case. */ if ((ret = __os_io(dbenv, &db_io, DB_IO_READ, &nr)) != 0) goto err; - } else - ret = 0; + } if (nr < pagesize) { - if (can_create) - created = 1; - else { - /* - * Don't output error messages for short reads. In - * particular, DB recovery processing may request pages - * that have never been written to disk or for which - * only some part have been written to disk, in which - * case we won't find the page. The caller must know - * how to handle the error. - */ + /* + * Don't output error messages for short reads. In particular, + * DB recovery processing may request pages never written to + * disk or for which only some part have been written to disk, + * in which case we won't find the page. The caller must know + * how to handle the error. + */ + if (can_create == 0) { ret = DB_PAGE_NOTFOUND; goto err; } + + /* Clear any bytes that need to be cleared. */ + len = mfp->clear_len == 0 ? pagesize : mfp->clear_len; + memset(bhp->buf, 0, len); + +#if defined(DIAGNOSTIC) || defined(UMRW) /* - * Clear any bytes that need to be cleared -- if we did a short - * read, we assume that a page was not completely written and - * clear even the bytes that we read. This is so our caller - * isn't surprised (for example, if the first sector only of a - * DB page was written, the LSN will indicate that the page was - * updated, but the page contents will be wrong). Support for - * page checksums might make this unnecessary in the future -- - * I would prefer not to discard data potentially written by - * the application, under any circumstances. - * * If we're running in diagnostic mode, corrupt any bytes on * the page that are unknown quantities for the caller. */ - len = mfp->clear_len == 0 ? pagesize : mfp->clear_len; - memset(bhp->buf, 0, len); -#if defined(DIAGNOSTIC) || defined(UMRW) if (len < pagesize) memset(bhp->buf + len, CLEAR_BYTE, pagesize - len); #endif - } + ++mfp->stat.st_page_create; + } else + ++mfp->stat.st_page_in; /* Call any pgin function. */ ret = mfp->ftype == 0 ? 0 : __memp_pg(dbmfp, bhp, 1); - /* Unlock the buffer and reacquire the region lock. */ + /* Unlock the buffer and reacquire the hash bucket lock. */ err: MUTEX_UNLOCK(dbenv, &bhp->mutex); - R_LOCK(dbenv, dbmp->reginfo); + MUTEX_LOCK(dbenv, mutexp); /* * If no errors occurred, the data is now valid, clear the BH_TRASH * flag; regardless, clear the lock bit and let other threads proceed. */ F_CLR(bhp, BH_LOCKED); - if (ret == 0) { + if (ret == 0) F_CLR(bhp, BH_TRASH); - /* Update the statistics. */ - if (created) - ++mfp->stat.st_page_create; - else - ++mfp->stat.st_page_in; - } - return (ret); } /* * __memp_pgwrite -- * Write a page to a file. - * - * PUBLIC: int __memp_pgwrite - * PUBLIC: __P((DB_MPOOL *, DB_MPOOLFILE *, BH *, int *, int *)); */ -int -__memp_pgwrite(dbmp, dbmfp, bhp, restartp, wrotep) +static int +__memp_pgwrite(dbmp, dbmfp, hp, bhp) DB_MPOOL *dbmp; DB_MPOOLFILE *dbmfp; + DB_MPOOL_HASH *hp; BH *bhp; - int *restartp, *wrotep; { DB_ENV *dbenv; DB_IO db_io; DB_LSN lsn; - MPOOL *c_mp, *mp; + MPOOL *mp; MPOOLFILE *mfp; size_t nw; - int callpgin, dosync, ret, syncfail; - const char *fail; + int callpgin, ret; dbenv = dbmp->dbenv; mp = dbmp->reginfo[0].primary; mfp = dbmfp == NULL ? NULL : dbmfp->mfp; + callpgin = ret = 0; - if (restartp != NULL) - *restartp = 0; - if (wrotep != NULL) - *wrotep = 0; - callpgin = 0; - - /* We should never be called with a clean or a locked buffer. */ + /* + * We should never be called with a clean or trash buffer. + * The sync code does call us with already locked buffers. + */ DB_ASSERT(F_ISSET(bhp, BH_DIRTY)); - DB_ASSERT(!F_ISSET(bhp, BH_LOCKED)); + DB_ASSERT(!F_ISSET(bhp, BH_TRASH)); /* - * Lock the buffer, set the I/O in progress flag, and discard the - * region lock. + * If we have not already traded the hash bucket lock for the buffer + * lock, do so now. */ - MUTEX_LOCK(dbenv, &bhp->mutex, dbenv->lockfhp); - F_SET(bhp, BH_LOCKED); - R_UNLOCK(dbenv, dbmp->reginfo); - - /* Tell the caller that the region lock was discarded. */ - if (restartp != NULL) - *restartp = 1; + if (!F_ISSET(bhp, BH_LOCKED)) { + F_SET(bhp, BH_LOCKED); + MUTEX_LOCK(dbenv, &bhp->mutex); + MUTEX_UNLOCK(dbenv, &hp->hash_mutex); + } /* * It's possible that the underlying file doesn't exist, either @@ -342,13 +325,9 @@ __memp_pgwrite(dbmp, dbmfp, bhp, restartp, wrotep) /* * If the page is in a file for which we have LSN information, we have - * to ensure the appropriate log records are on disk. If the page is - * being written as part of a sync operation, the flush has been done - * already, unless it was modified by the application *after* the sync - * was scheduled. + * to ensure the appropriate log records are on disk. */ - if (LOGGING_ON(dbenv) && !IS_RECOVERING(dbenv) && mfp->lsn_off != -1 && - (!F_ISSET(bhp, BH_SYNC) || F_ISSET(bhp, BH_SYNC_LOGFLSH))) { + if (LOGGING_ON(dbenv) && mfp->lsn_off != -1) { memcpy(&lsn, bhp->buf + mfp->lsn_off, sizeof(DB_LSN)); if ((ret = dbenv->log_flush(dbenv, &lsn)) != 0) goto err; @@ -361,7 +340,7 @@ __memp_pgwrite(dbmp, dbmfp, bhp, restartp, wrotep) * !!! * One special case. There is a single field on the meta-data page, * the last-page-number-in-the-file field, for which we do not log - * changes. So, if the page was original created in a database that + * changes. If the page was originally created in a database that * didn't have logging turned on, we can see a page marked dirty but * for which no corresponding log record has been written. However, * the only way that a page can be created for which there isn't a @@ -394,9 +373,7 @@ __memp_pgwrite(dbmp, dbmfp, bhp, restartp, wrotep) * that the contents of the buffer will need to be passed through pgin * before they are reused. */ - if (mfp->ftype == 0) - ret = 0; - else { + if (mfp->ftype != 0) { callpgin = 1; if ((ret = __memp_pg(dbmfp, bhp, 0)) != 0) goto err; @@ -405,17 +382,16 @@ __memp_pgwrite(dbmp, dbmfp, bhp, restartp, wrotep) /* Temporary files may not yet have been created. */ if (!F_ISSET(dbmfp->fhp, DB_FH_VALID)) { MUTEX_THREAD_LOCK(dbenv, dbmp->mutexp); - if (!F_ISSET(dbmfp->fhp, DB_FH_VALID) && - ((ret = __db_appname(dbenv, DB_APP_TMP, NULL, NULL, - DB_OSO_CREATE | DB_OSO_EXCL | DB_OSO_TEMP, - dbmfp->fhp, NULL)) != 0 || - !F_ISSET(dbmfp->fhp, DB_FH_VALID))) { - MUTEX_THREAD_UNLOCK(dbenv, dbmp->mutexp); + ret = F_ISSET(dbmfp->fhp, DB_FH_VALID) ? 0 : + __db_appname(dbenv, DB_APP_TMP, NULL, + F_ISSET(dbenv, DB_ENV_DIRECT_DB) ? DB_OSO_DIRECT : 0, + dbmfp->fhp, NULL); + MUTEX_THREAD_UNLOCK(dbenv, dbmp->mutexp); + if (ret != 0) { __db_err(dbenv, "unable to create temporary backing file"); goto err; } - MUTEX_THREAD_UNLOCK(dbenv, dbmp->mutexp); } /* Write the page. */ @@ -425,104 +401,44 @@ __memp_pgwrite(dbmp, dbmfp, bhp, restartp, wrotep) db_io.pgno = bhp->pgno; db_io.buf = bhp->buf; if ((ret = __os_io(dbenv, &db_io, DB_IO_WRITE, &nw)) != 0) { - fail = "write"; - goto syserr; - } - if (nw != mfp->stat.st_pagesize) { - ret = EIO; - fail = "write"; - goto syserr; + __db_err(dbenv, "%s: write failed for page %lu", + __memp_fn(dbmfp), (u_long)bhp->pgno); + goto err; } + ++mfp->stat.st_page_out; +err: file_dead: /* * !!! * Once we pass this point, dbmfp and mfp may be NULL, we may not have * a valid file reference. * - * Unlock the buffer and reacquire the region lock. + * Unlock the buffer and reacquire the hash lock. */ MUTEX_UNLOCK(dbenv, &bhp->mutex); - R_LOCK(dbenv, dbmp->reginfo); + MUTEX_LOCK(dbenv, &hp->hash_mutex); /* - * Clean up the flags based on a successful write. - * * If we rewrote the page, it will need processing by the pgin * routine before reuse. */ if (callpgin) F_SET(bhp, BH_CALLPGIN); - F_CLR(bhp, BH_DIRTY | BH_DIRTY_CREATE | BH_LOCKED); /* - * If we write a buffer for which a checkpoint is waiting, update - * the count of pending buffers (both in the mpool as a whole and - * for this file). If the count for this file goes to zero, set a - * flag so we flush the writes. + * Update the hash bucket statistics, reset the flags. + * If we were successful, the page is no longer dirty. */ - dosync = 0; - if (F_ISSET(bhp, BH_SYNC)) { - F_CLR(bhp, BH_SYNC | BH_SYNC_LOGFLSH); - - --mp->lsn_cnt; - if (mfp != NULL) - dosync = --mfp->lsn_cnt == 0 ? 1 : 0; - } - - /* Update the page clean/dirty statistics. */ - c_mp = BH_TO_CACHE(dbmp, bhp); - ++c_mp->stat.st_page_clean; - DB_ASSERT(c_mp->stat.st_page_dirty != 0); - --c_mp->stat.st_page_dirty; - - /* Update I/O statistics. */ - if (mfp != NULL) - ++mfp->stat.st_page_out; + if (ret == 0) { + DB_ASSERT(hp->hash_page_dirty != 0); + --hp->hash_page_dirty; - /* - * Do the sync after everything else has been updated, so any incoming - * checkpoint doesn't see inconsistent information. - * - * XXX: - * Don't lock the region around the sync, fsync(2) has no atomicity - * issues. - * - * XXX: - * We ignore errors from the sync -- it makes no sense to return an - * error to the calling process, so set a flag causing the checkpoint - * to be retried later. There is a possibility, of course, that a - * subsequent checkpoint was started and that we're going to force it - * to fail. That should be unlikely, and fixing it would be difficult. - */ - if (dosync) { - R_UNLOCK(dbenv, dbmp->reginfo); - syncfail = __os_fsync(dbenv, dbmfp->fhp) != 0; - R_LOCK(dbenv, dbmp->reginfo); - if (syncfail) - F_SET(mp, MP_LSN_RETRY); + F_CLR(bhp, BH_DIRTY | BH_DIRTY_CREATE); } - if (wrotep != NULL) - *wrotep = 1; - - return (0); - -syserr: __db_err(dbenv, "%s: %s failed for page %lu", - __memp_fn(dbmfp), fail, (u_long)bhp->pgno); - -err: /* Unlock the buffer and reacquire the region lock. */ - MUTEX_UNLOCK(dbenv, &bhp->mutex); - R_LOCK(dbenv, dbmp->reginfo); - - /* - * Clean up the flags based on a failure. - * - * The page remains dirty but we remove our lock. If we rewrote the - * page, it will need processing by the pgin routine before reuse. - */ - if (callpgin) - F_SET(bhp, BH_CALLPGIN); + /* Regardless, clear any sync wait-for count and remove our lock. */ + bhp->ref_sync = 0; F_CLR(bhp, BH_LOCKED); return (ret); @@ -541,15 +457,17 @@ __memp_pg(dbmfp, bhp, is_pgin) int is_pgin; { DBT dbt, *dbtp; + DB_ENV *dbenv; DB_MPOOL *dbmp; DB_MPREG *mpreg; MPOOLFILE *mfp; int ftype, ret; dbmp = dbmfp->dbmp; + dbenv = dbmp->dbenv; mfp = dbmfp->mfp; - MUTEX_THREAD_LOCK(dbmp->dbenv, dbmp->mutexp); + MUTEX_THREAD_LOCK(dbenv, dbmp->mutexp); ftype = mfp->ftype; for (mpreg = LIST_FIRST(&dbmp->dbregq); @@ -563,28 +481,28 @@ __memp_pg(dbmfp, bhp, is_pgin) dbt.data = R_ADDR(dbmp->reginfo, mfp->pgcookie_off); dbtp = &dbt; } - MUTEX_THREAD_UNLOCK(dbmp->dbenv, dbmp->mutexp); + MUTEX_THREAD_UNLOCK(dbenv, dbmp->mutexp); if (is_pgin) { if (mpreg->pgin != NULL && - (ret = mpreg->pgin(dbmp->dbenv, + (ret = mpreg->pgin(dbenv, bhp->pgno, bhp->buf, dbtp)) != 0) goto err; } else if (mpreg->pgout != NULL && - (ret = mpreg->pgout(dbmp->dbenv, + (ret = mpreg->pgout(dbenv, bhp->pgno, bhp->buf, dbtp)) != 0) goto err; break; } if (mpreg == NULL) - MUTEX_THREAD_UNLOCK(dbmp->dbenv, dbmp->mutexp); + MUTEX_THREAD_UNLOCK(dbenv, dbmp->mutexp); return (0); -err: MUTEX_THREAD_UNLOCK(dbmp->dbenv, dbmp->mutexp); - __db_err(dbmp->dbenv, "%s: %s failed for page %lu", +err: MUTEX_THREAD_UNLOCK(dbenv, dbmp->mutexp); + __db_err(dbenv, "%s: %s failed for page %lu", __memp_fn(dbmfp), is_pgin ? "pgin" : "pgout", (u_long)bhp->pgno); return (ret); } @@ -593,56 +511,78 @@ err: MUTEX_THREAD_UNLOCK(dbmp->dbenv, dbmp->mutexp); * __memp_bhfree -- * Free a bucket header and its referenced data. * - * PUBLIC: void __memp_bhfree __P((DB_MPOOL *, BH *, int)); + * PUBLIC: void __memp_bhfree __P((DB_MPOOL *, DB_MPOOL_HASH *, BH *, int)); */ void -__memp_bhfree(dbmp, bhp, free_mem) +__memp_bhfree(dbmp, hp, bhp, free_mem) DB_MPOOL *dbmp; + DB_MPOOL_HASH *hp; BH *bhp; int free_mem; { - DB_HASHTAB *dbht; + DB_ENV *dbenv; MPOOL *c_mp, *mp; MPOOLFILE *mfp; - int n_bucket, n_cache; + u_int32_t n_cache; + /* + * Assumes the hash bucket is locked and the MPOOL is not. + */ + dbenv = dbmp->dbenv; mp = dbmp->reginfo[0].primary; - c_mp = BH_TO_CACHE(dbmp, bhp); - n_cache = NCACHE(mp, bhp->pgno); - n_bucket = NBUCKET(c_mp, bhp->mf_offset, bhp->pgno); - dbht = R_ADDR(&dbmp->reginfo[n_cache], c_mp->htab); + n_cache = NCACHE(mp, bhp->mf_offset, bhp->pgno); - /* Delete the buffer header from the hash bucket queue. */ - SH_TAILQ_REMOVE(&dbht[n_bucket], bhp, hq, __bh); + /* + * Delete the buffer header from the hash bucket queue and reset + * the hash bucket's priority, if necessary. + */ + SH_TAILQ_REMOVE(&hp->hash_bucket, bhp, hq, __bh); + if (bhp->priority == hp->hash_priority) + hp->hash_priority = + SH_TAILQ_FIRST(&hp->hash_bucket, __bh) == NULL ? + 0 : SH_TAILQ_FIRST(&hp->hash_bucket, __bh)->priority; - /* Delete the buffer header from the LRU queue. */ - SH_TAILQ_REMOVE(&c_mp->bhq, bhp, q, __bh); + /* + * Discard the hash bucket's mutex, it's no longer needed, and + * we don't want to be holding it when acquiring other locks. + */ + MUTEX_UNLOCK(dbenv, &hp->hash_mutex); - /* Clear the mutex this buffer recorded */ - __db_shlocks_clear(&bhp->mutex, &dbmp->reginfo[n_cache], - (REGMAINT *)R_ADDR(&dbmp->reginfo[n_cache], mp->maint_off)); /* * Find the underlying MPOOLFILE and decrement its reference count. * If this is its last reference, remove it. */ mfp = R_ADDR(dbmp->reginfo, bhp->mf_offset); + MUTEX_LOCK(dbenv, &mfp->mutex); if (--mfp->block_cnt == 0 && mfp->mpf_cnt == 0) __memp_mf_discard(dbmp, mfp); + else + MUTEX_UNLOCK(dbenv, &mfp->mutex); - DB_ASSERT(c_mp->stat.st_page_clean != 0); - --c_mp->stat.st_page_clean; + R_LOCK(dbenv, &dbmp->reginfo[n_cache]); + + /* + * Clear the mutex this buffer recorded; requires the region lock + * be held. + */ + __db_shlocks_clear(&bhp->mutex, &dbmp->reginfo[n_cache], + (REGMAINT *)R_ADDR(&dbmp->reginfo[n_cache], mp->maint_off)); /* - * If we're not reusing it immediately, free the buffer header + * If we're not reusing the buffer immediately, free the buffer header * and data for real. */ - if (free_mem) + if (free_mem) { __db_shalloc_free(dbmp->reginfo[n_cache].addr, bhp); + c_mp = dbmp->reginfo[n_cache].primary; + c_mp->stat.st_pages--; + } + R_UNLOCK(dbenv, &dbmp->reginfo[n_cache]); } /* * __memp_upgrade -- - * Upgrade a file descriptor from readonly to readwrite. + * Upgrade a file descriptor from read-only to read-write. */ static int __memp_upgrade(dbmp, dbmfp, mfp) @@ -650,41 +590,58 @@ __memp_upgrade(dbmp, dbmfp, mfp) DB_MPOOLFILE *dbmfp; MPOOLFILE *mfp; { - DB_FH fh; + DB_ENV *dbenv; + DB_FH *fhp, *tfhp; int ret; char *rpath; - /* - * !!! - * We expect the handle to already be locked. - */ - - /* Check to see if we've already upgraded. */ - if (F_ISSET(dbmfp, MP_UPGRADE)) - return (0); - - /* Check to see if we've already failed. */ - if (F_ISSET(dbmfp, MP_UPGRADE_FAIL)) - return (1); + dbenv = dbmp->dbenv; + fhp = NULL; + rpath = NULL; /* * Calculate the real name for this file and try to open it read/write. * We know we have a valid pathname for the file because it's the only * way we could have gotten a file descriptor of any kind. */ - if ((ret = __db_appname(dbmp->dbenv, DB_APP_DATA, - NULL, R_ADDR(dbmp->reginfo, mfp->path_off), 0, NULL, &rpath)) != 0) - return (ret); - if (__os_open(dbmp->dbenv, rpath, 0, 0, &fh) != 0) { + if ((ret = __os_calloc(dbenv, 1, sizeof(DB_FH), &fhp)) != 0) + goto err; + + if ((ret = __db_appname(dbenv, DB_APP_DATA, + R_ADDR(dbmp->reginfo, mfp->path_off), 0, NULL, &rpath)) != 0) + goto err; + + if (__os_open(dbenv, rpath, + F_ISSET(mfp, MP_DIRECT) ? DB_OSO_DIRECT : 0, 0, fhp) != 0) { F_SET(dbmfp, MP_UPGRADE_FAIL); - ret = 1; - } else { - /* Swap the descriptors and set the upgrade flag. */ - (void)__os_closehandle(dbmfp->fhp); - *dbmfp->fhp = fh; - F_SET(dbmfp, MP_UPGRADE); - ret = 0; + goto err; } - __os_freestr(dbmp->dbenv, rpath); + + /* + * Swap the descriptors and set the upgrade flag. + * + * XXX + * There is a race here. If another process schedules a read using the + * existing file descriptor and is swapped out before making the system + * call, this code could theoretically close the file descriptor out + * from under it. While it's very unlikely, this code should still be + * rewritten. + */ + tfhp = dbmfp->fhp; + dbmfp->fhp = fhp; + fhp = tfhp; + + (void)__os_closehandle(dbenv, fhp); + F_SET(dbmfp, MP_UPGRADE); + + ret = 0; + if (0) { +err: ret = 1; + } + if (fhp != NULL) + __os_free(dbenv, fhp); + if (rpath != NULL) + __os_free(dbenv, rpath); + return (ret); } diff --git a/db/mp/mp_fopen.c b/db/mp/mp_fopen.c index bb3937e10..7209bf066 100644 --- a/db/mp/mp_fopen.c +++ b/db/mp/mp_fopen.c @@ -1,13 +1,13 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1996-2001 + * Copyright (c) 1996-2002 * Sleepycat Software. All rights reserved. */ #include "db_config.h" #ifndef lint -static const char revid[] = "Id: mp_fopen.c,v 11.60 2001/10/04 21:26:56 bostic Exp "; +static const char revid[] = "Id: mp_fopen.c,v 11.88 2002/07/01 15:05:30 bostic Exp "; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -17,14 +17,13 @@ static const char revid[] = "Id: mp_fopen.c,v 11.60 2001/10/04 21:26:56 bostic E #endif #include "db_int.h" -#include "db_shash.h" -#include "mp.h" +#include "dbinc/db_shash.h" +#include "dbinc/mp.h" static int __memp_fclose __P((DB_MPOOLFILE *, u_int32_t)); static int __memp_fopen __P((DB_MPOOLFILE *, const char *, u_int32_t, int, size_t)); -static int __memp_mf_open __P((DB_MPOOLFILE *, - const char *, size_t, db_pgno_t, u_int32_t, MPOOLFILE **)); +static void __memp_get_fileid __P((DB_MPOOLFILE *, u_int8_t *)); static void __memp_last_pgno __P((DB_MPOOLFILE *, db_pgno_t *)); static void __memp_refcnt __P((DB_MPOOLFILE *, db_pgno_t *)); static int __memp_set_clear_len __P((DB_MPOOLFILE *, u_int32_t)); @@ -32,21 +31,9 @@ static int __memp_set_fileid __P((DB_MPOOLFILE *, u_int8_t *)); static int __memp_set_ftype __P((DB_MPOOLFILE *, int)); static int __memp_set_lsn_offset __P((DB_MPOOLFILE *, int32_t)); static int __memp_set_pgcookie __P((DB_MPOOLFILE *, DBT *)); +static int __memp_set_priority __P((DB_MPOOLFILE *, DB_CACHE_PRIORITY)); static void __memp_set_unlink __P((DB_MPOOLFILE *, int)); -/* - * MEMP_FREMOVE -- - * Discard an MPOOLFILE and any buffers it references: update the flags - * so we never try to write buffers associated with the file, nor can we - * find it when looking for files to join. In addition, clear the ftype - * field, there's no reason to post-process pages, they can be discarded - * by any thread. - */ -#define MEMP_FREMOVE(mfp) { \ - mfp->ftype = 0; \ - F_SET(mfp, MP_DEADFILE); \ -} - /* Initialization methods cannot be called after open is called. */ #define MPF_ILLEGAL_AFTER_OPEN(dbmfp, name) \ if (F_ISSET(dbmfp, MP_OPEN_CALLED)) \ @@ -81,32 +68,23 @@ __memp_fcreate(dbenv, retp, flags) /* Allocate and initialize the per-process structure. */ if ((ret = __os_calloc(dbenv, 1, sizeof(DB_MPOOLFILE), &dbmfp)) != 0) return (ret); - if ((ret = __os_calloc(dbenv, 1, sizeof(DB_FH), &dbmfp->fhp)) != 0) { - __os_free(dbenv, dbmfp, sizeof(DB_MPOOLFILE)); - return (ret); - } + if ((ret = __os_calloc(dbenv, 1, sizeof(DB_FH), &dbmfp->fhp)) != 0) + goto err; /* Allocate and initialize a mutex if necessary. */ - if (F_ISSET(dbenv, DB_ENV_THREAD)) { - if ((ret = __db_mutex_alloc( - dbenv, dbmp->reginfo, 0, &dbmfp->mutexp)) != 0) - return (ret); - - if ((ret = __db_shmutex_init(dbenv, dbmfp->mutexp, 0, - MUTEX_THREAD, dbmp->reginfo, - (REGMAINT *)R_ADDR(dbmp->reginfo, - ((MPOOL *)dbmp->reginfo->primary)->maint_off))) != 0) { - __db_mutex_free(dbenv, dbmp->reginfo, dbmfp->mutexp); - return (ret); - } - } + if (F_ISSET(dbenv, DB_ENV_THREAD) && + (ret = __db_mutex_setup(dbenv, dbmp->reginfo, &dbmfp->mutexp, + MUTEX_ALLOC | MUTEX_THREAD)) != 0) + goto err; dbmfp->ref = 1; dbmfp->lsn_offset = -1; dbmfp->dbmp = dbmp; + dbmfp->mfp = INVALID_ROFF; dbmfp->close = __memp_fclose; dbmfp->get = __memp_fget; + dbmfp->get_fileid = __memp_get_fileid; dbmfp->last_pgno = __memp_last_pgno; dbmfp->open = __memp_fopen; dbmfp->put = __memp_fput; @@ -117,16 +95,19 @@ __memp_fcreate(dbenv, retp, flags) dbmfp->set_ftype = __memp_set_ftype; dbmfp->set_lsn_offset = __memp_set_lsn_offset; dbmfp->set_pgcookie = __memp_set_pgcookie; + dbmfp->set_priority = __memp_set_priority; dbmfp->set_unlink = __memp_set_unlink; dbmfp->sync = __memp_fsync; - /* Add the file to the environment's list of files. */ - MUTEX_THREAD_LOCK(dbenv, dbmp->mutexp); - TAILQ_INSERT_TAIL(&dbmp->dbmfq, dbmfp, q); - MUTEX_THREAD_UNLOCK(dbenv, dbmp->mutexp); - *retp = dbmfp; return (0); + +err: if (dbmfp != NULL) { + if (dbmfp->fhp != NULL) + (void)__os_free(dbenv, dbmfp->fhp); + (void)__os_free(dbenv, dbmfp); + } + return (ret); } /* @@ -168,6 +149,10 @@ __memp_set_ftype(dbmfp, ftype) DB_MPOOLFILE *dbmfp; int ftype; { + DB_ENV *dbenv; + + dbenv = dbmfp->dbmp->dbenv; + MPF_ILLEGAL_AFTER_OPEN(dbmfp, "set_ftype"); dbmfp->ftype = ftype; @@ -205,6 +190,40 @@ __memp_set_pgcookie(dbmfp, pgcookie) } /* + * __memp_set_priority -- + * Set the cache priority for pages from this file. + */ +static int +__memp_set_priority(dbmfp, priority) + DB_MPOOLFILE *dbmfp; + DB_CACHE_PRIORITY priority; +{ + switch (priority) { + case DB_PRIORITY_VERY_LOW: + dbmfp->mfp->priority = MPOOL_PRI_VERY_LOW; + break; + case DB_PRIORITY_LOW: + dbmfp->mfp->priority = MPOOL_PRI_LOW; + break; + case DB_PRIORITY_DEFAULT: + dbmfp->mfp->priority = MPOOL_PRI_DEFAULT; + break; + case DB_PRIORITY_HIGH: + dbmfp->mfp->priority = MPOOL_PRI_HIGH; + break; + case DB_PRIORITY_VERY_HIGH: + dbmfp->mfp->priority = MPOOL_PRI_VERY_HIGH; + break; + default: + __db_err(dbmfp->dbmp->dbenv, + "Unknown priority value: %d", priority); + return (EINVAL); + } + + return (0); +} + +/* * __memp_fopen -- * Open a backing file for the memory pool. */ @@ -227,7 +246,7 @@ __memp_fopen(dbmfp, path, flags, mode, pagesize) /* Validate arguments. */ if ((ret = __db_fchk(dbenv, "memp_fopen", flags, - DB_CREATE | DB_EXTENT | + DB_CREATE | DB_DIRECT | DB_EXTENT | DB_NOMMAP | DB_ODDFILESIZE | DB_RDONLY | DB_TRUNCATE)) != 0) return (ret); @@ -242,26 +261,18 @@ __memp_fopen(dbmfp, path, flags, mode, pagesize) } if (dbmfp->clear_len > pagesize) { __db_err(dbenv, - "memp_fopen: clear length larger than page size."); + "memp_fopen: clear length larger than page size"); return (EINVAL); } /* Read-only checks, and local flag. */ - if (LF_ISSET(DB_RDONLY)) { - if (path == NULL) { - __db_err(dbenv, - "memp_fopen: temporary files can't be readonly"); - return (EINVAL); - } - F_SET(dbmfp, MP_READONLY); + if (LF_ISSET(DB_RDONLY) && path == NULL) { + __db_err(dbenv, + "memp_fopen: temporary files can't be readonly"); + return (EINVAL); } - if ((ret = __memp_fopen_int( - dbmfp, NULL, path, flags, mode, pagesize, 1)) != 0) - return (ret); - - F_SET(dbmfp, MP_OPEN_CALLED); - return (0); + return (__memp_fopen_int(dbmfp, NULL, path, flags, mode, pagesize)); } /* @@ -269,51 +280,199 @@ __memp_fopen(dbmfp, path, flags, mode, pagesize) * Open a backing file for the memory pool; internal version. * * PUBLIC: int __memp_fopen_int __P((DB_MPOOLFILE *, - * PUBLIC: MPOOLFILE *, const char *, u_int32_t, int, size_t, int)); + * PUBLIC: MPOOLFILE *, const char *, u_int32_t, int, size_t)); */ int -__memp_fopen_int(dbmfp, mfp, path, flags, mode, pagesize, needlock) +__memp_fopen_int(dbmfp, mfp, path, flags, mode, pagesize) DB_MPOOLFILE *dbmfp; MPOOLFILE *mfp; const char *path; u_int32_t flags; - int mode, needlock; + int mode; size_t pagesize; { DB_ENV *dbenv; DB_MPOOL *dbmp; + MPOOL *mp; db_pgno_t last_pgno; size_t maxmap; u_int32_t mbytes, bytes, oflags; - int ret; + int mfp_alloc, ret; u_int8_t idbuf[DB_FILE_ID_LEN]; char *rpath; + void *p; dbmp = dbmfp->dbmp; dbenv = dbmp->dbenv; - ret = 0; + mp = dbmp->reginfo[0].primary; + mfp_alloc = ret = 0; rpath = NULL; + /* + * Set the page size so os_open can decide whether to turn buffering + * off if the DB_DIRECT_DB flag is set. + */ + dbmfp->fhp->pagesize = (u_int32_t)pagesize; + + /* + * If it's a temporary file, delay the open until we actually need + * to write the file, and we know we can't join any existing files. + */ if (path == NULL) - last_pgno = 0; - else { - /* Get the real name for this file and open it. */ - if ((ret = __db_appname(dbenv, - DB_APP_DATA, NULL, path, 0, NULL, &rpath)) != 0) + goto alloc; + + /* + * Get the real name for this file and open it. If it's a Queue extent + * file, it may not exist, and that's OK. + */ + oflags = 0; + if (LF_ISSET(DB_CREATE)) + oflags |= DB_OSO_CREATE; + if (LF_ISSET(DB_DIRECT)) + oflags |= DB_OSO_DIRECT; + if (LF_ISSET(DB_RDONLY)) { + F_SET(dbmfp, MP_READONLY); + oflags |= DB_OSO_RDONLY; + } + if ((ret = + __db_appname(dbenv, DB_APP_DATA, path, 0, NULL, &rpath)) != 0) + goto err; + if ((ret = __os_open(dbenv, rpath, oflags, mode, dbmfp->fhp)) != 0) { + if (!LF_ISSET(DB_EXTENT)) + __db_err(dbenv, "%s: %s", rpath, db_strerror(ret)); + goto err; + } + + /* + * Get the file id if we weren't given one. Generated file id's + * don't use timestamps, otherwise there'd be no chance of any + * other process joining the party. + */ + if (dbmfp->fileid == NULL) { + if ((ret = __os_fileid(dbenv, rpath, 0, idbuf)) != 0) goto err; - oflags = 0; - if (LF_ISSET(DB_CREATE)) - oflags |= DB_OSO_CREATE; - if (LF_ISSET(DB_RDONLY)) - oflags |= DB_OSO_RDONLY; - if ((ret = - __os_open(dbenv, rpath, oflags, mode, dbmfp->fhp)) != 0) { - if (!LF_ISSET(DB_EXTENT)) - __db_err(dbenv, - "%s: %s", rpath, db_strerror(ret)); + dbmfp->fileid = idbuf; + } + + /* + * If our caller knows what mfp we're using, increment the ref count, + * no need to search. + * + * We don't need to acquire a lock other than the mfp itself, because + * we know there's another reference and it's not going away. + */ + if (mfp != NULL) { + MUTEX_LOCK(dbenv, &mfp->mutex); + ++mfp->mpf_cnt; + MUTEX_UNLOCK(dbenv, &mfp->mutex); + goto check_map; + } + + /* + * If not creating a temporary file, walk the list of MPOOLFILE's, + * looking for a matching file. Files backed by temporary files + * or previously removed files can't match. + * + * DB_TRUNCATE support. + * + * The fileID is a filesystem unique number (e.g., a UNIX dev/inode + * pair) plus a timestamp. If files are removed and created in less + * than a second, the fileID can be repeated. The problem with + * repetition happens when the file that previously had the fileID + * value still has pages in the pool, since we don't want to use them + * to satisfy requests for the new file. + * + * Because the DB_TRUNCATE flag reuses the dev/inode pair, repeated + * opens with that flag set guarantees matching fileIDs when the + * machine can open a file and then re-open with truncate within a + * second. For this reason, we pass that flag down, and, if we find + * a matching entry, we ensure that it's never found again, and we + * create a new entry for the current request. + */ + R_LOCK(dbenv, dbmp->reginfo); + for (mfp = SH_TAILQ_FIRST(&mp->mpfq, __mpoolfile); + mfp != NULL; mfp = SH_TAILQ_NEXT(mfp, q, __mpoolfile)) { + /* Skip dead files and temporary files. */ + if (F_ISSET(mfp, MP_DEADFILE | MP_TEMP)) + continue; + + /* Skip non-matching files. */ + if (memcmp(dbmfp->fileid, R_ADDR(dbmp->reginfo, + mfp->fileid_off), DB_FILE_ID_LEN) != 0) + continue; + + /* + * If the file is being truncated, remove it from the system + * and create a new entry. + * + * !!! + * We should be able to set mfp to NULL and break out of the + * loop, but I like the idea of checking all the entries. + */ + if (LF_ISSET(DB_TRUNCATE)) { + MUTEX_LOCK(dbenv, &mfp->mutex); + MPOOLFILE_IGNORE(mfp); + MUTEX_UNLOCK(dbenv, &mfp->mutex); + continue; + } + + /* + * Some things about a file cannot be changed: the clear length, + * page size, or lSN location. + * + * The file type can change if the application's pre- and post- + * processing needs change. For example, an application that + * created a hash subdatabase in a database that was previously + * all btree. + * + * XXX + * We do not check to see if the pgcookie information changed, + * or update it if it is, this might be a bug. + */ + if (dbmfp->clear_len != mfp->clear_len || + pagesize != mfp->stat.st_pagesize || + dbmfp->lsn_offset != mfp->lsn_off) { + __db_err(dbenv, + "%s: clear length, page size or LSN location changed", + path); + R_UNLOCK(dbenv, dbmp->reginfo); + ret = EINVAL; goto err; } + if (dbmfp->ftype != 0) + mfp->ftype = dbmfp->ftype; + + MUTEX_LOCK(dbenv, &mfp->mutex); + ++mfp->mpf_cnt; + MUTEX_UNLOCK(dbenv, &mfp->mutex); + break; + } + R_UNLOCK(dbenv, dbmp->reginfo); + + if (mfp != NULL) + goto check_map; + +alloc: /* Allocate and initialize a new MPOOLFILE. */ + if ((ret = __memp_alloc( + dbmp, dbmp->reginfo, NULL, sizeof(MPOOLFILE), NULL, &mfp)) != 0) + goto err; + mfp_alloc = 1; + memset(mfp, 0, sizeof(MPOOLFILE)); + mfp->mpf_cnt = 1; + mfp->ftype = dbmfp->ftype; + mfp->stat.st_pagesize = pagesize; + mfp->lsn_off = dbmfp->lsn_offset; + mfp->clear_len = dbmfp->clear_len; + + if (LF_ISSET(DB_DIRECT)) + F_SET(mfp, MP_DIRECT); + if (LF_ISSET(DB_EXTENT)) + F_SET(mfp, MP_EXTENT); + + if (path == NULL) + F_SET(mfp, MP_TEMP); + else { /* * Don't permit files that aren't a multiple of the pagesize, * and find the number of the last page in the file, all the @@ -327,79 +486,84 @@ __memp_fopen_int(dbmfp, mfp, path, flags, mode, pagesize, needlock) * environments where an off_t is 32-bits, but still run where * offsets are 64-bits, and they pay us a lot of money. */ - if ((ret = __os_ioinfo(dbenv, rpath, - dbmfp->fhp, &mbytes, &bytes, NULL)) != 0) { + if ((ret = __os_ioinfo( + dbenv, rpath, dbmfp->fhp, &mbytes, &bytes, NULL)) != 0) { __db_err(dbenv, "%s: %s", rpath, db_strerror(ret)); goto err; } /* - * If we're doing a verify, we might have to cope with - * a truncated file; if the file size is not a multiple - * of the page size, round down to a page -- we'll - * take care of the partial page outside the memp system. + * During verify or recovery, we might have to cope with a + * truncated file; if the file size is not a multiple of the + * page size, round down to a page, we'll take care of the + * partial page outside the mpool system. */ if (bytes % pagesize != 0) { if (LF_ISSET(DB_ODDFILESIZE)) - /* - * During verify or recovery, we might have - * to cope with a truncated file; round down, - * we'll worry about the partial page outside - * the memp system. - */ - bytes -= (bytes % pagesize); + bytes -= (u_int32_t)(bytes % pagesize); else { __db_err(dbenv, - "%s: file size not a multiple of the pagesize", - rpath); + "%s: file size not a multiple of the pagesize", rpath); ret = EINVAL; goto err; } } - last_pgno = mbytes * (MEGABYTE / pagesize); - last_pgno += bytes / pagesize; - - /* Correction: page numbers are zero-based, not 1-based. */ + /* + * If the user specifies DB_MPOOL_LAST or DB_MPOOL_NEW on a + * page get, we have to increment the last page in the file. + * Figure it out and save it away. + * + * Note correction: page numbers are zero-based, not 1-based. + */ + last_pgno = (db_pgno_t)(mbytes * (MEGABYTE / pagesize)); + last_pgno += (db_pgno_t)(bytes / pagesize); if (last_pgno != 0) --last_pgno; + mfp->orig_last_pgno = mfp->last_pgno = last_pgno; - /* - * Get the file id if we weren't given one. Generated file id's - * don't use timestamps, otherwise there'd be no chance of any - * other process joining the party. - */ - if (dbmfp->fileid == NULL) { - if ((ret = __os_fileid(dbenv, rpath, 0, idbuf)) != 0) - goto err; - dbmfp->fileid = idbuf; - } + /* Copy the file path into shared memory. */ + if ((ret = __memp_alloc(dbmp, dbmp->reginfo, + NULL, strlen(path) + 1, &mfp->path_off, &p)) != 0) + goto err; + memcpy(p, path, strlen(path) + 1); + + /* Copy the file identification string into shared memory. */ + if ((ret = __memp_alloc(dbmp, dbmp->reginfo, + NULL, DB_FILE_ID_LEN, &mfp->fileid_off, &p)) != 0) + goto err; + memcpy(p, dbmfp->fileid, DB_FILE_ID_LEN); + } + + /* Copy the page cookie into shared memory. */ + if (dbmfp->pgcookie == NULL || dbmfp->pgcookie->size == 0) { + mfp->pgcookie_len = 0; + mfp->pgcookie_off = 0; + } else { + if ((ret = __memp_alloc(dbmp, dbmp->reginfo, + NULL, dbmfp->pgcookie->size, &mfp->pgcookie_off, &p)) != 0) + goto err; + memcpy(p, dbmfp->pgcookie->data, dbmfp->pgcookie->size); + mfp->pgcookie_len = dbmfp->pgcookie->size; } /* - * If we weren't provided an underlying shared object to join with, - * find/allocate the shared file objects. Also allocate space for - * for the per-process thread lock. + * Prepend the MPOOLFILE to the list of MPOOLFILE's. */ - if (needlock) - R_LOCK(dbenv, dbmp->reginfo); - if (mfp == NULL) - ret = __memp_mf_open( - dbmfp, path, pagesize, last_pgno, flags, &mfp); - else { - ++mfp->mpf_cnt; - ret = 0; - } - dbmfp->mfp = mfp; - if (needlock) - R_UNLOCK(dbenv, dbmp->reginfo); + R_LOCK(dbenv, dbmp->reginfo); + ret = __db_mutex_setup(dbenv, dbmp->reginfo, &mfp->mutex, + MUTEX_NO_RLOCK); + if (ret == 0) + SH_TAILQ_INSERT_HEAD(&mp->mpfq, mfp, q, __mpoolfile); + R_UNLOCK(dbenv, dbmp->reginfo); if (ret != 0) goto err; +check_map: /* * If a file: - * + is read-only * + isn't temporary + * + is read-only * + doesn't require any pgin/pgout support * + the DB_NOMMAP flag wasn't set (in either the file open or * the environment in which it was opened) @@ -411,7 +575,6 @@ __memp_fopen_int(dbmfp, mfp, path, flags, mode, pagesize, needlock) * NFS mounted partition, and we can fail in buffer I/O just as easily * as here. * - * XXX * We'd like to test to see if the file is too big to mmap. Since we * don't know what size or type off_t's or size_t's are, or the largest * unsigned integral type is, or what random insanity the local C @@ -420,10 +583,10 @@ __memp_fopen_int(dbmfp, mfp, path, flags, mode, pagesize, needlock) */ #define DB_MAXMMAPSIZE (10 * 1024 * 1024) /* 10 Mb. */ if (F_ISSET(mfp, MP_CAN_MMAP)) { - if (!F_ISSET(dbmfp, MP_READONLY)) - F_CLR(mfp, MP_CAN_MMAP); if (path == NULL) F_CLR(mfp, MP_CAN_MMAP); + if (!F_ISSET(dbmfp, MP_READONLY)) + F_CLR(mfp, MP_CAN_MMAP); if (dbmfp->ftype != 0) F_CLR(mfp, MP_CAN_MMAP); if (LF_ISSET(DB_NOMMAP) || F_ISSET(dbenv, DB_ENV_NOMMAP)) @@ -433,179 +596,72 @@ __memp_fopen_int(dbmfp, mfp, path, flags, mode, pagesize, needlock) if (mbytes > maxmap / MEGABYTE || (mbytes == maxmap / MEGABYTE && bytes >= maxmap % MEGABYTE)) F_CLR(mfp, MP_CAN_MMAP); - } - dbmfp->addr = NULL; - if (F_ISSET(mfp, MP_CAN_MMAP)) { - dbmfp->len = (size_t)mbytes * MEGABYTE + bytes; - if (__os_mapfile(dbenv, rpath, - dbmfp->fhp, dbmfp->len, 1, &dbmfp->addr) != 0) { - dbmfp->addr = NULL; - F_CLR(mfp, MP_CAN_MMAP); + + dbmfp->addr = NULL; + if (F_ISSET(mfp, MP_CAN_MMAP)) { + dbmfp->len = (size_t)mbytes * MEGABYTE + bytes; + if (__os_mapfile(dbenv, rpath, + dbmfp->fhp, dbmfp->len, 1, &dbmfp->addr) != 0) { + dbmfp->addr = NULL; + F_CLR(mfp, MP_CAN_MMAP); + } } } - if (rpath != NULL) - __os_freestr(dbenv, rpath); - return (0); + dbmfp->mfp = mfp; + + F_SET(dbmfp, MP_OPEN_CALLED); -err: if (rpath != NULL) - __os_freestr(dbenv, rpath); - if (F_ISSET(dbmfp->fhp, DB_FH_VALID)) - (void)__os_closehandle(dbmfp->fhp); + /* Add the file to the process' list of DB_MPOOLFILEs. */ + MUTEX_THREAD_LOCK(dbenv, dbmp->mutexp); + TAILQ_INSERT_TAIL(&dbmp->dbmfq, dbmfp, q); + MUTEX_THREAD_UNLOCK(dbenv, dbmp->mutexp); + + if (0) { +err: if (F_ISSET(dbmfp->fhp, DB_FH_VALID)) + (void)__os_closehandle(dbenv, dbmfp->fhp); + + if (mfp_alloc) { + R_LOCK(dbenv, dbmp->reginfo); + if (mfp->path_off != 0) + __db_shalloc_free(dbmp->reginfo[0].addr, + R_ADDR(dbmp->reginfo, mfp->path_off)); + if (mfp->fileid_off != 0) + __db_shalloc_free(dbmp->reginfo[0].addr, + R_ADDR(dbmp->reginfo, mfp->fileid_off)); + __db_shalloc_free(dbmp->reginfo[0].addr, mfp); + R_UNLOCK(dbenv, dbmp->reginfo); + } + + } + if (rpath != NULL) + __os_free(dbenv, rpath); return (ret); } /* - * __memp_mf_open -- - * Open an MPOOLFILE. + * __memp_get_fileid -- + * Return the file ID. + * + * XXX + * Undocumented interface: DB private. */ -static int -__memp_mf_open(dbmfp, path, pagesize, last_pgno, flags, retp) +static void +__memp_get_fileid(dbmfp, fidp) DB_MPOOLFILE *dbmfp; - const char *path; - size_t pagesize; - db_pgno_t last_pgno; - u_int32_t flags; - MPOOLFILE **retp; + u_int8_t *fidp; { - DB_MPOOL *dbmp; - MPOOL *mp; - MPOOLFILE *mfp; - int ret; - void *p; - -#define ISTEMPORARY (path == NULL) - - dbmp = dbmfp->dbmp; - /* - * If not creating a temporary file, walk the list of MPOOLFILE's, - * looking for a matching file. Files backed by temporary files - * or previously removed files can't match. - * - * DB_TRUNCATE support. + * No lock needed -- we're using the handle, it had better not + * be going away. * - * The fileID is a filesystem unique number (e.g., a UNIX dev/inode - * pair) plus a timestamp. If files are removed and created in less - * than a second, the fileID can be repeated. The problem with - * repetition happens when the file that previously had the fileID - * value still has pages in the pool, since we don't want to use them - * to satisfy requests for the new file. - * - * Because the DB_TRUNCATE flag reuses the dev/inode pair, repeated - * opens with that flag set guarantees matching fileIDs when the - * machine can open a file and then re-open with truncate within a - * second. For this reason, we pass that flag down, and, if we find - * a matching entry, we ensure that it's never found again, and we - * create a new entry for the current request. + * !!! + * Get the fileID out of the region, not out of the DB_MPOOLFILE + * structure because the DB_MPOOLFILE reference is possibly short + * lived, and isn't to be trusted. */ - if (!ISTEMPORARY) { - mp = dbmp->reginfo[0].primary; - for (mfp = SH_TAILQ_FIRST(&mp->mpfq, __mpoolfile); - mfp != NULL; mfp = SH_TAILQ_NEXT(mfp, q, __mpoolfile)) { - if (F_ISSET(mfp, MP_DEADFILE | MP_TEMP)) - continue; - if (memcmp(dbmfp->fileid, R_ADDR(dbmp->reginfo, - mfp->fileid_off), DB_FILE_ID_LEN) == 0) { - if (LF_ISSET(DB_TRUNCATE)) { - MEMP_FREMOVE(mfp); - continue; - } - if (dbmfp->clear_len != mfp->clear_len || - pagesize != mfp->stat.st_pagesize) { - __db_err(dbmp->dbenv, - "%s: page size or clear length changed", - path); - return (EINVAL); - } - - /* - * It's possible that our needs for pre- and - * post-processing are changing. For example, - * an application created a hash subdatabase - * in a database that was previously all btree. - */ - if (dbmfp->ftype != 0) - mfp->ftype = dbmfp->ftype; - - ++mfp->mpf_cnt; - - *retp = mfp; - return (0); - } - } - } - - /* Allocate a new MPOOLFILE. */ - if ((ret = __memp_alloc( - dbmp, dbmp->reginfo, NULL, sizeof(MPOOLFILE), NULL, &mfp)) != 0) - goto mem_err; - *retp = mfp; - - /* Initialize the structure. */ - memset(mfp, 0, sizeof(MPOOLFILE)); - mfp->mpf_cnt = 1; - mfp->ftype = dbmfp->ftype; - mfp->lsn_off = dbmfp->lsn_offset; - mfp->clear_len = dbmfp->clear_len; - - /* - * If the user specifies DB_MPOOL_LAST or DB_MPOOL_NEW on a memp_fget, - * we have to know the last page in the file. Figure it out and save - * it away. - */ - mfp->stat.st_pagesize = pagesize; - mfp->orig_last_pgno = mfp->last_pgno = last_pgno; - - if (ISTEMPORARY) - F_SET(mfp, MP_TEMP); - else { - /* Copy the file path into shared memory. */ - if ((ret = __memp_alloc(dbmp, dbmp->reginfo, - NULL, strlen(path) + 1, &mfp->path_off, &p)) != 0) - goto err; - memcpy(p, path, strlen(path) + 1); - - /* Copy the file identification string into shared memory. */ - if ((ret = __memp_alloc(dbmp, dbmp->reginfo, - NULL, DB_FILE_ID_LEN, &mfp->fileid_off, &p)) != 0) - goto err; - memcpy(p, dbmfp->fileid, DB_FILE_ID_LEN); - - F_SET(mfp, MP_CAN_MMAP); - if (LF_ISSET(DB_EXTENT)) - F_SET(mfp, MP_EXTENT); - } - - /* Copy the page cookie into shared memory. */ - if (dbmfp->pgcookie == NULL || dbmfp->pgcookie->size == 0) { - mfp->pgcookie_len = 0; - mfp->pgcookie_off = 0; - } else { - if ((ret = __memp_alloc(dbmp, dbmp->reginfo, - NULL, dbmfp->pgcookie->size, &mfp->pgcookie_off, &p)) != 0) - goto err; - memcpy(p, dbmfp->pgcookie->data, dbmfp->pgcookie->size); - mfp->pgcookie_len = dbmfp->pgcookie->size; - } - - /* Prepend the MPOOLFILE to the list of MPOOLFILE's. */ - mp = dbmp->reginfo[0].primary; - SH_TAILQ_INSERT_HEAD(&mp->mpfq, mfp, q, __mpoolfile); - - if (0) { -err: if (mfp->path_off != 0) - __db_shalloc_free(dbmp->reginfo[0].addr, - R_ADDR(dbmp->reginfo, mfp->path_off)); - if (mfp->fileid_off != 0) - __db_shalloc_free(dbmp->reginfo[0].addr, - R_ADDR(dbmp->reginfo, mfp->fileid_off)); - if (mfp != NULL) - __db_shalloc_free(dbmp->reginfo[0].addr, mfp); -mem_err: __db_err(dbmp->dbenv, - "Unable to allocate memory for mpool file"); - } - return (ret); + memcpy(fidp, R_ADDR( + dbmfp->dbmp->reginfo, dbmfp->mfp->fileid_off), DB_FILE_ID_LEN); } /* @@ -644,14 +700,12 @@ __memp_refcnt(dbmfp, cntp) db_pgno_t *cntp; { DB_ENV *dbenv; - DB_MPOOL *dbmp; - dbmp = dbmfp->dbmp; - dbenv = dbmp->dbenv; + dbenv = dbmfp->dbmp->dbenv; - R_LOCK(dbenv, dbmp->reginfo); + MUTEX_LOCK(dbenv, &dbmfp->mfp->mutex); *cntp = dbmfp->mfp->mpf_cnt; - R_UNLOCK(dbenv, dbmp->reginfo); + MUTEX_UNLOCK(dbenv, &dbmfp->mfp->mutex); } /* @@ -666,26 +720,16 @@ __memp_set_unlink(dbmpf, set) DB_MPOOLFILE *dbmpf; int set; { - DB_MPOOL *dbmp; + DB_ENV *dbenv; - dbmp = dbmpf->dbmp; + dbenv = dbmpf->dbmp->dbenv; - if (set) { - R_LOCK(dbmp->dbenv, dbmp->reginfo); + MUTEX_LOCK(dbenv, &dbmpf->mfp->mutex); + if (set) F_SET(dbmpf->mfp, MP_UNLINK); - R_UNLOCK(dbmp->dbenv, dbmp->reginfo); - } else { - /* - * This bit is protected in the queue code because the metapage - * is locked, so we can avoid getting the region lock. If this - * gets used from other than the queue code, we cannot. - */ - if (F_ISSET(dbmpf->mfp, MP_UNLINK)) { - R_LOCK(dbmp->dbenv, dbmp->reginfo); - F_CLR(dbmpf->mfp, MP_UNLINK); - R_UNLOCK(dbmp->dbenv, dbmp->reginfo); - } - } + else + F_CLR(dbmpf->mfp, MP_UNLINK); + MUTEX_UNLOCK(dbenv, &dbmpf->mfp->mutex); } /* @@ -698,7 +742,7 @@ __memp_fclose(dbmfp, flags) u_int32_t flags; { DB_ENV *dbenv; - int ret; + int ret, t_ret; dbenv = dbmfp->dbmp->dbenv; @@ -708,79 +752,83 @@ __memp_fclose(dbmfp, flags) * XXX * DB_MPOOL_DISCARD: Undocumented flag: DB private. */ - if (flags != 0 && (ret = __db_fchk(dbenv, - "DB_MPOOLFILE->close", flags, DB_MPOOL_DISCARD)) != 0) - return (ret); + ret = __db_fchk(dbenv, "DB_MPOOLFILE->close", flags, DB_MPOOL_DISCARD); + + if ((t_ret = __memp_fclose_int(dbmfp, flags)) != 0 && ret == 0) + ret = t_ret; - return (__memp_fclose_int(dbmfp, flags, 1)); + return (ret); } /* * __memp_fclose_int -- * Internal version of __memp_fclose. * - * PUBLIC: int __memp_fclose_int __P((DB_MPOOLFILE *, u_int32_t, int)); + * PUBLIC: int __memp_fclose_int __P((DB_MPOOLFILE *, u_int32_t)); */ int -__memp_fclose_int(dbmfp, flags, needlock) +__memp_fclose_int(dbmfp, flags) DB_MPOOLFILE *dbmfp; u_int32_t flags; - int needlock; { DB_ENV *dbenv; DB_MPOOL *dbmp; MPOOLFILE *mfp; char *rpath; - int ret, t_ret; + int deleted, ret, t_ret; dbmp = dbmfp->dbmp; dbenv = dbmp->dbenv; ret = 0; /* - * Remove the DB_MPOOLFILE from the queue. This has to happen before - * we perform any action that can fail, otherwise __memp_close may - * loop infinitely when calling us to discard all of the DB_MPOOLFILEs. + * We have to reference count DB_MPOOLFILE structures as other threads + * in the process may be using them. Here's the problem: + * + * Thread A opens a database. + * Thread B uses thread A's DB_MPOOLFILE to write a buffer + * in order to free up memory in the mpool cache. + * Thread A closes the database while thread B is using the + * DB_MPOOLFILE structure. + * + * By opening all databases before creating any threads, and closing + * the databases after all the threads have exited, applications get + * better performance and avoid the problem path entirely. + * + * Regardless, holding the DB_MPOOLFILE to flush a dirty buffer is a + * short-term lock, even in worst case, since we better be the only + * thread of control using the DB_MPOOLFILE structure to read pages + * *into* the cache. Wait until we're the only reference holder and + * remove the DB_MPOOLFILE structure from the list, so nobody else can + * find it. We do this, rather than have the last reference holder + * (whoever that might be) discard the DB_MPOOLFILE structure, because + * we'd rather write error messages to the application in the close + * routine, not in the checkpoint/sync routine. + * + * !!! + * It's possible the DB_MPOOLFILE was never added to the DB_MPOOLFILE + * file list, check the DB_OPEN_CALLED flag to be sure. */ - for (;;) { + for (deleted = 0;;) { MUTEX_THREAD_LOCK(dbenv, dbmp->mutexp); - - /* - * We have to reference count DB_MPOOLFILE structures as other - * threads may be using them. The problem only happens if the - * application makes a bad design choice. Here's the path: - * - * Thread A opens a database. - * Thread B uses thread A's DB_MPOOLFILE to write a buffer - * in order to free up memory in the mpool cache. - * Thread A closes the database while thread B is using the - * DB_MPOOLFILE structure. - * - * By opening all databases before creating the threads, and - * closing them after the threads have exited, applications - * get better performance and avoid the problem path entirely. - * - * Regardless, holding the DB_MPOOLFILE to flush a dirty buffer - * is a short-term lock, even in worst case, since we better be - * the only thread of control using the DB_MPOOLFILE structure - * to read pages *into* the cache. Wait until we're the only - * reference holder and remove the DB_MPOOLFILE structure from - * the list, so nobody else can even find it. - */ if (dbmfp->ref == 1) { - TAILQ_REMOVE(&dbmp->dbmfq, dbmfp, q); - break; + if (F_ISSET(dbmfp, MP_OPEN_CALLED)) + TAILQ_REMOVE(&dbmp->dbmfq, dbmfp, q); + deleted = 1; } MUTEX_THREAD_UNLOCK(dbenv, dbmp->mutexp); - (void)__os_sleep(dbenv, 1, 0); + if (deleted) + break; + __os_sleep(dbenv, 1, 0); } - MUTEX_THREAD_UNLOCK(dbenv, dbmp->mutexp); /* Complain if pinned blocks never returned. */ - if (dbmfp->pinref != 0) + if (dbmfp->pinref != 0) { __db_err(dbenv, "%s: close: %lu blocks left pinned", __memp_fn(dbmfp), (u_long)dbmfp->pinref); + ret = __db_panic(dbenv, DB_RUNRECOVERY); + } /* Discard any mmap information. */ if (dbmfp->addr != NULL && @@ -789,7 +837,7 @@ __memp_fclose_int(dbmfp, flags, needlock) /* Close the file; temporary files may not yet have been created. */ if (F_ISSET(dbmfp->fhp, DB_FH_VALID) && - (t_ret = __os_closehandle(dbmfp->fhp)) != 0) { + (t_ret = __os_closehandle(dbenv, dbmfp->fhp)) != 0) { __db_err(dbenv, "%s: %s", __memp_fn(dbmfp), db_strerror(t_ret)); if (ret == 0) ret = t_ret; @@ -801,41 +849,51 @@ __memp_fclose_int(dbmfp, flags, needlock) /* * Discard our reference on the the underlying MPOOLFILE, and close - * it if it's no longer useful to anyone. - * + * it if it's no longer useful to anyone. It possible the open of + * the file never happened or wasn't successful, in which case, mpf + * will be NULL; + */ + if ((mfp = dbmfp->mfp) == NULL) + goto done; + + /* * If it's a temp file, all outstanding references belong to unflushed * buffers. (A temp file can only be referenced by one DB_MPOOLFILE). * We don't care about preserving any of those buffers, so mark the * MPOOLFILE as dead so that even the dirty ones just get discarded * when we try to flush them. */ - if ((mfp = dbmfp->mfp) == NULL) - goto done; - if (needlock) - R_LOCK(dbenv, dbmp->reginfo); + deleted = 0; + MUTEX_LOCK(dbenv, &mfp->mutex); if (--mfp->mpf_cnt == 0 || LF_ISSET(DB_MPOOL_DISCARD)) { if (LF_ISSET(DB_MPOOL_DISCARD) || F_ISSET(mfp, MP_TEMP | MP_UNLINK)) - MEMP_FREMOVE(mfp); + MPOOLFILE_IGNORE(mfp); if (F_ISSET(mfp, MP_UNLINK)) { if ((t_ret = __db_appname(dbmp->dbenv, - DB_APP_DATA, NULL, R_ADDR(dbmp->reginfo, + DB_APP_DATA, R_ADDR(dbmp->reginfo, mfp->path_off), 0, NULL, &rpath)) != 0 && ret == 0) ret = t_ret; - if (t_ret == 0 && (t_ret = - __os_unlink(dbmp->dbenv, rpath) != 0) && ret == 0) + if (t_ret == 0) { + if ((t_ret = __os_unlink( + dbmp->dbenv, rpath) != 0) && ret == 0) + ret = t_ret; + __os_free(dbenv, rpath); + } + } + if (mfp->block_cnt == 0) { + if ((t_ret = + __memp_mf_discard(dbmp, mfp)) != 0 && ret == 0) ret = t_ret; - __os_free(dbenv, rpath, 0); + deleted = 1; } - if (mfp->block_cnt == 0) - __memp_mf_discard(dbmp, mfp); } - if (needlock) - R_UNLOCK(dbenv, dbmp->reginfo); + if (deleted == 0) + MUTEX_UNLOCK(dbenv, &mfp->mutex); -done: /* Discard the DB_MPOOLFILE structure. */ - __os_free(dbenv, dbmfp->fhp, sizeof(DB_FH)); - __os_free(dbenv, dbmfp, sizeof(DB_MPOOLFILE)); + /* Discard the DB_MPOOLFILE structure. */ +done: __os_free(dbenv, dbmfp->fhp); + __os_free(dbenv, dbmfp); return (ret); } @@ -844,20 +902,69 @@ done: /* Discard the DB_MPOOLFILE structure. */ * __memp_mf_discard -- * Discard an MPOOLFILE. * - * PUBLIC: void __memp_mf_discard __P((DB_MPOOL *, MPOOLFILE *)); + * PUBLIC: int __memp_mf_discard __P((DB_MPOOL *, MPOOLFILE *)); */ -void +int __memp_mf_discard(dbmp, mfp) DB_MPOOL *dbmp; MPOOLFILE *mfp; { + DB_ENV *dbenv; + DB_FH fh; + DB_MPOOL_STAT *sp; MPOOL *mp; + char *rpath; + int ret; + dbenv = dbmp->dbenv; mp = dbmp->reginfo[0].primary; + ret = 0; + + /* + * Expects caller to be holding the MPOOLFILE mutex. + * + * When discarding a file, we have to flush writes from it to disk. + * The scenario is that dirty buffers from this file need to be + * flushed to satisfy a future checkpoint, but when the checkpoint + * calls mpool sync, the sync code won't know anything about them. + */ + if (!F_ISSET(mfp, MP_DEADFILE) && + (ret = __db_appname(dbenv, DB_APP_DATA, + R_ADDR(dbmp->reginfo, mfp->path_off), 0, NULL, &rpath)) == 0) { + if ((ret = __os_open(dbenv, rpath, 0, 0, &fh)) == 0) { + ret = __os_fsync(dbenv, &fh); + (void)__os_closehandle(dbenv, &fh); + } + __os_free(dbenv, rpath); + } + + /* + * We have to release the MPOOLFILE lock before acquiring the region + * lock so that we don't deadlock. Make sure nobody ever looks at + * this structure again. + */ + MPOOLFILE_IGNORE(mfp); + + /* Discard the mutex we're holding. */ + MUTEX_UNLOCK(dbenv, &mfp->mutex); /* Delete from the list of MPOOLFILEs. */ + R_LOCK(dbenv, dbmp->reginfo); SH_TAILQ_REMOVE(&mp->mpfq, mfp, q, __mpoolfile); + /* Copy the statistics into the region. */ + sp = &mp->stat; + sp->st_cache_hit += mfp->stat.st_cache_hit; + sp->st_cache_miss += mfp->stat.st_cache_miss; + sp->st_map += mfp->stat.st_map; + sp->st_page_create += mfp->stat.st_page_create; + sp->st_page_in += mfp->stat.st_page_in; + sp->st_page_out += mfp->stat.st_page_out; + + /* Clear the mutex this MPOOLFILE recorded. */ + __db_shlocks_clear(&mfp->mutex, dbmp->reginfo, + (REGMAINT *)R_ADDR(dbmp->reginfo, mp->maint_off)); + /* Free the space. */ if (mfp->path_off != 0) __db_shalloc_free(dbmp->reginfo[0].addr, @@ -869,6 +976,10 @@ __memp_mf_discard(dbmp, mfp) __db_shalloc_free(dbmp->reginfo[0].addr, R_ADDR(dbmp->reginfo, mfp->pgcookie_off)); __db_shalloc_free(dbmp->reginfo[0].addr, mfp); + + R_UNLOCK(dbenv, dbmp->reginfo); + + return (ret); } /* diff --git a/db/os/os_map.c b/db/os/os_map.c index 7d6ad4080..2311fb539 100644 --- a/db/os/os_map.c +++ b/db/os/os_map.c @@ -1,14 +1,14 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1996-2001 + * Copyright (c) 1996-2002 * Sleepycat Software. All rights reserved. */ #include "db_config.h" #ifndef lint -static const char revid[] = "Id: os_map.c,v 11.37 2001/10/04 21:27:57 bostic Exp "; +static const char revid[] = "Id: os_map.c,v 11.44 2002/07/12 18:56:51 bostic Exp "; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -26,7 +26,6 @@ static const char revid[] = "Id: os_map.c,v 11.37 2001/10/04 21:27:57 bostic Exp #endif #include "db_int.h" -#include "os_jump.h" #ifdef HAVE_MMAP static int __os_map __P((DB_ENV *, char *, DB_FH *, size_t, int, int, void **)); @@ -141,12 +140,13 @@ __os_r_sysattach(dbenv, infop, rp) int ret; /* - * Try to open/create the shared region file. We DO NOT need to - * ensure that multiple threads/processes attempting to - * simultaneously create the region are properly ordered, - * our caller has already taken care of that. + * Try to open/create the shared region file. We DO NOT need to ensure + * that multiple threads/processes attempting to simultaneously create + * the region are properly ordered, our caller has already taken care + * of that. */ - if ((ret = __os_open(dbenv, infop->name, DB_OSO_REGION | + if ((ret = __os_open(dbenv, infop->name, + DB_OSO_REGION | DB_OSO_DIRECT | (F_ISSET(infop, REGION_CREATE_OK) ? DB_OSO_CREATE : 0), infop->mode, &fh)) != 0) __db_err(dbenv, "%s: %s", infop->name, db_strerror(ret)); @@ -159,7 +159,7 @@ __os_r_sysattach(dbenv, infop, rp) * point, *badly* merged VM/buffer cache systems. */ if (ret == 0 && F_ISSET(infop, REGION_CREATE)) - ret = __os_finit(dbenv, + ret = __db_fileinit(dbenv, &fh, rp->size, F_ISSET(dbenv, DB_ENV_REGION_INIT) ? 1 : 0); /* Map the file in. */ @@ -167,7 +167,8 @@ __os_r_sysattach(dbenv, infop, rp) ret = __os_map(dbenv, infop->name, &fh, rp->size, 1, 0, &infop->addr); - (void)__os_closehandle(&fh); + if (F_ISSET(&fh, DB_FH_VALID)) + (void)__os_closehandle(dbenv, &fh); return (ret); } @@ -293,8 +294,8 @@ __os_unmapfile(dbenv, addr, len) size_t len; { /* If the user replaced the map call, call through their interface. */ - if (__db_jump.j_unmap != NULL) - return (__db_jump.j_unmap(addr, len)); + if (DB_GLOBAL(j_unmap) != NULL) + return (DB_GLOBAL(j_unmap)(addr, len)); #ifdef HAVE_MMAP #ifdef HAVE_MUNLOCK @@ -337,8 +338,8 @@ __os_map(dbenv, path, fhp, len, is_region, is_rdonly, addrp) int flags, prot, ret; /* If the user replaced the map call, call through their interface. */ - if (__db_jump.j_map != NULL) - return (__db_jump.j_map + if (DB_GLOBAL(j_map) != NULL) + return (DB_GLOBAL(j_map) (path, len, is_region, is_rdonly, addrp)); /* diff --git a/db/os_vxworks/os_vx_abs.c b/db/os_vxworks/os_vx_abs.c index dcf4190dd..c3142dbe7 100644 --- a/db/os_vxworks/os_vx_abs.c +++ b/db/os_vxworks/os_vx_abs.c @@ -1,14 +1,14 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1997-2001 + * Copyright (c) 1997-2002 * Sleepycat Software. All rights reserved. */ #include "db_config.h" #ifndef lint -static const char revid[] = "Id: os_vx_abs.c,v 1.6 2001/05/23 14:47:23 sue Exp "; +static const char revid[] = "Id: os_vx_abs.c,v 1.7 2002/01/11 15:53:02 bostic Exp "; #endif /* not lint */ #include "db_int.h" diff --git a/db/os_vxworks/os_vx_map.c b/db/os_vxworks/os_vx_map.c index 6e971e15c..7e849f571 100644 --- a/db/os_vxworks/os_vx_map.c +++ b/db/os_vxworks/os_vx_map.c @@ -1,7 +1,7 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1998-2001 + * Copyright (c) 1998-2002 * Sleepycat Software. All rights reserved. * * This code is derived from software contributed to Sleepycat Software by @@ -11,7 +11,7 @@ #include "db_config.h" #ifndef lint -static const char revid[] = "Id: os_vx_map.c,v 1.17 2001/07/31 19:30:36 sue Exp "; +static const char revid[] = "Id: os_vx_map.c,v 1.21 2002/03/06 19:36:58 margo Exp "; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -20,7 +20,6 @@ static const char revid[] = "Id: os_vx_map.c,v 1.17 2001/07/31 19:30:36 sue Exp #endif #include "db_int.h" -#include "common_ext.h" /* * DB uses memory-mapped files for two things: @@ -243,17 +242,17 @@ __os_segdata_destroy(dbenv) for (i = 0; i < __os_segdata_size; i++) { p = &__os_segdata[i]; if (p->name != NULL) { - __os_freestr(dbenv, p->name); + __os_free(dbenv, p->name); p->name = NULL; } if (p->segment != NULL) { - __os_free(dbenv, p->segment, p->size); + __os_free(dbenv, p->segment); p->segment = NULL; } p->size = 0; } - __os_free(dbenv, __os_segdata, __os_segdata_size * sizeof(os_segdata_t)); + __os_free(dbenv, __os_segdata); __os_segdata = NULL; __os_segdata_size = 0; DB_END_SINGLE_THREAD; @@ -285,7 +284,7 @@ __os_segdata_allocate(dbenv, name, infop, rp) if ((ret = __os_calloc(dbenv, 1, rp->size, &p->segment)) != 0) return (ret); if ((ret = __os_strdup(dbenv, name, &p->name)) != 0) { - __os_free(dbenv, p->segment, rp->size); + __os_free(dbenv, p->segment); p->segment = NULL; return (ret); } @@ -425,11 +424,11 @@ __os_segdata_release(dbenv, rp, is_locked) DB_BEGIN_SINGLE_THREAD; p = &__os_segdata[rp->segid]; if (p->name != NULL) { - __os_freestr(dbenv, p->name); + __os_free(dbenv, p->name); p->name = NULL; } if (p->segment != NULL) { - __os_free(dbenv, p->segment, p->size); + __os_free(dbenv, p->segment); p->segment = NULL; } p->size = 0; diff --git a/db/perl/BerkeleyDB/t/btree.t b/db/perl/BerkeleyDB/t/btree.t index c85271d99..fd6ed8f12 100644 --- a/db/perl/BerkeleyDB/t/btree.t +++ b/db/perl/BerkeleyDB/t/btree.t @@ -14,7 +14,7 @@ BEGIN { use BerkeleyDB; use t::util ; -print "1..243\n"; +print "1..244\n"; my $Dfile = "dbhash.tmp"; my $Dfile2 = "dbhash2.tmp"; @@ -640,6 +640,9 @@ umask(0) ; -Env => $env, -Txn => $txn ; + ok 181, (my $Z = $txn->txn_commit()) == 0 ; + ok 182, $txn = $env->txn_begin() ; + $db1->Txn($txn); # create some data my %data = ( @@ -652,32 +655,32 @@ umask(0) ; while (my ($k, $v) = each %data) { $ret += $db1->db_put($k, $v) ; } - ok 181, $ret == 0 ; + ok 183, $ret == 0 ; # should be able to see all the records - ok 182, my $cursor = $db1->db_cursor() ; + ok 184, my $cursor = $db1->db_cursor() ; my ($k, $v) = ("", "") ; my $count = 0 ; # sequence forwards while ($cursor->c_get($k, $v, DB_NEXT) == 0) { ++ $count ; } - ok 183, $count == 3 ; + ok 185, $count == 3 ; undef $cursor ; # now abort the transaction #ok 151, $txn->txn_abort() == 0 ; - ok 184, (my $Z = $txn->txn_abort()) == 0 ; + ok 186, ($Z = $txn->txn_abort()) == 0 ; # there shouldn't be any records in the database $count = 0 ; # sequence forwards - ok 185, $cursor = $db1->db_cursor() ; + ok 187, $cursor = $db1->db_cursor() ; while ($cursor->c_get($k, $v, DB_NEXT) == 0) { ++ $count ; } - ok 186, $count == 0 ; + ok 188, $count == 0 ; undef $txn ; undef $cursor ; @@ -691,7 +694,7 @@ umask(0) ; my $lex = new LexFile $Dfile ; my %hash ; - ok 187, my $db = tie %hash, 'BerkeleyDB::Btree', -Filename => $Dfile, + ok 189, my $db = tie %hash, 'BerkeleyDB::Btree', -Filename => $Dfile, -Property => DB_DUP, -Flags => DB_CREATE ; @@ -702,24 +705,25 @@ umask(0) ; $hash{'Wall'} = 'Brick' ; $hash{'mouse'} = 'mickey' ; - ok 188, keys %hash == 6 ; + ok 190, keys %hash == 6 ; # create a cursor - ok 189, my $cursor = $db->db_cursor() ; + ok 191, my $cursor = $db->db_cursor() ; my $key = "Wall" ; my $value ; - ok 190, $cursor->c_get($key, $value, DB_SET) == 0 ; - ok 191, $key eq "Wall" && $value eq "Larry" ; - ok 192, $cursor->c_get($key, $value, DB_NEXT) == 0 ; - ok 193, $key eq "Wall" && $value eq "Stone" ; + ok 192, $cursor->c_get($key, $value, DB_SET) == 0 ; + ok 193, $key eq "Wall" && $value eq "Larry" ; ok 194, $cursor->c_get($key, $value, DB_NEXT) == 0 ; - ok 195, $key eq "Wall" && $value eq "Brick" ; + ok 195, $key eq "Wall" && $value eq "Stone" ; ok 196, $cursor->c_get($key, $value, DB_NEXT) == 0 ; ok 197, $key eq "Wall" && $value eq "Brick" ; + ok 198, $cursor->c_get($key, $value, DB_NEXT) == 0 ; + ok 199, $key eq "Wall" && $value eq "Brick" ; - my $ref = $db->db_stat() ; - ok 198, ($ref->{bt_flags} | DB_DUP) == DB_DUP ; + #my $ref = $db->db_stat() ; + #ok 200, ($ref->{bt_flags} | DB_DUP) == DB_DUP ; +#print "bt_flags " . $ref->{bt_flags} . " DB_DUP " . DB_DUP ."\n"; undef $db ; undef $cursor ; @@ -734,16 +738,16 @@ umask(0) ; my $recs = ($BerkeleyDB::db_version >= 3.1 ? "bt_ndata" : "bt_nrecs") ; my %hash ; my ($k, $v) ; - ok 199, my $db = new BerkeleyDB::Btree -Filename => $Dfile, + ok 200, my $db = new BerkeleyDB::Btree -Filename => $Dfile, -Flags => DB_CREATE, -Minkey =>3 , -Pagesize => 2 **12 ; my $ref = $db->db_stat() ; - ok 200, $ref->{$recs} == 0; - ok 201, $ref->{'bt_minkey'} == 3; - ok 202, $ref->{'bt_pagesize'} == 2 ** 12; + ok 201, $ref->{$recs} == 0; + ok 202, $ref->{'bt_minkey'} == 3; + ok 203, $ref->{'bt_pagesize'} == 2 ** 12; # create some data my %data = ( @@ -756,10 +760,10 @@ umask(0) ; while (($k, $v) = each %data) { $ret += $db->db_put($k, $v) ; } - ok 203, $ret == 0 ; + ok 204, $ret == 0 ; $ref = $db->db_stat() ; - ok 204, $ref->{$recs} == 3; + ok 205, $ref->{$recs} == 3; } { @@ -810,7 +814,7 @@ EOM BEGIN { push @INC, '.'; } eval 'use SubDB ; '; - main::ok 205, $@ eq "" ; + main::ok 206, $@ eq "" ; my %h ; my $X ; eval ' @@ -819,25 +823,27 @@ EOM -Mode => 0640 ); ' ; - main::ok 206, $@ eq "" ; + main::ok 207, $@ eq "" && $X ; my $ret = eval '$h{"fred"} = 3 ; return $h{"fred"} ' ; - main::ok 207, $@ eq "" ; - main::ok 208, $ret == 7 ; + main::ok 208, $@ eq "" ; + main::ok 209, $ret == 7 ; my $value = 0; $ret = eval '$X->db_put("joe", 4) ; $X->db_get("joe", $value) ; return $value' ; - main::ok 209, $@ eq "" ; - main::ok 210, $ret == 10 ; + main::ok 210, $@ eq "" ; + main::ok 211, $ret == 10 ; $ret = eval ' DB_NEXT eq main::DB_NEXT ' ; - main::ok 211, $@ eq "" ; - main::ok 212, $ret == 1 ; + main::ok 212, $@ eq "" ; + main::ok 213, $ret == 1 ; $ret = eval '$X->A_new_method("joe") ' ; - main::ok 213, $@ eq "" ; - main::ok 214, $ret eq "[[10]]" ; + main::ok 214, $@ eq "" ; + main::ok 215, $ret eq "[[10]]" ; + undef $X; + untie %h; unlink "SubDB.pm", "dbbtree.tmp" ; } @@ -848,7 +854,7 @@ EOM my $lex = new LexFile $Dfile ; my %hash ; my ($k, $v) = ("", ""); - ok 215, my $db = new BerkeleyDB::Btree + ok 216, my $db = new BerkeleyDB::Btree -Filename => $Dfile, -Flags => DB_CREATE, -Property => DB_RECNUM ; @@ -869,57 +875,57 @@ EOM $ret += $db->db_put($_, $ix) ; ++ $ix ; } - ok 216, $ret == 0 ; + ok 217, $ret == 0 ; # db_get & DB_SET_RECNO $k = 1 ; - ok 217, $db->db_get($k, $v, DB_SET_RECNO) == 0; - ok 218, $k eq "B one" && $v == 1 ; + ok 218, $db->db_get($k, $v, DB_SET_RECNO) == 0; + ok 219, $k eq "B one" && $v == 1 ; $k = 3 ; - ok 219, $db->db_get($k, $v, DB_SET_RECNO) == 0; - ok 220, $k eq "D three" && $v == 3 ; + ok 220, $db->db_get($k, $v, DB_SET_RECNO) == 0; + ok 221, $k eq "D three" && $v == 3 ; $k = 4 ; - ok 221, $db->db_get($k, $v, DB_SET_RECNO) == 0; - ok 222, $k eq "E four" && $v == 4 ; + ok 222, $db->db_get($k, $v, DB_SET_RECNO) == 0; + ok 223, $k eq "E four" && $v == 4 ; $k = 0 ; - ok 223, $db->db_get($k, $v, DB_SET_RECNO) == 0; - ok 224, $k eq "A zero" && $v == 0 ; + ok 224, $db->db_get($k, $v, DB_SET_RECNO) == 0; + ok 225, $k eq "A zero" && $v == 0 ; # cursor & DB_SET_RECNO # create the cursor - ok 225, my $cursor = $db->db_cursor() ; + ok 226, my $cursor = $db->db_cursor() ; $k = 2 ; - ok 226, $db->db_get($k, $v, DB_SET_RECNO) == 0; - ok 227, $k eq "C two" && $v == 2 ; + ok 227, $db->db_get($k, $v, DB_SET_RECNO) == 0; + ok 228, $k eq "C two" && $v == 2 ; $k = 0 ; - ok 228, $cursor->c_get($k, $v, DB_SET_RECNO) == 0; - ok 229, $k eq "A zero" && $v == 0 ; + ok 229, $cursor->c_get($k, $v, DB_SET_RECNO) == 0; + ok 230, $k eq "A zero" && $v == 0 ; $k = 3 ; - ok 230, $db->db_get($k, $v, DB_SET_RECNO) == 0; - ok 231, $k eq "D three" && $v == 3 ; + ok 231, $db->db_get($k, $v, DB_SET_RECNO) == 0; + ok 232, $k eq "D three" && $v == 3 ; # cursor & DB_GET_RECNO - ok 232, $cursor->c_get($k, $v, DB_FIRST) == 0 ; - ok 233, $k eq "A zero" && $v == 0 ; - ok 234, $cursor->c_get($k, $v, DB_GET_RECNO) == 0; - ok 235, $v == 0 ; - - ok 236, $cursor->c_get($k, $v, DB_NEXT) == 0 ; - ok 237, $k eq "B one" && $v == 1 ; - ok 238, $cursor->c_get($k, $v, DB_GET_RECNO) == 0; - ok 239, $v == 1 ; - - ok 240, $cursor->c_get($k, $v, DB_LAST) == 0 ; - ok 241, $k eq "E four" && $v == 4 ; - ok 242, $cursor->c_get($k, $v, DB_GET_RECNO) == 0; - ok 243, $v == 4 ; + ok 233, $cursor->c_get($k, $v, DB_FIRST) == 0 ; + ok 234, $k eq "A zero" && $v == 0 ; + ok 235, $cursor->c_get($k, $v, DB_GET_RECNO) == 0; + ok 236, $v == 0 ; + + ok 237, $cursor->c_get($k, $v, DB_NEXT) == 0 ; + ok 238, $k eq "B one" && $v == 1 ; + ok 239, $cursor->c_get($k, $v, DB_GET_RECNO) == 0; + ok 240, $v == 1 ; + + ok 241, $cursor->c_get($k, $v, DB_LAST) == 0 ; + ok 242, $k eq "E four" && $v == 4 ; + ok 243, $cursor->c_get($k, $v, DB_GET_RECNO) == 0; + ok 244, $v == 4 ; } diff --git a/db/perl/BerkeleyDB/t/db-3.0.t b/db/perl/BerkeleyDB/t/db-3.0.t index 971a5e830..0a213e5d4 100644 --- a/db/perl/BerkeleyDB/t/db-3.0.t +++ b/db/perl/BerkeleyDB/t/db-3.0.t @@ -87,3 +87,4 @@ umask(0); ok 14, $v eq "house" ; } + diff --git a/db/perl/BerkeleyDB/t/db-3.1.t b/db/perl/BerkeleyDB/t/db-3.1.t index d01681e54..bc0516f05 100644 --- a/db/perl/BerkeleyDB/t/db-3.1.t +++ b/db/perl/BerkeleyDB/t/db-3.1.t @@ -22,7 +22,7 @@ BEGIN } } -print "1..25\n"; +print "1..35\n"; my $Dfile = "dbhash.tmp"; my $Dfile2 = "dbhash2.tmp"; @@ -121,3 +121,79 @@ umask(0) ; untie %hash ; } + +{ + # rename + + my $lex = new LexFile $Dfile ; + + ok 26, my $db1 = new BerkeleyDB::Hash -Filename => $Dfile, + -Subname => "fred" , + -Flags => DB_CREATE ; + + ok 27, my $db2 = new BerkeleyDB::Btree -Filename => $Dfile, + -Subname => "joe" , + -Flags => DB_CREATE ; + + # Add a k/v pair + my %data = qw( + red sky + blue sea + black heart + yellow belley + green grass + ) ; + + ok 28, addData($db1, %data) ; + ok 29, addData($db2, %data) ; + + undef $db1 ; + undef $db2 ; + + # now rename + ok 30, BerkeleyDB::db_rename(-Filename => $Dfile, + -Subname => "fred", + -Newname => "harry") == 0; + + ok 31, my $db3 = new BerkeleyDB::Hash -Filename => $Dfile, + -Subname => "harry" ; + +} + +{ + # verify + + my $lex = new LexFile $Dfile, $Dfile2 ; + + ok 32, my $db1 = new BerkeleyDB::Hash -Filename => $Dfile, + -Subname => "fred" , + -Flags => DB_CREATE ; + + # Add a k/v pair + my %data = qw( + red sky + blue sea + black heart + yellow belley + green grass + ) ; + + ok 33, addData($db1, %data) ; + + undef $db1 ; + + # now verify + ok 34, BerkeleyDB::db_verify(-Filename => $Dfile, + -Subname => "fred", + ) == 0; + + # now verify & dump + ok 35, BerkeleyDB::db_verify(-Filename => $Dfile, + -Subname => "fred", + -Outfile => $Dfile2, + ) == 0; + +} + +# db_remove with env + diff --git a/db/perl/BerkeleyDB/t/db-3.2.t b/db/perl/BerkeleyDB/t/db-3.2.t index 1f7ad1504..38c68f42e 100644 --- a/db/perl/BerkeleyDB/t/db-3.2.t +++ b/db/perl/BerkeleyDB/t/db-3.2.t @@ -22,7 +22,7 @@ BEGIN } } -print "1..1\n"; +print "1..6\n"; my $Dfile = "dbhash.tmp"; @@ -40,3 +40,26 @@ umask(0) ; ok 1, 1 ; } +{ + # env->set_flags + + my $home = "./fred" ; + ok 2, my $lexD = new LexDir($home) ; + ok 3, my $env = new BerkeleyDB::Env -Home => $home, + -Flags => DB_CREATE , + -SetFlags => DB_NOMMAP ; + + undef $env ; +} + +{ + # env->set_flags + + my $home = "./fred" ; + ok 4, my $lexD = new LexDir($home) ; + ok 5, my $env = new BerkeleyDB::Env -Home => $home, + -Flags => DB_CREATE ; + ok 6, ! $env->set_flags(DB_NOMMAP, 1); + + undef $env ; +} diff --git a/db/perl/BerkeleyDB/t/destroy.t b/db/perl/BerkeleyDB/t/destroy.t index c060bc744..7457d36c5 100644 --- a/db/perl/BerkeleyDB/t/destroy.t +++ b/db/perl/BerkeleyDB/t/destroy.t @@ -12,7 +12,7 @@ BEGIN { use BerkeleyDB; use t::util ; -print "1..13\n"; +print "1..15\n"; my $Dfile = "dbhash.tmp"; my $home = "./fred" ; @@ -20,7 +20,7 @@ my $home = "./fred" ; umask(0); { - # let object destroction kill everything + # let object destruction kill everything my $lex = new LexFile $Dfile ; my %hash ; @@ -36,6 +36,9 @@ umask(0); -Env => $env, -Txn => $txn ; + ok 5, $txn->txn_commit() == 0 ; + ok 6, $txn = $env->txn_begin() ; + $db1->Txn($txn); # create some data my %data = ( @@ -48,31 +51,31 @@ umask(0); while (my ($k, $v) = each %data) { $ret += $db1->db_put($k, $v) ; } - ok 5, $ret == 0 ; + ok 7, $ret == 0 ; # should be able to see all the records - ok 6, my $cursor = $db1->db_cursor() ; + ok 8, my $cursor = $db1->db_cursor() ; my ($k, $v) = ("", "") ; my $count = 0 ; # sequence forwards while ($cursor->c_get($k, $v, DB_NEXT) == 0) { ++ $count ; } - ok 7, $count == 3 ; + ok 9, $count == 3 ; undef $cursor ; # now abort the transaction - ok 8, $txn->txn_abort() == 0 ; + ok 10, $txn->txn_abort() == 0 ; # there shouldn't be any records in the database $count = 0 ; # sequence forwards - ok 9, $cursor = $db1->db_cursor() ; + ok 11, $cursor = $db1->db_cursor() ; while ($cursor->c_get($k, $v, DB_NEXT) == 0) { ++ $count ; } - ok 10, $count == 0 ; + ok 12, $count == 0 ; #undef $txn ; #undef $cursor ; @@ -81,21 +84,22 @@ umask(0); #untie %hash ; } + { my $lex = new LexFile $Dfile ; my %hash ; my $cursor ; my ($k, $v) = ("", "") ; - ok 11, my $db1 = tie %hash, 'BerkeleyDB::Hash', + ok 13, my $db1 = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile, -Flags => DB_CREATE ; my $count = 0 ; # sequence forwards - ok 12, $cursor = $db1->db_cursor() ; + ok 14, $cursor = $db1->db_cursor() ; while ($cursor->c_get($k, $v, DB_NEXT) == 0) { ++ $count ; } - ok 13, $count == 0 ; + ok 15, $count == 0 ; } diff --git a/db/perl/BerkeleyDB/t/env.t b/db/perl/BerkeleyDB/t/env.t index d6ddc9860..3905abfae 100644 --- a/db/perl/BerkeleyDB/t/env.t +++ b/db/perl/BerkeleyDB/t/env.t @@ -14,7 +14,7 @@ BEGIN { use BerkeleyDB; use t::util ; -print "1..52\n"; +print "1..47\n"; my $Dfile = "dbhash.tmp"; @@ -74,7 +74,7 @@ umask(0); my $env = new BerkeleyDB::Env -Home => $home, -Flags => DB_INIT_LOCK ; ok 16, ! $env ; - ok 17, $! != 0 ; + ok 17, $! != 0 || $^E != 0 ; rmtree $home ; } @@ -141,65 +141,49 @@ umask(0); } { - # -ErrFile with a filehandle - use IO ; + # -ErrFile with a filehandle/reference -- should fail my $home = "./fred" ; ok 30, my $lexD = new LexDir($home) ; - my $errfile = "./errfile" ; - my $lex = new LexFile $errfile ; - ok 31, my $ef = new IO::File ">$errfile" ; - ok 32, my $env = new BerkeleyDB::Env( -ErrFile => $ef , + eval { my $env = new BerkeleyDB::Env( -ErrFile => [], -Flags => DB_CREATE, - -Home => $home) ; - my $db = new BerkeleyDB::Hash -Filename => $Dfile, - -Env => $env, - -Flags => -1; - ok 33, !$db ; - - ok 34, $BerkeleyDB::Error =~ /^illegal flag specified to (db_open|DB->open)/; - $ef->close() ; - ok 35, -e $errfile ; - my $contents = "" ; - $contents = docat($errfile) ; - chomp $contents ; - ok 36, $BerkeleyDB::Error eq $contents ; - undef $env ; + -Home => $home) ; }; + ok 31, $@ =~ /ErrFile parameter must be a file name/; } { # -ErrPrefix use IO ; my $home = "./fred" ; - ok 37, my $lexD = new LexDir($home) ; + ok 32, my $lexD = new LexDir($home) ; my $errfile = "./errfile" ; my $lex = new LexFile $errfile ; - ok 38, my $env = new BerkeleyDB::Env( -ErrFile => $errfile, + ok 33, my $env = new BerkeleyDB::Env( -ErrFile => $errfile, -ErrPrefix => "PREFIX", -Flags => DB_CREATE, -Home => $home) ; my $db = new BerkeleyDB::Hash -Filename => $Dfile, -Env => $env, -Flags => -1; - ok 39, !$db ; + ok 34, !$db ; - ok 40, $BerkeleyDB::Error =~ /^PREFIX: illegal flag specified to (db_open|DB->open)/; - ok 41, -e $errfile ; + ok 35, $BerkeleyDB::Error =~ /^PREFIX: illegal flag specified to (db_open|DB->open)/; + ok 36, -e $errfile ; my $contents = docat($errfile) ; chomp $contents ; - ok 42, $BerkeleyDB::Error eq $contents ; + ok 37, $BerkeleyDB::Error eq $contents ; # change the prefix on the fly my $old = $env->errPrefix("NEW ONE") ; - ok 43, $old eq "PREFIX" ; + ok 38, $old eq "PREFIX" ; $db = new BerkeleyDB::Hash -Filename => $Dfile, -Env => $env, -Flags => -1; - ok 44, !$db ; - ok 45, $BerkeleyDB::Error =~ /^NEW ONE: illegal flag specified to (db_open|DB->open)/; + ok 39, !$db ; + ok 40, $BerkeleyDB::Error =~ /^NEW ONE: illegal flag specified to (db_open|DB->open)/; $contents = docat($errfile) ; chomp $contents ; - ok 46, $contents =~ /$BerkeleyDB::Error$/ ; + ok 41, $contents =~ /$BerkeleyDB::Error$/ ; undef $env ; } @@ -211,20 +195,20 @@ umask(0); my $data_dir = "$home/data_dir" ; my $log_dir = "$home/log_dir" ; my $data_file = "data.db" ; - ok 47, my $lexD = new LexDir($home); - ok 48, -d $data_dir ? chmod 0777, $data_dir : mkdir($data_dir, 0777) ; - ok 49, -d $log_dir ? chmod 0777, $log_dir : mkdir($log_dir, 0777) ; + ok 42, my $lexD = new LexDir($home); + ok 43, -d $data_dir ? chmod 0777, $data_dir : mkdir($data_dir, 0777) ; + ok 44, -d $log_dir ? chmod 0777, $log_dir : mkdir($log_dir, 0777) ; my $env = new BerkeleyDB::Env -Home => $home, -Config => { DB_DATA_DIR => $data_dir, DB_LOG_DIR => $log_dir }, -Flags => DB_CREATE|DB_INIT_TXN|DB_INIT_LOG| DB_INIT_MPOOL|DB_INIT_LOCK ; - ok 50, $env ; + ok 45, $env ; - ok 51, my $txn_mgr = $env->TxnMgr() ; + ok 46, my $txn_mgr = $env->TxnMgr() ; - ok 52, $env->db_appexit() == 0 ; + ok 47, $env->db_appexit() == 0 ; } diff --git a/db/perl/BerkeleyDB/t/examples.t b/db/perl/BerkeleyDB/t/examples.t index 4cd7b79fc..69b7f8ff8 100644 --- a/db/perl/BerkeleyDB/t/examples.t +++ b/db/perl/BerkeleyDB/t/examples.t @@ -10,21 +10,10 @@ BEGIN { } use BerkeleyDB; -use t::util ; +use t::util; print "1..7\n"; -my $FA = 0 ; - -{ - sub try::TIEARRAY { bless [], "try" } - sub try::FETCHSIZE { $FA = 1 } - $FA = 0 ; - my @a ; - tie @a, 'try' ; - my $a = @a ; -} - my $Dfile = "dbhash.tmp"; my $Dfile2 = "dbhash2.tmp"; my $Dfile3 = "dbhash3.tmp"; diff --git a/db/perl/BerkeleyDB/t/examples.t.T b/db/perl/BerkeleyDB/t/examples.t.T index fe0922318..fe9bdf76b 100644 --- a/db/perl/BerkeleyDB/t/examples.t.T +++ b/db/perl/BerkeleyDB/t/examples.t.T @@ -10,91 +10,10 @@ BEGIN { } use BerkeleyDB; -use File::Path qw(rmtree); +use t::util; print "1..7\n"; -my $FA = 0 ; - -{ - sub try::TIEARRAY { bless [], "try" } - sub try::FETCHSIZE { $FA = 1 } - $FA = 0 ; - my @a ; - tie @a, 'try' ; - my $a = @a ; -} - -{ - package LexFile ; - - sub new - { - my $self = shift ; - unlink @_ ; - bless [ @_ ], $self ; - } - - sub DESTROY - { - my $self = shift ; - unlink @{ $self } ; - } -} - - -sub ok -{ - my $no = shift ; - my $result = shift ; - - print "not " unless $result ; - print "ok $no\n" ; -} - -{ - package Redirect ; - use Symbol ; - - sub new - { - my $class = shift ; - my $filename = shift ; - my $fh = gensym ; - open ($fh, ">$filename") || die "Cannot open $filename: $!" ; - my $real_stdout = select($fh) ; - return bless [$fh, $real_stdout ] ; - - } - sub DESTROY - { - my $self = shift ; - close $self->[0] ; - select($self->[1]) ; - } -} - -sub docat -{ - my $file = shift; - local $/ = undef; - open(CAT,$file) || die "Cannot open $file:$!"; - my $result = <CAT> || "" ; - close(CAT); - return $result; -} - -sub docat_del -{ - my $file = shift; - local $/ = undef; - open(CAT,$file) || die "Cannot open $file: $!"; - my $result = <CAT> || "" ; - close(CAT); - unlink $file ; - return $result; -} - my $Dfile = "dbhash.tmp"; my $Dfile2 = "dbhash2.tmp"; my $Dfile3 = "dbhash3.tmp"; diff --git a/db/perl/BerkeleyDB/t/examples3.t b/db/perl/BerkeleyDB/t/examples3.t index 72b68eb38..22e94b770 100644 --- a/db/perl/BerkeleyDB/t/examples3.t +++ b/db/perl/BerkeleyDB/t/examples3.t @@ -10,7 +10,7 @@ BEGIN { } use BerkeleyDB; -use t::util ; +use t::util; BEGIN { diff --git a/db/perl/BerkeleyDB/t/examples3.t.T b/db/perl/BerkeleyDB/t/examples3.t.T index 573c04903..5eeaa14d0 100644 --- a/db/perl/BerkeleyDB/t/examples3.t.T +++ b/db/perl/BerkeleyDB/t/examples3.t.T @@ -10,7 +10,7 @@ BEGIN { } use BerkeleyDB; -use File::Path qw(rmtree); +use t::util; BEGIN { @@ -23,87 +23,6 @@ BEGIN print "1..2\n"; -my $FA = 0 ; - -{ - sub try::TIEARRAY { bless [], "try" } - sub try::FETCHSIZE { $FA = 1 } - $FA = 0 ; - my @a ; - tie @a, 'try' ; - my $a = @a ; -} - -{ - package LexFile ; - - sub new - { - my $self = shift ; - unlink @_ ; - bless [ @_ ], $self ; - } - - sub DESTROY - { - my $self = shift ; - unlink @{ $self } ; - } -} - - -sub ok -{ - my $no = shift ; - my $result = shift ; - - print "not " unless $result ; - print "ok $no\n" ; -} - -{ - package Redirect ; - use Symbol ; - - sub new - { - my $class = shift ; - my $filename = shift ; - my $fh = gensym ; - open ($fh, ">$filename") || die "Cannot open $filename: $!" ; - my $real_stdout = select($fh) ; - return bless [$fh, $real_stdout ] ; - - } - sub DESTROY - { - my $self = shift ; - close $self->[0] ; - select($self->[1]) ; - } -} - -sub docat -{ - my $file = shift; - local $/ = undef; - open(CAT,$file) || die "Cannot open $file:$!"; - my $result = <CAT> || "" ; - close(CAT); - return $result; -} - -sub docat_del -{ - my $file = shift; - local $/ = undef; - open(CAT,$file) || die "Cannot open $file: $!"; - my $result = <CAT> || "" ; - close(CAT); - unlink $file ; - return $result; -} - my $Dfile = "dbhash.tmp"; my $Dfile2 = "dbhash2.tmp"; my $Dfile3 = "dbhash3.tmp"; diff --git a/db/perl/BerkeleyDB/t/hash.t b/db/perl/BerkeleyDB/t/hash.t index 661de1763..0e683851c 100644 --- a/db/perl/BerkeleyDB/t/hash.t +++ b/db/perl/BerkeleyDB/t/hash.t @@ -14,7 +14,7 @@ BEGIN { use BerkeleyDB; use t::util ; -print "1..210\n"; +print "1..212\n"; my $Dfile = "dbhash.tmp"; my $Dfile2 = "dbhash2.tmp"; @@ -447,6 +447,9 @@ umask(0) ; -Txn => $txn ; + ok 150, $txn->txn_commit() == 0 ; + ok 151, $txn = $env->txn_begin() ; + $db1->Txn($txn); # create some data my %data = ( "red" => "boat", @@ -458,31 +461,31 @@ umask(0) ; while (my ($k, $v) = each %data) { $ret += $db1->db_put($k, $v) ; } - ok 150, $ret == 0 ; + ok 152, $ret == 0 ; # should be able to see all the records - ok 151, my $cursor = $db1->db_cursor() ; + ok 153, my $cursor = $db1->db_cursor() ; my ($k, $v) = ("", "") ; my $count = 0 ; # sequence forwards while ($cursor->c_get($k, $v, DB_NEXT) == 0) { ++ $count ; } - ok 152, $count == 3 ; + ok 154, $count == 3 ; undef $cursor ; # now abort the transaction - ok 153, $txn->txn_abort() == 0 ; + ok 155, $txn->txn_abort() == 0 ; # there shouldn't be any records in the database $count = 0 ; # sequence forwards - ok 154, $cursor = $db1->db_cursor() ; + ok 156, $cursor = $db1->db_cursor() ; while ($cursor->c_get($k, $v, DB_NEXT) == 0) { ++ $count ; } - ok 155, $count == 0 ; + ok 157, $count == 0 ; undef $txn ; undef $cursor ; @@ -497,7 +500,7 @@ umask(0) ; my $lex = new LexFile $Dfile ; my %hash ; - ok 156, my $db = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile, + ok 158, my $db = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile, -Property => DB_DUP, -Flags => DB_CREATE ; @@ -508,36 +511,36 @@ umask(0) ; $hash{'Wall'} = 'Brick' ; $hash{'mouse'} = 'mickey' ; - ok 157, keys %hash == 6 ; + ok 159, keys %hash == 6 ; # create a cursor - ok 158, my $cursor = $db->db_cursor() ; + ok 160, my $cursor = $db->db_cursor() ; my $key = "Wall" ; my $value ; - ok 159, $cursor->c_get($key, $value, DB_SET) == 0 ; - ok 160, $key eq "Wall" && $value eq "Larry" ; - ok 161, $cursor->c_get($key, $value, DB_NEXT) == 0 ; - ok 162, $key eq "Wall" && $value eq "Stone" ; + ok 161, $cursor->c_get($key, $value, DB_SET) == 0 ; + ok 162, $key eq "Wall" && $value eq "Larry" ; ok 163, $cursor->c_get($key, $value, DB_NEXT) == 0 ; - ok 164, $key eq "Wall" && $value eq "Brick" ; + ok 164, $key eq "Wall" && $value eq "Stone" ; ok 165, $cursor->c_get($key, $value, DB_NEXT) == 0 ; ok 166, $key eq "Wall" && $value eq "Brick" ; + ok 167, $cursor->c_get($key, $value, DB_NEXT) == 0 ; + ok 168, $key eq "Wall" && $value eq "Brick" ; #my $ref = $db->db_stat() ; #ok 143, $ref->{bt_flags} | DB_DUP ; # test DB_DUP_NEXT my ($k, $v) = ("Wall", "") ; - ok 167, $cursor->c_get($k, $v, DB_SET) == 0 ; - ok 168, $k eq "Wall" && $v eq "Larry" ; - ok 169, $cursor->c_get($k, $v, DB_NEXT_DUP) == 0 ; - ok 170, $k eq "Wall" && $v eq "Stone" ; + ok 169, $cursor->c_get($k, $v, DB_SET) == 0 ; + ok 170, $k eq "Wall" && $v eq "Larry" ; ok 171, $cursor->c_get($k, $v, DB_NEXT_DUP) == 0 ; - ok 172, $k eq "Wall" && $v eq "Brick" ; + ok 172, $k eq "Wall" && $v eq "Stone" ; ok 173, $cursor->c_get($k, $v, DB_NEXT_DUP) == 0 ; ok 174, $k eq "Wall" && $v eq "Brick" ; - ok 175, $cursor->c_get($k, $v, DB_NEXT_DUP) == DB_NOTFOUND ; + ok 175, $cursor->c_get($k, $v, DB_NEXT_DUP) == 0 ; + ok 176, $k eq "Wall" && $v eq "Brick" ; + ok 177, $cursor->c_get($k, $v, DB_NEXT_DUP) == DB_NOTFOUND ; undef $db ; @@ -554,12 +557,12 @@ umask(0) ; my @Keys = qw( 0123 9 12 -1234 9 987654321 9 def ) ; my @Values = qw( 1 11 3 dd x abc 2 0 ) ; - ok 176, tie %h, "BerkeleyDB::Hash", -Filename => $Dfile, + ok 178, tie %h, "BerkeleyDB::Hash", -Filename => $Dfile, -DupCompare => sub { $_[0] cmp $_[1] }, -Property => DB_DUP|DB_DUPSORT, -Flags => DB_CREATE ; - ok 177, tie %g, 'BerkeleyDB::Hash', -Filename => $Dfile2, + ok 179, tie %g, 'BerkeleyDB::Hash', -Filename => $Dfile2, -DupCompare => sub { $_[0] <=> $_[1] }, -Property => DB_DUP|DB_DUPSORT, -Flags => DB_CREATE ; @@ -571,23 +574,23 @@ umask(0) ; $g{$_} = $value ; } - ok 178, my $cursor = (tied %h)->db_cursor() ; + ok 180, my $cursor = (tied %h)->db_cursor() ; $key = 9 ; $value = ""; - ok 179, $cursor->c_get($key, $value, DB_SET) == 0 ; - ok 180, $key == 9 && $value eq 11 ; - ok 181, $cursor->c_get($key, $value, DB_NEXT) == 0 ; - ok 182, $key == 9 && $value == 2 ; + ok 181, $cursor->c_get($key, $value, DB_SET) == 0 ; + ok 182, $key == 9 && $value eq 11 ; ok 183, $cursor->c_get($key, $value, DB_NEXT) == 0 ; - ok 184, $key == 9 && $value eq "x" ; + ok 184, $key == 9 && $value == 2 ; + ok 185, $cursor->c_get($key, $value, DB_NEXT) == 0 ; + ok 186, $key == 9 && $value eq "x" ; $cursor = (tied %g)->db_cursor() ; $key = 9 ; - ok 185, $cursor->c_get($key, $value, DB_SET) == 0 ; - ok 186, $key == 9 && $value eq "x" ; - ok 187, $cursor->c_get($key, $value, DB_NEXT) == 0 ; - ok 188, $key == 9 && $value == 2 ; + ok 187, $cursor->c_get($key, $value, DB_SET) == 0 ; + ok 188, $key == 9 && $value eq "x" ; ok 189, $cursor->c_get($key, $value, DB_NEXT) == 0 ; - ok 190, $key == 9 && $value == 11 ; + ok 190, $key == 9 && $value == 2 ; + ok 191, $cursor->c_get($key, $value, DB_NEXT) == 0 ; + ok 192, $key == 9 && $value == 11 ; } @@ -597,7 +600,7 @@ umask(0) ; my $lex = new LexFile $Dfile; my %hh ; - ok 191, my $YY = tie %hh, "BerkeleyDB::Hash", -Filename => $Dfile, + ok 193, my $YY = tie %hh, "BerkeleyDB::Hash", -Filename => $Dfile, -DupCompare => sub { $_[0] cmp $_[1] }, -Property => DB_DUP, -Flags => DB_CREATE ; @@ -609,34 +612,34 @@ umask(0) ; $hh{'mouse'} = 'mickey' ; # first work in scalar context - ok 192, scalar $YY->get_dup('Unknown') == 0 ; - ok 193, scalar $YY->get_dup('Smith') == 1 ; - ok 194, scalar $YY->get_dup('Wall') == 3 ; + ok 194, scalar $YY->get_dup('Unknown') == 0 ; + ok 195, scalar $YY->get_dup('Smith') == 1 ; + ok 196, scalar $YY->get_dup('Wall') == 3 ; # now in list context my @unknown = $YY->get_dup('Unknown') ; - ok 195, "@unknown" eq "" ; + ok 197, "@unknown" eq "" ; my @smith = $YY->get_dup('Smith') ; - ok 196, "@smith" eq "John" ; + ok 198, "@smith" eq "John" ; { my @wall = $YY->get_dup('Wall') ; my %wall ; @wall{@wall} = @wall ; - ok 197, (@wall == 3 && $wall{'Larry'} + ok 199, (@wall == 3 && $wall{'Larry'} && $wall{'Stone'} && $wall{'Brick'}); } # hash my %unknown = $YY->get_dup('Unknown', 1) ; - ok 198, keys %unknown == 0 ; + ok 200, keys %unknown == 0 ; my %smith = $YY->get_dup('Smith', 1) ; - ok 199, keys %smith == 1 && $smith{'John'} ; + ok 201, keys %smith == 1 && $smith{'John'} ; my %wall = $YY->get_dup('Wall', 1) ; - ok 200, keys %wall == 3 && $wall{'Larry'} == 1 && $wall{'Stone'} == 1 + ok 202, keys %wall == 3 && $wall{'Larry'} == 1 && $wall{'Stone'} == 1 && $wall{'Brick'} == 1 ; undef $YY ; @@ -692,7 +695,7 @@ EOM BEGIN { push @INC, '.'; } eval 'use SubDB ; '; - main::ok 201, $@ eq "" ; + main::ok 203, $@ eq "" ; my %h ; my $X ; eval ' @@ -701,24 +704,24 @@ EOM -Mode => 0640 ); ' ; - main::ok 202, $@ eq "" ; + main::ok 204, $@ eq "" ; my $ret = eval '$h{"fred"} = 3 ; return $h{"fred"} ' ; - main::ok 203, $@ eq "" ; - main::ok 204, $ret == 7 ; + main::ok 205, $@ eq "" ; + main::ok 206, $ret == 7 ; my $value = 0; $ret = eval '$X->db_put("joe", 4) ; $X->db_get("joe", $value) ; return $value' ; - main::ok 205, $@ eq "" ; - main::ok 206, $ret == 10 ; + main::ok 207, $@ eq "" ; + main::ok 208, $ret == 10 ; $ret = eval ' DB_NEXT eq main::DB_NEXT ' ; - main::ok 207, $@ eq "" ; - main::ok 208, $ret == 1 ; + main::ok 209, $@ eq "" ; + main::ok 210, $ret == 1 ; $ret = eval '$X->A_new_method("joe") ' ; - main::ok 209, $@ eq "" ; - main::ok 210, $ret eq "[[10]]" ; + main::ok 211, $@ eq "" ; + main::ok 212, $ret eq "[[10]]" ; unlink "SubDB.pm", "dbhash.tmp" ; diff --git a/db/perl/BerkeleyDB/t/join.t b/db/perl/BerkeleyDB/t/join.t index d63726c79..ed9b6a269 100644 --- a/db/perl/BerkeleyDB/t/join.t +++ b/db/perl/BerkeleyDB/t/join.t @@ -222,4 +222,4 @@ umask(0) ; untie %hash2 ; untie %hash3 ; } - +print "# at the end\n"; diff --git a/db/perl/BerkeleyDB/t/mldbm.t b/db/perl/BerkeleyDB/t/mldbm.t index fe195fe46..d35f7e158 100644 --- a/db/perl/BerkeleyDB/t/mldbm.t +++ b/db/perl/BerkeleyDB/t/mldbm.t @@ -1,5 +1,7 @@ #!/usr/bin/perl -w +use strict ; + BEGIN { if ($] < 5.005) { @@ -28,34 +30,35 @@ use t::util ; print "1..12\n"; { -package BTREE ; - -use BerkeleyDB ; -use MLDBM qw(BerkeleyDB::Btree) ; -use Data::Dumper; - -$filename = 'testmldbm' ; - -unlink $filename ; -$MLDBM::UseDB = "BerkeleyDB::Btree" ; -$db = tie %o, MLDBM, -Filename => $filename, - -Flags => DB_CREATE - or die $!; -::ok 1, $db ; -::ok 2, $db->type() == DB_BTREE ; - -$c = [\'c']; -$b = {}; -$a = [1, $b, $c]; -$b->{a} = $a; -$b->{b} = $a->[1]; -$b->{c} = $a->[2]; -@o{qw(a b c)} = ($a, $b, $c); -$o{d} = "{once upon a time}"; -$o{e} = 1024; -$o{f} = 1024.1024; -$first = Data::Dumper->new([@o{qw(a b c)}], [qw(a b c)])->Quotekeys(0)->Dump; -$second = <<'EOT'; + package BTREE ; + + use BerkeleyDB ; + use MLDBM qw(BerkeleyDB::Btree) ; + use Data::Dumper; + + my $filename = ""; + my $lex = new LexFile $filename; + + $MLDBM::UseDB = "BerkeleyDB::Btree" ; + my %o ; + my $db = tie %o, 'MLDBM', -Filename => $filename, + -Flags => DB_CREATE + or die $!; + ::ok 1, $db ; + ::ok 2, $db->type() == DB_BTREE ; + + my $c = [\'c']; + my $b = {}; + my $a = [1, $b, $c]; + $b->{a} = $a; + $b->{b} = $a->[1]; + $b->{c} = $a->[2]; + @o{qw(a b c)} = ($a, $b, $c); + $o{d} = "{once upon a time}"; + $o{e} = 1024; + $o{f} = 1024.1024; + my $first = Data::Dumper->new([@o{qw(a b c)}], [qw(a b c)])->Quotekeys(0)->Dump; + my $second = <<'EOT'; $a = [ 1, { @@ -82,46 +85,47 @@ $c = [ \'c' ]; EOT - -::ok 3, $first eq $second ; -::ok 4, $o{d} eq "{once upon a time}" ; -::ok 5, $o{e} == 1024 ; -::ok 6, $o{f} eq 1024.1024 ; - -unlink $filename ; + + ::ok 3, $first eq $second ; + ::ok 4, $o{d} eq "{once upon a time}" ; + ::ok 5, $o{e} == 1024 ; + ::ok 6, $o{f} eq 1024.1024 ; + } { -package HASH ; - -use BerkeleyDB ; -use MLDBM qw(BerkeleyDB::Hash) ; -use Data::Dumper; - -$filename = 'testmldbm' ; - -unlink $filename ; -$MLDBM::UseDB = "BerkeleyDB::Hash" ; -$db = tie %o, MLDBM, -Filename => $filename, - -Flags => DB_CREATE - or die $!; -::ok 7, $db ; -::ok 8, $db->type() == DB_HASH ; - - -$c = [\'c']; -$b = {}; -$a = [1, $b, $c]; -$b->{a} = $a; -$b->{b} = $a->[1]; -$b->{c} = $a->[2]; -@o{qw(a b c)} = ($a, $b, $c); -$o{d} = "{once upon a time}"; -$o{e} = 1024; -$o{f} = 1024.1024; -$first = Data::Dumper->new([@o{qw(a b c)}], [qw(a b c)])->Quotekeys(0)->Dump; -$second = <<'EOT'; + package HASH ; + + use BerkeleyDB ; + use MLDBM qw(BerkeleyDB::Hash) ; + use Data::Dumper; + + my $filename = ""; + my $lex = new LexFile $filename; + + unlink $filename ; + $MLDBM::UseDB = "BerkeleyDB::Hash" ; + my %o ; + my $db = tie %o, 'MLDBM', -Filename => $filename, + -Flags => DB_CREATE + or die $!; + ::ok 7, $db ; + ::ok 8, $db->type() == DB_HASH ; + + + my $c = [\'c']; + my $b = {}; + my $a = [1, $b, $c]; + $b->{a} = $a; + $b->{b} = $a->[1]; + $b->{c} = $a->[2]; + @o{qw(a b c)} = ($a, $b, $c); + $o{d} = "{once upon a time}"; + $o{e} = 1024; + $o{f} = 1024.1024; + my $first = Data::Dumper->new([@o{qw(a b c)}], [qw(a b c)])->Quotekeys(0)->Dump; + my $second = <<'EOT'; $a = [ 1, { @@ -149,11 +153,9 @@ $c = [ ]; EOT -::ok 9, $first eq $second ; -::ok 10, $o{d} eq "{once upon a time}" ; -::ok 11, $o{e} == 1024 ; -::ok 12, $o{f} eq 1024.1024 ; - -unlink $filename ; + ::ok 9, $first eq $second ; + ::ok 10, $o{d} eq "{once upon a time}" ; + ::ok 11, $o{e} == 1024 ; + ::ok 12, $o{f} eq 1024.1024 ; } diff --git a/db/perl/BerkeleyDB/t/queue.t b/db/perl/BerkeleyDB/t/queue.t index 3a0d107d8..86add129c 100644 --- a/db/perl/BerkeleyDB/t/queue.t +++ b/db/perl/BerkeleyDB/t/queue.t @@ -22,7 +22,7 @@ BEGIN } } -print "1..197\n"; +print "1..201\n"; sub fillout { @@ -210,17 +210,6 @@ umask(0) ; { # Tied Array interface - # full tied array support started in Perl 5.004_57 - # just double check. - my $FA = 0 ; - { - sub try::TIEARRAY { bless [], "try" } - sub try::FETCHSIZE { $FA = 1 } - my @a ; - tie @a, 'try' ; - my $a = @a ; - } - my $lex = new LexFile $Dfile ; my @array ; my $db ; @@ -545,6 +534,10 @@ umask(0) ; -Pad => " " ; + ok 173, $txn->txn_commit() == 0 ; + ok 174, $txn = $env->txn_begin() ; + $db1->Txn($txn); + # create some data my @data = ( "boat", @@ -557,31 +550,31 @@ umask(0) ; for ($i = 0 ; $i < @data ; ++$i) { $ret += $db1->db_put($i, $data[$i]) ; } - ok 173, $ret == 0 ; + ok 175, $ret == 0 ; # should be able to see all the records - ok 174, my $cursor = $db1->db_cursor() ; + ok 176, my $cursor = $db1->db_cursor() ; my ($k, $v) = (0, "") ; my $count = 0 ; # sequence forwards while ($cursor->c_get($k, $v, DB_NEXT) == 0) { ++ $count ; } - ok 175, $count == 3 ; + ok 177, $count == 3 ; undef $cursor ; # now abort the transaction - ok 176, $txn->txn_abort() == 0 ; + ok 178, $txn->txn_abort() == 0 ; # there shouldn't be any records in the database $count = 0 ; # sequence forwards - ok 177, $cursor = $db1->db_cursor() ; + ok 179, $cursor = $db1->db_cursor() ; while ($cursor->c_get($k, $v, DB_NEXT) == 0) { ++ $count ; } - ok 178, $count == 0 ; + ok 180, $count == 0 ; undef $txn ; undef $cursor ; @@ -599,7 +592,7 @@ umask(0) ; my @array ; my ($k, $v) ; my $rec_len = 7 ; - ok 179, my $db = new BerkeleyDB::Queue -Filename => $Dfile, + ok 181, my $db = new BerkeleyDB::Queue -Filename => $Dfile, -Flags => DB_CREATE, -Pagesize => 4 * 1024, -Len => $rec_len, @@ -607,8 +600,8 @@ umask(0) ; ; my $ref = $db->db_stat() ; - ok 180, $ref->{$recs} == 0; - ok 181, $ref->{'qs_pagesize'} == 4 * 1024; + ok 182, $ref->{$recs} == 0; + ok 183, $ref->{'qs_pagesize'} == 4 * 1024; # create some data my @data = ( @@ -622,10 +615,10 @@ umask(0) ; for ($i = $db->ArrayOffset ; @data ; ++$i) { $ret += $db->db_put($i, shift @data) ; } - ok 182, $ret == 0 ; + ok 184, $ret == 0 ; $ref = $db->db_stat() ; - ok 183, $ref->{$recs} == 3; + ok 185, $ref->{$recs} == 3; } { @@ -676,12 +669,12 @@ EOM BEGIN { push @INC, '.'; } eval 'use SubDB ; '; - main::ok 184, $@ eq "" ; + main::ok 186, $@ eq "" ; my @h ; my $X ; my $rec_len = 34 ; eval ' - $X = tie(@h, "SubDB", -Filename => "dbbtree.tmp", + $X = tie(@h, "SubDB", -Filename => "dbqueue.tmp", -Flags => DB_CREATE, -Mode => 0640 , -Len => $rec_len, @@ -689,26 +682,28 @@ EOM ); ' ; - main::ok 185, $@ eq "" ; + main::ok 187, $@ eq "" ; my $ret = eval '$h[1] = 3 ; return $h[1] ' ; - main::ok 186, $@ eq "" ; - main::ok 187, $ret == 7 ; + main::ok 188, $@ eq "" ; + main::ok 189, $ret == 7 ; my $value = 0; $ret = eval '$X->db_put(1, 4) ; $X->db_get(1, $value) ; return $value' ; - main::ok 188, $@ eq "" ; - main::ok 189, $ret == 10 ; + main::ok 190, $@ eq "" ; + main::ok 191, $ret == 10 ; $ret = eval ' DB_NEXT eq main::DB_NEXT ' ; - main::ok 190, $@ eq "" ; - main::ok 191, $ret == 1 ; + main::ok 192, $@ eq "" ; + main::ok 193, $ret == 1 ; $ret = eval '$X->A_new_method(1) ' ; - main::ok 192, $@ eq "" ; - main::ok 193, $ret eq "[[10]]" ; + main::ok 194, $@ eq "" ; + main::ok 195, $ret eq "[[10]]" ; - unlink "SubDB.pm", "dbbtree.tmp" ; + undef $X ; + untie @h ; + unlink "SubDB.pm", "dbqueue.tmp" ; } @@ -719,7 +714,7 @@ EOM my @array ; my $value ; my $rec_len = 21 ; - ok 194, my $db = tie @array, 'BerkeleyDB::Queue', + ok 196, my $db = tie @array, 'BerkeleyDB::Queue', -Filename => $Dfile, -Flags => DB_CREATE , -Len => $rec_len, @@ -730,14 +725,36 @@ EOM $array[3] = "ghi" ; my $k = 0 ; - ok 195, $db->db_put($k, "fred", DB_APPEND) == 0 ; - ok 196, $k == 4 ; - ok 197, $array[4] eq fillout("fred", $rec_len) ; + ok 197, $db->db_put($k, "fred", DB_APPEND) == 0 ; + ok 198, $k == 4 ; + ok 199, $array[4] eq fillout("fred", $rec_len) ; undef $db ; untie @array ; } +{ + # 23 Sept 2001 -- push into an empty array + my $lex = new LexFile $Dfile ; + my @array ; + my $db ; + my $rec_len = 21 ; + ok 200, $db = tie @array, 'BerkeleyDB::Queue', + -Flags => DB_CREATE , + -ArrayBase => 0, + -Len => $rec_len, + -Pad => " " , + -Filename => $Dfile ; + $FA ? push @array, "first" + : $db->push("first") ; + + ok 201, ($FA ? pop @array : $db->pop()) eq fillout("first", $rec_len) ; + + undef $db; + untie @array ; + +} + __END__ diff --git a/db/perl/BerkeleyDB/t/recno.t b/db/perl/BerkeleyDB/t/recno.t index 4da7ae2e0..64b1803f7 100644 --- a/db/perl/BerkeleyDB/t/recno.t +++ b/db/perl/BerkeleyDB/t/recno.t @@ -14,7 +14,7 @@ BEGIN { use BerkeleyDB; use t::util ; -print "1..218\n"; +print "1..226\n"; my $Dfile = "dbhash.tmp"; my $Dfile2 = "dbhash2.tmp"; @@ -23,7 +23,6 @@ unlink $Dfile; umask(0) ; - # Check for invalid parameters { # Check for invalid parameters @@ -184,16 +183,6 @@ umask(0) ; { # Tied Array interface - # full tied array support started in Perl 5.004_57 - # just double check. - my $FA = 0 ; - { - sub try::TIEARRAY { bless [], "try" } - sub try::FETCHSIZE { $FA = 1 } - my @a ; - tie @a, 'try' ; - my $a = @a ; - } my $lex = new LexFile $Dfile ; my @array ; @@ -488,6 +477,10 @@ umask(0) ; -Txn => $txn ; + ok 171, $txn->txn_commit() == 0 ; + ok 172, $txn = $env->txn_begin() ; + $db1->Txn($txn); + # create some data my @data = ( "boat", @@ -500,31 +493,31 @@ umask(0) ; for ($i = 0 ; $i < @data ; ++$i) { $ret += $db1->db_put($i, $data[$i]) ; } - ok 171, $ret == 0 ; + ok 173, $ret == 0 ; # should be able to see all the records - ok 172, my $cursor = $db1->db_cursor() ; + ok 174, my $cursor = $db1->db_cursor() ; my ($k, $v) = (0, "") ; my $count = 0 ; # sequence forwards while ($cursor->c_get($k, $v, DB_NEXT) == 0) { ++ $count ; } - ok 173, $count == 3 ; + ok 175, $count == 3 ; undef $cursor ; # now abort the transaction - ok 174, $txn->txn_abort() == 0 ; + ok 176, $txn->txn_abort() == 0 ; # there shouldn't be any records in the database $count = 0 ; # sequence forwards - ok 175, $cursor = $db1->db_cursor() ; + ok 177, $cursor = $db1->db_cursor() ; while ($cursor->c_get($k, $v, DB_NEXT) == 0) { ++ $count ; } - ok 176, $count == 0 ; + ok 178, $count == 0 ; undef $txn ; undef $cursor ; @@ -541,14 +534,14 @@ umask(0) ; my $recs = ($BerkeleyDB::db_version >= 3.1 ? "bt_ndata" : "bt_nrecs") ; my @array ; my ($k, $v) ; - ok 177, my $db = new BerkeleyDB::Recno -Filename => $Dfile, + ok 179, my $db = new BerkeleyDB::Recno -Filename => $Dfile, -Flags => DB_CREATE, -Pagesize => 4 * 1024, ; my $ref = $db->db_stat() ; - ok 178, $ref->{$recs} == 0; - ok 179, $ref->{'bt_pagesize'} == 4 * 1024; + ok 180, $ref->{$recs} == 0; + ok 181, $ref->{'bt_pagesize'} == 4 * 1024; # create some data my @data = ( @@ -562,10 +555,10 @@ umask(0) ; for ($i = $db->ArrayOffset ; @data ; ++$i) { $ret += $db->db_put($i, shift @data) ; } - ok 180, $ret == 0 ; + ok 182, $ret == 0 ; $ref = $db->db_stat() ; - ok 181, $ref->{$recs} == 3; + ok 183, $ref->{$recs} == 3; } { @@ -616,35 +609,37 @@ EOM BEGIN { push @INC, '.'; } eval 'use SubDB ; '; - main::ok 182, $@ eq "" ; + main::ok 184, $@ eq "" ; my @h ; my $X ; eval ' - $X = tie(@h, "SubDB", -Filename => "dbbtree.tmp", + $X = tie(@h, "SubDB", -Filename => "dbrecno.tmp", -Flags => DB_CREATE, -Mode => 0640 ); ' ; - main::ok 183, $@ eq "" ; + main::ok 185, $@ eq "" ; my $ret = eval '$h[1] = 3 ; return $h[1] ' ; - main::ok 184, $@ eq "" ; - main::ok 185, $ret == 7 ; + main::ok 186, $@ eq "" ; + main::ok 187, $ret == 7 ; my $value = 0; $ret = eval '$X->db_put(1, 4) ; $X->db_get(1, $value) ; return $value' ; - main::ok 186, $@ eq "" ; - main::ok 187, $ret == 10 ; + main::ok 188, $@ eq "" ; + main::ok 189, $ret == 10 ; $ret = eval ' DB_NEXT eq main::DB_NEXT ' ; - main::ok 188, $@ eq "" ; - main::ok 189, $ret == 1 ; + main::ok 190, $@ eq "" ; + main::ok 191, $ret == 1 ; $ret = eval '$X->A_new_method(1) ' ; - main::ok 190, $@ eq "" ; - main::ok 191, $ret eq "[[10]]" ; + main::ok 192, $@ eq "" ; + main::ok 193, $ret eq "[[10]]" ; - unlink "SubDB.pm", "dbbtree.tmp" ; + undef $X; + untie @h; + unlink "SubDB.pm", "dbrecno.tmp" ; } @@ -655,7 +650,7 @@ EOM touch $Dfile2 ; my @array ; my $value ; - ok 192, tie @array, 'BerkeleyDB::Recno', -Filename => $Dfile, + ok 194, tie @array, 'BerkeleyDB::Recno', -Filename => $Dfile, -ArrayBase => 0, -Flags => DB_CREATE , -Source => $Dfile2 ; @@ -665,7 +660,7 @@ EOM untie @array ; my $x = docat($Dfile2) ; - ok 193, $x eq "abc\ndef\n\nghi\n" ; + ok 195, $x eq "abc\ndef\n\nghi\n" ; } { @@ -675,7 +670,7 @@ EOM touch $Dfile2 ; my @array ; my $value ; - ok 194, tie @array, 'BerkeleyDB::Recno', -Filename => $Dfile, + ok 196, tie @array, 'BerkeleyDB::Recno', -Filename => $Dfile, -ArrayBase => 0, -Flags => DB_CREATE , -Source => $Dfile2 , @@ -686,7 +681,7 @@ EOM untie @array ; my $x = docat($Dfile2) ; - ok 195, $x eq "abc-def--ghi-"; + ok 197, $x eq "abc-def--ghi-"; } { @@ -696,7 +691,7 @@ EOM touch $Dfile2 ; my @array ; my $value ; - ok 196, tie @array, 'BerkeleyDB::Recno', -Filename => $Dfile, + ok 198, tie @array, 'BerkeleyDB::Recno', -Filename => $Dfile, -ArrayBase => 0, -Flags => DB_CREATE , -Len => 5, @@ -707,7 +702,7 @@ EOM untie @array ; my $x = docat($Dfile2) ; - ok 197, $x eq "abc def ghi " ; + ok 199, $x eq "abc def ghi " ; } { @@ -717,7 +712,7 @@ EOM touch $Dfile2 ; my @array ; my $value ; - ok 198, tie @array, 'BerkeleyDB::Recno', -Filename => $Dfile, + ok 200, tie @array, 'BerkeleyDB::Recno', -Filename => $Dfile, -ArrayBase => 0, -Flags => DB_CREATE , -Len => 5, @@ -729,7 +724,7 @@ EOM untie @array ; my $x = docat($Dfile2) ; - ok 199, $x eq "abc--def-------ghi--" ; + ok 201, $x eq "abc--def-------ghi--" ; } { @@ -738,7 +733,7 @@ EOM my $lex = new LexFile $Dfile; my @array ; my $value ; - ok 200, my $db = tie @array, 'BerkeleyDB::Recno', -Filename => $Dfile, + ok 202, my $db = tie @array, 'BerkeleyDB::Recno', -Filename => $Dfile, -Property => DB_RENUMBER, -ArrayBase => 0, -Flags => DB_CREATE ; @@ -747,14 +742,14 @@ EOM $array[1] = "def" ; $array[3] = "ghi" ; - ok 201, my ($length, $joined) = joiner($db, "|") ; - ok 202, $length == 3 ; - ok 203, $joined eq "abc|def|ghi"; + ok 203, my ($length, $joined) = joiner($db, "|") ; + ok 204, $length == 3 ; + ok 205, $joined eq "abc|def|ghi"; - ok 204, $db->db_del(1) == 0 ; - ok 205, ($length, $joined) = joiner($db, "|") ; - ok 206, $length == 2 ; - ok 207, $joined eq "abc|ghi"; + ok 206, $db->db_del(1) == 0 ; + ok 207, ($length, $joined) = joiner($db, "|") ; + ok 208, $length == 2 ; + ok 209, $joined eq "abc|ghi"; undef $db ; untie @array ; @@ -767,7 +762,7 @@ EOM my $lex = new LexFile $Dfile; my @array ; my $value ; - ok 208, my $db = tie @array, 'BerkeleyDB::Recno', + ok 210, my $db = tie @array, 'BerkeleyDB::Recno', -Filename => $Dfile, -Flags => DB_CREATE ; @@ -776,8 +771,8 @@ EOM $array[3] = "ghi" ; my $k = 0 ; - ok 209, $db->db_put($k, "fred", DB_APPEND) == 0 ; - ok 210, $k == 4 ; + ok 211, $db->db_put($k, "fred", DB_APPEND) == 0 ; + ok 212, $k == 4 ; undef $db ; untie @array ; @@ -790,7 +785,7 @@ EOM touch $Dfile2 ; my @array ; my $value ; - ok 211, tie @array, 'BerkeleyDB::Recno', -Source => $Dfile2 , + ok 213, tie @array, 'BerkeleyDB::Recno', -Source => $Dfile2 , -ArrayBase => 0, -Property => DB_RENUMBER, -Flags => DB_CREATE ; @@ -800,7 +795,7 @@ EOM untie @array ; my $x = docat($Dfile2) ; - ok 212, $x eq "abc\ndef\n\nghi\n" ; + ok 214, $x eq "abc\ndef\n\nghi\n" ; } { @@ -810,7 +805,7 @@ EOM touch $Dfile2 ; my @array ; my $value ; - ok 213, tie @array, 'BerkeleyDB::Recno', + ok 215, tie @array, 'BerkeleyDB::Recno', -ArrayBase => 0, -Flags => DB_CREATE , -Source => $Dfile2 , @@ -822,7 +817,7 @@ EOM untie @array ; my $x = docat($Dfile2) ; - ok 214, $x eq "abc-def--ghi-"; + ok 216, $x eq "abc-def--ghi-"; } { @@ -832,7 +827,7 @@ EOM touch $Dfile2 ; my @array ; my $value ; - ok 215, tie @array, 'BerkeleyDB::Recno', -ArrayBase => 0, + ok 217, tie @array, 'BerkeleyDB::Recno', -ArrayBase => 0, -Flags => DB_CREATE , -Property => DB_RENUMBER, -Len => 5, @@ -843,7 +838,7 @@ EOM untie @array ; my $x = docat($Dfile2) ; - ok 216, $x eq "abc def ghi " ; + ok 218, $x eq "abc def ghi " ; } { @@ -853,7 +848,7 @@ EOM touch $Dfile2 ; my @array ; my $value ; - ok 217, tie @array, 'BerkeleyDB::Recno', + ok 219, tie @array, 'BerkeleyDB::Recno', -ArrayBase => 0, -Flags => DB_CREATE , -Property => DB_RENUMBER, @@ -866,9 +861,50 @@ EOM untie @array ; my $x = docat($Dfile2) ; - ok 218, $x eq "abc--def-------ghi--" ; + ok 220, $x eq "abc--def-------ghi--" ; } +{ + # 23 Sept 2001 -- push into an empty array + my $lex = new LexFile $Dfile ; + my @array ; + my $db ; + ok 221, $db = tie @array, 'BerkeleyDB::Recno', + -ArrayBase => 0, + -Flags => DB_CREATE , + -Property => DB_RENUMBER, + -Filename => $Dfile ; + $FA ? push @array, "first" + : $db->push("first") ; + + ok 222, $array[0] eq "first" ; + ok 223, $FA ? pop @array : $db->pop() eq "first" ; + + undef $db; + untie @array ; + +} + +{ + # 23 Sept 2001 -- unshift into an empty array + my $lex = new LexFile $Dfile ; + my @array ; + my $db ; + ok 224, $db = tie @array, 'BerkeleyDB::Recno', + -ArrayBase => 0, + -Flags => DB_CREATE , + -Property => DB_RENUMBER, + -Filename => $Dfile ; + $FA ? unshift @array, "first" + : $db->unshift("first") ; + + ok 225, $array[0] eq "first" ; + ok 226, ($FA ? shift @array : $db->shift()) eq "first" ; + + undef $db; + untie @array ; + +} __END__ diff --git a/db/perl/BerkeleyDB/t/strict.t b/db/perl/BerkeleyDB/t/strict.t index a87d5312e..ab41d44cb 100644 --- a/db/perl/BerkeleyDB/t/strict.t +++ b/db/perl/BerkeleyDB/t/strict.t @@ -87,6 +87,7 @@ umask(0); eval { $status = $db->db_close() ; } ; ok 16, $status == 0 ; ok 17, $@ eq "" ; + #print "[$@]\n" ; eval { $status = $env->db_appexit() ; } ; ok 18, $status == 0 ; ok 19, $@ eq "" ; @@ -164,6 +165,7 @@ umask(0); eval { $status = $db->db_close() ; } ; ok 41, $status == 0 ; ok 42, $@ eq "" ; + #print "[$@]\n" ; eval { $status = $env->db_appexit() ; } ; ok 43, $status == 0 ; ok 44, $@ eq "" ; diff --git a/db/perl/BerkeleyDB/t/subdb.t b/db/perl/BerkeleyDB/t/subdb.t index c48ec6e25..23016d646 100644 --- a/db/perl/BerkeleyDB/t/subdb.t +++ b/db/perl/BerkeleyDB/t/subdb.t @@ -232,6 +232,7 @@ umask(0) ; ok 38, $status == DB_NOTFOUND ; ok 39, @dbnames == 0 ; undef $db ; + undef $cursor ; ok 40, -e $Dfile ; ok 41, BerkeleyDB::db_remove(-Filename => $Dfile) == 0 ; diff --git a/db/perl/BerkeleyDB/t/txn.t b/db/perl/BerkeleyDB/t/txn.t index c746c8d9b..ba6b636cd 100644 --- a/db/perl/BerkeleyDB/t/txn.t +++ b/db/perl/BerkeleyDB/t/txn.t @@ -12,7 +12,7 @@ BEGIN { use BerkeleyDB; use t::util ; -print "1..50\n"; +print "1..58\n"; my $Dfile = "dbhash.tmp"; @@ -57,6 +57,10 @@ umask(0); -Txn => $txn ; + ok 9, $txn->txn_commit() == 0 ; + ok 10, $txn = $env->txn_begin() ; + $db1->Txn($txn); + # create some data my %data = ( "red" => "boat", @@ -68,34 +72,34 @@ umask(0); while (my ($k, $v) = each %data) { $ret += $db1->db_put($k, $v) ; } - ok 9, $ret == 0 ; + ok 11, $ret == 0 ; # should be able to see all the records - ok 10, my $cursor = $db1->db_cursor() ; + ok 12, my $cursor = $db1->db_cursor() ; my ($k, $v) = ("", "") ; my $count = 0 ; # sequence forwards while ($cursor->c_get($k, $v, DB_NEXT) == 0) { ++ $count ; } - ok 11, $count == 3 ; + ok 13, $count == 3 ; undef $cursor ; # now abort the transaction - ok 12, $txn->txn_abort() == 0 ; + ok 14, $txn->txn_abort() == 0 ; # there shouldn't be any records in the database $count = 0 ; # sequence forwards - ok 13, $cursor = $db1->db_cursor() ; + ok 15, $cursor = $db1->db_cursor() ; while ($cursor->c_get($k, $v, DB_NEXT) == 0) { ++ $count ; } - ok 14, $count == 0 ; + ok 16, $count == 0 ; my $stat = $env->txn_stat() ; - ok 15, $stat->{'st_naborts'} == 1 ; + ok 17, $stat->{'st_naborts'} == 1 ; undef $txn ; undef $cursor ; @@ -112,17 +116,20 @@ umask(0); my $value ; my $home = "./fred" ; - ok 16, my $lexD = new LexDir($home); - ok 17, my $env = new BerkeleyDB::Env -Home => $home, + ok 18, my $lexD = new LexDir($home); + ok 19, my $env = new BerkeleyDB::Env -Home => $home, -Flags => DB_CREATE|DB_INIT_TXN| DB_INIT_MPOOL|DB_INIT_LOCK ; - ok 18, my $txn_mgr = $env->TxnMgr() ; - ok 19, my $txn = $txn_mgr->txn_begin() ; - ok 20, my $db1 = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile, + ok 20, my $txn_mgr = $env->TxnMgr() ; + ok 21, my $txn = $txn_mgr->txn_begin() ; + ok 22, my $db1 = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile, -Flags => DB_CREATE , -Env => $env, -Txn => $txn ; + ok 23, $txn->txn_commit() == 0 ; + ok 24, $txn = $env->txn_begin() ; + $db1->Txn($txn); # create some data my %data = ( @@ -135,34 +142,34 @@ umask(0); while (my ($k, $v) = each %data) { $ret += $db1->db_put($k, $v) ; } - ok 21, $ret == 0 ; + ok 25, $ret == 0 ; # should be able to see all the records - ok 22, my $cursor = $db1->db_cursor() ; + ok 26, my $cursor = $db1->db_cursor() ; my ($k, $v) = ("", "") ; my $count = 0 ; # sequence forwards while ($cursor->c_get($k, $v, DB_NEXT) == 0) { ++ $count ; } - ok 23, $count == 3 ; + ok 27, $count == 3 ; undef $cursor ; # now abort the transaction - ok 24, $txn->txn_abort() == 0 ; + ok 28, $txn->txn_abort() == 0 ; # there shouldn't be any records in the database $count = 0 ; # sequence forwards - ok 25, $cursor = $db1->db_cursor() ; + ok 29, $cursor = $db1->db_cursor() ; while ($cursor->c_get($k, $v, DB_NEXT) == 0) { ++ $count ; } - ok 26, $count == 0 ; + ok 30, $count == 0 ; my $stat = $txn_mgr->txn_stat() ; - ok 27, $stat->{'st_naborts'} == 1 ; + ok 31, $stat->{'st_naborts'} == 1 ; undef $txn ; undef $cursor ; @@ -180,17 +187,21 @@ umask(0); my $value ; my $home = "./fred" ; - ok 28, my $lexD = new LexDir($home); - ok 29, my $env = new BerkeleyDB::Env -Home => $home, + ok 32, my $lexD = new LexDir($home); + ok 33, my $env = new BerkeleyDB::Env -Home => $home, -Flags => DB_CREATE|DB_INIT_TXN| DB_INIT_MPOOL|DB_INIT_LOCK ; - ok 30, my $txn = $env->txn_begin() ; - ok 31, my $db1 = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile, + ok 34, my $txn = $env->txn_begin() ; + ok 35, my $db1 = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile, -Flags => DB_CREATE , -Env => $env, -Txn => $txn ; + ok 36, $txn->txn_commit() == 0 ; + ok 37, $txn = $env->txn_begin() ; + $db1->Txn($txn); + # create some data my %data = ( "red" => "boat", @@ -202,33 +213,33 @@ umask(0); while (my ($k, $v) = each %data) { $ret += $db1->db_put($k, $v) ; } - ok 32, $ret == 0 ; + ok 38, $ret == 0 ; # should be able to see all the records - ok 33, my $cursor = $db1->db_cursor() ; + ok 39, my $cursor = $db1->db_cursor() ; my ($k, $v) = ("", "") ; my $count = 0 ; # sequence forwards while ($cursor->c_get($k, $v, DB_NEXT) == 0) { ++ $count ; } - ok 34, $count == 3 ; + ok 40, $count == 3 ; undef $cursor ; # now commit the transaction - ok 35, $txn->txn_commit() == 0 ; + ok 41, $txn->txn_commit() == 0 ; $count = 0 ; # sequence forwards - ok 36, $cursor = $db1->db_cursor() ; + ok 42, $cursor = $db1->db_cursor() ; while ($cursor->c_get($k, $v, DB_NEXT) == 0) { ++ $count ; } - ok 37, $count == 3 ; + ok 43, $count == 3 ; my $stat = $env->txn_stat() ; - ok 38, $stat->{'st_naborts'} == 0 ; + ok 44, $stat->{'st_naborts'} == 0 ; undef $txn ; undef $cursor ; @@ -245,17 +256,20 @@ umask(0); my $value ; my $home = "./fred" ; - ok 39, my $lexD = new LexDir($home); - ok 40, my $env = new BerkeleyDB::Env -Home => $home, + ok 45, my $lexD = new LexDir($home); + ok 46, my $env = new BerkeleyDB::Env -Home => $home, -Flags => DB_CREATE|DB_INIT_TXN| DB_INIT_MPOOL|DB_INIT_LOCK ; - ok 41, my $txn_mgr = $env->TxnMgr() ; - ok 42, my $txn = $txn_mgr->txn_begin() ; - ok 43, my $db1 = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile, + ok 47, my $txn_mgr = $env->TxnMgr() ; + ok 48, my $txn = $txn_mgr->txn_begin() ; + ok 49, my $db1 = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile, -Flags => DB_CREATE , -Env => $env, -Txn => $txn ; + ok 50, $txn->txn_commit() == 0 ; + ok 51, $txn = $env->txn_begin() ; + $db1->Txn($txn); # create some data my %data = ( @@ -268,33 +282,33 @@ umask(0); while (my ($k, $v) = each %data) { $ret += $db1->db_put($k, $v) ; } - ok 44, $ret == 0 ; + ok 52, $ret == 0 ; # should be able to see all the records - ok 45, my $cursor = $db1->db_cursor() ; + ok 53, my $cursor = $db1->db_cursor() ; my ($k, $v) = ("", "") ; my $count = 0 ; # sequence forwards while ($cursor->c_get($k, $v, DB_NEXT) == 0) { ++ $count ; } - ok 46, $count == 3 ; + ok 54, $count == 3 ; undef $cursor ; # now commit the transaction - ok 47, $txn->txn_commit() == 0 ; + ok 55, $txn->txn_commit() == 0 ; $count = 0 ; # sequence forwards - ok 48, $cursor = $db1->db_cursor() ; + ok 56, $cursor = $db1->db_cursor() ; while ($cursor->c_get($k, $v, DB_NEXT) == 0) { ++ $count ; } - ok 49, $count == 3 ; + ok 57, $count == 3 ; my $stat = $txn_mgr->txn_stat() ; - ok 50, $stat->{'st_naborts'} == 0 ; + ok 58, $stat->{'st_naborts'} == 0 ; undef $txn ; undef $cursor ; diff --git a/db/perl/BerkeleyDB/t/util.pm b/db/perl/BerkeleyDB/t/util.pm index 0c7f0deb5..1a1449751 100644 --- a/db/perl/BerkeleyDB/t/util.pm +++ b/db/perl/BerkeleyDB/t/util.pm @@ -5,7 +5,9 @@ package main ; use strict ; use BerkeleyDB ; use File::Path qw(rmtree); -use vars qw(%DB_errors) ; +use vars qw(%DB_errors $FA) ; + +$| = 1; %DB_errors = ( 'DB_INCOMPLETE' => "DB_INCOMPLETE: Sync was unable to complete", @@ -18,20 +20,46 @@ use vars qw(%DB_errors) ; 'DB_RUNRECOVERY' => "DB_RUNRECOVERY: Fatal error, run database recovery", ) ; +# full tied array support started in Perl 5.004_57 +# just double check. +$FA = 0 ; +{ + sub try::TIEARRAY { bless [], "try" } + sub try::FETCHSIZE { $FA = 1 } + my @a ; + tie @a, 'try' ; + my $a = @a ; +} + { package LexFile ; + use vars qw( $basename @files ) ; + $basename = "db0000" ; + sub new { my $self = shift ; - unlink @_ ; - bless [ @_ ], $self ; + #my @files = () ; + foreach (@_) + { + $_ = $basename ; + unlink $basename ; + push @files, $basename ; + ++ $basename ; + } + bless [ @files ], $self ; } sub DESTROY { my $self = shift ; - unlink @{ $self } ; + #unlink @{ $self } ; + } + + END + { + foreach (@files) { unlink $_ } } } @@ -41,6 +69,8 @@ use vars qw(%DB_errors) ; use File::Path qw(rmtree); + use vars qw( $basename %dirs ) ; + sub new { my $self = shift ; @@ -56,8 +86,18 @@ use vars qw(%DB_errors) ; sub DESTROY { my $self = shift ; - rmtree $self->[0] ; + my $dir = $self->[0]; + #rmtree $dir; + $dirs{$dir} ++ ; + } + + END + { + foreach (keys %dirs) { + rmtree $_ if -d $_ ; + } } + } { |