diff options
author | jbj <devnull@localhost> | 2002-01-17 20:11:42 +0000 |
---|---|---|
committer | jbj <devnull@localhost> | 2002-01-17 20:11:42 +0000 |
commit | 3ef59667d3d4c6e2c4a64d53dc60472abb607e26 (patch) | |
tree | 2c6b1149b4b2c9a804aada943f8ee1a362bf6cef /db | |
parent | 3e0d0877ffe376e5187a173441a5f2a9ad68de49 (diff) | |
download | rpm-3ef59667d3d4c6e2c4a64d53dc60472abb607e26.tar.gz rpm-3ef59667d3d4c6e2c4a64d53dc60472abb607e26.tar.bz2 rpm-3ef59667d3d4c6e2c4a64d53dc60472abb607e26.zip |
Resync with db-4.0.14 (and what's on the rpm-4_0 branch).
CVS patchset: 5254
CVS date: 2002/01/17 20:11:42
Diffstat (limited to 'db')
104 files changed, 2847 insertions, 2950 deletions
diff --git a/db/cxx/cxx_db.cpp b/db/cxx/cxx_db.cpp index d573d48e4..66858ab16 100644 --- a/db/cxx/cxx_db.cpp +++ b/db/cxx/cxx_db.cpp @@ -8,7 +8,7 @@ #include "db_config.h" #ifndef lint -static const char revid[] = "Id: cxx_db.cpp,v 11.49 2001/07/28 20:01:18 dda Exp "; +static const char revid[] = "Id: cxx_db.cpp,v 11.50 2001/11/10 04:59:06 mjc Exp "; #endif /* not lint */ #include <errno.h> @@ -694,10 +694,10 @@ extern "C" int _verify_callback_c(void *handle, const void *str_arg) { char *str; - ostream *out; + OSTREAMCLASS *out; str = (char *)str_arg; - out = (ostream *)handle; + out = (OSTREAMCLASS *)handle; (*out) << str; if (out->fail()) @@ -707,7 +707,7 @@ int _verify_callback_c(void *handle, const void *str_arg) } int Db::verify(const char *name, const char *subdb, - ostream *ostr, u_int32_t flags) + OSTREAMCLASS *ostr, u_int32_t flags) { int err; DB *db = unwrap(this); @@ -816,7 +816,7 @@ int Db::set_paniccall(void (*callback)(DbEnv *, int)) return (env_->set_paniccall(callback)); } -void Db::set_error_stream(ostream *error_stream) +void Db::set_error_stream(OSTREAMCLASS *error_stream) { env_->set_error_stream(error_stream); } diff --git a/db/cxx/cxx_env.cpp b/db/cxx/cxx_env.cpp index 7c7d3ab82..d332f533d 100644 --- a/db/cxx/cxx_env.cpp +++ b/db/cxx/cxx_env.cpp @@ -8,7 +8,7 @@ #include "db_config.h" #ifndef lint -static const char revid[] = "Id: cxx_env.cpp,v 11.58 2001/10/04 21:13:59 bostic Exp "; +static const char revid[] = "Id: cxx_env.cpp,v 11.62 2001/11/10 04:59:06 mjc Exp "; #endif /* not lint */ #include <errno.h> @@ -21,6 +21,10 @@ static const char revid[] = "Id: cxx_env.cpp,v 11.58 2001/10/04 21:13:59 bostic #include "db_int.h" #include "common_ext.h" +#ifdef HAVE_CXX_STDHEADERS +using std::cerr; +#endif + // This datatype is needed for picky compilers. // extern "C" { @@ -39,7 +43,7 @@ extern "C" { // static int last_known_error_policy = ON_ERROR_UNKNOWN; -ostream *DbEnv::error_stream_ = 0; +OSTREAMCLASS *DbEnv::error_stream_ = 0; // These 'glue' function are declared as extern "C" so they will // be compatible with picky compilers that do not allow mixing @@ -78,11 +82,11 @@ int _tx_recover_intercept_c(DB_ENV *env, DBT *dbt, } extern "C" -int _rep_send_intercept_c(DB_ENV *env, void *cookie, const DBT *cntrl, - DBT *data, u_int32_t flags, int id) +int _rep_send_intercept_c(DB_ENV *env, const DBT *cntrl, + const DBT *data, int id, u_int32_t flags) { return (DbEnv::_rep_send_intercept(env, - cookie, cntrl, data, flags, id)); + cntrl, data, id, flags)); } // _destroy_check is called when there is a user error in a @@ -93,7 +97,7 @@ int _rep_send_intercept_c(DB_ENV *env, void *cookie, const DBT *cntrl, // void DbEnv::_destroy_check(const char *str, int isDbEnv) { - ostream *out; + OSTREAMCLASS *out; out = error_stream_; if (out == NULL || isDbEnv == 1) @@ -175,8 +179,8 @@ int DbEnv::_tx_recover_intercept(DB_ENV *env, DBT *dbt, return ((*cxxenv->tx_recover_callback_)(cxxenv, cxxdbt, cxxlsn, op)); } -int DbEnv::_rep_send_intercept(DB_ENV *env, void *cookie, const DBT *cntrl, - DBT *data, u_int32_t flags, int id) +int DbEnv::_rep_send_intercept(DB_ENV *env, const DBT *cntrl, + const DBT *data, int id, u_int32_t flags) { if (env == 0) { @@ -191,7 +195,7 @@ int DbEnv::_rep_send_intercept(DB_ENV *env, void *cookie, const DBT *cntrl, const Dbt *cxxcntrl = (const Dbt *)cntrl; Dbt *cxxdata = (Dbt *)data; return ((*cxxenv->rep_send_callback_)(cxxenv, - cookie, cxxcntrl, cxxdata, flags, id)); + cxxcntrl, cxxdata, flags, id)); } // A truism for the DbEnv object is that there is a valid @@ -798,7 +802,7 @@ void DbEnv::set_errcall(void (*arg)(const char *, char *)) // db_env triggered the call. A user that has multiple DB_ENVs // will simply not be able to have different streams for each one. // -void DbEnv::set_error_stream(ostream *stream) +void DbEnv::set_error_stream(OSTREAMCLASS *stream) { DB_ENV *dbenv = unwrap(this); @@ -978,27 +982,26 @@ int DbEnv::txn_stat(DB_TXN_STAT **statp, u_int32_t flags) return (err); } -int DbEnv::set_rep_transport(u_int32_t myid, void *cookie, - int (*f_send)(DbEnv *, void *, const Dbt *, Dbt *, u_int32_t, int)) +int DbEnv::set_rep_transport(u_int32_t myid, + int (*f_send)(DbEnv *, const Dbt *, const Dbt *, int, u_int32_t)) { int ret; DB_ENV *dbenv = unwrap(this); rep_send_callback_ = f_send; if ((ret = dbenv->set_rep_transport(dbenv, - myid, cookie, _rep_send_intercept_c)) != 0) + myid, _rep_send_intercept_c)) != 0) DB_ERROR("DbEnv::set_rep_transport", ret, error_policy()); return (ret); } -int DbEnv::rep_elect(int nsites, - int pri, u_int32_t wait, u_int32_t sleep, int *idp, int *selfp) +int DbEnv::rep_elect(int nsites, int pri, u_int32_t timeout, int *idp) { int ret; DB_ENV *dbenv = unwrap(this); if ((ret = dbenv->rep_elect(dbenv, - nsites, pri, wait, sleep, idp, selfp)) != 0) + nsites, pri, timeout, idp)) != 0) DB_ERROR("DbEnv::rep_elect", ret, error_policy()); return (ret); diff --git a/db/cxx/cxx_logc.cpp b/db/cxx/cxx_logc.cpp index f946b2523..61fb524a9 100644 --- a/db/cxx/cxx_logc.cpp +++ b/db/cxx/cxx_logc.cpp @@ -8,7 +8,7 @@ #include "db_config.h" #ifndef lint -static const char revid[] = "Id: cxx_logc.cpp,v 11.2 2001/10/02 01:33:37 bostic Exp "; +static const char revid[] = "Id: cxx_logc.cpp,v 11.3 2001/11/08 06:18:08 mjc Exp "; #endif /* not lint */ #include <errno.h> @@ -31,24 +31,26 @@ DbLogc::~DbLogc() { } -int DbLogc::close(u_int32_t flags) +// The name _flags prevents a name clash with __db_log_cursor::flags +int DbLogc::close(u_int32_t _flags) { DB_LOGC *cursor = this; int err; - if ((err = cursor->close(cursor, flags)) != 0) { + if ((err = cursor->close(cursor, _flags)) != 0) { DB_ERROR("DbLogc::close", err, ON_ERROR_UNKNOWN); return (err); } return (0); } -int DbLogc::get(DbLsn *lsn, Dbt *data, u_int32_t flags) +// The name _flags prevents a name clash with __db_log_cursor::flags +int DbLogc::get(DbLsn *lsn, Dbt *data, u_int32_t _flags) { DB_LOGC *cursor = this; int err; - if ((err = cursor->get(cursor, lsn, data, flags)) != 0) { + if ((err = cursor->get(cursor, lsn, data, _flags)) != 0) { // DB_NOTFOUND is a "normal" returns, // so should not be thrown as an error diff --git a/db/dist/aclocal/gcc.ac b/db/dist/aclocal/gcc.ac index 5bbf04168..0949d982f 100644 --- a/db/dist/aclocal/gcc.ac +++ b/db/dist/aclocal/gcc.ac @@ -1,39 +1,36 @@ -# Version 2.96 of gcc (shipped with RedHat Linux 7.[01]) incorrectly -# optimized for loops with conditionals in the termination clause. +# Version 2.96 of gcc (shipped with RedHat Linux 7.[01] and Mandrake) had +# serious problems. AC_DEFUN(AC_GCC_CONFIG1, [ +AC_CACHE_CHECK([whether we are using gcc version 2.96], +db_cv_gcc_2_96, [ +db_cv_gcc_2_96=no if test "$GCC" = "yes"; then - AC_CACHE_CHECK([for gcc 2.96 for-loop bug], db_cv_gcc_2_96_forloop_bug, [ - AC_TRY_RUN([void bug(unsigned int n) { - int i; - int shift = -1; - for (i=0; ((i < 10) && (shift < 0)) ; i++) { - if ((1UL << i) == n) - shift = i; - } - if (shift < 0) - exit(1); - } - int main() { - bug(64); - exit(0); - }], [db_cv_gcc_2_96_forloop_bug=no], [db_cv_gcc_2_96_forloop_bug=yes])]) - if test "$db_cv_gcc_2_96_forloop_bug" = "yes"; then + GCC_VERSION=`${MAKEFILE_CC} --version` + case ${GCC_VERSION} in + 2.96*) + db_cv_gcc_2_96=yes;; + esac +fi]) +if test "$db_cv_gcc_2_96" = "yes"; then CFLAGS=`echo "$CFLAGS" | sed 's/-O2/-O/'` CXXFLAGS=`echo "$CXXFLAGS" | sed 's/-O2/-O/'` AC_MSG_WARN([INSTALLED GCC COMPILER HAS SERIOUS BUGS; PLEASE UPGRADE.]) AC_MSG_WARN([GCC OPTIMIZATION LEVEL SET TO -O.]) - fi fi]) # Versions of g++ up to 2.8.0 required -fhandle-exceptions, but it is # renamed as -fexceptions and is the default in versions 2.8.0 and after. AC_DEFUN(AC_GCC_CONFIG2, [ +AC_CACHE_CHECK([whether g++ requires -fhandle-exceptions], +db_cv_gxx_except, [ +db_cv_gxx_except=no; if test "$GXX" = "yes"; then - CXXVERSION=`${MAKEFILE_CXX} --version` - case ${CXXVERSION} in + GXX_VERSION=`${MAKEFILE_CXX} --version` + case ${GXX_VERSION} in 1.*|2.[[01234567]].*|*-1.*|*-2.[[01234567]].*) - CXXFLAGS="-fhandle-exceptions $CXXFLAGS";; - *) - CXXFLAGS="-fexceptions $CXXFLAGS";; + db_cv_gxx_except=yes;; esac fi]) +if test "$db_cv_gxx_except" = "yes"; then + CXXFLAGS="$CXXFLAGS -fhandle-exceptions" +fi]) diff --git a/db/dist/aclocal/libtool.ac b/db/dist/aclocal/libtool.ac index 9cbfd0d68..29eef2f17 100644 --- a/db/dist/aclocal/libtool.ac +++ b/db/dist/aclocal/libtool.ac @@ -23,6 +23,7 @@ ## the same distribution terms that you use for the rest of that program. # serial 46 AC_PROG_LIBTOOL + AC_DEFUN([AC_PROG_LIBTOOL], [AC_REQUIRE([AC_LIBTOOL_SETUP])dnl @@ -148,9 +149,30 @@ _LT_AC_LTCONFIG_HACK ]) +# AC_LIBTOOL_HEADER_ASSERT +# ------------------------ +AC_DEFUN([AC_LIBTOOL_HEADER_ASSERT], +[AC_CACHE_CHECK([whether $CC supports assert without backlinking], + [lt_cv_func_assert_works], + [case $host in + *-*-solaris*) + if test "$GCC" = yes && test "$with_gnu_ld" != yes; then + case `$CC --version 2>/dev/null` in + [[12]].*) lt_cv_func_assert_works=no ;; + *) lt_cv_func_assert_works=yes ;; + esac + fi + ;; + esac]) + +if test "x$lt_cv_func_assert_works" = xyes; then + AC_CHECK_HEADERS(assert.h) +fi +])# AC_LIBTOOL_HEADER_ASSERT + # _LT_AC_CHECK_DLFCN # -------------------- -AC_DEFUN(_LT_AC_CHECK_DLFCN, +AC_DEFUN([_LT_AC_CHECK_DLFCN], [AC_CHECK_HEADERS(dlfcn.h) ])# _LT_AC_CHECK_DLFCN @@ -168,10 +190,10 @@ AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], [dnl # [They come from Ultrix. What could be older than Ultrix?!! ;)] # Character class describing NM global symbol codes. -[symcode='[BCDEGRST]'] +symcode='[[BCDEGRST]]' # Regexp to match symbols that can be accessed directly from C. -[sympat='\([_A-Za-z][_A-Za-z0-9]*\)'] +sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)' # Transform the above into a raw symbol and a C symbol. symxfrm='\1 \2\3 \3' @@ -179,25 +201,29 @@ symxfrm='\1 \2\3 \3' # Transform an extracted symbol line into a proper C declaration lt_cv_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern char \1;/p'" +# Transform an extracted symbol line into symbol name and symbol address +lt_cv_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" + # Define system-specific variables. case $host_os in aix*) - [symcode='[BCDT]'] + symcode='[[BCDT]]' ;; cygwin* | mingw* | pw32*) - [symcode='[ABCDGISTW]'] + symcode='[[ABCDGISTW]]' ;; hpux*) # Its linker distinguishes data from code symbols lt_cv_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern char \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" + lt_cv_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" ;; irix*) - [symcode='[BCDEGRST]'] + symcode='[[BCDEGRST]]' ;; solaris* | sysv5*) - [symcode='[BDT]'] + symcode='[[BDT]]' ;; sysv4) - [symcode='[DFNSTU]'] + symcode='[[DFNSTU]]' ;; esac @@ -211,14 +237,14 @@ esac # If we're using GNU nm, then use its standard symbol codes. if $NM -V 2>&1 | egrep '(GNU|with BFD)' > /dev/null; then - [symcode='[ABCDGISTW]'] + symcode='[[ABCDGISTW]]' fi # Try without a prefix undercore, then with it. for ac_symprfx in "" "_"; do # Write the raw and C identifiers. -[lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*\($ac_symprfx\)$sympat$opt_cr$/$symxfrm/p'"] +lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*\($ac_symprfx\)$sympat$opt_cr$/$symxfrm/p'" # Check to see that the pipe works correctly. pipe_works=no @@ -260,23 +286,23 @@ EOF cat <<EOF >> conftest.$ac_ext #if defined (__STDC__) && __STDC__ -# define lt_ptr_t void * +# define lt_ptr void * #else -# define lt_ptr_t char * +# define lt_ptr char * # define const #endif /* The mapping between symbol names and symbols. */ const struct { const char *name; - lt_ptr_t address; + lt_ptr address; } -[lt_preloaded_symbols[] =] +lt_preloaded_symbols[[]] = { EOF - sed "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (lt_ptr_t) \&\2},/" < "$nlist" >> conftest.$ac_ext + sed "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (lt_ptr) \&\2},/" < "$nlist" >> conftest.$ac_ext cat <<\EOF >> conftest.$ac_ext - {0, (lt_ptr_t) 0} + {0, (lt_ptr) 0} }; #ifdef __cplusplus @@ -320,10 +346,13 @@ done global_symbol_pipe="$lt_cv_sys_global_symbol_pipe" if test -z "$lt_cv_sys_global_symbol_pipe"; then global_symbol_to_cdecl= + global_symbol_to_c_name_address= else global_symbol_to_cdecl="$lt_cv_global_symbol_to_cdecl" + global_symbol_to_c_name_address="$lt_cv_global_symbol_to_c_name_address" fi -if test -z "$global_symbol_pipe$global_symbol_to_cdecl"; then +if test -z "$global_symbol_pipe$global_symbol_to_cdec$global_symbol_to_c_name_address"; +then AC_MSG_RESULT(failed) else AC_MSG_RESULT(ok) @@ -341,16 +370,17 @@ if test "X${PATH_SEPARATOR+set}" != Xset; then *-DOS) lt_cv_sys_path_separator=';' ;; *) lt_cv_sys_path_separator=':' ;; esac + PATH_SEPARATOR=$lt_cv_sys_path_separator fi ])# _LT_AC_LIBTOOL_SYS_PATH_SEPARATOR # _LT_AC_PROG_ECHO_BACKSLASH # -------------------------- # Add some code to the start of the generated configure script which -# will find an echo command which doesn;t interpret backslashes. +# will find an echo command which doesn't interpret backslashes. AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH], [ifdef([AC_DIVERSION_NOTICE], [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)], - [AC_DIVERT_PUSH(NOTICE)]) + [AC_DIVERT_PUSH(NOTICE)]) _LT_AC_LIBTOOL_SYS_PATH_SEPARATOR # Check that we are running under the correct shell. @@ -416,7 +446,7 @@ else # # So, first we look for a working echo in the user's PATH. - IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}" + IFS="${IFS= }"; save_ifs="$IFS"; IFS=$PATH_SEPARATOR for dir in $PATH /usr/ucb; do if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && @@ -505,7 +535,7 @@ AC_DIVERT_POP # _LT_AC_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, # ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) # ------------------------------------------------------------------ -AC_DEFUN(_LT_AC_TRY_DLOPEN_SELF, +AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF], [if test "$cross_compiling" = yes; then : [$4] else @@ -592,7 +622,7 @@ rm -fr conftest* # AC_LIBTOOL_DLOPEN_SELF # ------------------- -AC_DEFUN(AC_LIBTOOL_DLOPEN_SELF, +AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], [if test "x$enable_dlopen" != xyes; then enable_dlopen=unknown enable_dlopen_self=unknown @@ -614,16 +644,22 @@ else ;; *) - AC_CHECK_LIB(dl, dlopen, [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"], - [AC_CHECK_FUNC(dlopen, lt_cv_dlopen="dlopen", - [AC_CHECK_FUNC(shl_load, lt_cv_dlopen="shl_load", - [AC_CHECK_LIB(svld, dlopen, - [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"], - [AC_CHECK_LIB(dld, shl_load, - [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"]) + AC_CHECK_FUNC([shl_load], + [lt_cv_dlopen="shl_load"], + [AC_CHECK_LIB([dld], [shl_load], + [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld"], + [AC_CHECK_FUNC([dlopen], + [lt_cv_dlopen="dlopen"], + [AC_CHECK_LIB([dl], [dlopen], + [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"], + [AC_CHECK_LIB([svld], [dlopen], + [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"], + [AC_CHECK_LIB([dld], [dld_link], + [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"]) + ]) ]) - ]) - ]) + ]) + ]) ]) ;; esac @@ -686,10 +722,10 @@ AC_DEFUN([_LT_AC_LTCONFIG_HACK], # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. Xsed='sed -e s/^X//' -[sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g'] +sed_quote_subst='s/\([[\\"\\`$\\\\]]\)/\\\1/g' # Same as above, but do not quote variable references. -[double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g'] +double_quote_subst='s/\([[\\"\\`\\\\]]\)/\\\1/g' # Sed substitution to delay expansion of an escaped shell variable in a # double_quote_subst'ed string. @@ -758,8 +794,15 @@ old_postinstall_cmds='chmod 644 $oldlib' old_postuninstall_cmds= if test -n "$RANLIB"; then + case $host_os in + openbsd*) + old_postinstall_cmds="\$RANLIB -t \$oldlib~$old_postinstall_cmds" + ;; + *) + old_postinstall_cmds="\$RANLIB \$oldlib~$old_postinstall_cmds" + ;; + esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" - old_postinstall_cmds="\$RANLIB \$oldlib~$old_postinstall_cmds" fi # Allow CC to be a program name with arguments. @@ -785,7 +828,7 @@ AC_MSG_RESULT($objdir) ## FIXME: this should be a separate macro ## -AC_ARG_WITH(pic, +AC_ARG_WITH(pic, [ --with-pic try to use only PIC/non-PIC objects [default=use both]], pic_mode="$withval", pic_mode=default) test -z "$pic_mode" && pic_mode=default @@ -813,7 +856,7 @@ AC_CACHE_VAL(lt_cv_prog_cc_pic, # libC (AIX C++ library), which obviously doesn't included in libraries # list by gcc. This cause undefined symbols with -static flags. # This hack allows C programs to be linked with "-static -ldl", but - # we not sure about C++ programs. + # not sure about C++ programs. lt_cv_prog_cc_static="$lt_cv_prog_cc_static ${lt_cv_prog_cc_wl}-lC" ;; amigaos*) @@ -848,13 +891,13 @@ AC_CACHE_VAL(lt_cv_prog_cc_pic, # PORTME Check for PIC flags for the system compiler. case $host_os in aix3* | aix4* | aix5*) + lt_cv_prog_cc_wl='-Wl,' # All AIX code is PIC. if test "$host_cpu" = ia64; then - # AIX 5 now supports IA64 processor - lt_cv_prog_cc_static='-Bstatic' - lt_cv_prog_cc_wl='-Wl,' + # AIX 5 now supports IA64 processor + lt_cv_prog_cc_static='-Bstatic' else - lt_cv_prog_cc_static='-bnso -bI:/lib/syscalls.exp' + lt_cv_prog_cc_static='-bnso -bI:/lib/syscalls.exp' fi ;; @@ -910,9 +953,9 @@ AC_CACHE_VAL(lt_cv_prog_cc_pic, lt_cv_prog_cc_pic='-KPIC' lt_cv_prog_cc_static='-Bstatic' if test "x$host_vendor" = xsni; then - lt_cv_prog_cc_wl='-LD' + lt_cv_prog_cc_wl='-LD' else - lt_cv_prog_cc_wl='-Wl,' + lt_cv_prog_cc_wl='-Wl,' fi ;; @@ -981,7 +1024,7 @@ fi # Check for any special shared library compilation flags. if test -n "$lt_cv_prog_cc_shlib"; then AC_MSG_WARN([\`$CC' requires \`$lt_cv_prog_cc_shlib' to build shared libraries]) - if echo "$old_CC $old_CFLAGS " | [egrep -e "[ ]$lt_cv_prog_cc_shlib[ ]"] >/dev/null; then : + if echo "$old_CC $old_CFLAGS " | egrep -e "[[ ]]$lt_cv_prog_cc_shlib[[ ]]" >/dev/null; then : else AC_MSG_WARN([add \`$lt_cv_prog_cc_shlib' to the CC or CFLAGS env variable and reconfigure]) lt_cv_prog_cc_can_build_shared=no @@ -1063,6 +1106,8 @@ if test x"$compiler_c_o" = x"yes"; then lt_cv_compiler_o_lo=no save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -c -o conftest.lo" + save_objext="$ac_objext" + ac_objext=lo AC_TRY_COMPILE([], [int some_variable = 0;], [dnl # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -1072,10 +1117,11 @@ if test x"$compiler_c_o" = x"yes"; then lt_cv_compiler_o_lo=yes fi ]) + ac_objext="$save_objext" CFLAGS="$save_CFLAGS" ]) compiler_o_lo=$lt_cv_compiler_o_lo - AC_MSG_RESULT([$compiler_c_lo]) + AC_MSG_RESULT([$compiler_o_lo]) else compiler_o_lo=no fi @@ -1180,7 +1226,7 @@ exclude_expsyms="_GLOBAL_OFFSET_TABLE_" extract_expsyms_cmds= case $host_os in -cygwin* | mingw* | pw32* ) +cygwin* | mingw* | pw32*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. @@ -1188,7 +1234,9 @@ cygwin* | mingw* | pw32* ) with_gnu_ld=no fi ;; - +openbsd*) + with_gnu_ld=no + ;; esac ld_shlibs=yes @@ -1275,7 +1323,7 @@ EOF # can override, but on older systems we have to supply one (in ltdll.c) if test "x$lt_cv_need_dllmain" = "xyes"; then ltdll_obj='$output_objdir/$soname-ltdll.'"$ac_objext " - ltdll_cmds='test -f $output_objdir/$soname-ltdll.c || sed -e "/^# \/\* ltdll\.c starts here \*\//,/^# \/\* ltdll.c ends here \*\// { s/^# //; p; }" -e d < [$]0 > $output_objdir/$soname-ltdll.c~ + ltdll_cmds='test -f $output_objdir/$soname-ltdll.c || sed -e "/^# \/\* ltdll\.c starts here \*\//,/^# \/\* ltdll.c ends here \*\// { s/^# //; p; }" -e d < $''0 > $output_objdir/$soname-ltdll.c~ test -f $output_objdir/$soname-ltdll.$ac_objext || (cd $output_objdir && $CC -c $soname-ltdll.c)~' else ltdll_obj= @@ -1288,24 +1336,24 @@ EOF # Be careful not to strip the DATA tag left be newer dlltools. export_symbols_cmds="$ltdll_cmds"' $DLLTOOL --export-all --exclude-symbols '$dll_exclude_symbols' --output-def $output_objdir/$soname-def '$ltdll_obj'$libobjs $convenience~ - [sed -e "1,/EXPORTS/d" -e "s/ @ [0-9]*//" -e "s/ *;.*$//"] < $output_objdir/$soname-def > $export_symbols' + sed -e "1,/EXPORTS/d" -e "s/ @ [[0-9]]*//" -e "s/ *;.*$//" < $output_objdir/$soname-def > $export_symbols' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is. # If DATA tags from a recent dlltool are present, honour them! archive_expsym_cmds='if test "x`head -1 $export_symbols`" = xEXPORTS; then - cp $export_symbols $output_objdir/$soname-def; + cp $export_symbols $output_objdir/$soname-def; else - echo EXPORTS > $output_objdir/$soname-def; - _lt_hint=1; - cat $export_symbols | while read symbol; do - set dummy \$symbol; - case \[$]# in - 2) echo " \[$]2 @ \$_lt_hint ; " >> $output_objdir/$soname-def;; - *) echo " \[$]2 @ \$_lt_hint \[$]3 ; " >> $output_objdir/$soname-def;; - esac; - _lt_hint=`expr 1 + \$_lt_hint`; - done; + echo EXPORTS > $output_objdir/$soname-def; + _lt_hint=1; + cat $export_symbols | while read symbol; do + set dummy \$symbol; + case \[$]# in + 2) echo " \[$]2 @ \$_lt_hint ; " >> $output_objdir/$soname-def;; + *) echo " \[$]2 @ \$_lt_hint \[$]3 ; " >> $output_objdir/$soname-def;; + esac; + _lt_hint=`expr 1 + \$_lt_hint`; + done; fi~ '"$ltdll_cmds"' $CC -Wl,--base-file,$output_objdir/$soname-base '$lt_cv_cc_dll_switch' -Wl,-e,'$dll_entry' -o $output_objdir/$soname '$ltdll_obj'$libobjs $deplibs $compiler_flags~ @@ -1400,80 +1448,96 @@ else ;; aix4* | aix5*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag="" + else + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*) + for ld_flag in $LDFLAGS; do + if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then + aix_use_runtimelinking=yes + break + fi + done + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + hardcode_direct=yes archive_cmds='' hardcode_libdir_separator=':' if test "$GCC" = yes; then - collect2name=`${CC} -print-prog-name=collect2` - if test -f "$collect2name" && \ - strings "$collect2name" | grep resolve_lib_name >/dev/null - then - # We have reworked collect2 - hardcode_direct=yes - else - # We have old collect2 - hardcode_direct=unsupported - # It fails to find uninstalled libraries when the uninstalled - # path is not listed in the libpath. Setting hardcode_minus_L - # to unsupported forces relinking - hardcode_minus_L=yes - hardcode_libdir_flag_spec='-L$libdir' - hardcode_libdir_separator= - fi + case $host_os in aix4.[[012]]|aix4.[[012]].*) + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && \ + strings "$collect2name" | grep resolve_lib_name >/dev/null + then + # We have reworked collect2 + hardcode_direct=yes + else + # We have old collect2 + hardcode_direct=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + hardcode_minus_L=yes + hardcode_libdir_flag_spec='-L$libdir' + hardcode_libdir_separator= + fi + esac + shared_flag='-shared' else + # not using gcc if test "$host_cpu" = ia64; then - shared_flag='-G' + shared_flag='${wl}-G' else - shared_flag='${wl}-bM:SRE' + if test "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi fi - hardcode_direct=yes fi - if test "$host_cpu" = ia64; then - # On IA64, the linker does run time linking by default, so we don't - # have to do anything special. - aix_use_runtimelinking=no - exp_sym_flag='-Bexport' - no_entry_flag="" - else - # Test if we are trying to use run time linking, or normal AIX style linking. - # If -brtl is somewhere in LDFLAGS, we need to do run time linking. - aix_use_runtimelinking=no - for ld_flag in $LDFLAGS; do - if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl" ); then - aix_use_runtimelinking=yes - break - fi - done - exp_sym_flag='-bexport' - no_entry_flag='-bnoentry' - fi # It seems that -bexpall can do strange things, so it is better to # generate a list of symbols to export. always_export_symbols=yes if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + allow_undefined_flag='-berok' hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:/usr/lib:/lib' - allow_undefined_flag=' -Wl,-G' - archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols" + archive_expsym_cmds="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then - hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' - allow_undefined_flag="-znodefs" - archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname ${wl}-h$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols" + hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' + allow_undefined_flag="-z nodefs" + archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname ${wl}-h$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols" else - hardcode_libdir_flag_spec='${wl}-bnolibpath ${wl}-blibpath:$libdir:/usr/lib:/lib' - # Warning - without using the other run time loading flags, -berok will - # link without error, but may produce a broken library. - allow_undefined_flag='${wl}-berok" - # This is a bit strange, but is similar to how AIX traditionally builds - # it's shared libraries. - archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols"' ~$AR -crlo $objdir/$libname$release.a $objdir/$soname' + hardcode_libdir_flag_spec='${wl}-bnolibpath ${wl}-blibpath:$libdir:/usr/lib:/lib' + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + allow_undefined_flag='${wl}-berok' + # This is a bit strange, but is similar to how AIX traditionally builds + # it's shared libraries. + archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols"' ~$AR -crlo $objdir/$libname$release.a $objdir/$soname' fi fi ;; @@ -1505,11 +1569,18 @@ else ;; darwin* | rhapsody*) - allow_undefined_flag='-undefined suppress' + case "$host_os" in + rhapsody* | darwin1.[[012]]) + allow_undefined_flag='-undefined suppress' + ;; + *) # Darwin 1.3 on + allow_undefined_flag='-flat_namespace -undefined suppress' + ;; + esac # FIXME: Relying on posixy $() will cause problems for # cross-compilation, but unfortunately the echo tests do not # yet detect zsh echo's removal of \ escapes. - archive_cmds='$CC $(test .$module = .yes && echo -bundle || echo -dynamiclib) $allow_undefined_flag -o $lib $libobjs $deplibs$linkopts -install_name $rpath/$soname $(test -n "$verstring" -a x$verstring != x0.0 && echo $verstring)' + archive_cmds='$nonopt $(test "x$module" = xyes && echo -bundle || echo -dynamiclib) $allow_undefined_flag -o $lib $libobjs $deplibs$linker_flags -install_name $rpath/$soname $verstring' # We need to add '_' to the symbols in $export_symbols first #archive_expsym_cmds="$archive_cmds"' && strip -s $export_symbols' hardcode_direct=yes @@ -1584,7 +1655,7 @@ else ;; newsos6) - archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts' + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: @@ -1592,10 +1663,24 @@ else ;; openbsd*) - archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' - hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + export_dynamic_flag_spec='${wl}-E' + else + case "$host_os" in + openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='-R$libdir' + ;; + *) + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + ;; + esac + fi ;; os2*) @@ -1640,10 +1725,39 @@ else hardcode_shlibpath_var=no runpath_var=LD_RUN_PATH hardcode_runpath_var=yes + export_dynamic_flag_spec='${wl}-Bexport' ;; solaris*) + # gcc --version < 3.0 without binutils cannot create self contained + # shared libraries reliably, requiring libgcc.a to resolve some of + # the object symbols generated in some cases. Libraries that use + # assert need libgcc.a to resolve __eprintf, for example. Linking + # a copy of libgcc.a into every shared library to guarantee resolving + # such symbols causes other problems: According to Tim Van Holder + # <tim.van.holder@pandora.be>, C++ libraries end up with a separate + # (to the application) exception stack for one thing. no_undefined_flag=' -z defs' + if test "$GCC" = yes; then + case `$CC --version 2>/dev/null` in + [[12]].*) + cat <<EOF 1>&2 + +*** Warning: Releases of GCC earlier than version 3.0 cannot reliably +*** create self contained shared libraries on Solaris systems, without +*** introducing a dependency on libgcc.a. Therefore, libtool is disabling +*** -no-undefined support, which will at least allow you to build shared +*** libraries. However, you may find that when you link such libraries +*** into an application without using GCC, you have to manually add +*** \`gcc --print-libgcc-file-name\` to the link command. We urge you to +*** upgrade to a newer version of GCC. Another option is to rebuild your +*** current GCC to use the GNU linker from GNU binutils 2.9.1 or newer. + +EOF + no_undefined_flag= + ;; + esac + fi # $CC -shared without GNU ld will not create a library from C++ # object files and a static libstdc++, better avoid it by now archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' @@ -1652,7 +1766,7 @@ else hardcode_libdir_flag_spec='-R$libdir' hardcode_shlibpath_var=no case $host_os in - [solaris2.[0-5] | solaris2.[0-5].*]) ;; + solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) # Supported since Solaris 2.6 (maybe 2.5.1?) whole_archive_flag_spec='-z allextract$convenience -z defaultextract' ;; esac @@ -1675,7 +1789,7 @@ else sysv4) if test "x$host_vendor" = xsno; then - archive_cmds='$LD -G -Bsymbolic -h $soname -o $lib $libobjs $deplibs $linkopts' + archive_cmds='$LD -G -Bsymbolic -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes # is this really true??? else archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' @@ -1844,22 +1958,24 @@ aix4* | aix5*) # depend on `.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in - [ aix4 | aix4.[01] | aix4.[01].*)] - if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' - echo ' yes ' - echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then - : - else - can_build_shared=no - fi - ;; + aix4 | aix4.[[01]] | aix4.[[01]].*) + if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' + echo ' yes ' + echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then + : + else + can_build_shared=no + fi + ;; esac - # AIX (on Power*) has no versioning support, so currently we can not hardcode correct - # soname into executable. Probably we can add versioning support to - # collect2, so additional links can be useful in future. + # AIX (on Power*) has no versioning support, so currently we can + # not hardcode correct soname into executable. Probably we can + # add versioning support to collect2, so additional links can + # be useful in future. if test "$aix_use_runtimelinking" = yes; then - # If using run time linking (on AIX 4.2 or later) use lib<name>.so instead of - # lib<name>.a to let people know that these are not typical AIX shared libraries. + # If using run time linking (on AIX 4.2 or later) use lib<name>.so + # instead of lib<name>.a to let people know that these are not + # typical AIX shared libraries. library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' else # We preserve .a as extension for shared libraries through AIX4.2 @@ -1868,14 +1984,13 @@ aix4* | aix5*) soname_spec='${libname}${release}.so$major' fi shlibpath_var=LIBPATH - deplibs_check_method=pass_all fi ;; amigaos*) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. - finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | [$Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\'']`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "(cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a)"; (cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a) || exit 1; done' + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "(cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a)"; (cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a) || exit 1; done' ;; beos*) @@ -1906,7 +2021,7 @@ cygwin* | mingw* | pw32*) case $GCC,$host_os in yes,cygwin*) library_names_spec='$libname.dll.a' - soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | [sed -e 's/[.]/-/g']`${versuffix}.dll' + soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | sed -e 's/[[.]]/-/g'`${versuffix}.dll' postinstall_cmds='dlpath=`bash 2>&1 -c '\''. $dir/${file}i;echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ @@ -1916,14 +2031,14 @@ cygwin* | mingw* | pw32*) $rm \$dlpath' ;; yes,mingw*) - library_names_spec='${libname}`echo ${release} | [sed -e 's/[.]/-/g']`${versuffix}.dll' + library_names_spec='${libname}`echo ${release} | sed -e 's/[[.]]/-/g'`${versuffix}.dll' sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | sed -e "s/^libraries://" -e "s/;/ /g"` ;; yes,pw32*) library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | sed -e 's/[.]/-/g'`${versuffix}.dll' ;; *) - library_names_spec='${libname}`echo ${release} | [sed -e 's/[.]/-/g']`${versuffix}.dll $libname.lib' + library_names_spec='${libname}`echo ${release} | sed -e 's/[[.]]/-/g'`${versuffix}.dll $libname.lib' ;; esac dynamic_linker='Win32 ld.exe' @@ -2079,11 +2194,31 @@ newsos6) shlibpath_overrides_runpath=yes ;; +nto-qnx) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + soname_spec='${libname}${release}.so$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + openbsd*) version_type=sunos - if test "$with_gnu_ld" = yes; then - need_lib_prefix=no - need_version=no + need_lib_prefix=no + need_version=no + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + case "$host_os" in + openbsd2.[[89]] | openbsd2.[[89]].*) + shlibpath_overrides_runpath=no + ;; + *) + shlibpath_overrides_runpath=yes + ;; + esac + else + shlibpath_overrides_runpath=yes fi library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' @@ -2183,18 +2318,6 @@ sysv4*MP*) fi ;; -#### local change for Sleepycat DB: -# Add in the QNX support from QNX. -nto-qnx) - version_type=linux - need_lib_prefix=no - need_version=no - library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' - soname_spec='${libname}${release}.so$major' - shlibpath_var=LD_LIBRARY_PATH - shlibpath_overrides_runpath=yes - ;; - *) dynamic_linker=no ;; @@ -2212,6 +2335,41 @@ AC_MSG_RESULT([$can_build_shared]) ## ## END FIXME +## FIXME: this should be a separate macro +## +AC_MSG_CHECKING([whether to build shared libraries]) +test "$can_build_shared" = "no" && enable_shared=no + +# On AIX, shared libraries and static libraries use the same namespace, and +# are all built from PIC. +case "$host_os" in +aix3*) + test "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + +aix4*) + if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then + test "$enable_shared" = yes && enable_static=no + fi + ;; +esac +AC_MSG_RESULT([$enable_shared]) +## +## END FIXME + +## FIXME: this should be a separate macro +## +AC_MSG_CHECKING([whether to build static libraries]) +# Make sure either enable_shared or enable_static is yes. +test "$enable_shared" = yes || enable_static=yes +AC_MSG_RESULT([$enable_static]) +## +## END FIXME + if test "$hardcode_action" = relink; then # Fast installation is not supported enable_fast_install=no @@ -2311,6 +2469,7 @@ if test -f "$ltmain"; then old_striplib striplib file_magic_cmd export_symbols_cmds \ deplibs_check_method allow_undefined_flag no_undefined_flag \ finish_cmds finish_eval global_symbol_pipe global_symbol_to_cdecl \ + global_symbol_to_c_name_address \ hardcode_libdir_flag_spec hardcode_libdir_separator \ sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ compiler_c_o compiler_o_lo need_locks exclude_expsyms include_expsyms; do @@ -2377,12 +2536,12 @@ SHELL=$lt_SHELL # Whether or not to build shared libraries. build_libtool_libs=$enable_shared -# Whether or not to add -lc for building shared libraries. -build_libtool_need_lc=$need_lc - # Whether or not to build static libraries. build_old_libs=$enable_static +# Whether or not to add -lc for building shared libraries. +build_libtool_need_lc=$need_lc + # Whether or not to optimize for fast installation. fast_install=$enable_fast_install @@ -2548,6 +2707,9 @@ global_symbol_pipe=$lt_global_symbol_pipe # Transform the output of nm in a proper C declaration global_symbol_to_cdecl=$lt_global_symbol_to_cdecl +# Transform the output of nm in a C name address pair +global_symbol_to_c_name_address=$lt_global_symbol_to_c_name_address + # This is the shared library runtime path variable. runpath_var=$runpath_var @@ -2670,9 +2832,9 @@ EOF # return TRUE; # } # /* ltdll.c ends here */ - # This is a source program that is used to create import libraries - # on Windows for dlls which lack them. Don't remove nor modify the - # starting and closing comments + # This is a source program that is used to create import libraries + # on Windows for dlls which lack them. Don't remove nor modify the + # starting and closing comments # /* impgen.c starts here */ # /* Copyright (C) 1999-2000 Free Software Foundation, Inc. # @@ -2841,7 +3003,7 @@ AC_DEFUN([AC_ENABLE_SHARED], [define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl AC_ARG_ENABLE(shared, changequote(<<, >>)dnl -<< --enable-shared[=PKGS] build shared libraries [default=>>AC_ENABLE_SHARED_DEFAULT], +<< --enable-shared[=PKGS] build shared libraries [default=>>AC_ENABLE_SHARED_DEFAULT], changequote([, ])dnl [p=${PACKAGE-default} case $enableval in @@ -2875,7 +3037,7 @@ AC_DEFUN([AC_ENABLE_STATIC], [define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl AC_ARG_ENABLE(static, changequote(<<, >>)dnl -<< --enable-static[=PKGS] build static libraries [default=>>AC_ENABLE_STATIC_DEFAULT], +<< --enable-static[=PKGS] build static libraries [default=>>AC_ENABLE_STATIC_DEFAULT], changequote([, ])dnl [p=${PACKAGE-default} case $enableval in @@ -3029,6 +3191,7 @@ test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no) AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl +AC_REQUIRE([_LT_AC_LIBTOOL_SYS_PATH_SEPARATOR])dnl ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. @@ -3042,8 +3205,8 @@ if test "$GCC" = yes; then esac case $ac_prog in # Accept absolute paths. - [[\\/]* | [A-Za-z]:[\\/]*)] - [re_direlt='/[^/][^/]*/\.\./'] + [[\\/]]* | [[A-Za-z]]:[[\\/]]*) + re_direlt='/[[^/]][[^/]]*/\.\./' # Canonicalize the path of ld ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do @@ -3067,7 +3230,7 @@ else fi AC_CACHE_VAL(lt_cv_path_LD, [if test -z "$LD"; then - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then @@ -3131,7 +3294,7 @@ lt_cv_deplibs_check_method='unknown' # `unknown' -- same as none, but documents that we really don't know. # 'pass_all' -- all dependencies passed with no checks. # 'test_compile' -- check by making test program. -# ['file_magic [regex]'] -- check by looking for files in library path +# 'file_magic [[regex]]' -- check by looking for files in library path # which responds to the $file_magic_cmd with a given egrep regex. # If you have `file' or equivalent on your system and you're not sure # whether `pass_all' will *always* work, you probably want this one. @@ -3146,7 +3309,7 @@ beos*) ;; bsdi4*) - [lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)'] + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)' lt_cv_file_magic_cmd='/usr/bin/file -L' lt_cv_file_magic_test_file=/shlib/libc.so ;; @@ -3160,7 +3323,7 @@ darwin* | rhapsody*) lt_cv_deplibs_check_method='file_magic Mach-O dynamically linked shared library' lt_cv_file_magic_cmd='/usr/bin/file -L' case "$host_os" in - rhapsody* | darwin1.[012]) + rhapsody* | darwin1.[[012]]) lt_cv_file_magic_test_file=`echo /System/Library/Frameworks/System.framework/Versions/*/System | head -1` ;; *) # Darwin 1.3 on @@ -3175,7 +3338,7 @@ freebsd*) i*86 ) # Not sure whether the presence of OpenBSD here was a mistake. # Let's accept both of them until this is cleared up. - [lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD)/i[3-9]86 (compact )?demand paged shared library'] + lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD)/i[[3-9]]86 (compact )?demand paged shared library' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` ;; @@ -3190,7 +3353,7 @@ gnu*) ;; hpux10.20*|hpux11*) - [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library'] + lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=/usr/lib/libc.sl ;; @@ -3209,7 +3372,7 @@ irix5* | irix6*) *) libmagic=never-match;; esac # this will be overridden with pass_all, but let us keep it just in case - [lt_cv_deplibs_check_method="file_magic ELF ${libmagic} MSB mips-[1234] dynamic lib MIPS - version 1"] + lt_cv_deplibs_check_method="file_magic ELF ${libmagic} MSB mips-[[1234]] dynamic lib MIPS - version 1" ;; esac lt_cv_file_magic_test_file=`echo /lib${libsuff}/libc.so*` @@ -3219,33 +3382,41 @@ irix5* | irix6*) # This must be Linux ELF. linux-gnu*) case $host_cpu in - alpha* | i*86 | powerpc* | sparc* | ia64* ) + alpha* | hppa* | i*86 | powerpc* | sparc* | ia64* ) lt_cv_deplibs_check_method=pass_all ;; *) # glibc up to 2.1.1 does not perform some relocations on ARM - [lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' ;;] + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' ;; esac lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so` ;; netbsd*) if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then - [lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$'] + lt_cv_deplibs_check_method='match_pattern /lib[[^/\.]]+\.so\.[[0-9]]+\.[[0-9]]+$' else - [lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so$'] + lt_cv_deplibs_check_method='match_pattern /lib[[^/\.]]+\.so$' fi ;; newos6*) - [lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)'] + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=/usr/lib/libnls.so ;; -#### local change for Sleepycat DB: -# Add in the QNX support from QNX. nto-qnx) - lt_cv_deplibs_check_method=pass_all + lt_cv_deplibs_check_method=unknown + ;; + +openbsd*) + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB shared object' + else + lt_cv_deplibs_check_method='file_magic OpenBSD.* shared library' + fi ;; osf3* | osf4* | osf5*) @@ -3264,14 +3435,14 @@ solaris*) lt_cv_file_magic_test_file=/lib/libc.so ;; -[sysv5uw[78]* | sysv4*uw2*)] +sysv5uw[[78]]* | sysv4*uw2*) lt_cv_deplibs_check_method=pass_all ;; sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) case $host_vendor in motorola) - [lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]'] + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]' lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` ;; ncr) @@ -3279,11 +3450,11 @@ sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) ;; sequent) lt_cv_file_magic_cmd='/bin/file' - [lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )'] + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' ;; sni) lt_cv_file_magic_cmd='/bin/file' - [lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib"] + lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib" lt_cv_file_magic_test_file=/lib/libc.so ;; esac @@ -3297,13 +3468,14 @@ deplibs_check_method=$lt_cv_deplibs_check_method # AC_PROG_NM - find the path to a BSD-compatible name lister AC_DEFUN([AC_PROG_NM], -[AC_MSG_CHECKING([for BSD-compatible nm]) +[AC_REQUIRE([_LT_AC_LIBTOOL_SYS_PATH_SEPARATOR])dnl +AC_MSG_CHECKING([for BSD-compatible nm]) AC_CACHE_VAL(lt_cv_path_NM, [if test -n "$NM"; then # Let the user override the test. lt_cv_path_NM="$NM" else - IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do test -z "$ac_dir" && ac_dir=. tmp_nm=$ac_dir/${ac_tool_prefix}nm diff --git a/db/dist/aclocal/mutex.ac b/db/dist/aclocal/mutex.ac index f34144c45..5f46873a0 100644 --- a/db/dist/aclocal/mutex.ac +++ b/db/dist/aclocal/mutex.ac @@ -1,4 +1,4 @@ -# Id: mutex.ac,v 11.24 2001/05/22 01:00:30 bostic Exp +# Id: mutex.ac,v 11.25 2001/08/28 13:09:19 krinsky Exp # Figure out mutexes for this compiler/architecture. AC_DEFUN(AM_DEFINE_MUTEXES, [ @@ -172,7 +172,7 @@ fi if test "$db_cv_mutex" = no; then AC_TRY_RUN([ #include <sys/types.h> -#include <sys/mman.h>; +#include <sys/mman.h> main(){ typedef msemaphore tsl_t; msemaphore x; diff --git a/db/dist/aclocal/programs.ac b/db/dist/aclocal/programs.ac index a66b7b8e8..6e7f475be 100644 --- a/db/dist/aclocal/programs.ac +++ b/db/dist/aclocal/programs.ac @@ -1,4 +1,4 @@ -# Id: programs.ac,v 11.18 2001/06/13 14:57:50 bostic Exp +# Id: programs.ac,v 11.20 2001/09/24 02:09:25 bostic Exp # Check for programs used in building/installation. AC_DEFUN(AM_PROGRAMS_SET, [ @@ -62,12 +62,12 @@ if test "$db_cv_path_sh" = missing_sh; then AC_MSG_ERROR([No sh utility found.]) fi -# We need a complete path for ranlib, because it doesn't exist on some -# architectures because the ar utility packages the library itself. -AC_CHECK_TOOL(path_strip, strip, missing_strip) -AC_PATH_PROG(db_cv_path_strip, $path_strip, missing_strip) -if test "$db_cv_path_strip" = missing_strip; then - AC_MSG_ERROR([No strip utility found.]) +# Don't strip the binaries if --enable-debug was specified. +if test "$db_cv_debug" = yes; then + db_cv_path_strip=debug_build_no_strip +else + AC_CHECK_TOOL(path_strip, strip, missing_strip) + AC_PATH_PROG(db_cv_path_strip, $path_strip, missing_strip) fi if test "$db_cv_test" = "yes"; then diff --git a/db/dist/aclocal/tcl.ac b/db/dist/aclocal/tcl.ac index 8106de99e..a86ee7ca7 100644 --- a/db/dist/aclocal/tcl.ac +++ b/db/dist/aclocal/tcl.ac @@ -1,4 +1,4 @@ -# Id: tcl.ac,v 11.8 2001/06/07 21:23:36 bostic Exp +# Id: tcl.ac,v 11.12 2001/11/10 16:40:37 bostic Exp # The SC_* macros in this file are from the unix/tcl.m4 files in the Tcl # 8.3.0 distribution, with some minor changes. For this reason, license @@ -9,7 +9,7 @@ # California, Sun Microsystems, Inc., Scriptics Corporation, # and other parties. The following terms apply to all files associated # with the software unless explicitly disclaimed in individual files. -# +# # The authors hereby grant permission to use, copy, modify, distribute, # and license this software and its documentation for any purpose, provided # that existing copyright notices are retained in all copies and that this @@ -19,23 +19,23 @@ # and need not follow the licensing terms described here, provided that # the new terms are clearly indicated on the first page of each file where # they apply. -# +# # IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY # FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES # ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY # DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. -# +# # THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE # IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE # NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR # MODIFICATIONS. -# +# # GOVERNMENT USE: If you are acquiring this software on behalf of the # U.S. government, the Government shall have only "Restricted Rights" -# in the software and related documentation as defined in the Federal +# in the software and related documentation as defined in the Federal # Acquisition Regulations (FARs) in Clause 52.227.19 (c) (2). If you # are acquiring the software on behalf of the Department of Defense, the # software shall be classified as "Commercial Computer Software" and the @@ -43,7 +43,7 @@ # 252.227-7013 (c) (1) of DFARs. Notwithstanding the foregoing, the # authors grant the U.S. Government and others acting in its behalf # permission to use and distribute the software in accordance with the -# terms specified in this license. +# terms specified in this license. AC_DEFUN(SC_PATH_TCLCONFIG, [ AC_CACHE_VAL(ac_cv_c_tclconfig,[ @@ -95,6 +95,16 @@ AC_DEFUN(SC_LOAD_TCLCONFIG, [ eval TCL_LIB_FLAG="${TCL_LIB_FLAG}" eval "TCL_LIB_SPEC=\"${TCL_LIB_SPEC}\"" + # + # If the DB Tcl library isn't loaded with the Tcl spec and library + # flags on AIX, the resulting libdb_tcl-X.Y.so.0 will drop core at + # load time. [#4843] + # + case "$host_os" in + aix*) + LIBTSO_LIBS="$LIBTSO_LIBS $TCL_LIB_SPEC $TCL_LIB_FLAG";; + esac + AC_SUBST(TCL_BIN_DIR) AC_SUBST(TCL_SRC_DIR) AC_SUBST(TCL_LIB_FILE) @@ -119,8 +129,5 @@ if test "$db_cv_tcl" = "yes"; then TCFLAGS="-I$TCL_PREFIX/include" fi - LIBS="$LIBS $TCL_LIB_SPEC $TCL_LIBS" - - ADDITIONAL_LIBS="$ADDITIONAL_LIBS \$(libtso_target)" - DEFAULT_INSTALL="${DEFAULT_INSTALL} install_tcl" + INSTALL_LIBS="${INSTALL_LIBS} \$(libtso_target)" fi]) diff --git a/db/dist/aclocal/types.ac b/db/dist/aclocal/types.ac index f15d9b55c..4e432d832 100644 --- a/db/dist/aclocal/types.ac +++ b/db/dist/aclocal/types.ac @@ -1,12 +1,20 @@ -# Id: types.ac,v 11.6 2001/05/22 01:00:31 bostic Exp +# Id: types.ac,v 11.8 2001/09/27 13:18:19 bostic Exp # Check for the standard system types. AC_DEFUN(AM_TYPES, [ -AC_TYPE_MODE_T AC_TYPE_OFF_T +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 +if test "$ac_cv_type_size_t" = no; then + AC_MSG_ERROR([No size_t type.]) +fi AC_SUBST(u_char_decl) AC_CACHE_CHECK([for u_char], db_cv_uchar, [ @@ -48,7 +56,7 @@ AC_TRY_COMPILE([#include <sys/types.h>], u_int8_t foo;, 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.) + 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;" @@ -115,8 +123,8 @@ if test "$db_cv_int32" != yes; then 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 long, because it read/write -# and others historically returned an int. +# the same size as a size_t. Prefer int over anything else, because read, +# write and others historically returned an int. 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;, diff --git a/db/dist/buildrel b/db/dist/buildrel index e530b093f..ef589abcb 100644 --- a/db/dist/buildrel +++ b/db/dist/buildrel @@ -1,5 +1,5 @@ #!/bin/sh - -# Id: buildrel,v 1.30 2001/08/07 18:19:37 bostic Exp +# Id: buildrel,v 1.31 2001/10/14 15:31:11 bostic Exp # # Build the distribution archives. # @@ -22,7 +22,7 @@ cd $D/dist && sh s_all cd $D && cvs -q commit # Copy a development tree into a release tree. -setenv R /a/db-$VERSION +setenv R /var/tmp/db-$VERSION rm -rf $R && mkdir -p $R cd $D && tar cf - \ `cvs -q status | sed -n -e "/Repository/s;.*/CVSROOT/db/;;" -e "s/,v//p"` | \ @@ -46,10 +46,9 @@ cd $R/build_run && ~bostic/bin/dbconf && make >& mklog make prefix=`pwd`/BDB install # Clean up the tree. -cd $R && rm -rf build_run docs_src java/src/com/sleepycat/test +cd $R && rm -rf build_run docs_src cd $R && rm -rf test/TODO test/upgrade -cd $R && rm -rf test_cxx test_perf test_purify test_server test_thread -cd $R && rm -rf test_vxworks +cd $R && rm -rf test_perf test_purify test_server test_thread test_vxworks # ACQUIRE ROOT PRIVILEGES cd $R && find . -type d | xargs chmod 775 diff --git a/db/dist/vx_ae.in/Makefile.component b/db/dist/vx_ae.in/Makefile.component index 0eb96ad93..3d607b6ce 100644 --- a/db/dist/vx_ae.in/Makefile.component +++ b/db/dist/vx_ae.in/Makefile.component @@ -16,7 +16,7 @@ defaultTarget: $(COMPONENT_NAME).cm # default definition for CPU and TOOL (needed by defs.project) # -CPU = SIMSPARCSOLARIS +CPU = PENTIUM2 TOOL = gnu @@ -68,22 +68,6 @@ NUMBER_OF_COMPONENT_OBJS = $(words $(COMPONENT_OBJS)) endif -## CPU and TOOL info for build specification 'SIMSPARCSOLARISgnu.debug' - -ifeq ($(BUILD_SPEC),SIMSPARCSOLARISgnu.debug) -CPU = SIMSPARCSOLARIS -TOOL = gnu -SYS_OBJ_DIR = $(WIND_BASE)/target/lib/obj$(CPU)$(TOOL)vx -USER_OBJ_DIR = $(WIND_BASE)/target/user/objs/obj$(CPU)$(TOOL) -PRJ_OBJS = __DB_APPLICATION_NAME__.o \ - compConfig.o -COMPONENT_OBJS = __DB_APPLICATION_NAME__.o -DEPENDENCY_FILES = __DB_APPLICATION_NAME__.d \ - compConfig.d -NUMBER_OF_COMPONENT_OBJS = $(words $(COMPONENT_OBJS)) -endif - - include $(TGT_DIR)/h/make/defs.project @@ -176,36 +160,6 @@ POST_BUILD_RULE = endif - -## build-configuration info for build specification 'SIMSPARCSOLARISgnu.debug' - -ifeq ($(BUILD_SPEC),SIMSPARCSOLARISgnu.debug) - -## macros - -AR = arsparc -AS = ccsparc -CC = ccsparc -CFLAGS = -ansi -DRW_MULTI_THREAD -D_REENTRANT -g -fno-builtin -MD -Wall -I. -I$(WIND_BASE)/target/h -I$(PRJ_DIR)/../.. -I$(PRJ_DIR)/../../../include -I$(PRJ_DIR)/../../../include_auto -DCPU=SIMSPARCSOLARIS -CFLAGS_AS = -ansi -g -fno-builtin -P -x assembler-with-cpp -Wall -I. -I$(WIND_BASE)/target/h -DCPU=SIMSPARCSOLARIS -CPP = ccsparc -E -P -CPPFILT = c++filtsparc --strip-underscores -LD = ldsparc -LDFLAGS = -T $(WIND_BASE)/target/config/solaris/linker-script -LDPARTIAL = ccsparc -B$(WIND_BASE)/host/$(WIND_HOST_TYPE)/lib/gcc-lib/ -nostdlib -r -Wl,-X -LD_PARTIAL_FLAGS = -nostdlib -r -NM = nmsparc -OPTION_DEFINE_MACRO = -D -OPTION_GENERATE_DEPENDENCY_FILE = -MD -OPTION_INCLUDE_DIR = -I -RELEASE = 0 -SIZE = sizesparc -POST_BUILD_RULE = - -## end build-configuration info for build specification 'SIMSPARCSOLARISgnu.debug' - -endif - # override make definitions only below this line @@ -295,27 +249,6 @@ ifeq ($(BUILD_SPEC),PENTIUMgnu.debug) endif -## build rules for build specification 'SIMSPARCSOLARISgnu.debug' - -ifeq ($(BUILD_SPEC),SIMSPARCSOLARISgnu.debug) - -%.o : $(PRJ_DIR)/%.c - $(CC) -ansi -DRW_MULTI_THREAD -D_REENTRANT -g -fno-builtin -MD -Wall -I. -I$(WIND_BASE)/target/h -I$(PRJ_DIR)/../.. -I$(PRJ_DIR)/../../../include -I$(PRJ_DIR)/../../../include_auto -DCPU=SIMSPARCSOLARIS -c $< - -%.d : $(PRJ_DIR)/%.c - ccsparc -E -P -M -ansi -DRW_MULTI_THREAD -D_REENTRANT -g -fno-builtin -Wall -I. -I$(WIND_BASE)/target/h -I$(PRJ_DIR)/../.. -I$(PRJ_DIR)/../../../include -I$(PRJ_DIR)/../../../include_auto -DCPU=SIMSPARCSOLARIS $< > $@ - -%.o : $(PRJ_DIR)/../%.c - $(CC) -ansi -DRW_MULTI_THREAD -D_REENTRANT -g -fno-builtin -MD -Wall -I. -I$(WIND_BASE)/target/h -I$(PRJ_DIR)/../.. -I$(PRJ_DIR)/../../../include -I$(PRJ_DIR)/../../../include_auto -DCPU=SIMSPARCSOLARIS -c $< - -%.d : $(PRJ_DIR)/../%.c - ccsparc -E -P -M -ansi -DRW_MULTI_THREAD -D_REENTRANT -g -fno-builtin -Wall -I. -I$(WIND_BASE)/target/h -I$(PRJ_DIR)/../.. -I$(PRJ_DIR)/../../../include -I$(PRJ_DIR)/../../../include_auto -DCPU=SIMSPARCSOLARIS $< > $@ - - -## end build rules for build specification 'SIMSPARCSOLARISgnu.debug' - -endif - # # Rule for configurable, binary component # @@ -416,15 +349,6 @@ ifeq ($(BUILD_SPEC),PENTIUMgnu.debug) endif -## user-defined rules for build specification 'SIMSPARCSOLARISgnu.debug' - -ifeq ($(BUILD_SPEC),SIMSPARCSOLARISgnu.debug) - -## end user-defined rules for build specification 'SIMSPARCSOLARISgnu.debug' - -endif - - # # Recursive clean # diff --git a/db/dist/vx_ae.in/component.wpj b/db/dist/vx_ae.in/component.wpj index 59c1acebc..db7b118c9 100644 --- a/db/dist/vx_ae.in/component.wpj +++ b/db/dist/vx_ae.in/component.wpj @@ -9,7 +9,7 @@ AE1.1 <END> <BEGIN> BUILD__CURRENT -SIMSPARCSOLARISgnu.debug +PENTIUM2gnu.debug <END> <BEGIN> BUILD_PENTIUM2gnu.debug_CURRENT_TARGET @@ -447,145 +447,8 @@ $(WIND_BASE)/target/h/ ::tc_PENTIUMgnu.debug <END> -<BEGIN> BUILD_SIMSPARCSOLARISgnu.debug_CURRENT_TARGET -default -<END> - -<BEGIN> BUILD_SIMSPARCSOLARISgnu.debug_DEFAULTFORCPU -1 -<END> - -<BEGIN> BUILD_SIMSPARCSOLARISgnu.debug_FILE_$(PRJ_DIR)/../__DB_APPLICATION_NAME__.c_infoTags -toolMacro objects -<END> - -<BEGIN> BUILD_SIMSPARCSOLARISgnu.debug_FILE_$(PRJ_DIR)/../__DB_APPLICATION_NAME__.c_objects -__DB_APPLICATION_NAME__.o -<END> - -<BEGIN> BUILD_SIMSPARCSOLARISgnu.debug_FILE_$(PRJ_DIR)/../__DB_APPLICATION_NAME___DB_APPLICATION_NAME__.c_toolMacro -CC -<END> - -<BEGIN> BUILD_SIMSPARCSOLARISgnu.debug_FILE_$(PRJ_DIR)/compConfig.c_infoTags -toolMacro objects -<END> - -<BEGIN> BUILD_SIMSPARCSOLARISgnu.debug_FILE_$(PRJ_DIR)/compConfig.c_objects -compConfig.o -<END> - -<BEGIN> BUILD_SIMSPARCSOLARISgnu.debug_FILE_$(PRJ_DIR)/compConfig.c_toolMacro -CC -<END> - -<BEGIN> BUILD_SIMSPARCSOLARISgnu.debug_MACRO_AR -arsparc -<END> - -<BEGIN> BUILD_SIMSPARCSOLARISgnu.debug_MACRO_AS -ccsparc -<END> - -<BEGIN> BUILD_SIMSPARCSOLARISgnu.debug_MACRO_CC -ccsparc -<END> - -<BEGIN> BUILD_SIMSPARCSOLARISgnu.debug_MACRO_CFLAGS --ansi \ - -DRW_MULTI_THREAD \ - -D_REENTRANT \ - -g \ - -fno-builtin \ - -MD \ - -Wall \ - -I. \ - -I$(WIND_BASE)/target/h \ - -I$(PRJ_DIR)/../.. \ - -I$(PRJ_DIR)/../../../include \ - -I$(PRJ_DIR)/../../../include_auto \ - -DCPU=SIMSPARCSOLARIS -<END> - -<BEGIN> BUILD_SIMSPARCSOLARISgnu.debug_MACRO_CFLAGS_AS --ansi \ - -g \ - -fno-builtin \ - -P \ - -x \ - assembler-with-cpp \ - -Wall \ - -I. \ - -I$(WIND_BASE)/target/h \ - -DCPU=SIMSPARCSOLARIS -<END> - -<BEGIN> BUILD_SIMSPARCSOLARISgnu.debug_MACRO_CPP -ccsparc -E -P -<END> - -<BEGIN> BUILD_SIMSPARCSOLARISgnu.debug_MACRO_CPPFILT -c++filtsparc --strip-underscores -<END> - -<BEGIN> BUILD_SIMSPARCSOLARISgnu.debug_MACRO_LD -ldsparc -<END> - -<BEGIN> BUILD_SIMSPARCSOLARISgnu.debug_MACRO_LDFLAGS --T $(WIND_BASE)/target/config/solaris/linker-script -<END> - -<BEGIN> BUILD_SIMSPARCSOLARISgnu.debug_MACRO_LDPARTIAL -ccsparc \ - -B$(WIND_BASE)/host/$(WIND_HOST_TYPE)/lib/gcc-lib/ \ - -nostdlib \ - -r \ - -Wl,-X -<END> - -<BEGIN> BUILD_SIMSPARCSOLARISgnu.debug_MACRO_LD_PARTIAL_FLAGS --nostdlib -r -<END> - -<BEGIN> BUILD_SIMSPARCSOLARISgnu.debug_MACRO_NM -nmsparc -<END> - -<BEGIN> BUILD_SIMSPARCSOLARISgnu.debug_MACRO_OPTION_DEFINE_MACRO --D -<END> - -<BEGIN> BUILD_SIMSPARCSOLARISgnu.debug_MACRO_OPTION_GENERATE_DEPENDENCY_FILE --MD -<END> - -<BEGIN> BUILD_SIMSPARCSOLARISgnu.debug_MACRO_OPTION_INCLUDE_DIR --I -<END> - -<BEGIN> BUILD_SIMSPARCSOLARISgnu.debug_MACRO_RELEASE -0 -<END> - -<BEGIN> BUILD_SIMSPARCSOLARISgnu.debug_MACRO_SIZE -sizesparc -<END> - -<BEGIN> BUILD_SIMSPARCSOLARISgnu.debug_RELEASE -0 -<END> - -<BEGIN> BUILD_SIMSPARCSOLARISgnu.debug_RO_DEPEND_PATH -$(WIND_BASE)/target/h/ -<END> - -<BEGIN> BUILD_SIMSPARCSOLARISgnu.debug_TC -::tc_SIMSPARCSOLARISgnu.debug -<END> - <BEGIN> BUILD__LIST -PENTIUM2gnu.debug PENTIUM2gnu.release PENTIUMgnu.debug SIMSPARCSOLARISgnu.debug +PENTIUM2gnu.debug PENTIUM2gnu.release PENTIUMgnu.debug <END> <BEGIN> PROJECT_FILES diff --git a/db/dist/vx_buildcd b/db/dist/vx_buildcd index b6135711e..477fede4c 100755 --- a/db/dist/vx_buildcd +++ b/db/dist/vx_buildcd @@ -1,5 +1,5 @@ #!/bin/sh -# Id: vx_buildcd,v 1.5 2001/09/11 17:09:02 sue Exp +# Id: vx_buildcd,v 1.6 2001/11/05 21:05:58 sue Exp # # Build the Setup SDK CD image on the VxWorks host machine. @@ -14,9 +14,9 @@ S=$Q/resource/mfg/setup W=sun4-solaris2 symdoc=$D/docs/BerkeleyDB.$DB_VERSION_MAJOR.$DB_VERSION_MINOR.$DB_VERSION_PATCH -symdb=$D/target/src/BerkeleyDB.$DB_VERSION_MAJOR.$DB_VERSION_MINOR.$DB_VERSION_PATCH -rm -rf $D/docs $D/target -mkdir $D/docs $D/target $D/target/src +symdb=$D/windlink/sleepycat/BerkeleyDB.$DB_VERSION_MAJOR.$DB_VERSION_MINOR.$DB_VERSION_PATCH +rm -rf $D/docs $D/windlink +mkdir $D/docs $D/windlink $D/windlink/sleepycat ln -s $B/docs $symdoc ln -s $B $symdb @@ -100,17 +100,17 @@ f=$D/filelist.all # files; we cannot have all the directories listed too. # # NOTE: This find is overly aggressive in getting files, particularly -# for the 'target/src' files. We actually end up with 3 sets of the +# for the 'windlink/sleepycat' files. We actually end up with 3 sets of the # documentation, the "real" ones in 'docs/BerkeleyDB*', the set found -# via 'target/src/Berk*/docs' and the one found via our symlink in -# 'target/src/Berk*/dist/vx_setup/docs/Berk*'. +# via 'windlink/sleepycat/Berk*/docs' and the one found via our symlink in +# 'windlink/sleepycat/Berk*/dist/vx_setup/docs/Berk*'. # # However, we waste a little disk space so that the expression below # is trivial and we don't have to maintain it as new files/directories # are added to DB. # (cd $D && find docs/BerkeleyDB.$DB_VERSION_MAJOR.$DB_VERSION_MINOR.$DB_VERSION_PATCH/ -follow -name \* -type f -print) > $t -(cd $D && find target/src/BerkeleyDB.$DB_VERSION_MAJOR.$DB_VERSION_MINOR.$DB_VERSION_PATCH/ -follow -name docs -prune -o -type f -print) >> $t +(cd $D && find windlink/sleepycat/BerkeleyDB.$DB_VERSION_MAJOR.$DB_VERSION_MINOR.$DB_VERSION_PATCH/ -follow -name docs -prune -o -type f -print) >> $t (echo "Building $f" && rm -f $f && cp $t $f) # # Finally build the CD image! diff --git a/db/dist/vx_setup/vx_allfile.in b/db/dist/vx_setup/vx_allfile.in index 4d505cf38..61a1b8ee8 100644 --- a/db/dist/vx_setup/vx_allfile.in +++ b/db/dist/vx_setup/vx_allfile.in @@ -1,5 +1,5 @@ -target/src/BerkeleyDB.@DB_VERSION_MAJOR@.@DB_VERSION_MINOR@.@DB_VERSION_PATCH@/build_vxworks/BerkeleyDB.wpj -target/src/BerkeleyDB.@DB_VERSION_MAJOR@.@DB_VERSION_MINOR@.@DB_VERSION_PATCH@/build_vxworks/BerkeleyDB.wsp -target/src/BerkeleyDB.@DB_VERSION_MAJOR@.@DB_VERSION_MINOR@.@DB_VERSION_PATCH@/build_vxworks/db.h -target/src/BerkeleyDB.@DB_VERSION_MAJOR@.@DB_VERSION_MINOR@.@DB_VERSION_PATCH@/build_vxworks/db_config.h -target/src/BerkeleyDB.@DB_VERSION_MAJOR@.@DB_VERSION_MINOR@.@DB_VERSION_PATCH@/build_vxworks/db_int.h +windlink/sleepycat/BerkeleyDB.@DB_VERSION_MAJOR@.@DB_VERSION_MINOR@.@DB_VERSION_PATCH@/build_vxworks/BerkeleyDB.wpj +windlink/sleepycat/BerkeleyDB.@DB_VERSION_MAJOR@.@DB_VERSION_MINOR@.@DB_VERSION_PATCH@/build_vxworks/BerkeleyDB.wsp +windlink/sleepycat/BerkeleyDB.@DB_VERSION_MAJOR@.@DB_VERSION_MINOR@.@DB_VERSION_PATCH@/build_vxworks/db.h +windlink/sleepycat/BerkeleyDB.@DB_VERSION_MAJOR@.@DB_VERSION_MINOR@.@DB_VERSION_PATCH@/build_vxworks/db_config.h +windlink/sleepycat/BerkeleyDB.@DB_VERSION_MAJOR@.@DB_VERSION_MINOR@.@DB_VERSION_PATCH@/build_vxworks/db_int.h diff --git a/db/dist/vx_setup/vx_demofile.in b/db/dist/vx_setup/vx_demofile.in index e92c116b8..08593f653 100644 --- a/db/dist/vx_setup/vx_demofile.in +++ b/db/dist/vx_setup/vx_demofile.in @@ -1,3 +1,3 @@ -target/src/BerkeleyDB.@DB_VERSION_MAJOR@.@DB_VERSION_MINOR@.@DB_VERSION_PATCH@/build_vxworks/demo/DBdemo.wpj -target/src/BerkeleyDB.@DB_VERSION_MAJOR@.@DB_VERSION_MINOR@.@DB_VERSION_PATCH@/build_vxworks/demo/README -target/src/BerkeleyDB.@DB_VERSION_MAJOR@.@DB_VERSION_MINOR@.@DB_VERSION_PATCH@/build_vxworks/demo/dbdemo.c +windlink/sleepycat/BerkeleyDB.@DB_VERSION_MAJOR@.@DB_VERSION_MINOR@.@DB_VERSION_PATCH@/build_vxworks/demo/DBdemo.wpj +windlink/sleepycat/BerkeleyDB.@DB_VERSION_MAJOR@.@DB_VERSION_MINOR@.@DB_VERSION_PATCH@/build_vxworks/demo/README +windlink/sleepycat/BerkeleyDB.@DB_VERSION_MAJOR@.@DB_VERSION_MINOR@.@DB_VERSION_PATCH@/build_vxworks/demo/dbdemo.c diff --git a/db/dist/win_exports.in b/db/dist/win_exports.in index 65b799cb9..25e00cbc3 100644 --- a/db/dist/win_exports.in +++ b/db/dist/win_exports.in @@ -1,4 +1,4 @@ -# Id: win_exports.in,v 1.9 2001/10/11 17:05:51 dda Exp +# Id: win_exports.in,v 1.10 2001/11/05 18:24:58 bostic Exp # Standard interfaces. db_create @@ -32,6 +32,10 @@ db_env_set_func_write db_env_set_func_yield +# Needed for application-specific logging and recovery routines. + __db_add_recovery + __txn_activekids + # These are only for testing. __db_dbm_close __db_dbm_delete diff --git a/db/docs/api_c/env_set_timeout.html b/db/docs/api_c/env_set_timeout.html index c99234db9..e55e1450f 100644 --- a/db/docs/api_c/env_set_timeout.html +++ b/db/docs/api_c/env_set_timeout.html @@ -1,4 +1,4 @@ -<!--Id: env_set_timeout.so,v 10.2 2001/09/07 21:43:16 bostic Exp --> +<!--Id: env_set_timeout.so,v 10.3 2001/10/22 15:24:31 bostic Exp --> <!--Copyright 1997-2001 by Sleepycat Software, Inc.--> <!--All rights reserved.--> <html> diff --git a/db/docs/api_c/lock_id_free.html b/db/docs/api_c/lock_id_free.html index 8dca5ca14..0f32651a5 100644 --- a/db/docs/api_c/lock_id_free.html +++ b/db/docs/api_c/lock_id_free.html @@ -1,4 +1,4 @@ -<!--Id: lock_id_free.so,v 10.1 2001/09/25 15:18:55 bostic Exp --> +<!--Id: lock_id_free.so,v 10.2 2001/10/22 15:24:32 bostic Exp --> <!--Copyright 1997-2001 by Sleepycat Software, Inc.--> <!--All rights reserved.--> <html> diff --git a/db/docs/api_c/log_cursor.html b/db/docs/api_c/log_cursor.html index 0107ada24..0bf50ab34 100644 --- a/db/docs/api_c/log_cursor.html +++ b/db/docs/api_c/log_cursor.html @@ -1,4 +1,4 @@ -<!--Id: log_cursor.so,v 10.1 2001/09/28 15:09:35 bostic Exp --> +<!--Id: log_cursor.so,v 10.2 2001/10/22 15:24:33 bostic Exp --> <!--Copyright 1997-2001 by Sleepycat Software, Inc.--> <!--All rights reserved.--> <html> diff --git a/db/docs/api_c/logc_close.html b/db/docs/api_c/logc_close.html index 638fdcd32..6747f34ef 100644 --- a/db/docs/api_c/logc_close.html +++ b/db/docs/api_c/logc_close.html @@ -1,4 +1,4 @@ -<!--Id: logc_close.so,v 10.3 2001/10/02 01:33:35 bostic Exp --> +<!--Id: logc_close.so,v 10.4 2001/10/22 15:24:35 bostic Exp --> <!--Copyright 1997-2001 by Sleepycat Software, Inc.--> <!--All rights reserved.--> <html> diff --git a/db/docs/api_c/logc_get.html b/db/docs/api_c/logc_get.html index 2292e377a..4284db1b6 100644 --- a/db/docs/api_c/logc_get.html +++ b/db/docs/api_c/logc_get.html @@ -1,4 +1,4 @@ -<!--Id: logc_get.so,v 10.30 2001/09/29 15:48:08 dda Exp --> +<!--Id: logc_get.so,v 10.31 2001/10/22 15:24:35 bostic Exp --> <!--Copyright 1997-2001 by Sleepycat Software, Inc.--> <!--All rights reserved.--> <html> diff --git a/db/docs/api_c/memp_fcreate.html b/db/docs/api_c/memp_fcreate.html index b59bb3f80..169c64051 100644 --- a/db/docs/api_c/memp_fcreate.html +++ b/db/docs/api_c/memp_fcreate.html @@ -1,4 +1,4 @@ -<!--Id: memp_fcreate.so,v 10.3 2001/07/31 17:25:40 dda Exp --> +<!--Id: memp_fcreate.so,v 10.4 2001/10/22 15:24:35 bostic Exp --> <!--Copyright 1997-2001 by Sleepycat Software, Inc.--> <!--All rights reserved.--> <html> diff --git a/db/docs/api_c/memp_set_clear_len.html b/db/docs/api_c/memp_set_clear_len.html index ebc791497..02a90a849 100644 --- a/db/docs/api_c/memp_set_clear_len.html +++ b/db/docs/api_c/memp_set_clear_len.html @@ -1,4 +1,4 @@ -<!--Id: memp_set_clear_len.so,v 10.1 2001/07/24 18:31:14 bostic Exp --> +<!--Id: memp_set_clear_len.so,v 10.2 2001/10/22 15:24:36 bostic Exp --> <!--Copyright 1997-2001 by Sleepycat Software, Inc.--> <!--All rights reserved.--> <html> diff --git a/db/docs/api_c/memp_set_fileid.html b/db/docs/api_c/memp_set_fileid.html index 61d4fa195..90a73171a 100644 --- a/db/docs/api_c/memp_set_fileid.html +++ b/db/docs/api_c/memp_set_fileid.html @@ -1,4 +1,4 @@ -<!--Id: memp_set_fileid.so,v 10.1 2001/07/24 18:31:14 bostic Exp --> +<!--Id: memp_set_fileid.so,v 10.2 2001/10/22 15:24:36 bostic Exp --> <!--Copyright 1997-2001 by Sleepycat Software, Inc.--> <!--All rights reserved.--> <html> diff --git a/db/docs/api_c/memp_set_ftype.html b/db/docs/api_c/memp_set_ftype.html index ff6407b35..512cb34ef 100644 --- a/db/docs/api_c/memp_set_ftype.html +++ b/db/docs/api_c/memp_set_ftype.html @@ -1,4 +1,4 @@ -<!--Id: memp_set_ftype.so,v 10.1 2001/07/24 18:31:14 bostic Exp --> +<!--Id: memp_set_ftype.so,v 10.2 2001/10/22 15:24:37 bostic Exp --> <!--Copyright 1997-2001 by Sleepycat Software, Inc.--> <!--All rights reserved.--> <html> diff --git a/db/docs/api_c/memp_set_lsn_offset.html b/db/docs/api_c/memp_set_lsn_offset.html index 5a38b8fdf..40941e6ea 100644 --- a/db/docs/api_c/memp_set_lsn_offset.html +++ b/db/docs/api_c/memp_set_lsn_offset.html @@ -1,4 +1,4 @@ -<!--Id: memp_set_lsn_offset.so,v 10.1 2001/07/24 18:31:14 bostic Exp --> +<!--Id: memp_set_lsn_offset.so,v 10.2 2001/10/22 15:24:37 bostic Exp --> <!--Copyright 1997-2001 by Sleepycat Software, Inc.--> <!--All rights reserved.--> <html> diff --git a/db/docs/api_c/memp_set_pgcookie.html b/db/docs/api_c/memp_set_pgcookie.html index 92a78a902..bcfaa8e12 100644 --- a/db/docs/api_c/memp_set_pgcookie.html +++ b/db/docs/api_c/memp_set_pgcookie.html @@ -1,4 +1,4 @@ -<!--Id: memp_set_pgcookie.so,v 10.1 2001/07/24 18:31:15 bostic Exp --> +<!--Id: memp_set_pgcookie.so,v 10.2 2001/10/22 15:24:37 bostic Exp --> <!--Copyright 1997-2001 by Sleepycat Software, Inc.--> <!--All rights reserved.--> <html> diff --git a/db/docs/api_c/txn_set_timeout.html b/db/docs/api_c/txn_set_timeout.html index a53a290bd..4bd06a7a6 100644 --- a/db/docs/api_c/txn_set_timeout.html +++ b/db/docs/api_c/txn_set_timeout.html @@ -1,4 +1,4 @@ -<!--Id: txn_set_timeout.so,v 10.2 2001/09/07 21:43:17 bostic Exp --> +<!--Id: txn_set_timeout.so,v 10.3 2001/10/22 15:24:39 bostic Exp --> <!--Copyright 1997-2001 by Sleepycat Software, Inc.--> <!--All rights reserved.--> <html> diff --git a/db/docs/api_cxx/env_set_timeout.html b/db/docs/api_cxx/env_set_timeout.html index a267862f6..a04ec7d33 100644 --- a/db/docs/api_cxx/env_set_timeout.html +++ b/db/docs/api_cxx/env_set_timeout.html @@ -1,4 +1,4 @@ -<!--Id: env_set_timeout.so,v 10.2 2001/09/07 21:43:16 bostic Exp --> +<!--Id: env_set_timeout.so,v 10.3 2001/10/22 15:24:31 bostic Exp --> <!--Copyright 1997-2001 by Sleepycat Software, Inc.--> <!--All rights reserved.--> <html> diff --git a/db/docs/api_cxx/lock_id_free.html b/db/docs/api_cxx/lock_id_free.html index 4366d17e6..e6e8f8f36 100644 --- a/db/docs/api_cxx/lock_id_free.html +++ b/db/docs/api_cxx/lock_id_free.html @@ -1,4 +1,4 @@ -<!--Id: lock_id_free.so,v 10.1 2001/09/25 15:18:55 bostic Exp --> +<!--Id: lock_id_free.so,v 10.2 2001/10/22 15:24:32 bostic Exp --> <!--Copyright 1997-2001 by Sleepycat Software, Inc.--> <!--All rights reserved.--> <html> diff --git a/db/docs/api_cxx/log_cursor.html b/db/docs/api_cxx/log_cursor.html index e8463b4e0..b6a877ba3 100644 --- a/db/docs/api_cxx/log_cursor.html +++ b/db/docs/api_cxx/log_cursor.html @@ -1,4 +1,4 @@ -<!--Id: log_cursor.so,v 10.1 2001/09/28 15:09:35 bostic Exp --> +<!--Id: log_cursor.so,v 10.2 2001/10/22 15:24:33 bostic Exp --> <!--Copyright 1997-2001 by Sleepycat Software, Inc.--> <!--All rights reserved.--> <html> diff --git a/db/docs/api_cxx/logc_close.html b/db/docs/api_cxx/logc_close.html index 22c8f5052..b3ad0fc69 100644 --- a/db/docs/api_cxx/logc_close.html +++ b/db/docs/api_cxx/logc_close.html @@ -1,4 +1,4 @@ -<!--Id: logc_close.so,v 10.3 2001/10/02 01:33:35 bostic Exp --> +<!--Id: logc_close.so,v 10.4 2001/10/22 15:24:35 bostic Exp --> <!--Copyright 1997-2001 by Sleepycat Software, Inc.--> <!--All rights reserved.--> <html> diff --git a/db/docs/api_cxx/logc_get.html b/db/docs/api_cxx/logc_get.html index bb5e4a3c7..73d6e9f46 100644 --- a/db/docs/api_cxx/logc_get.html +++ b/db/docs/api_cxx/logc_get.html @@ -1,4 +1,4 @@ -<!--Id: logc_get.so,v 10.30 2001/09/29 15:48:08 dda Exp --> +<!--Id: logc_get.so,v 10.31 2001/10/22 15:24:35 bostic Exp --> <!--Copyright 1997-2001 by Sleepycat Software, Inc.--> <!--All rights reserved.--> <html> diff --git a/db/docs/api_cxx/memp_fcreate.html b/db/docs/api_cxx/memp_fcreate.html index 014688c6c..6a6a202f3 100644 --- a/db/docs/api_cxx/memp_fcreate.html +++ b/db/docs/api_cxx/memp_fcreate.html @@ -1,4 +1,4 @@ -<!--Id: memp_fcreate.so,v 10.3 2001/07/31 17:25:40 dda Exp --> +<!--Id: memp_fcreate.so,v 10.4 2001/10/22 15:24:35 bostic Exp --> <!--Copyright 1997-2001 by Sleepycat Software, Inc.--> <!--All rights reserved.--> <html> diff --git a/db/docs/api_cxx/memp_set_clear_len.html b/db/docs/api_cxx/memp_set_clear_len.html index 0574fff1c..56017cc18 100644 --- a/db/docs/api_cxx/memp_set_clear_len.html +++ b/db/docs/api_cxx/memp_set_clear_len.html @@ -1,4 +1,4 @@ -<!--Id: memp_set_clear_len.so,v 10.1 2001/07/24 18:31:14 bostic Exp --> +<!--Id: memp_set_clear_len.so,v 10.2 2001/10/22 15:24:36 bostic Exp --> <!--Copyright 1997-2001 by Sleepycat Software, Inc.--> <!--All rights reserved.--> <html> diff --git a/db/docs/api_cxx/memp_set_fileid.html b/db/docs/api_cxx/memp_set_fileid.html index 38d3a889b..50c179a2e 100644 --- a/db/docs/api_cxx/memp_set_fileid.html +++ b/db/docs/api_cxx/memp_set_fileid.html @@ -1,4 +1,4 @@ -<!--Id: memp_set_fileid.so,v 10.1 2001/07/24 18:31:14 bostic Exp --> +<!--Id: memp_set_fileid.so,v 10.2 2001/10/22 15:24:36 bostic Exp --> <!--Copyright 1997-2001 by Sleepycat Software, Inc.--> <!--All rights reserved.--> <html> diff --git a/db/docs/api_cxx/memp_set_ftype.html b/db/docs/api_cxx/memp_set_ftype.html index d87576141..04195c00a 100644 --- a/db/docs/api_cxx/memp_set_ftype.html +++ b/db/docs/api_cxx/memp_set_ftype.html @@ -1,4 +1,4 @@ -<!--Id: memp_set_ftype.so,v 10.1 2001/07/24 18:31:14 bostic Exp --> +<!--Id: memp_set_ftype.so,v 10.2 2001/10/22 15:24:37 bostic Exp --> <!--Copyright 1997-2001 by Sleepycat Software, Inc.--> <!--All rights reserved.--> <html> diff --git a/db/docs/api_cxx/memp_set_lsn_offset.html b/db/docs/api_cxx/memp_set_lsn_offset.html index 5173fbb15..05891ba4c 100644 --- a/db/docs/api_cxx/memp_set_lsn_offset.html +++ b/db/docs/api_cxx/memp_set_lsn_offset.html @@ -1,4 +1,4 @@ -<!--Id: memp_set_lsn_offset.so,v 10.1 2001/07/24 18:31:14 bostic Exp --> +<!--Id: memp_set_lsn_offset.so,v 10.2 2001/10/22 15:24:37 bostic Exp --> <!--Copyright 1997-2001 by Sleepycat Software, Inc.--> <!--All rights reserved.--> <html> diff --git a/db/docs/api_cxx/memp_set_pgcookie.html b/db/docs/api_cxx/memp_set_pgcookie.html index 1ed2548de..945f729f0 100644 --- a/db/docs/api_cxx/memp_set_pgcookie.html +++ b/db/docs/api_cxx/memp_set_pgcookie.html @@ -1,4 +1,4 @@ -<!--Id: memp_set_pgcookie.so,v 10.1 2001/07/24 18:31:15 bostic Exp --> +<!--Id: memp_set_pgcookie.so,v 10.2 2001/10/22 15:24:37 bostic Exp --> <!--Copyright 1997-2001 by Sleepycat Software, Inc.--> <!--All rights reserved.--> <html> diff --git a/db/docs/api_cxx/txn_set_timeout.html b/db/docs/api_cxx/txn_set_timeout.html index da3e6ea3d..f67020601 100644 --- a/db/docs/api_cxx/txn_set_timeout.html +++ b/db/docs/api_cxx/txn_set_timeout.html @@ -1,4 +1,4 @@ -<!--Id: txn_set_timeout.so,v 10.2 2001/09/07 21:43:17 bostic Exp --> +<!--Id: txn_set_timeout.so,v 10.3 2001/10/22 15:24:39 bostic Exp --> <!--Copyright 1997-2001 by Sleepycat Software, Inc.--> <!--All rights reserved.--> <html> diff --git a/db/docs/api_java/env_set_timeout.html b/db/docs/api_java/env_set_timeout.html index b7502961a..809bfdd48 100644 --- a/db/docs/api_java/env_set_timeout.html +++ b/db/docs/api_java/env_set_timeout.html @@ -1,4 +1,4 @@ -<!--Id: env_set_timeout.so,v 10.2 2001/09/07 21:43:16 bostic Exp --> +<!--Id: env_set_timeout.so,v 10.3 2001/10/22 15:24:31 bostic Exp --> <!--Copyright 1997-2001 by Sleepycat Software, Inc.--> <!--All rights reserved.--> <html> @@ -22,7 +22,7 @@ import com.sleepycat.db.*; <p> public void set_timeout(long timeout, int flags) - throws DbException; + throws DbException; </pre></h3> <h1>Description</h1> <p>The DbEnv.set_timeout method sets timeout values for locks or diff --git a/db/docs/api_java/lock_id_free.html b/db/docs/api_java/lock_id_free.html index 199bfc9ec..f275643a3 100644 --- a/db/docs/api_java/lock_id_free.html +++ b/db/docs/api_java/lock_id_free.html @@ -1,4 +1,4 @@ -<!--Id: lock_id_free.so,v 10.1 2001/09/25 15:18:55 bostic Exp --> +<!--Id: lock_id_free.so,v 10.2 2001/10/22 15:24:32 bostic Exp --> <!--Copyright 1997-2001 by Sleepycat Software, Inc.--> <!--All rights reserved.--> <html> @@ -22,7 +22,7 @@ import com.sleepycat.db.*; <p> public int lock_id_free(int id) - throws DbException; + throws DbException; </pre></h3> <h1>Description</h1> <p>The DbEnv.lock_id_free method frees a locker ID allocated by the diff --git a/db/docs/api_java/log_cursor.html b/db/docs/api_java/log_cursor.html index 5ca5cf65f..6c3acd5f7 100644 --- a/db/docs/api_java/log_cursor.html +++ b/db/docs/api_java/log_cursor.html @@ -1,4 +1,4 @@ -<!--Id: log_cursor.so,v 10.1 2001/09/28 15:09:35 bostic Exp --> +<!--Id: log_cursor.so,v 10.2 2001/10/22 15:24:33 bostic Exp --> <!--Copyright 1997-2001 by Sleepycat Software, Inc.--> <!--All rights reserved.--> <html> @@ -22,7 +22,7 @@ import com.sleepycat.db.*; <p> public DbLogc log_cursor(int flags) - throws DbException; + throws DbException; </pre></h3> <h1>Description</h1> <p>The DbEnv.log_cursor method diff --git a/db/docs/api_java/logc_close.html b/db/docs/api_java/logc_close.html index eea8254e0..90f13965c 100644 --- a/db/docs/api_java/logc_close.html +++ b/db/docs/api_java/logc_close.html @@ -1,4 +1,4 @@ -<!--Id: logc_close.so,v 10.3 2001/10/02 01:33:35 bostic Exp --> +<!--Id: logc_close.so,v 10.4 2001/10/22 15:24:35 bostic Exp --> <!--Copyright 1997-2001 by Sleepycat Software, Inc.--> <!--All rights reserved.--> <html> @@ -22,7 +22,7 @@ import com.sleepycat.db.*; <p> public void close(int flags) - throws DbException; + throws DbException; </pre></h3> <h1>Description</h1> <p>The DbLogc.logc_close method discards the log cursor. After DbLogc.logc_close diff --git a/db/docs/api_java/logc_get.html b/db/docs/api_java/logc_get.html index 2269a8a4b..0ae8791e1 100644 --- a/db/docs/api_java/logc_get.html +++ b/db/docs/api_java/logc_get.html @@ -1,4 +1,4 @@ -<!--Id: logc_get.so,v 10.30 2001/09/29 15:48:08 dda Exp --> +<!--Id: logc_get.so,v 10.31 2001/10/22 15:24:35 bostic Exp --> <!--Copyright 1997-2001 by Sleepycat Software, Inc.--> <!--All rights reserved.--> <html> @@ -22,7 +22,7 @@ import com.sleepycat.db.*; <p> public int get(DbLsn lsn, Dbt data, int flags) - throws DbException; + throws DbException; </pre></h3> <h1>Description</h1> <p>The DbLogc.logc_get method retrieve records from the log according to the diff --git a/db/docs/api_java/txn_set_timeout.html b/db/docs/api_java/txn_set_timeout.html index 9279d3b8f..78a1df76d 100644 --- a/db/docs/api_java/txn_set_timeout.html +++ b/db/docs/api_java/txn_set_timeout.html @@ -1,4 +1,4 @@ -<!--Id: txn_set_timeout.so,v 10.2 2001/09/07 21:43:17 bostic Exp --> +<!--Id: txn_set_timeout.so,v 10.3 2001/10/22 15:24:39 bostic Exp --> <!--Copyright 1997-2001 by Sleepycat Software, Inc.--> <!--All rights reserved.--> <html> @@ -22,7 +22,7 @@ import com.sleepycat.db.*; <p> public int set_timeout(long timeout, int flags) - throws DbException; + throws DbException; </pre></h3> <h1>Description</h1> <p>The DbTxn.set_timeout method sets timeout values for locks or diff --git a/db/docs/ref/build_vxworks/introae.html b/db/docs/ref/build_vxworks/introae.html index 4441aab5a..34b24671e 100644 --- a/db/docs/ref/build_vxworks/introae.html +++ b/db/docs/ref/build_vxworks/introae.html @@ -1,4 +1,4 @@ -<!--Id: introae.so,v 1.3 2001/10/12 19:21:26 bostic Exp --> +<!--Id: introae.so,v 1.4 2001/11/05 21:05:19 sue Exp --> <!--Copyright 1997-2001 by Sleepycat Software, Inc.--> <!--All rights reserved.--> <html> @@ -25,8 +25,8 @@ 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>Demo program component directory</td> </tr> -<tr> <td align=left>db_*/db_*</td> <td align=left><a href="../../utility/index.html">Support utilities</a> component directories</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>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> <p>This document assumes you already have a workspace set up and you diff --git a/db/docs/ref/rep/app.html b/db/docs/ref/rep/app.html index cc4ca9bdf..abc26fdd0 100644 --- a/db/docs/ref/rep/app.html +++ b/db/docs/ref/rep/app.html @@ -1,4 +1,4 @@ -<!--Id: app.so,v 1.1 2001/10/13 19:56:23 bostic Exp --> +<!--Id: app.so,v 1.3 2001/10/25 21:17:51 bostic Exp --> <!--Copyright 1997-2001 by Sleepycat Software, Inc.--> <!--All rights reserved.--> <html> @@ -21,10 +21,10 @@ 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>: <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. <p><dt><a href="../../api_c/rep_start.html">DB_ENV->rep_start</a><dd>The <a href="../../api_c/rep_start.html">DB_ENV->rep_start</a> function configures (or reconfigures) an existing database environment to be a replication master or client. -<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_message.html">DB_ENV->rep_process_message</a><dd>The <a href="../../api_c/rep_message.html">DB_ENV->rep_process_message</a> function is used to process incoming messages from other environments in the replication group. For clients, it is responsible for accepting log records and updating the local databases based on @@ -32,8 +32,8 @@ messages from the master. For both the master and the clients, it is responsible for handling administrative functions (for example, the protocol for dealing with lost messages), and permitting new clients to join an active replication group. -<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. +<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. </dl> <p>To add replication to a Berkeley DB application, application initialization must be changed, and some new code, the application's communications @@ -54,6 +54,10 @@ group, or, alternatively, configure all group members as clients and then call an election, letting the clients select the master from among themselves. Either is correct, and the choice is entirely up to the application. +<p>The result of calling <a href="../../api_c/rep_start.html">DB_ENV->rep_start</a> is usually the discovery of a +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>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 a58a11e0b..d7f550b7f 100644 --- a/db/docs/ref/rep/comm.html +++ b/db/docs/ref/rep/comm.html @@ -1,4 +1,4 @@ -<!--Id: comm.so,v 1.1 2001/10/13 19:56:23 bostic Exp --> +<!--Id: comm.so,v 1.3 2001/10/25 20:05:34 bostic Exp --> <!--Copyright 1997-2001 by Sleepycat Software, Inc.--> <!--All rights reserved.--> <html> @@ -14,14 +14,15 @@ </td></tr></table> <p> <h1 align=center>Building the communications infrastructure</h1> -<p>Replicated applications are typically written with one or more threads -of control looping on one or more communication channels. These threads -accept messages from remote environments for the local database -environment, and accept messages from the local environment for remote -environments. Messages 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>The replication portion of 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 +messages from the local environment for remote environments. Messages +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> interface, a callback interface used by Berkeley DB for sending messages to @@ -42,6 +43,11 @@ arbitrary thread or process in the Berkeley DB environment. <p>There are a number of informational returns from the <a href="../../api_c/rep_message.html">DB_ENV->rep_process_message</a> function: <p><dl compact> +<p><dt><a href="../../api_c/rep_message.html#DB_REP_DUPMASTER">DB_REP_DUPMASTER</a><dd>When <a href="../../api_c/rep_message.html">DB_ENV->rep_process_message</a> returns <a href="../../api_c/rep_message.html#DB_REP_DUPMASTER">DB_REP_DUPMASTER</a>, it means that +another database environment in the replication group also believes +itself to be the master. The application should reconfigure itself as +a client using the <a href="../../api_c/rep_start.html">DB_ENV->rep_start</a> function, and then call for an election by +calling the <a href="../../api_c/rep_elect.html">DB_ENV->rep_elect</a> function. <p><dt><a href="../../api_c/rep_message.html#DB_REP_HOLDELECTION">DB_REP_HOLDELECTION</a><dd>When <a href="../../api_c/rep_message.html">DB_ENV->rep_process_message</a> returns <a href="../../api_c/rep_message.html#DB_REP_HOLDELECTION">DB_REP_HOLDELECTION</a>, it means that another database environment in the replication group has called for an election. The application should call the <a href="../../api_c/rep_elect.html">DB_ENV->rep_elect</a> function. @@ -51,18 +57,17 @@ environment's ID for that master. If the ID of the master has changed, the application may need to reconfigure itself (for example, to redirect update queries to the new master rather then the old one). If the new master is the local environment, then the application must call the -<a href="../../api_c/rep_start.html">DB_ENV->rep_start</a> function, and to reconfigure the supporting Berkeley DB library as -a replication master. +<a href="../../api_c/rep_start.html">DB_ENV->rep_start</a> function, and reconfigure the supporting Berkeley DB library as a +replication master. <p><dt><a href="../../api_c/rep_message.html#DB_REP_NEWSITE">DB_REP_NEWSITE</a><dd>When <a href="../../api_c/rep_message.html">DB_ENV->rep_process_message</a> returns <a href="../../api_c/rep_message.html#DB_REP_NEWSITE">DB_REP_NEWSITE</a>, it means that a message from a previously unknown member of the replication group has been received. The application should reconfigure itself as necessary so it is able to send messages to this site. <p><dt><a href="../../api_c/rep_message.html#DB_REP_OUTDATED">DB_REP_OUTDATED</a><dd>When <a href="../../api_c/rep_message.html">DB_ENV->rep_process_message</a> returns <a href="../../api_c/rep_message.html#DB_REP_OUTDATED">DB_REP_OUTDATED</a>, it means that -the environment has been out-of-contact with the master for too long a -time, and the master no longer has sufficient logs in order to bring the -local client up-to-date. The application should shut down, and the -client reinitialized (see <a href="../../ref/rep/init.html">Initializing -a new site</a> for more information.) +the environment has been partitioned from the master for too long a +time, and the master no longer has the necessary log files to update +the local client. The application should shut down, and the client +should be reinitialized (see <a href="../../ref/rep/init.html">Initializing a new site</a> for more information). </dl> <table width="100%"><tr><td><br></td><td align=right><a href="../../ref/rep/app.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/newsite.html"><img src="../../images/next.gif" alt="Next"></a> </td></tr></table> diff --git a/db/docs/ref/rep/elect.html b/db/docs/ref/rep/elect.html index 8aa9bd6a6..c0b2ed9ac 100644 --- a/db/docs/ref/rep/elect.html +++ b/db/docs/ref/rep/elect.html @@ -1,4 +1,4 @@ -<!--Id: elect.so,v 1.1 2001/10/13 19:56:23 bostic Exp --> +<!--Id: elect.so,v 1.5 2001/10/25 21:20:01 bostic Exp --> <!--Copyright 1997-2001 by Sleepycat Software, Inc.--> <!--All rights reserved.--> <html> @@ -18,22 +18,29 @@ application. It is not dangerous to hold an election, as the Berkeley DB election process ensures there is never more than a single master environment. Clients should initiate an election whenever they lose -contact with the master environment, whenever see a return of +contact with the master environment, whenever they see a return of <a href="../../api_c/rep_message.html#DB_REP_HOLDELECTION">DB_REP_HOLDELECTION</a> from the <a href="../../api_c/rep_message.html">DB_ENV->rep_process_message</a> function, or when, for -whatever reason, they do not know who the master is. +whatever reason, they do not know who the master is. It is not +necessary for applications to immediately hold elections when they +start, as any existing master will be quickly discovered after calling +<a href="../../api_c/rep_start.html">DB_ENV->rep_start</a>. If no master has been found after a short wait +period, then the application should call for an election. <p>For a client to become the master, the client must win an election. To -win an election, the replication group must currently have no master -and the client must have the highest priority of the database -environments participating in the election. It is dangerous to -configure more than one master environment using the <a href="../../api_c/rep_start.html">DB_ENV->rep_start</a> function, -and applications should be careful not to do so. Applications should -only configure themselves as the master environment if they are the only -possible master, or if they have won an election. An application can -only know it has won an election if the <a href="../../api_c/rep_elect.html">DB_ENV->rep_elect</a> function returns -success and the local database environment's ID as the new master -environment ID, or if the <a href="../../api_c/rep_message.html">DB_ENV->rep_process_message</a> function returns -<a href="../../api_c/rep_message.html#DB_REP_NEWMASTER">DB_REP_NEWMASTER</a> and the local database environment's ID as the -new master environment ID. +win an election, the replication group must currently have no master, +the client must have the highest priority of the database environments +participating in the election, and at least (N / 2 + 1) of the members +of the replication group must participate in the election. In the case +of multiple database environments with equal priorities, the environment +with the most recent log records will win. +<p>It is dangerous to configure more than one master environment using the +<a href="../../api_c/rep_start.html">DB_ENV->rep_start</a> function, and applications should be careful not to do so. +Applications should only configure themselves as the master environment +if they are the only possible master, or if they have won an election. +An application can only know it has won an election if the +<a href="../../api_c/rep_elect.html">DB_ENV->rep_elect</a> function returns success and the local database environment's +ID as the new master environment ID, or if the <a href="../../api_c/rep_message.html">DB_ENV->rep_process_message</a> function +returns <a href="../../api_c/rep_message.html#DB_REP_NEWMASTER">DB_REP_NEWMASTER</a> and the local database environment's +ID as the new master environment ID. <p>To add a database environment to the replication group with the intent of it becoming the master, first add it as a client. Since it may be out-of-date with respect to the current master, allow it to update @@ -44,15 +51,17 @@ sufficient time to update itself with respect to the current master. <p>If a client is unable to find a master or win an election, it means that the network has been partitioned and there are not enough environments participating in the election for one of the participants to win. In -this case, the application should periodically hold an election until -a master is found or an election is won. In desperate circumstances, -an application could simply declare itself the master by calling -<a href="../../api_c/rep_start.html">DB_ENV->rep_start</a>, or by reducing the number of participants required -to win an election until the election is won. Neither of these -solutions is recommended: in the case of a network partition, either of -these choices can result in there being two masters in one replication -group, and the databases in the environment might irretrievably diverge -as they are modified in different ways by the masters. +this case, the application should repeatedly call <a href="../../api_c/rep_start.html">DB_ENV->rep_start</a> and +<a href="../../api_c/rep_elect.html">DB_ENV->rep_elect</a>, alternating between attempting to discover an +existing master, and holding an election to declare a new one. In +desperate circumstances, an application could simply declare itself the +master by calling <a href="../../api_c/rep_start.html">DB_ENV->rep_start</a>, or by reducing the number of +participants required to win an election until the election is won. +Neither of these solutions is recommended: in the case of a network +partition, either of these choices can result in there being two masters +in one replication group, and the databases in the environment might +irretrievably diverge as they are modified in different ways by the +masters. <p>Finally, it is possible for the wrong database environment to win an election if a number of systems crash at the same time. Because an election winner is declared as soon as enough environments participate diff --git a/db/docs/ref/rep/faq.html b/db/docs/ref/rep/faq.html index 3670df8e9..83ed42e96 100644 --- a/db/docs/ref/rep/faq.html +++ b/db/docs/ref/rep/faq.html @@ -1,4 +1,4 @@ -<!--Id: faq.so,v 1.1 2001/10/13 19:56:23 bostic Exp --> +<!--Id: faq.so,v 1.5 2001/11/17 16:59:33 bostic Exp --> <!--Copyright 1997-2001 by Sleepycat Software, Inc.--> <!--All rights reserved.--> <html> @@ -10,13 +10,13 @@ <body bgcolor=white> <table width="100%"><tr valign=top> <td><h3><dl><dt>Berkeley DB Reference Guide:<dd>Berkeley DB Replication</dl></h3></td> -<td align=right><a href="../../ref/rep/trans.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../../reftoc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../../ref/xa/intro.html"><img src="../../images/next.gif" alt="Next"></a> +<td align=right><a href="../../ref/rep/partition.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/ex.html"><img src="../../images/next.gif" alt="Next"></a> </td></tr></table> <p> <h1 align=center>Replication FAQ</h1> <p><ol> -<p><li><b>Does Berkeley DB provide support for sending database update messages -from the client application to the master?</b> +<p><li><b>Does Berkeley DB provide support for forwarding write queries from +clients to masters?</b> <p>No, it does not. The Berkeley DB RPC server code could be modified to support this functionality, but in general this protocol is left entirely to the application. Note, there is no reason not to use the communications @@ -27,24 +27,6 @@ those channels be used exclusively for replication messages. multiple sites?</b> <p>No, this is not possible. All replicated databases must be equally shared by all environments in the replication group. -<p><li><b>What happens if an environment with out-of-date information -wins the election?</b> -<p>This is unlikely, but it is possible, and the outcome can be the loss -of information. For example, consider a system with a master -environment and two clients A and B, where client A may upgrade to -master status and client B cannot. Then, assume client A is partitioned -from the other two database environments, and it becomes out-of-date -with respect to the master. Then, assume the master crashes and does -not come back on-line. Subsequently, the network partition is restored, -and clients A and B hold an election. As client B cannot win the -election, client A will win by default, and in order to get back into -sync with client B, it will unroll possibly committed transactions on -client B until they can once again move forward together. -<p>This scenario stresses the importance of good network infrastructure in -your replicated environments. When replicating database environments -over sufficiently lossy networking, the best solution is usually to pick -a single master, and only hold elections when human intervention has -determined the selected master is unable to recover. <p><li><b>How can I distinguish Berkeley DB messages from application messages?</b> <p>There is no way to distinguish Berkeley DB messages from application-specific messages, nor does Berkeley DB offer any way to wrap application messages @@ -57,20 +39,24 @@ send connection information to the other database environments in the group (see <a href="../../ref/rep/newsite.html">Connecting to a new site</a> for more information). <p><li><b>How should I build my <b>send</b> function?</b> -<p>This depends on the specifics of the application. One common way is -to write the <b>rec</b> and <b>control</b> arguments' sizes and data -to a socket connected to each remote site. +<p>This depends on the specifics of the application. One common way is to +write the <b>rec</b> and <b>control</b> arguments' sizes and data to +a socket connected to each remote site. On a fast, local area net, the +simplest method is likely to be construct broadcast messages. Each +Berkeley DB message would be encapsulated inside an application specific +message, with header information specifying the intended recipient(s) +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>Can I use replication to replicate just the database environment's log files?</b> -<p>Not explicitly. However, a client replica will contain a full set of -logs as generated by the master, within the semantic limits of the -transport mechanism. In the event that a master crashes, the client -environment may be used directly (after running recovery) or for -catastrophic recovery on the master site. -<p><font color=red>There's a DB_REP_LOGSONLY flag -- so this is wrong, I -think.</font> +<p>Yes. If the <a href="../../api_c/rep_start.html#DB_REP_LOGSONLY">DB_REP_LOGSONLY</a> flag is specified to +<a href="../../api_c/rep_start.html">DB_ENV->rep_start</a>, the client site acts as a repository for logfiles +(see <a href="../../ref/rep/logonly.html">Log file only clients</a> for more +information). </ol> -<table width="100%"><tr><td><br></td><td align=right><a href="../../ref/rep/trans.html"><img src="../../images/prev.gif" alt="Prev"></a><a href="../../reftoc.html"><img src="../../images/ref.gif" alt="Ref"></a><a href="../../ref/xa/intro.html"><img src="../../images/next.gif" alt="Next"></a> +<table width="100%"><tr><td><br></td><td align=right><a href="../../ref/rep/partition.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/ex.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/id.html b/db/docs/ref/rep/id.html index d470db350..572fcc1d6 100644 --- a/db/docs/ref/rep/id.html +++ b/db/docs/ref/rep/id.html @@ -1,4 +1,4 @@ -<!--Id: id.so,v 1.2 2001/10/13 19:56:23 bostic Exp --> +<!--Id: id.so,v 1.5 2001/11/05 17:24:27 bostic Exp --> <!--Copyright 1997-2001 by Sleepycat Software, Inc.--> <!--All rights reserved.--> <html> @@ -17,19 +17,26 @@ <p>Each database environment included in a replication group must have a unique identifier for itself and for the other members of the replication group. The identifiers do not need to be global, that is, -each instance of a running application can assign local identifiers to -members of the replication group as they find out about 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. +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. <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 <b>send</b> interface with those same identifiers. <p>Negative identifiers are reserved for use by Berkeley DB, and should never be -assigned to environments by the application. +assigned to environments by the application. Two of these reserved +identifiers are intended for application use, as follows: +<p><dl compact> +<p><dt><a href="../../api_c/rep_transport.html#DB_EID_BROADCAST">DB_EID_BROADCAST</a><dd>The <a href="../../api_c/rep_transport.html#DB_EID_BROADCAST">DB_EID_BROADCAST</a> identifier indicates a message should be +broadcast to all members of a replication group. +<p><dt><a href="../../api_c/rep_transport.html#DB_EID_INVALID">DB_EID_INVALID</a><dd>The <a href="../../api_c/rep_transport.html#DB_EID_INVALID">DB_EID_INVALID</a> identifier is an invalid environment ID, and +may be used to initialize environment ID variables that are subsequently +checked for validity. +</dl> <table width="100%"><tr><td><br></td><td align=right><a href="../../ref/rep/intro.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/pri.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/init.html b/db/docs/ref/rep/init.html index 0ab90224d..46a784c12 100644 --- a/db/docs/ref/rep/init.html +++ b/db/docs/ref/rep/init.html @@ -1,4 +1,4 @@ -<!--Id: init.so,v 1.1 2001/10/13 19:56:24 bostic Exp --> +<!--Id: init.so,v 1.2 2001/11/05 17:24:27 bostic Exp --> <!--Copyright 1997-2001 by Sleepycat Software, Inc.--> <!--All rights reserved.--> <html> @@ -17,17 +17,19 @@ <p>Perform the following steps to add a new site to the replication group: <p><ol> -<p><li>Perform a hot backup of the master's environment, as described in -<a href="../../ref/transapp/archival.html">Database and log file archival</a>. -<p><li>Copy the hot backup to the client. -<p><li>Run ordinary (non-catastrophic) recovery on the client's new -environment, using either the <a href="../../utility/db_recover.html">db_recover</a> utility or the -<a href="../../api_c/env_open.html#DB_RECOVER">DB_RECOVER</a> flag to <a href="../../api_c/env_open.html">DB_ENV->open</a>. +<p><li>Do an archival backup of the master's environment, as described in +<a href="../../ref/transapp/archival.html">Database and log file +archival</a>. The backup can either be a conventional backup or a hot +backup. +<p><li>Copy the archival backup into a clean environment directory on the +client. +<p><li>Run catastrophic recovery on the client's new environment, as described +in <a href="../../ref/transapp/recovery.html">Recovery procedures</a>. <p><li>Reconfigure and reopen the environment as a client member of the replication group. </ol> -<p>If copying the hot backup to the client takes a long time relative to -the frequency with which log files are reclaimed using the +<p>If copying the backup to the client takes a long time relative to the +frequency with which log files are reclaimed using the <a href="../../utility/db_archive.html">db_archive</a> utility or the <a href="../../api_c/log_archive.html">DB_ENV->log_archive</a> function, it may be necessary to suppress log reclamation until the newly restarted client has "caught up" and applied all log records generated during its diff --git a/db/docs/ref/rep/intro.html b/db/docs/ref/rep/intro.html index e0d670f98..439937cd1 100644 --- a/db/docs/ref/rep/intro.html +++ b/db/docs/ref/rep/intro.html @@ -1,4 +1,4 @@ -<!--Id: intro.so,v 1.2 2001/10/13 20:21:47 bostic Exp --> +<!--Id: intro.so,v 1.3 2001/10/24 19:06:38 bostic Exp --> <!--Copyright 1997-2001 by Sleepycat Software, Inc.--> <!--All rights reserved.--> <html> @@ -16,19 +16,17 @@ <p> <h1 align=center>Introduction</h1> <p>Berkeley DB includes support for building highly available applications based -on single-master (read-only) replication. Berkeley DB replication groups -consist of some number of independently configured database -environments. The database environments might be on separate computers, -on separate boards in a computer with replicated hardware, or on -separate disks in a single computer. The environments may be accessed -by any number of applications, from one to many. As always with Berkeley DB +on replication. Berkeley DB replication groups consist of some number of +independently configured database environments. There is a single +<i>master</i> database environment and one or more <i>client</i> +database environments. Master environments support both database reads +and writes; client environments support only database reads. If the +master environment fails, applications may upgrade a client to be the +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 -the database environment. -<p>Berkeley DB replication groups contain a single <i>master</i> database -environment and one or more <i>client</i> database environments. -Master environments support both database reads and writes; client -environments support only database reads. If the master environment -fails, applications may upgrade a client to be the new master. +a database 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 diff --git a/db/docs/ref/rep/logonly.html b/db/docs/ref/rep/logonly.html index cb1fac5b4..70860f10d 100644 --- a/db/docs/ref/rep/logonly.html +++ b/db/docs/ref/rep/logonly.html @@ -1,4 +1,4 @@ -<!--Id: logonly.so,v 1.1 2001/10/13 19:56:24 bostic Exp --> +<!--Id: logonly.so,v 1.4 2001/11/06 22:20:11 bostic Exp --> <!--Copyright 1997-2001 by Sleepycat Software, Inc.--> <!--All rights reserved.--> <html> @@ -14,7 +14,32 @@ </td></tr></table> <p> <h1 align=center>Log file only clients</h1> -<p><font color=red>Needs to be written.</font> +<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. +<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 +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. +<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 +<a href="../../ref/transapp/recovery.html">Recovery procedures</a> Berkeley DB +Reference Guide. +<p>In all other ways, a log-file-only site behaves as other replication +clients do. It should have a thread or process receiving messages and +passing them to <a href="../../api_c/rep_message.html">DB_ENV->rep_process_message</a> and must respond to all returns +described for that interface. <table width="100%"><tr><td><br></td><td align=right><a href="../../ref/rep/elect.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/trans.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/newsite.html b/db/docs/ref/rep/newsite.html index 3856bbe7e..ace77acf7 100644 --- a/db/docs/ref/rep/newsite.html +++ b/db/docs/ref/rep/newsite.html @@ -1,4 +1,4 @@ -<!--Id: newsite.so,v 1.1 2001/10/13 19:56:24 bostic Exp --> +<!--Id: newsite.so,v 1.2 2001/10/25 14:58:49 bostic Exp --> <!--Copyright 1997-2001 by Sleepycat Software, Inc.--> <!--All rights reserved.--> <html> @@ -20,8 +20,8 @@ should assign the new site a local environment ID number, and all future messages from the site passed to <a href="../../api_c/rep_message.html">DB_ENV->rep_process_message</a> should include that environment ID number. It is possible, of course, for the application to be aware of a new site before the return of <a href="../../api_c/rep_message.html">DB_ENV->rep_process_message</a> (for -example, applications using a connection-oriented protocols are likely -to detect new sites immediately, while applications using broadcast +example, applications using connection-oriented protocols are likely to +detect new sites immediately, while applications using broadcast protocols may not). <p>Regardless, in applications supporting the dynamic addition of database environments to replication groups, environments joining an existing diff --git a/db/docs/ref/rep/pri.html b/db/docs/ref/rep/pri.html index 6ceaf09be..cd92c9b13 100644 --- a/db/docs/ref/rep/pri.html +++ b/db/docs/ref/rep/pri.html @@ -1,4 +1,4 @@ -<!--Id: pri.so,v 1.1 2001/10/13 19:56:24 bostic Exp --> +<!--Id: pri.so,v 1.3 2001/11/05 17:24:27 bostic Exp --> <!--Copyright 1997-2001 by Sleepycat Software, Inc.--> <!--All rights reserved.--> <html> @@ -19,12 +19,14 @@ priority, which specifies a relative ordering among the different environments in a replication group. This ordering determines which environment will be selected as a new master in case the existing master fails. -<p>Priorities may be any integer. Larger valued priorities indicate a more -desirable master. For example, if a replication group consists of three -database environments, two of which are connected by an OC3 and the -third of which is connected by a T1, the third database environment -should be assigned a priority value which is lower than either of the -other two. +<p>Priorities must be a non-negative integer, but do not need to be unique +throughout the replication group. A priority of 0 means the system can +never become a master, regardless. Otherwise, larger valued priorities +indicate a more desirable master. For example, if a replication group +consists of three database environments, two of which are connected by +an OC3 and the third of which is connected by a T1, the third database +environment should be assigned a priority value which is lower than +either of the other two. <table width="100%"><tr><td><br></td><td align=right><a href="../../ref/rep/id.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/app.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/trans.html b/db/docs/ref/rep/trans.html index db8bd7b13..4dac09dee 100644 --- a/db/docs/ref/rep/trans.html +++ b/db/docs/ref/rep/trans.html @@ -1,4 +1,4 @@ -<!--Id: trans.so,v 1.1 2001/10/13 19:56:24 bostic Exp --> +<!--Id: trans.so,v 1.5 2001/11/05 17:24:27 bostic Exp --> <!--Copyright 1997-2001 by Sleepycat Software, Inc.--> <!--All rights reserved.--> <html> @@ -10,7 +10,7 @@ <body bgcolor=white> <table width="100%"><tr valign=top> <td><h3><dl><dt>Berkeley DB Reference Guide:<dd>Berkeley DB Replication</dl></h3></td> -<td align=right><a href="../../ref/rep/logonly.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/faq.html"><img src="../../images/next.gif" alt="Next"></a> +<td align=right><a href="../../ref/rep/logonly.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/partition.html"><img src="../../images/next.gif" alt="Next"></a> </td></tr></table> <p> <h1 align=center>Transactional guarantees</h1> @@ -23,15 +23,14 @@ information is reviewed during recovery, and the databases are updated so that all changes made as part of committed transactions appear, and all changes made as part of uncommitted transactions do not appear. In this case, no information will have been lost. -<p>If the database environment has been configured to not synchronously -flush the log to stable storage when transactions are committed (using -the <a href="../../api_c/env_open.html#DB_TXN_NOSYNC">DB_TXN_NOSYNC</a> flag to increase performance at the cost of -sacrificing transactional durability), Berkeley DB recovery will only be able -to restore the system to the state of the last commit found on stable -storage. In this case, information may have been lost (for example, -changes made on the part of a committed transaction may not appear in -a database). -<p>Finally, if there is database or log file loss or corruption (for +<p>If a database environment does not require that the log be flushed to +stable storage on transaction commit (using the <a href="../../api_c/env_set_flags.html#DB_TXN_NOSYNC">DB_TXN_NOSYNC</a> +flag to increase performance at the cost of sacrificing transactional +durability), Berkeley DB recovery will only be able to restore the system to +the state of the last commit found on stable storage. In this case, +information may have been lost (for example, the changes made by some +committed transactions may not appear in the databases after recovery). +<p>Further, if there is database or log file loss or corruption (for example, if a disk drive fails), then catastrophic recovery is necessary, and Berkeley DB recovery will only be able to restore the system to the state of the last archived log file. In this case, information @@ -40,11 +39,12 @@ may also have been lost. new component to "stable storage": the client's replicated information. If a database environment is replicated, there is no lost information in the case of database or log file loss, because the replicated system -contains a complete set of databases and log records up to the point of -failure. A database environment that loses a disk drive can have the -drive replaced, and it can rejoin the replication group as a client. +can be configured to contain a complete set of databases and log records +up to the point of failure. A database environment that loses a disk +drive can have the drive replaced, and it can rejoin the replication +group as a client. <p>Because of this new component of stable storage, specifying -<a href="../../api_c/env_open.html#DB_TXN_NOSYNC">DB_TXN_NOSYNC</a> in a replicated environment no longer sacrifices +<a href="../../api_c/env_set_flags.html#DB_TXN_NOSYNC">DB_TXN_NOSYNC</a> in a replicated environment no longer sacrifices durability, as long as one or more clients have acknowledged receipt of the messages sent by the master. Since network connections are often faster than local disk writes, replication becomes a way for @@ -57,13 +57,14 @@ 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. +want to avoid returning an error from the <b>send</b> interface, unless +it is absolutely necessary. <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 broadcast the message (or even simply -copied the message to local memory). +to Berkeley DB immediately after it has sent the message (or even simply +copied the message to its 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 @@ -76,25 +77,26 @@ 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 and the -<b>send</b> interface was unable to determine that some number of -clients received the message. How many clients should have received -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. +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. <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 message if both master and clients are on the same power supply, as the failure of the power supply will still potentially lose information. <p>Finally, the Berkeley DB replication implementation has one other additional -feature to increase application reliability. Replication in Berkeley DB was +feature to increase application reliability. Replication in Berkeley DB is implemented to perform database updates using a different code path than the standard ones. This means operations which manage to crash the replication master due to a software bug will not necessarily also crash replication clients. -<table width="100%"><tr><td><br></td><td align=right><a href="../../ref/rep/logonly.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/faq.html"><img src="../../images/next.gif" alt="Next"></a> +<table width="100%"><tr><td><br></td><td align=right><a href="../../ref/rep/logonly.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/partition.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/disk.html b/db/docs/ref/upgrade.4.0/disk.html index 1bb72138e..230840167 100644 --- a/db/docs/ref/upgrade.4.0/disk.html +++ b/db/docs/ref/upgrade.4.0/disk.html @@ -1,4 +1,4 @@ -<!--Id: disk.so,v 1.9 2001/09/18 16:08:16 bostic Exp --> +<!--Id: disk.so,v 1.10 2001/11/09 22:11:29 bostic Exp --> <!--Copyright 1997-2001 by Sleepycat Software, Inc.--> <!--All rights reserved.--> <html> @@ -10,7 +10,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/java.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/test/run.html"><img src="../../images/next.gif" alt="Next"></a> </td></tr></table> <p> <h1 align=center>Release 4.0: upgrade requirements</h1> @@ -18,7 +18,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/java.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/test/run.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/java.html b/db/docs/ref/upgrade.4.0/java.html index cb51dd8bc..788620b18 100644 --- a/db/docs/ref/upgrade.4.0/java.html +++ b/db/docs/ref/upgrade.4.0/java.html @@ -1,4 +1,4 @@ -<!--Id: java.so,v 1.4 2001/09/25 21:05:24 bostic Exp --> +<!--Id: java.so,v 1.6 2001/11/14 02:27:12 bostic Exp --> <!--Copyright 1997-2001 by Sleepycat Software, Inc.--> <!--All rights reserved.--> <html> @@ -10,7 +10,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/lock_id_free.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.0/disk.html"><img src="../../images/next.gif" alt="Next"></a> +<td align=right><a href="../../ref/upgrade.4.0/lock_id_free.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.0/cxx.html"><img src="../../images/next.gif" alt="Next"></a> </td></tr></table> <p> <h1 align=center>Release 4.0: Java CLASSPATH environment variable</h1> @@ -25,7 +25,7 @@ example, on UNIX: <p>For more information on Java configuration, please see <a href="../../ref/java/conf.html">Java configuration</a> and <a href="../../ref/build_win/intro.html">Building for Win32</a>. -<table width="100%"><tr><td><br></td><td align=right><a href="../../ref/upgrade.4.0/lock_id_free.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.0/disk.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/lock_id_free.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.0/cxx.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/toc.html b/db/docs/ref/upgrade.4.0/toc.html index 3c579f944..ad2033946 100644 --- a/db/docs/ref/upgrade.4.0/toc.html +++ b/db/docs/ref/upgrade.4.0/toc.html @@ -1,4 +1,4 @@ -<!--Id: toc.so,v 1.13 2001/09/25 21:05:25 bostic Exp --> +<!--Id: toc.so,v 1.15 2001/11/14 02:27:12 bostic Exp --> <!--Copyright 1997-2001 by Sleepycat Software, Inc.--> <!--All rights reserved.--> <html> @@ -26,6 +26,8 @@ <li><a href="set_lk_max.html">Release 4.0: DB_ENV->set_lk_max</a> <li><a href="lock_id_free.html">Release 4.0: DB_ENV->lock_id_free</a> <li><a href="java.html">Release 4.0: Java CLASSPATH environment variable</a> +<li><a href="cxx.html">Release 4.0: C++ ostream objects</a> +<li><a href="asr.html">Release 4.0: application-specific recovery</a> <li><a href="disk.html">Release 4.0: upgrade requirements</a> </ol> <table width="100%"><tr><td><br></td><td align=right><a href="../../reftoc.html"><img src="../../images/ref.gif" alt="Ref"></a> diff --git a/db/examples_c/ex_repquote/ex_repquote.h b/db/examples_c/ex_repquote/ex_repquote.h index eaf3423cc..75edbcc3c 100644 --- a/db/examples_c/ex_repquote/ex_repquote.h +++ b/db/examples_c/ex_repquote/ex_repquote.h @@ -4,7 +4,7 @@ * Copyright (c) 2001 * Sleepycat Software. All rights reserved. * - * Id: ex_repquote.h,v 1.19 2001/10/13 13:13:16 bostic Exp + * Id: ex_repquote.h,v 1.24 2001/10/28 15:45:39 bostic Exp */ #ifndef _EX_REPQUOTE_H_ @@ -19,7 +19,7 @@ typedef struct { /* Globals */ extern int master_eid; -extern char *myaddr;; +extern char *myaddr; struct __member; typedef struct __member member_t; struct __machtab; typedef struct __machtab machtab_t; @@ -58,10 +58,12 @@ int listen_socket_init __P((char *, int)); int listen_socket_accept __P((machtab_t *, 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 *, u_int32_t *)); +void machtab_parm __P((machtab_t *, int *, int *, u_int32_t *)); int machtab_rem __P((machtab_t *, int, int)); -int quote_send __P((DB_ENV *, void *, const DBT *, DBT *, u_int32_t, int)); +int quote_send __P((DB_ENV *, const DBT *, const DBT *, int, u_int32_t)); +#ifndef COMPQUIET #define COMPQUIET(x,y) x = (y) +#endif #endif /* !_EX_REPQUOTE_H_ */ diff --git a/db/examples_c/ex_repquote/ex_rq_client.c b/db/examples_c/ex_repquote/ex_rq_client.c index 440d3766a..a6d4b143c 100644 --- a/db/examples_c/ex_repquote/ex_rq_client.c +++ b/db/examples_c/ex_repquote/ex_rq_client.c @@ -4,7 +4,7 @@ * Copyright (c) 2001 * Sleepycat Software. All rights reserved. * - * Id: ex_rq_client.c,v 1.21 2001/10/09 14:45:43 margo Exp + * Id: ex_rq_client.c,v 1.25 2001/11/18 01:29:07 margo Exp */ #include <sys/types.h> @@ -57,22 +57,19 @@ doclient(dbenv, progname, machtab) dargs.progname = progname; dargs.dbenv = dbenv; if (pthread_create(&disp_thr, NULL, display_loop, (void *)&dargs)) { - fprintf(stderr, "%s: display_loop pthread_create failed: %s\n", - progname, strerror(errno)); + dbenv->err(dbenv, errno, "display_loop pthread_create failed"); goto err; } cargs.dbenv = dbenv; cargs.machtab = machtab; if (pthread_create(&check_thr, NULL, check_loop, (void *)&cargs)) { - fprintf(stderr, "%s: check_thread pthread_create failed: %s\n", - progname, strerror(errno)); + dbenv->err(dbenv, errno, "check_thread pthread_create failed"); goto err; } if (pthread_join(disp_thr, &dstatus) || pthread_join(check_thr, &cstatus)) { - fprintf(stderr, "%s: pthread_join failed: %s\n", - progname, strerror(errno)); + dbenv->err(dbenv, errno, "pthread_join failed"); goto err; } @@ -96,9 +93,9 @@ check_loop(args) DB_ENV *dbenv; DBT dbt; checkloop_args *cargs; - int count, n, is_me, pri; + int count, n, pri; machtab_t *machtab; - u_int32_t check, elect; + u_int32_t timeout; cargs = (checkloop_args *)args; dbenv = cargs->dbenv; @@ -107,48 +104,25 @@ check_loop(args) #define IDLE_INTERVAL 1 count = 0; - while (1) { - sleep(IDLE_INTERVAL); - - /* If we become master, shut this loop off. */ - if (master_eid == SELF_EID) - break; - - if (master_eid == DB_INVALID_EID) - count++; - else - count = 0; - - if (count <= 1) - continue; - + while (master_eid == DB_EID_INVALID) { /* - * First, call rep_start (possibly again) to see if we can - * find a master. + * Call either rep_start or rep_elect depending on if + * count is 0 or 1. */ - memset(&dbt, 0, sizeof(dbt)); - dbt.data = myaddr; - dbt.size = strlen(myaddr) + 1; - (void)dbenv->rep_start(dbenv, &dbt, DB_REP_CLIENT); - sleep(IDLE_INTERVAL); - - if (master_eid != DB_INVALID_EID) { + if (count == 0) { + memset(&dbt, 0, sizeof(dbt)); + dbt.data = myaddr; + dbt.size = strlen(myaddr) + 1; + (void)dbenv->rep_start(dbenv, &dbt, DB_REP_CLIENT); + count = 1; + } else { + machtab_parm(machtab, &n, &pri, &timeout); + (void)dbenv->rep_elect(dbenv, + n, pri, timeout, &master_eid); count = 0; - continue; - } - - /* Now call for an election */ - machtab_parm(machtab, &n, &pri, &check, &elect); - if (dbenv->rep_elect(dbenv, - n, pri, check, elect, &master_eid, &is_me) != 0) - continue; - - /* If I'm the new master, I can stop checking for masters. */ - if (is_me) { - master_eid = SELF_EID; - break; } + sleep(IDLE_INTERVAL); } return ((void *)EXIT_SUCCESS); @@ -179,8 +153,7 @@ display_loop(args) if (dbp == NULL) { if ((ret = db_create(&dbp, dbenv, 0)) != 0) { - fprintf(stderr, "%s: db_create: %s\n", progname, - db_strerror(ret)); + dbenv->err(dbenv, ret, "db_create"); return ((void *)EXIT_FAILURE); } @@ -190,37 +163,31 @@ display_loop(args) printf( "No stock database yet available.\n"); if ((ret = dbp->close(dbp, 0)) != 0) { - fprintf(stderr, - "%s: DB->close: %s", - progname, - db_strerror(ret)); + dbenv->err(dbenv, + ret, "DB->close"); goto err; } dbp = NULL; sleep(SLEEPTIME); continue; } - fprintf(stderr, "%s: DB->open: %s\n", progname, - db_strerror(ret)); + dbenv->err(dbenv, ret, "DB->open"); goto err; } } if ((ret = dbp->cursor(dbp, NULL, &dbc, 0)) != 0) { - fprintf(stderr, "%s: DB->cursor: %s\n", progname, - db_strerror(ret)); + dbenv->err(dbenv, ret, "DB->cursor"); goto err; } if ((ret = print_stocks(dbc)) != 0) { - fprintf(stderr, "%s: database traversal failed: %s\n", - progname, db_strerror(ret)); + dbenv->err(dbenv, ret, "database traversal failed"); goto err; } if ((ret = dbc->c_close(dbc)) != 0) { - fprintf(stderr, "%s: DB->close: %s\n", progname, - db_strerror(ret)); + dbenv->err(dbenv, ret, "DB->close"); goto err; } @@ -236,14 +203,12 @@ err: rval = EXIT_FAILURE; } if (dbc != NULL && (ret = dbc->c_close(dbc)) != 0) { - fprintf(stderr, "%s: DB->close: %s\n", progname, - db_strerror(ret)); + dbenv->err(dbenv, ret, "DB->close"); rval = EXIT_FAILURE; } if (dbp != NULL && (ret = dbp->close(dbp, 0)) != 0) { - fprintf(stderr, "%s: DB->close: %s\n", progname, - db_strerror(ret)); + dbenv->err(dbenv, ret, "DB->close"); return ((void *)EXIT_FAILURE); } diff --git a/db/examples_c/ex_repquote/ex_rq_main.c b/db/examples_c/ex_repquote/ex_rq_main.c index 6ee27d788..f9adbacad 100644 --- a/db/examples_c/ex_repquote/ex_rq_main.c +++ b/db/examples_c/ex_repquote/ex_rq_main.c @@ -4,7 +4,7 @@ * Copyright (c) 2001 * Sleepycat Software. All rights reserved. * - * Id: ex_rq_main.c,v 1.11 2001/10/09 14:45:43 margo Exp + * Id: ex_rq_main.c,v 1.18 2001/11/18 01:29:07 margo Exp */ #include <sys/types.h> @@ -26,7 +26,7 @@ int master_eid; char *myaddr; -int env_init __P((char *, char *, DB_ENV **, machtab_t *, u_int32_t)); +static int env_init __P((char *, char *, DB_ENV **, machtab_t *, u_int32_t)); static void usage __P((char *)); int @@ -40,25 +40,25 @@ main(argc, argv) DBT local; enum { MASTER, CLIENT, UNKNOWN } whoami; all_args aa; - char *c, ch, *home, *progname; connect_args ca; - int maxsites, nsites, ret, priority, totalsites; machtab_t *machtab; pthread_t all_thr, conn_thr; site_t site, *sitep, self, *selfp; struct sigaction sigact; + int maxsites, nsites, ret, priority, totalsites; + char *c, ch, *home, *progname; void *astatus, *cstatus; - home = "TESTDIR"; + master_eid = DB_EID_INVALID; + + dbenv = NULL; + whoami = UNKNOWN; machtab = NULL; selfp = sitep = NULL; - maxsites = nsites = totalsites = 0; - progname = "ex_repquote"; - ret = 0; - whoami = UNKNOWN; + maxsites = nsites = ret = totalsites = 0; priority = 100; - - master_eid = DB_INVALID_EID; + home = "TESTDIR"; + progname = "ex_repquote"; while ((ch = getopt(argc, argv, "Ch:Mm:n:o:p:")) != EOF) switch (ch) { @@ -145,10 +145,6 @@ main(argc, argv) * We are hardcoding priorities here that all clients have the * same priority except for a designated master who gets a higher * priority. - * XXX If we add a logsonly site to this app, we can give it - * priority 0; I say we should document that priority=0 sites should - * never become masters; they still need to vote, they just can't - * be masters. */ if ((ret = machtab_init(&machtab, priority, totalsites)) != 0) @@ -159,9 +155,9 @@ main(argc, argv) * begin replicating. However, we want to have a dbenv around * so that we can send it into any of our message handlers. */ - if ((ret = env_init(progname, - home, &dbenv, machtab, DB_THREAD | DB_RECOVER)) != 0) + if ((ret = env_init(progname, home, &dbenv, machtab, DB_RECOVER)) != 0) goto err; + /* * Now sets up comm infrastructure. There are two phases. First, * we open our port for listening for incoming connections. Then @@ -188,17 +184,14 @@ main(argc, argv) /* * We have now got the entire communication infrastructure set up. * It's time to declare ourselves to be a client or master. - * XXX How do I decide that I have to switch from doing the read - * loop to the write loop or vica versa? */ if (whoami == MASTER) { if ((ret = dbenv->rep_start(dbenv, NULL, DB_REP_MASTER)) != 0) { - fprintf(stderr, - "dbenv->rep_start failed %s\n", db_strerror(ret)); + dbenv->err(dbenv, ret, "dbenv->rep_start failed"); goto err; } if ((ret = domaster(dbenv, progname)) != 0) { - fprintf(stderr, "Master failed %s\n", db_strerror(ret)); + dbenv->err(dbenv, ret, "Master failed"); goto err; } } else { @@ -207,12 +200,13 @@ main(argc, argv) local.size = strlen(myaddr) + 1; if ((ret = dbenv->rep_start(dbenv, &local, DB_REP_CLIENT)) != 0) { - fprintf(stderr, - "dbenv->rep_start failed %s\n", db_strerror(ret)); + dbenv->err(dbenv, ret, "dbenv->rep_start failed"); goto err; } + /* Sleep to give ourselves a minute to find a master. */ + sleep(5); if ((ret = doclient(dbenv, progname, machtab)) != 0) { - fprintf(stderr, "Client failed %s\n", db_strerror(ret)); + dbenv->err(dbenv, ret, "Client failed"); goto err; } @@ -250,8 +244,9 @@ err: if (machtab != NULL) * -[MC] M for master/C for client * -h home directory * -n nsites (optional; number of sites in replication group; defaults to 0 - * in which case we try to dynamically computer the number of sites in + * in which case we try to dynamically compute the number of sites in * the replication group.) + * -p priority (optional: defaults to 100) */ static void usage(progname) @@ -289,17 +284,14 @@ 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_cachesize(dbenv, 0, CACHESIZE, 0); /* (void)dbenv->set_flags(dbenv, DB_TXN_NOSYNC, 1); */ - (void)dbenv->set_rep_transport(dbenv, - SELF_EID, (void *)machtab, quote_send); + dbenv->app_private = machtab; + (void)dbenv->set_rep_transport(dbenv, SELF_EID, quote_send); - /* - * When we have log cursors, we can open this threaded and then - * not create a new environment for each thread. - */ - flags |= DB_CREATE | + flags |= DB_CREATE | DB_THREAD | DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_MPOOL | DB_INIT_TXN; ret = dbenv->open(dbenv, home, flags, 0); diff --git a/db/examples_c/ex_repquote/ex_rq_master.c b/db/examples_c/ex_repquote/ex_rq_master.c index 0bf732b7b..713a1dec6 100644 --- a/db/examples_c/ex_repquote/ex_rq_master.c +++ b/db/examples_c/ex_repquote/ex_rq_master.c @@ -5,7 +5,7 @@ * Copyright (c) 2001 * Sleepycat Software. All rights reserved. * - * Id: ex_rq_master.c,v 1.15 2001/10/13 13:13:16 bostic Exp + * Id: ex_rq_master.c,v 1.16 2001/10/26 19:19:43 margo Exp */ #include <sys/types.h> @@ -120,7 +120,7 @@ master_loop(dbenvv) if (strncmp(buf, "exit", 4) == 0 || strncmp(buf, "quit", 4) == 0) break; - fprintf(stderr, "Format: TICKER VALUE\n"); + dbenv->errx(dbenv, "Format: TICKER VALUE"); continue; } diff --git a/db/examples_c/ex_repquote/ex_rq_net.c b/db/examples_c/ex_repquote/ex_rq_net.c index 96d5c8939..0ef216f49 100644 --- a/db/examples_c/ex_repquote/ex_rq_net.c +++ b/db/examples_c/ex_repquote/ex_rq_net.c @@ -4,7 +4,7 @@ * Copyright (c) 2001 * Sleepycat Software. All rights reserved. * - * Id: ex_rq_net.c,v 1.20 2001/10/13 13:13:16 bostic Exp + * Id: ex_rq_net.c,v 1.30 2001/11/18 01:29:07 margo Exp */ #include <sys/types.h> @@ -26,6 +26,8 @@ #include <db.h> +#include "mutex.h" +#include "rep.h" #include "ex_repquote.h" int machtab_add __P((machtab_t *, int, u_int32_t, int, int *)); @@ -67,8 +69,7 @@ struct __machtab { LIST_HEAD(__machlist, __member) machlist; int nextid; pthread_mutex_t mtmutex; - u_int32_t check_time; - u_int32_t elect_time; + u_int32_t timeout_time; int current; int max; int nsites; @@ -85,14 +86,14 @@ struct __member { /* For linked list of all members we know of. */ }; -static int quote_send_broadcast __P((DB_ENV *, - machtab_t *, const DBT *, DBT *, u_int32_t)); -static int quote_send_one __P((DB_ENV *, const DBT *, DBT *, int, int, u_int32_t)); +static int quote_send_broadcast __P((machtab_t *, + const DBT *, const DBT *, u_int32_t)); +static int quote_send_one __P((const DBT *, const DBT *, int, u_int32_t)); /* * machtab_init -- * Initialize the machine ID table. - * XXX Right now I treat the number of sites as the maximum + * XXX Right now we treat the number of sites as the maximum * number we've ever had on the list at one time. We probably * want to make that smarter. */ @@ -111,10 +112,7 @@ machtab_init(machtabp, pri, nsites) /* Reserve eid's 0 and 1. */ machtab->nextid = 2; -/* microseconds in millisecond */ -#define MS 1000 - machtab->check_time = 500 * MS; - machtab->elect_time = 2 * 1000 * MS; + machtab->timeout_time = 2 * 1000000; /* 2 seconds. */ machtab->current = machtab->max = 0; machtab->priority = pri; machtab->nsites = nsites; @@ -170,15 +168,7 @@ machtab_add(machtab, fd, hostaddr, port, idp) if (m == NULL) { if (++machtab->current > machtab->max) machtab->max = machtab->current; -#ifdef APP_DEBUG -printf("%lx Adding to machtab: %lx:%d at eid %d\n", -(long)pthread_self(), (long)hostaddr, port, member->eid); -#endif } else { -#ifdef APP_DEBUG -printf("%lx Found in machtab: %lx:%d at eid %d\n", -(long)pthread_self(), (long)hostaddr, port, member->eid); -#endif free(member); ret = EEXIST; } @@ -240,10 +230,6 @@ machtab_rem(machtab, eid, lock) member != NULL; member = LIST_NEXT(member, links)) if (member->eid == eid) { -#ifdef APP_DEBUG -printf("%lx Removing eid %d %lx:%d\n", (long)pthread_self, member->eid, -(long)member->hostaddr, member->port); -#endif found = 1; LIST_REMOVE(member, links); (void)close(member->fd); @@ -262,18 +248,17 @@ printf("%lx Removing eid %d %lx:%d\n", (long)pthread_self, member->eid, } void -machtab_parm(machtab, nump, prip, checkp, electp) +machtab_parm(machtab, nump, prip, timeoutp) machtab_t *machtab; int *nump, *prip; - u_int32_t *checkp, *electp; + u_int32_t *timeoutp; { if (machtab->nsites == 0) *nump = machtab->max; else *nump = machtab->nsites; *prip = machtab->priority; - *checkp = machtab->check_time; - *electp = machtab->elect_time; + *timeoutp = machtab->timeout_time; } /* @@ -326,9 +311,9 @@ listen_socket_accept(machtab, progname, s, eidp) char *progname; int s, *eidp; { - int host, ns, port, ret; - size_t si_len; struct sockaddr_in si; + socklen_t si_len; + int host, ns, port, ret; COMPQUIET(progname, NULL); @@ -360,10 +345,10 @@ get_accepted_socket(progname, port) char *progname; int port; { - int s, ns; - size_t si_len; struct protoent *proto; struct sockaddr_in si; + socklen_t si_len; + int s, ns; if ((proto = getprotobyname("tcp")) == NULL) return (-1); @@ -386,10 +371,6 @@ get_accepted_socket(progname, port) si_len = sizeof(si); ns = accept(s, (struct sockaddr *)&si, &si_len); - /* XXX I think we may want to pass up the identify of the - * connecting host so we can check for duplicates. For - * debugging, let's just display it for now. - */ return (ns); err: fprintf(stderr, "%s: %s", progname, strerror(errno)); @@ -460,9 +441,8 @@ 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 will become the guts of f_receive, but is also used - * directly by code that plans to do the equivalent outside a callback, - * and manually dispatch to DB_ENV->rep_process_message() + * 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 get_next_message(fd, rec, control) @@ -528,20 +508,8 @@ get_next_message(fd, rec, control) control->data = controlbuf; control->size = csize; -#ifdef APP_DEBUG_MSG - { - REP_CONTROL *rp; - - rp = (REP_CONTROL *)control->data; - fprintf(stderr, - "%lx Received message type %d gen %d lsn[%d,%d] flags %lx\n", - (long)pthread_self(), - rp->rectype, rp->gen, rp->lsn.file, rp->lsn.offset, - (unsigned long)rp->flags); - if (rp->rectype == REP_LOG) - __db_loadme(); - } -#endif +fprintf(stderr, "%lx Received %d\n", (long)pthread_self(), +((REP_CONTROL *)controlbuf)->rectype ); return (0); } @@ -551,27 +519,25 @@ get_next_message(fd, rec, control) * The f_send function for DB_ENV->set_rep_transport. */ int -quote_send(dbenv, cookie, rec, control, flags, eid) +quote_send(dbenv, control, rec, eid, flags) DB_ENV *dbenv; - void *cookie; - const DBT *rec; - DBT *control; - u_int32_t flags; + const DBT *control, *rec; int eid; + u_int32_t flags; { int fd, n, ret, t_ret; machtab_t *machtab; member_t *m; - machtab = (machtab_t *)cookie; + machtab = (machtab_t *)dbenv->app_private; - if (eid == DB_BROADCAST_EID) { + if (eid == DB_EID_BROADCAST) { /* * Right now, we do not require successful transmission. * I'd like to move this requiring at least one successful * transmission on PERMANENT requests. */ - n = quote_send_broadcast(dbenv, machtab, rec, control, flags); + n = quote_send_broadcast(machtab, rec, control, flags); if (n < 0 /*|| (n == 0 && LF_ISSET(DB_REP_PERMANENT))*/) return (DB_REP_UNAVAIL); return (0); @@ -595,7 +561,7 @@ quote_send(dbenv, cookie, rec, control, flags, eid) return (DB_REP_UNAVAIL); } - ret = quote_send_one(dbenv, rec, control, eid, fd, flags); + ret = quote_send_one(rec, control, fd, flags); if ((t_ret = (pthread_mutex_unlock(&machtab->mtmutex))) != 0 && ret == 0) @@ -611,11 +577,9 @@ quote_send(dbenv, cookie, rec, control, flags, eid) * communicated. A -1 indicates a fatal error. */ static int -quote_send_broadcast(dbenv, machtab, rec, control, flags) - DB_ENV *dbenv; +quote_send_broadcast(machtab, rec, control, flags) machtab_t *machtab; - const DBT *rec; - DBT *control; + const DBT *rec, *control; u_int32_t flags; { int ret, sent; @@ -627,8 +591,7 @@ quote_send_broadcast(dbenv, machtab, rec, control, flags) sent = 0; for (m = LIST_FIRST(&machtab->machlist); m != NULL; m = next) { next = LIST_NEXT(m, links); - if ((ret = - quote_send_one(dbenv, rec, control, m->eid, m->fd, flags)) != 0) { + if ((ret = quote_send_one(rec, control, m->fd, flags)) != 0) { (void)machtab_rem(machtab, m->eid, 0); } else sent++; @@ -651,11 +614,9 @@ quote_send_broadcast(dbenv, machtab, rec, control, flags) * intersperse writes that are part of two single messages. */ static int -quote_send_one(dbenv, rec, control, eid, fd, flags) - DB_ENV *dbenv; - const DBT *rec; - DBT *control; - int eid, fd; +quote_send_one(rec, control, fd, flags) + const DBT *rec, *control; + int fd; u_int32_t flags; { @@ -701,24 +662,7 @@ quote_send_one(dbenv, rec, control, eid, fd, flags) if (nw != (ssize_t)control->size) return (DB_REP_UNAVAIL); } - -#ifdef APP_DEBUG_MSG - { - REP_CONTROL *rp; - - rp = (REP_CONTROL *)control->data; - fprintf(stderr, - "%lx Sent to %d message type %d, gen %d lsn [%d,%d] flags %lx\n", - (long)pthread_self(), eid, - rp->rectype, rp->gen, rp->lsn.file, rp->lsn.offset, - (unsigned long)rp->flags); - if (rp->rectype == REP_LOG) - __db_loadme(); - } -#else - COMPQUIET(eid, 0); - COMPQUIET(dbenv, NULL); -#endif - +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 9dee69d45..9fbb3eb10 100644 --- a/db/examples_c/ex_repquote/ex_rq_util.c +++ b/db/examples_c/ex_repquote/ex_rq_util.c @@ -4,7 +4,7 @@ * Copyright (c) 2001 * Sleepycat Software. All rights reserved. * - * Id: ex_rq_util.c,v 1.10 2001/10/13 13:13:16 bostic Exp + * Id: ex_rq_util.c,v 1.14 2001/10/28 15:45:39 bostic Exp */ #include <sys/types.h> @@ -50,14 +50,14 @@ hm_loop(args) DB_ENV *dbenv; DBT rec, control; char *c, *home, *progname; - int fd, is_me, eid, n, newm; + 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; - u_int32_t check, elect; + u_int32_t timeout; void *status; ea = NULL; @@ -76,9 +76,6 @@ hm_loop(args) for (ret = 0; ret == 0;) { if ((ret = get_next_message(fd, &rec, &control)) != 0) { -#ifdef APP_DEBUG -printf("%lx get_next_message for eid = %d failed\n", (long)pthread_self(), eid); -#endif /* * Close this connection; if it's the master call * for an election. @@ -102,29 +99,25 @@ printf("%lx get_next_message for eid = %d failed\n", (long)pthread_self(), eid); if (master_eid != eid) break; - master_eid = DB_INVALID_EID; - machtab_parm(tab, &n, &pri, &check, &elect); + master_eid = DB_EID_INVALID; + machtab_parm(tab, &n, &pri, &timeout); if ((ret = dbenv->rep_elect(dbenv, - n, pri, check, elect, &newm, &is_me)) != 0) + n, pri, timeout, &newm)) != 0) continue; -#ifdef APP_DEBUG - printf("%lx Election returned new master %d%s\n", - (long)pthread_self(), - newm, is_me ? "(me)" : ""); -#endif + /* * Regardless of the results, the site I was talking * to is gone, so I have nothing to do but exit. */ - if (is_me && (ret = dbenv->rep_start(dbenv, - NULL, DB_REP_MASTER)) == 0) + if (newm == SELF_EID && (ret = + dbenv->rep_start(dbenv, NULL, DB_REP_MASTER)) == 0) ret = domaster(dbenv, progname); break; } tmpid = eid; switch(r = dbenv->rep_process_message(dbenv, - &rec, &control, &tmpid)) { + &control, &rec, &tmpid)) { case DB_REP_NEWSITE: /* * Check if we got sent connect information and if we @@ -132,25 +125,19 @@ printf("%lx get_next_message for eid = %d failed\n", (long)pthread_self(), eid); * connection to this new site. If we don't, * establish a new one. */ -#ifdef APP_DEBUG -printf("Received NEWSITE return for %s\n", rec.size == 0 ? "" : (char *)rec.data); -#endif + /* No connect info. */ if (rec.size == 0) break; /* It's me, do nothing. */ - if (strncmp(myaddr, rec.data, rec.size) == 0) { -#ifdef APP_DEBUG -printf("New site was me\n"); -#endif + if (strncmp(myaddr, rec.data, rec.size) == 0) break; - } self.host = (char *)rec.data; self.host = strtok(self.host, ":"); if ((c = strtok(NULL, ":")) == NULL) { - fprintf(stderr, "Bad host specification.\n"); + dbenv->errx(dbenv, "Bad host specification"); goto out; } self.port = atoi(c); @@ -161,12 +148,8 @@ printf("New site was me\n"); * should be up if we got a message from it (even * indirectly). */ - ret = connect_site(dbenv, - tab, progname, &self, &open, &eid); -#ifdef APP_DEBUG -printf("Forked thread for new site: %d\n", eid); -#endif - if (ret != 0) + if ((ret = connect_site(dbenv, + tab, progname, &self, &open, &eid)) != 0) goto out; break; case DB_REP_HOLDELECTION: @@ -183,17 +166,11 @@ printf("Forked thread for new site: %d\n", eid); } ea->dbenv = dbenv; ea->machtab = tab; -#ifdef APP_DEBUG -printf("%lx Forking off election thread\n", (long)pthread_self()); -#endif ret = pthread_create(&elect_thr, NULL, elect_thread, (void *)ea); break; case DB_REP_NEWMASTER: /* Check if it's us. */ -#ifdef APP_DEBUG -printf("%lx Got new master message %d\n", (long)pthread_self(), tmpid); -#endif master_eid = tmpid; if (tmpid == SELF_EID) { if ((ret = dbenv->rep_start(dbenv, @@ -205,14 +182,10 @@ printf("%lx Got new master message %d\n", (long)pthread_self(), tmpid); case 0: break; default: - fprintf(stderr, "%s: %s", progname, db_strerror(r)); + dbenv->err(dbenv, r, "DBENV->rep_process_message"); break; } } -#ifdef APP_DEBUG -printf("%lx Breaking out of loop in hm_loop: %s\n", -(long)pthread_self(), db_strerror(ret)); -#endif out: if ((t_ret = machtab_rem(tab, eid, 1)) != 0 && ret == 0) ret = t_ret; @@ -289,7 +262,7 @@ connect_thread(args) } /* If we fell out, we ended up with too many threads. */ - fprintf(stderr, "Too many threads!\n"); + dbenv->errx(dbenv, "Too many threads"); ret = ENOMEM; err: pthread_attr_destroy(&attr); @@ -323,7 +296,7 @@ connect_all(args) ret = 0; if ((success = calloc(nsites, sizeof(int))) == NULL) { - fprintf(stderr, "%s: %s\n", progname, strerror(errno)); + dbenv->err(dbenv, errno, "connect_all"); ret = 1; goto err; } @@ -395,8 +368,7 @@ connect_site(dbenv, machtab, progname, site, is_open, eidp) if ((ret = pthread_create(&hm_thr, NULL, hm_loop, (void *)ha)) != 0) { - fprintf(stderr,"%s: System error %s\n", - progname, strerror(ret)); + dbenv->err(dbenv, ret, "connect site"); goto err1; } @@ -417,22 +389,22 @@ elect_thread(args) { DB_ENV *dbenv; elect_args *eargs; - int is_me, n, ret, pri; + int n, ret, pri; machtab_t *machtab; - u_int32_t check, elect; + u_int32_t timeout; eargs = (elect_args *)args; dbenv = eargs->dbenv; machtab = eargs->machtab; free(eargs); - machtab_parm(machtab, &n, &pri, &check, &elect); - while ((ret = dbenv->rep_elect(dbenv, - n, pri, check, elect, &master_eid, &is_me)) != 0) + machtab_parm(machtab, &n, &pri, &timeout); + while ((ret = + dbenv->rep_elect(dbenv, n, pri, timeout, &master_eid)) != 0) sleep(2); /* Check if it's us. */ - if (is_me) + if (master_eid == SELF_EID) ret = dbenv->rep_start(dbenv, NULL, DB_REP_MASTER); return ((void *)(ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE)); diff --git a/db/include/rep.h b/db/include/rep.h index 0cf2469b4..bcf8f26c3 100644 --- a/db/include/rep.h +++ b/db/include/rep.h @@ -49,7 +49,7 @@ /* Shared replication structure. */ typedef struct __rep { - DB_MUTEX mutex; /* Region lock. */ + DB_MUTEX mutex; /* Region lock. */ u_int32_t tally_off; /* Offset of the tally region. */ int eid; /* Environment id. */ int master_id; /* ID of the master site. */ @@ -87,13 +87,23 @@ struct __db_rep { DB *rep_db; /* Bookkeeping database. */ REP *region; /* In memory structure. */ int (*rep_send) /* Send function. */ - __P((DB_ENV *, void *, - const DBT *, DBT *, u_int32_t, int)); - void *rep_send_data; /* User data passed to every send. */ + __P((DB_ENV *, + const DBT *, const DBT *, int, u_int32_t)); }; -/* Control structure for replication communication infrastructure. */ +/* + * Control structure for replication communication infrastructure. + * + * Note that the version information should be at the beginning of the + * structure, so that we can rearrange the rest of it while letting the + * version checks continue to work. DB_REPVERSION should be revved any time + * the rest of the structure changes. + */ typedef struct __rep_control { +#define DB_REPVERSION 1 + u_int32_t rep_version; /* Replication version number. */ + u_int32_t log_version; /* Log version number. */ + DB_LSN lsn; /* Log sequence number. */ u_int32_t rectype; /* Message type. */ u_int32_t gen; /* Generation number. */ diff --git a/db/include_auto/rep_ext.h b/db/include_auto/rep_ext.h index f030c9c23..440065c25 100644 --- a/db/include_auto/rep_ext.h +++ b/db/include_auto/rep_ext.h @@ -7,12 +7,12 @@ extern "C" { int __rep_dbenv_create __P((DB_ENV *)); int __rep_process_message __P((DB_ENV *, DBT *, DBT *, int *)); int __rep_client_dbinit __P((DB_ENV *, int)); -int __rep_send_message __P((DB_ENV *, int, u_int32_t, DB_LSN *, const DBT *, u_int32_t)); int __rep_region_init __P((DB_ENV *)); int __rep_region_destroy __P((DB_ENV *)); int __rep_dbenv_close __P((DB_ENV *)); int __rep_preclose __P((DB_ENV *)); int __rep_check_alloc __P((DB_ENV *, TXN_RECS *, int)); +int __rep_send_message __P((DB_ENV *, int, u_int32_t, DB_LSN *, const DBT *, u_int32_t)); int __rep_new_master __P((DB_ENV *, REP_CONTROL *, int)); int __rep_lockpgno_init __P((DB_ENV *, int (***)(DB_ENV *, DBT *, DB_LSN *, db_recops, void *), size_t *)); int __rep_unlockpages __P((DB_ENV *, u_int32_t)); diff --git a/db/include_auto/rep_ext.in b/db/include_auto/rep_ext.in index e6d994d07..d0157753f 100644 --- a/db/include_auto/rep_ext.in +++ b/db/include_auto/rep_ext.in @@ -10,8 +10,6 @@ int __rep_dbenv_create __P((DB_ENV *)); int __rep_process_message __P((DB_ENV *, DBT *, DBT *, int *)); #define __rep_client_dbinit __rep_client_dbinit@DB_VERSION_UNIQUE_NAME@ int __rep_client_dbinit __P((DB_ENV *, int)); -#define __rep_send_message __rep_send_message@DB_VERSION_UNIQUE_NAME@ -int __rep_send_message __P((DB_ENV *, int, u_int32_t, DB_LSN *, const DBT *, u_int32_t)); #define __rep_region_init __rep_region_init@DB_VERSION_UNIQUE_NAME@ int __rep_region_init __P((DB_ENV *)); #define __rep_region_destroy __rep_region_destroy@DB_VERSION_UNIQUE_NAME@ @@ -22,6 +20,8 @@ int __rep_dbenv_close __P((DB_ENV *)); int __rep_preclose __P((DB_ENV *)); #define __rep_check_alloc __rep_check_alloc@DB_VERSION_UNIQUE_NAME@ int __rep_check_alloc __P((DB_ENV *, TXN_RECS *, int)); +#define __rep_send_message __rep_send_message@DB_VERSION_UNIQUE_NAME@ +int __rep_send_message __P((DB_ENV *, int, u_int32_t, DB_LSN *, const DBT *, u_int32_t)); #define __rep_new_master __rep_new_master@DB_VERSION_UNIQUE_NAME@ int __rep_new_master __P((DB_ENV *, REP_CONTROL *, int)); #define __rep_lockpgno_init __rep_lockpgno_init@DB_VERSION_UNIQUE_NAME@ diff --git a/db/perl/BerkeleyDB/BerkeleyDB.pm b/db/perl/BerkeleyDB/BerkeleyDB.pm index 03374e4d6..e1ae757f8 100644 --- a/db/perl/BerkeleyDB/BerkeleyDB.pm +++ b/db/perl/BerkeleyDB/BerkeleyDB.pm @@ -16,7 +16,7 @@ use strict; use Carp; use vars qw($VERSION @ISA @EXPORT $AUTOLOAD); -$VERSION = '0.16'; +$VERSION = '0.17'; require Exporter; require DynaLoader; @@ -27,41 +27,83 @@ use IO ; # Items to export into callers namespace by default. Note: do not export # names by default without a very good reason. Use EXPORT_OK instead. # Do not simply export all your public functions/methods/constants. -@EXPORT = qw( +# NOTE -- Do not add to @EXPORT directly. It is written by mkconsts +@EXPORT = qw( DB_AFTER + DB_AGGRESSIVE + DB_ALREADY_ABORTED DB_APPEND + DB_APPLY_LOGREG + DB_APP_INIT DB_ARCH_ABS DB_ARCH_DATA DB_ARCH_LOG DB_BEFORE + DB_BROADCAST_EID DB_BTREE DB_BTREEMAGIC DB_BTREEOLDVER DB_BTREEVERSION + DB_CACHED_COUNTS + DB_CDB_ALLDB DB_CHECKPOINT + DB_CLIENT + DB_CL_WRITER + DB_COMMIT DB_CONSUME DB_CONSUME_WAIT DB_CREATE DB_CURLSN DB_CURRENT - DB_DBT_MALLOC - DB_DBT_PARTIAL - DB_DBT_USERMEM + DB_CXX_NO_EXCEPTIONS DB_DELETED DB_DELIMITER + DB_DIRTY_READ + DB_DONOTINDEX DB_DUP + DB_DUPCURSOR DB_DUPSORT DB_ENV_APPINIT + DB_ENV_CDB + DB_ENV_CDB_ALLDB + DB_ENV_CREATE + DB_ENV_DBLOCAL + DB_ENV_LOCKDOWN + DB_ENV_LOCKING + DB_ENV_LOGGING + DB_ENV_NOLOCKING + DB_ENV_NOMMAP + DB_ENV_NOPANIC + DB_ENV_OPEN_CALLED + DB_ENV_PANIC_OK + DB_ENV_PRIVATE + DB_ENV_REGION_INIT + DB_ENV_REP_CLIENT + DB_ENV_REP_LOGSONLY + DB_ENV_REP_MASTER + DB_ENV_RPCCLIENT + DB_ENV_RPCCLIENT_GIVEN DB_ENV_STANDALONE + DB_ENV_SYSTEM_MEM DB_ENV_THREAD + DB_ENV_TXN + DB_ENV_TXN_NOSYNC + DB_ENV_USER_ALLOC + DB_ENV_YIELDCPU DB_EXCL + DB_EXTENT + DB_FAST_STAT + DB_FCNTL_LOCKING DB_FILE_ID_LEN DB_FIRST DB_FIXEDLEN DB_FLUSH DB_FORCE + DB_GETREC DB_GET_BOTH + DB_GET_BOTHC + DB_GET_BOTH_RANGE DB_GET_RECNO DB_HASH DB_HASHMAGIC @@ -73,75 +115,181 @@ use IO ; DB_INIT_LOG DB_INIT_MPOOL DB_INIT_TXN - DB_JOIN_ITEM + DB_INVALID_EID + DB_JAVA_CALLBACK DB_JOINENV + DB_JOIN_ITEM + DB_JOIN_NOSORT DB_KEYEMPTY DB_KEYEXIST DB_KEYFIRST DB_KEYLAST DB_LAST + DB_LOCKDOWN DB_LOCKMAGIC DB_LOCKVERSION DB_LOCK_CONFLICT DB_LOCK_DEADLOCK DB_LOCK_DEFAULT + DB_LOCK_DUMP + DB_LOCK_EXPIRE + DB_LOCK_FREE_LOCKER DB_LOCK_GET + DB_LOCK_GET_TIMEOUT + DB_LOCK_INHERIT + DB_LOCK_MAXLOCKS + DB_LOCK_MINLOCKS + DB_LOCK_MINWRITE DB_LOCK_NORUN DB_LOCK_NOTGRANTED DB_LOCK_NOTHELD DB_LOCK_NOWAIT DB_LOCK_OLDEST + DB_LOCK_PUT + DB_LOCK_PUT_ALL + DB_LOCK_PUT_OBJ + DB_LOCK_PUT_READ DB_LOCK_RANDOM + DB_LOCK_RECORD DB_LOCK_RIW_N DB_LOCK_RW_N + DB_LOCK_SET_TIMEOUT + DB_LOCK_SWITCH + DB_LOCK_TIMEOUT + DB_LOCK_UPGRADE + DB_LOCK_UPGRADE_WRITE DB_LOCK_YOUNGEST + DB_LOGC_BUF_SIZE + DB_LOGFILEID_INVALID DB_LOGMAGIC DB_LOGOLDVER + DB_LOGVERSION + DB_LOG_DISK + DB_LOG_LOCKED + DB_LOG_SILENT_ERR DB_MAX_PAGES DB_MAX_RECORDS DB_MPOOL_CLEAN DB_MPOOL_CREATE DB_MPOOL_DIRTY DB_MPOOL_DISCARD + DB_MPOOL_EXTENT DB_MPOOL_LAST DB_MPOOL_NEW + DB_MPOOL_NEW_GROUP DB_MPOOL_PRIVATE + DB_MULTIPLE + DB_MULTIPLE_KEY DB_MUTEXDEBUG DB_MUTEXLOCKS DB_NEEDSPLIT DB_NEXT DB_NEXT_DUP + DB_NEXT_NODUP + DB_NODUPDATA + DB_NOLOCKING DB_NOMMAP + DB_NOORDERCHK DB_NOOVERWRITE + DB_NOPANIC + DB_NORECURSE + DB_NOSERVER + DB_NOSERVER_HOME + DB_NOSERVER_ID DB_NOSYNC DB_NOTFOUND + DB_ODDFILESIZE + DB_OK_BTREE + DB_OK_HASH + DB_OK_QUEUE + DB_OK_RECNO + DB_OLD_VERSION + DB_OPEN_CALLED + DB_OPFLAGS_MASK + DB_ORDERCHKONLY DB_PAD DB_PAGEYIELD + DB_PAGE_LOCK + DB_PAGE_NOTFOUND + DB_PANIC_ENVIRONMENT DB_POSITION + DB_POSITIONI DB_PREV + DB_PREV_NODUP DB_PRIVATE + DB_PR_HEADERS + DB_PR_PAGE + DB_PR_RECOVERYTEST + DB_QAMMAGIC + DB_QAMOLDVER + DB_QAMVERSION DB_QUEUE DB_RDONLY + DB_RDWRMASTER DB_RECNO DB_RECNUM DB_RECORDCOUNT + DB_RECORD_LOCK DB_RECOVER DB_RECOVER_FATAL + DB_REGION_ANON + DB_REGION_INIT + DB_REGION_MAGIC + DB_REGION_NAME DB_REGISTERED DB_RENUMBER + DB_REP_CLIENT + DB_REP_DUPMASTER + DB_REP_HOLDELECTION + DB_REP_LOGSONLY + DB_REP_MASTER + DB_REP_NEWMASTER + DB_REP_NEWSITE + DB_REP_OUTDATED + DB_REP_PERMANENT + DB_REP_UNAVAIL + DB_REVSPLITOFF DB_RMW + DB_RPC_SERVERPROG + DB_RPC_SERVERVERS DB_RUNRECOVERY + DB_SALVAGE + DB_SECONDARY_BAD DB_SEQUENTIAL DB_SET + DB_SET_LOCK_TIMEOUT DB_SET_RANGE DB_SET_RECNO + DB_SET_TXN_NOW + DB_SET_TXN_TIMEOUT DB_SNAPSHOT + DB_STAT_CLEAR + DB_SURPRISE_KID DB_SWAPBYTES + DB_SYSTEM_MEM DB_TEMPORARY + DB_TEST_POSTDESTROY + DB_TEST_POSTEXTDELETE + DB_TEST_POSTEXTOPEN + DB_TEST_POSTEXTUNLINK + DB_TEST_POSTLOG + DB_TEST_POSTLOGMETA + DB_TEST_POSTOPEN + DB_TEST_POSTRENAME + DB_TEST_POSTSYNC + DB_TEST_PREDESTROY + DB_TEST_PREEXTDELETE + DB_TEST_PREEXTOPEN + DB_TEST_PREEXTUNLINK + DB_TEST_PREOPEN + DB_TEST_PRERENAME DB_THREAD + DB_TIMEOUT DB_TRUNCATE DB_TXNMAGIC DB_TXNVERSION + DB_TXN_ABORT + DB_TXN_APPLY DB_TXN_BACKWARD_ROLL DB_TXN_CKP DB_TXN_FORWARD_ROLL @@ -156,37 +304,44 @@ use IO ; DB_TXN_NOSYNC DB_TXN_NOWAIT DB_TXN_OPENFILES + DB_TXN_POPENFILES DB_TXN_REDO DB_TXN_SYNC DB_TXN_UNDO + DB_UNKNOWN + DB_UNRESOLVED_CHILD + DB_UPDATE_SECONDARY + DB_UPGRADE DB_USE_ENVIRON DB_USE_ENVIRON_ROOT + DB_VERB_CHKPOINT + DB_VERB_DEADLOCK + DB_VERB_RECOVERY + DB_VERB_WAITSFOR + DB_VERIFY + DB_VERIFY_BAD + DB_VERIFY_FATAL DB_VERSION_MAJOR DB_VERSION_MINOR DB_VERSION_PATCH + DB_VERSION_STRING + DB_VRFY_FLAGMASK DB_WRITECURSOR + DB_WRITELOCK + DB_XA_CREATE + DB_XIDDATASIZE + DB_YIELDCPU ); sub AUTOLOAD { - # This AUTOLOAD is used to 'autoload' constants from the constant() - # XS function. If a constant is not found then control is passed - # to the AUTOLOAD in AutoLoader. - - my $constname; + my($constname); ($constname = $AUTOLOAD) =~ s/.*:://; - my $val = constant($constname, @_ ? $_[0] : 0); - if ($! != 0) { - if ($! =~ /Invalid/) { - $AutoLoader::AUTOLOAD = $AUTOLOAD; - goto &AutoLoader::AUTOLOAD; - } - else { - croak "Your vendor has not defined BerkeleyDB macro $constname"; - } - } - eval "sub $AUTOLOAD { $val }"; - goto &$AUTOLOAD; -} + my ($error, $val) = constant($constname); + Carp::croak $error if $error; + no strict 'refs'; + *{$AUTOLOAD} = sub { $val }; + goto &{$AUTOLOAD}; +} bootstrap BerkeleyDB $VERSION; @@ -656,6 +811,12 @@ sub new *BerkeleyDB::Queue::TIEARRAY = \&BerkeleyDB::Queue::new ; +sub UNSHIFT +{ + my $self = shift; + croak "unshift is unsupported with Queue databases"; +} + ## package BerkeleyDB::Text ; ## ## use vars qw(@ISA) ; @@ -938,13 +1099,12 @@ sub SHIFT sub UNSHIFT { my $self = shift; - croak "unshift is unsupported with Queue databases" - if $self->type == BerkeleyDB::DB_QUEUE() ; if (@_) { my ($key, $value) = (0, 0) ; my $cursor = $self->db_cursor() ; - if ($cursor->c_get($key, $value, BerkeleyDB::DB_FIRST()) == 0) + my $status = $cursor->c_get($key, $value, BerkeleyDB::DB_FIRST()) ; + if ($status == 0) { foreach $value (reverse @_) { @@ -952,6 +1112,14 @@ sub UNSHIFT $cursor->c_put($key, $value, BerkeleyDB::DB_BEFORE()) ; } } + elsif ($status == BerkeleyDB::DB_NOTFOUND()) + { + $key = 0 ; + foreach $value (@_) + { + $self->db_put($key++, $value) ; + } + } } } @@ -960,14 +1128,16 @@ sub PUSH my $self = shift; if (@_) { - my ($key, $value) = (0, 0) ; + my ($key, $value) = (-1, 0) ; my $cursor = $self->db_cursor() ; - if ($cursor->c_get($key, $value, BerkeleyDB::DB_LAST()) == 0) + my $status = $cursor->c_get($key, $value, BerkeleyDB::DB_LAST()) ; + if ($status == 0 || $status == BerkeleyDB::DB_NOTFOUND()) { + $key = -1 if $status != 0 and $self->type != BerkeleyDB::DB_RECNO() ; foreach $value (@_) { ++ $key ; - $self->db_put($key, $value) ; + $status = $self->db_put($key, $value) ; } } diff --git a/db/perl/BerkeleyDB/BerkeleyDB.pod b/db/perl/BerkeleyDB/BerkeleyDB.pod index 0509fd5fe..a6c18c82a 100644 --- a/db/perl/BerkeleyDB/BerkeleyDB.pod +++ b/db/perl/BerkeleyDB/BerkeleyDB.pod @@ -68,6 +68,7 @@ BerkeleyDB - Perl extension for Berkeley DB version 2 or 3 $status = $txn->txn_commit() $status = $txn->txn_abort() $status = $txn->txn_id() + $status = $txn->txn_discard() $status = $env->set_lg_dir(); $status = $env->set_lg_bsize(); diff --git a/db/perl/BerkeleyDB/BerkeleyDB.pod.P b/db/perl/BerkeleyDB/BerkeleyDB.pod.P index da1c5e60a..644cdb931 100644 --- a/db/perl/BerkeleyDB/BerkeleyDB.pod.P +++ b/db/perl/BerkeleyDB/BerkeleyDB.pod.P @@ -68,6 +68,7 @@ BerkeleyDB - Perl extension for Berkeley DB version 2 or 3 $status = $txn->txn_commit() $status = $txn->txn_abort() $status = $txn->txn_id() + $status = $txn->txn_discard() $status = $env->set_lg_dir(); $status = $env->set_lg_bsize(); diff --git a/db/perl/BerkeleyDB/BerkeleyDB.xs b/db/perl/BerkeleyDB/BerkeleyDB.xs index c2230e053..5a26166bd 100644 --- a/db/perl/BerkeleyDB/BerkeleyDB.xs +++ b/db/perl/BerkeleyDB/BerkeleyDB.xs @@ -83,6 +83,10 @@ extern "C" { # define AT_LEAST_DB_3_3 #endif +#if DB_VERSION_MAJOR >= 4 +# define AT_LEAST_DB_4 +#endif + /* need to define DEFSV & SAVE_DEFSV for older version of Perl */ #ifndef DEFSV # define DEFSV GvSV(defgv) @@ -577,7 +581,11 @@ close_everything(void) tid = * (BerkeleyDB__Txn__Raw *) hv_iterkey(he, &len) ; Trace((" Aborting Transaction [%d] in [%d] Active [%d]\n", tid->txn, tid, tid->active)); if (tid->active) { +#ifdef AT_LEAST_DB_4 + tid->txn->abort(tid->txn) ; +#else txn_abort(tid->txn); +#endif ++ closed ; } tid->active = FALSE ; @@ -695,7 +703,7 @@ destroyDB(BerkeleyDB db) Safefree(db) ; } -static void +static int softCrash(const char *pat, ...) { char buffer1 [500] ; @@ -717,6 +725,7 @@ softCrash(const char *pat, ...) /* NOTREACHED */ va_end(args); + return 1 ; } @@ -1248,7 +1257,7 @@ my_db_open( if ((Status = db_open(file, type, flags, mode, env, info, &dbp)) == 0) { #endif /* DB_VERSION_MAJOR == 2 */ - Trace(("db_opened\n")); + Trace(("db_opened ok\n")); RETVAL = db ; #ifdef AT_LEAST_DB_3_3 dbp->set_alloc(dbp, safemalloc, MyRealloc, safefree) ; @@ -1287,925 +1296,12 @@ my_db_open( return RETVAL ; } -static double -constant(char * name, int arg) -{ - errno = 0; - switch (*name) { - case 'A': - break; - case 'B': - break; - case 'C': - break; - case 'D': - if (strEQ(name, "DB_AFTER")) -#ifdef DB_AFTER - return DB_AFTER; -#else - goto not_there; -#endif - if (strEQ(name, "DB_APPEND")) -#ifdef DB_APPEND - return DB_APPEND; -#else - goto not_there; -#endif - if (strEQ(name, "DB_ARCH_ABS")) -#ifdef DB_ARCH_ABS - return DB_ARCH_ABS; -#else - goto not_there; -#endif - if (strEQ(name, "DB_ARCH_DATA")) -#ifdef DB_ARCH_DATA - return DB_ARCH_DATA; -#else - goto not_there; -#endif - if (strEQ(name, "DB_ARCH_LOG")) -#ifdef DB_ARCH_LOG - return DB_ARCH_LOG; -#else - goto not_there; -#endif - if (strEQ(name, "DB_BEFORE")) -#ifdef DB_BEFORE - return DB_BEFORE; -#else - goto not_there; -#endif - if (strEQ(name, "DB_BTREE")) - return DB_BTREE; - if (strEQ(name, "DB_BTREEMAGIC")) -#ifdef DB_BTREEMAGIC - return DB_BTREEMAGIC; -#else - goto not_there; -#endif - if (strEQ(name, "DB_BTREEOLDVER")) -#ifdef DB_BTREEOLDVER - return DB_BTREEOLDVER; -#else - goto not_there; -#endif - if (strEQ(name, "DB_BTREEVERSION")) -#ifdef DB_BTREEVERSION - return DB_BTREEVERSION; -#else - goto not_there; -#endif - if (strEQ(name, "DB_CHECKPOINT")) -#ifdef DB_CHECKPOINT - return DB_CHECKPOINT; -#else - goto not_there; -#endif - if (strEQ(name, "DB_CONSUME")) -#ifdef DB_CONSUME - return DB_CONSUME; -#else - goto not_there; -#endif - if (strEQ(name, "DB_CONSUME_WAIT")) -#ifdef DB_CONSUME_WAIT - return DB_CONSUME_WAIT; -#else - goto not_there; -#endif - if (strEQ(name, "DB_CREATE")) -#ifdef DB_CREATE - return DB_CREATE; -#else - goto not_there; -#endif - if (strEQ(name, "DB_CURLSN")) -#ifdef DB_CURLSN - return DB_CURLSN; -#else - goto not_there; -#endif - if (strEQ(name, "DB_CURRENT")) -#ifdef DB_CURRENT - return DB_CURRENT; -#else - goto not_there; -#endif - if (strEQ(name, "DB_DBT_MALLOC")) -#ifdef DB_DBT_MALLOC - return DB_DBT_MALLOC; -#else - goto not_there; -#endif - if (strEQ(name, "DB_DBT_PARTIAL")) -#ifdef DB_DBT_PARTIAL - return DB_DBT_PARTIAL; -#else - goto not_there; -#endif - if (strEQ(name, "DB_DBT_USERMEM")) -#ifdef DB_DBT_USERMEM - return DB_DBT_USERMEM; -#else - goto not_there; -#endif - if (strEQ(name, "DB_DELETED")) -#ifdef DB_DELETED - return DB_DELETED; -#else - goto not_there; -#endif - if (strEQ(name, "DB_DELIMITER")) -#ifdef DB_DELIMITER - return DB_DELIMITER; -#else - goto not_there; -#endif - if (strEQ(name, "DB_DUP")) -#ifdef DB_DUP - return DB_DUP; -#else - goto not_there; -#endif - if (strEQ(name, "DB_DUPSORT")) -#ifdef DB_DUPSORT - return DB_DUPSORT; -#else - goto not_there; -#endif - if (strEQ(name, "DB_ENV_APPINIT")) -#ifdef DB_ENV_APPINIT - return DB_ENV_APPINIT; -#else - goto not_there; -#endif - if (strEQ(name, "DB_ENV_STANDALONE")) -#ifdef DB_ENV_STANDALONE - return DB_ENV_STANDALONE; -#else - goto not_there; -#endif - if (strEQ(name, "DB_ENV_THREAD")) -#ifdef DB_ENV_THREAD - return DB_ENV_THREAD; -#else - goto not_there; -#endif - if (strEQ(name, "DB_EXCL")) -#ifdef DB_EXCL - return DB_EXCL; -#else - goto not_there; -#endif - if (strEQ(name, "DB_FILE_ID_LEN")) -#ifdef DB_FILE_ID_LEN - return DB_FILE_ID_LEN; -#else - goto not_there; -#endif - if (strEQ(name, "DB_FIRST")) -#ifdef DB_FIRST - return DB_FIRST; -#else - goto not_there; -#endif - if (strEQ(name, "DB_FIXEDLEN")) -#ifdef DB_FIXEDLEN - return DB_FIXEDLEN; -#else - goto not_there; -#endif - if (strEQ(name, "DB_FLUSH")) -#ifdef DB_FLUSH - return DB_FLUSH; -#else - goto not_there; -#endif - if (strEQ(name, "DB_FORCE")) -#ifdef DB_FORCE - return DB_FORCE; -#else - goto not_there; -#endif - if (strEQ(name, "DB_GET_BOTH")) -#ifdef DB_GET_BOTH - return DB_GET_BOTH; -#else - goto not_there; -#endif - if (strEQ(name, "DB_GET_RECNO")) -#ifdef DB_GET_RECNO - return DB_GET_RECNO; -#else - goto not_there; -#endif - if (strEQ(name, "DB_HASH")) - return DB_HASH; - if (strEQ(name, "DB_HASHMAGIC")) -#ifdef DB_HASHMAGIC - return DB_HASHMAGIC; -#else - goto not_there; -#endif - if (strEQ(name, "DB_HASHOLDVER")) -#ifdef DB_HASHOLDVER - return DB_HASHOLDVER; -#else - goto not_there; -#endif - if (strEQ(name, "DB_HASHVERSION")) -#ifdef DB_HASHVERSION - return DB_HASHVERSION; -#else - goto not_there; -#endif - if (strEQ(name, "DB_INCOMPLETE")) -#ifdef DB_INCOMPLETE - return DB_INCOMPLETE; -#else - goto not_there; -#endif - if (strEQ(name, "DB_INIT_CDB")) -#ifdef DB_INIT_CDB - return DB_INIT_CDB; -#else - goto not_there; -#endif - if (strEQ(name, "DB_INIT_LOCK")) -#ifdef DB_INIT_LOCK - return DB_INIT_LOCK; -#else - goto not_there; -#endif - if (strEQ(name, "DB_INIT_LOG")) -#ifdef DB_INIT_LOG - return DB_INIT_LOG; -#else - goto not_there; -#endif - if (strEQ(name, "DB_INIT_MPOOL")) -#ifdef DB_INIT_MPOOL - return DB_INIT_MPOOL; -#else - goto not_there; -#endif - if (strEQ(name, "DB_INIT_TXN")) -#ifdef DB_INIT_TXN - return DB_INIT_TXN; -#else - goto not_there; -#endif - if (strEQ(name, "DB_JOIN_ITEM")) -#ifdef DB_JOIN_ITEM - return DB_JOIN_ITEM; -#else - goto not_there; -#endif - if (strEQ(name, "DB_JOINENV")) -#ifdef DB_JOINENV - return DB_JOINENV; -#else - goto not_there; -#endif - if (strEQ(name, "DB_KEYEMPTY")) -#ifdef DB_KEYEMPTY - return DB_KEYEMPTY; -#else - goto not_there; -#endif - if (strEQ(name, "DB_KEYEXIST")) -#ifdef DB_KEYEXIST - return DB_KEYEXIST; -#else - goto not_there; -#endif - if (strEQ(name, "DB_KEYFIRST")) -#ifdef DB_KEYFIRST - return DB_KEYFIRST; -#else - goto not_there; -#endif - if (strEQ(name, "DB_KEYLAST")) -#ifdef DB_KEYLAST - return DB_KEYLAST; -#else - goto not_there; -#endif - if (strEQ(name, "DB_LAST")) -#ifdef DB_LAST - return DB_LAST; -#else - goto not_there; -#endif - if (strEQ(name, "DB_LOCKMAGIC")) -#ifdef DB_LOCKMAGIC - return DB_LOCKMAGIC; -#else - goto not_there; -#endif - if (strEQ(name, "DB_LOCKVERSION")) -#ifdef DB_LOCKVERSION - return DB_LOCKVERSION; -#else - goto not_there; -#endif - if (strEQ(name, "DB_LOCK_CONFLICT")) -#ifdef DB_LOCK_CONFLICT - return DB_LOCK_CONFLICT; -#else - goto not_there; -#endif - if (strEQ(name, "DB_LOCK_DEADLOCK")) -#ifdef DB_LOCK_DEADLOCK - return DB_LOCK_DEADLOCK; -#else - goto not_there; -#endif - if (strEQ(name, "DB_LOCK_DEFAULT")) -#ifdef DB_LOCK_DEFAULT - return DB_LOCK_DEFAULT; -#else - goto not_there; -#endif - if (strEQ(name, "DB_LOCK_GET")) - return DB_LOCK_GET; - if (strEQ(name, "DB_LOCK_NORUN")) -#ifdef DB_LOCK_NORUN - return DB_LOCK_NORUN; -#else - goto not_there; -#endif - if (strEQ(name, "DB_LOCK_NOTGRANTED")) -#ifdef DB_LOCK_NOTGRANTED - return DB_LOCK_NOTGRANTED; -#else - goto not_there; -#endif - if (strEQ(name, "DB_LOCK_NOTHELD")) -#ifdef DB_LOCK_NOTHELD - return DB_LOCK_NOTHELD; -#else - goto not_there; -#endif - if (strEQ(name, "DB_LOCK_NOWAIT")) -#ifdef DB_LOCK_NOWAIT - return DB_LOCK_NOWAIT; -#else - goto not_there; -#endif - if (strEQ(name, "DB_LOCK_OLDEST")) -#ifdef DB_LOCK_OLDEST - return DB_LOCK_OLDEST; -#else - goto not_there; -#endif - if (strEQ(name, "DB_LOCK_RANDOM")) -#ifdef DB_LOCK_RANDOM - return DB_LOCK_RANDOM; -#else - goto not_there; -#endif - if (strEQ(name, "DB_LOCK_RIW_N")) -#ifdef DB_LOCK_RIW_N - return DB_LOCK_RIW_N; -#else - goto not_there; -#endif - if (strEQ(name, "DB_LOCK_RW_N")) -#ifdef DB_LOCK_RW_N - return DB_LOCK_RW_N; -#else - goto not_there; -#endif - if (strEQ(name, "DB_LOCK_YOUNGEST")) -#ifdef DB_LOCK_YOUNGEST - return DB_LOCK_YOUNGEST; -#else - goto not_there; -#endif - if (strEQ(name, "DB_LOGMAGIC")) -#ifdef DB_LOGMAGIC - return DB_LOGMAGIC; -#else - goto not_there; -#endif - if (strEQ(name, "DB_LOGOLDVER")) -#ifdef DB_LOGOLDVER - return DB_LOGOLDVER; -#else - goto not_there; -#endif - if (strEQ(name, "DB_MAX_PAGES")) -#ifdef DB_MAX_PAGES - return DB_MAX_PAGES; -#else - goto not_there; -#endif - if (strEQ(name, "DB_MAX_RECORDS")) -#ifdef DB_MAX_RECORDS - return DB_MAX_RECORDS; -#else - goto not_there; -#endif - if (strEQ(name, "DB_MPOOL_CLEAN")) -#ifdef DB_MPOOL_CLEAN - return DB_MPOOL_CLEAN; -#else - goto not_there; -#endif - if (strEQ(name, "DB_MPOOL_CREATE")) -#ifdef DB_MPOOL_CREATE - return DB_MPOOL_CREATE; -#else - goto not_there; -#endif - if (strEQ(name, "DB_MPOOL_DIRTY")) -#ifdef DB_MPOOL_DIRTY - return DB_MPOOL_DIRTY; -#else - goto not_there; -#endif - if (strEQ(name, "DB_MPOOL_DISCARD")) -#ifdef DB_MPOOL_DISCARD - return DB_MPOOL_DISCARD; -#else - goto not_there; -#endif - if (strEQ(name, "DB_MPOOL_LAST")) -#ifdef DB_MPOOL_LAST - return DB_MPOOL_LAST; -#else - goto not_there; -#endif - if (strEQ(name, "DB_MPOOL_NEW")) -#ifdef DB_MPOOL_NEW - return DB_MPOOL_NEW; -#else - goto not_there; -#endif - if (strEQ(name, "DB_MPOOL_PRIVATE")) -#ifdef DB_MPOOL_PRIVATE - return DB_MPOOL_PRIVATE; -#else - goto not_there; -#endif - if (strEQ(name, "DB_MUTEXDEBUG")) -#ifdef DB_MUTEXDEBUG - return DB_MUTEXDEBUG; -#else - goto not_there; -#endif - if (strEQ(name, "DB_MUTEXLOCKS")) -#ifdef DB_MUTEXLOCKS - return DB_MUTEXLOCKS; -#else - goto not_there; -#endif - if (strEQ(name, "DB_NEEDSPLIT")) -#ifdef DB_NEEDSPLIT - return DB_NEEDSPLIT; -#else - goto not_there; -#endif - if (strEQ(name, "DB_NEXT")) -#ifdef DB_NEXT - return DB_NEXT; -#else - goto not_there; -#endif - if (strEQ(name, "DB_NEXT_DUP")) -#ifdef DB_NEXT_DUP - return DB_NEXT_DUP; -#else - goto not_there; -#endif - if (strEQ(name, "DB_NOMMAP")) -#ifdef DB_NOMMAP - return DB_NOMMAP; -#else - goto not_there; -#endif - if (strEQ(name, "DB_NOOVERWRITE")) -#ifdef DB_NOOVERWRITE - return DB_NOOVERWRITE; -#else - goto not_there; -#endif - if (strEQ(name, "DB_NOSYNC")) -#ifdef DB_NOSYNC - return DB_NOSYNC; -#else - goto not_there; -#endif - if (strEQ(name, "DB_NOTFOUND")) -#ifdef DB_NOTFOUND - return DB_NOTFOUND; -#else - goto not_there; -#endif - if (strEQ(name, "DB_PAD")) -#ifdef DB_PAD - return DB_PAD; -#else - goto not_there; -#endif - if (strEQ(name, "DB_PAGEYIELD")) -#ifdef DB_PAGEYIELD - return DB_PAGEYIELD; -#else - goto not_there; -#endif - if (strEQ(name, "DB_POSITION")) -#ifdef DB_POSITION - return DB_POSITION; -#else - goto not_there; -#endif - if (strEQ(name, "DB_PREV")) -#ifdef DB_PREV - return DB_PREV; -#else - goto not_there; -#endif - if (strEQ(name, "DB_PRIVATE")) -#ifdef DB_PRIVATE - return DB_PRIVATE; -#else - goto not_there; -#endif - if (strEQ(name, "DB_QUEUE")) - return DB_QUEUE; - if (strEQ(name, "DB_RDONLY")) -#ifdef DB_RDONLY - return DB_RDONLY; -#else - goto not_there; -#endif - if (strEQ(name, "DB_RECNO")) - return DB_RECNO; - if (strEQ(name, "DB_RECNUM")) -#ifdef DB_RECNUM - return DB_RECNUM; -#else - goto not_there; -#endif - if (strEQ(name, "DB_RECORDCOUNT")) -#ifdef DB_RECORDCOUNT - return DB_RECORDCOUNT; -#else - goto not_there; -#endif - if (strEQ(name, "DB_RECOVER")) -#ifdef DB_RECOVER - return DB_RECOVER; -#else - goto not_there; -#endif - if (strEQ(name, "DB_RECOVER_FATAL")) -#ifdef DB_RECOVER_FATAL - return DB_RECOVER_FATAL; -#else - goto not_there; -#endif - if (strEQ(name, "DB_REGISTERED")) -#ifdef DB_REGISTERED - return DB_REGISTERED; -#else - goto not_there; -#endif - if (strEQ(name, "DB_RENUMBER")) -#ifdef DB_RENUMBER - return DB_RENUMBER; -#else - goto not_there; -#endif - if (strEQ(name, "DB_RMW")) -#ifdef DB_RMW - return DB_RMW; -#else - goto not_there; -#endif - if (strEQ(name, "DB_RUNRECOVERY")) -#ifdef DB_RUNRECOVERY - return DB_RUNRECOVERY; -#else - goto not_there; -#endif - if (strEQ(name, "DB_SEQUENTIAL")) -#ifdef DB_SEQUENTIAL - return DB_SEQUENTIAL; -#else - goto not_there; -#endif - if (strEQ(name, "DB_SET")) -#ifdef DB_SET - return DB_SET; -#else - goto not_there; -#endif - if (strEQ(name, "DB_SET_RANGE")) -#ifdef DB_SET_RANGE - return DB_SET_RANGE; -#else - goto not_there; -#endif - if (strEQ(name, "DB_SET_RECNO")) -#ifdef DB_SET_RECNO - return DB_SET_RECNO; -#else - goto not_there; -#endif - if (strEQ(name, "DB_SNAPSHOT")) -#ifdef DB_SNAPSHOT - return DB_SNAPSHOT; -#else - goto not_there; -#endif - if (strEQ(name, "DB_SWAPBYTES")) -#ifdef DB_SWAPBYTES - return DB_SWAPBYTES; -#else - goto not_there; -#endif - if (strEQ(name, "DB_TEMPORARY")) -#ifdef DB_TEMPORARY - return DB_TEMPORARY; -#else - goto not_there; -#endif - if (strEQ(name, "DB_THREAD")) -#ifdef DB_THREAD - return DB_THREAD; -#else - goto not_there; -#endif - if (strEQ(name, "DB_TRUNCATE")) -#ifdef DB_TRUNCATE - return DB_TRUNCATE; -#else - goto not_there; -#endif - if (strEQ(name, "DB_TXNMAGIC")) -#ifdef DB_TXNMAGIC - return DB_TXNMAGIC; -#else - goto not_there; -#endif - if (strEQ(name, "DB_TXNVERSION")) -#ifdef DB_TXNVERSION - return DB_TXNVERSION; -#else - goto not_there; -#endif - if (strEQ(name, "DB_TXN_BACKWARD_ROLL")) - return DB_TXN_BACKWARD_ROLL; - if (strEQ(name, "DB_TXN_CKP")) -#ifdef DB_TXN_CKP - return DB_TXN_CKP; -#else - goto not_there; -#endif - if (strEQ(name, "DB_TXN_FORWARD_ROLL")) - return DB_TXN_FORWARD_ROLL; - if (strEQ(name, "DB_TXN_LOCK_2PL")) -#ifdef DB_TXN_LOCK_2PL - return DB_TXN_LOCK_2PL; -#else - goto not_there; -#endif - if (strEQ(name, "DB_TXN_LOCK_MASK")) -#ifdef DB_TXN_LOCK_MASK - return DB_TXN_LOCK_MASK; -#else - goto not_there; -#endif - if (strEQ(name, "DB_TXN_LOCK_OPTIMIST")) -#ifdef DB_TXN_LOCK_OPTIMIST - return DB_TXN_LOCK_OPTIMIST; -#else - goto not_there; -#endif - if (strEQ(name, "DB_TXN_LOCK_OPTIMISTIC")) -#ifdef DB_TXN_LOCK_OPTIMISTIC - return DB_TXN_LOCK_OPTIMISTIC; -#else - goto not_there; -#endif - if (strEQ(name, "DB_TXN_LOG_MASK")) -#ifdef DB_TXN_LOG_MASK - return DB_TXN_LOG_MASK; -#else - goto not_there; -#endif - if (strEQ(name, "DB_TXN_LOG_REDO")) -#ifdef DB_TXN_LOG_REDO - return DB_TXN_LOG_REDO; -#else - goto not_there; -#endif - if (strEQ(name, "DB_TXN_LOG_UNDO")) -#ifdef DB_TXN_LOG_UNDO - return DB_TXN_LOG_UNDO; -#else - goto not_there; -#endif - if (strEQ(name, "DB_TXN_LOG_UNDOREDO")) -#ifdef DB_TXN_LOG_UNDOREDO - return DB_TXN_LOG_UNDOREDO; -#else - goto not_there; -#endif - if (strEQ(name, "DB_TXN_NOSYNC")) -#ifdef DB_TXN_NOSYNC - return DB_TXN_NOSYNC; -#else - goto not_there; -#endif - if (strEQ(name, "DB_TXN_NOWAIT")) -#ifdef DB_TXN_NOWAIT - return DB_TXN_NOWAIT; -#else - goto not_there; -#endif - if (strEQ(name, "DB_TXN_OPENFILES")) - return DB_TXN_OPENFILES; - if (strEQ(name, "DB_TXN_REDO")) -#ifdef DB_TXN_REDO - return DB_TXN_REDO; -#else - goto not_there; -#endif - if (strEQ(name, "DB_TXN_SYNC")) -#ifdef DB_TXN_SYNC - return DB_TXN_SYNC; -#else - goto not_there; -#endif - if (strEQ(name, "DB_TXN_UNDO")) -#ifdef DB_TXN_UNDO - return DB_TXN_UNDO; -#else - goto not_there; -#endif - if (strEQ(name, "DB_UNKNOWN")) - return DB_UNKNOWN; - if (strEQ(name, "DB_USE_ENVIRON")) -#ifdef DB_USE_ENVIRON - return DB_USE_ENVIRON; -#else - goto not_there; -#endif - if (strEQ(name, "DB_USE_ENVIRON_ROOT")) -#ifdef DB_USE_ENVIRON_ROOT - return DB_USE_ENVIRON_ROOT; -#else - goto not_there; -#endif - if (strEQ(name, "DB_VERSION_MAJOR")) -#ifdef DB_VERSION_MAJOR - return DB_VERSION_MAJOR; -#else - goto not_there; -#endif - if (strEQ(name, "DB_VERSION_MINOR")) -#ifdef DB_VERSION_MINOR - return DB_VERSION_MINOR; -#else - goto not_there; -#endif - if (strEQ(name, "DB_VERSION_PATCH")) -#ifdef DB_VERSION_PATCH - return DB_VERSION_PATCH; -#else - goto not_there; -#endif - if (strEQ(name, "DB_WRITECURSOR")) -#ifdef DB_WRITECURSOR - return DB_WRITECURSOR; -#else - goto not_there; -#endif - break; - case 'E': - break; - case 'F': - break; - case 'G': - break; - case 'H': - break; - case 'I': - break; - case 'J': - break; - case 'K': - break; - case 'L': - break; - case 'M': - break; - case 'N': - break; - case 'O': - break; - case 'P': - break; - case 'Q': - break; - case 'R': - break; - case 'S': - break; - case 'T': - break; - case 'U': - break; - case 'V': - break; - case 'W': - break; - case 'X': - break; - case 'Y': - break; - case 'Z': - break; - case 'a': - break; - case 'b': - break; - case 'c': - break; - case 'd': - break; - case 'e': - break; - case 'f': - break; - case 'g': - break; - case 'h': - break; - case 'i': - break; - case 'j': - break; - case 'k': - break; - case 'l': - break; - case 'm': - break; - case 'n': - break; - case 'o': - break; - case 'p': - break; - case 'q': - break; - case 'r': - break; - case 's': - break; - case 't': - break; - case 'u': - break; - case 'v': - break; - case 'w': - break; - case 'x': - break; - case 'y': - break; - case 'z': - break; - } - errno = EINVAL; - return 0; - -not_there: - errno = ENOENT; - return 0; -} +#include "constants.h" MODULE = BerkeleyDB PACKAGE = BerkeleyDB PREFIX = env_ -char * -DB_VERSION_STRING() - CODE: - RETVAL = DB_VERSION_STRING ; - OUTPUT: - RETVAL - - -double -constant(name,arg) - char * name - int arg +INCLUDE: constants.xs #define env_db_version(maj, min, patch) db_version(&maj, &min, &patch) char * @@ -2368,7 +1464,16 @@ _db_appinit(self, ref) Trace(("set_lk_detect [%d] returned %s\n", lk_detect, my_db_strerror(status))); } -#ifdef AT_LEAST_DB_3_1 +#ifdef AT_LEAST_DB_4 + /* set the server */ + if (server && status == 0) + { + status = env->set_rpc_server(env, NULL, server, 0, 0, 0); + Trace(("ENV->set_rpc_server server = %s returned %s\n", server, + my_db_strerror(status))) ; + } +#else +# if defined(AT_LEAST_DB_3_1) && ! defined(AT_LEAST_DB_4) /* set the server */ if (server && status == 0) { @@ -2376,6 +1481,7 @@ _db_appinit(self, ref) Trace(("ENV->set_server server = %s returned %s\n", server, my_db_strerror(status))) ; } +# endif #endif if (status == 0) { @@ -2422,6 +1528,38 @@ _db_appinit(self, ref) OUTPUT: RETVAL +void +log_archive(env, flags=0) + u_int32_t flags + BerkeleyDB::Env env + PPCODE: + { + char ** list; + char ** file; + AV * av; +#ifndef AT_LEAST_DB_3 + softCrash("log_archive needs at least Berkeley DB 3.x.x"); +#else +# ifdef AT_LEAST_DB_4 + env->Status = env->Env->log_archive(env->Env, &list, flags) ; +# else +# ifdef AT_LEAST_DB_3_3 + env->Status = log_archive(env->Env, &list, flags) ; +# else + env->Status = log_archive(env->Env, &list, flags, safemalloc) ; +# endif +# endif + if (env->Status == 0 && list != NULL) + { + for (file = list; *file != NULL; ++file) + { + XPUSHs(sv_2mortal(newSVpv(*file, 0))) ; + } + safefree(list); + } +#endif + } + BerkeleyDB::Txn::Raw _txn_begin(env, pid=NULL, flags=0) u_int32_t flags @@ -2444,7 +1582,11 @@ _txn_begin(env, pid=NULL, flags=0) #if DB_VERSION_MAJOR == 2 txn_begin(env->Env->tx_info, p_id, &txn) ; #else +# ifdef AT_LEAST_DB_4 + env->Env->txn_begin(env->Env, p_id, &txn, flags) ; +# else txn_begin(env->Env, p_id, &txn, flags) ; +# endif #endif if (env->TxnMgrStatus == 0) { ZMALLOC(RETVAL, BerkeleyDB_Txn_type) ; @@ -2461,19 +1603,24 @@ _txn_begin(env, pid=NULL, flags=0) #if DB_VERSION_MAJOR == 2 -# define env_txn_checkpoint(e,k,m) txn_checkpoint(e->Env->tx_info, k, m) +# define env_txn_checkpoint(e,k,m,f) txn_checkpoint(e->Env->tx_info, k, m) #else /* DB 3.0 or better */ -# ifdef AT_LEAST_DB_3_1 -# define env_txn_checkpoint(e,k,m) txn_checkpoint(e->Env, k, m, 0) +# ifdef AT_LEAST_DB_4 +# define env_txn_checkpoint(e,k,m,f) e->Env->txn_checkpoint(e->Env, k, m, f) # else -# define env_txn_checkpoint(e,k,m) txn_checkpoint(e->Env, k, m) +# ifdef AT_LEAST_DB_3_1 +# define env_txn_checkpoint(e,k,m,f) txn_checkpoint(e->Env, k, m, 0) +# else +# define env_txn_checkpoint(e,k,m,f) txn_checkpoint(e->Env, k, m) +# endif # endif #endif DualType -env_txn_checkpoint(env, kbyte, min) +env_txn_checkpoint(env, kbyte, min, flags=0) BerkeleyDB::Env env long kbyte long min + u_int32_t flags HV * txn_stat(env) @@ -2482,14 +1629,18 @@ txn_stat(env) CODE: { DB_TXN_STAT * stat ; -#ifdef AT_LEAST_DB_3_3 - if(txn_stat(env->Env, &stat) == 0) { +#ifdef AT_LEAST_DB_4 + if(env->Env->txn_stat(env->Env, &stat, 0) == 0) { #else -#if DB_VERSION_MAJOR == 2 +# ifdef AT_LEAST_DB_3_3 + if(txn_stat(env->Env, &stat) == 0) { +# else +# if DB_VERSION_MAJOR == 2 if(txn_stat(env->Env->tx_info, &stat, safemalloc) == 0) { -#else +# else if(txn_stat(env->Env, &stat, safemalloc) == 0) { -#endif +# endif +# endif #endif RETVAL = (HV*)sv_2mortal((SV*)newHV()) ; hv_store_iv(RETVAL, "st_time_ckp", stat->st_time_ckp) ; @@ -2718,11 +1869,15 @@ set_mutexlocks(env, do_lock) #ifndef AT_LEAST_DB_3 softCrash("$env->set_setmutexlocks needs Berkeley DB 3.0 or better") ; #else -#if defined(AT_LEAST_DB_3_2_6) || defined(IS_DB_3_0_x) +# ifdef AT_LEAST_DB_4 + RETVAL = env->Status = env->Env->set_flags(env->Env, DB_NOLOCKING, 1); +# else +# if defined(AT_LEAST_DB_3_2_6) || defined(IS_DB_3_0_x) RETVAL = env->Status = env->Env->set_mutexlocks(env->Env, do_lock); -#else /* DB 3.1 or 3.2.3 */ +# else /* DB 3.1 or 3.2.3 */ RETVAL = env->Status = db_env_set_mutexlocks(do_lock); -#endif +# endif +# endif #endif OUTPUT: RETVAL @@ -3776,7 +2931,11 @@ _txn_begin(txnmgr, pid=NULL, flags=0) #if DB_VERSION_MAJOR == 2 txn_begin(txnmgr->env->Env->tx_info, p_id, &txn) ; #else +# ifdef AT_LEAST_DB_4 + txnmgr->env->Env->txn_begin(txnmgr->env->Env, p_id, &txn, flags) ; +# else txn_begin(txnmgr->env->Env, p_id, &txn, flags) ; +# endif #endif if (txnmgr->env->TxnMgrStatus == 0) { ZMALLOC(RETVAL, BerkeleyDB_Txn_type) ; @@ -3816,19 +2975,24 @@ txn_close(txnp) #if DB_VERSION_MAJOR == 2 -# define xx_txn_checkpoint(t,k,m) txn_checkpoint(t->env->Env->tx_info, k, m) +# define xx_txn_checkpoint(t,k,m,f) txn_checkpoint(t->env->Env->tx_info, k, m) #else -# ifdef AT_LEAST_DB_3_1 -# define xx_txn_checkpoint(t,k,m) txn_checkpoint(t->env->Env, k, m, 0) +# ifdef AT_LEAST_DB_4 +# define xx_txn_checkpoint(e,k,m,f) e->env->Env->txn_checkpoint(e->env->Env, k, m, f) # else -# define xx_txn_checkpoint(t,k,m) txn_checkpoint(t->env->Env, k, m) +# ifdef AT_LEAST_DB_3_1 +# define xx_txn_checkpoint(t,k,m,f) txn_checkpoint(t->env->Env, k, m, 0) +# else +# define xx_txn_checkpoint(t,k,m,f) txn_checkpoint(t->env->Env, k, m) +# endif # endif #endif DualType -xx_txn_checkpoint(txnp, kbyte, min) +xx_txn_checkpoint(txnp, kbyte, min, flags=0) BerkeleyDB::TxnMgr txnp long kbyte long min + u_int32_t flags HV * txn_stat(txnp) @@ -3837,14 +3001,18 @@ txn_stat(txnp) CODE: { DB_TXN_STAT * stat ; -#ifdef AT_LEAST_DB_3_3 - if(txn_stat(txnp->env->Env, &stat) == 0) { +#ifdef AT_LEAST_DB_4 + if(txnp->env->Env->txn_stat(txnp->env->Env, &stat, 0) == 0) { #else -#if DB_VERSION_MAJOR == 2 +# ifdef AT_LEAST_DB_3_3 + if(txn_stat(txnp->env->Env, &stat) == 0) { +# else +# if DB_VERSION_MAJOR == 2 if(txn_stat(txnp->env->Env->tx_info, &stat, safemalloc) == 0) { -#else +# else if(txn_stat(txnp->env->Env, &stat, safemalloc) == 0) { -#endif +# endif +# endif #endif RETVAL = (HV*)sv_2mortal((SV*)newHV()) ; hv_store_iv(RETVAL, "st_time_ckp", stat->st_time_ckp) ; @@ -3892,7 +3060,11 @@ _DESTROY(tid) CODE: Trace(("In BerkeleyDB::Txn::_DESTROY txn [%d] active [%d] dirty=%d\n", tid->txn, tid->active, PL_dirty)) ; if (tid->active) +#ifdef AT_LEAST_DB_4 + tid->txn->abort(tid->txn) ; +#else txn_abort(tid->txn) ; +#endif RETVAL = (int)tid ; hash_delete("BerkeleyDB::Term::Txn", (char *)tid) ; Safefree(tid) ; @@ -3908,10 +3080,14 @@ xx_txn_unlink(dir, force, dbenv) BerkeleyDB::Env dbenv NOT_IMPLEMENTED_YET -#ifdef AT_LEAST_DB_3_3 -#define xx_txn_prepare(t) (t->Status = txn_prepare(t->txn, 0)) +#ifdef AT_LEAST_DB_4 +# define xx_txn_prepare(t) (t->Status = t->txn->prepare(t->txn, 0)) #else -#define xx_txn_prepare(t) (t->Status = txn_prepare(t->txn)) +# ifdef AT_LEAST_DB_3_3 +# define xx_txn_prepare(t) (t->Status = txn_prepare(t->txn, 0)) +# else +# define xx_txn_prepare(t) (t->Status = txn_prepare(t->txn)) +# endif #endif DualType xx_txn_prepare(tid) @@ -3919,10 +3095,14 @@ xx_txn_prepare(tid) INIT: ckActive_Transaction(tid->active) ; -#if DB_VERSION_MAJOR == 2 -# define _txn_commit(t,flags) (t->Status = txn_commit(t->txn)) +#ifdef AT_LEAST_DB_4 +# define _txn_commit(t,flags) (t->Status = t->txn->commit(t->txn, flags)) #else -# define _txn_commit(t, flags) (t->Status = txn_commit(t->txn, flags)) +# if DB_VERSION_MAJOR == 2 +# define _txn_commit(t,flags) (t->Status = txn_commit(t->txn)) +# else +# define _txn_commit(t, flags) (t->Status = txn_commit(t->txn, flags)) +# endif #endif DualType _txn_commit(tid, flags=0) @@ -3933,7 +3113,11 @@ _txn_commit(tid, flags=0) hash_delete("BerkeleyDB::Term::Txn", (char *)tid) ; tid->active = FALSE ; -#define _txn_abort(t) (t->Status = txn_abort(t->txn)) +#ifdef AT_LEAST_DB_4 +# define _txn_abort(t) (t->Status = t->txn->abort(t->txn)) +#else +# define _txn_abort(t) (t->Status = txn_abort(t->txn)) +#endif DualType _txn_abort(tid) BerkeleyDB::Txn tid @@ -3942,7 +3126,29 @@ _txn_abort(tid) hash_delete("BerkeleyDB::Term::Txn", (char *)tid) ; tid->active = FALSE ; -#define xx_txn_id(t) txn_id(t->txn) +#ifdef AT_LEAST_DB_4 +# define _txn_discard(t,f) (t->Status = t->txn->discard(t->txn, f)) +#else +# ifdef AT_LEAST_DB_3_3_4 +# define _txn_discard(t,f) (t->Status = txn_discard(t->txn, f)) +# else +# define _txn_discard(t,f) (int)softCrash("txn_discard needs Berkeley DB 3.3.4 or better") ; +# endif +#endif +DualType +_txn_discard(tid, flags=0) + BerkeleyDB::Txn tid + u_int32_t flags + INIT: + ckActive_Transaction(tid->active) ; + hash_delete("BerkeleyDB::Term::Txn", (char *)tid) ; + tid->active = FALSE ; + +#ifdef AT_LEAST_DB_4 +# define xx_txn_id(t) t->txn->id(t->txn) +#else +# define xx_txn_id(t) txn_id(t->txn) +#endif u_int32_t xx_txn_id(tid) BerkeleyDB::Txn tid @@ -3992,12 +3198,13 @@ FIRSTKEY(db) int NEXTKEY(db, key) BerkeleyDB::Common db - DBTKEY key + DBTKEY key = NO_INIT CODE: { DBT value ; CurrentDB = db ; + DBT_clear(key) ; DBT_clear(value) ; key.flags = 0 ; RETVAL = (db->Status) = diff --git a/db/perl/BerkeleyDB/Changes b/db/perl/BerkeleyDB/Changes index f647bea85..732dbac66 100644 --- a/db/perl/BerkeleyDB/Changes +++ b/db/perl/BerkeleyDB/Changes @@ -1,5 +1,11 @@ Revision history for Perl extension BerkeleyDB. +0.17 26 23 September 2001 + * Fixed a bug in BerkeleyDB::Recno - reported by Niklas Paulsson. + * Added log_archive - patch supplied by Benjamin Holzman + * Added txn_discard + * Builds with Berkeley DB 4.0.x + 0.16 26 1 August 2001 * added support for Berkeley DB 3.3.x (but no support for any of the new features just yet) diff --git a/db/perl/BerkeleyDB/MANIFEST b/db/perl/BerkeleyDB/MANIFEST index ed8450f6f..6e9857be4 100644 --- a/db/perl/BerkeleyDB/MANIFEST +++ b/db/perl/BerkeleyDB/MANIFEST @@ -6,6 +6,8 @@ BerkeleyDB/Btree.pm BerkeleyDB/Hash.pm Changes config.in +constants.h +constants.xs dbinfo hints/solaris.pl hints/irix_6_5.pl diff --git a/db/perl/BerkeleyDB/Makefile.PL b/db/perl/BerkeleyDB/Makefile.PL index c99283b20..dbf0f2c41 100644 --- a/db/perl/BerkeleyDB/Makefile.PL +++ b/db/perl/BerkeleyDB/Makefile.PL @@ -63,8 +63,14 @@ sub MY::postamble { $(NAME).pod: $(NAME).pod.P t/examples.t.T t/examples3.t.T mkpod perl ./mkpod -$(NAME).xs: typemap - @$(TOUCH) $(NAME).xs +$(NAME).xs: constants.h constants.xs typemap + $(TOUCH) $(NAME).xs + +constants.h constants.xs: mkconsts + bleedperl mkconsts xs + +$(NAME).pm: mkconsts + bleedperl mkconsts pm $(NAME).pm > $(NAME).pm.tmp && mv $(NAME).pm.tmp $(NAME).pm Makefile: config.in diff --git a/db/perl/BerkeleyDB/README b/db/perl/BerkeleyDB/README index 5784a1954..8640949f3 100644 --- a/db/perl/BerkeleyDB/README +++ b/db/perl/BerkeleyDB/README @@ -1,8 +1,8 @@ BerkeleyDB - Version 0.16 + Version 0.17 - 1st August 2001 + 22nd October 2001 Copyright (c) 1997-2001 Paul Marquess. All rights reserved. This program is free software; you can redistribute it and/or modify @@ -13,8 +13,9 @@ DESCRIPTION ----------- BerkeleyDB is a module which allows Perl programs to make use of the -facilities provided by Berkeley DB version 2 or 3. (Note: if you want -to use version 1 of Berkeley DB with Perl you need the DB_File module). +facilities provided by Berkeley DB version 2 or greater. (Note: if +you want to use version 1 of Berkeley DB with Perl you need the DB_File +module). Berkeley DB is a C library which provides a consistent interface to a number of database formats. BerkeleyDB provides an interface to all diff --git a/db/perl/BerkeleyDB/config.in b/db/perl/BerkeleyDB/config.in index 1718297d8..ab3c026c1 100644 --- a/db/perl/BerkeleyDB/config.in +++ b/db/perl/BerkeleyDB/config.in @@ -7,24 +7,26 @@ # Change the path below to point to the directory where db.h is # installed on your system. -#INCLUDE = /usr/local/include -INCLUDE = /usr/local/BerkeleyDB/include -#INCLUDE = ./libraries/2.7.5 -#INCLUDE = ./libraries/3.0.55 -#INCLUDE = ./libraries/3.1.17 -#INCLUDE = ./libraries/3.3.11 +INCLUDE = /usr/local/include +#INCLUDE = /usr/local/BerkeleyDB/include +#INCLUDE = ./libraries/2.7.5/include +#INCLUDE = ./libraries/3.0.55/include +#INCLUDE = ./libraries/3.1.17/include +#INCLUDE = ./libraries/3.3.11/include +#INCLUDE = ./libraries/4.0.7/include # 2. Where is libdb? # # Change the path below to point to the directory where libdb is # installed on your system. -#LIB = /usr/local/lib -LIB = /usr/local/BerkeleyDB/lib -#LIB = ./libraries/2.7.5 -#LIB = ./libraries/3.0.55 -#LIB = ./libraries/3.1.17 -#LIB = ./libraries/3.3.11 +LIB = /usr/local/lib +#LIB = /usr/local/BerkeleyDB/lib +#LIB = ./libraries/2.7.5/lib +#LIB = ./libraries/3.0.55/lib +#LIB = ./libraries/3.1.17/lib +#LIB = ./libraries/3.3.11/lib +#LIB = ./libraries/4.0.7/lib # 3. Is the library called libdb? # diff --git a/db/perl/BerkeleyDB/mkconsts b/db/perl/BerkeleyDB/mkconsts index 24ef4fca7..dc90ea970 100644 --- a/db/perl/BerkeleyDB/mkconsts +++ b/db/perl/BerkeleyDB/mkconsts @@ -1,211 +1,678 @@ #!/usr/bin/perl +use ExtUtils::Constant qw(WriteConstants); + +use constant DEFINE => 'define' ; +use constant STRING => 'string' ; +use constant IGNORE => 'ignore' ; + %constants = ( - # Symbol 0 = define, 1 = enum - DB_AFTER => 0, - DB_APPEND => 0, - DB_ARCH_ABS => 0, - DB_ARCH_DATA => 0, - DB_ARCH_LOG => 0, - DB_BEFORE => 0, - DB_BTREE => 1, - DB_BTREEMAGIC => 0, - DB_BTREEOLDVER => 0, - DB_BTREEVERSION => 0, - DB_CHECKPOINT => 0, - DB_CONSUME => 0, - DB_CREATE => 0, - DB_CURLSN => 0, - DB_CURRENT => 0, - DB_DBT_MALLOC => 0, - DB_DBT_PARTIAL => 0, - DB_DBT_USERMEM => 0, - DB_DELETED => 0, - DB_DELIMITER => 0, - DB_DUP => 0, - DB_DUPSORT => 0, - DB_ENV_APPINIT => 0, - DB_ENV_STANDALONE => 0, - DB_ENV_THREAD => 0, - DB_EXCL => 0, - DB_FILE_ID_LEN => 0, - DB_FIRST => 0, - DB_FIXEDLEN => 0, - DB_FLUSH => 0, - DB_FORCE => 0, - DB_GET_BOTH => 0, - DB_GET_RECNO => 0, - DB_HASH => 1, - DB_HASHMAGIC => 0, - DB_HASHOLDVER => 0, - DB_HASHVERSION => 0, - DB_INCOMPLETE => 0, - DB_INIT_CDB => 0, - DB_INIT_LOCK => 0, - DB_INIT_LOG => 0, - DB_INIT_MPOOL => 0, - DB_INIT_TXN => 0, - DB_JOIN_ITEM => 0, - DB_KEYEMPTY => 0, - DB_KEYEXIST => 0, - DB_KEYFIRST => 0, - DB_KEYLAST => 0, - DB_LAST => 0, - DB_LOCK_CONFLICT => 0, - DB_LOCK_DEADLOCK => 0, - DB_LOCK_DEFAULT => 0, - DB_LOCK_GET => 1, - DB_LOCK_NORUN => 0, - DB_LOCK_NOTGRANTED => 0, - DB_LOCK_NOTHELD => 0, - DB_LOCK_NOWAIT => 0, - DB_LOCK_OLDEST => 0, - DB_LOCK_RANDOM => 0, - DB_LOCK_RIW_N => 0, - DB_LOCK_RW_N => 0, - DB_LOCK_YOUNGEST => 0, - DB_LOCKMAGIC => 0, - DB_LOCKVERSION => 0, - DB_LOGMAGIC => 0, - DB_LOGOLDVER => 0, - DB_MAX_PAGES => 0, - DB_MAX_RECORDS => 0, - DB_MPOOL_CLEAN => 0, - DB_MPOOL_CREATE => 0, - DB_MPOOL_DIRTY => 0, - DB_MPOOL_DISCARD => 0, - DB_MPOOL_LAST => 0, - DB_MPOOL_NEW => 0, - DB_MPOOL_PRIVATE => 0, - DB_MUTEXDEBUG => 0, - DB_MUTEXLOCKS => 0, - DB_NEEDSPLIT => 0, - DB_NEXT => 0, - DB_NEXT_DUP => 0, - DB_NOMMAP => 0, - DB_NOOVERWRITE => 0, - DB_NOSYNC => 0, - DB_NOTFOUND => 0, - DB_PAD => 0, - DB_PAGEYIELD => 0, - DB_POSITION => 0, - DB_PREV => 0, - DB_PRIVATE => 0, - DB_QUEUE => 1, - DB_RDONLY => 0, - DB_RECNO => 1, - DB_RECNUM => 0, - DB_RECORDCOUNT => 0, - DB_RECOVER => 0, - DB_RECOVER_FATAL => 0, - DB_REGISTERED => 0, - DB_RENUMBER => 0, - DB_RMW => 0, - DB_RUNRECOVERY => 0, - DB_SEQUENTIAL => 0, - DB_SET => 0, - DB_SET_RANGE => 0, - DB_SET_RECNO => 0, - DB_SNAPSHOT => 0, - DB_SWAPBYTES => 0, - DB_TEMPORARY => 0, - DB_THREAD => 0, - DB_TRUNCATE => 0, - DB_TXN_ABORT => 1, - DB_TXN_BACKWARD_ROLL => 1, - DB_TXN_CKP => 0, - DB_TXN_FORWARD_ROLL => 1, - DB_TXN_LOCK_2PL => 0, - DB_TXN_LOCK_MASK => 0, - DB_TXN_LOCK_OPTIMISTIC => 0, - DB_TXN_LOG_MASK => 0, - DB_TXN_LOG_REDO => 0, - DB_TXN_LOG_UNDO => 0, - DB_TXN_LOG_UNDOREDO => 0, - DB_TXN_NOSYNC => 0, - DB_TXN_NOWAIT => 0, - DB_TXN_SYNC => 0, - DB_TXN_OPENFILES => 1, - DB_TXN_REDO => 0, - DB_TXN_UNDO => 0, - DB_TXNMAGIC => 0, - DB_TXNVERSION => 0, - DB_TXN_LOCK_OPTIMIST => 0, - DB_UNKNOWN => 1, - DB_USE_ENVIRON => 0, - DB_USE_ENVIRON_ROOT => 0, - DB_VERSION_MAJOR => 0, - DB_VERSION_MINOR => 0, - DB_VERSION_PATCH => 0, - DB_WRITECURSOR => 0, + + ######### + # 2.0.0 + ######### + + DBM_INSERT => IGNORE, + DBM_REPLACE => IGNORE, + DBM_SUFFIX => IGNORE, + DB_AFTER => DEFINE, + DB_AM_DUP => IGNORE, + DB_AM_INMEM => IGNORE, + DB_AM_LOCKING => IGNORE, + DB_AM_LOGGING => IGNORE, + DB_AM_MLOCAL => IGNORE, + DB_AM_PGDEF => IGNORE, + DB_AM_RDONLY => IGNORE, + DB_AM_RECOVER => IGNORE, + DB_AM_SWAP => IGNORE, + DB_AM_TXN => IGNORE, + DB_APP_INIT => DEFINE, + DB_BEFORE => DEFINE, + DB_BTREEMAGIC => DEFINE, + DB_BTREEVERSION => DEFINE, + DB_BT_DELIMITER => IGNORE, + DB_BT_EOF => IGNORE, + DB_BT_FIXEDLEN => IGNORE, + DB_BT_PAD => IGNORE, + DB_BT_SNAPSHOT => IGNORE, + DB_CHECKPOINT => DEFINE, + DB_CREATE => DEFINE, + DB_CURRENT => DEFINE, + DB_DBT_INTERNAL => IGNORE, + DB_DBT_MALLOC => IGNORE, + DB_DBT_PARTIAL => IGNORE, + DB_DBT_USERMEM => IGNORE, + DB_DELETED => DEFINE, + DB_DELIMITER => DEFINE, + DB_DUP => DEFINE, + DB_EXCL => DEFINE, + DB_FIRST => DEFINE, + DB_FIXEDLEN => DEFINE, + DB_FLUSH => DEFINE, + DB_HASHMAGIC => DEFINE, + DB_HASHVERSION => DEFINE, + DB_HS_DIRTYMETA => IGNORE, + DB_INCOMPLETE => DEFINE, + DB_INIT_LOCK => DEFINE, + DB_INIT_LOG => DEFINE, + DB_INIT_MPOOL => DEFINE, + DB_INIT_TXN => DEFINE, + DB_KEYEXIST => DEFINE, + DB_KEYFIRST => DEFINE, + DB_KEYLAST => DEFINE, + DB_LAST => DEFINE, + DB_LOCKMAGIC => DEFINE, + DB_LOCKVERSION => DEFINE, + DB_LOCK_DEADLOCK => DEFINE, + DB_LOCK_NOTGRANTED => DEFINE, + DB_LOCK_NOTHELD => DEFINE, + DB_LOCK_NOWAIT => DEFINE, + DB_LOCK_RIW_N => DEFINE, + DB_LOCK_RW_N => DEFINE, + DB_LOGMAGIC => DEFINE, + DB_LOGVERSION => DEFINE, + DB_MAX_PAGES => DEFINE, + DB_MAX_RECORDS => DEFINE, + DB_MPOOL_CLEAN => DEFINE, + DB_MPOOL_CREATE => DEFINE, + DB_MPOOL_DIRTY => DEFINE, + DB_MPOOL_DISCARD => DEFINE, + DB_MPOOL_LAST => DEFINE, + DB_MPOOL_NEW => DEFINE, + DB_MPOOL_PRIVATE => DEFINE, + DB_MUTEXDEBUG => DEFINE, + DB_NEEDSPLIT => DEFINE, + DB_NEXT => DEFINE, + DB_NOOVERWRITE => DEFINE, + DB_NORECURSE => DEFINE, + DB_NOSYNC => DEFINE, + DB_NOTFOUND => DEFINE, + DB_PAD => DEFINE, + DB_PREV => DEFINE, + DB_RDONLY => DEFINE, + DB_REGISTERED => DEFINE, + DB_RE_MODIFIED => IGNORE, + DB_SET => DEFINE, + DB_SET_RANGE => DEFINE, + DB_SNAPSHOT => DEFINE, + DB_SWAPBYTES => DEFINE, + DB_TRUNCATE => DEFINE, + DB_TXNMAGIC => DEFINE, + DB_TXNVERSION => DEFINE, + DB_TXN_BACKWARD_ROLL => DEFINE, + DB_TXN_FORWARD_ROLL => DEFINE, + DB_TXN_LOCK_2PL => DEFINE, + DB_TXN_LOCK_MASK => DEFINE, + DB_TXN_LOCK_OPTIMISTIC => DEFINE, + DB_TXN_LOG_MASK => DEFINE, + DB_TXN_LOG_REDO => DEFINE, + DB_TXN_LOG_UNDO => DEFINE, + DB_TXN_LOG_UNDOREDO => DEFINE, + DB_TXN_OPENFILES => DEFINE, + DB_TXN_REDO => DEFINE, + DB_TXN_UNDO => DEFINE, + DB_USE_ENVIRON => DEFINE, + DB_USE_ENVIRON_ROOT => DEFINE, + DB_VERSION_MAJOR => DEFINE, + DB_VERSION_MINOR => DEFINE, + DB_VERSION_PATCH => DEFINE, + DB_VERSION_STRING => STRING, + _DB_H_ => IGNORE, + __BIT_TYPES_DEFINED__ => IGNORE, + const => IGNORE, + + # enum DBTYPE + DB_BTREE => '2.0.0', + DB_HASH => '2.0.0', + DB_RECNO => '2.0.0', + DB_UNKNOWN => '2.0.0', + + # enum db_lockop_t + DB_LOCK_DUMP => '2.0.0', + DB_LOCK_GET => '2.0.0', + DB_LOCK_PUT => '2.0.0', + DB_LOCK_PUT_ALL => '2.0.0', + DB_LOCK_PUT_OBJ => '2.0.0', + + # enum db_lockmode_t + DB_LOCK_NG => IGNORE, # 2.0.0 + DB_LOCK_READ => IGNORE, # 2.0.0 + DB_LOCK_WRITE => IGNORE, # 2.0.0 + DB_LOCK_IREAD => IGNORE, # 2.0.0 + DB_LOCK_IWRITE => IGNORE, # 2.0.0 + DB_LOCK_IWR => IGNORE, # 2.0.0 + + # enum ACTION + FIND => IGNORE, # 2.0.0 + ENTER => IGNORE, # 2.0.0 + + ######### + # 2.0.3 + ######### + + DB_SEQUENTIAL => DEFINE, + DB_TEMPORARY => DEFINE, + + ######### + # 2.1.0 + ######### + + DB_NOMMAP => DEFINE, + + ######### + # 2.2.6 + ######### + + DB_AM_THREAD => IGNORE, + DB_ARCH_ABS => DEFINE, + DB_ARCH_DATA => DEFINE, + DB_ARCH_LOG => DEFINE, + DB_LOCK_CONFLICT => DEFINE, + DB_LOCK_DEFAULT => DEFINE, + DB_LOCK_NORUN => DEFINE, + DB_LOCK_OLDEST => DEFINE, + DB_LOCK_RANDOM => DEFINE, + DB_LOCK_YOUNGEST => DEFINE, + DB_RECOVER => DEFINE, + DB_RECOVER_FATAL => DEFINE, + DB_THREAD => DEFINE, + DB_TXN_NOSYNC => DEFINE, + + ######### + # 2.3.0 + ######### + + DB_BTREEOLDVER => DEFINE, + DB_BT_RECNUM => IGNORE, + DB_FILE_ID_LEN => DEFINE, + DB_GETREC => DEFINE, + DB_HASHOLDVER => DEFINE, + DB_KEYEMPTY => DEFINE, + DB_LOGOLDVER => DEFINE, + DB_RECNUM => DEFINE, + DB_RECORDCOUNT => DEFINE, + DB_RENUMBER => DEFINE, + DB_RE_DELIMITER => IGNORE, + DB_RE_FIXEDLEN => IGNORE, + DB_RE_PAD => IGNORE, + DB_RE_RENUMBER => IGNORE, + DB_RE_SNAPSHOT => IGNORE, + + ######### + # 2.3.1 + ######### + + DB_GET_RECNO => DEFINE, + DB_SET_RECNO => DEFINE, + + ######### + # 2.3.3 + ######### + + DB_APPEND => DEFINE, + + ######### + # 2.3.6 + ######### + + DB_TXN_CKP => DEFINE, + + ######### + # 2.3.11 + ######### + + DB_ENV_APPINIT => DEFINE, + DB_ENV_STANDALONE => DEFINE, + DB_ENV_THREAD => DEFINE, + + ######### + # 2.3.12 + ######### + + DB_FUNC_CALLOC => IGNORE, + DB_FUNC_CLOSE => IGNORE, + DB_FUNC_DIRFREE => IGNORE, + DB_FUNC_DIRLIST => IGNORE, + DB_FUNC_EXISTS => IGNORE, + DB_FUNC_FREE => IGNORE, + DB_FUNC_FSYNC => IGNORE, + DB_FUNC_IOINFO => IGNORE, + DB_FUNC_MALLOC => IGNORE, + DB_FUNC_MAP => IGNORE, + DB_FUNC_OPEN => IGNORE, + DB_FUNC_READ => IGNORE, + DB_FUNC_REALLOC => IGNORE, + DB_FUNC_SEEK => IGNORE, + DB_FUNC_SLEEP => IGNORE, + DB_FUNC_STRDUP => IGNORE, + DB_FUNC_UNLINK => IGNORE, + DB_FUNC_UNMAP => IGNORE, + DB_FUNC_WRITE => IGNORE, + DB_FUNC_YIELD => IGNORE, + + ######### + # 2.3.14 + ######### + + DB_TSL_SPINS => IGNORE, + + ######### + # 2.3.16 + ######### + + DB_DBM_HSEARCH => IGNORE, + firstkey => IGNORE, + hdestroy => IGNORE, + + ######### + # 2.4.10 + ######### + + DB_CURLSN => DEFINE, + DB_FUNC_RUNLINK => IGNORE, + DB_REGION_ANON => DEFINE, + DB_REGION_INIT => DEFINE, + DB_REGION_NAME => DEFINE, + DB_TXN_LOCK_OPTIMIST => DEFINE, + __CURRENTLY_UNUSED => IGNORE, + + # enum db_status_t + DB_LSTAT_ABORTED => IGNORE, # 2.4.10 + DB_LSTAT_ERR => IGNORE, # 2.4.10 + DB_LSTAT_FREE => IGNORE, # 2.4.10 + DB_LSTAT_HELD => IGNORE, # 2.4.10 + DB_LSTAT_NOGRANT => IGNORE, # 2.4.10 + DB_LSTAT_PENDING => IGNORE, # 2.4.10 + DB_LSTAT_WAITING => IGNORE, # 2.4.10 + + ######### + # 2.4.14 + ######### + + DB_MUTEXLOCKS => DEFINE, + DB_PAGEYIELD => DEFINE, + __UNUSED_100 => IGNORE, + __UNUSED_4000 => IGNORE, + + ######### + # 2.5.2 + ######### + + DBC_CONTINUE => IGNORE, + DBC_KEYSET => IGNORE, + DBC_RECOVER => IGNORE, + DBC_RMW => IGNORE, + DB_DBM_ERROR => IGNORE, + DB_GET_BOTH => DEFINE, + DB_NEXT_DUP => DEFINE, + DB_OPFLAGS_MASK => DEFINE, + DB_RMW => DEFINE, + DB_RUNRECOVERY => DEFINE, + dbmclose => IGNORE, + + ######### + # 2.5.9 + ######### + + DB_DUPSORT => DEFINE, + DB_JOIN_ITEM => DEFINE, + + ######### + # 2.6.4 + ######### + + DBC_WRITER => IGNORE, + DB_AM_CDB => IGNORE, + DB_ENV_CDB => DEFINE, + DB_INIT_CDB => DEFINE, + DB_LOCK_UPGRADE => DEFINE, + DB_WRITELOCK => DEFINE, + + ######### + # 2.7.1 + ######### + + + # enum db_lockop_t + DB_LOCK_INHERIT => '2.7.1', + + ######### + # 2.7.7 + ######### + + DB_FCNTL_LOCKING => DEFINE, + + ######### + # 3.0.55 + ######### + + DBC_WRITECURSOR => IGNORE, + DB_AM_DISCARD => IGNORE, + DB_AM_SUBDB => IGNORE, + DB_BT_REVSPLIT => IGNORE, + DB_CONSUME => DEFINE, + DB_CXX_NO_EXCEPTIONS => DEFINE, + DB_DBT_REALLOC => IGNORE, + DB_DUPCURSOR => DEFINE, + DB_ENV_CREATE => DEFINE, + DB_ENV_DBLOCAL => DEFINE, + DB_ENV_LOCKDOWN => DEFINE, + DB_ENV_LOCKING => DEFINE, + DB_ENV_LOGGING => DEFINE, + DB_ENV_NOMMAP => DEFINE, + DB_ENV_OPEN_CALLED => DEFINE, + DB_ENV_PRIVATE => DEFINE, + DB_ENV_SYSTEM_MEM => DEFINE, + DB_ENV_TXN => DEFINE, + DB_ENV_TXN_NOSYNC => DEFINE, + DB_ENV_USER_ALLOC => DEFINE, + DB_FORCE => DEFINE, + DB_LOCKDOWN => DEFINE, + DB_LOCK_RECORD => DEFINE, + DB_LOGFILEID_INVALID => DEFINE, + DB_MPOOL_NEW_GROUP => DEFINE, + DB_NEXT_NODUP => DEFINE, + DB_OK_BTREE => DEFINE, + DB_OK_HASH => DEFINE, + DB_OK_QUEUE => DEFINE, + DB_OK_RECNO => DEFINE, + DB_OLD_VERSION => DEFINE, + DB_OPEN_CALLED => DEFINE, + DB_PAGE_LOCK => DEFINE, + DB_POSITION => DEFINE, + DB_POSITIONI => DEFINE, + DB_PRIVATE => DEFINE, + DB_QAMMAGIC => DEFINE, + DB_QAMOLDVER => DEFINE, + DB_QAMVERSION => DEFINE, + DB_RECORD_LOCK => DEFINE, + DB_REVSPLITOFF => DEFINE, + DB_SYSTEM_MEM => DEFINE, + DB_TEST_POSTLOG => DEFINE, + DB_TEST_POSTLOGMETA => DEFINE, + DB_TEST_POSTOPEN => DEFINE, + DB_TEST_POSTRENAME => DEFINE, + DB_TEST_POSTSYNC => DEFINE, + DB_TEST_PREOPEN => DEFINE, + DB_TEST_PRERENAME => DEFINE, + DB_TXN_NOWAIT => DEFINE, + DB_TXN_SYNC => DEFINE, + DB_UPGRADE => DEFINE, + DB_VERB_CHKPOINT => DEFINE, + DB_VERB_DEADLOCK => DEFINE, + DB_VERB_RECOVERY => DEFINE, + DB_VERB_WAITSFOR => DEFINE, + DB_WRITECURSOR => DEFINE, + DB_XA_CREATE => DEFINE, + + # enum DBTYPE + DB_QUEUE => '3.0.55', + + ######### + # 3.1.12 + ######### + + DBC_ACTIVE => IGNORE, + DBC_OPD => IGNORE, + DBC_TRANSIENT => IGNORE, + DBC_WRITEDUP => IGNORE, + DB_AGGRESSIVE => DEFINE, + DB_AM_DUPSORT => IGNORE, + DB_CACHED_COUNTS => DEFINE, + DB_CLIENT => DEFINE, + DB_DBT_DUPOK => IGNORE, + DB_DBT_ISSET => IGNORE, + DB_ENV_RPCCLIENT => DEFINE, + DB_GET_BOTHC => DEFINE, + DB_JOIN_NOSORT => DEFINE, + DB_NODUPDATA => DEFINE, + DB_NOORDERCHK => DEFINE, + DB_NOSERVER => DEFINE, + DB_NOSERVER_HOME => DEFINE, + DB_NOSERVER_ID => DEFINE, + DB_ODDFILESIZE => DEFINE, + DB_ORDERCHKONLY => DEFINE, + DB_PREV_NODUP => DEFINE, + DB_PR_HEADERS => DEFINE, + DB_PR_PAGE => DEFINE, + DB_PR_RECOVERYTEST => DEFINE, + DB_RDWRMASTER => DEFINE, + DB_SALVAGE => DEFINE, + DB_VERIFY_BAD => DEFINE, + DB_VERIFY_FATAL => DEFINE, + DB_VRFY_FLAGMASK => DEFINE, + + # enum db_recops + DB_TXN_ABORT => '3.1.12', + DB_TXN_BACKWARD_ROLL => '3.1.12', + DB_TXN_FORWARD_ROLL => '3.1.12', + DB_TXN_OPENFILES => '3.1.12', + + ######### + # 3.2.3 + ######### + + DBC_COMPENSATE => IGNORE, + DB_AM_VERIFYING => IGNORE, + DB_CDB_ALLDB => DEFINE, + DB_ENV_CDB_ALLDB => DEFINE, + DB_EXTENT => DEFINE, + DB_JOINENV => DEFINE, + DB_LOCK_SWITCH => DEFINE, + DB_MPOOL_EXTENT => DEFINE, + DB_REGION_MAGIC => DEFINE, + DB_UNRESOLVED_CHILD => DEFINE, + DB_VERIFY => DEFINE, + + # enum db_notices + DB_NOTICE_LOGFILE_CHANGED => IGNORE, # 3.2.3 + + ######### + # 3.2.6 + ######### + + DB_ALREADY_ABORTED => DEFINE, + DB_CONSUME_WAIT => DEFINE, + DB_JAVA_CALLBACK => DEFINE, + DB_TEST_POSTEXTDELETE => DEFINE, + DB_TEST_POSTEXTOPEN => DEFINE, + DB_TEST_POSTEXTUNLINK => DEFINE, + DB_TEST_PREEXTDELETE => DEFINE, + DB_TEST_PREEXTOPEN => DEFINE, + DB_TEST_PREEXTUNLINK => DEFINE, + + # enum db_lockmode_t + DB_LOCK_WAIT => IGNORE, # 3.2.6 + + ######### + # 3.3.4 + ######### + + DBC_DIRTY_READ => IGNORE, + DBC_MULTIPLE => IGNORE, + DBC_MULTIPLE_KEY => IGNORE, + DB_AM_DIRTY => IGNORE, + DB_AM_SECONDARY => IGNORE, + DB_COMMIT => DEFINE, + DB_DBT_APPMALLOC => IGNORE, + DB_DIRTY_READ => DEFINE, + DB_DONOTINDEX => DEFINE, + DB_ENV_PANIC_OK => DEFINE, + DB_ENV_RPCCLIENT_GIVEN => DEFINE, + DB_FAST_STAT => DEFINE, + DB_LOCK_MAXLOCKS => DEFINE, + DB_LOCK_MINLOCKS => DEFINE, + DB_LOCK_MINWRITE => DEFINE, + DB_MULTIPLE => DEFINE, + DB_MULTIPLE_KEY => DEFINE, + DB_PAGE_NOTFOUND => DEFINE, + DB_RPC_SERVERPROG => DEFINE, + DB_RPC_SERVERVERS => DEFINE, + DB_UPDATE_SECONDARY => DEFINE, + DB_XIDDATASIZE => DEFINE, + + # enum db_recops + DB_TXN_POPENFILES => '3.3.4', + + # enum db_lockop_t + DB_LOCK_UPGRADE_WRITE => '3.3.4', + + # enum db_lockmode_t + DB_LOCK_DIRTY => IGNORE, # 3.3.4 + DB_LOCK_WWRITE => IGNORE, # 3.3.4 + + ######### + # 3.3.11 + ######### + + DB_SECONDARY_BAD => DEFINE, + DB_SURPRISE_KID => DEFINE, + DB_TEST_POSTDESTROY => DEFINE, + DB_TEST_PREDESTROY => DEFINE, + + ######### + # 4.0.7 + ######### + + DB_APPLY_LOGREG => DEFINE, + DB_BROADCAST_EID => DEFINE, + DB_CL_WRITER => DEFINE, + DB_ENV_NOLOCKING => DEFINE, + DB_ENV_NOPANIC => DEFINE, + DB_ENV_REGION_INIT => DEFINE, + DB_ENV_REP_CLIENT => DEFINE, + DB_ENV_REP_LOGSONLY => DEFINE, + DB_ENV_REP_MASTER => DEFINE, + DB_ENV_YIELDCPU => DEFINE, + DB_GET_BOTH_RANGE => DEFINE, + DB_INVALID_EID => DEFINE, + DB_LOCK_EXPIRE => DEFINE, + DB_LOCK_FREE_LOCKER => DEFINE, + DB_LOCK_SET_TIMEOUT => DEFINE, + DB_LOGC_BUF_SIZE => DEFINE, + DB_LOG_DISK => DEFINE, + DB_LOG_LOCKED => DEFINE, + DB_LOG_SILENT_ERR => DEFINE, + DB_NOLOCKING => DEFINE, + DB_NOPANIC => DEFINE, + DB_PANIC_ENVIRONMENT => DEFINE, + DB_REP_CLIENT => DEFINE, + DB_REP_DUPMASTER => DEFINE, + DB_REP_HOLDELECTION => DEFINE, + DB_REP_LOGSONLY => DEFINE, + DB_REP_MASTER => DEFINE, + DB_REP_NEWMASTER => DEFINE, + DB_REP_NEWSITE => DEFINE, + DB_REP_OUTDATED => DEFINE, + DB_REP_PERMANENT => DEFINE, + DB_REP_UNAVAIL => DEFINE, + DB_SET_LOCK_TIMEOUT => DEFINE, + DB_SET_TXN_NOW => DEFINE, + DB_SET_TXN_TIMEOUT => DEFINE, + DB_STAT_CLEAR => DEFINE, + DB_TIMEOUT => DEFINE, + DB_YIELDCPU => DEFINE, + MP_FLUSH => IGNORE, + MP_OPEN_CALLED => IGNORE, + MP_READONLY => IGNORE, + MP_UPGRADE => IGNORE, + MP_UPGRADE_FAIL => IGNORE, + TXN_CHILDCOMMIT => IGNORE, + TXN_COMPENSATE => IGNORE, + TXN_DIRTY_READ => IGNORE, + TXN_LOCKTIMEOUT => IGNORE, + TXN_MALLOC => IGNORE, + TXN_NOSYNC => IGNORE, + TXN_NOWAIT => IGNORE, + TXN_SYNC => IGNORE, + + # enum db_recops + DB_TXN_APPLY => '4.0.7', + + # enum db_lockop_t + DB_LOCK_GET_TIMEOUT => '4.0.7', + DB_LOCK_PUT_READ => '4.0.7', + DB_LOCK_TIMEOUT => '4.0.7', + + # enum db_status_t + DB_LSTAT_EXPIRED => IGNORE, # 4.0.7 + ) ; +sub enum_Macro +{ + my $str = shift ; + my ($major, $minor, $patch) = split /\./, $str ; + + my $macro = + "#if (DB_VERSION_MAJOR > $major) || \\\n" . + " (DB_VERSION_MAJOR == $major && DB_VERSION_MINOR > $minor) || \\\n" . + " (DB_VERSION_MAJOR == $major && DB_VERSION_MINOR == $minor && \\\n" . + " DB_VERSION_PATCH >= $patch)\n" ; + + return $macro; + +} + sub OutputXS { - # skip to the marker - if (0) { - while (<>) - { - last if /^MARKER/ ; - print ; - } - } - + + my @names = () ; + foreach my $key (sort keys %constants) { - my $isEnum = $constants{$key} ; - - if ($isEnum) { - print <<EOM - if (strEQ(name, "$key")) - return $key; -EOM - } - else - { - print <<EOM - if (strEQ(name, "$key")) -#ifdef $key - return $key; -#else - goto not_there; -#endif -EOM - } - - } - - if (0) { - while (<>) - { - print ; - } + my $val = $constants{$key} ; + next if $val eq IGNORE; + + if ($val eq STRING) + { push @names, { name => $key, type => "PV" } } + elsif ($val eq DEFINE) + { push @names, $key } + else + { push @names, { name => $key, macro => [enum_Macro($val), "#endif\n"] } } } + + WriteConstants( + NAME => BerkeleyDB, + NAMES => \@names, + C_FILE => 'constants.h', + XS_FILE => 'constants.xs', + ) ; } sub OutputPM { - # skip to the marker - if (0) { - while (<>) + my $START = '@EXPORT = qw(' ; + my $START_re = quotemeta $START ; + my $END = ');'; + my $END_re = quotemeta $END ; + + # skip to the @EXPORT declaration + OUTER: while (<>) + { + if ( /^\s*$START_re/ ) { - last if /^MARKER/ ; - print ; + # skip to the end marker. + while (<>) + { last OUTER if /^\s*$END_re/ } } + print ; } + print "$START\n"; foreach my $key (sort keys %constants) { + next if $constants{$key} eq IGNORE; print "\t$key\n"; } + print "\t$END\n"; - if (0) { - while (<>) - { - print ; - } + while (<>) + { + print ; } } -OutputXS() if $ARGV[0] =~ /xs/i ; -OutputPM() if $ARGV[0] =~ /pm/i ; +my $opt = shift ; +OutputXS() if $opt =~ /^xs/i ; +OutputPM() if $opt =~ /^pm/i ; diff --git a/db/perl/DB_File/Changes b/db/perl/DB_File/Changes index da6af577c..b0068feac 100644 --- a/db/perl/DB_File/Changes +++ b/db/perl/DB_File/Changes @@ -343,8 +343,8 @@ 1.77 26th April 2001 - * AIX is reported to need -lpthreads, so Makefile.PL now checks for AIX and - adds it to the link options. + * AIX is reported to need -lpthreads, so Makefile.PL now checks for + AIX and adds it to the link options. * Minor documentation updates. @@ -366,3 +366,32 @@ * added documentation patch regarding duplicate keys from Andrew Johnson +1.79 22nd October 2001 + + * Added a "local $SIG{__DIE__}" inside the eval that checks for + the presence of XSLoader s suggested by Andrew Hryckowin. + + * merged core patch 12277. + + * Changed NEXTKEY to not initialise the input key. It isn't used anyway. + +1.79 22nd October 2001 + + * Fixed test harness for cygwin + + +1.800 23rd November 2001 + + * use pport.h for perl backward compatability code. + + * use new ExtUtils::Constant module to generate XS constants. + + * upgrade Makefile.PL upgrade/downgrade code to toggle "our" with + "use vars" + +1.801 26th November 2001 + + * Fixed typo in Makefile.PL + + * Added "clean" attribute to Makefile.PL + diff --git a/db/perl/DB_File/DB_File.pm b/db/perl/DB_File/DB_File.pm index 289ac0a65..b83877f0c 100644 --- a/db/perl/DB_File/DB_File.pm +++ b/db/perl/DB_File/DB_File.pm @@ -1,8 +1,8 @@ # DB_File.pm -- Perl 5 interface to Berkeley DB # # written by Paul Marquess (Paul.Marquess@btinternet.com) -# last modified 30th July 2001 -# version 1.78 +# last modified 26th Nov 2001 +# version 1.801 # # Copyright (c) 1995-2001 Paul Marquess. All rights reserved. # This program is free software; you can redistribute it and/or @@ -11,7 +11,7 @@ package DB_File::HASHINFO ; -require 5.003 ; +require 5.00404; use warnings; use strict; @@ -145,13 +145,12 @@ package DB_File ; use warnings; use strict; -use vars qw($VERSION @ISA @EXPORT $AUTOLOAD $DB_BTREE $DB_HASH $DB_RECNO - $db_version $use_XSLoader - ) ; +our ($VERSION, @ISA, @EXPORT, $AUTOLOAD, $DB_BTREE, $DB_HASH, $DB_RECNO); +our ($db_version, $use_XSLoader); use Carp; -$VERSION = "1.78" ; +$VERSION = "1.801" ; #typedef enum { DB_BTREE, DB_HASH, DB_RECNO } DBTYPE; $DB_BTREE = new DB_File::BTREEINFO ; @@ -163,7 +162,7 @@ require Exporter; use AutoLoader; BEGIN { $use_XSLoader = 1 ; - eval { require XSLoader } ; + { local $SIG{__DIE__} ; eval { require XSLoader } ; } if ($@) { $use_XSLoader = 0 ; @@ -210,21 +209,12 @@ push @ISA, qw(Tie::Hash Exporter); sub AUTOLOAD { my($constname); ($constname = $AUTOLOAD) =~ s/.*:://; - my $val = constant($constname, @_ ? $_[0] : 0); - if ($! != 0) { - if ($! =~ /Invalid/ || $!{EINVAL}) { - $AutoLoader::AUTOLOAD = $AUTOLOAD; - goto &AutoLoader::AUTOLOAD; - } - else { - my($pack,$file,$line) = caller; - croak "Your vendor has not defined DB macro $constname, used at $file line $line. -"; - } - } - eval "sub $AUTOLOAD { $val }"; - goto &$AUTOLOAD; -} + my ($error, $val) = constant($constname); + Carp::croak $error if $error; + no strict 'refs'; + *{$AUTOLOAD} = sub { $val }; + goto &{$AUTOLOAD}; +} eval { @@ -594,7 +584,7 @@ DB_File - Perl5 access to Berkeley DB version 1.x B<DB_File> is a module which allows Perl programs to make use of the facilities provided by Berkeley DB version 1.x (if you have a newer -version of DB, see L<Using DB_File with Berkeley DB version 2 or 3>). +version of DB, see L<Using DB_File with Berkeley DB version 2 or greater>). It is assumed that you have a copy of the Berkeley DB manual pages at hand when reading this documentation. The interface defined here mirrors the Berkeley DB interface closely. @@ -638,27 +628,27 @@ number. =back -=head2 Using DB_File with Berkeley DB version 2 or 3 +=head2 Using DB_File with Berkeley DB version 2 or greater Although B<DB_File> is intended to be used with Berkeley DB version 1, -it can also be used with version 2 or 3. In this case the interface is +it can also be used with version 2, 3 or 4. In this case the interface is limited to the functionality provided by Berkeley DB 1.x. Anywhere the -version 2 or 3 interface differs, B<DB_File> arranges for it to work +version 2 or greater interface differs, B<DB_File> arranges for it to work like version 1. This feature allows B<DB_File> scripts that were built -with version 1 to be migrated to version 2 or 3 without any changes. +with version 1 to be migrated to version 2 or greater without any changes. If you want to make use of the new features available in Berkeley DB 2.x or greater, use the Perl module B<BerkeleyDB> instead. -B<Note:> The database file format has changed in both Berkeley DB -version 2 and 3. If you cannot recreate your databases, you must dump -any existing databases with either the C<db_dump> or the C<db_dump185> -utility that comes with Berkeley DB. -Once you have rebuilt DB_File to use Berkeley DB version 2 or 3, your -databases can be recreated using C<db_load>. Refer to the Berkeley DB +B<Note:> The database file format has changed multiple times in Berkeley +DB version 2, 3 and 4. If you cannot recreate your databases, you +must dump any existing databases with either the C<db_dump> or the +C<db_dump185> utility that comes with Berkeley DB. +Once you have rebuilt DB_File to use Berkeley DB version 2 or greater, +your databases can be recreated using C<db_load>. Refer to the Berkeley DB documentation for further details. -Please read L<"COPYRIGHT"> before using version 2.x or 3.x of Berkeley +Please read L<"COPYRIGHT"> before using version 2.x or greater of Berkeley DB with DB_File. =head2 Interface to Berkeley DB @@ -838,7 +828,7 @@ contents of the database. use warnings ; use strict ; use DB_File ; - use vars qw( %h $k $v ) ; + our (%h, $k, $v) ; unlink "fruit" ; tie %h, "DB_File", "fruit", O_RDWR|O_CREAT, 0666, $DB_HASH @@ -948,7 +938,7 @@ database. Duplicate keys are entirely defined by the comparison function. In the case-insensitive example above, the keys: 'KEY' and 'key' would be considered duplicates, and assigning to the second one -would overwirte the first. If duplicates are allowed for (with the +would overwrite the first. If duplicates are allowed for (with the R_DUPS flag discussed below), only a single copy of duplicate keys is stored in the database --- so (again with example above) assigning three values to the keys: 'KEY', 'Key', and 'key' would leave just @@ -988,7 +978,7 @@ code: use strict ; use DB_File ; - use vars qw($filename %h ) ; + our ($filename, %h) ; $filename = "tree" ; unlink $filename ; @@ -1043,7 +1033,7 @@ Here is the script above rewritten using the C<seq> API method. use strict ; use DB_File ; - use vars qw($filename $x %h $status $key $value) ; + our ($filename, $x, %h, $status, $key, $value) ; $filename = "tree" ; unlink $filename ; @@ -1115,7 +1105,7 @@ this: use strict ; use DB_File ; - use vars qw($filename $x %h ) ; + our ($filename, $x, %h) ; $filename = "tree" ; @@ -1165,9 +1155,9 @@ Assuming the database from the previous example: use strict ; use DB_File ; - use vars qw($filename $x %h $found) ; + our ($filename, $x, %h, $found) ; - my $filename = "tree" ; + $filename = "tree" ; # Enable duplicate records $DB_BTREE->{'flags'} = R_DUP ; @@ -1204,9 +1194,9 @@ Again assuming the existence of the C<tree> database use strict ; use DB_File ; - use vars qw($filename $x %h $found) ; + our ($filename, $x, %h, $found) ; - my $filename = "tree" ; + $filename = "tree" ; # Enable duplicate records $DB_BTREE->{'flags'} = R_DUP ; @@ -1250,7 +1240,7 @@ and print the first matching key/value pair given a partial key. use DB_File ; use Fcntl ; - use vars qw($filename $x %h $st $key $value) ; + our ($filename, $x, %h, $st, $key, $value) ; sub match { @@ -1449,7 +1439,7 @@ L<THE API INTERFACE>). use warnings ; use strict ; - use vars qw(@h $H $file $i) ; + our (@h, $H, $file, $i) ; use DB_File ; use Fcntl ; @@ -2014,7 +2004,7 @@ F<authors/id/TOMC/scripts/nshist.gz>). use DB_File ; use Fcntl ; - use vars qw( $dotdir $HISTORY %hist_db $href $binary_time $date ) ; + our ($dotdir, $HISTORY, %hist_db, $href, $binary_time, $date) ; $dotdir = $ENV{HOME} || $ENV{LOGNAME}; $HISTORY = "$dotdir/.netscape/history.db"; @@ -2169,7 +2159,7 @@ Consider this script: use warnings ; use strict ; use DB_File ; - use vars qw(%x) ; + my %x ; tie %x, DB_File, "filename" ; Running it produces the error in question: diff --git a/db/perl/DB_File/DB_File.xs b/db/perl/DB_File/DB_File.xs index d2dc572ab..c788b987f 100644 --- a/db/perl/DB_File/DB_File.xs +++ b/db/perl/DB_File/DB_File.xs @@ -3,8 +3,8 @@ DB_File.xs -- Perl 5 interface to Berkeley DB written by Paul Marquess <Paul.Marquess@btinternet.com> - last modified 30th July 2001 - version 1.78 + last modified 26th Nov 2001 + version 1.801 All comments/suggestions/problems are welcome @@ -93,6 +93,11 @@ 1.76 - No change to DB_File.xs 1.77 - Tidied up a few types used in calling newSVpvn. 1.78 - Core patch 10335, 10372, 10534, 10549, 11051 included. + 1.79 - NEXTKEY ignores the input key. + Added lots of casts + 1.800 - Moved backward compatability code into ppport.h. + Use the new constants code. + 1.801 - No change to DB_File.xs */ @@ -101,23 +106,8 @@ #include "perl.h" #include "XSUB.h" -#ifndef PERL_VERSION -# include "patchlevel.h" -# define PERL_REVISION 5 -# define PERL_VERSION PATCHLEVEL -# define PERL_SUBVERSION SUBVERSION -#endif - -#if PERL_REVISION == 5 && (PERL_VERSION < 4 || (PERL_VERSION == 4 && PERL_SUBVERSION <= 75 )) - -# define PL_sv_undef sv_undef -# define PL_na na - -#endif - -/* DEFSV appears first in 5.004_56 */ -#ifndef DEFSV -# define DEFSV GvSV(defgv) +#ifdef _NOT_CORE +# include "ppport.h" #endif /* Mention DB_VERSION_MAJOR_CFG, DB_VERSION_MINOR_CFG, and @@ -134,13 +124,6 @@ -/* If Perl has been compiled with Threads support,the symbol op will - be defined here. This clashes with a field name in db.h, so get rid of it. - */ -#ifdef op -# undef op -#endif - #ifdef COMPAT185 # include <db_185.h> #else @@ -175,17 +158,6 @@ #endif /* Perl >= 5.7 */ -#ifndef pTHX -# define pTHX -# define pTHX_ -# define aTHX -# define aTHX_ -#endif - -#ifndef newSVpvn -# define newSVpvn(a,b) newSVpv(a,b) -#endif - #include <fcntl.h> /* #define TRACE */ @@ -412,7 +384,7 @@ typedef DBT DBTKEY ; #define ckFilter(arg,type,name) \ if (db->type) { \ SV * save_defsv ; \ - /* printf("filtering %s\n", name) ;*/ \ + /* printf("filtering %s\n", name) ; */ \ if (db->filtering) \ croak("recursion detected in %s", name) ; \ db->filtering = TRUE ; \ @@ -424,7 +396,7 @@ typedef DBT DBTKEY ; sv_setsv(DEFSV, save_defsv) ; \ SvREFCNT_dec(save_defsv) ; \ db->filtering = FALSE ; \ - /*printf("end of filtering %s\n", name) ;*/ \ + /* printf("end of filtering %s\n", name) ; */ \ } #else @@ -454,16 +426,29 @@ typedef DBT DBTKEY ; } \ } +#define my_SvUV32(sv) ((u_int32_t)SvUV(sv)) #ifdef CAN_PROTOTYPE extern void __getBerkeleyDBInfo(void); #endif /* Internal Global Data */ -static recno_t Value ; -static recno_t zero = 0 ; -static DB_File CurrentDB ; -static DBTKEY empty ; + +#define MY_CXT_KEY "DB_File::_guts" XS_VERSION + +typedef struct { + recno_t x_Value; + recno_t x_zero; + DB_File x_CurrentDB; + DBTKEY x_empty; +} my_cxt_t; + +START_MY_CXT + +#define Value (MY_CXT.x_Value) +#define zero (MY_CXT.x_zero) +#define CurrentDB (MY_CXT.x_CurrentDB) +#define empty (MY_CXT.x_empty) #ifdef DB_VERSION_MAJOR @@ -557,7 +542,8 @@ const DBT * key2 ; dTHX; #endif dSP ; - char * data1, * data2 ; + dMY_CXT ; + void * data1, * data2 ; int retval ; int count ; @@ -628,6 +614,7 @@ const DBT * key2 ; dTHX; #endif dSP ; + dMY_CXT ; char * data1, * data2 ; int retval ; int count ; @@ -706,6 +693,7 @@ HASH_CB_SIZE_TYPE size ; dTHX; #endif dSP ; + dMY_CXT; int retval ; int count ; @@ -881,6 +869,7 @@ SV * sv ; void * openinfo = NULL ; INFO * info = &RETVAL->info ; STRLEN n_a; + dMY_CXT; /* printf("In ParseOpenInfo name=[%s] flags=[%d] mode = [%d]\n", name, flags, mode) ; */ Zero(RETVAL, 1, DB_File_type) ; @@ -1154,6 +1143,7 @@ SV * sv ; DB * dbp ; STRLEN n_a; int status ; + dMY_CXT; /* printf("In ParseOpenInfo name=[%s] flags=[%d] mode = [%d]\n", name, flags, mode) ; */ Zero(RETVAL, 1, DB_File_type) ; @@ -1210,23 +1200,23 @@ SV * sv ; svp = hv_fetch(action, "ffactor", 7, FALSE); if (svp) - (void)dbp->set_h_ffactor(dbp, SvIV(*svp)) ; + (void)dbp->set_h_ffactor(dbp, my_SvUV32(*svp)) ; svp = hv_fetch(action, "nelem", 5, FALSE); if (svp) - (void)dbp->set_h_nelem(dbp, SvIV(*svp)) ; + (void)dbp->set_h_nelem(dbp, my_SvUV32(*svp)) ; svp = hv_fetch(action, "bsize", 5, FALSE); if (svp) - (void)dbp->set_pagesize(dbp, SvIV(*svp)); + (void)dbp->set_pagesize(dbp, my_SvUV32(*svp)); svp = hv_fetch(action, "cachesize", 9, FALSE); if (svp) - (void)dbp->set_cachesize(dbp, 0, SvIV(*svp), 0) ; + (void)dbp->set_cachesize(dbp, 0, my_SvUV32(*svp), 0) ; svp = hv_fetch(action, "lorder", 6, FALSE); if (svp) - (void)dbp->set_lorder(dbp, SvIV(*svp)) ; + (void)dbp->set_lorder(dbp, (int)SvIV(*svp)) ; PrintHash(info) ; } @@ -1253,19 +1243,19 @@ SV * sv ; svp = hv_fetch(action, "flags", 5, FALSE); if (svp) - (void)dbp->set_flags(dbp, SvIV(*svp)) ; + (void)dbp->set_flags(dbp, my_SvUV32(*svp)) ; svp = hv_fetch(action, "cachesize", 9, FALSE); if (svp) - (void)dbp->set_cachesize(dbp, 0, SvIV(*svp), 0) ; + (void)dbp->set_cachesize(dbp, 0, my_SvUV32(*svp), 0) ; svp = hv_fetch(action, "psize", 5, FALSE); if (svp) - (void)dbp->set_pagesize(dbp, SvIV(*svp)) ; + (void)dbp->set_pagesize(dbp, my_SvUV32(*svp)) ; svp = hv_fetch(action, "lorder", 6, FALSE); if (svp) - (void)dbp->set_lorder(dbp, SvIV(*svp)) ; + (void)dbp->set_lorder(dbp, (int)SvIV(*svp)) ; PrintBtree(info) ; @@ -1291,17 +1281,17 @@ SV * sv ; svp = hv_fetch(action, "cachesize", 9, FALSE); if (svp) { - status = dbp->set_cachesize(dbp, 0, SvIV(*svp), 0) ; + status = dbp->set_cachesize(dbp, 0, my_SvUV32(*svp), 0) ; } svp = hv_fetch(action, "psize", 5, FALSE); if (svp) { - status = dbp->set_pagesize(dbp, SvIV(*svp)) ; + status = dbp->set_pagesize(dbp, my_SvUV32(*svp)) ; } svp = hv_fetch(action, "lorder", 6, FALSE); if (svp) { - status = dbp->set_lorder(dbp, SvIV(*svp)) ; + status = dbp->set_lorder(dbp, (int)SvIV(*svp)) ; } svp = hv_fetch(action, "bval", 4, FALSE); @@ -1311,7 +1301,7 @@ SV * sv ; if (SvPOK(*svp)) value = (int)*SvPV(*svp, n_a) ; else - value = SvIV(*svp) ; + value = (int)SvIV(*svp) ; if (fixed) { status = dbp->set_re_pad(dbp, value) ; @@ -1325,7 +1315,7 @@ SV * sv ; if (fixed) { svp = hv_fetch(action, "reclen", 6, FALSE); if (svp) { - u_int32_t len = (u_int32_t)SvIV(*svp) ; + u_int32_t len = my_SvUV32(*svp) ; status = dbp->set_re_len(dbp, len) ; } } @@ -1344,10 +1334,10 @@ SV * sv ; name = NULL ; - status = dbp->set_flags(dbp, DB_RENUMBER) ; + status = dbp->set_flags(dbp, (u_int32_t)DB_RENUMBER) ; if (flags){ - (void)dbp->set_flags(dbp, flags) ; + (void)dbp->set_flags(dbp, (u_int32_t)flags) ; } PrintRecno(info) ; } @@ -1356,7 +1346,7 @@ SV * sv ; } { - int Flags = 0 ; + u_int32_t Flags = 0 ; int status ; /* Map 1.x flags to 3.x flags */ @@ -1396,246 +1386,15 @@ SV * sv ; } /* ParseOpenInfo */ -static double -#ifdef CAN_PROTOTYPE -constant(char *name, int arg) -#else -constant(name, arg) -char *name; -int arg; -#endif -{ - errno = 0; - switch (*name) { - case 'A': - break; - case 'B': - if (strEQ(name, "BTREEMAGIC")) -#ifdef BTREEMAGIC - return BTREEMAGIC; -#else - goto not_there; -#endif - if (strEQ(name, "BTREEVERSION")) -#ifdef BTREEVERSION - return BTREEVERSION; -#else - goto not_there; -#endif - break; - case 'C': - break; - case 'D': - if (strEQ(name, "DB_LOCK")) -#ifdef DB_LOCK - return DB_LOCK; -#else - goto not_there; -#endif - if (strEQ(name, "DB_SHMEM")) -#ifdef DB_SHMEM - return DB_SHMEM; -#else - goto not_there; -#endif - if (strEQ(name, "DB_TXN")) -#ifdef DB_TXN - return (U32)DB_TXN; -#else - goto not_there; -#endif - break; - case 'E': - break; - case 'F': - break; - case 'G': - break; - case 'H': - if (strEQ(name, "HASHMAGIC")) -#ifdef HASHMAGIC - return HASHMAGIC; -#else - goto not_there; -#endif - if (strEQ(name, "HASHVERSION")) -#ifdef HASHVERSION - return HASHVERSION; -#else - goto not_there; -#endif - break; - case 'I': - break; - case 'J': - break; - case 'K': - break; - case 'L': - break; - case 'M': - if (strEQ(name, "MAX_PAGE_NUMBER")) -#ifdef MAX_PAGE_NUMBER - return (U32)MAX_PAGE_NUMBER; -#else - goto not_there; -#endif - if (strEQ(name, "MAX_PAGE_OFFSET")) -#ifdef MAX_PAGE_OFFSET - return MAX_PAGE_OFFSET; -#else - goto not_there; -#endif - if (strEQ(name, "MAX_REC_NUMBER")) -#ifdef MAX_REC_NUMBER - return (U32)MAX_REC_NUMBER; -#else - goto not_there; -#endif - break; - case 'N': - break; - case 'O': - break; - case 'P': - break; - case 'Q': - break; - case 'R': - if (strEQ(name, "RET_ERROR")) -#ifdef RET_ERROR - return RET_ERROR; -#else - goto not_there; -#endif - if (strEQ(name, "RET_SPECIAL")) -#ifdef RET_SPECIAL - return RET_SPECIAL; -#else - goto not_there; -#endif - if (strEQ(name, "RET_SUCCESS")) -#ifdef RET_SUCCESS - return RET_SUCCESS; -#else - goto not_there; -#endif - if (strEQ(name, "R_CURSOR")) -#ifdef R_CURSOR - return R_CURSOR; -#else - goto not_there; -#endif - if (strEQ(name, "R_DUP")) -#ifdef R_DUP - return R_DUP; -#else - goto not_there; -#endif - if (strEQ(name, "R_FIRST")) -#ifdef R_FIRST - return R_FIRST; -#else - goto not_there; -#endif - if (strEQ(name, "R_FIXEDLEN")) -#ifdef R_FIXEDLEN - return R_FIXEDLEN; -#else - goto not_there; -#endif - if (strEQ(name, "R_IAFTER")) -#ifdef R_IAFTER - return R_IAFTER; -#else - goto not_there; -#endif - if (strEQ(name, "R_IBEFORE")) -#ifdef R_IBEFORE - return R_IBEFORE; -#else - goto not_there; -#endif - if (strEQ(name, "R_LAST")) -#ifdef R_LAST - return R_LAST; -#else - goto not_there; -#endif - if (strEQ(name, "R_NEXT")) -#ifdef R_NEXT - return R_NEXT; -#else - goto not_there; -#endif - if (strEQ(name, "R_NOKEY")) -#ifdef R_NOKEY - return R_NOKEY; -#else - goto not_there; -#endif - if (strEQ(name, "R_NOOVERWRITE")) -#ifdef R_NOOVERWRITE - return R_NOOVERWRITE; -#else - goto not_there; -#endif - if (strEQ(name, "R_PREV")) -#ifdef R_PREV - return R_PREV; -#else - goto not_there; -#endif - if (strEQ(name, "R_RECNOSYNC")) -#ifdef R_RECNOSYNC - return R_RECNOSYNC; -#else - goto not_there; -#endif - if (strEQ(name, "R_SETCURSOR")) -#ifdef R_SETCURSOR - return R_SETCURSOR; -#else - goto not_there; -#endif - if (strEQ(name, "R_SNAPSHOT")) -#ifdef R_SNAPSHOT - return R_SNAPSHOT; -#else - goto not_there; -#endif - break; - case 'S': - break; - case 'T': - break; - case 'U': - break; - case 'V': - break; - case 'W': - break; - case 'X': - break; - case 'Y': - break; - case 'Z': - break; - case '_': - break; - } - errno = EINVAL; - return 0; - -not_there: - errno = ENOENT; - return 0; -} +#include "constants.h" MODULE = DB_File PACKAGE = DB_File PREFIX = db_ +INCLUDE: constants.xs + BOOT: { + MY_CXT_INIT; __getBerkeleyDBInfo() ; DBT_clear(empty) ; @@ -1643,10 +1402,6 @@ BOOT: empty.size = sizeof(recno_t) ; } -double -constant(name,arg) - char * name - int arg DB_File @@ -1677,6 +1432,8 @@ db_DoTie_(isHASH, dbtype, name=undef, flags=O_CREAT|O_RDWR, mode=0666, type=DB_H int db_DESTROY(db) DB_File db + PREINIT: + dMY_CXT; INIT: CurrentDB = db ; CLEANUP: @@ -1708,6 +1465,8 @@ db_DELETE(db, key, flags=0) DB_File db DBTKEY key u_int flags + PREINIT: + dMY_CXT; INIT: CurrentDB = db ; @@ -1716,6 +1475,8 @@ int db_EXISTS(db, key) DB_File db DBTKEY key + PREINIT: + dMY_CXT; CODE: { DBT value ; @@ -1733,7 +1494,8 @@ db_FETCH(db, key, flags=0) DBTKEY key u_int flags PREINIT: - int RETVAL; + dMY_CXT ; + int RETVAL ; CODE: { DBT value ; @@ -1752,6 +1514,8 @@ db_STORE(db, key, value, flags=0) DBTKEY key DBT value u_int flags + PREINIT: + dMY_CXT; INIT: CurrentDB = db ; @@ -1760,7 +1524,8 @@ void db_FIRSTKEY(db) DB_File db PREINIT: - int RETVAL; + dMY_CXT ; + int RETVAL ; CODE: { DBTKEY key ; @@ -1777,13 +1542,15 @@ db_FIRSTKEY(db) void db_NEXTKEY(db, key) DB_File db - DBTKEY key + DBTKEY key = NO_INIT PREINIT: - int RETVAL; + dMY_CXT ; + int RETVAL ; CODE: { DBT value ; + DBT_clear(key) ; DBT_clear(value) ; CurrentDB = db ; RETVAL = do_SEQ(db, key, value, R_NEXT) ; @@ -1799,6 +1566,8 @@ int unshift(db, ...) DB_File db ALIAS: UNSHIFT = 1 + PREINIT: + dMY_CXT; CODE: { DBTKEY key ; @@ -1839,9 +1608,11 @@ unshift(db, ...) void pop(db) DB_File db + PREINIT: + dMY_CXT; ALIAS: POP = 1 PREINIT: - I32 RETVAL; + I32 RETVAL; CODE: { DBTKEY key ; @@ -1868,9 +1639,11 @@ pop(db) void shift(db) DB_File db + PREINIT: + dMY_CXT; ALIAS: SHIFT = 1 PREINIT: - I32 RETVAL; + I32 RETVAL; CODE: { DBT value ; @@ -1897,6 +1670,8 @@ shift(db) I32 push(db, ...) DB_File db + PREINIT: + dMY_CXT; ALIAS: PUSH = 1 CODE: { @@ -1939,6 +1714,8 @@ push(db, ...) I32 length(db) DB_File db + PREINIT: + dMY_CXT; ALIAS: FETCHSIZE = 1 CODE: CurrentDB = db ; @@ -1956,6 +1733,8 @@ db_del(db, key, flags=0) DB_File db DBTKEY key u_int flags + PREINIT: + dMY_CXT; CODE: CurrentDB = db ; RETVAL = db_del(db, key, flags) ; @@ -1975,6 +1754,8 @@ db_get(db, key, value, flags=0) DBTKEY key DBT value = NO_INIT u_int flags + PREINIT: + dMY_CXT; CODE: CurrentDB = db ; DBT_clear(value) ; @@ -1995,6 +1776,8 @@ db_put(db, key, value, flags=0) DBTKEY key DBT value u_int flags + PREINIT: + dMY_CXT; CODE: CurrentDB = db ; RETVAL = db_put(db, key, value, flags) ; @@ -2011,6 +1794,8 @@ db_put(db, key, value, flags=0) int db_fd(db) DB_File db + PREINIT: + dMY_CXT ; CODE: CurrentDB = db ; #ifdef DB_VERSION_MAJOR @@ -2035,6 +1820,8 @@ int db_sync(db, flags=0) DB_File db u_int flags + PREINIT: + dMY_CXT; CODE: CurrentDB = db ; RETVAL = db_sync(db, flags) ; @@ -2052,6 +1839,8 @@ db_seq(db, key, value, flags) DBTKEY key DBT value = NO_INIT u_int flags + PREINIT: + dMY_CXT; CODE: CurrentDB = db ; DBT_clear(value) ; diff --git a/db/perl/DB_File/MANIFEST b/db/perl/DB_File/MANIFEST index 0cc30dbfb..b3e1a7bd8 100644 --- a/db/perl/DB_File/MANIFEST +++ b/db/perl/DB_File/MANIFEST @@ -1,19 +1,16 @@ -Makefile.PL +Changes DB_File.pm DB_File.xs DB_File_BS -Changes +MANIFEST +Makefile.PL +README config.in dbinfo +fallback.h +fallback.xs hints/dynixptx.pl hints/sco.pl -MANIFEST -README -typemap -t/db-btree.t -t/db-hash.t -t/db-recno.t -version.c patches/5.004 patches/5.004_01 patches/5.004_02 @@ -25,3 +22,9 @@ patches/5.005_01 patches/5.005_02 patches/5.005_03 patches/5.6.0 +ppport.h +t/db-btree.t +t/db-hash.t +t/db-recno.t +typemap +version.c diff --git a/db/perl/DB_File/Makefile.PL b/db/perl/DB_File/Makefile.PL index 3a0b8196d..7f4537269 100644 --- a/db/perl/DB_File/Makefile.PL +++ b/db/perl/DB_File/Makefile.PL @@ -1,8 +1,12 @@ #! perl -w + use strict ; use ExtUtils::MakeMaker 5.16 ; use Config ; +die "DB_File needs Perl 5.004_05 or better. This is $]\n" + if $] <= 5.00404; + my $VER_INFO ; my $LIB_DIR ; my $INC_DIR ; @@ -10,15 +14,11 @@ my $DB_NAME ; my $LIBS ; my $COMPAT185 = "" ; -my @files = ('DB_File.pm', glob "t/*.t") ; -# warnings pragma is stable from 5.6.1 onward -if ($] < 5.006001) - { oldWarnings(@files) } -else - { newWarnings(@files) } - ParseCONFIG() ; +my @files = ('DB_File.pm', glob "t/*.t") ; +UpDowngrade(@files); + if (defined $DB_NAME) { $LIBS = $DB_NAME } else { @@ -45,35 +45,126 @@ WriteMakefile( INC => "-I$INC_DIR", VERSION_FROM => 'DB_File.pm', XSPROTOARG => '-noprototypes', - DEFINE => "$OS2 $VER_INFO $COMPAT185", + DEFINE => "-D_NOT_CORE $OS2 $VER_INFO $COMPAT185", OBJECT => 'version$(OBJ_EXT) DB_File$(OBJ_EXT)', - OPTIMIZE => '-g', - 'macro' => { INSTALLDIRS => 'perl' }, - 'dist' => {COMPRESS=>'gzip', SUFFIX=>'gz', - DIST_DEFAULT => 'MyDoubleCheck tardist'}, + #OPTIMIZE => '-g', + 'depend' => { 'Makefile' => 'config.in', + 'version$(OBJ_EXT)' => 'version.c'}, + 'clean' => { FILES => 'constants.h constants.xs' }, + 'macro' => { INSTALLDIRS => 'perl', my_files => "@files" }, + 'dist' => { COMPRESS => 'gzip', SUFFIX => 'gz', + DIST_DEFAULT => 'MyDoubleCheck tardist'}, ); -sub MY::postamble { - ' +my @names = qw( + BTREEMAGIC + BTREEVERSION + DB_LOCK + DB_SHMEM + DB_TXN + HASHMAGIC + HASHVERSION + MAX_PAGE_NUMBER + MAX_PAGE_OFFSET + MAX_REC_NUMBER + RET_ERROR + RET_SPECIAL + RET_SUCCESS + R_CURSOR + R_DUP + R_FIRST + R_FIXEDLEN + R_IAFTER + R_IBEFORE + R_LAST + R_NEXT + R_NOKEY + R_NOOVERWRITE + R_PREV + R_RECNOSYNC + R_SETCURSOR + R_SNAPSHOT + __R_UNUSED + ); + +if (eval {require ExtUtils::Constant; 1}) { + # Check the constants above all appear in @EXPORT in DB_File.pm + my %names = map { $_, 1} @names; + open F, "<DB_File.pm" or die "Cannot open DB_File.pm: $!\n"; + while (<F>) + { + last if /^\s*\@EXPORT\s+=\s+qw\(/ ; + } -MyDoubleCheck: + while (<F>) + { + last if /^\s*\)/ ; + /(\S+)/ ; + delete $names{$1} if defined $1 ; + } + close F ; + + if ( keys %names ) + { + my $missing = join ("\n\t", sort keys %names) ; + die "The following names are missing from \@EXPORT in DB_File.pm\n" . + "\t$missing\n" ; + } + + + ExtUtils::Constant::WriteConstants( + NAME => 'DB_File', + NAMES => \@names, + C_FILE => 'constants.h', + XS_FILE => 'constants.xs', + + ); +} +else { + use File::Copy; + copy ('fallback.h', 'constants.h') + or die "Can't copy fallback.h to constants.h: $!"; + copy ('fallback.xs', 'constants.xs') + or die "Can't copy fallback.xs to constants.xs: $!"; +} + +exit; + + +sub MY::postamble { <<'EOM' } ; + +MyDoubleCheck: @echo Checking config.in is setup for a release @(grep "^LIB.*/usr/local/BerkeleyDB" config.in && \ grep "^INCLUDE.*/usr/local/BerkeleyDB" config.in && \ grep "^#DBNAME.*" config.in) >/dev/null || \ - (echo config.in needs fixing ; exit 1) + (echo config.in needs fixing ; exit 1) @echo config.in is ok + @echo + @echo Checking DB_File.xs is ok for a release. + @(perl -ne ' exit 1 if /^\s*#\s*define\s+TRACE/ ; ' DB_File.xs || \ + (echo DB_File.xs needs fixing ; exit 1)) + @echo DB_File.xs is ok + @echo + @echo Checking for $$^W in files: $(my_files) + @perl -ne ' \ + exit 1 if /^\s*local\s*\(\s*\$$\^W\s*\)/;' $(my_files) || \ + (echo found unexpected $$^W ; exit 1) + @echo No $$^W found. + @echo + @echo Checking for 'use vars' in files: $(my_files) + @perl -ne ' \ + exit 0 if /^__(DATA|END)__/; \ + exit 1 if /^\s*use\s+vars/;' $(my_files) || \ + (echo found unexpected "use vars"; exit 1) + @echo No 'use vars' found. + @echo + @echo All files are OK for a release. + @echo -version$(OBJ_EXT): version.c - -$(NAME).xs: typemap - @$(TOUCH) $(NAME).xs - -Makefile: config.in +EOM -' ; -} sub ParseCONFIG @@ -146,51 +237,81 @@ EOM } -sub oldWarnings +sub UpDowngrade { - local ($^I) = ".bak" ; - local (@ARGV) = @_ ; + my @files = @_ ; - while (<>) - { - if (/^__END__/) - { - print ; - my $this = $ARGV ; - while (<>) - { - last if $ARGV ne $this ; - print ; - } - } + # our is stable from 5.6.0 onward + # warnings is stable from 5.6.1 onward - s/^(\s*)(no\s+warnings)/${1}local (\$^W) = 0; #$2/ ; - s/^(\s*)(use\s+warnings)/${1}local (\$^W) = 1; #$2/ ; - print ; + # Note: this code assumes that each statement it modifies is not + # split across multiple lines. + + + my $warn_sub ; + my $our_sub ; + + if ($] < 5.006001) { + # From: use|no warnings "blah" + # To: local ($^W) = 1; # use|no warnings "blah" + $warn_sub = sub { + s/^(\s*)(no\s+warnings)/${1}local (\$^W) = 0; #$2/ ; + s/^(\s*)(use\s+warnings)/${1}local (\$^W) = 1; #$2/ ; + }; } + else { + # From: local ($^W) = 1; # use|no warnings "blah" + # To: use|no warnings "blah" + $warn_sub = sub { + s/^(\s*)local\s*\(\$\^W\)\s*=\s*\d+\s*;\s*#\s*((no|use)\s+warnings.*)/$1$2/ ; + }; + } + + if ($] < 5.006000) { + $our_sub = sub { + if ( /^(\s*)our\s+\(\s*([^)]+\s*)\)/ ) { + my $indent = $1; + my $vars = join ' ', split /\s*,\s*/, $2; + $_ = "${indent}use vars qw($vars);\n"; + } + }; + } + else { + $our_sub = sub { + if ( /^(\s*)use\s+vars\s+qw\((.*?)\)/ ) { + my $indent = $1; + my $vars = join ', ', split ' ', $2; + $_ = "${indent}our ($vars);\n"; + } + }; + } + + foreach (@files) + { doUpDown($our_sub, $warn_sub, $_) } } -sub newWarnings + +sub doUpDown { + my $our_sub = shift; + my $warn_sub = shift; + local ($^I) = ".bak" ; - local (@ARGV) = @_ ; + local (@ARGV) = shift; while (<>) { - if (/^__END__/) - { - my $this = $ARGV ; - print ; - while (<>) - { - last if $ARGV ne $this ; - print ; - } - } + print, last if /^__(END|DATA)__/ ; - s/^(\s*)local\s*\(\$\^W\)\s*=\s*\d+\s*;\s*#\s*((no|use)\s+warnings.*)/$1$2/ ; + &{ $our_sub }(); + &{ $warn_sub }(); print ; } + + return if eof ; + + while (<>) + { print } } # end of file Makefile.PL diff --git a/db/perl/DB_File/README b/db/perl/DB_File/README index 3e9934550..b3eaf266a 100644 --- a/db/perl/DB_File/README +++ b/db/perl/DB_File/README @@ -1,8 +1,8 @@ DB_File - Version 1.78 + Version 1.801 - 30th July 2001 + 26th Nov 2001 Copyright (c) 1995-2001 Paul Marquess. All rights reserved. This program is free software; you can redistribute it and/or modify @@ -22,11 +22,11 @@ DESCRIPTION DB_File is a module which allows Perl programs to make use of the facilities provided by Berkeley DB version 1. (DB_File can be built -version 2 or 3 of Berkeley DB, but it will only support the 1.x +version 2,i 3 or 4 of Berkeley DB, but it will only support the 1.x features), If you want to make use of the new features available in Berkeley DB -2.x or 3.x, use the Perl module BerkeleyDB instead. +2.x, 3.x or 4.x, use the Perl module BerkeleyDB instead. Berkeley DB is a C library which provides a consistent interface to a number of database formats. DB_File provides an interface to all three @@ -42,7 +42,7 @@ PREREQUISITES Before you can build DB_File you must have the following installed on your system: - * Perl 5.004 or greater. + * Perl 5.004_05 or greater. * Berkeley DB. @@ -57,8 +57,8 @@ your system: compatible version of Berkeley DB. If you want to use Berkeley DB 2.x, you must have version 2.3.4 - or greater. If you want to use Berkeley DB 3.x, any version will - do. For Berkeley DB 1.x, use either version 1.85 or 1.86. + or greater. If you want to use Berkeley DB 3.x or 4.x, any version + will do. For Berkeley DB 1.x, use either version 1.85 or 1.86. BUILDING THE MODULE @@ -68,7 +68,7 @@ Assuming you have met all the prerequisites, building the module should be relatively straightforward. Step 1 : If you are running either Solaris 2.5 or HP-UX 10 and want - to use Berkeley DB version 2 or 3, read either the Solaris Notes + to use Berkeley DB version 2, 3 or 4, read either the Solaris Notes or HP-UX Notes sections below. If you are running Linux please read the Linux Notes section before proceeding. diff --git a/db/perl/DB_File/version.c b/db/perl/DB_File/version.c index 48c29a0e6..0997db101 100644 --- a/db/perl/DB_File/version.c +++ b/db/perl/DB_File/version.c @@ -3,8 +3,8 @@ version.c -- Perl 5 interface to Berkeley DB written by Paul Marquess <Paul.Marquess@btinternet.com> - last modified 30th July 2001 - version 1.78 + last modified 22nd Oct 2001 + version 1.79 All comments/suggestions/problems are welcome diff --git a/db/rep/rep_method.c b/db/rep/rep_method.c index 859158d2a..3b8bfac31 100644 --- a/db/rep/rep_method.c +++ b/db/rep/rep_method.c @@ -7,16 +7,12 @@ #include "db_config.h" #ifndef lint -static const char revid[] = "Id: rep_method.c,v 1.23 2001/10/10 02:57:41 margo Exp "; +static const char revid[] = "Id: rep_method.c,v 1.37 2001/11/16 16:29:10 bostic Exp "; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES #include <sys/types.h> -/* XXX */ -#ifdef REP_DEBUG -#include <pthread.h> -#endif #include <stdlib.h> #include <string.h> #include <unistd.h> @@ -34,14 +30,12 @@ static const char revid[] = "Id: rep_method.c,v 1.23 2001/10/10 02:57:41 margo E #include "rpc_client_ext.h" #endif -static int __rep_elect __P((DB_ENV *, - int, int, u_int32_t, u_int32_t, int *, int *)); +static int __rep_elect __P((DB_ENV *, int, int, u_int32_t, int *)); static int __rep_elect_init __P((DB_ENV *, DB_LSN *, int, int, int *)); -static int __rep_set_rep_transport __P((DB_ENV *, int, void *, - int (*)(DB_ENV *, void *, const DBT *, DBT *, db_reptype_t, int))); +static int __rep_set_rep_transport __P((DB_ENV *, int, + int (*)(DB_ENV *, const DBT *, const DBT *, int, u_int32_t))); static int __rep_start __P((DB_ENV *, DBT *, u_int32_t)); -static int __rep_wait __P((DB_ENV *, - u_int32_t, u_int32_t, int *, int *, u_int32_t)); +static int __rep_wait __P((DB_ENV *, u_int32_t, int *, u_int32_t)); /* * __rep_dbenv_create -- @@ -100,6 +94,8 @@ __rep_start(dbenv, dbt, flags) DBT *dbt; u_int32_t flags; { + DB_LOG *dblp; + DB_LSN lsn; DB_REP *db_rep; REP *rep; int announce, init_db, ret; @@ -115,24 +111,29 @@ __rep_start(dbenv, dbt, flags) return (ret); /* Exactly one of CLIENT and MASTER must be specified. */ - if ((!LF_ISSET(DB_REP_CLIENT) && (!LF_ISSET(DB_REP_MASTER))) || - (LF_ISSET(DB_REP_CLIENT) && LF_ISSET(DB_REP_MASTER))) - return (__db_ferr(dbenv, "DB_ENV->rep_start", 1)); + if ((ret = __db_fcchk(dbenv, + "DB_ENV->rep_start", flags, DB_REP_CLIENT, DB_REP_MASTER)) != 0) + return (ret); + if (!LF_ISSET(DB_REP_CLIENT | DB_REP_MASTER)) { + __db_err(dbenv, + "DB_ENV->rep_start: either DB_CLIENT or DB_MASTER must be specified."); + return (EINVAL); + } /* Masters can't be logs-only. */ - if (LF_ISSET(DB_REP_MASTER) && LF_ISSET(DB_REP_LOGSONLY)) - return (__db_ferr(dbenv, "DB_ENV->rep_start", 1)); + if ((ret = __db_fcchk(dbenv, + "DB_ENV->rep_start", flags, DB_REP_LOGSONLY, DB_REP_MASTER)) != 0) + return (ret); /* We need a transport function. */ if (db_rep->rep_send == NULL) { __db_err(dbenv, - "DB_ENV->set_rep_transport must be called before %s", - "DB_ENV->rep_start"); + "DB_ENV->set_rep_transport must be called before DB_ENV->rep_start"); return (EINVAL); } MUTEX_LOCK(dbenv, db_rep->mutexp, dbenv->lockfhp); - if (rep->eid == DB_INVALID_EID) + if (rep->eid == DB_EID_INVALID) rep->eid = dbenv->rep_eid; if (LF_ISSET(DB_REP_MASTER)) { @@ -153,21 +154,23 @@ __rep_start(dbenv, dbt, flags) F_SET(rep, REP_F_MASTER); F_SET(dbenv, DB_ENV_REP_MASTER); MUTEX_UNLOCK(dbenv, db_rep->mutexp); + dblp = (DB_LOG *)dbenv->lg_handle; + R_LOCK(dbenv, &dblp->reginfo); + lsn = ((LOG *)dblp->reginfo.primary)->lsn; + R_UNLOCK(dbenv, &dblp->reginfo); + ret = __rep_send_message(dbenv, + DB_EID_BROADCAST, REP_NEWMASTER, &lsn, NULL, 0); } else { - if (F_ISSET(dbenv, DB_ENV_REP_MASTER) || - F_ISSET(rep, REP_F_MASTER)) { - MUTEX_UNLOCK(dbenv, db_rep->mutexp); - return (DB_REP_NEWMASTER); - } - + F_CLR(dbenv, DB_ENV_REP_MASTER); F_SET(dbenv, DB_ENV_REP_CLIENT); if (LF_ISSET(DB_REP_LOGSONLY)) F_SET(dbenv, DB_ENV_REP_LOGSONLY); announce = !F_ISSET(rep, REP_ISCLIENT) || - rep->master_id == DB_INVALID_EID; + rep->master_id == DB_EID_INVALID; init_db = 0; if (!F_ISSET(rep, REP_ISCLIENT)) { + F_CLR(rep, REP_F_MASTER); if (LF_ISSET(DB_REP_LOGSONLY)) F_SET(rep, REP_F_LOGSONLY); else @@ -180,7 +183,7 @@ __rep_start(dbenv, dbt, flags) * during normal operation and a master failure. */ rep->gen = 0; - rep->master_id = DB_INVALID_EID; + rep->master_id = DB_EID_INVALID; init_db = 1; } MUTEX_UNLOCK(dbenv, db_rep->mutexp); @@ -198,7 +201,7 @@ __rep_start(dbenv, dbt, flags) */ if (announce) ret = __rep_send_message(dbenv, - DB_BROADCAST_EID, REP_NEWCLIENT, NULL, dbt, 0); + DB_EID_BROADCAST, REP_NEWCLIENT, NULL, dbt, 0); } return (ret); } @@ -208,26 +211,35 @@ __rep_start(dbenv, dbt, flags) * Set the transport function for replication. */ static int -__rep_set_rep_transport(dbenv, eid, send_cookie, f_send) +__rep_set_rep_transport(dbenv, eid, f_send) DB_ENV *dbenv; int eid; - void *send_cookie; - int (*f_send)(DB_ENV *, - void *, const DBT *, DBT *, u_int32_t, int); + int (*f_send) __P((DB_ENV *, const DBT *, const DBT *, int, u_int32_t)); { DB_REP *db_rep; - int ret; - ret = 0; - db_rep = dbenv->rep_handle; - if (db_rep == NULL) + if ((db_rep = dbenv->rep_handle) == NULL) { + __db_err(dbenv, + "DB_ENV->set_rep_transport: database environment not properly initialized"); + return (DB_RUNRECOVERY); + } + + if (f_send == NULL) { + __db_err(dbenv, + "DB_ENV->set_rep_transport: no send function specified"); return (EINVAL); + } + + if (eid < 0) { + __db_err(dbenv, + "DB_ENV->set_rep_transport: eid must be greater than or equal to 0"); + return (EINVAL); + } db_rep->rep_send = f_send; - db_rep->rep_send_data = send_cookie; dbenv->rep_eid = eid; - return (ret); + return (0); } /* @@ -236,11 +248,11 @@ __rep_set_rep_transport(dbenv, eid, send_cookie, f_send) * a new master. */ static int -__rep_elect(dbenv, nsites, pri, wait, sleep, eidp, selfp) +__rep_elect(dbenv, nsites, priority, timeout, eidp) DB_ENV *dbenv; - int nsites, pri; - u_int32_t wait, sleep; - int *eidp, *selfp; + int nsites, priority; + u_int32_t timeout; + int *eidp; { DB_LOG *dblp; DB_LSN lsn; @@ -248,7 +260,17 @@ __rep_elect(dbenv, nsites, pri, wait, sleep, eidp, selfp) REP *rep; int in_progress, ret, send_vote; - *selfp = 0; + /* Error checking. */ + if (nsites <= 0) { + __db_err(dbenv, + "DB_ENV->rep_elect: nsites must be greater than 0"); + return (EINVAL); + } + if (priority < 0) { + __db_err(dbenv, + "DB_ENV->rep_elect: priority may not be negative"); + return (EINVAL); + } dblp = dbenv->lg_handle; R_LOCK(dbenv, &dblp->reginfo); @@ -258,26 +280,33 @@ __rep_elect(dbenv, nsites, pri, wait, sleep, eidp, selfp) db_rep = dbenv->rep_handle; rep = db_rep->region; if ((ret = __rep_elect_init(dbenv, - &lsn, nsites, pri, &in_progress)) != 0) + &lsn, nsites, priority, &in_progress)) != 0) { + if (ret == DB_REP_NEWMASTER) { + ret = 0; + *eidp = dbenv->rep_eid; + } return (ret); + } -#ifdef REP_DEBUG -if (!in_progress) - fprintf(stderr, "%lx Beginning an election\n", (long)pthread_self()); + if (!in_progress) { +#ifdef DIAGNOSTIC + if (FLD_ISSET(dbenv->verbose, DB_VERB_REPLICATION)) + __db_err(dbenv, "Beginning an election"); #endif - if (!in_progress && (ret = __rep_send_message(dbenv, - DB_BROADCAST_EID, REP_ELECT, NULL, NULL, 0)) != 0) - goto err; + if ((ret = __rep_send_message(dbenv, + DB_EID_BROADCAST, REP_ELECT, NULL, NULL, 0)) != 0) + goto err; + } /* Now send vote */ - if ((ret = __rep_send_vote(dbenv, &lsn, nsites, pri)) != 0) + if ((ret = __rep_send_vote(dbenv, &lsn, nsites, priority)) != 0) goto err; - ret = __rep_wait(dbenv, wait, sleep, selfp, eidp, REP_F_EPHASE1); + ret = __rep_wait(dbenv, timeout, eidp, REP_F_EPHASE1); switch (ret) { case 0: /* Check if election complete or phase complete. */ - if (*eidp != DB_INVALID_EID) + if (*eidp != DB_EID_INVALID) return (0); goto phase2; case DB_TIMEOUT: @@ -292,7 +321,7 @@ if (!in_progress) * the winner. */ MUTEX_LOCK(dbenv, db_rep->mutexp, dbenv->lockfhp); - send_vote = DB_INVALID_EID; + send_vote = DB_EID_INVALID; if (rep->sites > rep->nsites / 2) { /* We think we've seen enough to cast a vote. */ send_vote = rep->winner; @@ -302,26 +331,29 @@ if (!in_progress) F_SET(rep, REP_F_EPHASE2); } MUTEX_UNLOCK(dbenv, db_rep->mutexp); - if (send_vote == DB_INVALID_EID) { + if (send_vote == DB_EID_INVALID) { /* We do not have enough votes to elect. */ -#ifdef REP_DEBUG -fprintf(stderr, "%lx Not enough votes to elect: received %d of %d\n", -(long)pthread_self(), rep->sites, rep->nsites); +#ifdef DIAGNOSTIC + if (FLD_ISSET(dbenv->verbose, DB_VERB_REPLICATION)) + __db_err(dbenv, + "Not enough votes to elect: received %d of %d", + rep->sites, rep->nsites); #endif ret = DB_REP_UNAVAIL; goto err; } -#ifdef REP_DEBUG -if (send_vote != rep->eid) - fprintf(stderr, "%lx Sending vote\n", (long)pthread_self()); +#ifdef DIAGNOSTIC + if (FLD_ISSET(dbenv->verbose, DB_VERB_REPLICATION) && + send_vote != rep->eid) + __db_err(dbenv, "Sending vote"); #endif if (send_vote != rep->eid && (ret = __rep_send_message(dbenv, send_vote, REP_VOTE2, NULL, NULL, 0)) != 0) goto err; -phase2: ret = __rep_wait(dbenv, wait, sleep, selfp, eidp, REP_F_EPHASE2); +phase2: ret = __rep_wait(dbenv, timeout, eidp, REP_F_EPHASE2); switch (ret) { case 0: return (0); @@ -335,8 +367,10 @@ phase2: ret = __rep_wait(dbenv, wait, sleep, selfp, eidp, REP_F_EPHASE2); err: MUTEX_LOCK(dbenv, db_rep->mutexp, dbenv->lockfhp); ELECTION_DONE(rep); MUTEX_UNLOCK(dbenv, db_rep->mutexp); -#ifdef REP_DEBUG -fprintf(stderr, "%lx Ended election with %d\n", (long)pthread_self(), ret); + +#ifdef DIAGNOSTIC + if (FLD_ISSET(dbenv->verbose, DB_VERB_REPLICATION)) + __db_err(dbenv, "Ended election with %d", ret); #endif return (ret); } @@ -346,11 +380,11 @@ fprintf(stderr, "%lx Ended election with %d\n", (long)pthread_self(), ret); * Initialize an election. Sets beginp non-zero if the election is * already in progress; makes it 0 otherwise. */ -int -__rep_elect_init(dbenv, lsnp, nsites, pri, beginp) +static int +__rep_elect_init(dbenv, lsnp, nsites, priority, beginp) DB_ENV *dbenv; DB_LSN *lsnp; - int nsites, pri, *beginp; + int nsites, priority, *beginp; { DB_REP *db_rep; REP *rep; @@ -360,16 +394,24 @@ __rep_elect_init(dbenv, lsnp, nsites, pri, beginp) rep = db_rep->region; ret = 0; + + /* If we are already a master; simply broadcast that fact and return. */ + if (F_ISSET(dbenv, DB_ENV_REP_MASTER)) { + ret = __rep_send_message(dbenv, + DB_EID_BROADCAST, REP_NEWMASTER, lsnp, NULL, 0); + return (DB_REP_NEWMASTER); + } + MUTEX_LOCK(dbenv, db_rep->mutexp, dbenv->lockfhp); *beginp = IN_ELECTION(rep); if (!*beginp) { F_SET(rep, REP_F_EPHASE1); - rep->master_id = DB_INVALID_EID; + rep->master_id = DB_EID_INVALID; if (nsites > rep->asites && (ret = __rep_grow_sites(dbenv, nsites)) != 0) goto err; rep->nsites = nsites; - rep->priority = pri; + rep->priority = priority; rep->votes = 0; /* We have always heard from ourselves. */ @@ -377,14 +419,14 @@ __rep_elect_init(dbenv, lsnp, nsites, pri, beginp) tally = R_ADDR((REGINFO *)dbenv->reginfo, rep->tally_off); tally[0] = rep->eid; - if (pri != 0) { + if (priority != 0) { /* Make ourselves the winner to start. */ rep->winner = rep->eid; - rep->w_priority = pri; + rep->w_priority = priority; rep->w_gen = rep->gen; rep->w_lsn = *lsnp; } else { - rep->winner = DB_INVALID_EID; + rep->winner = DB_EID_INVALID; rep->w_priority = 0; rep->w_gen = 0; ZERO_LSN(rep->w_lsn); @@ -395,38 +437,43 @@ err: MUTEX_UNLOCK(dbenv, db_rep->mutexp); } static int -__rep_wait(dbenv, wait, sleep, selfp, eidp, flags) +__rep_wait(dbenv, timeout, eidp, flags) DB_ENV *dbenv; - u_int32_t wait, sleep; - int *selfp, *eidp; + u_int32_t timeout; + int *eidp; u_int32_t flags; { DB_REP *db_rep; REP *rep; int done, ret; + u_int32_t sleeptime; done = 0; db_rep = dbenv->rep_handle; rep = db_rep->region; - while (wait > 0) { - if ((ret = __os_sleep(dbenv, 0, sleep)) != 0) + /* + * The user specifies an overall timeout function, but checking + * is cheap and the timeout may be a generous upper bound. + * Sleep repeatedly for the smaller of .5s and timeout/10. + */ + sleeptime = (timeout > 5000000) ? 500000 : timeout / 10; + while (timeout > 0) { + if ((ret = __os_sleep(dbenv, 0, sleeptime)) != 0) return (ret); MUTEX_LOCK(dbenv, db_rep->mutexp, dbenv->lockfhp); - done = !F_ISSET(rep, flags) && rep->master_id != DB_INVALID_EID; + done = !F_ISSET(rep, flags) && rep->master_id != DB_EID_INVALID; *eidp = rep->master_id; - if (rep->eid == rep->master_id) - *selfp = 1; MUTEX_UNLOCK(dbenv, db_rep->mutexp); if (done) return (0); - if (wait > sleep) - wait -= sleep; + if (timeout > sleeptime) + timeout -= sleeptime; else - wait = 0; + timeout = 0; } return (DB_TIMEOUT); } diff --git a/db/rep/rep_record.c b/db/rep/rep_record.c index 80c87d55e..dd4d870b4 100644 --- a/db/rep/rep_record.c +++ b/db/rep/rep_record.c @@ -8,7 +8,7 @@ #include "db_config.h" #ifndef lint -static const char revid[] = "Id: rep_record.c,v 1.43 2001/10/10 02:57:42 margo Exp "; +static const char revid[] = "Id: rep_record.c,v 1.64 2001/11/16 16:29:10 bostic Exp "; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -32,25 +32,33 @@ static int __rep_process_txn __P((DB_ENV *, DBT *)); ((R) != DB_txn_regop && (R) != DB_txn_ckp && (R) != DB_log_register) /* - * This is a bit of a hack. If we set the offset to - * be the sizeof the persistent log structure, then - * we'll match the correct LSN on the next log write - * and the guts of the log system will take care of - * actually writing the persistent header. + * This is a bit of a hack. If we set the offset to be the sizeof the + * persistent log structure, then we'll match the correct LSN on the + * next log write. * - * And now it's even more of a hack. If lp->ready_lsn is [1][0], we need - * to "change" to the first log file (we currently have none). - * However, in this situation, we don't want to wind up at LSN - * [2][whatever], we want to wind up at LSN [1][whatever], - * so don't increment lsn.file. + * If lp->ready_lsn is [1][0], we need to "change" to the first log + * file (we currently have none). However, in this situation, we + * don't want to wind up at LSN [2][whatever], we want to wind up at + * LSN [1][whatever], so don't set LOG_NEWFILE. The guts of the log + * system will take care of actually writing the persistent header, + * since we're doing a log_put to an empty log. + * + * If lp->ready_lsn is [m-1][n] for some m > 1, n > 0, we really do need to + * change to the first log file. Not only do we need to jump to lsn + * [m][0], we need to write out a persistent header there, so set + * LOG_NEWFILE so the right stuff happens in the bowels of log_put. + * Note that we could dispense with LOG_NEWFILE by simply relying upon + * the log system to decide to switch files at the same time the + * master did--lg_max should be the same in both places--but this is + * scary. */ #define CHANGE_FILES do { \ - if (!(lp->ready_lsn.file == 1 && lp->ready_lsn.offset == 0)) \ - lp->ready_lsn.file = rp->lsn.file + 1; \ + if (!(lp->ready_lsn.file == 1 && lp->ready_lsn.offset == 0)) { \ + lp->ready_lsn.file++; \ + F_SET(lp, LOG_NEWFILE); \ + } \ lp->ready_lsn.offset = sizeof(struct __log_persist) + \ sizeof(struct __hdr); \ - if ((ret = __log_newfh(dblp)) != 0) \ - goto err; \ /* Make this evaluate to a simple rectype. */ \ rectype = 0; \ } while (0) @@ -69,25 +77,32 @@ static int __rep_process_txn __P((DB_ENV *, DBT *)); * PUBLIC: int __rep_process_message __P((DB_ENV *, DBT *, DBT *, int *)); */ int -__rep_process_message(dbenv, rec, control, eidp) +__rep_process_message(dbenv, control, rec, eidp) DB_ENV *dbenv; - DBT *rec, *control; + DBT *control, *rec; int *eidp; { - DBT *d, data_dbt, mylog; + DBT *d, data_dbt, lsndbt, mylog; DB_LOG *dblp; DB_LOGC *logc; - DB_LSN lsn; + DB_LSN lsn, newfilelsn, oldfilelsn; DB_REP *db_rep; LOG *lp; REP *rep; REP_CONTROL *rp; REP_VOTE_INFO *vi; u_int32_t gen, type; - int done, i, master, eid, old, recovering, ret, t_ret, *tally; + int done, i, master, old, recovering, ret, t_ret, *tally; PANIC_CHECK(dbenv); + /* Control argument must be non-Null. */ + if (control == NULL || control->size == 0) { + __db_err(dbenv, + "DB_ENV->rep_process_message: control argument must be specified"); + return (EINVAL); + } + ret = 0; db_rep = dbenv->rep_handle; rep = db_rep->region; @@ -96,7 +111,6 @@ __rep_process_message(dbenv, rec, control, eidp) MUTEX_LOCK(dbenv, db_rep->mutexp, dbenv->lockfhp); gen = rep->gen; - eid = rep->eid; recovering = F_ISSET(rep, REP_F_RECOVER); MUTEX_UNLOCK(dbenv, db_rep->mutexp); @@ -106,6 +120,20 @@ __rep_process_message(dbenv, rec, control, eidp) */ rp = (REP_CONTROL *)control->data; + /* Complain if we see an improper version number. */ + if (rp->rep_version != DB_REPVERSION) { + __db_err(dbenv, + "unexpected replication message version %d, expected %d", + rp->rep_version, DB_REPVERSION); + return (EINVAL); + } + if (rp->log_version != DB_LOGVERSION) { + __db_err(dbenv, + "unexpected log record version %d, expected %d", + rp->log_version, DB_LOGVERSION); + return (EINVAL); + } + /* * Check for generation number matching. Ignore any old messages * except requests for ALIVE since the sender needs those to @@ -118,7 +146,7 @@ __rep_process_message(dbenv, rec, control, eidp) if (rp->gen > gen && rp->rectype != REP_ALIVE && rp->rectype != REP_NEWMASTER) return (__rep_send_message(dbenv, - DB_BROADCAST_EID, REP_MASTER_REQ, NULL, NULL, 0)); + DB_EID_BROADCAST, REP_MASTER_REQ, NULL, NULL, 0)); /* * We need to check if we're in recovery and if we are @@ -162,25 +190,51 @@ __rep_process_message(dbenv, rec, control, eidp) if ((ret = dbenv->log_cursor(dbenv, &logc, 0)) != 0) goto err; memset(&data_dbt, 0, sizeof(data_dbt)); - lsn = rp->lsn; + oldfilelsn = lsn = rp->lsn; for (ret = logc->get(logc, &rp->lsn, &data_dbt, DB_SET); ret == 0; ret = logc->get(logc, &lsn, &data_dbt, DB_NEXT)) { + /* + * lsn.offset will only be 0 if this is the + * beginning of the log; DB_SET, but not DB_NEXT, + * can set the log cursor to [n][0]. + */ if (lsn.offset == 0) + ret = __rep_send_message(dbenv, *eidp, + REP_NEWFILE, &lsn, NULL, 0); + else { /* - * We are starting a new file; we have to - * do that with a NEWFILE message, not a - * regular log message, else we end up with - * two persist structures in the log. + * DB_NEXT will never run into offsets + * of 0; thus, when a log file changes, + * we'll have a real log record with + * some lsn [n][m], and we'll also want to send + * a NEWFILE message with lsn [n][0]. + * So that the client can detect gaps, + * send in the rec parameter the + * last LSN in the old file. */ - ret = __rep_send_message(dbenv, - DB_BROADCAST_EID, REP_NEWFILE, - &lsn, NULL, 0); - else + if (lsn.file != oldfilelsn.file) { + newfilelsn.file = lsn.file; + newfilelsn.offset = 0; + + memset(&lsndbt, 0, sizeof(DBT)); + lsndbt.size = sizeof(DB_LSN); + lsndbt.data = &oldfilelsn; + + if ((ret = __rep_send_message(dbenv, + *eidp, REP_NEWFILE, &newfilelsn, + &lsndbt, 0)) != 0) + break; + } ret = __rep_send_message(dbenv, *eidp, REP_LOG, &lsn, &data_dbt, 0); - if (ret != 0) - break; + } + + /* + * In case we're about to change files and need it + * for a NEWFILE message, save the current LSN. + */ + oldfilelsn = lsn; } if (ret == DB_NOTFOUND) @@ -217,14 +271,36 @@ __rep_process_message(dbenv, rec, control, eidp) if ((ret = dbenv->log_cursor(dbenv, &logc, 0)) != 0) goto err; memset(&data_dbt, 0, sizeof(data_dbt)); - if ((ret = logc->get(logc, &rp->lsn, &data_dbt, DB_SET)) == 0) - ret = __rep_send_message( - dbenv, *eidp, REP_LOG, &rp->lsn, &data_dbt, 0); + lsn = rp->lsn; + if ((ret = logc->get(logc, &rp->lsn, &data_dbt, DB_SET)) == 0) { + /* + * If the log file has changed, we may get back a + * log record with a later LSN than we requested. + * This most likely means that the log file + * changed, so we need to send a NEWFILE message. + */ + if (log_compare(&lsn, &rp->lsn) < 0 && + rp->lsn.offset == 0) + ret = __rep_send_message(dbenv, *eidp, + REP_NEWFILE, &lsn, NULL, 0); + else + ret = __rep_send_message(dbenv, *eidp, + REP_LOG, &rp->lsn, &data_dbt, 0); + } if ((t_ret = logc->close(logc, 0)) != 0 && ret == 0) ret = t_ret; return (ret); case REP_NEWSITE: /* This is a rebroadcast; simply tell the application. */ + if (F_ISSET(dbenv, DB_ENV_REP_MASTER)) { + dblp = dbenv->lg_handle; + lp = dblp->reginfo.primary; + R_LOCK(dbenv, &dblp->reginfo); + lsn = lp->lsn; + R_UNLOCK(dbenv, &dblp->reginfo); + (void)__rep_send_message(dbenv, + *eidp, REP_NEWMASTER, &lsn, NULL, 0); + } return (DB_REP_NEWSITE); case REP_NEWCLIENT: /* @@ -235,7 +311,7 @@ __rep_process_message(dbenv, rec, control, eidp) * record to all the clients. */ if ((ret = __rep_send_message(dbenv, - DB_BROADCAST_EID, REP_NEWSITE, &rp->lsn, rec, 0)) != 0) + DB_EID_BROADCAST, REP_NEWSITE, &rp->lsn, rec, 0)) != 0) goto err; if (F_ISSET(dbenv, DB_ENV_REP_CLIENT)) @@ -251,18 +327,15 @@ __rep_process_message(dbenv, rec, control, eidp) R_UNLOCK(dbenv, &dblp->reginfo); return (__rep_send_message(dbenv, *eidp, REP_NEWMASTER, &lsn, NULL, 0)); - break; case REP_NEWFILE: CLIENT_ONLY(dbenv); return (__rep_apply(dbenv, rp, rec)); - case REP_NEWMASTER: ANYSITE(dbenv); if (F_ISSET(dbenv, DB_ENV_REP_MASTER) && *eidp != dbenv->rep_eid) return (DB_REP_DUPMASTER); return (__rep_new_master(dbenv, rp, *eidp)); - break; case REP_PAGE: /* TODO */ CLIENT_ONLY(dbenv); break; @@ -330,8 +403,9 @@ rep_verify_err: if ((t_ret = logc->close(logc, 0)) != 0 && ret == 0) goto err; case REP_VOTE1: if (F_ISSET(dbenv, DB_ENV_REP_MASTER)) { -#ifdef REP_DEBUG -fprintf(stderr, "%lx Master received vote\n", (long)pthread_self()); +#ifdef DIAGNOSTIC + if (FLD_ISSET(dbenv->verbose, DB_VERB_REPLICATION)) + __db_err(dbenv, "Master received vote"); #endif R_LOCK(dbenv, &dblp->reginfo); lsn = lp->lsn; @@ -349,8 +423,10 @@ fprintf(stderr, "%lx Master received vote\n", (long)pthread_self()); * this site to send its vote again. */ if (!IN_ELECTION(rep)) { -#ifdef REP_DEBUG -fprintf(stderr, "%lx Not in election, but received vote1\n", (long)pthread_self()); +#ifdef DIAGNOSTIC + if (FLD_ISSET(dbenv->verbose, DB_VERB_REPLICATION)) + __db_err(dbenv, + "Not in election, but received vote1"); #endif ret = DB_REP_HOLDELECTION; goto unlock; @@ -388,15 +464,24 @@ fprintf(stderr, "%lx Not in election, but received vote1\n", (long)pthread_self( * Change winners if the incoming record has a higher * priority, or an equal priority but a larger LSN. */ -#ifdef REP_DEBUG -fprintf(stderr, "%lx Existing vote: (eid)%d (pri)%d (gen)%d [%d,%d]\n", (long)pthread_self(), rep->winner, rep->w_priority, rep->w_gen, rep->w_lsn.file, rep->w_lsn.offset); -fprintf(stderr, "%lx Incoming vote: (eid)%d (pri)%d (gen)%d [%d,%d]\n", (long)pthread_self(), *eidp, vi->priority, rp->gen, rp->lsn.file, rp->lsn.offset); +#ifdef DIAGNOSTIC + if (FLD_ISSET(dbenv->verbose, DB_VERB_REPLICATION)) { + __db_err(dbenv, + "Existing vote: (eid)%d (pri)%d (gen)%d [%d,%d]", + rep->winner, rep->w_priority, rep->w_gen, + rep->w_lsn.file, rep->w_lsn.offset); + __db_err(dbenv, + "Incoming vote: (eid)%d (pri)%d (gen)%d [%d,%d]", + *eidp, vi->priority, rp->gen, rp->lsn.file, + rp->lsn.offset); + } #endif if (vi->priority > rep->w_priority || - (vi->priority == rep->w_priority && + (vi->priority != 0 && vi->priority == rep->w_priority && log_compare(&rp->lsn, &rep->w_lsn) > 0)) { -#ifdef REP_DEBUG -fprintf(stderr, "%lx Taking new vote\n", (long)pthread_self()); +#ifdef DIABNOSTIC + if (FLD_ISSET(dbenv->verbose, DB_VERB_REPLICATION)) + __db_err(dbenv, "Accepting new vote"); #endif rep->winner = *eidp; rep->w_priority = vi->priority; @@ -405,54 +490,57 @@ fprintf(stderr, "%lx Taking new vote\n", (long)pthread_self()); } master = rep->winner; lsn = rep->w_lsn; - done = rep->sites == rep->nsites; + done = rep->sites == rep->nsites && rep->w_priority != 0; if (done) { -#ifdef REP_DEBUG -fprintf(stderr, "%lx Consider election phase1 done\n", (long)pthread_self()); +#ifdef DIAGNOSTIC + if (FLD_ISSET(dbenv->verbose, DB_VERB_REPLICATION)) { + __db_err(dbenv, "Phase1 election done"); + __db_err(dbenv, "Voting for %d%s", + master, master == rep->eid ? "(self)" : ""); + } #endif F_CLR(rep, REP_F_EPHASE1); F_SET(rep, REP_F_EPHASE2); } + if (done && master == rep->eid) { -#ifdef REP_DEBUG -fprintf(stderr, "%lx Entering phase 2 casting vote for ourselves.\n", -(long)pthread_self()); -#endif rep->votes++; MUTEX_UNLOCK(dbenv, db_rep->mutexp); return (0); } MUTEX_UNLOCK(dbenv, db_rep->mutexp); - if (done) { -#ifdef REP_DEBUG -fprintf(stderr, "%lx Entering phase 2 with voting for %d\n", -(long)pthread_self(), master); -#endif - /* Someone else gets the vote. */ - return (__rep_send_message(dbenv, master, REP_VOTE2, - NULL, NULL, 0)); - } + + /* Vote for someone else. */ + if (done) + return (__rep_send_message(dbenv, + master, REP_VOTE2, NULL, NULL, 0)); + /* Election is still going on. */ break; case REP_VOTE2: - if (F_ISSET(dbenv, DB_ENV_REP_MASTER)) { -#ifdef REP_DEBUG -fprintf(stderr, "%lx Master received vote\n", (long)pthread_self()); +#ifdef DIAGNOSTIC + if (FLD_ISSET(dbenv->verbose, DB_VERB_REPLICATION)) + __db_err(dbenv, "We received a vote%s", + F_ISSET(dbenv, DB_ENV_REP_MASTER) ? + " (master)" : ""); #endif + if (F_ISSET(dbenv, DB_ENV_REP_MASTER)) { R_LOCK(dbenv, &dblp->reginfo); lsn = lp->lsn; R_UNLOCK(dbenv, &dblp->reginfo); return (__rep_send_message(dbenv, *eidp, REP_NEWMASTER, &lsn, NULL, 0)); } -#ifdef REP_DEBUG -fprintf(stderr, "%lx Got a vote\n", (long)pthread_self()); -#endif MUTEX_LOCK(dbenv, db_rep->mutexp, dbenv->lockfhp); - if (!IN_ELECTION(rep) && rep->master_id != DB_INVALID_EID) { -#ifdef REP_DEBUG -fprintf(stderr, "%lx Not in election, but received vote2\n", (long)pthread_self()); + + /* If we have priority 0, we should never get a vote. */ + DB_ASSERT(rep->priority != 0); + + if (!IN_ELECTION(rep) && rep->master_id != DB_EID_INVALID) { +#ifdef DIAGNOSTIC + if (FLD_ISSET(dbenv->verbose, DB_VERB_REPLICATION)) + __db_err(dbenv, "Not in election, got vote"); #endif MUTEX_UNLOCK(dbenv, db_rep->mutexp); return (DB_REP_HOLDELECTION); @@ -461,17 +549,17 @@ fprintf(stderr, "%lx Not in election, but received vote2\n", (long)pthread_self( rep->votes++; done = rep->votes > rep->nsites / 2; if (done) { -#ifdef REP_DEBUG -fprintf(stderr, "%lx Got enough votes to win\n", (long)pthread_self()); -#endif rep->master_id = rep->eid; rep->gen = rep->w_gen + 1; ELECTION_DONE(rep); F_CLR(rep, REP_F_UPGRADE); F_SET(rep, REP_F_MASTER); *eidp = rep->master_id; -#ifdef REP_DEBUG -fprintf(stderr, "%lx Election done; winner is %d\n", (long)pthread_self(), rep->master_id); +#ifdef DIAGNOSTIC + if (FLD_ISSET(dbenv->verbose, DB_VERB_REPLICATION)) + __db_err(dbenv, + "Got enough votes to win; election done; winner is %d", + rep->master_id); #endif } MUTEX_UNLOCK(dbenv, db_rep->mutexp); @@ -479,17 +567,22 @@ fprintf(stderr, "%lx Election done; winner is %d\n", (long)pthread_self(), rep-> R_LOCK(dbenv, &dblp->reginfo); lsn = lp->lsn; R_UNLOCK(dbenv, &dblp->reginfo); + /* Declare me the winner. */ -#ifdef REP_DEBUG -fprintf(stderr, "%lx I won, sending NEWMASTER\n", (long)pthread_self()); +#ifdef DIAGNOSTIC + if (FLD_ISSET(dbenv->verbose, DB_VERB_REPLICATION)) + __db_err(dbenv, "I won, sending NEWMASTER"); #endif - if ((ret = __rep_send_message(dbenv, DB_BROADCAST_EID, + if ((ret = __rep_send_message(dbenv, DB_EID_BROADCAST, REP_NEWMASTER, &lsn, NULL, 0)) != 0) break; return (DB_REP_NEWMASTER); } break; default: + __db_err(dbenv, + "DB_ENV->rep_process_message: unknown replication message: type %lu", + (u_long)rp->rectype); return (EINVAL); } @@ -559,7 +652,7 @@ __rep_apply(dbenv, rp, rec) */ if (cmp == 0) { if (rp->rectype == REP_NEWFILE) { - CHANGE_FILES; +newfile: CHANGE_FILES; } else { ret = __log_put_int(dbenv, &rp->lsn, rec, rp->flags); lp->ready_lsn = lp->lsn; @@ -587,7 +680,7 @@ gap_check: R_UNLOCK(dbenv, &dblp->reginfo); * or removed that record from the database. */ if (log_compare(&lp->ready_lsn, &rp->lsn) == 0) { - if (rp->rectype == REP_NEWFILE) { + if (rp->rectype != REP_NEWFILE) { ret = __log_put_int(dbenv, &rp->lsn, &data_dbt, rp->flags); lp->ready_lsn = lp->lsn; @@ -596,23 +689,63 @@ gap_check: R_UNLOCK(dbenv, &dblp->reginfo); R_UNLOCK(dbenv, &dblp->reginfo); if ((ret = dbc->c_del(dbc, 0)) != 0) goto err; - ret = dbc->c_get(dbc, - &key_dbt, &data_dbt, DB_NEXT); - if (ret != DB_NOTFOUND && ret != 0) - goto err; - lsn = ((REP_CONTROL *)key_dbt.data)->lsn; - if ((ret = dbc->c_close(dbc)) != 0) - goto err; - R_LOCK(dbenv, &dblp->reginfo); - if (ret == DB_NOTFOUND) { - ZERO_LSN(lp->waiting_lsn); + + /* + * If the current rectype is simple, we're + * ready for another record; otherwise, + * don't get one, because we need to + * process the current one now. + */ + if (IS_SIMPLE(rectype)) { + ret = dbc->c_get(dbc, + &key_dbt, &data_dbt, DB_NEXT); + if (ret != DB_NOTFOUND && ret != 0) + goto err; + lsn = + ((REP_CONTROL *)key_dbt.data)->lsn; + if ((ret = dbc->c_close(dbc)) != 0) + goto err; + R_LOCK(dbenv, &dblp->reginfo); + if (ret == DB_NOTFOUND) { + ZERO_LSN(lp->waiting_lsn); + break; + } else + lp->waiting_lsn = lsn; + } else { + R_LOCK(dbenv, &dblp->reginfo); + lp->waiting_lsn = lp->ready_lsn; break; - } else - lp->waiting_lsn = lsn; + } } } } else if (cmp > 0) { /* + * The LSN is higher than the one we were waiting for. + * If it is a NEWFILE message, this may not mean that + * there's a gap; in some cases, NEWFILE messages contain + * the LSN of the beginning of the new file instead + * of the end of the old. + * + * In these cases, the rec DBT will contain the last LSN + * of the old file, so we can tell whether there's a gap. + */ + if (rp->rectype == REP_NEWFILE && + rp->lsn.file == lp->ready_lsn.file + 1 && + rp->lsn.offset == 0) { + DB_ASSERT(rec != NULL && rec->data != NULL && + rec->size == sizeof(DB_LSN)); + memcpy(&lsn, rec->data, sizeof(DB_LSN)); + if (log_compare(&lp->ready_lsn, &lsn) > 0) + /* + * The last LSN in the old file is smaller + * than the one we're expecting, so there's + * no gap--the one we're expecting just + * doesn't exist. + */ + goto newfile; + } + + /* * This record isn't in sequence; add it to the table and * update waiting_lsn if necessary. */ @@ -630,8 +763,11 @@ gap_check: R_UNLOCK(dbenv, &dblp->reginfo); &next_lsn, NULL, 0); R_LOCK(dbenv, &dblp->reginfo); if (ret == 0) - if (log_compare(&rp->lsn, &lp->waiting_lsn) < 0) + if (IS_ZERO_LSN(lp->waiting_lsn) || + log_compare(&rp->lsn, &lp->waiting_lsn) < 0) lp->waiting_lsn = rp->lsn; + R_UNLOCK(dbenv, &dblp->reginfo); + return (ret); } R_UNLOCK(dbenv, &dblp->reginfo); if (ret != 0 || cmp < 0 || (cmp == 0 && IS_SIMPLE(rectype))) @@ -728,6 +864,7 @@ __rep_process_txn(dbenv, commit_rec) if (op != TXN_COMMIT) return (0); + memset(&recs, 0, sizeof(recs)); recs.txnid = txn_args->txnid->txnid; if ((ret = dbenv->lock_id(dbenv, &recs.lockid)) != 0) return (ret); @@ -760,7 +897,9 @@ err: if (recs.nalloc != 0) { DB_LOCK_FREE_LOCKER, &req, 1, &lvp)) != 0 && ret == 0) ret = t_ret; __os_free(dbenv, recs.array, recs.nalloc * sizeof(LSN_PAGE)); - } else if ((t_ret = + } + + if ((t_ret = dbenv->lock_id_free(dbenv, recs.lockid)) != 0 && ret == 0) ret = t_ret; @@ -822,7 +961,8 @@ __rep_client_dbinit(dbenv, startup) if ((ret = rep_db->set_bt_compare(rep_db, __rep_bt_cmp)) != 0) goto err; - flags = DB_THREAD | (startup ? DB_CREATE : 0); + flags = (F_ISSET(dbenv, DB_ENV_THREAD) ? DB_THREAD : 0) | + (startup ? DB_CREATE : 0); if ((ret = rep_db->open(rep_db, "__db.rep.db", NULL, DB_BTREE, flags, 0)) != 0) goto err; @@ -855,6 +995,7 @@ __rep_bt_cmp(dbp, dbt1, dbt2) DB *dbp; const DBT *dbt1, *dbt2; { + DB_LSN lsn1, lsn2; REP_CONTROL *rp1, *rp2; COMPQUIET(dbp, NULL); @@ -862,149 +1003,21 @@ __rep_bt_cmp(dbp, dbt1, dbt2) rp1 = dbt1->data; rp2 = dbt2->data; - if (rp1->lsn.file > rp2->lsn.file) + __ua_memcpy(&lsn1, &rp1->lsn, sizeof(DB_LSN)); + __ua_memcpy(&lsn2, &rp2->lsn, sizeof(DB_LSN)); + + if (lsn1.file > lsn2.file) return (1); - if (rp1->lsn.file < rp2->lsn.file) + if (lsn1.file < lsn2.file) return (-1); - if (rp1->lsn.offset > rp2->lsn.offset) + if (lsn1.offset > lsn2.offset) return (1); - if (rp1->lsn.offset < rp2->lsn.offset) + if (lsn1.offset < lsn2.offset) return (-1); return (0); } -/* - * __rep_send_message -- - * This is a wrapper for sending a message. It takes care of constructing - * the REP_CONTROL structure and calling the user's specified send function. - * - * PUBLIC: int __rep_send_message __P((DB_ENV *, int, - * PUBLIC: u_int32_t, DB_LSN *, const DBT *, u_int32_t)); - */ -int -__rep_send_message(dbenv, eid, rtype, lsnp, dbtp, flags) - DB_ENV *dbenv; - int eid; - u_int32_t rtype; - DB_LSN *lsnp; - const DBT *dbtp; - u_int32_t flags; -{ - DB_REP *db_rep; - REP *rep; - DBT cdbt, scrap_dbt; - REP_CONTROL cntrl; - u_int32_t send_flags; - - db_rep = dbenv->rep_handle; - rep = db_rep->region; - - /* Set up control structure. */ - memset(&cntrl, 0, sizeof(cntrl)); - if (lsnp == NULL) - ZERO_LSN(cntrl.lsn); - else - cntrl.lsn = *lsnp; - cntrl.rectype = rtype; - cntrl.flags = flags; - MUTEX_LOCK(dbenv, db_rep->mutexp, dbenv->lockfhp); - cntrl.gen = rep->gen; - MUTEX_UNLOCK(dbenv, db_rep->mutexp); - - memset(&cdbt, 0, sizeof(cdbt)); - cdbt.data = &cntrl; - cdbt.size = sizeof(cntrl); - - /* Don't assume the send function will be tolerant of NULL records. */ - if (dbtp == NULL) { - memset(&scrap_dbt, 0, sizeof(DBT)); - dbtp = &scrap_dbt; - } - - send_flags = (FLUSH_ON_FLAG(flags) ? DB_REP_PERMANENT : 0); - - return (db_rep->rep_send(dbenv, db_rep->rep_send_data, dbtp, &cdbt, - send_flags, eid)); -} - -#ifdef NOTYET -static int __rep_send_file __P((DB_ENV *, DBT *, u_int32_t)); -/* - * __rep_send_file -- - * Send an entire file, one block at a time. - */ -static int -__rep_send_file(dbenv, rec, eid) - DB_ENV *dbenv; - DBT *rec; - u_int32_t eid; -{ - DB *dbp; - DB_LOCK lk; - DB_MPOOLFILE *mpf; - DBC *dbc; - DBT rec_dbt; - PAGE *pagep; - db_pgno_t last_pgno, pgno; - int ret, t_ret; - - dbp = NULL; - dbc = NULL; - pagep = NULL; - mpf = NULL; - LOCK_INIT(lk); - - if ((ret = db_create(&dbp, dbenv, 0)) != 0) - goto err; - - if ((ret = dbp->open(dbp, rec->data, NULL, DB_UNKNOWN, 0, 0)) != 0) - goto err; - - if ((ret = dbp->cursor(dbp, NULL, &dbc, 0)) != 0) - goto err; - /* - * Force last_pgno to some value that will let us read the meta-dat - * page in the following loop. - */ - memset(&rec_dbt, 0, sizeof(rec_dbt)); - last_pgno = 1; - for (pgno = 0; pgno <= last_pgno; pgno++) { - if ((ret = __db_lget(dbc, 0, pgno, DB_LOCK_READ, 0, &lk)) != 0) - goto err; - - if ((ret = mpf->get(mpf, &pgno, 0, &pagep)) != 0) - goto err; - - if (pgno == 0) - last_pgno = ((DBMETA *)pagep)->last_pgno; - - rec_dbt.data = pagep; - rec_dbt.size = dbp->pgsize; - if ((ret = __rep_send_message(dbenv, eid, - REP_FILE, NULL, &rec_dbt, pgno == last_pgno)) != 0) - goto err; - ret = mpf->put(mpf, pagep, 0); - pagep = NULL; - if (ret != 0) - goto err; - ret = __LPUT(dbc, lk); - LOCK_INIT(lk); - if (ret != 0) - goto err; - } - -err: if (LOCK_ISSET(lk) && (t_ret = __LPUT(dbc, lk)) != 0 && ret == 0) - ret = t_ret; - if (dbc != NULL && (t_ret = dbc->c_close(dbc)) != 0 && ret == 0) - ret = t_ret; - if (pagep != NULL && (t_ret = mpf->put(mpf, pagep, 0)) != 0 && ret == 0) - ret = t_ret; - if (dbp != NULL && (t_ret = dbp->close(dbp, 0)) != 0 && ret == 0) - ret = t_ret; - return (ret); -} -#endif diff --git a/db/rep/rep_region.c b/db/rep/rep_region.c index c42b43328..895a8f741 100644 --- a/db/rep/rep_region.c +++ b/db/rep/rep_region.c @@ -7,7 +7,7 @@ #include "db_config.h" #ifndef lint -static const char revid[] = "Id: rep_region.c,v 1.13 2001/10/10 18:32:56 krinsky Exp "; +static const char revid[] = "Id: rep_region.c,v 1.14 2001/10/25 14:08:49 bostic Exp "; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -54,8 +54,8 @@ __rep_region_init(dbenv) goto err; /* We have the region; fill in the values. */ - rep->eid = DB_INVALID_EID; - rep->master_id = DB_INVALID_EID; + rep->eid = DB_EID_INVALID; + rep->master_id = DB_EID_INVALID; rep->gen = 0; } else rep = R_ADDR(infop, renv->rep_off); diff --git a/db/rep/rep_util.c b/db/rep/rep_util.c index d54a14c0f..2b7d9572e 100644 --- a/db/rep/rep_util.c +++ b/db/rep/rep_util.c @@ -8,7 +8,7 @@ #include "db_config.h" #ifndef lint -static const char revid[] = "Id: rep_util.c,v 1.25 2001/10/11 01:07:16 bostic Exp "; +static const char revid[] = "Id: rep_util.c,v 1.29 2001/11/16 10:57:51 krinsky Exp "; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -69,6 +69,61 @@ __rep_check_alloc(dbenv, r, n) } /* + * __rep_send_message -- + * This is a wrapper for sending a message. It takes care of constructing + * the REP_CONTROL structure and calling the user's specified send function. + * + * PUBLIC: int __rep_send_message __P((DB_ENV *, int, + * PUBLIC: u_int32_t, DB_LSN *, const DBT *, u_int32_t)); + */ +int +__rep_send_message(dbenv, eid, rtype, lsnp, dbtp, flags) + DB_ENV *dbenv; + int eid; + u_int32_t rtype; + DB_LSN *lsnp; + const DBT *dbtp; + u_int32_t flags; +{ + DB_REP *db_rep; + REP *rep; + DBT cdbt, scrap_dbt; + REP_CONTROL cntrl; + u_int32_t send_flags; + + db_rep = dbenv->rep_handle; + rep = db_rep->region; + + /* Set up control structure. */ + memset(&cntrl, 0, sizeof(cntrl)); + if (lsnp == NULL) + ZERO_LSN(cntrl.lsn); + else + cntrl.lsn = *lsnp; + cntrl.rectype = rtype; + cntrl.flags = flags; + cntrl.rep_version = DB_REPVERSION; + cntrl.log_version = DB_LOGVERSION; + MUTEX_LOCK(dbenv, db_rep->mutexp, dbenv->lockfhp); + cntrl.gen = rep->gen; + MUTEX_UNLOCK(dbenv, db_rep->mutexp); + + memset(&cdbt, 0, sizeof(cdbt)); + cdbt.data = &cntrl; + cdbt.size = sizeof(cntrl); + + /* Don't assume the send function will be tolerant of NULL records. */ + if (dbtp == NULL) { + memset(&scrap_dbt, 0, sizeof(DBT)); + dbtp = &scrap_dbt; + } + + send_flags = (LF_ISSET(DB_FLUSH) ? DB_REP_PERMANENT : 0); + + return (db_rep->rep_send(dbenv, &cdbt, dbtp, eid, send_flags)); +} + +/* * __rep_new_master -- * Called after a master election to sync back up with a new master. * It's possible that we already know of this new master in which case @@ -284,17 +339,18 @@ __rep_lockpages(dbenv, dtab, key_lsn, max_lsn, recs, lid) if ((ret = dbenv->log_cursor(dbenv, &logc, 0)) != 0) goto err; ret = logc->get(logc, key_lsn, &data_dbt, DB_SET); - if ((t_ret = logc->close(logc, 0)) != 0 && ret == 0) - ret = t_ret; - if (ret != 0) - goto err; /* Save lsn values, since dispatch functions can change them. */ tmp_lsn = *key_lsn; - if ((ret = __db_dispatch(dbenv, dtab, - &data_dbt, &tmp_lsn, DB_TXN_APPLY, t)) != 0) + ret = __db_dispatch(dbenv, + dtab, &data_dbt, &tmp_lsn, DB_TXN_APPLY, t); + + if ((t_ret = logc->close(logc, 0)) != 0 && ret == 0) + ret = t_ret; + if (ret != 0) goto err; } + if (t->npages == 0) goto out; @@ -573,7 +629,7 @@ __rep_send_vote(dbenv, lsnp, nsites, pri) vote_dbt.size = sizeof(vi); return (__rep_send_message(dbenv, - DB_BROADCAST_EID, REP_VOTE1, lsnp, &vote_dbt, 0)); + DB_EID_BROADCAST, REP_VOTE1, lsnp, &vote_dbt, 0)); } /* @@ -605,7 +661,7 @@ __rep_grow_sites(dbenv, nsites) nalloc = 2 * rep->asites; if (nalloc < nsites) nalloc = nsites; - + infop = dbenv->reginfo; renv = infop->primary; MUTEX_LOCK(dbenv, &renv->mutex, dbenv->lockfhp); @@ -621,3 +677,81 @@ __rep_grow_sites(dbenv, nsites) MUTEX_UNLOCK(dbenv, &renv->mutex); return (ret); } + +#ifdef NOTYET +static int __rep_send_file __P((DB_ENV *, DBT *, u_int32_t)); +/* + * __rep_send_file -- + * Send an entire file, one block at a time. + */ +static int +__rep_send_file(dbenv, rec, eid) + DB_ENV *dbenv; + DBT *rec; + u_int32_t eid; +{ + DB *dbp; + DB_LOCK lk; + DB_MPOOLFILE *mpf; + DBC *dbc; + DBT rec_dbt; + PAGE *pagep; + db_pgno_t last_pgno, pgno; + int ret, t_ret; + + dbp = NULL; + dbc = NULL; + pagep = NULL; + mpf = NULL; + LOCK_INIT(lk); + + if ((ret = db_create(&dbp, dbenv, 0)) != 0) + goto err; + + if ((ret = dbp->open(dbp, rec->data, NULL, DB_UNKNOWN, 0, 0)) != 0) + goto err; + + if ((ret = dbp->cursor(dbp, NULL, &dbc, 0)) != 0) + goto err; + /* + * Force last_pgno to some value that will let us read the meta-dat + * page in the following loop. + */ + memset(&rec_dbt, 0, sizeof(rec_dbt)); + last_pgno = 1; + for (pgno = 0; pgno <= last_pgno; pgno++) { + if ((ret = __db_lget(dbc, 0, pgno, DB_LOCK_READ, 0, &lk)) != 0) + goto err; + + if ((ret = mpf->get(mpf, &pgno, 0, &pagep)) != 0) + goto err; + + if (pgno == 0) + last_pgno = ((DBMETA *)pagep)->last_pgno; + + rec_dbt.data = pagep; + rec_dbt.size = dbp->pgsize; + if ((ret = __rep_send_message(dbenv, eid, + REP_FILE, NULL, &rec_dbt, pgno == last_pgno)) != 0) + goto err; + ret = mpf->put(mpf, pagep, 0); + pagep = NULL; + if (ret != 0) + goto err; + ret = __LPUT(dbc, lk); + LOCK_INIT(lk); + if (ret != 0) + goto err; + } + +err: if (LOCK_ISSET(lk) && (t_ret = __LPUT(dbc, lk)) != 0 && ret == 0) + ret = t_ret; + if (dbc != NULL && (t_ret = dbc->c_close(dbc)) != 0 && ret == 0) + ret = t_ret; + if (pagep != NULL && (t_ret = mpf->put(mpf, pagep, 0)) != 0 && ret == 0) + ret = t_ret; + if (dbp != NULL && (t_ret = dbp->close(dbp, 0)) != 0 && ret == 0) + ret = t_ret; + return (ret); +} +#endif diff --git a/db/test/dead007.tcl b/db/test/dead007.tcl index f7fe42c21..9f58c019a 100644 --- a/db/test/dead007.tcl +++ b/db/test/dead007.tcl @@ -3,7 +3,7 @@ # Copyright (c) 1996-2001 # Sleepycat Software. All rights reserved. # -# Id: dead007.tcl,v 1.1 2001/10/10 16:23:48 ubell Exp +# Id: dead007.tcl,v 1.2 2001/10/20 14:21:08 bostic Exp # # TEST dead007 # TEST use timeouts rather than the normal dd algorithm. @@ -31,5 +31,4 @@ proc dead007 { } { set lock_curid $save_curid set lock_maxid $save_maxid - puts "Dead007 -- complete" } diff --git a/db/test/lock004.tcl b/db/test/lock004.tcl index 1976ac7a0..fcbdf25a7 100644 --- a/db/test/lock004.tcl +++ b/db/test/lock004.tcl @@ -3,7 +3,7 @@ # Copyright (c) 1996-2001 # Sleepycat Software. All rights reserved. # -# Id: lock004.tcl,v 11.1 2001/10/10 16:22:10 ubell Exp +# Id: lock004.tcl,v 11.2 2001/10/20 14:24:34 bostic Exp # # TEST lock004 # TEST Test locker ids wraping around. @@ -27,7 +27,7 @@ proc lock004 {} { error_check_good locker1 [is_valid_locker $locker1] TRUE error_check_good lock_id_set \ [$e lock_id_set [expr $lock_maxid - 1] $lock_maxid] 0 - + catch { $e lock_id } locker2 error_check_good locker2 [is_valid_locker $locker2] TRUE catch { $e lock_id } locker3 diff --git a/db/test/rep001.tcl b/db/test/rep001.tcl index 57b9b97fb..f524bfcc9 100644 --- a/db/test/rep001.tcl +++ b/db/test/rep001.tcl @@ -3,7 +3,7 @@ # Copyright (c) 2001 # Sleepycat Software. All rights reserved. # -# Id: rep001.tcl,v 11.2 2001/10/05 02:38:09 bostic Exp +# Id: rep001.tcl,v 11.3 2001/11/16 10:50:12 krinsky Exp # # TEST rep001 # TEST Replication smoke test. @@ -30,7 +30,7 @@ proc rep001 { method args } { # Open a master. repladd 1 - set masterenv [berkdb env -create \ + set masterenv [berkdb env -create -log_max 1000000 \ -home $masterdir -txn -rep_master -rep_transport [list 1 replsend]] error_check_good master_env [is_valid_env $masterenv] TRUE @@ -42,7 +42,7 @@ proc rep001 { method args } { # Run a modified test001 in the master. puts "\tRep001.a: Running test001 in replicated env." - eval rep_test001 $method 1000 "01" -env $masterenv $args + eval rep_test001 $method 10000 "01" -env $masterenv $args # Loop, processing first the master's messages, then the client's, # until both queues are empty. diff --git a/db/test/reputils.tcl b/db/test/reputils.tcl index 71b88135c..d41886a80 100644 --- a/db/test/reputils.tcl +++ b/db/test/reputils.tcl @@ -3,7 +3,7 @@ # Copyright (c) 2001 # Sleepycat Software. All rights reserved. # -# Id: reputils.tcl,v 11.2 2001/10/05 02:38:09 bostic Exp +# Id: reputils.tcl,v 11.3 2001/11/16 00:36:20 krinsky Exp # # Replication testing utilities @@ -91,8 +91,12 @@ proc replprocessqueue { dbenv machid } { { set dbt [$dbc get -next] } { set data [lindex [lindex $dbt 0] 1] - error_check_good process_message [$dbenv rep_process_message \ - [lindex $data 2] [lindex $data 0] [lindex $data 1]] 0 + # XXX + # It would be nice to make sure that NEWMASTER messages + # indicate the right master. We don't have the necessary + # info in here, though. + $dbenv rep_process_message \ + [lindex $data 2] [lindex $data 0] [lindex $data 1] incr nproced diff --git a/db/test/scr001/chk.code b/db/test/scr001/chk.code index 7dd5a549c..00197e954 100644 --- a/db/test/scr001/chk.code +++ b/db/test/scr001/chk.code @@ -1,6 +1,6 @@ #!/bin/sh - # -# Id: chk.code,v 1.8 2001/10/12 17:55:31 bostic Exp +# Id: chk.code,v 1.9 2001/10/17 16:15:22 bostic Exp # # Check to make sure that the code samples in the documents build. @@ -10,7 +10,7 @@ d=../.. echo 'FAIL: cannot find source distribution directory.' exit 1 } -[ -f ../libdb.a ] || make libdb.a || { +[ -f ../libdb.a ] || (cd .. && make libdb.a) || { echo 'FAIL: unable to find or build libdb.a' exit 1 } diff --git a/db/test/scr006/chk.offt b/db/test/scr006/chk.offt index 3dcc181f5..9b23445b7 100644 --- a/db/test/scr006/chk.offt +++ b/db/test/scr006/chk.offt @@ -1,6 +1,6 @@ #!/bin/sh - # -# Id: chk.offt,v 1.8 2001/10/12 17:55:34 bostic Exp +# Id: chk.offt,v 1.9 2001/10/26 13:40:15 bostic Exp # # Make sure that no off_t's have snuck into the release. @@ -23,6 +23,7 @@ sed -e "/#undef off_t/d" \ -e "/os_rw.c:.*(off_t)db_iop->pgno/d" \ -e "/os_seek.c:.*off_t offset;/d" \ -e "/os_seek.c:.*offset = /d" \ + -e "/test_perf\/perf_misc.c:/d" \ -e "/test_server\/dbs.c:/d" \ -e "/test_vxworks\/vx_mutex.c:/d" > $t diff --git a/db/test/scr010/spell.ok b/db/test/scr010/spell.ok index eb69020c8..b3fd9cfbf 100644 --- a/db/test/scr010/spell.ok +++ b/db/test/scr010/spell.ok @@ -24,6 +24,7 @@ CONFIG CdFILTvX DBC DBENV +DBS DBSDIR DBT DBTYPE @@ -32,6 +33,7 @@ DONOTINDEX DS DUP DUPMASTER +DUPSORT Db DbAppendRecno DbBtreeCompare @@ -107,6 +109,7 @@ Ll LockExample LogRegister LpRsS +LprRsS MEM MMDDhhmm MPOOL @@ -186,12 +189,14 @@ VM VX Vv VvW +VvXxZ Vvw Vx VxWorks Waitsfor XA XxZ +YIELDCPU YY abcdef abs @@ -295,11 +300,13 @@ dirfno dist dists dlen +ds dsize dup dup'ed dupcompare dups +dupset dupsort efh eid @@ -385,6 +392,7 @@ keylast keyrange killinterval killiteration +killtest klNprRV klNprRs krinsky @@ -453,6 +461,7 @@ minlocks minwrite minwrites mis +mjc mkdir mlock mmap @@ -560,6 +569,7 @@ panic'ing paniccall panicstate parentid +perf perfdb pflag pg @@ -600,6 +610,7 @@ qtest rand rcuradj rdonly +readd readonly realloc rec diff --git a/db/test/scr015/TestLogc.cpp b/db/test/scr015/TestLogc.cpp index d6d0003cd..3a2521ef1 100644 --- a/db/test/scr015/TestLogc.cpp +++ b/db/test/scr015/TestLogc.cpp @@ -4,7 +4,7 @@ * Copyright (c) 2000 * Sleepycat Software. All rights reserved. * - * Id: TestLogc.cpp,v 1.3 2001/10/12 13:02:31 dda Exp + * Id: TestLogc.cpp,v 1.4 2001/10/16 15:40:53 dda Exp */ /* @@ -66,27 +66,36 @@ int main(int argc, char *argv[]) int count = 0; while ((ret = logc->get(&lsn, dbt, flags)) == 0) { - cout << "logc.get: " << count; // We ignore the contents of the log record, - // it's not portable. + // it's not portable. Even the exact count + // is may change when the underlying implementation + // changes, we'll just make sure at the end we saw + // 'enough'. // + // cout << "logc.get: " << count; // show_dbt(cout, dbt); + // cout << "\n"; // - - cout << "\n"; count++; flags = DB_NEXT; } if (ret != DB_NOTFOUND) { - cerr << "*** Failed to get log record, returned: " + cerr << "*** FAIL: logc.get returned: " << DbEnv::strerror(ret) << "\n"; } logc->close(0); + + // There has to be at *least* four log records, + // since we did four separate database operations. + // + if (count < 4) + cerr << "*** FAIL: not enough log records\n"; + cout << "TestLogc done.\n"; } catch (DbException &dbe) { - cerr << "Db Exception: " << dbe.what(); + cerr << "*** FAIL: " << dbe.what() <<"\n"; } return 0; } diff --git a/db/test/scr015/TestLogc.testout b/db/test/scr015/TestLogc.testout index 858947464..afac3af7e 100644 --- a/db/test/scr015/TestLogc.testout +++ b/db/test/scr015/TestLogc.testout @@ -1,18 +1 @@ -logc.get: 0 -logc.get: 1 -logc.get: 2 -logc.get: 3 -logc.get: 4 -logc.get: 5 -logc.get: 6 -logc.get: 7 -logc.get: 8 -logc.get: 9 -logc.get: 10 -logc.get: 11 -logc.get: 12 -logc.get: 13 -logc.get: 14 -logc.get: 15 -logc.get: 16 TestLogc done. diff --git a/db/test/scr015/chk.cxxtests b/db/test/scr015/chk.cxxtests index 84b7901aa..702ee5710 100644 --- a/db/test/scr015/chk.cxxtests +++ b/db/test/scr015/chk.cxxtests @@ -1,11 +1,10 @@ #!/bin/sh - # -# Id: chk.cxxtests,v 1.2 2001/10/12 13:02:31 dda Exp +# Id: chk.cxxtests,v 1.3 2001/10/23 21:23:04 dda Exp # # Check to make sure that regression tests for C++ run. TEST_CXX_SRCDIR=../test/scr015 # must be a relative directory -CXX=${CXX:-c++} # All paths must be relative to a subdirectory of the build directory LIBS="-L.. -ldb -ldb_cxx" @@ -30,6 +29,8 @@ cd .. echo 'FAIL: unable to build libdb_cxx.a' exit 1 } +CXX=`sed -e '/^CXX=/!d' -e 's/^CXX=//' -e 's/.*mode=compile *//' Makefile` +echo " ====== cxx tests using $CXX" testnames=`cd $TEST_CXX_SRCDIR; ls *.cpp | sed -e 's/\.cpp$//'` for testname in $testnames; do diff --git a/db/test/scr016/TestLogc.java b/db/test/scr016/TestLogc.java index a484ee763..cb3df6280 100644 --- a/db/test/scr016/TestLogc.java +++ b/db/test/scr016/TestLogc.java @@ -4,7 +4,7 @@ * Copyright (c) 1997, 1998, 1999, 2000 * Sleepycat Software. All rights reserved. * - * Id: TestLogc.java,v 1.4 2001/10/12 13:02:33 dda Exp + * Id: TestLogc.java,v 1.5 2001/10/16 15:40:54 dda Exp */ /* @@ -47,28 +47,38 @@ public class TestLogc int count = 0; while ((ret = logc.get(lsn, dbt, flags)) == 0) { - System.out.println("logc.get: " + count); // We ignore the contents of the log record, - // it's not portable. + // it's not portable. Even the exact count + // is may change when the underlying implementation + // changes, we'll just make sure at the end we saw + // 'enough'. // + // System.out.println("logc.get: " + count); // System.out.println(showDbt(dbt)); // count++; flags = Db.DB_NEXT; } if (ret != Db.DB_NOTFOUND) { - System.err.println("*** Failed to get log record, returned: " + + System.err.println("*** FAIL: logc.get returned: " + DbEnv.strerror(ret)); } logc.close(0); + + // There has to be at *least* four log records, + // since we did four separate database operations. + // + if (count < 4) + System.out.println("*** FAIL: not enough log records"); + System.out.println("TestLogc done."); } catch (DbException dbe) { - System.err.println("Db Exception: " + dbe); + System.err.println("*** FAIL: Db Exception: " + dbe); } catch (FileNotFoundException fnfe) { - System.err.println("FileNotFoundException: " + fnfe); + System.err.println("*** FAIL: FileNotFoundException: " + fnfe); } } diff --git a/db/test/scr016/TestLogc.testout b/db/test/scr016/TestLogc.testout index 858947464..afac3af7e 100644 --- a/db/test/scr016/TestLogc.testout +++ b/db/test/scr016/TestLogc.testout @@ -1,18 +1 @@ -logc.get: 0 -logc.get: 1 -logc.get: 2 -logc.get: 3 -logc.get: 4 -logc.get: 5 -logc.get: 6 -logc.get: 7 -logc.get: 8 -logc.get: 9 -logc.get: 10 -logc.get: 11 -logc.get: 12 -logc.get: 13 -logc.get: 14 -logc.get: 15 -logc.get: 16 TestLogc done. diff --git a/db/test/shelltest.tcl b/db/test/shelltest.tcl index 97c215acc..ad3c88086 100644 --- a/db/test/shelltest.tcl +++ b/db/test/shelltest.tcl @@ -3,7 +3,7 @@ # Copyright (c) 2001 # Sleepycat Software. All rights reserved. # -# Id: shelltest.tcl,v 1.13 2001/10/12 15:54:53 bostic Exp +# Id: shelltest.tcl,v 1.15 2001/11/03 18:43:48 bostic Exp # # TEST scr### # TEST The scr### directories are shell scripts that test a variety of @@ -55,7 +55,7 @@ proc shelltest_copy { fromdir todir } { } proc shelltest_run { sh srcdir test testdir } { - puts "Running shell script $test..." + puts "Running shell script $srcdir ($test)..." set ret [catch {exec $sh -c "cd $testdir && sh $test" >&@ stdout} res] @@ -81,3 +81,4 @@ proc scr014 {} { shelltest 14 } proc scr015 {} { shelltest 15 } proc scr016 {} { shelltest 16 } proc scr017 {} { shelltest 17 } +proc scr018 {} { shelltest 18 } |