From: Paul Marquess Date: Tue, 3 Aug 1999 22:55:00 +0000 (+0100) Subject: (Replaced by change #3921) X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a62982a846c50953d49f512fd1ec36e63b0a9e81;p=p5sagit%2Fp5-mst-13.2.git (Replaced by change #3921) To: gsar@activestate.com Cc: perl5-porters@perl.org Subject: [PATCH 5.005_60] DB_File 1.69 Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB29C6D04@mbtlipnt02.btlabs.bt.co.uk> p4raw-link: @3921 (not found) p4raw-id: //depot/cfgperl@3917 --- diff --git a/ext/DB_File/Changes b/ext/DB_File/Changes index c5cf329..462056a 100644 --- a/ext/DB_File/Changes +++ b/ext/DB_File/Changes @@ -255,3 +255,10 @@ 2 databases. * Added some of the examples in the POD into the test harness. + +1.69 3rd August 1999 + + * fixed a bug in push -- DB_APPEND wasn't working properly. + * Fixed the R_SETCURSOR bug introduced in 1.68 + * Added a new Perl variable $DB_File::db_ver + diff --git a/ext/DB_File/DB_File.pm b/ext/DB_File/DB_File.pm index 6c78098..c2b7b09 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 22nd July 1999 -# version 1.68 +# last modified 3rd August 1999 +# version 1.69 # # 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.68" ; +$VERSION = "1.69" ; #typedef enum { DB_BTREE, DB_HASH, DB_RECNO } DBTYPE; $DB_BTREE = new DB_File::BTREEINFO ; diff --git a/ext/DB_File/DB_File.xs b/ext/DB_File/DB_File.xs index b8c820a..1223ad4 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 - last modified 22nd July 1999 - version 1.68 + last modified 3rd August 1999 + version 1.69 All comments/suggestions/problems are welcome @@ -71,6 +71,10 @@ Fixed a small memory leak in the filter code. 1.68 - fixed backward compatability bug with R_IAFTER & R_IBEFORE merged in the 5.005_58 changes + 1.69 - fixed a bug in push -- DB_APPEND wasn't working properly. + Fixed the R_SETCURSOR bug introduced in 1.68 + Added a new Perl variable $DB_File::db_ver + @@ -161,7 +165,11 @@ typedef db_recno_t recno_t; #define R_NEXT DB_NEXT #define R_NOOVERWRITE DB_NOOVERWRITE #define R_PREV DB_PREV -#define R_SETCURSOR (-1 ) +#if DB_VERSION_MAJOR == 2 && DB_VERSION_MINOR < 5 +#define R_SETCURSOR 0x800000 +#else +#define R_SETCURSOR (-100) +#endif #define R_RECNOSYNC 0 #define R_FIXEDLEN DB_FIXEDLEN #define R_DUP DB_DUP @@ -271,7 +279,8 @@ typedef union INFO { #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_DESTROY(db) ( db->cursor->c_close(db->cursor),\ + db->dbp->close(db->dbp, 0) ) #define db_close(db) ((db->dbp)->close)(db->dbp, 0) #define db_del(db, key, flags) (flagSet(flags, R_CURSOR) \ ? ((db->cursor)->c_del)(db->cursor, 0) \ @@ -432,7 +441,8 @@ u_int flags ; static void GetVersionInfo(pTHX) { - SV * ver_sv = perl_get_sv("DB_File::db_version", TRUE) ; + SV * version_sv = perl_get_sv("DB_File::db_version", TRUE) ; + SV * ver_sv = perl_get_sv("DB_File::db_ver", TRUE) ; #ifdef DB_VERSION_MAJOR int Major, Minor, Patch ; @@ -444,16 +454,20 @@ GetVersionInfo(pTHX) Major, Minor, Patch) ; #if PERL_VERSION > 3 - sv_setpvf(ver_sv, "%d.%d", Major, Minor) ; + sv_setpvf(version_sv, "%d.%d", Major, Minor) ; + sv_setpvf(ver_sv, "%d.%03d%03d", Major, Minor, Patch) ; #else { 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) ; } #endif #else + sv_setiv(version_sv, 1) ; sv_setiv(ver_sv, 1) ; #endif @@ -1522,6 +1536,7 @@ push(db, ...) DBT_flags(value) ; CurrentDB = db ; #ifdef DB_VERSION_MAJOR + RETVAL = do_SEQ(db, key, value, DB_LAST) ; RETVAL = 0 ; key = empty ; for (i = 1 ; i < items ; ++i) diff --git a/t/lib/db-btree.t b/t/lib/db-btree.t index 7263a90..cea8163 100755 --- a/t/lib/db-btree.t +++ b/t/lib/db-btree.t @@ -178,7 +178,6 @@ delete $h{'goner2'}; undef $X ; untie(%h); - # tie to the same file again ok(26, $X = tie(%h,'DB_File',$Dfile, O_RDWR, 0640, $DB_BTREE)) ; @@ -1189,4 +1188,31 @@ EOM } +#{ +# # R_SETCURSOR +# use strict ; +# my (%h, $db) ; +# unlink $Dfile; +# +# ok(156, $db = tie(%h, 'DB_File', $Dfile, O_RDWR|O_CREAT, 0640, $DB_BTREE ) ); +# +# $h{abc} = 33 ; +# my $k = "newest" ; +# my $v = 44 ; +# my $status = $db->put($k, $v, R_SETCURSOR) ; +# print "status = [$status]\n" ; +# ok(157, $status == 0) ; +# $status = $db->del($k, R_CURSOR) ; +# print "status = [$status]\n" ; +# ok(158, $status == 0) ; +# $k = "newest" ; +# ok(159, $db->get($k, $v, R_CURSOR)) ; +# +# ok(160, keys %h == 1) ; +# +# undef $db ; +# untie %h; +# unlink $Dfile; +#} + exit ; diff --git a/t/lib/db-hash.t b/t/lib/db-hash.t index 2293a42..c52d8ae 100755 --- a/t/lib/db-hash.t +++ b/t/lib/db-hash.t @@ -197,6 +197,8 @@ ok(25, $#keys == 31) ; $h{'foo'} = ''; ok(26, $h{'foo'} eq '' ); +# Berkeley DB 2 from version 2.4.10 onwards does not allow null keys. +# This feature will be reenabled in a future version of Berkeley DB. #$h{''} = 'bar'; #ok(27, $h{''} eq 'bar' ); ok(27,1) ;