From 1f70e1ea8280242937e42514e140f4e467e09404 Mon Sep 17 00:00:00 2001 From: Paul Marquess Date: Tue, 16 Dec 1997 22:25:29 +0000 Subject: [PATCH] Upgrade DB_File to 1.56: Subject: DB_File-1.56 for _55 p4raw-id: //depot/perl@372 --- Configure | 40 ++- ext/DB_File/DB_File.pm | 317 ++++++++++-------------- ext/DB_File/DB_File.xs | 628 ++++++++++++++++++++++++++++++++++++++---------- ext/DB_File/Makefile.PL | 6 +- ext/DB_File/typemap | 9 +- t/lib/db-btree.t | 4 +- 6 files changed, 675 insertions(+), 329 deletions(-) diff --git a/Configure b/Configure index 934958b..daf4d0a 100755 --- a/Configure +++ b/Configure @@ -8273,7 +8273,7 @@ eval $inhdr case "$i_db" in $define) - : Check db version. We can not use version 2. + : Check db version. echo " " echo "Checking Berkeley DB version ..." >&4 $cat >try.c < main() { -#ifdef DB_VERSION_MAJOR /* DB version >= 2: not yet. */ - printf("You have Berkeley DB Version %d.%d\n", - DB_VERSION_MAJOR, DB_VERSION_MINOR); - printf("Perl currently only supports up to version 1.86.\n"); - exit(2); +#ifdef DB_VERSION_MAJOR /* DB version >= 2 */ + int Major, Minor, Patch ; + (void)db_version(&Major, &Minor, &Patch) ; + printf("You have Berkeley DB Version 2 or greater\n"); + + printf("db.h is from Berkeley DB Version %d.%d.%d\n", + DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH); + printf("libdb is from Berkeley DB Version %d.%d.%d\n", + Major, Minor, Patch) ; + + /* check that db.h & libdb are compatible */ + if (DB_VERSION_MAJOR != Major || DB_VERSION_MINOR != Minor || DB_VERSION_PATCH != Patch) { + printf("db.h and libdb are incompatible\n") ; + exit(3); + } + + printf("db.h and libdb are compatible\n") ; + /* needs to be >= 2.05 */ + if (DB_VERSION_MAJOR == 2 && DB_VERSION_MINOR == 0 && DB_VERSION_PATCH < 5) { + printf("but Perl needs Berkeley DB 2.0.5 or greater\n") ; + exit(2); + } + + exit(0); #else #if defined(_DB_H_) && defined(BTREEMAGIC) && defined(HASHMAGIC) + printf("You have Berkeley DB Version 1\n"); exit(0); /* DB version < 2: the coast is clear. */ #else exit(1); /* not Berkeley DB? */ @@ -8301,7 +8321,7 @@ main() } EOCP if $cc $optimize $ccflags $ldflags -o try try.c $libs && ./try; then - echo 'Looks OK. (Perl supports up to version 1.86).' >&4 + echo 'Looks OK.' >&4 else echo "I can't use Berkeley DB with your . I'll disable Berkeley DB." >&4 i_db=$undef @@ -8332,6 +8352,8 @@ define) #endif #include #include + +#ifndef DB_VERSION_MAJOR u_int32_t hash_cb (ptr, size) const void *ptr; size_t size; @@ -8342,6 +8364,7 @@ main() { info.hash = hash_cb; } +#endif EOCP if $cc $ccflags -c try.c >try.out 2>&1 ; then if $contains warning try.out >>/dev/null 2>&1 ; then @@ -8374,6 +8397,8 @@ define) #endif #include #include + +#ifndef DB_VERSION_MAJOR size_t prefix_cb (key1, key2) const DBT *key1; const DBT *key2; @@ -8384,6 +8409,7 @@ main() { info.prefix = prefix_cb; } +#endif EOCP if $cc $ccflags -c try.c >try.out 2>&1 ; then if $contains warning try.out >>/dev/null 2>&1 ; then diff --git a/ext/DB_File/DB_File.pm b/ext/DB_File/DB_File.pm index 9ed5185..d08b21c 100644 --- a/ext/DB_File/DB_File.pm +++ b/ext/DB_File/DB_File.pm @@ -1,8 +1,8 @@ # DB_File.pm -- Perl 5 interface to Berkeley DB # # written by Paul Marquess (pmarquess@bfsec.bt.co.uk) -# last modified 8th Oct 1997 -# version 1.16 +# last modified 20th Nov 1997 +# version 1.56 # # Copyright (c) 1995, 1996, 1997 Paul Marquess. All rights reserved. # This program is free software; you can redistribute it and/or @@ -141,11 +141,11 @@ sub TIEHASH package DB_File ; use strict; -use vars qw($VERSION @ISA @EXPORT $AUTOLOAD $DB_BTREE $DB_HASH $DB_RECNO) ; +use vars qw($VERSION @ISA @EXPORT $AUTOLOAD $DB_BTREE $DB_HASH $DB_RECNO $db_version) ; use Carp; -$VERSION = "1.15" ; +$VERSION = "1.56" ; #typedef enum { DB_BTREE, DB_HASH, DB_RECNO } DBTYPE; $DB_BTREE = new DB_File::BTREEINFO ; @@ -212,13 +212,25 @@ sub AUTOLOAD { eval { - # Make all Fcntl O_XXX constants available for importing - require Fcntl; - my @O = grep /^O_/, @Fcntl::EXPORT; - Fcntl->import(@O); # first we import what we want to export - push(@EXPORT, @O); + # Make all Fcntl O_XXX constants available for importing + require Fcntl; + my @O = grep /^O_/, @Fcntl::EXPORT; + Fcntl->import(@O); # first we import what we want to export + push(@EXPORT, @O); }; +## import borrowed from IO::File +## exports Fcntl constants if available. +#sub import { +# my $pkg = shift; +# my $callpkg = caller; +# Exporter::export $pkg, $callpkg, @_; +# eval { +# require Fcntl; +# Exporter::export 'Fcntl', $callpkg, '/^O_/'; +# }; +#} + bootstrap DB_File $VERSION; # Preloaded methods go here. Autoload methods go after __END__, and are @@ -232,6 +244,14 @@ sub tie_hash_or_array $arg[4] = tied %{ $arg[4] } if @arg >= 5 && ref $arg[4] && $arg[4] =~ /=HASH/ && tied %{ $arg[4] } ; + # make recno in Berkeley DB version 2 work like recno in version 1. + if ($db_version > 1 and defined $arg[4] and $arg[4] =~ /RECNO/ and + $arg[1] and ! -e $arg[1]) { + open(FH, ">$arg[1]") or return undef ; + close FH ; + chmod $arg[3] ? $arg[3] : 0666 , $arg[1] ; + } + DoTie_($tieHASH, @arg) ; } @@ -245,6 +265,22 @@ sub TIEARRAY tie_hash_or_array(@_) ; } +sub CLEAR { + my $self = shift; + my $key = "" ; + my $value = "" ; + my $status = $self->seq($key, $value, R_FIRST()); + my @keys; + + while ($status == 0) { + push @keys, $key; + $status = $self->seq($key, $value, R_NEXT()); + } + foreach $key (reverse @keys) { + my $s = $self->del($key); + } +} + sub get_dup { croak "Usage: \$db->get_dup(key [,flag])\n" @@ -288,7 +324,7 @@ __END__ =head1 NAME -DB_File - Perl5 access to Berkeley DB +DB_File - Perl5 access to Berkeley DB version 1.x =head1 SYNOPSIS @@ -323,14 +359,11 @@ DB_File - Perl5 access to Berkeley DB =head1 DESCRIPTION B is a module which allows Perl programs to make use of the -facilities provided by Berkeley DB. If you intend to use this -module you should really have a copy of the Berkeley DB manual pages at -hand. The interface defined here mirrors the Berkeley DB interface -closely. - -Please note that this module will only work with version 1.x of -Berkeley DB. Once Berkeley DB version 2 is released, B will be -upgraded to work with it. +facilities provided by Berkeley DB version 1.x (if you have a newer +version of DB, see L). 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. Berkeley DB is a C library which provides a consistent interface to a number of database formats. B provides an interface to all @@ -371,6 +404,33 @@ number. =back +=head2 Using DB_File with Berkeley DB version 2 + +Although B is intended to be used with Berkeley DB version 1, +it can also be used with version 2. In this case the interface is +limited to the functionality provided by Berkeley DB 1.x. Anywhere the +version 2 interface differs, B arranges for it to work like +version 1. This feature allows B scripts that were built with +version 1 to be migrated to version 2 without any changes. + +If you want to make use of the new features available in Berkeley DB +2.x, use the Perl module B instead. + +At the time of writing this document the B module is still +alpha quality (the version number is < 1.0), and so unsuitable for use +in any serious development work. Once its version number is >= 1.0, it +is considered stable enough for real work. + +B The database file format has changed in Berkeley DB version 2. +If you cannot recreate your databases, you must dump any existing +databases with the C utility that comes with Berkeley DB. +Once you have upgraded DB_File to use Berkeley DB version 2, your +databases can be recreated using C. Refer to the Berkeley DB +documentation for further details. + +Please read L before using version 2.x of Berkeley DB with +DB_File. + =head2 Interface to Berkeley DB B allows access to Berkeley DB files using the tie() mechanism @@ -1537,195 +1597,74 @@ of having a C in all your scripts. =head1 HISTORY -=over - -=item 0.1 - -First Release. - -=item 0.2 - -When B is opening a database file it no longer terminates the -process if I returned an error. This allows file protection -errors to be caught at run time. Thanks to Judith Grass -Egrass@cybercash.comE for spotting the bug. - -=item 0.3 - -Added prototype support for multiple btree compare callbacks. - -=item 1.0 - -B has been in use for over a year. To reflect that, the -version number has been incremented to 1.0. - -Added complete support for multiple concurrent callbacks. - -Using the I method on an empty list didn't work properly. This -has been fixed. - -=item 1.01 - -Fixed a core dump problem with SunOS. - -The return value from TIEHASH wasn't set to NULL when dbopen returned -an error. - -=item 1.02 - -Merged OS/2 specific code into DB_File.xs - -Removed some redundant code in DB_File.xs. - -Documentation update. - -Allow negative subscripts with RECNO interface. - -Changed the default flags from O_RDWR to O_CREAT|O_RDWR. - -The example code which showed how to lock a database needed a call to -C added. Without it the resultant database file was empty. - -Added get_dup method. - -=item 1.03 - -Documentation update. - -B now imports the constants (O_RDWR, O_CREAT etc.) from Fcntl -automatically. - -The standard hash function C is now supported. - -Modified the behavior of get_dup. When it returns an associative -array, the value is the count of the number of matching BTREE values. - -=item 1.04 +Moved to the Changes file. -Minor documentation changes. - -Fixed a bug in hash_cb. Patches supplied by Dave Hammen, -Ehammen@gothamcity.jsc.nasa.govE. - -Fixed a bug with the constructors for DB_File::HASHINFO, -DB_File::BTREEINFO and DB_File::RECNOINFO. Also tidied up the -constructors to make them C<-w> clean. - -Reworked part of the test harness to be more locale friendly. - -=item 1.05 - -Made all scripts in the documentation C and C<-w> clean. - -Added logic to F to allow the module to be built after Perl -is installed. - -=item 1.06 - -Minor namespace cleanup: Localized C. - -=item 1.07 - -Fixed bug with RECNO, where bval wasn't defaulting to "\n". - -=item 1.08 - -Documented operation of bval. - -=item 1.09 - -Minor bug fix in DB_File::HASHINFO, DB_File::RECNOINFO and -DB_File::BTREEINFO. - -Changed default mode to 0666. - -=item 1.10 - -Fixed fd method so that it still returns -1 for in-memory files when db -1.86 is used. - -=item 1.11 - -Documented the untie gotcha. - -=item 1.12 - -Documented the incompatibility with version 2 of Berkeley DB. - -=item 1.13 - -Minor changes to DB_FIle.xs and DB_File.pm - -=item 1.14 - -Made it illegal to tie an associative array to a RECNO database and an -ordinary array to a HASH or BTREE database. +=head1 BUGS -=item 1.15 +Some older versions of Berkeley DB had problems with fixed length +records using the RECNO file format. This problem has been fixed since +version 1.85 of Berkeley DB. -Patch from Gisle Aas to suppress "use of undefined -value" warning with db_get and db_seq. +I am sure there are bugs in the code. If you do find any, or can +suggest any enhancements, I would welcome your comments. -Patch from Gisle Aas to make DB_File export only the O_* -constants from Fcntl. +=head1 AVAILABILITY -Removed the DESTROY method from the DB_File::HASHINFO module. +B comes with the standard Perl source distribution. Look in +the directory F. Given the amount of time between releases +of Perl the version that ships with Perl is quite likely to be out of +date, so the most recent version can always be found on CPAN (see +L for details), in the directory +F. -Previously DB_File hard-wired the class name of any object that it -created to "DB_File". This makes sub-classing difficult. Now DB_File -creats objects in the namespace of the package it has been inherited -into. +This version of B will work with either version 1.x or 2.x of +Berkeley DB, but is limited to the functionality provided by version 1. -=item 1.16 +The official web site for Berkeley DB is +F. The ftp equivalent is +F. Both versions 1 and 2 of Berkeley DB are +available there. -Minor changes to DB_File.xs to support multithreaded perl. +Alternatively, Berkeley DB version 1 is available at your nearest CPAN +archive in F. -=back +If you are running IRIX, then get Berkeley DB version 1 from +F. It has the patches necessary to +compile properly on IRIX 5.3. -=head1 BUGS +=head1 COPYRIGHT -Some older versions of Berkeley DB had problems with fixed length -records using the RECNO file format. The newest version at the time of -writing was 1.85 - this seems to have fixed the problems with RECNO. +Copyright (c) 1997 Paul Marquess. All rights reserved. This program is +free software; you can redistribute it and/or modify it under the same +terms as Perl itself. -I am sure there are bugs in the code. If you do find any, or can -suggest any enhancements, I would welcome your comments. +Although B is covered by the Perl license, the library it +makes use of, namely Berkeley DB, is not. Berkeley DB has its own +copyright and its own license. Please take the time to read it. -=head1 AVAILABILITY +The license for Berkeley DB version 2, and how it relates to DB_File +does need some extra clarification. Here are are few words taken from +the Berkeley DB FAQ regarding the version 2 license: -B comes with the standard Perl source distribution. Look in -the directory F. + The major difference is that the license for DB 2.0, when + downloaded from the net, requires that the software that + uses DB 2.0 be freely redistributable. -This version of B will only work with version 1.x of Berkeley -DB. It is I yet compatible with version 2. +That means that if you want to use DB_File, and you have changed either +the source for Berkeley DB or Perl, then the changes must be freely +available. -Version 1 of Berkeley DB is available at your nearest CPAN archive (see -L for a list) in F, or via the -host F in F. Alternatively, -check out the Berkeley DB home page at F. It -is I under the GPL. +In the case of Perl, the term source refers to the complete source +code for Perl (e.g. sv.c, toke.c, perl.h) and any external modules that +you are using (e.g. DB_File, Tk). -If you are running IRIX, then get Berkeley DB from -F. It has the patches necessary to -compile properly on IRIX 5.3. +Note that any Perl scripts that you write are your property - this +includes scripts that make use of DB_File. Neither the Perl license or +the Berkeley DB license place any restriction on what you have to do +with them. -As of January 1997, version 1.86 of Berkeley DB is available from the -Berkeley DB home page. Although this release does fix a number of bugs -that were present in 1.85 you should be aware of the following -information (taken from the Berkeley DB home page) before you consider -using it: - - DB version 1.86 includes a new implementation of the hash access - method that fixes a variety of hashing problems found in DB version - 1.85. We are making it available as an interim solution until DB - 2.0 is available. - - PLEASE NOTE: the underlying file format for the hash access method - changed between version 1.85 and version 1.86, so you will have to - dump and reload all of your databases to convert from version 1.85 - to version 1.86. If you do not absolutely require the fixes from - version 1.86, we strongly urge you to wait until DB 2.0 is released - before upgrading from 1.85. +If you are in any doubt about the license situation, contact either the +Berkeley DB authors or the author of DB_File. See L<"AUTHOR"> for details. =head1 SEE ALSO diff --git a/ext/DB_File/DB_File.xs b/ext/DB_File/DB_File.xs index b6e8a03..f77757c 100644 --- a/ext/DB_File/DB_File.xs +++ b/ext/DB_File/DB_File.xs @@ -3,8 +3,8 @@ DB_File.xs -- Perl 5 interface to Berkeley DB written by Paul Marquess (pmarquess@bfsec.bt.co.uk) - last modified 8th Oct 1997 - version 1.16 + last modified 20th Nov 1997 + version 1.56 All comments/suggestions/problems are welcome @@ -39,12 +39,19 @@ in-memory files when db 1.86 is used. 1.11 - No change to DB_File.xs 1.12 - No change to DB_File.xs - 1.13 - Tidied up a few casts. - 1.14 - Made it illegal to tie an associative array to a RECNO - database and an ordinary array to a HASH or BTREE database. - 1.15 - Patch from Gisle Aas to suppress "use of + 1.13 - Tidied up a few casts. + 1.14 - Made it illegal to tie an associative array to a RECNO + database and an ordinary array to a HASH or BTREE database. + 1.50 - Make work with both DB 1.x or DB 2.x + 1.51 - Fixed a bug in mapping 1.x O_RDONLY flag to 2.x DB_RDONLY equivalent + 1.52 - Patch from Gisle Aas to suppress "use of undefined value" warning with db_get and db_seq. - 1.16 - Minor additions to DB_File.xs to support multithreaded perl. + 1.53 - Added DB_RENUMBER to flags for recno. + 1.54 - Fixed bug in the fd method + 1.55 - Fix for AIX from Jarkko Hietaniemi + 1.56 - No change to DB_File.xs + + */ @@ -55,15 +62,94 @@ /* Being the Berkeley DB we prefer the (which will be * shortly #included by the ) __attribute__ to the possibly * already defined __attribute__, for example by GNUC or by Perl. */ + #undef __attribute__ #include -/* #ifdef DB_VERSION_MAJOR */ -/* #include */ -/* #endif */ #include +/* #define TRACE */ + + + +#ifdef DB_VERSION_MAJOR + +/* map version 2 features & constants onto their version 1 equivalent */ + +#ifdef DB_Prefix_t +#undef DB_Prefix_t +#endif +#define DB_Prefix_t size_t + +#ifdef DB_Hash_t +#undef DB_Hash_t +#endif +#define DB_Hash_t u_int32_t + +/* DBTYPE stays the same */ +/* HASHINFO, RECNOINFO and BTREEINFO map to DB_INFO */ +typedef DB_INFO INFO ; + +/* version 2 has db_recno_t in place of recno_t */ +typedef db_recno_t recno_t; + + +#define R_CURSOR DB_SET_RANGE +#define R_FIRST DB_FIRST +#define R_IAFTER DB_AFTER +#define R_IBEFORE DB_BEFORE +#define R_LAST DB_LAST +#define R_NEXT DB_NEXT +#define R_NOOVERWRITE DB_NOOVERWRITE +#define R_PREV DB_PREV +#define R_SETCURSOR 0 +#define R_RECNOSYNC 0 +#define R_FIXEDLEN DB_FIXEDLEN +#define R_DUP DB_DUP + +#define db_HA_hash h_hash +#define db_HA_ffactor h_ffactor +#define db_HA_nelem h_nelem +#define db_HA_bsize db_pagesize +#define db_HA_cachesize db_cachesize +#define db_HA_lorder db_lorder + +#define db_BT_compare bt_compare +#define db_BT_prefix bt_prefix +#define db_BT_flags flags +#define db_BT_psize db_pagesize +#define db_BT_cachesize db_cachesize +#define db_BT_lorder db_lorder +#define db_BT_maxkeypage +#define db_BT_minkeypage + + +#define db_RE_reclen re_len +#define db_RE_flags flags +#define db_RE_bval re_pad +#define db_RE_bfname re_source +#define db_RE_psize db_pagesize +#define db_RE_cachesize db_cachesize +#define db_RE_lorder db_lorder + +#define TXN NULL, + +#define do_SEQ(db, key, value, flag) (db->cursor->c_get)(db->cursor, &key, &value, flag) + + +#define DBT_flags(x) x.flags = 0 +#define DB_flags(x, v) x |= v + +#else /* db version 1.x */ + +typedef union INFO { + HASHINFO hash ; + RECNOINFO recno ; + BTREEINFO btree ; + } INFO ; + + #ifdef mDB_Prefix_t #ifdef DB_Prefix_t #undef DB_Prefix_t @@ -78,11 +164,63 @@ #define DB_Hash_t mDB_Hash_t #endif -union INFO { - HASHINFO hash ; - RECNOINFO recno ; - BTREEINFO btree ; - } ; +#define db_HA_hash hash.hash +#define db_HA_ffactor hash.ffactor +#define db_HA_nelem hash.nelem +#define db_HA_bsize hash.bsize +#define db_HA_cachesize hash.cachesize +#define db_HA_lorder hash.lorder + +#define db_BT_compare btree.compare +#define db_BT_prefix btree.prefix +#define db_BT_flags btree.flags +#define db_BT_psize btree.psize +#define db_BT_cachesize btree.cachesize +#define db_BT_lorder btree.lorder +#define db_BT_maxkeypage btree.maxkeypage +#define db_BT_minkeypage btree.minkeypage + +#define db_RE_reclen recno.reclen +#define db_RE_flags recno.flags +#define db_RE_bval recno.bval +#define db_RE_bfname recno.bfname +#define db_RE_psize recno.psize +#define db_RE_cachesize recno.cachesize +#define db_RE_lorder recno.lorder + +#define TXN + +#define do_SEQ(db, key, value, flag) (db->dbp->seq)(db->dbp, &key, &value, flag) +#define DBT_flags(x) +#define DB_flags(x, v) + +#endif /* db version 1 */ + + + +#define db_DELETE(db, key, flags) ((db->dbp)->del)(db->dbp, TXN &key, flags) +#define db_STORE(db, key, value, flags) ((db->dbp)->put)(db->dbp, TXN &key, &value, flags) +#define db_FETCH(db, key, flags) ((db->dbp)->get)(db->dbp, TXN &key, &value, flags) + +#define db_sync(db, flags) ((db->dbp)->sync)(db->dbp, flags) +#define db_get(db, key, value, flags) ((db->dbp)->get)(db->dbp, TXN &key, &value, flags) +#ifdef DB_VERSION_MAJOR +#define db_DESTROY(db) ((db->dbp)->close)(db->dbp, 0) +#define db_close(db) ((db->dbp)->close)(db->dbp, 0) +#define db_del(db, key, flags) ((flags & R_CURSOR) \ + ? ((db->cursor)->c_del)(db->cursor, 0) \ + : ((db->dbp)->del)(db->dbp, NULL, &key, flags) ) + +#else + +#define db_DESTROY(db) ((db->dbp)->close)(db->dbp) +#define db_close(db) ((db->dbp)->close)(db->dbp) +#define db_del(db, key, flags) ((db->dbp)->del)(db->dbp, &key, flags) +#define db_put(db, key, value, flags) ((db->dbp)->put)(db->dbp, &key, &value, flags) + +#endif + +#define db_seq(db, key, value, flags) do_SEQ(db, key, value, flags) typedef struct { DBTYPE type ; @@ -91,31 +229,16 @@ typedef struct { SV * prefix ; SV * hash ; int in_memory ; - union INFO info ; + INFO info ; +#ifdef DB_VERSION_MAJOR + DBC * cursor ; +#endif } DB_File_type; typedef DB_File_type * DB_File ; typedef DBT DBTKEY ; -/* #define TRACE */ - -#define db_DESTROY(db) ((db->dbp)->close)(db->dbp) -#define db_DELETE(db, key, flags) ((db->dbp)->del)(db->dbp, &key, flags) -#define db_STORE(db, key, value, flags) ((db->dbp)->put)(db->dbp, &key, &value, flags) -#define db_FETCH(db, key, flags) ((db->dbp)->get)(db->dbp, &key, &value, flags) - -#define db_close(db) ((db->dbp)->close)(db->dbp) -#define db_del(db, key, flags) ((db->dbp)->del)(db->dbp, &key, flags) -#define db_fd(db) (db->in_memory \ - ? -1 \ - : ((db->dbp)->fd)(db->dbp) ) -#define db_put(db, key, value, flags) ((db->dbp)->put)(db->dbp, &key, &value, flags) -#define db_get(db, key, value, flags) ((db->dbp)->get)(db->dbp, &key, &value, flags) -#define db_seq(db, key, value, flags) ((db->dbp)->seq)(db->dbp, &key, &value, flags) -#define db_sync(db, flags) ((db->dbp)->sync)(db->dbp, flags) - - #define OutputValue(arg, name) \ { if (RETVAL == 0) { \ sv_setpvn(arg, name.data, name.size) ; \ @@ -123,7 +246,7 @@ typedef DBT DBTKEY ; } #define OutputKey(arg, name) \ - { if (RETVAL == 0) \ + { if (RETVAL == 0) \ { \ if (db->type != DB_RECNO) { \ sv_setpvn(arg, name.data, name.size); \ @@ -135,9 +258,65 @@ typedef DBT DBTKEY ; /* Internal Global Data */ static recno_t Value ; -static DB_File CurrentDB ; static recno_t zero = 0 ; -static DBTKEY empty = { &zero, sizeof(recno_t) } ; +static DB_File CurrentDB ; +static DBTKEY empty ; + +#ifdef DB_VERSION_MAJOR + +static int +db_put(db, key, value, flags) +DB_File db ; +DBTKEY key ; +DBT value ; +u_int flags ; + +{ + int status ; + + if (flags & R_CURSOR) { + status = ((db->cursor)->c_del)(db->cursor, 0); + if (status != 0) + return status ; + + flags &= ~R_CURSOR ; + } + + return ((db->dbp)->put)(db->dbp, NULL, &key, &value, flags) ; + +} + +#endif /* DB_VERSION_MAJOR */ + +static void +GetVersionInfo() +{ + SV * ver_sv = perl_get_sv("DB_File::db_version", TRUE) ; +#ifdef DB_VERSION_MAJOR + int Major, Minor, Patch ; + + (void)db_version(&Major, &Minor, &Patch) ; + + /* check that libdb is recent enough */ + if (Major == 2 && Minor == 0 && Patch < 5) + croak("DB_File needs Berkeley DB 2.0.5 or greater, you have %d.%d.%d\n", + Major, Minor, Patch) ; + +#if PATCHLEVEL > 3 + sv_setpvf(ver_sv, "%d.%d", Major, Minor) ; +#else + { + char buffer[40] ; + sprintf(buffer, "%d.%d", Major, Minor) ; + sv_setpv(ver_sv, buffer) ; + } +#endif + +#else + sv_setiv(ver_sv, 1) ; +#endif + +} static int @@ -276,45 +455,50 @@ size_t size ; static void PrintHash(hash) -HASHINFO * hash ; +INFO * hash ; { printf ("HASH Info\n") ; - printf (" hash = %s\n", (hash->hash != NULL ? "redefined" : "default")) ; - printf (" bsize = %d\n", hash->bsize) ; - printf (" ffactor = %d\n", hash->ffactor) ; - printf (" nelem = %d\n", hash->nelem) ; - printf (" cachesize = %d\n", hash->cachesize) ; - printf (" lorder = %d\n", hash->lorder) ; + printf (" hash = %s\n", + (hash->db_HA_hash != NULL ? "redefined" : "default")) ; + printf (" bsize = %d\n", hash->db_HA_bsize) ; + printf (" ffactor = %d\n", hash->db_HA_ffactor) ; + printf (" nelem = %d\n", hash->db_HA_nelem) ; + printf (" cachesize = %d\n", hash->db_HA_cachesize) ; + printf (" lorder = %d\n", hash->db_HA_lorder) ; } static void PrintRecno(recno) -RECNOINFO * recno ; +INFO * recno ; { printf ("RECNO Info\n") ; - printf (" flags = %d\n", recno->flags) ; - printf (" cachesize = %d\n", recno->cachesize) ; - printf (" psize = %d\n", recno->psize) ; - printf (" lorder = %d\n", recno->lorder) ; - printf (" reclen = %lu\n", (unsigned long)recno->reclen) ; - printf (" bval = %d 0x%x\n", recno->bval, recno->bval) ; - printf (" bfname = %d [%s]\n", recno->bfname, recno->bfname) ; + printf (" flags = %d\n", recno->db_RE_flags) ; + printf (" cachesize = %d\n", recno->db_RE_cachesize) ; + printf (" psize = %d\n", recno->db_RE_psize) ; + printf (" lorder = %d\n", recno->db_RE_lorder) ; + printf (" reclen = %ul\n", (unsigned long)recno->db_RE_reclen) ; + printf (" bval = %d 0x%x\n", recno->db_RE_bval, recno->db_RE_bval) ; + printf (" bfname = %d [%s]\n", recno->db_RE_bfname, recno->db_RE_bfname) ; } static void PrintBtree(btree) -BTREEINFO * btree ; +INFO * btree ; { printf ("BTREE Info\n") ; - printf (" compare = %s\n", (btree->compare ? "redefined" : "default")) ; - printf (" prefix = %s\n", (btree->prefix ? "redefined" : "default")) ; - printf (" flags = %d\n", btree->flags) ; - printf (" cachesize = %d\n", btree->cachesize) ; - printf (" psize = %d\n", btree->psize) ; - printf (" maxkeypage = %d\n", btree->maxkeypage) ; - printf (" minkeypage = %d\n", btree->minkeypage) ; - printf (" lorder = %d\n", btree->lorder) ; + printf (" compare = %s\n", + (btree->db_BT_compare ? "redefined" : "default")) ; + printf (" prefix = %s\n", + (btree->db_BT_prefix ? "redefined" : "default")) ; + printf (" flags = %d\n", btree->db_BT_flags) ; + printf (" cachesize = %d\n", btree->db_BT_cachesize) ; + printf (" psize = %d\n", btree->db_BT_psize) ; +#ifndef DB_VERSION_MAJOR + printf (" maxkeypage = %d\n", btree->db_BT_maxkeypage) ; + printf (" minkeypage = %d\n", btree->db_BT_minkeypage) ; +#endif + printf (" lorder = %d\n", btree->db_BT_lorder) ; } #else @@ -328,16 +512,18 @@ BTREEINFO * btree ; static I32 GetArrayLength(db) -DB * db ; +DB_File db ; { DBT key ; DBT value ; int RETVAL ; - RETVAL = (db->seq)(db, &key, &value, R_LAST) ; + DBT_flags(key) ; + DBT_flags(value) ; + RETVAL = do_SEQ(db, key, value, R_LAST) ; if (RETVAL == 0) RETVAL = *(I32 *)key.data ; - else if (RETVAL == 1) /* No key means empty file */ + else /* No key means empty file */ RETVAL = 0 ; return ((I32)RETVAL) ; @@ -350,7 +536,7 @@ I32 value ; { if (value < 0) { /* Get the length of the array */ - I32 length = GetArrayLength(db->dbp) ; + I32 length = GetArrayLength(db) ; /* check for attempt to write before start of array */ if (length + value + 1 <= 0) @@ -376,7 +562,10 @@ SV * sv ; HV * action ; DB_File RETVAL = (DB_File)safemalloc(sizeof(DB_File_type)) ; void * openinfo = NULL ; - union INFO * info = &RETVAL->info ; + INFO * info = &RETVAL->info ; + +/* printf("In ParseOpenInfo name=[%s] flags=[%d] mode = [%d]\n", name, flags, mode) ; */ + Zero(RETVAL, 1, DB_File_type) ; /* Default to HASH */ RETVAL->hash = RETVAL->compare = RETVAL->prefix = NULL ; @@ -412,26 +601,26 @@ SV * sv ; if (svp && SvOK(*svp)) { - info->hash.hash = hash_cb ; + info->db_HA_hash = hash_cb ; RETVAL->hash = newSVsv(*svp) ; } else - info->hash.hash = NULL ; + info->db_HA_hash = NULL ; - svp = hv_fetch(action, "bsize", 5, FALSE); - info->hash.bsize = svp ? SvIV(*svp) : 0; - svp = hv_fetch(action, "ffactor", 7, FALSE); - info->hash.ffactor = svp ? SvIV(*svp) : 0; + info->db_HA_ffactor = svp ? SvIV(*svp) : 0; svp = hv_fetch(action, "nelem", 5, FALSE); - info->hash.nelem = svp ? SvIV(*svp) : 0; + info->db_HA_nelem = svp ? SvIV(*svp) : 0; + svp = hv_fetch(action, "bsize", 5, FALSE); + info->db_HA_bsize = svp ? SvIV(*svp) : 0; + svp = hv_fetch(action, "cachesize", 9, FALSE); - info->hash.cachesize = svp ? SvIV(*svp) : 0; + info->db_HA_cachesize = svp ? SvIV(*svp) : 0; svp = hv_fetch(action, "lorder", 6, FALSE); - info->hash.lorder = svp ? SvIV(*svp) : 0; + info->db_HA_lorder = svp ? SvIV(*svp) : 0; PrintHash(info) ; } @@ -446,38 +635,40 @@ SV * sv ; svp = hv_fetch(action, "compare", 7, FALSE); if (svp && SvOK(*svp)) { - info->btree.compare = btree_compare ; + info->db_BT_compare = btree_compare ; RETVAL->compare = newSVsv(*svp) ; } else - info->btree.compare = NULL ; + info->db_BT_compare = NULL ; svp = hv_fetch(action, "prefix", 6, FALSE); if (svp && SvOK(*svp)) { - info->btree.prefix = btree_prefix ; + info->db_BT_prefix = btree_prefix ; RETVAL->prefix = newSVsv(*svp) ; } else - info->btree.prefix = NULL ; + info->db_BT_prefix = NULL ; svp = hv_fetch(action, "flags", 5, FALSE); - info->btree.flags = svp ? SvIV(*svp) : 0; + info->db_BT_flags = svp ? SvIV(*svp) : 0; svp = hv_fetch(action, "cachesize", 9, FALSE); - info->btree.cachesize = svp ? SvIV(*svp) : 0; + info->db_BT_cachesize = svp ? SvIV(*svp) : 0; +#ifndef DB_VERSION_MAJOR svp = hv_fetch(action, "minkeypage", 10, FALSE); info->btree.minkeypage = svp ? SvIV(*svp) : 0; svp = hv_fetch(action, "maxkeypage", 10, FALSE); info->btree.maxkeypage = svp ? SvIV(*svp) : 0; +#endif svp = hv_fetch(action, "psize", 5, FALSE); - info->btree.psize = svp ? SvIV(*svp) : 0; + info->db_BT_psize = svp ? SvIV(*svp) : 0; svp = hv_fetch(action, "lorder", 6, FALSE); - info->btree.lorder = svp ? SvIV(*svp) : 0; + info->db_BT_lorder = svp ? SvIV(*svp) : 0; PrintBtree(info) ; @@ -490,45 +681,87 @@ SV * sv ; RETVAL->type = DB_RECNO ; openinfo = (void *)info ; + info->db_RE_flags = 0 ; + svp = hv_fetch(action, "flags", 5, FALSE); - info->recno.flags = (u_long) (svp ? SvIV(*svp) : 0); + info->db_RE_flags = (u_long) (svp ? SvIV(*svp) : 0); + + svp = hv_fetch(action, "reclen", 6, FALSE); + info->db_RE_reclen = (size_t) (svp ? SvIV(*svp) : 0); svp = hv_fetch(action, "cachesize", 9, FALSE); - info->recno.cachesize = (u_int) (svp ? SvIV(*svp) : 0); + info->db_RE_cachesize = (u_int) (svp ? SvIV(*svp) : 0); svp = hv_fetch(action, "psize", 5, FALSE); - info->recno.psize = (u_int) (svp ? SvIV(*svp) : 0); + info->db_RE_psize = (u_int) (svp ? SvIV(*svp) : 0); svp = hv_fetch(action, "lorder", 6, FALSE); - info->recno.lorder = (int) (svp ? SvIV(*svp) : 0); - - svp = hv_fetch(action, "reclen", 6, FALSE); - info->recno.reclen = (size_t) (svp ? SvIV(*svp) : 0); + info->db_RE_lorder = (int) (svp ? SvIV(*svp) : 0); + +#ifdef DB_VERSION_MAJOR + info->re_source = name ; + name = NULL ; +#endif + svp = hv_fetch(action, "bfname", 6, FALSE); + if (svp && SvOK(*svp)) { + char * ptr = SvPV(*svp,na) ; +#ifdef DB_VERSION_MAJOR + name = (char*) na ? ptr : NULL ; +#else + info->db_RE_bfname = (char*) (na ? ptr : NULL) ; +#endif + } + else +#ifdef DB_VERSION_MAJOR + name = NULL ; +#else + info->db_RE_bfname = NULL ; +#endif svp = hv_fetch(action, "bval", 4, FALSE); +#ifdef DB_VERSION_MAJOR if (svp && SvOK(*svp)) { + int value ; if (SvPOK(*svp)) - info->recno.bval = (u_char)*SvPV(*svp, na) ; + value = (int)*SvPV(*svp, na) ; else - info->recno.bval = (u_char)(unsigned long) SvIV(*svp) ; + value = SvIV(*svp) ; + + if (info->flags & DB_FIXEDLEN) { + info->re_pad = value ; + info->flags |= DB_PAD ; + } + else { + info->re_delim = value ; + info->flags |= DB_DELIMITER ; + } + + } +#else + if (svp && SvOK(*svp)) + { + if (SvPOK(*svp)) + info->db_RE_bval = (u_char)*SvPV(*svp, na) ; + else + info->db_RE_bval = (u_char)(unsigned long) SvIV(*svp) ; + DB_flags(info->flags, DB_DELIMITER) ; + } else { - if (info->recno.flags & R_FIXEDLEN) - info->recno.bval = (u_char) ' ' ; + if (info->db_RE_flags & R_FIXEDLEN) + info->db_RE_bval = (u_char) ' ' ; else - info->recno.bval = (u_char) '\n' ; + info->db_RE_bval = (u_char) '\n' ; + DB_flags(info->flags, DB_DELIMITER) ; } - - svp = hv_fetch(action, "bfname", 6, FALSE); - if (svp && SvOK(*svp)) { - char * ptr = SvPV(*svp,na) ; - info->recno.bfname = (char*) (na ? ptr : NULL) ; - } - else - info->recno.bfname = NULL ; +#endif +#ifdef DB_RENUMBER + info->flags |= DB_RENUMBER ; +#endif + PrintRecno(info) ; } else @@ -543,7 +776,44 @@ SV * sv ; #endif /* __EMX__ */ #endif /* OS2 */ +#ifdef DB_VERSION_MAJOR + + { + int Flags = 0 ; + int status ; + + /* Map 1.x flags to 2.x flags */ + if ((flags & O_CREAT) == O_CREAT) + Flags |= DB_CREATE ; + +#ifdef O_NONBLOCK + if ((flags & O_NONBLOCK) == O_NONBLOCK) + Flags |= DB_EXCL ; +#endif + +#if O_RDONLY == 0 + if (flags == O_RDONLY) +#else + if (flags & O_RDONLY) == O_RDONLY) +#endif + Flags |= DB_RDONLY ; + +#ifdef O_NONBLOCK + if ((flags & O_TRUNC) == O_TRUNC) + Flags |= DB_TRUNCATE ; +#endif + + status = db_open(name, RETVAL->type, Flags, mode, NULL, openinfo, &RETVAL->dbp) ; + if (status == 0) + status = (RETVAL->dbp->cursor)(RETVAL->dbp, NULL, &RETVAL->cursor) ; + + if (status) + RETVAL->dbp = NULL ; + + } +#else RETVAL->dbp = dbopen(name, flags, mode, RETVAL->type, openinfo) ; +#endif return (RETVAL) ; } @@ -779,12 +1049,6 @@ int arg; case 'Z': break; case '_': - if (strEQ(name, "__R_UNUSED")) -#ifdef __R_UNUSED - return __R_UNUSED; -#else - goto not_there; -#endif break; } errno = EINVAL; @@ -797,6 +1061,15 @@ not_there: MODULE = DB_File PACKAGE = DB_File PREFIX = db_ +BOOT: + { + GetVersionInfo() ; + + empty.data = &zero ; + empty.size = sizeof(recno_t) ; + DBT_flags(empty) ; + } + double constant(name,arg) char * name @@ -840,6 +1113,10 @@ db_DESTROY(db) if (db->prefix) SvREFCNT_dec(db->prefix) ; Safefree(db) ; +#ifdef DB_VERSION_MAJOR + if (RETVAL > 0) + RETVAL = -1 ; +#endif int @@ -859,8 +1136,9 @@ db_EXISTS(db, key) { DBT value ; + DBT_flags(value) ; CurrentDB = db ; - RETVAL = (((db->dbp)->get)(db->dbp, &key, &value, 0) == 0) ; + RETVAL = (((db->dbp)->get)(db->dbp, TXN &key, &value, 0) == 0) ; } OUTPUT: RETVAL @@ -872,12 +1150,14 @@ db_FETCH(db, key, flags=0) u_int flags CODE: { - DBT value ; + DBT value ; + DBT_flags(value) ; CurrentDB = db ; - RETVAL = ((db->dbp)->get)(db->dbp, &key, &value, flags) ; + /* RETVAL = ((db->dbp)->get)(db->dbp, TXN &key, &value, flags) ; */ + RETVAL = db_get(db, key, value, flags) ; ST(0) = sv_newmortal(); - if (RETVAL == 0) + if (RETVAL == 0) sv_setpvn(ST(0), value.data, value.size); } @@ -896,12 +1176,14 @@ db_FIRSTKEY(db) DB_File db CODE: { - DBTKEY key ; + DBTKEY key ; DBT value ; DB * Db = db->dbp ; + DBT_flags(key) ; + DBT_flags(value) ; CurrentDB = db ; - RETVAL = (Db->seq)(Db, &key, &value, R_FIRST) ; + RETVAL = do_SEQ(db, key, value, R_FIRST) ; ST(0) = sv_newmortal(); if (RETVAL == 0) { @@ -921,8 +1203,9 @@ db_NEXTKEY(db, key) DBT value ; DB * Db = db->dbp ; + DBT_flags(value) ; CurrentDB = db ; - RETVAL = (Db->seq)(Db, &key, &value, R_NEXT) ; + RETVAL = do_SEQ(db, key, value, R_NEXT) ; ST(0) = sv_newmortal(); if (RETVAL == 0) { @@ -948,8 +1231,16 @@ unshift(db, ...) int One ; DB * Db = db->dbp ; + DBT_flags(key) ; + DBT_flags(value) ; CurrentDB = db ; +#ifdef DB_VERSION_MAJOR + /* get the first value */ + RETVAL = do_SEQ(db, key, value, DB_FIRST) ; + RETVAL = 0 ; +#else RETVAL = -1 ; +#endif for (i = items-1 ; i > 0 ; --i) { value.data = SvPV(ST(i), na) ; @@ -957,7 +1248,11 @@ unshift(db, ...) One = 1 ; key.data = &One ; key.size = sizeof(int) ; +#ifdef DB_VERSION_MAJOR + RETVAL = (db->cursor->c_put)(db->cursor, &key, &value, DB_BEFORE) ; +#else RETVAL = (Db->put)(Db, &key, &value, R_IBEFORE) ; +#endif if (RETVAL != 0) break; } @@ -974,16 +1269,19 @@ pop(db) DBT value ; DB * Db = db->dbp ; + DBT_flags(key) ; + DBT_flags(value) ; CurrentDB = db ; + /* First get the final value */ - RETVAL = (Db->seq)(Db, &key, &value, R_LAST) ; + RETVAL = do_SEQ(db, key, value, R_LAST) ; ST(0) = sv_newmortal(); /* Now delete it */ if (RETVAL == 0) { /* the call to del will trash value, so take a copy now */ sv_setpvn(ST(0), value.data, value.size); - RETVAL = (Db->del)(Db, &key, R_CURSOR) ; + RETVAL = db_del(db, key, R_CURSOR) ; if (RETVAL != 0) sv_setsv(ST(0), &sv_undef); } @@ -998,16 +1296,18 @@ shift(db) DBTKEY key ; DB * Db = db->dbp ; + DBT_flags(key) ; + DBT_flags(value) ; CurrentDB = db ; /* get the first value */ - RETVAL = (Db->seq)(Db, &key, &value, R_FIRST) ; + RETVAL = do_SEQ(db, key, value, R_FIRST) ; ST(0) = sv_newmortal(); /* Now delete it */ if (RETVAL == 0) { /* the call to del will trash value, so take a copy now */ sv_setpvn(ST(0), value.data, value.size); - RETVAL = (Db->del)(Db, &key, R_CURSOR) ; + RETVAL = db_del(db, key, R_CURSOR) ; if (RETVAL != 0) sv_setsv (ST(0), &sv_undef) ; } @@ -1025,13 +1325,27 @@ push(db, ...) DB * Db = db->dbp ; int i ; + DBT_flags(key) ; + DBT_flags(value) ; CurrentDB = db ; /* Set the Cursor to the Last element */ - RETVAL = (Db->seq)(Db, &key, &value, R_LAST) ; + RETVAL = do_SEQ(db, key, value, R_LAST) ; if (RETVAL >= 0) { if (RETVAL == 1) keyptr = &empty ; +#ifdef DB_VERSION_MAJOR + for (i = 1 ; i < items ; ++i) + { + + ++ (* (int*)key.data) ; + value.data = SvPV(ST(i), na) ; + value.size = na ; + RETVAL = (Db->put)(Db, NULL, &key, &value, 0) ; + if (RETVAL != 0) + break; + } +#else for (i = items - 1 ; i > 0 ; --i) { value.data = SvPV(ST(i), na) ; @@ -1040,6 +1354,7 @@ push(db, ...) if (RETVAL != 0) break; } +#endif } } OUTPUT: @@ -1051,7 +1366,7 @@ length(db) DB_File db CODE: CurrentDB = db ; - RETVAL = GetArrayLength(db->dbp) ; + RETVAL = GetArrayLength(db) ; OUTPUT: RETVAL @@ -1065,8 +1380,17 @@ db_del(db, key, flags=0) DB_File db DBTKEY key u_int flags - INIT: + CODE: CurrentDB = db ; + RETVAL = db_del(db, key, flags) ; +#ifdef DB_VERSION_MAJOR + if (RETVAL > 0) + RETVAL = -1 ; + else if (RETVAL == DB_NOTFOUND) + RETVAL = 1 ; +#endif + OUTPUT: + RETVAL int @@ -1075,9 +1399,18 @@ db_get(db, key, value, flags=0) DBTKEY key DBT value = NO_INIT u_int flags - INIT: + CODE: CurrentDB = db ; + DBT_flags(value) ; + RETVAL = db_get(db, key, value, flags) ; +#ifdef DB_VERSION_MAJOR + if (RETVAL > 0) + RETVAL = -1 ; + else if (RETVAL == DB_NOTFOUND) + RETVAL = 1 ; +#endif OUTPUT: + RETVAL value int @@ -1086,23 +1419,53 @@ db_put(db, key, value, flags=0) DBTKEY key DBT value u_int flags - INIT: + CODE: CurrentDB = db ; + RETVAL = db_put(db, key, value, flags) ; +#ifdef DB_VERSION_MAJOR + if (RETVAL > 0) + RETVAL = -1 ; + else if (RETVAL == DB_KEYEXIST) + RETVAL = 1 ; +#endif OUTPUT: + RETVAL key if (flags & (R_IAFTER|R_IBEFORE)) OutputKey(ST(1), key); int db_fd(db) DB_File db - INIT: + int status = 0 ; + CODE: CurrentDB = db ; +#ifdef DB_VERSION_MAJOR + RETVAL = -1 ; + status = (db->in_memory + ? -1 + : ((db->dbp)->fd)(db->dbp, &RETVAL) ) ; + if (status != 0) + RETVAL = -1 ; +#else + RETVAL = (db->in_memory + ? -1 + : ((db->dbp)->fd)(db->dbp) ) ; +#endif + OUTPUT: + RETVAL int db_sync(db, flags=0) DB_File db u_int flags - INIT: + CODE: CurrentDB = db ; + RETVAL = db_sync(db, flags) ; +#ifdef DB_VERSION_MAJOR + if (RETVAL > 0) + RETVAL = -1 ; +#endif + OUTPUT: + RETVAL int @@ -1111,9 +1474,18 @@ db_seq(db, key, value, flags) DBTKEY key DBT value = NO_INIT u_int flags - INIT: + CODE: CurrentDB = db ; + DBT_flags(value) ; + RETVAL = db_seq(db, key, value, flags); +#ifdef DB_VERSION_MAJOR + if (RETVAL > 0) + RETVAL = -1 ; + else if (RETVAL == DB_NOTFOUND) + RETVAL = 1 ; +#endif OUTPUT: + RETVAL key value diff --git a/ext/DB_File/Makefile.PL b/ext/DB_File/Makefile.PL index 39b8bc7..dbe19f1 100644 --- a/ext/DB_File/Makefile.PL +++ b/ext/DB_File/Makefile.PL @@ -4,9 +4,13 @@ use Config ; # OS2 is a special case, so check for it now. my $OS2 = "-DOS2" if $Config{'osname'} eq 'os2' ; +my $LIB = "-ldb" ; +# so is win32 +$LIB = "-llibdb" if $^O eq 'MSWin32' ; + WriteMakefile( NAME => 'DB_File', - LIBS => ["-L/usr/local/lib -ldb"], + LIBS => ["-L/usr/local/lib $LIB"], MAN3PODS => ' ', # Pods will be built by installman. #INC => '-I/usr/local/include', VERSION_FROM => 'DB_File.pm', diff --git a/ext/DB_File/typemap b/ext/DB_File/typemap index a621224..19b131b 100644 --- a/ext/DB_File/typemap +++ b/ext/DB_File/typemap @@ -1,8 +1,8 @@ -# typemap for Perl 5 interface to Berkeley DB +# typemap for Perl 5 interface to Berkeley # # written by Paul Marquess (pmarquess@bfsec.bt.co.uk) -# last modified 28th June 1996 -# version 0.2 +# last modified 9th Sept 1997 +# version 1.53 # #################################### DB SECTION # @@ -18,15 +18,18 @@ T_dbtkeydatum if (db->type != DB_RECNO) { $var.data = SvPV($arg, na); $var.size = (int)na; + DBT_flags($var); } else { Value = GetRecnoKey(db, SvIV($arg)) ; $var.data = & Value; $var.size = (int)sizeof(recno_t); + DBT_flags($var); } T_dbtdatum $var.data = SvPV($arg, na); $var.size = (int)na; + DBT_flags($var); OUTPUT diff --git a/t/lib/db-btree.t b/t/lib/db-btree.t index c85c22f..ffd8cbb 100755 --- a/t/lib/db-btree.t +++ b/t/lib/db-btree.t @@ -308,7 +308,9 @@ ok(62, $status == 0 ); ok(63, $key eq 'replace key' ); ok(64, $value eq 'replace value' ); $status = $X->get('y', $value) ; -ok(65, $status == 1 ); +ok(65, 1) ; # hard-wire to always pass. the previous test ($status == 1) + # only worked because of a bug in 1.85/6 + # use seq to walk forwards through a file -- 2.7.4