From: Paul Marquess Date: Thu, 9 Sep 1999 11:20:13 +0000 (+0100) Subject: DB_File 1.71 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=039d031f4e1c7ff1bc271958724796969501dded;p=p5sagit%2Fp5-mst-13.2.git DB_File 1.71 To: gsar@ActiveState.com Cc: perl5-porters@perl.org Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB202D49BBE@mbtlipnt02.btlabs.bt.co.uk> p4raw-id: //depot/cfgperl@4113 --- diff --git a/MANIFEST b/MANIFEST index 6bd774f..c007d65 100644 --- a/MANIFEST +++ b/MANIFEST @@ -207,6 +207,7 @@ ext/DB_File/Makefile.PL Berkeley DB extension makefile writer ext/DB_File/dbinfo Berkeley DB database version checker ext/DB_File/hints/dynixptx.pl Hint for DB_File for named architecture ext/DB_File/typemap Berkeley DB extension interface types +ext/DB_File/version.c Berkeley DB extension interface version check ext/Data/Dumper/Changes Data pretty printer, changelog ext/Data/Dumper/Dumper.pm Data pretty printer, module ext/Data/Dumper/Dumper.xs Data pretty printer, externals diff --git a/ext/DB_File/Changes b/ext/DB_File/Changes index 6d374bf..8f36456 100644 --- a/ext/DB_File/Changes +++ b/ext/DB_File/Changes @@ -272,3 +272,10 @@ * Added a BOOT check to test for equivalent versions of db.h & libdb.a/so. +1.71 7th September 1999 + + * Fixed a bug that prevented 1.70 from compiling under win32 + + * Updated to support Berkeley DB 3.x + + * Updated dbinfo for Berkeley DB 3.x file formats. diff --git a/ext/DB_File/DB_File.pm b/ext/DB_File/DB_File.pm index e20a562..44bdad6 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 (Paul.Marquess@btinternet.com) -# last modified 4th August 1999 -# version 1.70 +# last modified 4th September 1999 +# version 1.71 # # Copyright (c) 1995-1999 Paul Marquess. All rights reserved. # This program is free software; you can redistribute it and/or @@ -145,7 +145,7 @@ use vars qw($VERSION @ISA @EXPORT $AUTOLOAD $DB_BTREE $DB_HASH $DB_RECNO $db_ver use Carp; -$VERSION = "1.70" ; +$VERSION = "1.71" ; #typedef enum { DB_BTREE, DB_HASH, DB_RECNO } DBTYPE; $DB_BTREE = new DB_File::BTREEINFO ; @@ -421,10 +421,10 @@ DB_File - Perl5 access to Berkeley DB version 1.x B 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). 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. +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 @@ -465,32 +465,33 @@ number. =back -=head2 Using DB_File with Berkeley DB version 2 +=head2 Using DB_File with Berkeley DB version 2 or 3 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 +it can also be used with version 2.or 3 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. +version 2 or 3 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 or 3 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. +2.x or 3.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 rebuilt DB_File to use Berkeley DB version 2, your +B 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 the C 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. Refer to the Berkeley DB documentation for further details. -Please read L<"COPYRIGHT"> before using version 2.x of Berkeley DB with -DB_File. +Please read L<"COPYRIGHT"> before using version 2.x or 3.x of Berkeley +DB with DB_File. =head2 Interface to Berkeley DB @@ -1940,11 +1941,12 @@ date, so the most recent version can always be found on CPAN (see L for details), in the directory F. -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. +This version of B will work with either version 1.x, 2.x or +3.x of Berkeley DB, but is limited to the functionality provided by +version 1. The official web site for Berkeley DB is F. -Both versions 1 and 2 of Berkeley DB are available there. +All versions of Berkeley DB are available there. Alternatively, Berkeley DB version 1 is available at your nearest CPAN archive in F. diff --git a/ext/DB_File/Makefile.PL b/ext/DB_File/Makefile.PL index 1a13e0b..a247924 100644 --- a/ext/DB_File/Makefile.PL +++ b/ext/DB_File/Makefile.PL @@ -14,7 +14,15 @@ WriteMakefile( MAN3PODS => {}, # Pods will be built by installman. #INC => '-I/usr/local/include', VERSION_FROM => 'DB_File.pm', + OBJECT => 'version$(OBJ_EXT) DB_File$(OBJ_EXT)', XSPROTOARG => '-noprototypes', DEFINE => "$OS2", ); +sub MY::postamble { + ' +version$(OBJ_EXT): version.c + +' ; +} + diff --git a/ext/DB_File/dbinfo b/ext/DB_File/dbinfo index 24a7944..701ac61 100644 --- a/ext/DB_File/dbinfo +++ b/ext/DB_File/dbinfo @@ -4,8 +4,8 @@ # a database file # # Author: Paul Marquess -# Version: 1.01 -# Date 16th April 1998 +# Version: 1.02 +# Date 20th August 1999 # # Copyright (c) 1998 Paul Marquess. All rights reserved. # This program is free software; you can redistribute it and/or @@ -19,7 +19,7 @@ use strict ; my %Data = ( 0x053162 => { - Type => "Btree", + Type => "Btree", Versions => { 1 => "Unknown (older than 1.71)", @@ -27,18 +27,27 @@ my %Data = 3 => "1.71 -> 1.85, 1.86", 4 => "Unknown", 5 => "2.0.0 -> 2.3.0", - 6 => "2.3.1 or greater", + 6 => "2.3.1 -> 2.7.7", + 7 => "3.0.0 or greater", } }, 0x061561 => { - Type => "Hash", + Type => "Hash", Versions => { 1 => "Unknown (older than 1.71)", 2 => "1.71 -> 1.85", 3 => "1.86", 4 => "2.0.0 -> 2.1.0", - 5 => "2.2.6 or greater", + 5 => "2.2.6 -> 2.7.7", + 6 => "3.0.0 or greater", + } + }, + 0x042253 => { + Type => "Queue", + Versions => + { + 1 => "3.0.0 or greater", } }, ) ; diff --git a/ext/DB_File/typemap b/ext/DB_File/typemap index a614cc4..41a24f4 100644 --- a/ext/DB_File/typemap +++ b/ext/DB_File/typemap @@ -1,8 +1,8 @@ # typemap for Perl 5 interface to Berkeley # # written by Paul Marquess -# last modified 6th June 1999 -# version 1.67 +# last modified 7th September 1999 +# version 1.71 # #################################### DB SECTION # @@ -16,22 +16,21 @@ DBTKEY T_dbtkeydatum INPUT T_dbtkeydatum ckFilter($arg, filter_store_key, \"filter_store_key\"); + DBT_clear($var) ; if (db->type != DB_RECNO) { $var.data = SvPV($arg, PL_na); $var.size = (int)PL_na; - DBT_flags($var); } else { Value = GetRecnoKey(aTHX_ db, SvIV($arg)) ; $var.data = & Value; $var.size = (int)sizeof(recno_t); - DBT_flags($var); } T_dbtdatum ckFilter($arg, filter_store_value, \"filter_store_value\"); + DBT_clear($var) ; $var.data = SvPV($arg, PL_na); $var.size = (int)PL_na; - DBT_flags($var); OUTPUT diff --git a/ext/DB_File/version.c b/ext/DB_File/version.c new file mode 100644 index 0000000..23c96a6 --- /dev/null +++ b/ext/DB_File/version.c @@ -0,0 +1,70 @@ +/* + + version.c -- Perl 5 interface to Berkeley DB + + written by Paul Marquess + last modified 7th September 1999 + version 1.71 + + All comments/suggestions/problems are welcome + + Copyright (c) 1995-9 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. + + Changes: + 1.71 - Support for Berkeley DB version 3. + Support for Berkeley DB 2/3's backward compatability mode. + +*/ + +#include "EXTERN.h" +#include "perl.h" +#include "XSUB.h" + +#include + +void +__getBerkeleyDBInfo() +{ + SV * version_sv = perl_get_sv("DB_File::db_version", GV_ADD|GV_ADDMULTI) ; + SV * ver_sv = perl_get_sv("DB_File::db_ver", GV_ADD|GV_ADDMULTI) ; + SV * compat_sv = perl_get_sv("DB_File::db_185_compat", GV_ADD|GV_ADDMULTI) ; + +#ifdef DB_VERSION_MAJOR + int Major, Minor, Patch ; + + (void)db_version(&Major, &Minor, &Patch) ; + + /* Check that the versions of db.h and libdb.a are the same */ + if (Major != DB_VERSION_MAJOR || Minor != DB_VERSION_MINOR + || Patch != DB_VERSION_PATCH) + croak("\nDB_File needs compatible versions of libdb & db.h\n\tyou have db.h version %d.%d.%d and libdb version %d.%d.%d\n", + DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH, + Major, Minor, Patch) ; + + /* check that libdb is recent enough -- we need 2.3.4 or greater */ + if (Major == 2 && (Minor < 3 || (Minor == 3 && Patch < 4))) + croak("DB_File needs Berkeley DB 2.3.4 or greater, you have %d.%d.%d\n", + Major, Minor, Patch) ; + + { + char buffer[40] ; + sprintf(buffer, "%d.%d", Major, Minor) ; + sv_setpv(version_sv, buffer) ; + sprintf(buffer, "%d.%03d%03d", Major, Minor, Patch) ; + sv_setpv(ver_sv, buffer) ; + } + +#else /* ! DB_VERSION_MAJOR */ + sv_setiv(version_sv, 1) ; + sv_setiv(ver_sv, 1) ; +#endif /* ! DB_VERSION_MAJOR */ + +#ifdef COMPAT185 + sv_setiv(compat_sv, 1) ; +#else /* ! COMPAT185 */ + sv_setiv(compat_sv, 0) ; +#endif /* ! COMPAT185 */ + +} diff --git a/t/lib/db-btree.t b/t/lib/db-btree.t index cea8163..b13e50e 100755 --- a/t/lib/db-btree.t +++ b/t/lib/db-btree.t @@ -82,6 +82,8 @@ sub docat_del } +$db185mode = ($DB_File::db_version == 1 && ! $DB_File::db_185_compat) ; + my $Dfile = "dbbtree.tmp"; unlink $Dfile; @@ -933,7 +935,7 @@ EOM unlink $filename ; } - ok(150, docat_del($file) eq ($DB_File::db_version == 1 ? <<'EOM' : <<'EOM') ) ; + ok(150, docat_del($file) eq ($db185mode ? <<'EOM' : <<'EOM') ) ; Smith -> John Wall -> Brick Wall -> Brick @@ -987,7 +989,7 @@ EOM untie %h ; } - ok(151, docat_del($file) eq ($DB_File::db_version == 1 ? <<'EOM' : <<'EOM') ) ; + ok(151, docat_del($file) eq ($db185mode == 1 ? <<'EOM' : <<'EOM') ) ; Smith -> John Wall -> Brick Wall -> Brick