Import BSDDB 4.7.25 (as of svn r89086)

This commit is contained in:
Zachary Ware
2017-09-04 13:40:25 -05:00
parent 4b29e0458f
commit 8f590873d0
4781 changed files with 2241032 additions and 6 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,8 @@
package BerkeleyDB::Btree ;
# This file is only used for MLDBM
use BerkeleyDB ;
1 ;

View File

@@ -0,0 +1,8 @@
package BerkeleyDB::Hash ;
# This file is only used for MLDBM
use BerkeleyDB ;
1 ;

312
perl/BerkeleyDB/Changes Normal file
View File

@@ -0,0 +1,312 @@
Revision history for Perl extension BerkeleyDB.
0.34 27th March 2008
* Updates to support building with Berkeley DB version 4.7
* Typo in #ifdef for ThreadCount support. Spotted by Mark Hindley
* Updated dbinfo
0.33 17th January 2008
* Added failchk, set_isalive, lock_stat_print & mutex_stat_print.
Patch provided by Thomas Busch.
0.32 10th July 2007
* Updates to support Berkeley DB 4.6
* Remove all global static data from BerkeleyDB.xs.
0.31 15th Oct 2006
* Fixed DB_GET_BOTH. Tnanks to Thomas Drugeon for spotting the typo
in typemap and supplying a regression test for this fix.
0.30 11th Sept 2006
* Fixed queue test harness for Berkeley DB 4.5 compliance
* Added $env->lsn_reset, $txn->set_timeout, $env->set_timeout &
$env->get_timeout, $txn->set_tx_max, $txn->get_tx_max
0.29 2nd July 2006
* Fixes for cursor get from secondary where primary os recno.
* Added db_compact
0.28 11th June 2006
* Fixes for secondary where primary is recno.
* GET_BOTH_RANGE wasn't working. It is now.
* Added FreeBSD hints to README - patch supplied by David Landgren
in #17675 from rt.cpan.org
0.27 1st Novemver 2005
* Added support for Berkeley DB 4.4
* Fixed secondary key issue with recno databases
* Added libscan to Makefile.PL
* Fixed a problem in t/subdb.t that meant it hung on Win32.
* The logic for set_mutexlocks was inverted when using Berkeley DB 4.x
Bug spotted by Zefram <zefram@fysh.org>
* Transactional rename/remove added.
Patch supplied by Zefram <zefram@fysh.org>
0.26 10th October 2004
* Changed to allow Building with Berkeley DB 4.3
* added cds_lock and associated methods as a convenience to allow
safe updaing of database records when using Berkeley DB CDS mode.
* added t/cds.t and t/pod.t
* Modified the test suite to use "-ErrFile => *STDOUT" where
possible. This will make it easier to diagnose build issues.
* -Errfile will now accept a filehandle as well as a filename
This means that -ErrFile => *STDOUT will get all extended error
messages displayed directly on screen.
* Added support for set_shm_key & get_shm_key.
* Patch from Mark Jason Dominus to add a better error message
when an odd number of parameters are passed to ParseParameters.
* fixed off-by-one error in my_strdup
* Fixed a problem with push, pop, shift & unshift with Queue &
Recno when used in CDS mode. These methods were not using
a write cursor behind the scenes.
Problem reported by Pavel Hlavnicka.
0.25 1st November 2003
* Minor update to dbinfo
* Fixed a bug in the test harnesses that is only apparent in
perl 5.8.2. Original patch courtesy of Michael Schwern.
0.24 27th September 2003
* Mentioned comp.databases.berkeley-db in README
* Builds with Berkeley DB 4.2
* The return type for db->db_fd was wrongly set at DualType -
should be int.
0.23 15th June 2003
* Fixed problem where a secondary index would use the same
compare callback as the primary key, regardless of what was
defined for the secondary index.
Problem spotted by Dave Tallman.
* Also fixed a problem with the associate callback. If the value
for the secondary key was not a string, the secondary key was
being set incorrectly. This is now fixed.
* When built with Berkeley DB 3.2 or better, all callbacks now use
the BackRef pointer instead of the global CurrentDB. This was
done partially to fix the secondary index problem, above.
* The test harness was failing under cygwin. Now fixed.
* Previous release broke TRACE. Fixed.
0.22 17th May 2003
* win32 problem with open macro fixed.
0.21 12th May 2003
* adding support for env->set_flags
* adding recursion detection
* win32 problem with rename fixed.
* problem with sub-database name in Recno & Queue fixed.
* fixed the mldbm.t test harness to work with perl 5.8.0
* added a note about not using a network drive when running the
test harness.
* fixed c_pget
* added BerkeleyDB::Env::DB_ENV method
* added support for encryption
* the dbinfo script will now indicate if the database is encrypted
* The CLEAR method is now CDB safe.
0.20 2nd September 2002
* More support for building with Berkeley DB 4.1.x
* db->get & db->pget used the wrong output macro for DBM filters
bug spotted by Aaron Ross.
* db_join didn't keep a reference to the cursors it was joining.
Spotted by Winton Davies.
0.19 5th June 2002
* Removed the targets that used mkconsts from Makefile.PL. They relied
on a module that is not available in all versions of Perl.
* added support for env->set_verbose
* added support for db->truncate
* added support for db->rename via BerkeleyDB::db_rename
* added support for db->verify via BerkeleyDB::db_verify
* added support for db->associate, db->pget & cursor->c_pget
* Builds with Berkeley DB 4.1.x
0.18 6th January 2002
* Dropped support for ErrFile as a file handle. It was proving too
difficult to get at the underlying FILE * in XS.
Reported by Jonas Smedegaard (Debian powerpc) & Kenneth Olwing (Win32)
* Fixed problem with abort macro in XSUB.h clashing with txn abort
method in Berkeley DB 4.x -- patch supplied by Kenneth Olwing.
* DB->set_alloc was getting called too late in BerkeleyDB.xs.
This was causing problems with ActivePerl -- problem reported
by Kenneth Olwing.
* When opening a queue, the Len proprty set the DB_PAD flag.
Should have been DB_FIXEDLEN. Fix provided by Kenneth Olwing.
* Test harness fixes from Kenneth Olwing.
0.17 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 1 August 2001
* added support for Berkeley DB 3.3.x (but no support for any of the
new features just yet)
0.15 26 April 2001
* Fixed a bug in the processing of the flags options in
db_key_range.
* added support for set_lg_max & set_lg_bsize
* allow DB_TMP_DIR and DB_TEMP_DIR
* the -Filename parameter to BerkeleyDB::Queue didn't work.
* added symbol DB_CONSUME_WAIT
0.14 21st January 2001
* Silenced the warnings when build with a 64-bit Perl.
* Can now build with DB 3.2.3h (part of MySQL). The test harness
takes an age to do the queue test, but it does eventually pass.
* Mentioned the problems that occur when perl is built with sfio.
0.13 15th January 2001
* Added support to allow this module to build with Berkeley DB 3.2
* Updated dbinfo to support Berkeley DB 3.1 & 3.2 file format
changes.
* Documented the Solaris 2.7 core dump problem in README.
* Tidied up the test harness to fix a problem on Solaris where the
"fred" directory wasn't being deleted when it should have been.
* two calls to "open" clashed with a win32 macro.
* size argument for hash_cb is different for Berkeley DB 3.x
* Documented the issue of building on Linux.
* Added -Server, -CacheSize & -LockDetect options
[original patch supplied by Graham Barr]
* Added support for set_mutexlocks, c_count, set_q_extentsize,
key_range, c_dup
* Dropped the "attempted to close a Cursor with an open transaction"
error in c_close. The correct behaviour is that the cursor
should be closed before committing/aborting the transaction.
0.12 2nd August 2000
* Serious bug with get fixed. Spotted by Sleepycat.
* Added hints file for Solaris & Irix (courtesy of Albert Chin-A-Young)
0.11 4th June 2000
* When built with Berkeley Db 3.x there can be a clash with the close
macro.
* Typo in the definition of DB_WRITECURSOR
* The flags parameter wasn't getting sent to db_cursor
* Plugged small memory leak in db_cursor (DESTROY wasn't freeing
memory)
* Can be built with Berkeley DB 3.1
0.10 8th December 1999
* The DESTROY method was missing for BerkeleyDB::Env. This resulted in
a memory leak. Fixed.
* If opening an environment or database failed, there was a small
memory leak. This has been fixed.
* A thread-enabled Perl it could core when a database was closed.
Problem traced to the strdup function.
0.09 29th November 1999
* the queue.t & subdb.t test harnesses were outputting a few
spurious warnings. This has been fixed.
0.08 28nd November 1999
* More documentation updates
* Changed reference to files in /tmp in examples.t
* Fixed a typo in softCrash that caused problems when building
with a thread-enabled Perl.
* BerkeleyDB::Error wasn't initialised properly.
* ANSI-ified all the static C functions in BerkeleyDB.xs
* Added support for the following DB 3.x features:
+ The Queue database type
+ db_remove
+ subdatabases
+ db_stat for Hash & Queue
0.07 21st September 1999
* Numerous small bug fixes.
* Added support for sorting duplicate values DB_DUPSORT.
* Added support for DB_GET_BOTH & DB_NEXT_DUP.
* Added get_dup (from DB_File).
* beefed up the documentation.
* Forgot to add the DB_INIT_CDB in BerkeleyDB.pm in previous release.
* Merged the DBM Filter code from DB_File into BerkeleyDB.
* Fixed a nasty bug where a closed transaction was still used with
with dp_put, db_get etc.
* Added logic to gracefully close everything whenever a fatal error
happens. Previously the plug was just pulled.
* It is now a fatal error to explicitly close an environment if there
is still an open database; a database when there are open cursors or
an open transaction; and a cursor if there is an open transaction.
Using object destruction doesn't have this issue, as object
references will ensure everything gets closed in the correct order.
* The BOOT code now checks that the version of db.h & libdb are the
same - this seems to be a common problem on Linux.
* MLDBM support added.
* Support for the new join cursor added.
* Builds with Berkeley DB 3.x
* Updated dbinfo for Berkeley DB 3.x file formats.
* Deprecated the TxnMgr class. As with Berkeley DB version 3,
txn_begin etc are now accessed via the environment object.
0.06 19 December 1998
* Minor modifications to get the module to build with DB 2.6.x
* Added support for DB 2.6.x's Concurrent Access Method, DB_INIT_CDB.
0.05 9 November 1998
* Added a note to README about how to build Berkeley DB 2.x
when using HP-UX.
* Minor modifications to get the module to build with DB 2.5.x
0.04 19 May 1998
* Define DEFSV & SAVE_DEFSV if not already defined. This allows
the module to be built with Perl 5.004_04.
0.03 5 May 1998
* fixed db_get with DB_SET_RECNO
* fixed c_get with DB_SET_RECNO and DB_GET_RECNO
* implemented BerkeleyDB::Unknown
* implemented BerkeleyDB::Recno, including push, pop etc
modified the txn support.
0.02 30 October 1997
* renamed module to BerkeleyDB
* fixed a few bugs & added more tests
0.01 23 October 1997
* first alpha release as BerkDB.

64
perl/BerkeleyDB/MANIFEST Normal file
View File

@@ -0,0 +1,64 @@
BerkeleyDB.pm
BerkeleyDB.pod
BerkeleyDB.pod.P
BerkeleyDB.xs
BerkeleyDB/Btree.pm
BerkeleyDB/Hash.pm
Changes
config.in
constants.h
constants.xs
dbinfo
hints/dec_osf.pl
hints/solaris.pl
hints/irix_6_5.pl
Makefile.PL
MANIFEST
mkconsts
mkpod
ppport.h
README
t/btree.t
t/cds.t
t/db-3.0.t
t/db-3.1.t
t/db-3.2.t
t/db-3.3.t
t/db-4.x.t
t/db-4.4.t
t/destroy.t
t/encrypt.t
t/env.t
t/examples.t
t/examples.t.T
t/examples3.t
t/examples3.t.T
t/filter.t
t/hash.t
t/join.t
t/mldbm.t
t/pod.t
t/queue.t
t/recno.t
t/strict.t
t/subdb.t
t/txn.t
t/unknown.t
t/util.pm
t/Test/More.pm
t/Test/Builder.pm
Todo
typemap
patches/5.004
patches/5.004_01
patches/5.004_02
patches/5.004_03
patches/5.004_04
patches/5.004_05
patches/5.005
patches/5.005_01
patches/5.005_02
patches/5.005_03
patches/5.6.0
scan
META.yml Module meta-data (added by MakeMaker)

13
perl/BerkeleyDB/META.yml Normal file
View File

@@ -0,0 +1,13 @@
--- #YAML:1.0
name: BerkeleyDB
version: 0.34
abstract: Perl extension for Berkeley DB version 2, 3 or 4
license: perl
author:
- Paul Marquess <pmqs@cpan.org>
generated_by: ExtUtils::MakeMaker version 6.44
distribution_type: module
requires:
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.3.html
version: 1.3

152
perl/BerkeleyDB/Makefile.PL Normal file
View File

@@ -0,0 +1,152 @@
#! perl -w
# It should not be necessary to edit this file. The configuration for
# BerkeleyDB is controlled from the file config.in
BEGIN { die "BerkeleyDB needs Perl 5.004_04 or greater" if $] < 5.004_04 ; }
use strict ;
use ExtUtils::MakeMaker ;
use Config ;
# Check for the presence of sfio
if ($Config{'d_sfio'}) {
print <<EOM;
WARNING: Perl seems to have been built with SFIO support enabled.
Please read the SFIO Notes in the README file.
EOM
}
my $LIB_DIR ;
my $INC_DIR ;
my $DB_NAME ;
my $LIBS ;
ParseCONFIG() ;
if (defined $DB_NAME)
{ $LIBS = $DB_NAME }
else {
if ($^O eq 'MSWin32')
{ $LIBS = '-llibdb' }
elsif ($^O =~ /aix/i ) {
$LIBS .= '-ldb -lpthread ';
if ($Config{'cc'} eq 'gcc' && $Config{'osvers'} eq '5.1')
{ $LIBS .= '-lgcc_s' }
}
else
{ $LIBS = '-ldb' }
}
# OS2 is a special case, so check for it now.
my $OS2 = "" ;
$OS2 = "-DOS2" if $^O eq 'os2' ;
my $WALL = '';
#$WALL = ' -Wall ' if $Config{'cc'} =~ /gcc/ ;
WriteMakefile(
NAME => 'BerkeleyDB',
LIBS => ["-L${LIB_DIR} $LIBS"],
#MAN3PODS => {}, # Pods will be built by installman.
INC => "-I$INC_DIR",
VERSION_FROM => 'BerkeleyDB.pm',
XSPROTOARG => '-noprototypes',
DEFINE => "$OS2 $WALL",
#'macro' => { INSTALLDIRS => 'perl' },
'dist' => {COMPRESS=>'gzip', SUFFIX=>'gz'},
($] >= 5.005
? (ABSTRACT_FROM => 'BerkeleyDB.pod',
AUTHOR => 'Paul Marquess <pmqs@cpan.org>')
: ()
),
((ExtUtils::MakeMaker->VERSION() gt '6.30')
? ('LICENSE' => 'perl')
: ()
),
);
sub MY::libscan
{
my $self = shift ;
my $path = shift ;
return undef
if $path =~ /(~|\.bak)$/ ||
$path =~ /^\..*\.swp$/ ;
return $path;
}
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
Makefile: config.in
' ;
}
sub ParseCONFIG
{
my ($k, $v) ;
my @badkey = () ;
my %Info = () ;
my @Options = qw( INCLUDE LIB DBNAME ) ;
my %ValidOption = map {$_, 1} @Options ;
my %Parsed = %ValidOption ;
my $CONFIG = 'config.in' ;
print "Parsing $CONFIG...\n" ;
# DBNAME is optional, so pretend it has been parsed.
delete $Parsed{'DBNAME'} ;
open(F, "$CONFIG") or die "Cannot open file $CONFIG: $!\n" ;
while (<F>) {
s/^\s*|\s*$//g ;
next if /^\s*$/ or /^\s*#/ ;
s/\s*#\s*$// ;
($k, $v) = split(/\s+=\s+/, $_, 2) ;
$k = uc $k ;
if ($ValidOption{$k}) {
delete $Parsed{$k} ;
$Info{$k} = $v ;
}
else {
push(@badkey, $k) ;
}
}
close F ;
print "Unknown keys in $CONFIG ignored [@badkey]\n"
if @badkey ;
# check parsed values
my @missing = () ;
die "The following keys are missing from $CONFIG file: [@missing]\n"
if @missing = keys %Parsed ;
$INC_DIR = $ENV{'BERKELEYDB_INCLUDE'} || $Info{'INCLUDE'} ;
$LIB_DIR = $ENV{'BERKELEYDB_LIB'} || $Info{'LIB'} ;
$DB_NAME = $ENV{BERKELEYDB_NAME} || $Info{'DBNAME'} ;
#$DB_NAME = $ENV{} || $Info{'DBNAME'} if defined $Info{'DBNAME'} ;
print "Looks Good.\n" ;
}
# end of file Makefile.PL

671
perl/BerkeleyDB/README Normal file
View File

@@ -0,0 +1,671 @@
BerkeleyDB
Version 0.34
27th March 2008
Copyright (c) 1997-2008 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.
DESCRIPTION
-----------
BerkeleyDB is a module which allows Perl programs to make use of the
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
four of the database types (hash, btree, queue and recno) currently
supported by Berkeley DB.
For further details see the documentation in the file BerkeleyDB.pod.
PREREQUISITES
-------------
Before you can build BerkeleyDB you need to have the following
installed on your system:
* To run the test harness for this module, you must make sure that the
directory where you have untarred this module is NOT a network
drive, e.g. NFS or AFS.
* Perl 5.004_04 or greater.
* Berkeley DB Version 2.6.4 or greater
The official web site for Berkeley DB is
http://www.oracle.com/technology/products/berkeley-db/db/index.html
The latest version of Berkeley DB is always available there. It
is recommended that you use the most recent version available.
The one exception to this advice is where you want to use BerkeleyDB
to access database files created by a third-party application,
like Sendmail. In these cases you must build BerkeleyDB with a
compatible version of Berkeley DB.
BUILDING THE MODULE
-------------------
Assuming you have met all the prerequisites, building the module should
be relatively straightforward.
Step 1 : If you are running Solaris 2.5, 2.7 or HP-UX 10 read either
the Solaris Notes or HP-UX Notes sections below.
If you are running Linux please read the Linux Notes section
before proceeding.
If you are running FreeBSD read the FreeBSD Notes section
below.
Step 2 : Edit the file config.in to suit you local installation.
Instructions are given in the file.
Step 3 : Build and test the module using this sequence of commands:
perl Makefile.PL
make
make test
INSTALLATION
------------
make install
TROUBLESHOOTING
===============
Here are some of the problems that people encounter when building BerkeleyDB.
Missing db.h or libdb.a
-----------------------
If you get an error like this:
cc -c -I./libraries/ -Dbool=char -DHAS_BOOL -I/usr/local/include -O2
-DVERSION=\"0.07\" -DXS_VERSION=\"0.07\" -fpic
-I/usr/local/lib/perl5/5.00503/i586-linux/CORE BerkeleyDB.c
BerkeleyDB.xs:52: db.h: No such file or directory
or this:
cc -c -I./libraries/2.7.5 -Dbool=char -DHAS_BOOL -I/usr/local/include -O2
-DVERSION=\"0.07\" -DXS_VERSION=\"0.07\" -fpic
-I/usr/local/lib/perl5/5.00503/i586-linux/CORE BerkeleyDB.c
LD_RUN_PATH="/lib" cc -o blib/arch/auto/BerkeleyDB/BerkeleyDB.so -shared
-L/usr/local/lib BerkeleyDB.o
-L/home/paul/perl/ext/BerkDB/BerkeleyDB/libraries -ldb
ld: cannot open -ldb: No such file or directory
This symptom can imply:
1. You don't have Berkeley DB installed on your system at all.
Solution: get & install Berkeley DB.
2. You do have Berkeley DB installed, but it isn't in a standard place.
Solution: Edit config.in and set the LIB and INCLUDE variables to point
to the directories where libdb.a and db.h are installed.
#error db.h is not for Berkeley DB at all.
------------------------------------------
If you get the error above when building this module it means that there
is a file called "db.h" on your system that isn't the one that comes
with Berkeley DB.
Options:
1. You don't have Berkeley DB installed on your system at all.
Solution: get & install Berkeley DB.
2. Edit config.in and make sure the INCLUDE variable points to the
directory where the Berkeley DB file db.h is installed.
3. If option 2 doesn't work, try tempoarily renaming the db.h file
that is causing the error.
#error db.h is for Berkeley DB 1.x - need at least Berkeley DB 2.6.4
--------------------------------------------------------------------
The error above will occur if there is a copy of the Berkeley DB 1.x
file db.h on your system.
This error will happen when
1. you only have Berkeley DB version 1 on your system.
Solution: get & install a newer version of Berkeley DB.
2. you have both version 1 and a later version of Berkeley DB
installed on your system. When building BerkeleyDB it attempts to
use the db.h for Berkeley DB version 1.
Solution: Edit config.in and set the LIB and INCLUDE variables
to point to the directories where libdb.a and db.h are
installed.
#error db.h is for Berkeley DB 2.0-2.5 - need at least Berkeley DB 2.6.4
------------------------------------------------------------------------
The error above will occur if there is a copy of the the file db.h for
Berkeley DB 2.0 to 2.5 on your system.
This symptom can imply:
1. You don't have a new enough version of Berkeley DB.
Solution: get & install a newer version of Berkeley DB.
2. You have the correct version of Berkeley DB installed, but it isn't
in a standard place.
Solution: Edit config.in and set the LIB and INCLUDE variables
to point to the directories where libdb.a and db.h are
installed.
Undefined Symbol: txn_stat
--------------------------
BerkeleyDB seems to have built correctly, but you get an error like this
when you run the test harness:
$ make test
PERL_DL_NONLAZY=1 /home/paul/perl/install/bin/perl5.00503
-Iblib/arch -Iblib/lib -I/usr/local/lib/perl5/5.00503/i586-linux
-I/usr/local/lib/perl5/5.00503 -e 'use Test::Harness qw(&runtests $verbose);
$verbose=0; runtests @ARGV;' t/*.t
t/btree.............Can't load 'blib/arch/auto/BerkeleyDB/BerkeleyDB.so' for
module BerkeleyDB: blib/arch/auto/BerkeleyDB/BerkeleyDB.so:
undefined symbol: txn_stat
at /usr/local/lib/perl5/5.00503/i586-linux/DynaLoader.pm line 169.
...
This error usually happens when you have both version 1 and a newer version
of Berkeley DB installed on your system. BerkeleyDB attempts
to build using the db.h for Berkeley DB version 2/3/4 and the version 1
library. Unfortunately the two versions aren't compatible with each
other. BerkeleyDB can only be built with Berkeley DB version 2, 3 or 4.
Solution: Setting the LIB & INCLUDE variables in config.in to point to the
correct directories can sometimes be enough to fix this
problem. If that doesn't work the easiest way to fix the
problem is to either delete or temporarily rename the copies
of db.h and libdb.a that you don't want BerkeleyDB to use.
Undefined Symbol: db_appinit
----------------------------
BerkeleyDB seems to have built correctly, but you get an error like this
when you run the test harness:
$ make test
PERL_DL_NONLAZY=1 /home/paul/perl/install/bin/perl5.00561 -Iblib/arch
-Iblib/lib -I/home/paul/perl/install/5.005_61/lib/5.00561/i586-linux
-I/home/paul/perl/install/5.005_61/lib/5.00561 -e 'use Test::Harness
qw(&runtests $verbose); $verbose=0; runtests @ARGV;' t/*.t
t/btree.............Can't load 'blib/arch/auto/BerkeleyDB/BerkeleyDB.so' for
module BerkeleyDB: blib/arch/auto/BerkeleyDB/BerkeleyDB.so:
undefined symbol: db_appinit
at /home/paul/perl/install/5.005_61/lib/5.00561/i586-linux/DynaLoader.pm
...
This error usually happens when you have both version 2 and version
3 of Berkeley DB installed on your system and BerkeleyDB attempts
to build using the db.h for Berkeley DB version 2 and the version 3
library. Unfortunately the two versions aren't compatible with each
other.
Solution: Setting the LIB & INCLUDE variables in config.in to point to the
correct directories can sometimes be enough to fix this
problem. If that doesn't work the easiest way to fix the
problem is to either delete or temporarily rename the copies
of db.h and libdb.a that you don't want BerkeleyDB to use.
Undefined Symbol: db_create
---------------------------
BerkeleyDB seems to have built correctly, but you get an error like this
when you run the test harness:
$ make test
PERL_DL_NONLAZY=1 /home/paul/perl/install/bin/perl5.00561 -Iblib/arch
-Iblib/lib -I/home/paul/perl/install/5.005_61/lib/5.00561/i586-linux
-I/home/paul/perl/install/5.005_61/lib/5.00561 -e 'use Test::Harness
qw(&runtests $verbose); $verbose=0; runtests @ARGV;' t/*.t
t/btree.............Can't load 'blib/arch/auto/BerkeleyDB/BerkeleyDB.so' for
module BerkeleyDB: blib/arch/auto/BerkeleyDB/BerkeleyDB.so:
undefined symbol: db_create
at /home/paul/perl/install/5.005_61/lib/5.00561/i586-linux/DynaLoader.pm
...
This error usually happens when you have both version 2 and version
3 of Berkeley DB installed on your system and BerkeleyDB attempts
to build using the db.h for Berkeley DB version 3 and the version 2
library. Unfortunately the two versions aren't compatible with each
other.
Solution: Setting the LIB & INCLUDE variables in config.in to point to the
correct directories can sometimes be enough to fix this
problem. If that doesn't work the easiest way to fix the
problem is to either delete or temporarily rename the copies
of db.h and libdb.a that you don't want BerkeleyDB to use.
Incompatible versions of db.h and libdb
---------------------------------------
BerkeleyDB seems to have built correctly, but you get an error like this
when you run the test harness:
$ make test
PERL_DL_NONLAZY=1 /home/paul/perl/install/bin/perl5.00503
-Iblib/arch -Iblib/lib -I/usr/local/lib/perl5/5.00503/i586-linux
-I/usr/local/lib/perl5/5.00503 -e 'use Test::Harness qw(&runtests $verbose);
$verbose=0; runtests @ARGV;' t/*.t
t/btree.............
BerkeleyDB needs compatible versions of libdb & db.h
you have db.h version 2.6.4 and libdb version 2.7.5
BEGIN failed--compilation aborted at t/btree.t line 25.
dubious
Test returned status 255 (wstat 65280, 0xff00)
...
Another variation on the theme of having two versions of Berkeley DB on
your system.
Solution: Setting the LIB & INCLUDE variables in config.in to point to the
correct directories can sometimes be enough to fix this
problem. If that doesn't work the easiest way to fix the
problem is to either delete or temporarily rename the copies
of db.h and libdb.a that you don't want BerkeleyDB to use.
If you are running Linux, please read the Linux Notes section below.
Solaris build fails with "language optional software package not installed"
---------------------------------------------------------------------------
If you are trying to build this module under Solaris and you get an
error message like this
/usr/ucb/cc: language optional software package not installed
it means that Perl cannot find the C compiler on your system. The cryptic
message is just Sun's way of telling you that you haven't bought their
C compiler.
When you build a Perl module that needs a C compiler, the Perl build
system tries to use the same C compiler that was used to build perl
itself. In this case your Perl binary was built with a C compiler that
lived in /usr/ucb.
To continue with building this module, you need to get a C compiler,
or tell Perl where your C compiler is, if you already have one.
Assuming you have now got a C compiler, what you do next will be dependant
on what C compiler you have installed. If you have just installed Sun's
C compiler, you shouldn't have to do anything. Just try rebuilding
this module.
If you have installed another C compiler, say gcc, you have to tell perl
how to use it instead of /usr/ucb/cc.
This set of options seems to work if you want to use gcc. Your mileage
may vary.
perl Makefile.PL CC=gcc CCCDLFLAGS=-fPIC OPTIMIZE=" "
make test
If that doesn't work for you, it's time to make changes to the Makefile
by hand. Good luck!
Solaris build fails with "gcc: unrecognized option `-KPIC'"
-----------------------------------------------------------
You are running Solaris and you get an error like this when you try to
build this Perl module
gcc: unrecognized option `-KPIC'
This symptom usually means that you are using a Perl binary that has been
built with the Sun C compiler, but you are using gcc to build this module.
When Perl builds modules that need a C compiler, it will attempt to use
the same C compiler and command line options that was used to build perl
itself. In this case "-KPIC" is a valid option for the Sun C compiler,
but not for gcc. The equivalent option for gcc is "-fPIC".
The solution is either:
1. Build both Perl and this module with the same C compiler, either
by using the Sun C compiler for both or gcc for both.
2. Try generating the Makefile for this module like this perl
perl Makefile.PL CC=gcc CCCDLFLAGS=-fPIC OPTIMIZE=" " LD=gcc
make test
This second option seems to work when mixing a Perl binary built
with the Sun C compiler and this module built with gcc. Your
mileage may vary.
Network Drive
-------------
BerkeleyDB seems to have built correctly, but you get a series of errors
like this when you run the test harness:
t/btree........NOK 178Can't call method "txn_begin" on an undefined value at t/btree.t line 637.
t/btree........dubious
Test returned status 11 (wstat 2816, 0xb00)
DIED. FAILED tests 28, 178-244
Failed 68/244 tests, 72.13% okay
t/db-3.0.......NOK 2Can't call method "set_mutexlocks" on an undefined value at t/db-3.0.t line 39.
t/db-3.0.......dubious
Test returned status 11 (wstat 2816, 0xb00)
DIED. FAILED tests 2-14
Failed 13/14 tests, 7.14% okay
t/db-3.1.......ok
t/db-3.2.......NOK 5Can't call method "set_flags" on an undefined value at t/db-3.2.t line 62.
t/db-3.2.......dubious
Test returned status 11 (wstat 2816, 0xb00)
DIED. FAILED tests 3, 5-6
Failed 3/6 tests, 50.00% okay
t/db-3.3.......ok
This pattern of errors happens if you have built the module in a directory
that is network mounted (e.g. NFS ar AFS).
The solution is to use a local drive. Berkeley DB doesn't support
network drives.
Berkeley DB library configured to support only DB_PRIVATE environments
----------------------------------------------------------------------
BerkeleyDB seems to have built correctly, but you get a series of errors
like this when you run the test harness:
t/btree........ok 27/244
# : Berkeley DB library configured to support only DB_PRIVATE environments
t/btree........ok 177/244
# : Berkeley DB library configured to support only DB_PRIVATE environments
t/btree........NOK 178Can't call method "txn_begin" on an undefined value at t/btree.t line 638.
t/btree........dubious
Test returned status 2 (wstat 512, 0x200)
Scalar found where operator expected at (eval 153) line 1, near "'int' $__val"
(Missing operator before $__val?)
DIED. FAILED tests 28, 178-244
Failed 68/244 tests, 72.13% okay
Some versions of Redhat Linux, and possibly some other Linux
distributions, include a seriously restricted build of the
Berkeley DB library that is incompatible with this module. See
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=91933 for an
exhaustive discussion on the reasons for this.
Solution:
You will have to build a private copy of the Berkeley DB library and
use it when building this Perl module.
Linux Notes
-----------
Some versions of Linux (e.g. RedHat 6, SuSe 6) ship with a C library
that has version 2.x of Berkeley DB linked into it. This makes it
difficult to build this module with anything other than the version of
Berkeley DB that shipped with your Linux release. If you do try to use
a different version of Berkeley DB you will most likely get the error
described in the "Incompatible versions of db.h and libdb" section of
this file.
To make matters worse, prior to Perl 5.6.1, the perl binary itself
*always* included the Berkeley DB library.
If you want to use a newer version of Berkeley DB with this module, the
easiest solution is to use Perl 5.6.1 (or better) and Berkeley DB 3.x
(or better).
There are two approaches you can use to get older versions of Perl to
work with specific versions of Berkeley DB. Both have their advantages
and disadvantages.
The first approach will only work when you want to build a version of
Perl older than 5.6.1 along with Berkeley DB 3.x. If you want to use
Berkeley DB 2.x, you must use the next approach. This approach involves
rebuilding your existing version of Perl after applying an unofficial
patch. The "patches" directory in the this module's source distribution
contains a number of patch files. There is one patch file for every
stable version of Perl since 5.004. Apply the appropriate patch to your
Perl source tree before re-building and installing Perl from scratch.
For example, assuming you are in the top-level source directory for
Perl 5.6.0, the command below will apply the necessary patch. Remember
to replace the path shown below with one that points to this module's
patches directory.
patch -p1 -N </path/to/BerkeleyDB/patches/5.6.0
Now rebuild & install perl. You should now have a perl binary that can
be used to build this module. Follow the instructions in "BUILDING THE
MODULE", remembering to set the INCLUDE and LIB variables in config.in.
The second approach will work with Berkeley DB 2.x or better.
Start by building Berkeley DB as a shared library. This is from
the Berkeley DB build instructions:
Building Shared Libraries for the GNU GCC compiler
If you're using gcc and there's no better shared library example for
your architecture, the following shared library build procedure will
probably work.
Add the -fpic option to the CFLAGS value in the Makefile.
Rebuild all of your .o files. This will create a Berkeley DB library
that contains .o files with PIC code. To build the shared library,
then take the following steps in the library build directory:
% mkdir tmp
% cd tmp
% ar xv ../libdb.a
% gcc -shared -o libdb.so *.o
% mv libdb.so ..
% cd ..
% rm -rf tmp
Note, you may have to change the gcc line depending on the
requirements of your system.
The file libdb.so is your shared library
Once you have built libdb.so, you will need to store it somewhere safe.
cp libdb.so /usr/local/BerkeleyDB/lib
If you now set the LD_PRELOAD environment variable to point to this
shared library, Perl will use it instead of the version of Berkeley DB
that shipped with your Linux distribution.
export LD_PRELOAD=/usr/local/BerkeleyDB/lib/libdb.so
Finally follow the instructions in "BUILDING THE MODULE" to build,
test and install this module. Don't forget to set the INCLUDE and LIB
variables in config.in.
Remember, you will need to have the LD_PRELOAD variable set anytime you
want to use Perl with Berkeley DB. Also note that if you have LD_PRELOAD
permanently set it will affect ALL commands you execute. This may be a
problem if you run any commands that access a database created by the
version of Berkeley DB that shipped with your Linux distribution.
Solaris 2.5 Notes
-----------------
If you are running Solaris 2.5, and you get this error when you run the
BerkeleyDB test harness:
libc internal error: _rmutex_unlock: rmutex not held.
you probably need to install a Sun patch. It has been reported that
Sun patch 103187-25 (or later revisions) fixes this problem.
To find out if you have the patch installed, the command "showrev -p"
will display the patches that are currently installed on your system.
Solaris 2.7 Notes
-----------------
If you are running Solaris 2.7 and all the tests in the test harness
generate a core dump, try applying Sun patch 106980-09 (or better).
To find out if you have the patch installed, the command "showrev -p"
will display the patches that are currently installed on your system.
HP-UX Notes
-----------
Some people running HP-UX 10 have reported getting an error like this
when building this module with the native HP-UX compiler.
ld: (Warning) At least one PA 2.0 object file (BerkeleyDB.o) was detected.
The linked output may not run on a PA 1.x system.
ld: Invalid loader fixup for symbol "$000000A5".
If this is the case for you, Berkeley DB needs to be recompiled with
the +z or +Z option and the resulting library placed in a .sl file. The
following steps should do the trick:
1: Configure the Berkeley DB distribution with the +z or +Z C compiler
flag:
env "CFLAGS=+z" ../dist/configure ...
2: Edit the Berkeley DB Makefile and change:
"libdb= libdb.a" to "libdb= libdb.sl".
3: Build and install the Berkeley DB distribution as usual.
FreeBSD Notes
-------------
On FreeBSD 4.x through 6.x, the default db.h is for version 1. The build
will fail with an error similar to:
BerkeleyDB.xs:74: #error db.h is from Berkeley DB 1.x - need at least
Berkeley DB 2.6.4
Later versions of Berkeley DB are usually installed from ports.
The available versions can be found by running a find(1) command:
% find /usr/local/include -name 'db.h'
/usr/local/include/db3/db.h
/usr/local/include/db4/db.h
/usr/local/include/db41/db.h
/usr/local/include/db42/db.h
/usr/local/include/db43/db.h
The desired version of the library must be specified on the command line or
via the config.in file. Make sure both values point to the same version:
INCLUDE = /usr/local/include/db43
LIB = /usr/local/lib/db43
FEEDBACK
--------
General feedback/questions/bug reports can be sent to me at pmqs@cpan.org.
Alternatively, if you have Usenet access, you can try the
comp.databases.berkeley-db or comp.lang.perl.modules groups.
How to report a problem with BerkeleyDB.
----------------------------------------
To help me help you, I need of the following information:
1. The version of Perl and the operating system name and version you
are running. The complete output from running "perl -V" will tell
me all I need to know.
If your perl does not understand the "-V" option is too old.
BerkeleyDB needs Perl version 5.004_04 or better.
2. The version of BerkeleyDB you have. If you have successfully
installed BerkeleyDB, this one-liner will tell you:
perl -MBerkeleyDB -e 'print qq{BerkeleyDB ver $BerkeleyDB::VERSION\n}'
If you are running windows use this
perl -MBerkeleyDB -e "print qq{BerkeleyDB ver $BerkeleyDB::VERSION\n}"
If you haven't installed BerkeleyDB then search BerkeleyDB.pm for a
line like this:
$VERSION = "1.20" ;
3. The version of Berkeley DB you have installed. If you have
successfully installed BerkeleyDB, this one-liner will tell you:
perl -MBerkeleyDB -e 'print BerkeleyDB::DB_VERSION_STRING.qq{\n}'
If you are running windows use this
perl -MBerkeleyDB -e "print BerkeleyDB::DB_VERSION_STRING.qq{\n}"
If you haven't installed BerkeleyDB then search db.h for a line
like this:
#define DB_VERSION_STRING
4. If you are having problems building BerkeleyDB, send me a complete
log of what happened.
5. Now the difficult one. If you think you have found a bug in
BerkeleyDB and you want me to fix it, you will *greatly* enhance
the chances of me being able to track it down by sending me a small
self-contained Perl script that illustrates the problem you are
encountering. Include a summary of what you think the problem is
and a log of what happens when you run the script, in case I can't
reproduce your problem on my system. If possible, don't have the
script dependent on an existing 20Meg database. If the script you
send me can create the database itself then that is preferred.
I realise that in some cases this is easier said than done, so if
you can only reproduce the problem in your existing script, then
you can post me that if you want. Just don't expect me to find your
problem in a hurry, or at all. :-)
CHANGES
-------
See the Changes file.
Paul Marquess <pmqs@cpan.org>

57
perl/BerkeleyDB/Todo Normal file
View File

@@ -0,0 +1,57 @@
* Proper documentation.
* address or document the "close all cursors if you encounter an error"
* Change the $BerkeleyDB::Error to store the info in the db object,
if possible.
* $BerkeleyDB::db_version is documented. &db_version isn't.
* migrate perl code into the .xs file where necessary
* convert as many of the DB examples files to BerkeleyDB format.
* add a method to the DB object to allow access to the environment (if there
actually is one).
Possibles
* use '~' magic to store the inner data.
* for the get stuff zap the value to undef if it doesn't find the
key. This may be more intuitive for those folks who are used with
the $hash{key} interface.
* Text interface? This can be done as via Recno
* allow recno to allow base offset for arrays to be either 0 or 1.
* when duplicate keys are enabled, allow db_put($key, [$val1, $val2,...])
2.x -> 3.x Upgrade
==================
Environment Verbose
Env->open mode
DB cache size extra parameter
DB->open subdatabases Done
An empty environment causes DB->open to fail
where is __db.001 coming from? db_remove seems to create it. Bug in 3.0.55
Change db_strerror for 0 to ""? Done
Queue Done
db_stat for Hash & Queue Done
No TxnMgr
DB->remove
ENV->remove
ENV->set_verbose
upgrade
$env = BerkeleyDB::Env::Create
$env = create BerkeleyDB::Env
$status = $env->open()
$db = BerkeleyDB::Hash::Create
$status = $db->open()

45
perl/BerkeleyDB/config.in Normal file
View File

@@ -0,0 +1,45 @@
# Filename: config.in
#
# written by Paul Marquess <Paul.Marquess@btinternet.com>
# 1. Where is the file db.h?
#
# Change the path below to point to the directory where db.h is
# installed on your system.
#INCLUDE = /usr/local/include
#INCLUDE = ../..
INCLUDE = /usr/local/BerkeleyDB/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 = ../..
LIB = /usr/local/BerkeleyDB/lib
# 3. Is the library called libdb?
#
# If you have copies of both 1.x and 2.x Berkeley DB installed on
# your system it can sometimes be tricky to make sure you are using
# the correct one. Renaming one (or creating a symbolic link) to
# include the version number of the library can help.
#
# For example, if you have Berkeley DB 2.6.4 you could rename the
# Berkeley DB library from libdb.a to libdb-2.6.4.a and change the
# DBNAME line below to look like this:
#
# DBNAME = -ldb-2.6.4
#
# Note: If you are building this module with Win32, -llibdb will be
# used by default.
#
# If you have changed the name of the library, uncomment the line
# below (by removing the leading #) and edit the line to use the name
# you have picked.
#DBNAME = -ldb-3.0
# end of file config.in

5719
perl/BerkeleyDB/constants.h Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,87 @@
void
constant(sv)
PREINIT:
#ifdef dXSTARG
dXSTARG; /* Faster if we have it. */
#else
dTARGET;
#endif
STRLEN len;
int type;
IV iv;
/* NV nv; Uncomment this if you need to return NVs */
const char *pv;
INPUT:
SV * sv;
const char * s = SvPV(sv, len);
PPCODE:
/* Change this to constant(aTHX_ s, len, &iv, &nv);
if you need to return both NVs and IVs */
type = constant(aTHX_ s, len, &iv, &pv);
/* Return 1 or 2 items. First is error message, or undef if no error.
Second, if present, is found value */
switch (type) {
case PERL_constant_NOTFOUND:
sv = sv_2mortal(newSVpvf("%s is not a valid BerkeleyDB macro", s));
PUSHs(sv);
break;
case PERL_constant_NOTDEF:
sv = sv_2mortal(newSVpvf(
"Your vendor has not defined BerkeleyDB macro %s, used", s));
PUSHs(sv);
break;
case PERL_constant_ISIV:
EXTEND(SP, 1);
PUSHs(&PL_sv_undef);
PUSHi(iv);
break;
/* Uncomment this if you need to return NOs
case PERL_constant_ISNO:
EXTEND(SP, 1);
PUSHs(&PL_sv_undef);
PUSHs(&PL_sv_no);
break; */
/* Uncomment this if you need to return NVs
case PERL_constant_ISNV:
EXTEND(SP, 1);
PUSHs(&PL_sv_undef);
PUSHn(nv);
break; */
case PERL_constant_ISPV:
EXTEND(SP, 1);
PUSHs(&PL_sv_undef);
PUSHp(pv, strlen(pv));
break;
/* Uncomment this if you need to return PVNs
case PERL_constant_ISPVN:
EXTEND(SP, 1);
PUSHs(&PL_sv_undef);
PUSHp(pv, iv);
break; */
/* Uncomment this if you need to return SVs
case PERL_constant_ISSV:
EXTEND(SP, 1);
PUSHs(&PL_sv_undef);
PUSHs(sv);
break; */
/* Uncomment this if you need to return UNDEFs
case PERL_constant_ISUNDEF:
break; */
/* Uncomment this if you need to return UVs
case PERL_constant_ISUV:
EXTEND(SP, 1);
PUSHs(&PL_sv_undef);
PUSHu((UV)iv);
break; */
/* Uncomment this if you need to return YESs
case PERL_constant_ISYES:
EXTEND(SP, 1);
PUSHs(&PL_sv_undef);
PUSHs(&PL_sv_yes);
break; */
default:
sv = sv_2mortal(newSVpvf(
"Unexpected return type %d while processing BerkeleyDB macro %s, used",
type, s));
PUSHs(sv);
}

133
perl/BerkeleyDB/dbinfo Normal file
View File

@@ -0,0 +1,133 @@
#!/usr/local/bin/perl
# Name: dbinfo -- identify berkeley DB version used to create
# a database file
#
# Author: Paul Marquess <Paul.Marquess@btinternet.com>
# Version: 1.06
# Date 27th MArch 2008
#
# Copyright (c) 1998-2008 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.
# Todo: Print more stats on a db file, e.g. no of records
# add log/txn/lock files
use strict ;
my %Data =
(
0x053162 => # DB_BTREEMAGIC
{
Type => "Btree",
Versions => # DB_BTREEVERSION
{
1 => [0, "Unknown (older than 1.71)"],
2 => [0, "Unknown (older than 1.71)"],
3 => [0, "1.71 -> 1.85, 1.86"],
4 => [0, "Unknown"],
5 => [0, "2.0.0 -> 2.3.0"],
6 => [0, "2.3.1 -> 2.7.7"],
7 => [0, "3.0.x"],
8 => [0, "3.1.x -> 4.0.x"],
9 => [1, "4.1.x or greater"],
}
},
0x061561 => # DB_HASHMAGIC
{
Type => "Hash",
Versions => # DB_HASHVERSION
{
1 => [0, "Unknown (older than 1.71)"],
2 => [0, "1.71 -> 1.85"],
3 => [0, "1.86"],
4 => [0, "2.0.0 -> 2.1.0"],
5 => [0, "2.2.6 -> 2.7.7"],
6 => [0, "3.0.x"],
7 => [0, "3.1.x -> 4.0.x"],
8 => [1, "4.1.x or greater"],
9 => [1, "4.6.x or greater"],
}
},
0x042253 => # DB_QAMMAGIC
{
Type => "Queue",
Versions => # DB_QAMVERSION
{
1 => [0, "3.0.x"],
2 => [0, "3.1.x"],
3 => [0, "3.2.x -> 4.0.x"],
4 => [1, "4.1.x or greater"],
}
},
) ;
die "Usage: dbinfo file\n" unless @ARGV == 1 ;
print "testing file $ARGV[0]...\n\n" ;
open (F, "<$ARGV[0]") or die "Cannot open file $ARGV[0]: $!\n" ;
my $buff ;
read F, $buff, 30 ;
my (@info) = unpack("NNNNNNC", $buff) ;
my (@info1) = unpack("VVVVVVC", $buff) ;
my ($magic, $version, $endian, $encrypt) ;
if ($Data{$info[0]}) # first try DB 1.x format, big endian
{
$magic = $info[0] ;
$version = $info[1] ;
$endian = "Big Endian" ;
$encrypt = "Not Supported";
}
elsif ($Data{$info1[0]}) # first try DB 1.x format, little endian
{
$magic = $info1[0] ;
$version = $info1[1] ;
$endian = "Little Endian" ;
$encrypt = "Not Supported";
}
elsif ($Data{$info[3]}) # next DB 2.x big endian
{
$magic = $info[3] ;
$version = $info[4] ;
$endian = "Big Endian" ;
}
elsif ($Data{$info1[3]}) # next DB 2.x little endian
{
$magic = $info1[3] ;
$version = $info1[4] ;
$endian = "Little Endian" ;
}
else
{ die "not a Berkeley DB database file.\n" }
my $type = $Data{$magic} ;
$magic = sprintf "%06X", $magic ;
my $ver_string = "Unknown" ;
if ( defined $type->{Versions}{$version} )
{
$ver_string = $type->{Versions}{$version}[1];
if ($type->{Versions}{$version}[0] )
{ $encrypt = $info[6] ? "Enabled" : "Disabled" }
else
{ $encrypt = "Not Supported" }
}
print <<EOM ;
File Type: Berkeley DB $type->{Type} file.
File Version ID: $version
Built with Berkeley DB: $ver_string
Byte Order: $endian
Magic: $magic
Encryption: $encrypt
EOM
close F ;
exit ;

View File

@@ -0,0 +1 @@
$self->{LIBS} = [ "@{$self->{LIBS}} -lpthreads" ];

View File

@@ -0,0 +1 @@
$self->{LIBS} = [ "@{$self->{LIBS}} -lthread" ];

View File

@@ -0,0 +1 @@
$self->{LIBS} = [ "@{$self->{LIBS}} -lmt" ];

969
perl/BerkeleyDB/mkconsts Normal file
View File

@@ -0,0 +1,969 @@
#!/usr/bin/perl
use ExtUtils::Constant qw(WriteConstants);
use constant DEFINE => 'define' ;
use constant STRING => 'string' ;
use constant IGNORE => 'ignore' ;
%constants = (
#########
# 2.0.3
#########
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_SEQUENTIAL => DEFINE,
DB_SET => DEFINE,
DB_SET_RANGE => DEFINE,
DB_SNAPSHOT => DEFINE,
DB_SWAPBYTES => DEFINE,
DB_TEMPORARY => 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.3',
DB_HASH => '2.0.3',
DB_RECNO => '2.0.3',
DB_UNKNOWN => '2.0.3',
# enum db_lockop_t
DB_LOCK_DUMP => '2.0.3',
DB_LOCK_GET => '2.0.3',
DB_LOCK_PUT => '2.0.3',
DB_LOCK_PUT_ALL => '2.0.3',
DB_LOCK_PUT_OBJ => '2.0.3',
# enum db_lockmode_t
DB_LOCK_NG => IGNORE, # 2.0.3
DB_LOCK_READ => IGNORE, # 2.0.3
DB_LOCK_WRITE => IGNORE, # 2.0.3
DB_LOCK_IREAD => IGNORE, # 2.0.3
DB_LOCK_IWRITE => IGNORE, # 2.0.3
DB_LOCK_IWR => IGNORE, # 2.0.3
# enum ACTION
FIND => IGNORE, # 2.0.3
ENTER => IGNORE, # 2.0.3
#########
# 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.10
#########
DB_APPEND => DEFINE,
DB_GET_RECNO => DEFINE,
DB_SET_RECNO => DEFINE,
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.9
#########
DBC_CONTINUE => IGNORE,
DBC_KEYSET => IGNORE,
DBC_RECOVER => IGNORE,
DBC_RMW => IGNORE,
DB_DBM_ERROR => IGNORE,
DB_DUPSORT => DEFINE,
DB_GET_BOTH => DEFINE,
DB_JOIN_ITEM => DEFINE,
DB_NEXT_DUP => DEFINE,
DB_OPFLAGS_MASK => DEFINE,
DB_RMW => DEFINE,
DB_RUNRECOVERY => DEFINE,
dbmclose => IGNORE,
#########
# 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.14
#########
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.14',
DB_TXN_BACKWARD_ROLL => '3.1.14',
DB_TXN_FORWARD_ROLL => '3.1.14',
DB_TXN_OPENFILES => '3.1.14',
#########
# 3.2.9
#########
DBC_COMPENSATE => IGNORE,
DB_ALREADY_ABORTED => DEFINE,
DB_AM_VERIFYING => IGNORE,
DB_CDB_ALLDB => DEFINE,
DB_CONSUME_WAIT => DEFINE,
DB_ENV_CDB_ALLDB => DEFINE,
DB_EXTENT => DEFINE,
DB_JAVA_CALLBACK => DEFINE,
DB_JOINENV => DEFINE,
DB_LOCK_SWITCH => DEFINE,
DB_MPOOL_EXTENT => DEFINE,
DB_REGION_MAGIC => DEFINE,
DB_VERIFY => DEFINE,
# enum db_lockmode_t
DB_LOCK_WAIT => IGNORE, # 3.2.9
#########
# 3.3.11
#########
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_SECONDARY_BAD => DEFINE,
DB_SURPRISE_KID => DEFINE,
DB_TEST_POSTDESTROY => DEFINE,
DB_TEST_PREDESTROY => DEFINE,
DB_UPDATE_SECONDARY => DEFINE,
DB_XIDDATASIZE => DEFINE,
# enum db_recops
DB_TXN_POPENFILES => '3.3.11',
# enum db_lockop_t
DB_LOCK_UPGRADE_WRITE => '3.3.11',
# enum db_lockmode_t
DB_LOCK_DIRTY => IGNORE, # 3.3.11
DB_LOCK_WWRITE => IGNORE, # 3.3.11
#########
# 4.0.14
#########
DB_APPLY_LOGREG => DEFINE,
DB_CL_WRITER => DEFINE,
DB_EID_BROADCAST => DEFINE,
DB_EID_INVALID => 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_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_VERB_REPLICATION => 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.14',
# enum db_lockop_t
DB_LOCK_GET_TIMEOUT => '4.0.14',
DB_LOCK_PUT_READ => '4.0.14',
DB_LOCK_TIMEOUT => '4.0.14',
# enum db_status_t
DB_LSTAT_EXPIRED => IGNORE, # 4.0.14
#########
# 4.1.24
#########
DBC_OWN_LID => IGNORE,
DB_AM_CHKSUM => IGNORE,
DB_AM_CL_WRITER => IGNORE,
DB_AM_COMPENSATE => IGNORE,
DB_AM_CREATED => IGNORE,
DB_AM_CREATED_MSTR => IGNORE,
DB_AM_DBM_ERROR => IGNORE,
DB_AM_DELIMITER => IGNORE,
DB_AM_ENCRYPT => IGNORE,
DB_AM_FIXEDLEN => IGNORE,
DB_AM_IN_RENAME => IGNORE,
DB_AM_OPEN_CALLED => IGNORE,
DB_AM_PAD => IGNORE,
DB_AM_RECNUM => IGNORE,
DB_AM_RENUMBER => IGNORE,
DB_AM_REVSPLITOFF => IGNORE,
DB_AM_SNAPSHOT => IGNORE,
DB_AUTO_COMMIT => DEFINE,
DB_CHKSUM_SHA1 => DEFINE,
DB_DIRECT => DEFINE,
DB_DIRECT_DB => DEFINE,
DB_DIRECT_LOG => DEFINE,
DB_ENCRYPT => DEFINE,
DB_ENCRYPT_AES => DEFINE,
DB_ENV_AUTO_COMMIT => DEFINE,
DB_ENV_DIRECT_DB => DEFINE,
DB_ENV_DIRECT_LOG => DEFINE,
DB_ENV_FATAL => DEFINE,
DB_ENV_OVERWRITE => DEFINE,
DB_ENV_TXN_WRITE_NOSYNC => DEFINE,
DB_HANDLE_LOCK => DEFINE,
DB_LOCK_NOTEXIST => DEFINE,
DB_LOCK_REMOVE => DEFINE,
DB_NOCOPY => DEFINE,
DB_OVERWRITE => DEFINE,
DB_PERMANENT => DEFINE,
DB_PRINTABLE => DEFINE,
DB_RENAMEMAGIC => DEFINE,
DB_TEST_ELECTINIT => DEFINE,
DB_TEST_ELECTSEND => DEFINE,
DB_TEST_ELECTVOTE1 => DEFINE,
DB_TEST_ELECTVOTE2 => DEFINE,
DB_TEST_ELECTWAIT1 => DEFINE,
DB_TEST_ELECTWAIT2 => DEFINE,
DB_TEST_SUBDB_LOCKS => DEFINE,
DB_TXN_LOCK => DEFINE,
DB_TXN_WRITE_NOSYNC => DEFINE,
DB_WRITEOPEN => DEFINE,
DB_WRNOSYNC => DEFINE,
_DB_EXT_PROT_IN_ => IGNORE,
# enum db_lockop_t
DB_LOCK_TRADE => '4.1.24',
# enum db_status_t
DB_LSTAT_NOTEXIST => IGNORE, # 4.1.24
# enum DB_CACHE_PRIORITY
DB_PRIORITY_VERY_LOW => '4.1.24',
DB_PRIORITY_LOW => '4.1.24',
DB_PRIORITY_DEFAULT => '4.1.24',
DB_PRIORITY_HIGH => '4.1.24',
DB_PRIORITY_VERY_HIGH => '4.1.24',
# enum db_recops
#DB_TXN_BACKWARD_ALLOC => '4.1.24',
DB_TXN_PRINT => '4.1.24',
#########
# 4.2.50
#########
DB_AM_NOT_DURABLE => IGNORE,
DB_AM_REPLICATION => IGNORE,
DB_ARCH_REMOVE => DEFINE,
DB_CHKSUM => DEFINE,
DB_ENV_LOG_AUTOREMOVE => DEFINE,
DB_ENV_TIME_NOTGRANTED => DEFINE,
DB_ENV_TXN_NOT_DURABLE => DEFINE,
DB_FILEOPEN => DEFINE,
DB_INIT_REP => DEFINE,
DB_LOG_AUTOREMOVE => DEFINE,
DB_LOG_CHKPNT => DEFINE,
DB_LOG_COMMIT => DEFINE,
DB_LOG_NOCOPY => DEFINE,
DB_LOG_NOT_DURABLE => DEFINE,
DB_LOG_PERM => DEFINE,
DB_LOG_WRNOSYNC => DEFINE,
DB_MPOOL_NOFILE => DEFINE,
DB_MPOOL_UNLINK => DEFINE,
DB_NO_AUTO_COMMIT => DEFINE,
DB_REP_CREATE => DEFINE,
DB_REP_HANDLE_DEAD => DEFINE,
DB_REP_ISPERM => DEFINE,
DB_REP_NOBUFFER => DEFINE,
DB_REP_NOTPERM => DEFINE,
DB_RPCCLIENT => DEFINE,
DB_TIME_NOTGRANTED => DEFINE,
DB_TXN_NOT_DURABLE => DEFINE,
DB_debug_FLAG => DEFINE,
DB_user_BEGIN => DEFINE,
MP_FILEID_SET => IGNORE,
TXN_RESTORED => IGNORE,
#########
# 4.3.21
#########
DBC_DEGREE_2 => IGNORE,
DB_AM_INORDER => IGNORE,
DB_BUFFER_SMALL => DEFINE,
DB_DEGREE_2 => DEFINE,
DB_DSYNC_LOG => DEFINE,
DB_DURABLE_UNKNOWN => DEFINE,
DB_ENV_DSYNC_LOG => DEFINE,
DB_ENV_LOG_INMEMORY => DEFINE,
DB_INORDER => DEFINE,
DB_LOCK_ABORT => DEFINE,
DB_LOCK_MAXWRITE => DEFINE,
DB_LOG_BUFFER_FULL => DEFINE,
DB_LOG_INMEMORY => DEFINE,
DB_LOG_RESEND => DEFINE,
DB_MPOOL_FREE => DEFINE,
DB_REP_EGENCHG => DEFINE,
DB_REP_LOGREADY => DEFINE,
DB_REP_PAGEDONE => DEFINE,
DB_REP_STARTUPDONE => DEFINE,
DB_SEQUENCE_VERSION => DEFINE,
DB_SEQ_DEC => DEFINE,
DB_SEQ_INC => DEFINE,
DB_SEQ_RANGE_SET => DEFINE,
DB_SEQ_WRAP => DEFINE,
DB_STAT_ALL => DEFINE,
DB_STAT_LOCK_CONF => DEFINE,
DB_STAT_LOCK_LOCKERS => DEFINE,
DB_STAT_LOCK_OBJECTS => DEFINE,
DB_STAT_LOCK_PARAMS => DEFINE,
DB_STAT_MEMP_HASH => DEFINE,
DB_STAT_SUBSYSTEM => DEFINE,
DB_UNREF => DEFINE,
DB_VERSION_MISMATCH => DEFINE,
TXN_DEADLOCK => IGNORE,
TXN_DEGREE_2 => IGNORE,
#########
# 4.3.28
#########
DB_SEQUENCE_OLDVER => DEFINE,
#########
# 4.4.16
#########
DBC_READ_COMMITTED => IGNORE,
DBC_READ_UNCOMMITTED => IGNORE,
DB_AM_READ_UNCOMMITTED => IGNORE,
DB_ASSOC_IMMUTABLE_KEY => DEFINE,
DB_COMPACT_FLAGS => DEFINE,
DB_DSYNC_DB => DEFINE,
DB_ENV_DSYNC_DB => DEFINE,
DB_FREELIST_ONLY => DEFINE,
DB_FREE_SPACE => DEFINE,
DB_IMMUTABLE_KEY => DEFINE,
DB_MUTEX_ALLOCATED => DEFINE,
DB_MUTEX_LOCKED => DEFINE,
DB_MUTEX_LOGICAL_LOCK => DEFINE,
DB_MUTEX_SELF_BLOCK => DEFINE,
DB_MUTEX_THREAD => DEFINE,
DB_READ_COMMITTED => DEFINE,
DB_READ_UNCOMMITTED => DEFINE,
DB_REGISTER => DEFINE,
DB_REP_ANYWHERE => DEFINE,
DB_REP_BULKOVF => DEFINE,
DB_REP_CONF_BULK => DEFINE,
DB_REP_CONF_DELAYCLIENT => DEFINE,
DB_REP_CONF_NOAUTOINIT => DEFINE,
DB_REP_CONF_NOWAIT => DEFINE,
DB_REP_IGNORE => DEFINE,
DB_REP_JOIN_FAILURE => DEFINE,
DB_REP_LOCKOUT => DEFINE,
DB_REP_REREQUEST => DEFINE,
DB_SEQ_WRAPPED => DEFINE,
DB_THREADID_STRLEN => DEFINE,
DB_VERB_REGISTER => DEFINE,
TXN_READ_COMMITTED => IGNORE,
TXN_READ_UNCOMMITTED => IGNORE,
TXN_SYNC_FLAGS => IGNORE,
TXN_WRITE_NOSYNC => IGNORE,
# enum db_lockmode_t
DB_LOCK_READ_UNCOMMITTED => IGNORE, # 4.4.16
#########
# 4.5.20
#########
DBC_DONTLOCK => IGNORE,
DB_DBT_USERCOPY => IGNORE,
DB_ENV_MULTIVERSION => DEFINE,
DB_ENV_TXN_SNAPSHOT => DEFINE,
DB_EVENT_NO_SUCH_EVENT => DEFINE,
DB_EVENT_PANIC => DEFINE,
DB_EVENT_REP_CLIENT => DEFINE,
DB_EVENT_REP_MASTER => DEFINE,
DB_EVENT_REP_NEWMASTER => DEFINE,
DB_EVENT_REP_STARTUPDONE => DEFINE,
DB_EVENT_WRITE_FAILED => DEFINE,
DB_MPOOL_EDIT => DEFINE,
DB_MULTIVERSION => DEFINE,
DB_MUTEX_PROCESS_ONLY => DEFINE,
DB_REPMGR_ACKS_ALL => DEFINE,
DB_REPMGR_ACKS_ALL_PEERS => DEFINE,
DB_REPMGR_ACKS_NONE => DEFINE,
DB_REPMGR_ACKS_ONE => DEFINE,
DB_REPMGR_ACKS_ONE_PEER => DEFINE,
DB_REPMGR_ACKS_QUORUM => DEFINE,
DB_REPMGR_CONNECTED => DEFINE,
DB_REPMGR_DISCONNECTED => DEFINE,
DB_REPMGR_PEER => DEFINE,
DB_REP_ACK_TIMEOUT => DEFINE,
DB_REP_CONNECTION_RETRY => DEFINE,
DB_REP_ELECTION => DEFINE,
DB_REP_ELECTION_RETRY => DEFINE,
DB_REP_ELECTION_TIMEOUT => DEFINE,
DB_REP_FULL_ELECTION => DEFINE,
DB_STAT_NOERROR => DEFINE,
DB_TEST_RECYCLE => DEFINE,
DB_TXN_SNAPSHOT => DEFINE,
DB_USERCOPY_GETDATA => DEFINE,
DB_USERCOPY_SETDATA => DEFINE,
MP_MULTIVERSION => IGNORE,
TXN_ABORTED => IGNORE,
TXN_CDSGROUP => IGNORE,
TXN_COMMITTED => IGNORE,
TXN_PREPARED => IGNORE,
TXN_PRIVATE => IGNORE,
TXN_RUNNING => IGNORE,
TXN_SNAPSHOT => IGNORE,
TXN_XA_ABORTED => IGNORE,
TXN_XA_DEADLOCKED => IGNORE,
TXN_XA_ENDED => IGNORE,
TXN_XA_PREPARED => IGNORE,
TXN_XA_STARTED => IGNORE,
TXN_XA_SUSPENDED => IGNORE,
#########
# 4.6.11
#########
DB_CKP_INTERNAL => DEFINE,
DB_DBT_MULTIPLE => IGNORE,
DB_ENV_NO_OUTPUT_SET => DEFINE,
DB_ENV_RECOVER_FATAL => DEFINE,
DB_ENV_REF_COUNTED => DEFINE,
DB_ENV_TXN_NOWAIT => DEFINE,
DB_EVENT_NOT_HANDLED => DEFINE,
DB_EVENT_REP_ELECTED => DEFINE,
DB_EVENT_REP_PERM_FAILED => DEFINE,
DB_IGNORE_LEASE => DEFINE,
DB_PREV_DUP => DEFINE,
DB_REPFLAGS_MASK => DEFINE,
DB_REP_CHECKPOINT_DELAY => DEFINE,
DB_REP_DEFAULT_PRIORITY => DEFINE,
DB_REP_FULL_ELECTION_TIMEOUT => DEFINE,
DB_REP_LEASE_EXPIRED => DEFINE,
DB_REP_LEASE_TIMEOUT => DEFINE,
DB_SPARE_FLAG => DEFINE,
DB_TXN_WAIT => DEFINE,
DB_VERB_FILEOPS => DEFINE,
DB_VERB_FILEOPS_ALL => DEFINE,
# enum DB_CACHE_PRIORITY
DB_PRIORITY_UNCHANGED => '4.6.11',
#########
# 4.7.16
#########
DBC_DUPLICATE => IGNORE,
DB_FOREIGN_ABORT => DEFINE,
DB_FOREIGN_CASCADE => DEFINE,
DB_FOREIGN_CONFLICT => DEFINE,
DB_FOREIGN_NULLIFY => DEFINE,
DB_LOG_AUTO_REMOVE => DEFINE,
DB_LOG_DIRECT => DEFINE,
DB_LOG_DSYNC => DEFINE,
DB_LOG_IN_MEMORY => DEFINE,
DB_LOG_ZERO => DEFINE,
DB_MPOOL_NOLOCK => DEFINE,
DB_REPMGR_CONF_2SITE_STRICT => DEFINE,
DB_REP_CONF_LEASE => DEFINE,
DB_REP_HEARTBEAT_MONITOR => DEFINE,
DB_REP_HEARTBEAT_SEND => DEFINE,
DB_SA_SKIPFIRSTKEY => DEFINE,
DB_STAT_MEMP_NOERROR => DEFINE,
DB_ST_DUPOK => DEFINE,
DB_ST_DUPSET => DEFINE,
DB_ST_DUPSORT => DEFINE,
DB_ST_IS_RECNO => DEFINE,
DB_ST_OVFL_LEAF => DEFINE,
DB_ST_RECNUM => DEFINE,
DB_ST_RELEN => DEFINE,
DB_ST_TOPLEVEL => DEFINE,
DB_VERB_REPMGR_CONNFAIL => DEFINE,
DB_VERB_REPMGR_MISC => DEFINE,
DB_VERB_REP_ELECT => DEFINE,
DB_VERB_REP_LEASE => DEFINE,
DB_VERB_REP_MISC => DEFINE,
DB_VERB_REP_MSGS => DEFINE,
DB_VERB_REP_SYNC => DEFINE,
MP_DUMMY => IGNORE,
) ;
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
{
my @names = () ;
foreach my $key (sort keys %constants)
{
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"] } }
}
warn "Updating constants.xs & constants.h...\n";
WriteConstants(
NAME => BerkeleyDB,
NAMES => \@names,
C_FILE => 'constants.h',
XS_FILE => 'constants.xs',
) ;
}
sub OutputPM
{
my $filename = 'BerkeleyDB.pm';
warn "Updating $filename...\n";
open IN, "<$filename" || die "Cannot open $filename: $!\n";
open OUT, ">$filename.tmp" || die "Cannot open $filename.tmp: $!\n";
my $START = '@EXPORT = qw(' ;
my $START_re = quotemeta $START ;
my $END = ');';
my $END_re = quotemeta $END ;
# skip to the @EXPORT declaration
OUTER: while (<IN>)
{
if ( /^\s*$START_re/ )
{
# skip to the end marker.
while (<IN>)
{ last OUTER if /^\s*$END_re/ }
}
print OUT ;
}
print OUT "$START\n";
foreach my $key (sort keys %constants)
{
next if $constants{$key} eq IGNORE;
print OUT "\t$key\n";
}
print OUT "\t$END\n";
while (<IN>)
{
print OUT ;
}
close IN;
close OUT;
rename $filename, "$filename.bak" || die "Cannot rename $filename: $!\n" ;
rename "$filename.tmp", $filename || die "Cannot rename $filename.tmp: $!\n" ;
}
OutputXS() ;
OutputPM() ;

146
perl/BerkeleyDB/mkpod Normal file
View File

@@ -0,0 +1,146 @@
#!/usr/local/bin/perl5
# Filename: mkpod
#
# Author: Paul Marquess
# File types
#
# Macro files end with .M
# Tagged source files end with .T
# Output from the code ends with .O
# Pre-Pod file ends with .P
#
# Tags
#
# ## BEGIN tagname
# ...
# ## END tagname
#
# ## 0
# ## 1
#
# Constants
$TOKEN = '##' ;
$Verbose = 1 if $ARGV[0] =~ /^-v/i ;
# Macros files first
foreach $file (glob("*.M"))
{
open (F, "<$file") or die "Cannot open '$file':$!\n" ;
print " Processing Macro file $file\n" ;
while (<F>)
{
# Skip blank & comment lines
next if /^\s*$/ || /^\s*#/ ;
#
($name, $expand) = split (/\t+/, $_, 2) ;
$expand =~ s/^\s*// ;
$expand =~ s/\s*$// ;
if ($expand =~ /\[#/ )
{
}
$Macros{$name} = $expand ;
}
close F ;
}
# Suck up all the code files
foreach $file (glob("t/*.T"))
{
($newfile = $file) =~ s/\.T$// ;
open (F, "<$file") or die "Cannot open '$file':$!\n" ;
open (N, ">$newfile") or die "Cannot open '$newfile':$!\n" ;
print " Processing $file -> $newfile\n" ;
while ($line = <F>)
{
if ($line =~ /^$TOKEN\s*BEGIN\s+(\w+)\s*$/ or
$line =~ m[\s*/\*$TOKEN\s*BEGIN\s+(\w+)\s*$] )
{
print " Section $1 begins\n" if $Verbose ;
$InSection{$1} ++ ;
$Section{$1} = '' unless $Section{$1} ;
}
elsif ($line =~ /^$TOKEN\s*END\s+(\w+)\s*$/ or
$line =~ m[^\s*/\*$TOKEN\s*END\s+(\w+)\s*$] )
{
warn "Encountered END without a begin [$line]\n"
unless $InSection{$1} ;
delete $InSection{$1} ;
print " Section $1 ends\n" if $Verbose ;
}
else
{
print N $line ;
chop $line ;
$line =~ s/\s*$// ;
# Save the current line in each of the sections
foreach( keys %InSection)
{
if ($line !~ /^\s*$/ )
#{ $Section{$_} .= " $line" }
{ $Section{$_} .= $line }
$Section{$_} .= "\n" ;
}
}
}
if (%InSection)
{
# Check for unclosed sections
print "The following Sections are not terminated\n" ;
foreach (sort keys %InSection)
{ print "\t$_\n" }
exit 1 ;
}
close F ;
close N ;
}
print "\n\nCreating pod file(s)\n\n" if $Verbose ;
@ppods = glob('*.P') ;
#$ppod = $ARGV[0] ;
#$pod = $ARGV[1] ;
# Now process the pre-pod file
foreach $ppod (@ppods)
{
($pod = $ppod) =~ s/\.P$// ;
open (PPOD, "<$ppod") or die "Cannot open file '$ppod': $!\n" ;
open (POD, ">$pod") or die "Cannot open file '$pod': $!\n" ;
print " $ppod -> $pod\n" ;
while ($line = <PPOD>)
{
if ( $line =~ /^\s*$TOKEN\s*(\w+)\s*$/)
{
warn "No code insert '$1' available\n"
unless $Section{$1} ;
print "Expanding section $1\n" if $Verbose ;
print POD $Section{$1} ;
}
else
{
# $line =~ s/\[#([^\]])]/$Macros{$1}/ge ;
print POD $line ;
}
}
close PPOD ;
close POD ;
}

View File

@@ -0,0 +1,93 @@
diff -rc perl5.004.orig/Configure perl5.004/Configure
*** perl5.004.orig/Configure 1997-05-13 18:20:34.000000000 +0100
--- perl5.004/Configure 2003-04-26 16:36:53.000000000 +0100
***************
*** 188,193 ****
--- 188,194 ----
mv=''
nroff=''
perl=''
+ perllibs=''
pg=''
pmake=''
pr=''
***************
*** 9902,9907 ****
--- 9903,9916 ----
shift
extensions="$*"
+ : Remove libraries needed only for extensions
+ : The appropriate ext/Foo/Makefile.PL will add them back in, if
+ : necessary.
+ set X `echo " $libs " |
+ sed -e 's@ -lndbm @ @' -e 's@ -lgdbm @ @' -e 's@ -ldbm @ @' -e 's@ -ldb @ @'`
+ shift
+ perllibs="$*"
+
: Remove build directory name from cppstdin so it can be used from
: either the present location or the final installed location.
echo " "
***************
*** 10370,10375 ****
--- 10379,10385 ----
patchlevel='$patchlevel'
path_sep='$path_sep'
perl='$perl'
+ perllibs='$perllibs'
perladmin='$perladmin'
perlpath='$perlpath'
pg='$pg'
diff -rc perl5.004.orig/Makefile.SH perl5.004/Makefile.SH
*** perl5.004.orig/Makefile.SH 1997-05-01 15:22:39.000000000 +0100
--- perl5.004/Makefile.SH 2003-04-26 16:37:23.000000000 +0100
***************
*** 119,125 ****
ext = \$(dynamic_ext) \$(static_ext)
DYNALOADER = lib/auto/DynaLoader/DynaLoader\$(LIB_EXT)
! libs = $libs $cryptlib
public = perl $suidperl utilities translators
--- 119,125 ----
ext = \$(dynamic_ext) \$(static_ext)
DYNALOADER = lib/auto/DynaLoader/DynaLoader\$(LIB_EXT)
! libs = $perllibs $cryptlib
public = perl $suidperl utilities translators
diff -rc perl5.004.orig/myconfig perl5.004/myconfig
*** perl5.004.orig/myconfig 1996-12-21 01:13:20.000000000 +0000
--- perl5.004/myconfig 2003-04-26 16:37:51.000000000 +0100
***************
*** 35,41 ****
Linker and Libraries:
ld='$ld', ldflags ='$ldflags'
libpth=$libpth
! libs=$libs
libc=$libc, so=$so
useshrplib=$useshrplib, libperl=$libperl
Dynamic Linking:
--- 35,41 ----
Linker and Libraries:
ld='$ld', ldflags ='$ldflags'
libpth=$libpth
! libs=$perllibs
libc=$libc, so=$so
useshrplib=$useshrplib, libperl=$libperl
Dynamic Linking:
diff -rc perl5.004.orig/patchlevel.h perl5.004/patchlevel.h
*** perl5.004.orig/patchlevel.h 1997-05-15 23:15:17.000000000 +0100
--- perl5.004/patchlevel.h 2003-04-26 16:38:11.000000000 +0100
***************
*** 38,43 ****
--- 38,44 ----
*/
static char *local_patches[] = {
NULL
+ ,"NODB-1.0 - remove -ldb from core perl binary."
,NULL
};

View File

@@ -0,0 +1,217 @@
diff -rc perl5.004_01.orig/Configure perl5.004_01/Configure
*** perl5.004_01.orig/Configure Wed Jun 11 00:28:03 1997
--- perl5.004_01/Configure Sun Nov 12 22:12:35 2000
***************
*** 188,193 ****
--- 188,194 ----
mv=''
nroff=''
perl=''
+ perllibs=''
pg=''
pmake=''
pr=''
***************
*** 9907,9912 ****
--- 9908,9921 ----
shift
extensions="$*"
+ : Remove libraries needed only for extensions
+ : The appropriate ext/Foo/Makefile.PL will add them back in, if
+ : necessary.
+ set X `echo " $libs " |
+ sed -e 's@ -lndbm @ @' -e 's@ -lgdbm @ @' -e 's@ -ldbm @ @' -e 's@ -ldb @ @'`
+ shift
+ perllibs="$*"
+
: Remove build directory name from cppstdin so it can be used from
: either the present location or the final installed location.
echo " "
***************
*** 10375,10380 ****
--- 10384,10390 ----
patchlevel='$patchlevel'
path_sep='$path_sep'
perl='$perl'
+ perllibs='$perllibs'
perladmin='$perladmin'
perlpath='$perlpath'
pg='$pg'
diff -rc perl5.004_01.orig/Makefile.SH perl5.004_01/Makefile.SH
*** perl5.004_01.orig/Makefile.SH Thu Jun 12 23:27:56 1997
--- perl5.004_01/Makefile.SH Sun Nov 12 22:12:35 2000
***************
*** 126,132 ****
ext = \$(dynamic_ext) \$(static_ext)
DYNALOADER = lib/auto/DynaLoader/DynaLoader\$(LIB_EXT)
! libs = $libs $cryptlib
public = perl $suidperl utilities translators
--- 126,132 ----
ext = \$(dynamic_ext) \$(static_ext)
DYNALOADER = lib/auto/DynaLoader/DynaLoader\$(LIB_EXT)
! libs = $perllibs $cryptlib
public = perl $suidperl utilities translators
diff -rc perl5.004_01.orig/lib/ExtUtils/Embed.pm perl5.004_01/lib/ExtUtils/Embed.pm
*** perl5.004_01.orig/lib/ExtUtils/Embed.pm Wed Apr 2 22:12:04 1997
--- perl5.004_01/lib/ExtUtils/Embed.pm Sun Nov 12 22:12:35 2000
***************
*** 170,176 ****
@path = $path ? split(/:/, $path) : @INC;
push(@potential_libs, @link_args) if scalar @link_args;
! push(@potential_libs, $Config{libs}) if defined $std;
push(@mods, static_ext()) if $std;
--- 170,176 ----
@path = $path ? split(/:/, $path) : @INC;
push(@potential_libs, @link_args) if scalar @link_args;
! push(@potential_libs, $Config{perllibs}) if defined $std;
push(@mods, static_ext()) if $std;
diff -rc perl5.004_01.orig/lib/ExtUtils/Liblist.pm perl5.004_01/lib/ExtUtils/Liblist.pm
*** perl5.004_01.orig/lib/ExtUtils/Liblist.pm Sat Jun 7 01:19:44 1997
--- perl5.004_01/lib/ExtUtils/Liblist.pm Sun Nov 12 22:13:27 2000
***************
*** 16,33 ****
sub _unix_os2_ext {
my($self,$potential_libs, $Verbose) = @_;
! if ($^O =~ 'os2' and $Config{libs}) {
# Dynamic libraries are not transitive, so we may need including
# the libraries linked against perl.dll again.
$potential_libs .= " " if $potential_libs;
! $potential_libs .= $Config{libs};
}
return ("", "", "", "") unless $potential_libs;
print STDOUT "Potential libraries are '$potential_libs':\n" if $Verbose;
my($so) = $Config{'so'};
! my($libs) = $Config{'libs'};
my $Config_libext = $Config{lib_ext} || ".a";
--- 16,33 ----
sub _unix_os2_ext {
my($self,$potential_libs, $Verbose) = @_;
! if ($^O =~ 'os2' and $Config{perllibs}) {
# Dynamic libraries are not transitive, so we may need including
# the libraries linked against perl.dll again.
$potential_libs .= " " if $potential_libs;
! $potential_libs .= $Config{perllibs};
}
return ("", "", "", "") unless $potential_libs;
print STDOUT "Potential libraries are '$potential_libs':\n" if $Verbose;
my($so) = $Config{'so'};
! my($libs) = $Config{'perllibs'};
my $Config_libext = $Config{lib_ext} || ".a";
***************
*** 186,196 ****
my($self, $potential_libs, $Verbose) = @_;
# If user did not supply a list, we punt.
! # (caller should probably use the list in $Config{libs})
return ("", "", "", "") unless $potential_libs;
my($so) = $Config{'so'};
! my($libs) = $Config{'libs'};
my($libpth) = $Config{'libpth'};
my($libext) = $Config{'lib_ext'} || ".lib";
--- 186,196 ----
my($self, $potential_libs, $Verbose) = @_;
# If user did not supply a list, we punt.
! # (caller should probably use the list in $Config{perllibs})
return ("", "", "", "") unless $potential_libs;
my($so) = $Config{'so'};
! my($libs) = $Config{'perllibs'};
my($libpth) = $Config{'libpth'};
my($libext) = $Config{'lib_ext'} || ".lib";
***************
*** 540,546 ****
=item *
If C<$potential_libs> is empty, the return value will be empty.
! Otherwise, the libraries specified by C<$Config{libs}> (see Config.pm)
will be appended to the list of C<$potential_libs>. The libraries
will be searched for in the directories specified in C<$potential_libs>
as well as in C<$Config{libpth}>. For each library that is found, a
--- 540,546 ----
=item *
If C<$potential_libs> is empty, the return value will be empty.
! Otherwise, the libraries specified by C<$Config{perllibs}> (see Config.pm)
will be appended to the list of C<$potential_libs>. The libraries
will be searched for in the directories specified in C<$potential_libs>
as well as in C<$Config{libpth}>. For each library that is found, a
diff -rc perl5.004_01.orig/lib/ExtUtils/MM_Unix.pm perl5.004_01/lib/ExtUtils/MM_Unix.pm
*** perl5.004_01.orig/lib/ExtUtils/MM_Unix.pm Thu Jun 12 22:06:18 1997
--- perl5.004_01/lib/ExtUtils/MM_Unix.pm Sun Nov 12 22:12:35 2000
***************
*** 2137,2143 ****
MAP_STATIC = ",
join(" \\\n\t", reverse sort keys %static), "
! MAP_PRELIBS = $Config::Config{libs} $Config::Config{cryptlib}
";
if (defined $libperl) {
--- 2137,2143 ----
MAP_STATIC = ",
join(" \\\n\t", reverse sort keys %static), "
! MAP_PRELIBS = $Config::Config{perllibs} $Config::Config{cryptlib}
";
if (defined $libperl) {
diff -rc perl5.004_01.orig/myconfig perl5.004_01/myconfig
*** perl5.004_01.orig/myconfig Sat Dec 21 01:13:20 1996
--- perl5.004_01/myconfig Sun Nov 12 22:12:35 2000
***************
*** 35,41 ****
Linker and Libraries:
ld='$ld', ldflags ='$ldflags'
libpth=$libpth
! libs=$libs
libc=$libc, so=$so
useshrplib=$useshrplib, libperl=$libperl
Dynamic Linking:
--- 35,41 ----
Linker and Libraries:
ld='$ld', ldflags ='$ldflags'
libpth=$libpth
! libs=$perllibs
libc=$libc, so=$so
useshrplib=$useshrplib, libperl=$libperl
Dynamic Linking:
diff -rc perl5.004_01.orig/patchlevel.h perl5.004_01/patchlevel.h
*** perl5.004_01.orig/patchlevel.h Wed Jun 11 03:06:10 1997
--- perl5.004_01/patchlevel.h Sun Nov 12 22:12:35 2000
***************
*** 38,43 ****
--- 38,44 ----
*/
static char *local_patches[] = {
NULL
+ ,"NODB-1.0 - remove -ldb from core perl binary."
,NULL
};

View File

@@ -0,0 +1,217 @@
diff -rc perl5.004_02.orig/Configure perl5.004_02/Configure
*** perl5.004_02.orig/Configure Thu Aug 7 15:08:44 1997
--- perl5.004_02/Configure Sun Nov 12 22:06:24 2000
***************
*** 188,193 ****
--- 188,194 ----
mv=''
nroff=''
perl=''
+ perllibs=''
pg=''
pmake=''
pr=''
***************
*** 9911,9916 ****
--- 9912,9925 ----
shift
extensions="$*"
+ : Remove libraries needed only for extensions
+ : The appropriate ext/Foo/Makefile.PL will add them back in, if
+ : necessary.
+ set X `echo " $libs " |
+ sed -e 's@ -lndbm @ @' -e 's@ -lgdbm @ @' -e 's@ -ldbm @ @' -e 's@ -ldb @ @'`
+ shift
+ perllibs="$*"
+
: Remove build directory name from cppstdin so it can be used from
: either the present location or the final installed location.
echo " "
***************
*** 10379,10384 ****
--- 10388,10394 ----
patchlevel='$patchlevel'
path_sep='$path_sep'
perl='$perl'
+ perllibs='$perllibs'
perladmin='$perladmin'
perlpath='$perlpath'
pg='$pg'
diff -rc perl5.004_02.orig/Makefile.SH perl5.004_02/Makefile.SH
*** perl5.004_02.orig/Makefile.SH Thu Aug 7 13:10:53 1997
--- perl5.004_02/Makefile.SH Sun Nov 12 22:06:24 2000
***************
*** 126,132 ****
ext = \$(dynamic_ext) \$(static_ext)
DYNALOADER = lib/auto/DynaLoader/DynaLoader\$(LIB_EXT)
! libs = $libs $cryptlib
public = perl $suidperl utilities translators
--- 126,132 ----
ext = \$(dynamic_ext) \$(static_ext)
DYNALOADER = lib/auto/DynaLoader/DynaLoader\$(LIB_EXT)
! libs = $perllibs $cryptlib
public = perl $suidperl utilities translators
diff -rc perl5.004_02.orig/lib/ExtUtils/Embed.pm perl5.004_02/lib/ExtUtils/Embed.pm
*** perl5.004_02.orig/lib/ExtUtils/Embed.pm Fri Aug 1 15:08:44 1997
--- perl5.004_02/lib/ExtUtils/Embed.pm Sun Nov 12 22:06:24 2000
***************
*** 178,184 ****
@path = $path ? split(/:/, $path) : @INC;
push(@potential_libs, @link_args) if scalar @link_args;
! push(@potential_libs, $Config{libs}) if defined $std;
push(@mods, static_ext()) if $std;
--- 178,184 ----
@path = $path ? split(/:/, $path) : @INC;
push(@potential_libs, @link_args) if scalar @link_args;
! push(@potential_libs, $Config{perllibs}) if defined $std;
push(@mods, static_ext()) if $std;
diff -rc perl5.004_02.orig/lib/ExtUtils/Liblist.pm perl5.004_02/lib/ExtUtils/Liblist.pm
*** perl5.004_02.orig/lib/ExtUtils/Liblist.pm Fri Aug 1 19:36:58 1997
--- perl5.004_02/lib/ExtUtils/Liblist.pm Sun Nov 12 22:06:24 2000
***************
*** 16,33 ****
sub _unix_os2_ext {
my($self,$potential_libs, $verbose) = @_;
! if ($^O =~ 'os2' and $Config{libs}) {
# Dynamic libraries are not transitive, so we may need including
# the libraries linked against perl.dll again.
$potential_libs .= " " if $potential_libs;
! $potential_libs .= $Config{libs};
}
return ("", "", "", "") unless $potential_libs;
print STDOUT "Potential libraries are '$potential_libs':\n" if $verbose;
my($so) = $Config{'so'};
! my($libs) = $Config{'libs'};
my $Config_libext = $Config{lib_ext} || ".a";
--- 16,33 ----
sub _unix_os2_ext {
my($self,$potential_libs, $verbose) = @_;
! if ($^O =~ 'os2' and $Config{perllibs}) {
# Dynamic libraries are not transitive, so we may need including
# the libraries linked against perl.dll again.
$potential_libs .= " " if $potential_libs;
! $potential_libs .= $Config{perllibs};
}
return ("", "", "", "") unless $potential_libs;
print STDOUT "Potential libraries are '$potential_libs':\n" if $verbose;
my($so) = $Config{'so'};
! my($libs) = $Config{'perllibs'};
my $Config_libext = $Config{lib_ext} || ".a";
***************
*** 186,196 ****
my($self, $potential_libs, $verbose) = @_;
# If user did not supply a list, we punt.
! # (caller should probably use the list in $Config{libs})
return ("", "", "", "") unless $potential_libs;
my($so) = $Config{'so'};
! my($libs) = $Config{'libs'};
my($libpth) = $Config{'libpth'};
my($libext) = $Config{'lib_ext'} || ".lib";
--- 186,196 ----
my($self, $potential_libs, $verbose) = @_;
# If user did not supply a list, we punt.
! # (caller should probably use the list in $Config{perllibs})
return ("", "", "", "") unless $potential_libs;
my($so) = $Config{'so'};
! my($libs) = $Config{'perllibs'};
my($libpth) = $Config{'libpth'};
my($libext) = $Config{'lib_ext'} || ".lib";
***************
*** 540,546 ****
=item *
If C<$potential_libs> is empty, the return value will be empty.
! Otherwise, the libraries specified by C<$Config{libs}> (see Config.pm)
will be appended to the list of C<$potential_libs>. The libraries
will be searched for in the directories specified in C<$potential_libs>
as well as in C<$Config{libpth}>. For each library that is found, a
--- 540,546 ----
=item *
If C<$potential_libs> is empty, the return value will be empty.
! Otherwise, the libraries specified by C<$Config{perllibs}> (see Config.pm)
will be appended to the list of C<$potential_libs>. The libraries
will be searched for in the directories specified in C<$potential_libs>
as well as in C<$Config{libpth}>. For each library that is found, a
diff -rc perl5.004_02.orig/lib/ExtUtils/MM_Unix.pm perl5.004_02/lib/ExtUtils/MM_Unix.pm
*** perl5.004_02.orig/lib/ExtUtils/MM_Unix.pm Tue Aug 5 14:28:08 1997
--- perl5.004_02/lib/ExtUtils/MM_Unix.pm Sun Nov 12 22:06:25 2000
***************
*** 2224,2230 ****
MAP_STATIC = ",
join(" \\\n\t", reverse sort keys %static), "
! MAP_PRELIBS = $Config::Config{libs} $Config::Config{cryptlib}
";
if (defined $libperl) {
--- 2224,2230 ----
MAP_STATIC = ",
join(" \\\n\t", reverse sort keys %static), "
! MAP_PRELIBS = $Config::Config{perllibs} $Config::Config{cryptlib}
";
if (defined $libperl) {
diff -rc perl5.004_02.orig/myconfig perl5.004_02/myconfig
*** perl5.004_02.orig/myconfig Sat Dec 21 01:13:20 1996
--- perl5.004_02/myconfig Sun Nov 12 22:06:25 2000
***************
*** 35,41 ****
Linker and Libraries:
ld='$ld', ldflags ='$ldflags'
libpth=$libpth
! libs=$libs
libc=$libc, so=$so
useshrplib=$useshrplib, libperl=$libperl
Dynamic Linking:
--- 35,41 ----
Linker and Libraries:
ld='$ld', ldflags ='$ldflags'
libpth=$libpth
! libs=$perllibs
libc=$libc, so=$so
useshrplib=$useshrplib, libperl=$libperl
Dynamic Linking:
diff -rc perl5.004_02.orig/patchlevel.h perl5.004_02/patchlevel.h
*** perl5.004_02.orig/patchlevel.h Fri Aug 1 15:07:34 1997
--- perl5.004_02/patchlevel.h Sun Nov 12 22:06:25 2000
***************
*** 38,43 ****
--- 38,44 ----
*/
static char *local_patches[] = {
NULL
+ ,"NODB-1.0 - remove -ldb from core perl binary."
,NULL
};

View File

@@ -0,0 +1,223 @@
diff -rc perl5.004_03.orig/Configure perl5.004_03/Configure
*** perl5.004_03.orig/Configure Wed Aug 13 16:09:46 1997
--- perl5.004_03/Configure Sun Nov 12 21:56:18 2000
***************
*** 188,193 ****
--- 188,194 ----
mv=''
nroff=''
perl=''
+ perllibs=''
pg=''
pmake=''
pr=''
***************
*** 9911,9916 ****
--- 9912,9925 ----
shift
extensions="$*"
+ : Remove libraries needed only for extensions
+ : The appropriate ext/Foo/Makefile.PL will add them back in, if
+ : necessary.
+ set X `echo " $libs " |
+ sed -e 's@ -lndbm @ @' -e 's@ -lgdbm @ @' -e 's@ -ldbm @ @' -e 's@ -ldb @ @'`
+ shift
+ perllibs="$*"
+
: Remove build directory name from cppstdin so it can be used from
: either the present location or the final installed location.
echo " "
***************
*** 10379,10384 ****
--- 10388,10394 ----
patchlevel='$patchlevel'
path_sep='$path_sep'
perl='$perl'
+ perllibs='$perllibs'
perladmin='$perladmin'
perlpath='$perlpath'
pg='$pg'
Only in perl5.004_03: Configure.orig
diff -rc perl5.004_03.orig/Makefile.SH perl5.004_03/Makefile.SH
*** perl5.004_03.orig/Makefile.SH Mon Aug 18 19:24:29 1997
--- perl5.004_03/Makefile.SH Sun Nov 12 21:56:18 2000
***************
*** 126,132 ****
ext = \$(dynamic_ext) \$(static_ext)
DYNALOADER = lib/auto/DynaLoader/DynaLoader\$(LIB_EXT)
! libs = $libs $cryptlib
public = perl $suidperl utilities translators
--- 126,132 ----
ext = \$(dynamic_ext) \$(static_ext)
DYNALOADER = lib/auto/DynaLoader/DynaLoader\$(LIB_EXT)
! libs = $perllibs $cryptlib
public = perl $suidperl utilities translators
Only in perl5.004_03: Makefile.SH.orig
diff -rc perl5.004_03.orig/lib/ExtUtils/Embed.pm perl5.004_03/lib/ExtUtils/Embed.pm
*** perl5.004_03.orig/lib/ExtUtils/Embed.pm Fri Aug 1 15:08:44 1997
--- perl5.004_03/lib/ExtUtils/Embed.pm Sun Nov 12 21:56:18 2000
***************
*** 178,184 ****
@path = $path ? split(/:/, $path) : @INC;
push(@potential_libs, @link_args) if scalar @link_args;
! push(@potential_libs, $Config{libs}) if defined $std;
push(@mods, static_ext()) if $std;
--- 178,184 ----
@path = $path ? split(/:/, $path) : @INC;
push(@potential_libs, @link_args) if scalar @link_args;
! push(@potential_libs, $Config{perllibs}) if defined $std;
push(@mods, static_ext()) if $std;
diff -rc perl5.004_03.orig/lib/ExtUtils/Liblist.pm perl5.004_03/lib/ExtUtils/Liblist.pm
*** perl5.004_03.orig/lib/ExtUtils/Liblist.pm Fri Aug 1 19:36:58 1997
--- perl5.004_03/lib/ExtUtils/Liblist.pm Sun Nov 12 21:57:17 2000
***************
*** 16,33 ****
sub _unix_os2_ext {
my($self,$potential_libs, $verbose) = @_;
! if ($^O =~ 'os2' and $Config{libs}) {
# Dynamic libraries are not transitive, so we may need including
# the libraries linked against perl.dll again.
$potential_libs .= " " if $potential_libs;
! $potential_libs .= $Config{libs};
}
return ("", "", "", "") unless $potential_libs;
print STDOUT "Potential libraries are '$potential_libs':\n" if $verbose;
my($so) = $Config{'so'};
! my($libs) = $Config{'libs'};
my $Config_libext = $Config{lib_ext} || ".a";
--- 16,33 ----
sub _unix_os2_ext {
my($self,$potential_libs, $verbose) = @_;
! if ($^O =~ 'os2' and $Config{perllibs}) {
# Dynamic libraries are not transitive, so we may need including
# the libraries linked against perl.dll again.
$potential_libs .= " " if $potential_libs;
! $potential_libs .= $Config{perllibs};
}
return ("", "", "", "") unless $potential_libs;
print STDOUT "Potential libraries are '$potential_libs':\n" if $verbose;
my($so) = $Config{'so'};
! my($libs) = $Config{'perllibs'};
my $Config_libext = $Config{lib_ext} || ".a";
***************
*** 186,196 ****
my($self, $potential_libs, $verbose) = @_;
# If user did not supply a list, we punt.
! # (caller should probably use the list in $Config{libs})
return ("", "", "", "") unless $potential_libs;
my($so) = $Config{'so'};
! my($libs) = $Config{'libs'};
my($libpth) = $Config{'libpth'};
my($libext) = $Config{'lib_ext'} || ".lib";
--- 186,196 ----
my($self, $potential_libs, $verbose) = @_;
# If user did not supply a list, we punt.
! # (caller should probably use the list in $Config{perllibs})
return ("", "", "", "") unless $potential_libs;
my($so) = $Config{'so'};
! my($libs) = $Config{'perllibs'};
my($libpth) = $Config{'libpth'};
my($libext) = $Config{'lib_ext'} || ".lib";
***************
*** 540,546 ****
=item *
If C<$potential_libs> is empty, the return value will be empty.
! Otherwise, the libraries specified by C<$Config{libs}> (see Config.pm)
will be appended to the list of C<$potential_libs>. The libraries
will be searched for in the directories specified in C<$potential_libs>
as well as in C<$Config{libpth}>. For each library that is found, a
--- 540,546 ----
=item *
If C<$potential_libs> is empty, the return value will be empty.
! Otherwise, the libraries specified by C<$Config{perllibs}> (see Config.pm)
will be appended to the list of C<$potential_libs>. The libraries
will be searched for in the directories specified in C<$potential_libs>
as well as in C<$Config{libpth}>. For each library that is found, a
Only in perl5.004_03/lib/ExtUtils: Liblist.pm.orig
Only in perl5.004_03/lib/ExtUtils: Liblist.pm.rej
diff -rc perl5.004_03.orig/lib/ExtUtils/MM_Unix.pm perl5.004_03/lib/ExtUtils/MM_Unix.pm
*** perl5.004_03.orig/lib/ExtUtils/MM_Unix.pm Mon Aug 18 19:16:12 1997
--- perl5.004_03/lib/ExtUtils/MM_Unix.pm Sun Nov 12 21:56:19 2000
***************
*** 2224,2230 ****
MAP_STATIC = ",
join(" \\\n\t", reverse sort keys %static), "
! MAP_PRELIBS = $Config::Config{libs} $Config::Config{cryptlib}
";
if (defined $libperl) {
--- 2224,2230 ----
MAP_STATIC = ",
join(" \\\n\t", reverse sort keys %static), "
! MAP_PRELIBS = $Config::Config{perllibs} $Config::Config{cryptlib}
";
if (defined $libperl) {
Only in perl5.004_03/lib/ExtUtils: MM_Unix.pm.orig
diff -rc perl5.004_03.orig/myconfig perl5.004_03/myconfig
*** perl5.004_03.orig/myconfig Sat Dec 21 01:13:20 1996
--- perl5.004_03/myconfig Sun Nov 12 21:56:19 2000
***************
*** 35,41 ****
Linker and Libraries:
ld='$ld', ldflags ='$ldflags'
libpth=$libpth
! libs=$libs
libc=$libc, so=$so
useshrplib=$useshrplib, libperl=$libperl
Dynamic Linking:
--- 35,41 ----
Linker and Libraries:
ld='$ld', ldflags ='$ldflags'
libpth=$libpth
! libs=$perllibs
libc=$libc, so=$so
useshrplib=$useshrplib, libperl=$libperl
Dynamic Linking:
diff -rc perl5.004_03.orig/patchlevel.h perl5.004_03/patchlevel.h
*** perl5.004_03.orig/patchlevel.h Wed Aug 13 11:42:01 1997
--- perl5.004_03/patchlevel.h Sun Nov 12 21:56:19 2000
***************
*** 38,43 ****
--- 38,44 ----
*/
static char *local_patches[] = {
NULL
+ ,"NODB-1.0 - remove -ldb from core perl binary."
,NULL
};
Only in perl5.004_03: patchlevel.h.orig

View File

@@ -0,0 +1,209 @@
diff -rc perl5.004_04.orig/Configure perl5.004_04/Configure
*** perl5.004_04.orig/Configure Fri Oct 3 18:57:39 1997
--- perl5.004_04/Configure Sun Nov 12 21:50:51 2000
***************
*** 188,193 ****
--- 188,194 ----
mv=''
nroff=''
perl=''
+ perllibs=''
pg=''
pmake=''
pr=''
***************
*** 9910,9915 ****
--- 9911,9924 ----
shift
extensions="$*"
+ : Remove libraries needed only for extensions
+ : The appropriate ext/Foo/Makefile.PL will add them back in, if
+ : necessary.
+ set X `echo " $libs " |
+ sed -e 's@ -lndbm @ @' -e 's@ -lgdbm @ @' -e 's@ -ldbm @ @' -e 's@ -ldb @ @'`
+ shift
+ perllibs="$*"
+
: Remove build directory name from cppstdin so it can be used from
: either the present location or the final installed location.
echo " "
***************
*** 10378,10383 ****
--- 10387,10393 ----
patchlevel='$patchlevel'
path_sep='$path_sep'
perl='$perl'
+ perllibs='$perllibs'
perladmin='$perladmin'
perlpath='$perlpath'
pg='$pg'
diff -rc perl5.004_04.orig/Makefile.SH perl5.004_04/Makefile.SH
*** perl5.004_04.orig/Makefile.SH Wed Oct 15 10:33:16 1997
--- perl5.004_04/Makefile.SH Sun Nov 12 21:50:51 2000
***************
*** 129,135 ****
ext = \$(dynamic_ext) \$(static_ext)
DYNALOADER = lib/auto/DynaLoader/DynaLoader\$(LIB_EXT)
! libs = $libs $cryptlib
public = perl $suidperl utilities translators
--- 129,135 ----
ext = \$(dynamic_ext) \$(static_ext)
DYNALOADER = lib/auto/DynaLoader/DynaLoader\$(LIB_EXT)
! libs = $perllibs $cryptlib
public = perl $suidperl utilities translators
diff -rc perl5.004_04.orig/lib/ExtUtils/Embed.pm perl5.004_04/lib/ExtUtils/Embed.pm
*** perl5.004_04.orig/lib/ExtUtils/Embed.pm Fri Aug 1 15:08:44 1997
--- perl5.004_04/lib/ExtUtils/Embed.pm Sun Nov 12 21:50:51 2000
***************
*** 178,184 ****
@path = $path ? split(/:/, $path) : @INC;
push(@potential_libs, @link_args) if scalar @link_args;
! push(@potential_libs, $Config{libs}) if defined $std;
push(@mods, static_ext()) if $std;
--- 178,184 ----
@path = $path ? split(/:/, $path) : @INC;
push(@potential_libs, @link_args) if scalar @link_args;
! push(@potential_libs, $Config{perllibs}) if defined $std;
push(@mods, static_ext()) if $std;
diff -rc perl5.004_04.orig/lib/ExtUtils/Liblist.pm perl5.004_04/lib/ExtUtils/Liblist.pm
*** perl5.004_04.orig/lib/ExtUtils/Liblist.pm Tue Sep 9 17:41:32 1997
--- perl5.004_04/lib/ExtUtils/Liblist.pm Sun Nov 12 21:51:33 2000
***************
*** 16,33 ****
sub _unix_os2_ext {
my($self,$potential_libs, $verbose) = @_;
! if ($^O =~ 'os2' and $Config{libs}) {
# Dynamic libraries are not transitive, so we may need including
# the libraries linked against perl.dll again.
$potential_libs .= " " if $potential_libs;
! $potential_libs .= $Config{libs};
}
return ("", "", "", "") unless $potential_libs;
warn "Potential libraries are '$potential_libs':\n" if $verbose;
my($so) = $Config{'so'};
! my($libs) = $Config{'libs'};
my $Config_libext = $Config{lib_ext} || ".a";
--- 16,33 ----
sub _unix_os2_ext {
my($self,$potential_libs, $verbose) = @_;
! if ($^O =~ 'os2' and $Config{perllibs}) {
# Dynamic libraries are not transitive, so we may need including
# the libraries linked against perl.dll again.
$potential_libs .= " " if $potential_libs;
! $potential_libs .= $Config{perllibs};
}
return ("", "", "", "") unless $potential_libs;
warn "Potential libraries are '$potential_libs':\n" if $verbose;
my($so) = $Config{'so'};
! my($libs) = $Config{'perllibs'};
my $Config_libext = $Config{lib_ext} || ".a";
***************
*** 189,195 ****
return ("", "", "", "") unless $potential_libs;
my($so) = $Config{'so'};
! my($libs) = $Config{'libs'};
my($libpth) = $Config{'libpth'};
my($libext) = $Config{'lib_ext'} || ".lib";
--- 189,195 ----
return ("", "", "", "") unless $potential_libs;
my($so) = $Config{'so'};
! my($libs) = $Config{'perllibs'};
my($libpth) = $Config{'libpth'};
my($libext) = $Config{'lib_ext'} || ".lib";
***************
*** 539,545 ****
=item *
If C<$potential_libs> is empty, the return value will be empty.
! Otherwise, the libraries specified by C<$Config{libs}> (see Config.pm)
will be appended to the list of C<$potential_libs>. The libraries
will be searched for in the directories specified in C<$potential_libs>
as well as in C<$Config{libpth}>. For each library that is found, a
--- 539,545 ----
=item *
If C<$potential_libs> is empty, the return value will be empty.
! Otherwise, the libraries specified by C<$Config{perllibs}> (see Config.pm)
will be appended to the list of C<$potential_libs>. The libraries
will be searched for in the directories specified in C<$potential_libs>
as well as in C<$Config{libpth}>. For each library that is found, a
diff -rc perl5.004_04.orig/lib/ExtUtils/MM_Unix.pm perl5.004_04/lib/ExtUtils/MM_Unix.pm
*** perl5.004_04.orig/lib/ExtUtils/MM_Unix.pm Wed Oct 8 14:13:51 1997
--- perl5.004_04/lib/ExtUtils/MM_Unix.pm Sun Nov 12 21:50:51 2000
***************
*** 2229,2235 ****
MAP_STATIC = ",
join(" \\\n\t", reverse sort keys %static), "
! MAP_PRELIBS = $Config::Config{libs} $Config::Config{cryptlib}
";
if (defined $libperl) {
--- 2229,2235 ----
MAP_STATIC = ",
join(" \\\n\t", reverse sort keys %static), "
! MAP_PRELIBS = $Config::Config{perllibs} $Config::Config{cryptlib}
";
if (defined $libperl) {
diff -rc perl5.004_04.orig/myconfig perl5.004_04/myconfig
*** perl5.004_04.orig/myconfig Mon Oct 6 18:26:49 1997
--- perl5.004_04/myconfig Sun Nov 12 21:50:51 2000
***************
*** 35,41 ****
Linker and Libraries:
ld='$ld', ldflags ='$ldflags'
libpth=$libpth
! libs=$libs
libc=$libc, so=$so
useshrplib=$useshrplib, libperl=$libperl
Dynamic Linking:
--- 35,41 ----
Linker and Libraries:
ld='$ld', ldflags ='$ldflags'
libpth=$libpth
! libs=$perllibs
libc=$libc, so=$so
useshrplib=$useshrplib, libperl=$libperl
Dynamic Linking:
diff -rc perl5.004_04.orig/patchlevel.h perl5.004_04/patchlevel.h
*** perl5.004_04.orig/patchlevel.h Wed Oct 15 10:55:19 1997
--- perl5.004_04/patchlevel.h Sun Nov 12 21:50:51 2000
***************
*** 39,44 ****
--- 39,45 ----
/* The following line and terminating '};' are read by perlbug.PL. Don't alter. */
static char *local_patches[] = {
NULL
+ ,"NODB-1.0 - remove -ldb from core perl binary."
,NULL
};

View File

@@ -0,0 +1,209 @@
diff -rc perl5.004_05.orig/Configure perl5.004_05/Configure
*** perl5.004_05.orig/Configure Thu Jan 6 22:05:49 2000
--- perl5.004_05/Configure Sun Nov 12 21:36:25 2000
***************
*** 188,193 ****
--- 188,194 ----
mv=''
nroff=''
perl=''
+ perllibs=''
pg=''
pmake=''
pr=''
***************
*** 10164,10169 ****
--- 10165,10178 ----
shift
extensions="$*"
+ : Remove libraries needed only for extensions
+ : The appropriate ext/Foo/Makefile.PL will add them back in, if
+ : necessary.
+ set X `echo " $libs " |
+ sed -e 's@ -lndbm @ @' -e 's@ -lgdbm @ @' -e 's@ -ldbm @ @' -e 's@ -ldb @ @'`
+ shift
+ perllibs="$*"
+
: Remove build directory name from cppstdin so it can be used from
: either the present location or the final installed location.
echo " "
***************
*** 10648,10653 ****
--- 10657,10663 ----
patchlevel='$patchlevel'
path_sep='$path_sep'
perl='$perl'
+ perllibs='$perllibs'
perladmin='$perladmin'
perlpath='$perlpath'
pg='$pg'
diff -rc perl5.004_05.orig/Makefile.SH perl5.004_05/Makefile.SH
*** perl5.004_05.orig/Makefile.SH Thu Jan 6 22:05:49 2000
--- perl5.004_05/Makefile.SH Sun Nov 12 21:36:25 2000
***************
*** 151,157 ****
ext = \$(dynamic_ext) \$(static_ext)
DYNALOADER = lib/auto/DynaLoader/DynaLoader\$(LIB_EXT)
! libs = $libs $cryptlib
public = perl $suidperl utilities translators
--- 151,157 ----
ext = \$(dynamic_ext) \$(static_ext)
DYNALOADER = lib/auto/DynaLoader/DynaLoader\$(LIB_EXT)
! libs = $perllibs $cryptlib
public = perl $suidperl utilities translators
diff -rc perl5.004_05.orig/lib/ExtUtils/Embed.pm perl5.004_05/lib/ExtUtils/Embed.pm
*** perl5.004_05.orig/lib/ExtUtils/Embed.pm Fri Aug 1 15:08:44 1997
--- perl5.004_05/lib/ExtUtils/Embed.pm Sun Nov 12 21:36:25 2000
***************
*** 178,184 ****
@path = $path ? split(/:/, $path) : @INC;
push(@potential_libs, @link_args) if scalar @link_args;
! push(@potential_libs, $Config{libs}) if defined $std;
push(@mods, static_ext()) if $std;
--- 178,184 ----
@path = $path ? split(/:/, $path) : @INC;
push(@potential_libs, @link_args) if scalar @link_args;
! push(@potential_libs, $Config{perllibs}) if defined $std;
push(@mods, static_ext()) if $std;
diff -rc perl5.004_05.orig/lib/ExtUtils/Liblist.pm perl5.004_05/lib/ExtUtils/Liblist.pm
*** perl5.004_05.orig/lib/ExtUtils/Liblist.pm Thu Jan 6 22:05:54 2000
--- perl5.004_05/lib/ExtUtils/Liblist.pm Sun Nov 12 21:45:31 2000
***************
*** 16,33 ****
sub _unix_os2_ext {
my($self,$potential_libs, $verbose) = @_;
! if ($^O =~ 'os2' and $Config{libs}) {
# Dynamic libraries are not transitive, so we may need including
# the libraries linked against perl.dll again.
$potential_libs .= " " if $potential_libs;
! $potential_libs .= $Config{libs};
}
return ("", "", "", "") unless $potential_libs;
warn "Potential libraries are '$potential_libs':\n" if $verbose;
my($so) = $Config{'so'};
! my($libs) = $Config{'libs'};
my $Config_libext = $Config{lib_ext} || ".a";
--- 16,33 ----
sub _unix_os2_ext {
my($self,$potential_libs, $verbose) = @_;
! if ($^O =~ 'os2' and $Config{perllibs}) {
# Dynamic libraries are not transitive, so we may need including
# the libraries linked against perl.dll again.
$potential_libs .= " " if $potential_libs;
! $potential_libs .= $Config{perllibs};
}
return ("", "", "", "") unless $potential_libs;
warn "Potential libraries are '$potential_libs':\n" if $verbose;
my($so) = $Config{'so'};
! my($libs) = $Config{'perllibs'};
my $Config_libext = $Config{lib_ext} || ".a";
***************
*** 196,202 ****
my $BC = 1 if $cc =~ /^bcc/i;
my $GC = 1 if $cc =~ /^gcc/i;
my $so = $Config{'so'};
! my $libs = $Config{'libs'};
my $libpth = $Config{'libpth'};
my $libext = $Config{'lib_ext'} || ".lib";
--- 196,202 ----
my $BC = 1 if $cc =~ /^bcc/i;
my $GC = 1 if $cc =~ /^gcc/i;
my $so = $Config{'so'};
! my $libs = $Config{'perllibs'};
my $libpth = $Config{'libpth'};
my $libext = $Config{'lib_ext'} || ".lib";
***************
*** 590,596 ****
=item *
If C<$potential_libs> is empty, the return value will be empty.
! Otherwise, the libraries specified by C<$Config{libs}> (see Config.pm)
will be appended to the list of C<$potential_libs>. The libraries
will be searched for in the directories specified in C<$potential_libs>
as well as in C<$Config{libpth}>. For each library that is found, a
--- 590,596 ----
=item *
If C<$potential_libs> is empty, the return value will be empty.
! Otherwise, the libraries specified by C<$Config{perllibs}> (see Config.pm)
will be appended to the list of C<$potential_libs>. The libraries
will be searched for in the directories specified in C<$potential_libs>
as well as in C<$Config{libpth}>. For each library that is found, a
diff -rc perl5.004_05.orig/lib/ExtUtils/MM_Unix.pm perl5.004_05/lib/ExtUtils/MM_Unix.pm
*** perl5.004_05.orig/lib/ExtUtils/MM_Unix.pm Thu Jan 6 22:05:54 2000
--- perl5.004_05/lib/ExtUtils/MM_Unix.pm Sun Nov 12 21:36:25 2000
***************
*** 2246,2252 ****
MAP_STATIC = ",
join(" \\\n\t", reverse sort keys %static), "
! MAP_PRELIBS = $Config::Config{libs} $Config::Config{cryptlib}
";
if (defined $libperl) {
--- 2246,2252 ----
MAP_STATIC = ",
join(" \\\n\t", reverse sort keys %static), "
! MAP_PRELIBS = $Config::Config{perllibs} $Config::Config{cryptlib}
";
if (defined $libperl) {
diff -rc perl5.004_05.orig/myconfig perl5.004_05/myconfig
*** perl5.004_05.orig/myconfig Thu Jan 6 22:05:55 2000
--- perl5.004_05/myconfig Sun Nov 12 21:43:54 2000
***************
*** 34,40 ****
Linker and Libraries:
ld='$ld', ldflags ='$ldflags'
libpth=$libpth
! libs=$libs
libc=$libc, so=$so
useshrplib=$useshrplib, libperl=$libperl
Dynamic Linking:
--- 34,40 ----
Linker and Libraries:
ld='$ld', ldflags ='$ldflags'
libpth=$libpth
! libs=$perllibs
libc=$libc, so=$so
useshrplib=$useshrplib, libperl=$libperl
Dynamic Linking:
diff -rc perl5.004_05.orig/patchlevel.h perl5.004_05/patchlevel.h
*** perl5.004_05.orig/patchlevel.h Thu Jan 6 22:05:48 2000
--- perl5.004_05/patchlevel.h Sun Nov 12 21:36:25 2000
***************
*** 39,44 ****
--- 39,45 ----
/* The following line and terminating '};' are read by perlbug.PL. Don't alter. */
static char *local_patches[] = {
NULL
+ ,"NODB-1.0 - remove -ldb from core perl binary."
,NULL
};

View File

@@ -0,0 +1,209 @@
diff -rc perl5.005.orig/Configure perl5.005/Configure
*** perl5.005.orig/Configure Wed Jul 15 08:05:44 1998
--- perl5.005/Configure Sun Nov 12 21:30:40 2000
***************
*** 234,239 ****
--- 234,240 ----
nm=''
nroff=''
perl=''
+ perllibs=''
pg=''
pmake=''
pr=''
***************
*** 11279,11284 ****
--- 11280,11293 ----
shift
extensions="$*"
+ : Remove libraries needed only for extensions
+ : The appropriate ext/Foo/Makefile.PL will add them back in, if
+ : necessary.
+ set X `echo " $libs " |
+ sed -e 's@ -lndbm @ @' -e 's@ -lgdbm @ @' -e 's@ -ldbm @ @' -e 's@ -ldb @ @'`
+ shift
+ perllibs="$*"
+
: Remove build directory name from cppstdin so it can be used from
: either the present location or the final installed location.
echo " "
***************
*** 11804,11809 ****
--- 11813,11819 ----
patchlevel='$patchlevel'
path_sep='$path_sep'
perl='$perl'
+ perllibs='$perllibs'
perladmin='$perladmin'
perlpath='$perlpath'
pg='$pg'
diff -rc perl5.005.orig/Makefile.SH perl5.005/Makefile.SH
*** perl5.005.orig/Makefile.SH Sun Jul 19 08:06:35 1998
--- perl5.005/Makefile.SH Sun Nov 12 21:30:40 2000
***************
*** 150,156 ****
ext = \$(dynamic_ext) \$(static_ext) \$(nonxs_ext)
DYNALOADER = lib/auto/DynaLoader/DynaLoader\$(LIB_EXT)
! libs = $libs $cryptlib
public = perl $suidperl utilities translators
--- 150,156 ----
ext = \$(dynamic_ext) \$(static_ext) \$(nonxs_ext)
DYNALOADER = lib/auto/DynaLoader/DynaLoader\$(LIB_EXT)
! libs = $perllibs $cryptlib
public = perl $suidperl utilities translators
diff -rc perl5.005.orig/lib/ExtUtils/Embed.pm perl5.005/lib/ExtUtils/Embed.pm
*** perl5.005.orig/lib/ExtUtils/Embed.pm Wed Jul 22 07:45:02 1998
--- perl5.005/lib/ExtUtils/Embed.pm Sun Nov 12 21:30:40 2000
***************
*** 194,200 ****
@path = $path ? split(/:/, $path) : @INC;
push(@potential_libs, @link_args) if scalar @link_args;
! push(@potential_libs, $Config{libs}) if defined $std;
push(@mods, static_ext()) if $std;
--- 194,200 ----
@path = $path ? split(/:/, $path) : @INC;
push(@potential_libs, @link_args) if scalar @link_args;
! push(@potential_libs, $Config{perllibs}) if defined $std;
push(@mods, static_ext()) if $std;
diff -rc perl5.005.orig/lib/ExtUtils/Liblist.pm perl5.005/lib/ExtUtils/Liblist.pm
*** perl5.005.orig/lib/ExtUtils/Liblist.pm Wed Jul 22 07:09:42 1998
--- perl5.005/lib/ExtUtils/Liblist.pm Sun Nov 12 21:30:40 2000
***************
*** 16,33 ****
sub _unix_os2_ext {
my($self,$potential_libs, $verbose) = @_;
! if ($^O =~ 'os2' and $Config{libs}) {
# Dynamic libraries are not transitive, so we may need including
# the libraries linked against perl.dll again.
$potential_libs .= " " if $potential_libs;
! $potential_libs .= $Config{libs};
}
return ("", "", "", "") unless $potential_libs;
warn "Potential libraries are '$potential_libs':\n" if $verbose;
my($so) = $Config{'so'};
! my($libs) = $Config{'libs'};
my $Config_libext = $Config{lib_ext} || ".a";
--- 16,33 ----
sub _unix_os2_ext {
my($self,$potential_libs, $verbose) = @_;
! if ($^O =~ 'os2' and $Config{perllibs}) {
# Dynamic libraries are not transitive, so we may need including
# the libraries linked against perl.dll again.
$potential_libs .= " " if $potential_libs;
! $potential_libs .= $Config{perllibs};
}
return ("", "", "", "") unless $potential_libs;
warn "Potential libraries are '$potential_libs':\n" if $verbose;
my($so) = $Config{'so'};
! my($libs) = $Config{'perllibs'};
my $Config_libext = $Config{lib_ext} || ".a";
***************
*** 290,296 ****
$self->{CCFLAS} || $Config{'ccflags'};
@crtls = ( ($dbgqual =~ m-/Debug-i ? $Config{'dbgprefix'} : '')
. 'PerlShr/Share' );
! push(@crtls, grep { not /\(/ } split /\s+/, $Config{'libs'});
push(@crtls, grep { not /\(/ } split /\s+/, $Config{'libc'});
# In general, we pass through the basic libraries from %Config unchanged.
# The one exception is that if we're building in the Perl source tree, and
--- 290,296 ----
$self->{CCFLAS} || $Config{'ccflags'};
@crtls = ( ($dbgqual =~ m-/Debug-i ? $Config{'dbgprefix'} : '')
. 'PerlShr/Share' );
! push(@crtls, grep { not /\(/ } split /\s+/, $Config{'perllibs'});
push(@crtls, grep { not /\(/ } split /\s+/, $Config{'libc'});
# In general, we pass through the basic libraries from %Config unchanged.
# The one exception is that if we're building in the Perl source tree, and
***************
*** 598,604 ****
=item *
If C<$potential_libs> is empty, the return value will be empty.
! Otherwise, the libraries specified by C<$Config{libs}> (see Config.pm)
will be appended to the list of C<$potential_libs>. The libraries
will be searched for in the directories specified in C<$potential_libs>
as well as in C<$Config{libpth}>. For each library that is found, a
--- 598,604 ----
=item *
If C<$potential_libs> is empty, the return value will be empty.
! Otherwise, the libraries specified by C<$Config{perllibs}> (see Config.pm)
will be appended to the list of C<$potential_libs>. The libraries
will be searched for in the directories specified in C<$potential_libs>
as well as in C<$Config{libpth}>. For each library that is found, a
diff -rc perl5.005.orig/lib/ExtUtils/MM_Unix.pm perl5.005/lib/ExtUtils/MM_Unix.pm
*** perl5.005.orig/lib/ExtUtils/MM_Unix.pm Tue Jul 14 04:39:12 1998
--- perl5.005/lib/ExtUtils/MM_Unix.pm Sun Nov 12 21:30:41 2000
***************
*** 2281,2287 ****
MAP_STATIC = ",
join(" \\\n\t", reverse sort keys %static), "
! MAP_PRELIBS = $Config::Config{libs} $Config::Config{cryptlib}
";
if (defined $libperl) {
--- 2281,2287 ----
MAP_STATIC = ",
join(" \\\n\t", reverse sort keys %static), "
! MAP_PRELIBS = $Config::Config{perllibs} $Config::Config{cryptlib}
";
if (defined $libperl) {
diff -rc perl5.005.orig/myconfig perl5.005/myconfig
*** perl5.005.orig/myconfig Fri Apr 3 01:20:35 1998
--- perl5.005/myconfig Sun Nov 12 21:30:41 2000
***************
*** 34,40 ****
Linker and Libraries:
ld='$ld', ldflags ='$ldflags'
libpth=$libpth
! libs=$libs
libc=$libc, so=$so, useshrplib=$useshrplib, libperl=$libperl
Dynamic Linking:
dlsrc=$dlsrc, dlext=$dlext, d_dlsymun=$d_dlsymun, ccdlflags='$ccdlflags'
--- 34,40 ----
Linker and Libraries:
ld='$ld', ldflags ='$ldflags'
libpth=$libpth
! libs=$perllibs
libc=$libc, so=$so, useshrplib=$useshrplib, libperl=$libperl
Dynamic Linking:
dlsrc=$dlsrc, dlext=$dlext, d_dlsymun=$d_dlsymun, ccdlflags='$ccdlflags'
diff -rc perl5.005.orig/patchlevel.h perl5.005/patchlevel.h
*** perl5.005.orig/patchlevel.h Wed Jul 22 19:22:01 1998
--- perl5.005/patchlevel.h Sun Nov 12 21:30:41 2000
***************
*** 39,44 ****
--- 39,45 ----
*/
static char *local_patches[] = {
NULL
+ ,"NODB-1.0 - remove -ldb from core perl binary."
,NULL
};

View File

@@ -0,0 +1,209 @@
diff -rc perl5.005_01.orig/Configure perl5.005_01/Configure
*** perl5.005_01.orig/Configure Wed Jul 15 08:05:44 1998
--- perl5.005_01/Configure Sun Nov 12 20:55:58 2000
***************
*** 234,239 ****
--- 234,240 ----
nm=''
nroff=''
perl=''
+ perllibs=''
pg=''
pmake=''
pr=''
***************
*** 11279,11284 ****
--- 11280,11293 ----
shift
extensions="$*"
+ : Remove libraries needed only for extensions
+ : The appropriate ext/Foo/Makefile.PL will add them back in, if
+ : necessary.
+ set X `echo " $libs " |
+ sed -e 's@ -lndbm @ @' -e 's@ -lgdbm @ @' -e 's@ -ldbm @ @' -e 's@ -ldb @ @'`
+ shift
+ perllibs="$*"
+
: Remove build directory name from cppstdin so it can be used from
: either the present location or the final installed location.
echo " "
***************
*** 11804,11809 ****
--- 11813,11819 ----
patchlevel='$patchlevel'
path_sep='$path_sep'
perl='$perl'
+ perllibs='$perllibs'
perladmin='$perladmin'
perlpath='$perlpath'
pg='$pg'
diff -rc perl5.005_01.orig/Makefile.SH perl5.005_01/Makefile.SH
*** perl5.005_01.orig/Makefile.SH Sun Jul 19 08:06:35 1998
--- perl5.005_01/Makefile.SH Sun Nov 12 20:55:58 2000
***************
*** 150,156 ****
ext = \$(dynamic_ext) \$(static_ext) \$(nonxs_ext)
DYNALOADER = lib/auto/DynaLoader/DynaLoader\$(LIB_EXT)
! libs = $libs $cryptlib
public = perl $suidperl utilities translators
--- 150,156 ----
ext = \$(dynamic_ext) \$(static_ext) \$(nonxs_ext)
DYNALOADER = lib/auto/DynaLoader/DynaLoader\$(LIB_EXT)
! libs = $perllibs $cryptlib
public = perl $suidperl utilities translators
diff -rc perl5.005_01.orig/lib/ExtUtils/Embed.pm perl5.005_01/lib/ExtUtils/Embed.pm
*** perl5.005_01.orig/lib/ExtUtils/Embed.pm Wed Jul 22 07:45:02 1998
--- perl5.005_01/lib/ExtUtils/Embed.pm Sun Nov 12 20:55:58 2000
***************
*** 194,200 ****
@path = $path ? split(/:/, $path) : @INC;
push(@potential_libs, @link_args) if scalar @link_args;
! push(@potential_libs, $Config{libs}) if defined $std;
push(@mods, static_ext()) if $std;
--- 194,200 ----
@path = $path ? split(/:/, $path) : @INC;
push(@potential_libs, @link_args) if scalar @link_args;
! push(@potential_libs, $Config{perllibs}) if defined $std;
push(@mods, static_ext()) if $std;
diff -rc perl5.005_01.orig/lib/ExtUtils/Liblist.pm perl5.005_01/lib/ExtUtils/Liblist.pm
*** perl5.005_01.orig/lib/ExtUtils/Liblist.pm Wed Jul 22 07:09:42 1998
--- perl5.005_01/lib/ExtUtils/Liblist.pm Sun Nov 12 20:55:58 2000
***************
*** 16,33 ****
sub _unix_os2_ext {
my($self,$potential_libs, $verbose) = @_;
! if ($^O =~ 'os2' and $Config{libs}) {
# Dynamic libraries are not transitive, so we may need including
# the libraries linked against perl.dll again.
$potential_libs .= " " if $potential_libs;
! $potential_libs .= $Config{libs};
}
return ("", "", "", "") unless $potential_libs;
warn "Potential libraries are '$potential_libs':\n" if $verbose;
my($so) = $Config{'so'};
! my($libs) = $Config{'libs'};
my $Config_libext = $Config{lib_ext} || ".a";
--- 16,33 ----
sub _unix_os2_ext {
my($self,$potential_libs, $verbose) = @_;
! if ($^O =~ 'os2' and $Config{perllibs}) {
# Dynamic libraries are not transitive, so we may need including
# the libraries linked against perl.dll again.
$potential_libs .= " " if $potential_libs;
! $potential_libs .= $Config{perllibs};
}
return ("", "", "", "") unless $potential_libs;
warn "Potential libraries are '$potential_libs':\n" if $verbose;
my($so) = $Config{'so'};
! my($libs) = $Config{'perllibs'};
my $Config_libext = $Config{lib_ext} || ".a";
***************
*** 290,296 ****
$self->{CCFLAS} || $Config{'ccflags'};
@crtls = ( ($dbgqual =~ m-/Debug-i ? $Config{'dbgprefix'} : '')
. 'PerlShr/Share' );
! push(@crtls, grep { not /\(/ } split /\s+/, $Config{'libs'});
push(@crtls, grep { not /\(/ } split /\s+/, $Config{'libc'});
# In general, we pass through the basic libraries from %Config unchanged.
# The one exception is that if we're building in the Perl source tree, and
--- 290,296 ----
$self->{CCFLAS} || $Config{'ccflags'};
@crtls = ( ($dbgqual =~ m-/Debug-i ? $Config{'dbgprefix'} : '')
. 'PerlShr/Share' );
! push(@crtls, grep { not /\(/ } split /\s+/, $Config{'perllibs'});
push(@crtls, grep { not /\(/ } split /\s+/, $Config{'libc'});
# In general, we pass through the basic libraries from %Config unchanged.
# The one exception is that if we're building in the Perl source tree, and
***************
*** 598,604 ****
=item *
If C<$potential_libs> is empty, the return value will be empty.
! Otherwise, the libraries specified by C<$Config{libs}> (see Config.pm)
will be appended to the list of C<$potential_libs>. The libraries
will be searched for in the directories specified in C<$potential_libs>
as well as in C<$Config{libpth}>. For each library that is found, a
--- 598,604 ----
=item *
If C<$potential_libs> is empty, the return value will be empty.
! Otherwise, the libraries specified by C<$Config{perllibs}> (see Config.pm)
will be appended to the list of C<$potential_libs>. The libraries
will be searched for in the directories specified in C<$potential_libs>
as well as in C<$Config{libpth}>. For each library that is found, a
diff -rc perl5.005_01.orig/lib/ExtUtils/MM_Unix.pm perl5.005_01/lib/ExtUtils/MM_Unix.pm
*** perl5.005_01.orig/lib/ExtUtils/MM_Unix.pm Tue Jul 14 04:39:12 1998
--- perl5.005_01/lib/ExtUtils/MM_Unix.pm Sun Nov 12 20:55:58 2000
***************
*** 2281,2287 ****
MAP_STATIC = ",
join(" \\\n\t", reverse sort keys %static), "
! MAP_PRELIBS = $Config::Config{libs} $Config::Config{cryptlib}
";
if (defined $libperl) {
--- 2281,2287 ----
MAP_STATIC = ",
join(" \\\n\t", reverse sort keys %static), "
! MAP_PRELIBS = $Config::Config{perllibs} $Config::Config{cryptlib}
";
if (defined $libperl) {
diff -rc perl5.005_01.orig/myconfig perl5.005_01/myconfig
*** perl5.005_01.orig/myconfig Fri Apr 3 01:20:35 1998
--- perl5.005_01/myconfig Sun Nov 12 20:55:58 2000
***************
*** 34,40 ****
Linker and Libraries:
ld='$ld', ldflags ='$ldflags'
libpth=$libpth
! libs=$libs
libc=$libc, so=$so, useshrplib=$useshrplib, libperl=$libperl
Dynamic Linking:
dlsrc=$dlsrc, dlext=$dlext, d_dlsymun=$d_dlsymun, ccdlflags='$ccdlflags'
--- 34,40 ----
Linker and Libraries:
ld='$ld', ldflags ='$ldflags'
libpth=$libpth
! libs=$perllibs
libc=$libc, so=$so, useshrplib=$useshrplib, libperl=$libperl
Dynamic Linking:
dlsrc=$dlsrc, dlext=$dlext, d_dlsymun=$d_dlsymun, ccdlflags='$ccdlflags'
diff -rc perl5.005_01.orig/patchlevel.h perl5.005_01/patchlevel.h
*** perl5.005_01.orig/patchlevel.h Mon Jan 3 11:07:45 2000
--- perl5.005_01/patchlevel.h Sun Nov 12 20:55:58 2000
***************
*** 39,44 ****
--- 39,45 ----
*/
static char *local_patches[] = {
NULL
+ ,"NODB-1.0 - remove -ldb from core perl binary."
,NULL
};

View File

@@ -0,0 +1,264 @@
diff -rc perl5.005_02.orig/Configure perl5.005_02/Configure
*** perl5.005_02.orig/Configure Mon Jan 3 11:12:20 2000
--- perl5.005_02/Configure Sun Nov 12 20:50:51 2000
***************
*** 234,239 ****
--- 234,240 ----
nm=''
nroff=''
perl=''
+ perllibs=''
pg=''
pmake=''
pr=''
***************
*** 11334,11339 ****
--- 11335,11348 ----
shift
extensions="$*"
+ : Remove libraries needed only for extensions
+ : The appropriate ext/Foo/Makefile.PL will add them back in, if
+ : necessary.
+ set X `echo " $libs " |
+ sed -e 's@ -lndbm @ @' -e 's@ -lgdbm @ @' -e 's@ -ldbm @ @' -e 's@ -ldb @ @'`
+ shift
+ perllibs="$*"
+
: Remove build directory name from cppstdin so it can be used from
: either the present location or the final installed location.
echo " "
***************
*** 11859,11864 ****
--- 11868,11874 ----
patchlevel='$patchlevel'
path_sep='$path_sep'
perl='$perl'
+ perllibs='$perllibs'
perladmin='$perladmin'
perlpath='$perlpath'
pg='$pg'
Only in perl5.005_02: Configure.orig
diff -rc perl5.005_02.orig/Makefile.SH perl5.005_02/Makefile.SH
*** perl5.005_02.orig/Makefile.SH Sun Jul 19 08:06:35 1998
--- perl5.005_02/Makefile.SH Sun Nov 12 20:50:51 2000
***************
*** 150,156 ****
ext = \$(dynamic_ext) \$(static_ext) \$(nonxs_ext)
DYNALOADER = lib/auto/DynaLoader/DynaLoader\$(LIB_EXT)
! libs = $libs $cryptlib
public = perl $suidperl utilities translators
--- 150,156 ----
ext = \$(dynamic_ext) \$(static_ext) \$(nonxs_ext)
DYNALOADER = lib/auto/DynaLoader/DynaLoader\$(LIB_EXT)
! libs = $perllibs $cryptlib
public = perl $suidperl utilities translators
Only in perl5.005_02: Makefile.SH.orig
diff -rc perl5.005_02.orig/lib/ExtUtils/Embed.pm perl5.005_02/lib/ExtUtils/Embed.pm
*** perl5.005_02.orig/lib/ExtUtils/Embed.pm Wed Jul 22 07:45:02 1998
--- perl5.005_02/lib/ExtUtils/Embed.pm Sun Nov 12 20:50:51 2000
***************
*** 194,200 ****
@path = $path ? split(/:/, $path) : @INC;
push(@potential_libs, @link_args) if scalar @link_args;
! push(@potential_libs, $Config{libs}) if defined $std;
push(@mods, static_ext()) if $std;
--- 194,200 ----
@path = $path ? split(/:/, $path) : @INC;
push(@potential_libs, @link_args) if scalar @link_args;
! push(@potential_libs, $Config{perllibs}) if defined $std;
push(@mods, static_ext()) if $std;
diff -rc perl5.005_02.orig/lib/ExtUtils/Liblist.pm perl5.005_02/lib/ExtUtils/Liblist.pm
*** perl5.005_02.orig/lib/ExtUtils/Liblist.pm Mon Jan 3 11:12:21 2000
--- perl5.005_02/lib/ExtUtils/Liblist.pm Sun Nov 12 20:50:51 2000
***************
*** 16,33 ****
sub _unix_os2_ext {
my($self,$potential_libs, $verbose) = @_;
! if ($^O =~ 'os2' and $Config{libs}) {
# Dynamic libraries are not transitive, so we may need including
# the libraries linked against perl.dll again.
$potential_libs .= " " if $potential_libs;
! $potential_libs .= $Config{libs};
}
return ("", "", "", "") unless $potential_libs;
warn "Potential libraries are '$potential_libs':\n" if $verbose;
my($so) = $Config{'so'};
! my($libs) = $Config{'libs'};
my $Config_libext = $Config{lib_ext} || ".a";
--- 16,33 ----
sub _unix_os2_ext {
my($self,$potential_libs, $verbose) = @_;
! if ($^O =~ 'os2' and $Config{perllibs}) {
# Dynamic libraries are not transitive, so we may need including
# the libraries linked against perl.dll again.
$potential_libs .= " " if $potential_libs;
! $potential_libs .= $Config{perllibs};
}
return ("", "", "", "") unless $potential_libs;
warn "Potential libraries are '$potential_libs':\n" if $verbose;
my($so) = $Config{'so'};
! my($libs) = $Config{'perllibs'};
my $Config_libext = $Config{lib_ext} || ".a";
***************
*** 196,202 ****
my $BC = 1 if $cc =~ /^bcc/i;
my $GC = 1 if $cc =~ /^gcc/i;
my $so = $Config{'so'};
! my $libs = $Config{'libs'};
my $libpth = $Config{'libpth'};
my $libext = $Config{'lib_ext'} || ".lib";
--- 196,202 ----
my $BC = 1 if $cc =~ /^bcc/i;
my $GC = 1 if $cc =~ /^gcc/i;
my $so = $Config{'so'};
! my $libs = $Config{'perllibs'};
my $libpth = $Config{'libpth'};
my $libext = $Config{'lib_ext'} || ".lib";
***************
*** 333,339 ****
$self->{CCFLAS} || $Config{'ccflags'};
@crtls = ( ($dbgqual =~ m-/Debug-i ? $Config{'dbgprefix'} : '')
. 'PerlShr/Share' );
! push(@crtls, grep { not /\(/ } split /\s+/, $Config{'libs'});
push(@crtls, grep { not /\(/ } split /\s+/, $Config{'libc'});
# In general, we pass through the basic libraries from %Config unchanged.
# The one exception is that if we're building in the Perl source tree, and
--- 333,339 ----
$self->{CCFLAS} || $Config{'ccflags'};
@crtls = ( ($dbgqual =~ m-/Debug-i ? $Config{'dbgprefix'} : '')
. 'PerlShr/Share' );
! push(@crtls, grep { not /\(/ } split /\s+/, $Config{'perllibs'});
push(@crtls, grep { not /\(/ } split /\s+/, $Config{'libc'});
# In general, we pass through the basic libraries from %Config unchanged.
# The one exception is that if we're building in the Perl source tree, and
***************
*** 623,629 ****
=item *
If C<$potential_libs> is empty, the return value will be empty.
! Otherwise, the libraries specified by C<$Config{libs}> (see Config.pm)
will be appended to the list of C<$potential_libs>. The libraries
will be searched for in the directories specified in C<$potential_libs>
as well as in C<$Config{libpth}>. For each library that is found, a
--- 623,629 ----
=item *
If C<$potential_libs> is empty, the return value will be empty.
! Otherwise, the libraries specified by C<$Config{perllibs}> (see Config.pm)
will be appended to the list of C<$potential_libs>. The libraries
will be searched for in the directories specified in C<$potential_libs>
as well as in C<$Config{libpth}>. For each library that is found, a
***************
*** 666,672 ****
alphanumeric characters are treated as flags. Unknown flags will be ignored.
An entry that matches C</:nodefault/i> disables the appending of default
! libraries found in C<$Config{libs}> (this should be only needed very rarely).
An entry that matches C</:nosearch/i> disables all searching for
the libraries specified after it. Translation of C<-Lfoo> and
--- 666,672 ----
alphanumeric characters are treated as flags. Unknown flags will be ignored.
An entry that matches C</:nodefault/i> disables the appending of default
! libraries found in C<$Config{perllibs}> (this should be only needed very rarely).
An entry that matches C</:nosearch/i> disables all searching for
the libraries specified after it. Translation of C<-Lfoo> and
***************
*** 676,682 ****
An entry that matches C</:search/i> reenables searching for
the libraries specified after it. You can put it at the end to
! enable searching for default libraries specified by C<$Config{libs}>.
=item *
--- 676,682 ----
An entry that matches C</:search/i> reenables searching for
the libraries specified after it. You can put it at the end to
! enable searching for default libraries specified by C<$Config{perllibs}>.
=item *
Only in perl5.005_02/lib/ExtUtils: Liblist.pm.orig
diff -rc perl5.005_02.orig/lib/ExtUtils/MM_Unix.pm perl5.005_02/lib/ExtUtils/MM_Unix.pm
*** perl5.005_02.orig/lib/ExtUtils/MM_Unix.pm Tue Jul 14 04:39:12 1998
--- perl5.005_02/lib/ExtUtils/MM_Unix.pm Sun Nov 12 20:50:51 2000
***************
*** 2281,2287 ****
MAP_STATIC = ",
join(" \\\n\t", reverse sort keys %static), "
! MAP_PRELIBS = $Config::Config{libs} $Config::Config{cryptlib}
";
if (defined $libperl) {
--- 2281,2287 ----
MAP_STATIC = ",
join(" \\\n\t", reverse sort keys %static), "
! MAP_PRELIBS = $Config::Config{perllibs} $Config::Config{cryptlib}
";
if (defined $libperl) {
Only in perl5.005_02/lib/ExtUtils: MM_Unix.pm.orig
diff -rc perl5.005_02.orig/myconfig perl5.005_02/myconfig
*** perl5.005_02.orig/myconfig Fri Apr 3 01:20:35 1998
--- perl5.005_02/myconfig Sun Nov 12 20:50:51 2000
***************
*** 34,40 ****
Linker and Libraries:
ld='$ld', ldflags ='$ldflags'
libpth=$libpth
! libs=$libs
libc=$libc, so=$so, useshrplib=$useshrplib, libperl=$libperl
Dynamic Linking:
dlsrc=$dlsrc, dlext=$dlext, d_dlsymun=$d_dlsymun, ccdlflags='$ccdlflags'
--- 34,40 ----
Linker and Libraries:
ld='$ld', ldflags ='$ldflags'
libpth=$libpth
! libs=$perllibs
libc=$libc, so=$so, useshrplib=$useshrplib, libperl=$libperl
Dynamic Linking:
dlsrc=$dlsrc, dlext=$dlext, d_dlsymun=$d_dlsymun, ccdlflags='$ccdlflags'
diff -rc perl5.005_02.orig/patchlevel.h perl5.005_02/patchlevel.h
*** perl5.005_02.orig/patchlevel.h Mon Jan 3 11:12:19 2000
--- perl5.005_02/patchlevel.h Sun Nov 12 20:50:51 2000
***************
*** 40,45 ****
--- 40,46 ----
*/
static char *local_patches[] = {
NULL
+ ,"NODB-1.0 - remove -ldb from core perl binary."
,NULL
};

View File

@@ -0,0 +1,250 @@
diff -rc perl5.005_03.orig/Configure perl5.005_03/Configure
*** perl5.005_03.orig/Configure Sun Mar 28 17:12:57 1999
--- perl5.005_03/Configure Sun Sep 17 22:19:16 2000
***************
*** 208,213 ****
--- 208,214 ----
nm=''
nroff=''
perl=''
+ perllibs=''
pg=''
pmake=''
pr=''
***************
*** 11642,11647 ****
--- 11643,11656 ----
shift
extensions="$*"
+ : Remove libraries needed only for extensions
+ : The appropriate ext/Foo/Makefile.PL will add them back in, if
+ : necessary.
+ set X `echo " $libs " |
+ sed -e 's@ -lndbm @ @' -e 's@ -lgdbm @ @' -e 's@ -ldbm @ @' -e 's@ -ldb @ @'`
+ shift
+ perllibs="$*"
+
: Remove build directory name from cppstdin so it can be used from
: either the present location or the final installed location.
echo " "
***************
*** 12183,12188 ****
--- 12192,12198 ----
patchlevel='$patchlevel'
path_sep='$path_sep'
perl='$perl'
+ perllibs='$perllibs'
perladmin='$perladmin'
perlpath='$perlpath'
pg='$pg'
diff -rc perl5.005_03.orig/Makefile.SH perl5.005_03/Makefile.SH
*** perl5.005_03.orig/Makefile.SH Thu Mar 4 02:35:25 1999
--- perl5.005_03/Makefile.SH Sun Sep 17 22:21:01 2000
***************
*** 58,67 ****
shrpldflags="-H512 -T512 -bhalt:4 -bM:SRE -bE:perl.exp"
case "$osvers" in
3*)
! shrpldflags="$shrpldflags -e _nostart $ldflags $libs $cryptlib"
;;
*)
! shrpldflags="$shrpldflags -b noentry $ldflags $libs $cryptlib"
;;
esac
aixinstdir=`pwd | sed 's/\/UU$//'`
--- 58,67 ----
shrpldflags="-H512 -T512 -bhalt:4 -bM:SRE -bE:perl.exp"
case "$osvers" in
3*)
! shrpldflags="$shrpldflags -e _nostart $ldflags $perllibs $cryptlib"
;;
*)
! shrpldflags="$shrpldflags -b noentry $ldflags $perllibs $cryptlib"
;;
esac
aixinstdir=`pwd | sed 's/\/UU$//'`
***************
*** 155,161 ****
ext = \$(dynamic_ext) \$(static_ext) \$(nonxs_ext)
DYNALOADER = lib/auto/DynaLoader/DynaLoader\$(LIB_EXT)
! libs = $libs $cryptlib
public = perl $suidperl utilities translators
--- 155,161 ----
ext = \$(dynamic_ext) \$(static_ext) \$(nonxs_ext)
DYNALOADER = lib/auto/DynaLoader/DynaLoader\$(LIB_EXT)
! libs = $perllibs $cryptlib
public = perl $suidperl utilities translators
diff -rc perl5.005_03.orig/lib/ExtUtils/Embed.pm perl5.005_03/lib/ExtUtils/Embed.pm
*** perl5.005_03.orig/lib/ExtUtils/Embed.pm Wed Jan 6 02:17:50 1999
--- perl5.005_03/lib/ExtUtils/Embed.pm Sun Sep 17 22:19:16 2000
***************
*** 194,200 ****
@path = $path ? split(/:/, $path) : @INC;
push(@potential_libs, @link_args) if scalar @link_args;
! push(@potential_libs, $Config{libs}) if defined $std;
push(@mods, static_ext()) if $std;
--- 194,200 ----
@path = $path ? split(/:/, $path) : @INC;
push(@potential_libs, @link_args) if scalar @link_args;
! push(@potential_libs, $Config{perllibs}) if defined $std;
push(@mods, static_ext()) if $std;
diff -rc perl5.005_03.orig/lib/ExtUtils/Liblist.pm perl5.005_03/lib/ExtUtils/Liblist.pm
*** perl5.005_03.orig/lib/ExtUtils/Liblist.pm Wed Jan 6 02:17:47 1999
--- perl5.005_03/lib/ExtUtils/Liblist.pm Sun Sep 17 22:19:16 2000
***************
*** 16,33 ****
sub _unix_os2_ext {
my($self,$potential_libs, $verbose) = @_;
! if ($^O =~ 'os2' and $Config{libs}) {
# Dynamic libraries are not transitive, so we may need including
# the libraries linked against perl.dll again.
$potential_libs .= " " if $potential_libs;
! $potential_libs .= $Config{libs};
}
return ("", "", "", "") unless $potential_libs;
warn "Potential libraries are '$potential_libs':\n" if $verbose;
my($so) = $Config{'so'};
! my($libs) = $Config{'libs'};
my $Config_libext = $Config{lib_ext} || ".a";
--- 16,33 ----
sub _unix_os2_ext {
my($self,$potential_libs, $verbose) = @_;
! if ($^O =~ 'os2' and $Config{perllibs}) {
# Dynamic libraries are not transitive, so we may need including
# the libraries linked against perl.dll again.
$potential_libs .= " " if $potential_libs;
! $potential_libs .= $Config{perllibs};
}
return ("", "", "", "") unless $potential_libs;
warn "Potential libraries are '$potential_libs':\n" if $verbose;
my($so) = $Config{'so'};
! my($libs) = $Config{'perllibs'};
my $Config_libext = $Config{lib_ext} || ".a";
***************
*** 196,202 ****
my $BC = 1 if $cc =~ /^bcc/i;
my $GC = 1 if $cc =~ /^gcc/i;
my $so = $Config{'so'};
! my $libs = $Config{'libs'};
my $libpth = $Config{'libpth'};
my $libext = $Config{'lib_ext'} || ".lib";
--- 196,202 ----
my $BC = 1 if $cc =~ /^bcc/i;
my $GC = 1 if $cc =~ /^gcc/i;
my $so = $Config{'so'};
! my $libs = $Config{'perllibs'};
my $libpth = $Config{'libpth'};
my $libext = $Config{'lib_ext'} || ".lib";
***************
*** 336,342 ****
$self->{CCFLAS} || $Config{'ccflags'};
@crtls = ( ($dbgqual =~ m-/Debug-i ? $Config{'dbgprefix'} : '')
. 'PerlShr/Share' );
! push(@crtls, grep { not /\(/ } split /\s+/, $Config{'libs'});
push(@crtls, grep { not /\(/ } split /\s+/, $Config{'libc'});
# In general, we pass through the basic libraries from %Config unchanged.
# The one exception is that if we're building in the Perl source tree, and
--- 336,342 ----
$self->{CCFLAS} || $Config{'ccflags'};
@crtls = ( ($dbgqual =~ m-/Debug-i ? $Config{'dbgprefix'} : '')
. 'PerlShr/Share' );
! push(@crtls, grep { not /\(/ } split /\s+/, $Config{'perllibs'});
push(@crtls, grep { not /\(/ } split /\s+/, $Config{'libc'});
# In general, we pass through the basic libraries from %Config unchanged.
# The one exception is that if we're building in the Perl source tree, and
***************
*** 626,632 ****
=item *
If C<$potential_libs> is empty, the return value will be empty.
! Otherwise, the libraries specified by C<$Config{libs}> (see Config.pm)
will be appended to the list of C<$potential_libs>. The libraries
will be searched for in the directories specified in C<$potential_libs>,
C<$Config{libpth}>, and in C<$Config{installarchlib}/CORE>.
--- 626,632 ----
=item *
If C<$potential_libs> is empty, the return value will be empty.
! Otherwise, the libraries specified by C<$Config{perllibs}> (see Config.pm)
will be appended to the list of C<$potential_libs>. The libraries
will be searched for in the directories specified in C<$potential_libs>,
C<$Config{libpth}>, and in C<$Config{installarchlib}/CORE>.
***************
*** 670,676 ****
alphanumeric characters are treated as flags. Unknown flags will be ignored.
An entry that matches C</:nodefault/i> disables the appending of default
! libraries found in C<$Config{libs}> (this should be only needed very rarely).
An entry that matches C</:nosearch/i> disables all searching for
the libraries specified after it. Translation of C<-Lfoo> and
--- 670,676 ----
alphanumeric characters are treated as flags. Unknown flags will be ignored.
An entry that matches C</:nodefault/i> disables the appending of default
! libraries found in C<$Config{perllibs}> (this should be only needed very rarely).
An entry that matches C</:nosearch/i> disables all searching for
the libraries specified after it. Translation of C<-Lfoo> and
***************
*** 680,686 ****
An entry that matches C</:search/i> reenables searching for
the libraries specified after it. You can put it at the end to
! enable searching for default libraries specified by C<$Config{libs}>.
=item *
--- 680,686 ----
An entry that matches C</:search/i> reenables searching for
the libraries specified after it. You can put it at the end to
! enable searching for default libraries specified by C<$Config{perllibs}>.
=item *
diff -rc perl5.005_03.orig/lib/ExtUtils/MM_Unix.pm perl5.005_03/lib/ExtUtils/MM_Unix.pm
*** perl5.005_03.orig/lib/ExtUtils/MM_Unix.pm Fri Mar 5 00:34:20 1999
--- perl5.005_03/lib/ExtUtils/MM_Unix.pm Sun Sep 17 22:19:16 2000
***************
*** 2284,2290 ****
MAP_STATIC = ",
join(" \\\n\t", reverse sort keys %static), "
! MAP_PRELIBS = $Config::Config{libs} $Config::Config{cryptlib}
";
if (defined $libperl) {
--- 2284,2290 ----
MAP_STATIC = ",
join(" \\\n\t", reverse sort keys %static), "
! MAP_PRELIBS = $Config::Config{perllibs} $Config::Config{cryptlib}
";
if (defined $libperl) {

View File

@@ -0,0 +1,294 @@
diff -cr perl-5.6.0.orig/Configure perl-5.6.0/Configure
*** perl-5.6.0.orig/Configure Wed Mar 22 20:36:37 2000
--- perl-5.6.0/Configure Sun Sep 17 23:40:15 2000
***************
*** 217,222 ****
--- 217,223 ----
nm=''
nroff=''
perl=''
+ perllibs=''
pg=''
pmake=''
pr=''
***************
*** 14971,14976 ****
--- 14972,14985 ----
shift
extensions="$*"
+ : Remove libraries needed only for extensions
+ : The appropriate ext/Foo/Makefile.PL will add them back in, if
+ : necessary.
+ set X `echo " $libs " |
+ sed -e 's@ -lndbm @ @' -e 's@ -lgdbm @ @' -e 's@ -ldbm @ @' -e 's@ -ldb @ @'`
+ shift
+ perllibs="$*"
+
: Remove build directory name from cppstdin so it can be used from
: either the present location or the final installed location.
echo " "
***************
*** 15640,15645 ****
--- 15649,15655 ----
path_sep='$path_sep'
perl5='$perl5'
perl='$perl'
+ perllibs='$perllibs'
perladmin='$perladmin'
perlpath='$perlpath'
pg='$pg'
diff -cr perl-5.6.0.orig/Makefile.SH perl-5.6.0/Makefile.SH
*** perl-5.6.0.orig/Makefile.SH Sat Mar 11 16:05:24 2000
--- perl-5.6.0/Makefile.SH Sun Sep 17 23:40:15 2000
***************
*** 70,76 ****
*) shrpldflags="$shrpldflags -b noentry"
;;
esac
! shrpldflags="$shrpldflags $ldflags $libs $cryptlib"
linklibperl="-L $archlibexp/CORE -L `pwd | sed 's/\/UU$//'` -lperl"
;;
hpux*)
--- 70,76 ----
*) shrpldflags="$shrpldflags -b noentry"
;;
esac
! shrpldflags="$shrpldflags $ldflags $perllibs $cryptlib"
linklibperl="-L $archlibexp/CORE -L `pwd | sed 's/\/UU$//'` -lperl"
;;
hpux*)
***************
*** 176,182 ****
ext = \$(dynamic_ext) \$(static_ext) \$(nonxs_ext)
DYNALOADER = lib/auto/DynaLoader/DynaLoader\$(LIB_EXT)
! libs = $libs $cryptlib
public = perl $suidperl utilities translators
--- 176,182 ----
ext = \$(dynamic_ext) \$(static_ext) \$(nonxs_ext)
DYNALOADER = lib/auto/DynaLoader/DynaLoader\$(LIB_EXT)
! libs = $perllibs $cryptlib
public = perl $suidperl utilities translators
***************
*** 333,339 ****
case "$osname" in
aix)
$spitshell >>Makefile <<!GROK!THIS!
! LIBS = $libs
# In AIX we need to change this for building Perl itself from
# its earlier definition (which is for building external
# extensions *after* Perl has been built and installed)
--- 333,339 ----
case "$osname" in
aix)
$spitshell >>Makefile <<!GROK!THIS!
! LIBS = $perllibs
# In AIX we need to change this for building Perl itself from
# its earlier definition (which is for building external
# extensions *after* Perl has been built and installed)
diff -cr perl-5.6.0.orig/lib/ExtUtils/Embed.pm perl-5.6.0/lib/ExtUtils/Embed.pm
*** perl-5.6.0.orig/lib/ExtUtils/Embed.pm Sun Jan 23 12:08:32 2000
--- perl-5.6.0/lib/ExtUtils/Embed.pm Sun Sep 17 23:40:15 2000
***************
*** 193,199 ****
@path = $path ? split(/:/, $path) : @INC;
push(@potential_libs, @link_args) if scalar @link_args;
! push(@potential_libs, $Config{libs}) if defined $std;
push(@mods, static_ext()) if $std;
--- 193,199 ----
@path = $path ? split(/:/, $path) : @INC;
push(@potential_libs, @link_args) if scalar @link_args;
! push(@potential_libs, $Config{perllibs}) if defined $std;
push(@mods, static_ext()) if $std;
diff -cr perl-5.6.0.orig/lib/ExtUtils/Liblist.pm perl-5.6.0/lib/ExtUtils/Liblist.pm
*** perl-5.6.0.orig/lib/ExtUtils/Liblist.pm Wed Mar 22 16:16:31 2000
--- perl-5.6.0/lib/ExtUtils/Liblist.pm Sun Sep 17 23:40:15 2000
***************
*** 17,34 ****
sub _unix_os2_ext {
my($self,$potential_libs, $verbose) = @_;
! if ($^O =~ 'os2' and $Config{libs}) {
# Dynamic libraries are not transitive, so we may need including
# the libraries linked against perl.dll again.
$potential_libs .= " " if $potential_libs;
! $potential_libs .= $Config{libs};
}
return ("", "", "", "") unless $potential_libs;
warn "Potential libraries are '$potential_libs':\n" if $verbose;
my($so) = $Config{'so'};
! my($libs) = $Config{'libs'};
my $Config_libext = $Config{lib_ext} || ".a";
--- 17,34 ----
sub _unix_os2_ext {
my($self,$potential_libs, $verbose) = @_;
! if ($^O =~ 'os2' and $Config{perllibs}) {
# Dynamic libraries are not transitive, so we may need including
# the libraries linked against perl.dll again.
$potential_libs .= " " if $potential_libs;
! $potential_libs .= $Config{perllibs};
}
return ("", "", "", "") unless $potential_libs;
warn "Potential libraries are '$potential_libs':\n" if $verbose;
my($so) = $Config{'so'};
! my($libs) = $Config{'perllibs'};
my $Config_libext = $Config{lib_ext} || ".a";
***************
*** 198,204 ****
my $BC = 1 if $cc =~ /^bcc/i;
my $GC = 1 if $cc =~ /^gcc/i;
my $so = $Config{'so'};
! my $libs = $Config{'libs'};
my $libpth = $Config{'libpth'};
my $libext = $Config{'lib_ext'} || ".lib";
--- 198,204 ----
my $BC = 1 if $cc =~ /^bcc/i;
my $GC = 1 if $cc =~ /^gcc/i;
my $so = $Config{'so'};
! my $libs = $Config{'perllibs'};
my $libpth = $Config{'libpth'};
my $libext = $Config{'lib_ext'} || ".lib";
***************
*** 338,344 ****
$self->{CCFLAS} || $Config{'ccflags'};
@crtls = ( ($dbgqual =~ m-/Debug-i ? $Config{'dbgprefix'} : '')
. 'PerlShr/Share' );
! push(@crtls, grep { not /\(/ } split /\s+/, $Config{'libs'});
push(@crtls, grep { not /\(/ } split /\s+/, $Config{'libc'});
# In general, we pass through the basic libraries from %Config unchanged.
# The one exception is that if we're building in the Perl source tree, and
--- 338,344 ----
$self->{CCFLAS} || $Config{'ccflags'};
@crtls = ( ($dbgqual =~ m-/Debug-i ? $Config{'dbgprefix'} : '')
. 'PerlShr/Share' );
! push(@crtls, grep { not /\(/ } split /\s+/, $Config{'perllibs'});
push(@crtls, grep { not /\(/ } split /\s+/, $Config{'libc'});
# In general, we pass through the basic libraries from %Config unchanged.
# The one exception is that if we're building in the Perl source tree, and
***************
*** 624,630 ****
=item *
If C<$potential_libs> is empty, the return value will be empty.
! Otherwise, the libraries specified by C<$Config{libs}> (see Config.pm)
will be appended to the list of C<$potential_libs>. The libraries
will be searched for in the directories specified in C<$potential_libs>,
C<$Config{libpth}>, and in C<$Config{installarchlib}/CORE>.
--- 624,630 ----
=item *
If C<$potential_libs> is empty, the return value will be empty.
! Otherwise, the libraries specified by C<$Config{perllibs}> (see Config.pm)
will be appended to the list of C<$potential_libs>. The libraries
will be searched for in the directories specified in C<$potential_libs>,
C<$Config{libpth}>, and in C<$Config{installarchlib}/CORE>.
***************
*** 668,674 ****
alphanumeric characters are treated as flags. Unknown flags will be ignored.
An entry that matches C</:nodefault/i> disables the appending of default
! libraries found in C<$Config{libs}> (this should be only needed very rarely).
An entry that matches C</:nosearch/i> disables all searching for
the libraries specified after it. Translation of C<-Lfoo> and
--- 668,674 ----
alphanumeric characters are treated as flags. Unknown flags will be ignored.
An entry that matches C</:nodefault/i> disables the appending of default
! libraries found in C<$Config{perllibs}> (this should be only needed very rarely).
An entry that matches C</:nosearch/i> disables all searching for
the libraries specified after it. Translation of C<-Lfoo> and
***************
*** 678,684 ****
An entry that matches C</:search/i> reenables searching for
the libraries specified after it. You can put it at the end to
! enable searching for default libraries specified by C<$Config{libs}>.
=item *
--- 678,684 ----
An entry that matches C</:search/i> reenables searching for
the libraries specified after it. You can put it at the end to
! enable searching for default libraries specified by C<$Config{perllibs}>.
=item *
diff -cr perl-5.6.0.orig/lib/ExtUtils/MM_Unix.pm perl-5.6.0/lib/ExtUtils/MM_Unix.pm
*** perl-5.6.0.orig/lib/ExtUtils/MM_Unix.pm Thu Mar 2 17:52:52 2000
--- perl-5.6.0/lib/ExtUtils/MM_Unix.pm Sun Sep 17 23:40:15 2000
***************
*** 2450,2456 ****
MAP_STATIC = ",
join(" \\\n\t", reverse sort keys %static), "
! MAP_PRELIBS = $Config::Config{libs} $Config::Config{cryptlib}
";
if (defined $libperl) {
--- 2450,2456 ----
MAP_STATIC = ",
join(" \\\n\t", reverse sort keys %static), "
! MAP_PRELIBS = $Config::Config{perllibs} $Config::Config{cryptlib}
";
if (defined $libperl) {
diff -cr perl-5.6.0.orig/myconfig.SH perl-5.6.0/myconfig.SH
*** perl-5.6.0.orig/myconfig.SH Sat Feb 26 06:34:49 2000
--- perl-5.6.0/myconfig.SH Sun Sep 17 23:41:17 2000
***************
*** 48,54 ****
Linker and Libraries:
ld='$ld', ldflags ='$ldflags'
libpth=$libpth
! libs=$libs
libc=$libc, so=$so, useshrplib=$useshrplib, libperl=$libperl
Dynamic Linking:
dlsrc=$dlsrc, dlext=$dlext, d_dlsymun=$d_dlsymun, ccdlflags='$ccdlflags'
--- 48,54 ----
Linker and Libraries:
ld='$ld', ldflags ='$ldflags'
libpth=$libpth
! libs=$perllibs
libc=$libc, so=$so, useshrplib=$useshrplib, libperl=$libperl
Dynamic Linking:
dlsrc=$dlsrc, dlext=$dlext, d_dlsymun=$d_dlsymun, ccdlflags='$ccdlflags'
diff -cr perl-5.6.0.orig/patchlevel.h perl-5.6.0/patchlevel.h
*** perl-5.6.0.orig/patchlevel.h Wed Mar 22 20:23:11 2000
--- perl-5.6.0/patchlevel.h Sun Sep 17 23:40:15 2000
***************
*** 70,75 ****
--- 70,76 ----
#if !defined(PERL_PATCHLEVEL_H_IMPLICIT) && !defined(LOCAL_PATCH_COUNT)
static char *local_patches[] = {
NULL
+ ,"NODB-1.0 - remove -ldb from core perl binary."
,NULL
};

349
perl/BerkeleyDB/ppport.h Normal file
View File

@@ -0,0 +1,349 @@
/* This file is Based on output from
* Perl/Pollution/Portability Version 2.0000 */
#ifndef _P_P_PORTABILITY_H_
#define _P_P_PORTABILITY_H_
#ifndef PERL_REVISION
# ifndef __PATCHLEVEL_H_INCLUDED__
# include "patchlevel.h"
# endif
# ifndef PERL_REVISION
# define PERL_REVISION (5)
/* Replace: 1 */
# define PERL_VERSION PATCHLEVEL
# define PERL_SUBVERSION SUBVERSION
/* Replace PERL_PATCHLEVEL with PERL_VERSION */
/* Replace: 0 */
# endif
#endif
#define PERL_BCDVERSION ((PERL_REVISION * 0x1000000L) + (PERL_VERSION * 0x1000L) + PERL_SUBVERSION)
#ifndef ERRSV
# define ERRSV perl_get_sv("@",FALSE)
#endif
#if (PERL_VERSION < 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION <= 5))
/* Replace: 1 */
# define PL_Sv Sv
# define PL_compiling compiling
# define PL_copline copline
# define PL_curcop curcop
# define PL_curstash curstash
# define PL_defgv defgv
# define PL_dirty dirty
# define PL_hints hints
# define PL_na na
# define PL_perldb perldb
# define PL_rsfp_filters rsfp_filters
# define PL_rsfp rsfp
# define PL_stdingv stdingv
# define PL_sv_no sv_no
# define PL_sv_undef sv_undef
# define PL_sv_yes sv_yes
/* Replace: 0 */
#endif
#ifndef pTHX
# define pTHX
# define pTHX_
# define aTHX
# define aTHX_
#endif
#ifndef PTR2IV
# define PTR2IV(d) (IV)(d)
#endif
#ifndef INT2PTR
# define INT2PTR(any,d) (any)(d)
#endif
#ifndef dTHR
# ifdef WIN32
# define dTHR extern int Perl___notused
# else
# define dTHR extern int errno
# endif
#endif
#ifndef boolSV
# define boolSV(b) ((b) ? &PL_sv_yes : &PL_sv_no)
#endif
#ifndef gv_stashpvn
# define gv_stashpvn(str,len,flags) gv_stashpv(str,flags)
#endif
#ifndef newSVpvn
# define newSVpvn(data,len) ((len) ? newSVpv ((data), (len)) : newSVpv ("", 0))
#endif
#ifndef newRV_inc
/* Replace: 1 */
# define newRV_inc(sv) newRV(sv)
/* Replace: 0 */
#endif
#ifndef SvGETMAGIC
# define SvGETMAGIC(x) STMT_START { if (SvGMAGICAL(x)) mg_get(x); } STMT_END
#endif
/* DEFSV appears first in 5.004_56 */
#ifndef DEFSV
# define DEFSV GvSV(PL_defgv)
#endif
#ifndef SAVE_DEFSV
# define SAVE_DEFSV SAVESPTR(GvSV(PL_defgv))
#endif
#ifndef newRV_noinc
# ifdef __GNUC__
# define newRV_noinc(sv) \
({ \
SV *nsv = (SV*)newRV(sv); \
SvREFCNT_dec(sv); \
nsv; \
})
# else
# if defined(CRIPPLED_CC) || defined(USE_THREADS)
static SV * newRV_noinc (SV * sv)
{
SV *nsv = (SV*)newRV(sv);
SvREFCNT_dec(sv);
return nsv;
}
# else
# define newRV_noinc(sv) \
((PL_Sv=(SV*)newRV(sv), SvREFCNT_dec(sv), (SV*)PL_Sv)
# endif
# endif
#endif
/* Provide: newCONSTSUB */
/* newCONSTSUB from IO.xs is in the core starting with 5.004_63 */
#if (PERL_VERSION < 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION < 63))
#if defined(NEED_newCONSTSUB)
static
#else
extern void newCONSTSUB _((HV * stash, char * name, SV *sv));
#endif
#if defined(NEED_newCONSTSUB) || defined(NEED_newCONSTSUB_GLOBAL)
void
newCONSTSUB(stash,name,sv)
HV *stash;
char *name;
SV *sv;
{
U32 oldhints = PL_hints;
HV *old_cop_stash = PL_curcop->cop_stash;
HV *old_curstash = PL_curstash;
line_t oldline = PL_curcop->cop_line;
PL_curcop->cop_line = PL_copline;
PL_hints &= ~HINT_BLOCK_SCOPE;
if (stash)
PL_curstash = PL_curcop->cop_stash = stash;
newSUB(
#if (PERL_VERSION < 3) || ((PERL_VERSION == 3) && (PERL_SUBVERSION < 22))
/* before 5.003_22 */
start_subparse(),
#else
# if (PERL_VERSION == 3) && (PERL_SUBVERSION == 22)
/* 5.003_22 */
start_subparse(0),
# else
/* 5.003_23 onwards */
start_subparse(FALSE, 0),
# endif
#endif
newSVOP(OP_CONST, 0, newSVpv(name,0)),
newSVOP(OP_CONST, 0, &PL_sv_no), /* SvPV(&PL_sv_no) == "" -- GMB */
newSTATEOP(0, Nullch, newSVOP(OP_CONST, 0, sv))
);
PL_hints = oldhints;
PL_curcop->cop_stash = old_cop_stash;
PL_curstash = old_curstash;
PL_curcop->cop_line = oldline;
}
#endif
#endif /* newCONSTSUB */
#ifndef START_MY_CXT
/*
* Boilerplate macros for initializing and accessing interpreter-local
* data from C. All statics in extensions should be reworked to use
* this, if you want to make the extension thread-safe. See ext/re/re.xs
* for an example of the use of these macros.
*
* Code that uses these macros is responsible for the following:
* 1. #define MY_CXT_KEY to a unique string, e.g. "DynaLoader_guts"
* 2. Declare a typedef named my_cxt_t that is a structure that contains
* all the data that needs to be interpreter-local.
* 3. Use the START_MY_CXT macro after the declaration of my_cxt_t.
* 4. Use the MY_CXT_INIT macro such that it is called exactly once
* (typically put in the BOOT: section).
* 5. Use the members of the my_cxt_t structure everywhere as
* MY_CXT.member.
* 6. Use the dMY_CXT macro (a declaration) in all the functions that
* access MY_CXT.
*/
#if defined(MULTIPLICITY) || defined(PERL_OBJECT) || \
defined(PERL_CAPI) || defined(PERL_IMPLICIT_CONTEXT)
/* This must appear in all extensions that define a my_cxt_t structure,
* right after the definition (i.e. at file scope). The non-threads
* case below uses it to declare the data as static. */
#define START_MY_CXT
#if PERL_REVISION == 5 && \
(PERL_VERSION < 4 || (PERL_VERSION == 4 && PERL_SUBVERSION < 68 ))
/* Fetches the SV that keeps the per-interpreter data. */
#define dMY_CXT_SV \
SV *my_cxt_sv = perl_get_sv(MY_CXT_KEY, FALSE)
#else /* >= perl5.004_68 */
#define dMY_CXT_SV \
SV *my_cxt_sv = *hv_fetch(PL_modglobal, MY_CXT_KEY, \
sizeof(MY_CXT_KEY)-1, TRUE)
#endif /* < perl5.004_68 */
/* This declaration should be used within all functions that use the
* interpreter-local data. */
#define dMY_CXT \
dMY_CXT_SV; \
my_cxt_t *my_cxtp = INT2PTR(my_cxt_t*,SvUV(my_cxt_sv))
/* Creates and zeroes the per-interpreter data.
* (We allocate my_cxtp in a Perl SV so that it will be released when
* the interpreter goes away.) */
#define MY_CXT_INIT \
dMY_CXT_SV; \
/* newSV() allocates one more than needed */ \
my_cxt_t *my_cxtp = (my_cxt_t*)SvPVX(newSV(sizeof(my_cxt_t)-1));\
Zero(my_cxtp, 1, my_cxt_t); \
sv_setuv(my_cxt_sv, PTR2UV(my_cxtp))
/* This macro must be used to access members of the my_cxt_t structure.
* e.g. MYCXT.some_data */
#define MY_CXT (*my_cxtp)
/* Judicious use of these macros can reduce the number of times dMY_CXT
* is used. Use is similar to pTHX, aTHX etc. */
#define pMY_CXT my_cxt_t *my_cxtp
#define pMY_CXT_ pMY_CXT,
#define _pMY_CXT ,pMY_CXT
#define aMY_CXT my_cxtp
#define aMY_CXT_ aMY_CXT,
#define _aMY_CXT ,aMY_CXT
#else /* single interpreter */
#ifndef NOOP
# define NOOP (void)0
#endif
#ifdef HASATTRIBUTE
# define PERL_UNUSED_DECL __attribute__((unused))
#else
# define PERL_UNUSED_DECL
#endif
#ifndef dNOOP
# define dNOOP extern int Perl___notused PERL_UNUSED_DECL
#endif
#define START_MY_CXT static my_cxt_t my_cxt;
#define dMY_CXT_SV dNOOP
#define dMY_CXT dNOOP
#define MY_CXT_INIT NOOP
#define MY_CXT my_cxt
#define pMY_CXT void
#define pMY_CXT_
#define _pMY_CXT
#define aMY_CXT
#define aMY_CXT_
#define _aMY_CXT
#endif
#endif /* START_MY_CXT */
#if 1
#ifdef DBM_setFilter
#undef DBM_setFilter
#undef DBM_ckFilter
#endif
#endif
#ifndef DBM_setFilter
/*
The DBM_setFilter & DBM_ckFilter macros are only used by
the *DB*_File modules
*/
#define DBM_setFilter(db_type,code) \
{ \
if (db_type) \
RETVAL = sv_mortalcopy(db_type) ; \
ST(0) = RETVAL ; \
if (db_type && (code == &PL_sv_undef)) { \
SvREFCNT_dec(db_type) ; \
db_type = NULL ; \
} \
else if (code) { \
if (db_type) \
sv_setsv(db_type, code) ; \
else \
db_type = newSVsv(code) ; \
} \
}
#define DBM_ckFilter(arg,type,name) \
if (db->type) { \
/* printf("Filtering %s\n", name); */ \
if (db->filtering) { \
croak("recursion detected in %s", name) ; \
} \
ENTER ; \
SAVETMPS ; \
SAVEINT(db->filtering) ; \
db->filtering = TRUE ; \
SAVESPTR(DEFSV) ; \
if (name[7] == 's') \
arg = newSVsv(arg); \
DEFSV = arg ; \
SvTEMP_off(arg) ; \
PUSHMARK(SP) ; \
PUTBACK ; \
(void) perl_call_sv(db->type, G_DISCARD); \
arg = DEFSV ; \
SPAGAIN ; \
PUTBACK ; \
FREETMPS ; \
LEAVE ; \
if (name[7] == 's'){ \
arg = sv_2mortal(arg); \
} \
SvOKp(arg); \
}
#endif /* DBM_setFilter */
#endif /* _P_P_PORTABILITY_H_ */

238
perl/BerkeleyDB/scan Normal file
View File

@@ -0,0 +1,238 @@
#!/usr/local/bin/perl
my $ignore_re = '^(' . join("|",
qw(
_
[a-z]
DBM
DBC
DB_AM_
DB_BT_
DB_RE_
DB_HS_
DB_FUNC_
DB_DBT_
DB_DBM
DB_TSL
MP
TXN
DB_TXN_GETPGNOS
)) . ')' ;
my %ignore_def = map {$_, 1} qw() ;
%ignore_enums = map {$_, 1} qw( ACTION db_status_t db_notices db_lockmode_t ) ;
my %ignore_exact_enum = map { $_ => 1}
qw(
DB_TXN_GETPGNOS
);
my $filler = ' ' x 26 ;
chdir "libraries" || die "Cannot chdir into './libraries': $!\n";
foreach my $name (sort tuple glob "[2-9]*")
{
next if $name =~ /(NC|private)$/;
my $inc = "$name/include/db.h" ;
next unless -f $inc ;
my $file = readFile($inc) ;
StripCommentsAndStrings($file) ;
my $result = scan($name, $file) ;
print "\n\t#########\n\t# $name\n\t#########\n\n$result"
if $result;
}
exit ;
sub scan
{
my $version = shift ;
my $file = shift ;
my %seen_define = () ;
my $result = "" ;
if (1) {
# Preprocess all tri-graphs
# including things stuck in quoted string constants.
$file =~ s/\?\?=/#/g; # | ??=| #|
$file =~ s/\?\?\!/|/g; # | ??!| ||
$file =~ s/\?\?'/^/g; # | ??'| ^|
$file =~ s/\?\?\(/[/g; # | ??(| [|
$file =~ s/\?\?\)/]/g; # | ??)| ]|
$file =~ s/\?\?\-/~/g; # | ??-| ~|
$file =~ s/\?\?\//\\/g; # | ??/| \|
$file =~ s/\?\?</{/g; # | ??<| {|
$file =~ s/\?\?>/}/g; # | ??>| }|
}
while ( $file =~ /^\s*#\s*define\s+([\$\w]+)\b(?!\()\s*(.*)/gm )
{
my $def = $1;
my $rest = $2;
my $ignore = 0 ;
$ignore = 1 if $ignore_def{$def} || $def =~ /$ignore_re/o ;
# Cannot do: (-1) and ((LHANDLE)3) are OK:
#print("Skip non-wordy $def => $rest\n"),
$rest =~ s/\s*$//;
#next if $rest =~ /[^\w\$]/;
#print "Matched $_ ($def)\n" ;
next if $before{$def} ++ ;
if ($ignore)
{ $seen_define{$def} = 'IGNORE' }
elsif ($rest =~ /"/)
{ $seen_define{$def} = 'STRING' }
else
{ $seen_define{$def} = 'DEFINE' }
}
foreach $define (sort keys %seen_define)
{
my $out = $filler ;
substr($out,0, length $define) = $define;
$result .= "\t$out => $seen_define{$define},\n" ;
}
while ($file =~ /\btypedef\s+enum\s*{(.*?)}\s*(\w+)/gs )
{
my $enum = $1 ;
my $name = $2 ;
my $ignore = 0 ;
$ignore = 1 if $ignore_enums{$name} ;
#$enum =~ s/\s*=\s*\S+\s*(,?)\s*\n/$1/g;
$enum =~ s/^\s*//;
$enum =~ s/\s*$//;
my @tokens = map { s/\s*=.*// ; $_} split /\s*,\s*/, $enum ;
my @new = grep { ! $Enums{$_}++ } @tokens ;
if (@new)
{
my $value ;
if ($ignore)
{ $value = "IGNORE, # $version" }
else
{ $value = "'$version'," }
$result .= "\n\t# enum $name\n";
my $out = $filler ;
foreach $name (@new)
{
next if $ignore_exact_enum{$name} ;
$out = $filler ;
substr($out,0, length $name) = $name;
$result .= "\t$out => $value\n" ;
}
}
}
return $result ;
}
sub StripCommentsAndStrings
{
# Strip C & C++ coments
# From the perlfaq
$_[0] =~
s{
/\* ## Start of /* ... */ comment
[^*]*\*+ ## Non-* followed by 1-or-more *'s
(
[^/*][^*]*\*+
)* ## 0-or-more things which don't start with /
## but do end with '*'
/ ## End of /* ... */ comment
| ## OR C++ Comment
// ## Start of C++ comment //
[^\n]* ## followed by 0-or-more non end of line characters
| ## OR various things which aren't comments:
(
" ## Start of " ... " string
(
\\. ## Escaped char
| ## OR
[^"\\] ## Non "\
)*
" ## End of " ... " string
| ## OR
' ## Start of ' ... ' string
(
\\. ## Escaped char
| ## OR
[^'\\] ## Non '\
)*
' ## End of ' ... ' string
| ## OR
. ## Anything other char
[^/"'\\]* ## Chars which doesn't start a comment, string or escape
)
}{$2}gxs;
# Remove double-quoted strings.
#$_[0] =~ s#"(\\.|[^"\\])*"##g;
# Remove single-quoted strings.
#$_[0] =~ s#'(\\.|[^'\\])*'##g;
# Remove leading whitespace.
$_[0] =~ s/\A\s+//m ;
# Remove trailing whitespace.
$_[0] =~ s/\s+\Z//m ;
# Replace all multiple whitespace by a single space.
#$_[0] =~ s/\s+/ /g ;
}
sub readFile
{
my $filename = shift ;
open F, "<$filename" || die "Cannot open $filename: $!\n" ;
local $/ ;
my $x = <F> ;
close F ;
return $x ;
}
sub tuple
{
my (@a) = split(/\./, $a) ;
my (@b) = split(/\./, $b) ;
if (@a != @b) {
my $diff = @a - @b ;
push @b, (0 x $diff) if $diff > 0 ;
push @a, (0 x -$diff) if $diff < 0 ;
}
foreach $A (@a) {
$B = shift @b ;
$A == $B or return $A <=> $B ;
}
return 0;
}
__END__

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

925
perl/BerkeleyDB/t/btree.t Normal file
View File

@@ -0,0 +1,925 @@
#!./perl -w
use strict ;
use lib 't';
use BerkeleyDB;
use util ;
print "1..244\n";
my $Dfile = "dbhash.tmp";
my $Dfile2 = "dbhash2.tmp";
my $Dfile3 = "dbhash3.tmp";
unlink $Dfile;
umask(0) ;
# Check for invalid parameters
{
# Check for invalid parameters
my $db ;
eval ' $db = new BerkeleyDB::Btree -Stupid => 3 ; ' ;
ok 1, $@ =~ /unknown key value\(s\) Stupid/ ;
eval ' $db = new BerkeleyDB::Btree -Bad => 2, -Mode => 0345, -Stupid => 3; ' ;
ok 2, $@ =~ /unknown key value\(s\) (Bad,? |Stupid,? ){2}/
or print "# $@" ;
eval ' $db = new BerkeleyDB::Btree -Env => 2 ' ;
ok 3, $@ =~ /^Env not of type BerkeleyDB::Env/ ;
eval ' $db = new BerkeleyDB::Btree -Txn => "x" ' ;
ok 4, $@ =~ /^Txn not of type BerkeleyDB::Txn/ ;
my $obj = bless [], "main" ;
eval ' $db = new BerkeleyDB::Btree -Env => $obj ' ;
ok 5, $@ =~ /^Env not of type BerkeleyDB::Env/ ;
}
# Now check the interface to Btree
{
my $lex = new LexFile $Dfile ;
ok 6, my $db = new BerkeleyDB::Btree -Filename => $Dfile,
-Flags => DB_CREATE ;
# Add a k/v pair
my $value ;
my $status ;
ok 7, $db->db_put("some key", "some value") == 0 ;
ok 8, $db->status() == 0 ;
ok 9, $db->db_get("some key", $value) == 0 ;
ok 10, $value eq "some value" ;
ok 11, $db->db_put("key", "value") == 0 ;
ok 12, $db->db_get("key", $value) == 0 ;
ok 13, $value eq "value" ;
ok 14, $db->db_del("some key") == 0 ;
ok 15, ($status = $db->db_get("some key", $value)) == DB_NOTFOUND ;
ok 16, $db->status() == DB_NOTFOUND ;
ok 17, $db->status() eq $DB_errors{'DB_NOTFOUND'} ;
ok 18, $db->db_sync() == 0 ;
# Check NOOVERWRITE will make put fail when attempting to overwrite
# an existing record.
ok 19, $db->db_put( 'key', 'x', DB_NOOVERWRITE) == DB_KEYEXIST ;
ok 20, $db->status() eq $DB_errors{'DB_KEYEXIST'} ;
ok 21, $db->status() == DB_KEYEXIST ;
# check that the value of the key has not been changed by the
# previous test
ok 22, $db->db_get("key", $value) == 0 ;
ok 23, $value eq "value" ;
# test DB_GET_BOTH
my ($k, $v) = ("key", "value") ;
ok 24, $db->db_get($k, $v, DB_GET_BOTH) == 0 ;
($k, $v) = ("key", "fred") ;
ok 25, $db->db_get($k, $v, DB_GET_BOTH) == DB_NOTFOUND ;
($k, $v) = ("another", "value") ;
ok 26, $db->db_get($k, $v, DB_GET_BOTH) == DB_NOTFOUND ;
}
{
# Check simple env works with a hash.
my $lex = new LexFile $Dfile ;
my $home = "./fred" ;
ok 27, my $lexD = new LexDir($home) ;
ok 28, my $env = new BerkeleyDB::Env -Flags => DB_CREATE|DB_INIT_MPOOL,
@StdErrFile, -Home => $home ;
ok 29, my $db = new BerkeleyDB::Btree -Filename => $Dfile,
-Env => $env,
-Flags => DB_CREATE ;
# Add a k/v pair
my $value ;
ok 30, $db->db_put("some key", "some value") == 0 ;
ok 31, $db->db_get("some key", $value) == 0 ;
ok 32, $value eq "some value" ;
undef $db ;
undef $env ;
}
{
# cursors
my $lex = new LexFile $Dfile ;
my %hash ;
my ($k, $v) ;
ok 33, my $db = new BerkeleyDB::Btree -Filename => $Dfile,
-Flags => DB_CREATE ;
#print "[$db] [$!] $BerkeleyDB::Error\n" ;
# create some data
my %data = (
"red" => 2,
"green" => "house",
"blue" => "sea",
) ;
my $ret = 0 ;
while (($k, $v) = each %data) {
$ret += $db->db_put($k, $v) ;
}
ok 34, $ret == 0 ;
# create the cursor
ok 35, my $cursor = $db->db_cursor() ;
$k = $v = "" ;
my %copy = %data ;
my $extras = 0 ;
# sequence forwards
while ($cursor->c_get($k, $v, DB_NEXT) == 0) {
if ( $copy{$k} eq $v )
{ delete $copy{$k} }
else
{ ++ $extras }
}
ok 36, $cursor->status() == DB_NOTFOUND ;
ok 37, $cursor->status() eq $DB_errors{'DB_NOTFOUND'};
ok 38, keys %copy == 0 ;
ok 39, $extras == 0 ;
# sequence backwards
%copy = %data ;
$extras = 0 ;
my $status ;
for ( $status = $cursor->c_get($k, $v, DB_LAST) ;
$status == 0 ;
$status = $cursor->c_get($k, $v, DB_PREV)) {
if ( $copy{$k} eq $v )
{ delete $copy{$k} }
else
{ ++ $extras }
}
ok 40, $status == DB_NOTFOUND ;
ok 41, $status eq $DB_errors{'DB_NOTFOUND'};
ok 42, $cursor->status() == $status ;
ok 43, $cursor->status() eq $status ;
ok 44, keys %copy == 0 ;
ok 45, $extras == 0 ;
($k, $v) = ("green", "house") ;
ok 46, $cursor->c_get($k, $v, DB_GET_BOTH) == 0 ;
($k, $v) = ("green", "door") ;
ok 47, $cursor->c_get($k, $v, DB_GET_BOTH) == DB_NOTFOUND ;
($k, $v) = ("black", "house") ;
ok 48, $cursor->c_get($k, $v, DB_GET_BOTH) == DB_NOTFOUND ;
}
{
# Tied Hash interface
my $lex = new LexFile $Dfile ;
my %hash ;
ok 49, tie %hash, 'BerkeleyDB::Btree', -Filename => $Dfile,
-Flags => DB_CREATE ;
# check "each" with an empty database
my $count = 0 ;
while (my ($k, $v) = each %hash) {
++ $count ;
}
ok 50, (tied %hash)->status() == DB_NOTFOUND ;
ok 51, $count == 0 ;
# Add a k/v pair
my $value ;
$hash{"some key"} = "some value";
ok 52, (tied %hash)->status() == 0 ;
ok 53, $hash{"some key"} eq "some value";
ok 54, defined $hash{"some key"} ;
ok 55, (tied %hash)->status() == 0 ;
ok 56, exists $hash{"some key"} ;
ok 57, !defined $hash{"jimmy"} ;
ok 58, (tied %hash)->status() == DB_NOTFOUND ;
ok 59, !exists $hash{"jimmy"} ;
ok 60, (tied %hash)->status() == DB_NOTFOUND ;
delete $hash{"some key"} ;
ok 61, (tied %hash)->status() == 0 ;
ok 62, ! defined $hash{"some key"} ;
ok 63, (tied %hash)->status() == DB_NOTFOUND ;
ok 64, ! exists $hash{"some key"} ;
ok 65, (tied %hash)->status() == DB_NOTFOUND ;
$hash{1} = 2 ;
$hash{10} = 20 ;
$hash{1000} = 2000 ;
my ($keys, $values) = (0,0);
$count = 0 ;
while (my ($k, $v) = each %hash) {
$keys += $k ;
$values += $v ;
++ $count ;
}
ok 66, $count == 3 ;
ok 67, $keys == 1011 ;
ok 68, $values == 2022 ;
# now clear the hash
%hash = () ;
ok 69, keys %hash == 0 ;
untie %hash ;
}
{
# override default compare
my $lex = new LexFile $Dfile, $Dfile2, $Dfile3 ;
my $value ;
my (%h, %g, %k) ;
my @Keys = qw( 0123 12 -1234 9 987654321 def ) ;
ok 70, tie %h, "BerkeleyDB::Btree", -Filename => $Dfile,
-Compare => sub { $_[0] <=> $_[1] },
-Flags => DB_CREATE ;
ok 71, tie %g, 'BerkeleyDB::Btree', -Filename => $Dfile2,
-Compare => sub { $_[0] cmp $_[1] },
-Flags => DB_CREATE ;
ok 72, tie %k, 'BerkeleyDB::Btree', -Filename => $Dfile3,
-Compare => sub { length $_[0] <=> length $_[1] },
-Flags => DB_CREATE ;
my @srt_1 ;
{ local $^W = 0 ;
@srt_1 = sort { $a <=> $b } @Keys ;
}
my @srt_2 = sort { $a cmp $b } @Keys ;
my @srt_3 = sort { length $a <=> length $b } @Keys ;
foreach (@Keys) {
local $^W = 0 ;
$h{$_} = 1 ;
$g{$_} = 1 ;
$k{$_} = 1 ;
}
sub ArrayCompare
{
my($a, $b) = @_ ;
return 0 if @$a != @$b ;
foreach (1 .. length @$a)
{
return 0 unless $$a[$_] eq $$b[$_] ;
}
1 ;
}
ok 73, ArrayCompare (\@srt_1, [keys %h]);
ok 74, ArrayCompare (\@srt_2, [keys %g]);
ok 75, ArrayCompare (\@srt_3, [keys %k]);
}
{
# override default compare, with duplicates, don't sort values
my $lex = new LexFile $Dfile, $Dfile2, $Dfile3 ;
my $value ;
my (%h, %g, %k) ;
my @Keys = qw( 0123 9 12 -1234 9 987654321 def ) ;
my @Values = qw( 1 0 3 dd x abc 0 ) ;
ok 76, tie %h, "BerkeleyDB::Btree", -Filename => $Dfile,
-Compare => sub { $_[0] <=> $_[1] },
-Property => DB_DUP,
-Flags => DB_CREATE ;
ok 77, tie %g, 'BerkeleyDB::Btree', -Filename => $Dfile2,
-Compare => sub { $_[0] cmp $_[1] },
-Property => DB_DUP,
-Flags => DB_CREATE ;
ok 78, tie %k, 'BerkeleyDB::Btree', -Filename => $Dfile3,
-Compare => sub { length $_[0] <=> length $_[1] },
-Property => DB_DUP,
-Flags => DB_CREATE ;
my @srt_1 ;
{ local $^W = 0 ;
@srt_1 = sort { $a <=> $b } @Keys ;
}
my @srt_2 = sort { $a cmp $b } @Keys ;
my @srt_3 = sort { length $a <=> length $b } @Keys ;
foreach (@Keys) {
local $^W = 0 ;
my $value = shift @Values ;
$h{$_} = $value ;
$g{$_} = $value ;
$k{$_} = $value ;
}
sub getValues
{
my $hash = shift ;
my $db = tied %$hash ;
my $cursor = $db->db_cursor() ;
my @values = () ;
my ($k, $v) = (0,0) ;
while ($cursor->c_get($k, $v, DB_NEXT) == 0) {
push @values, $v ;
}
return @values ;
}
ok 79, ArrayCompare (\@srt_1, [keys %h]);
ok 80, ArrayCompare (\@srt_2, [keys %g]);
ok 81, ArrayCompare (\@srt_3, [keys %k]);
ok 82, ArrayCompare ([qw(dd 0 0 x 3 1 abc)], [getValues \%h]);
ok 83, ArrayCompare ([qw(dd 1 0 3 x abc 0)], [getValues \%g]);
ok 84, ArrayCompare ([qw(0 x 3 0 1 dd abc)], [getValues \%k]);
# test DB_DUP_NEXT
ok 85, my $cur = (tied %g)->db_cursor() ;
my ($k, $v) = (9, "") ;
ok 86, $cur->c_get($k, $v, DB_SET) == 0 ;
ok 87, $k == 9 && $v == 0 ;
ok 88, $cur->c_get($k, $v, DB_NEXT_DUP) == 0 ;
ok 89, $k == 9 && $v eq "x" ;
ok 90, $cur->c_get($k, $v, DB_NEXT_DUP) == DB_NOTFOUND ;
}
{
# override default compare, with duplicates, sort values
my $lex = new LexFile $Dfile, $Dfile2;
my $value ;
my (%h, %g) ;
my @Keys = qw( 0123 9 12 -1234 9 987654321 9 def ) ;
my @Values = qw( 1 11 3 dd x abc 2 0 ) ;
ok 91, tie %h, "BerkeleyDB::Btree", -Filename => $Dfile,
-Compare => sub { $_[0] <=> $_[1] },
-DupCompare => sub { $_[0] cmp $_[1] },
-Property => DB_DUP,
-Flags => DB_CREATE ;
ok 92, tie %g, 'BerkeleyDB::Btree', -Filename => $Dfile2,
-Compare => sub { $_[0] cmp $_[1] },
-DupCompare => sub { $_[0] <=> $_[1] },
-Property => DB_DUP,
-Flags => DB_CREATE ;
my @srt_1 ;
{ local $^W = 0 ;
@srt_1 = sort { $a <=> $b } @Keys ;
}
my @srt_2 = sort { $a cmp $b } @Keys ;
foreach (@Keys) {
local $^W = 0 ;
my $value = shift @Values ;
$h{$_} = $value ;
$g{$_} = $value ;
}
ok 93, ArrayCompare (\@srt_1, [keys %h]);
ok 94, ArrayCompare (\@srt_2, [keys %g]);
ok 95, ArrayCompare ([qw(dd 1 3 x 2 11 abc 0)], [getValues \%g]);
ok 96, ArrayCompare ([qw(dd 0 11 2 x 3 1 abc)], [getValues \%h]);
}
{
# get_dup etc
my $lex = new LexFile $Dfile;
my %hh ;
ok 97, my $YY = tie %hh, "BerkeleyDB::Btree", -Filename => $Dfile,
-DupCompare => sub { $_[0] cmp $_[1] },
-Property => DB_DUP,
-Flags => DB_CREATE ;
$hh{'Wall'} = 'Larry' ;
$hh{'Wall'} = 'Stone' ; # Note the duplicate key
$hh{'Wall'} = 'Brick' ; # Note the duplicate key
$hh{'Smith'} = 'John' ;
$hh{'mouse'} = 'mickey' ;
# first work in scalar context
ok 98, scalar $YY->get_dup('Unknown') == 0 ;
ok 99, scalar $YY->get_dup('Smith') == 1 ;
ok 100, scalar $YY->get_dup('Wall') == 3 ;
# now in list context
my @unknown = $YY->get_dup('Unknown') ;
ok 101, "@unknown" eq "" ;
my @smith = $YY->get_dup('Smith') ;
ok 102, "@smith" eq "John" ;
{
my @wall = $YY->get_dup('Wall') ;
my %wall ;
@wall{@wall} = @wall ;
ok 103, (@wall == 3 && $wall{'Larry'} && $wall{'Stone'} && $wall{'Brick'});
}
# hash
my %unknown = $YY->get_dup('Unknown', 1) ;
ok 104, keys %unknown == 0 ;
my %smith = $YY->get_dup('Smith', 1) ;
ok 105, keys %smith == 1 && $smith{'John'} ;
my %wall = $YY->get_dup('Wall', 1) ;
ok 106, keys %wall == 3 && $wall{'Larry'} == 1 && $wall{'Stone'} == 1
&& $wall{'Brick'} == 1 ;
undef $YY ;
untie %hh ;
}
{
# in-memory file
my $lex = new LexFile $Dfile ;
my %hash ;
my $fd ;
my $value ;
ok 107, my $db = tie %hash, 'BerkeleyDB::Btree' ;
ok 108, $db->db_put("some key", "some value") == 0 ;
ok 109, $db->db_get("some key", $value) == 0 ;
ok 110, $value eq "some value" ;
}
{
# partial
# check works via API
my $lex = new LexFile $Dfile ;
my $value ;
ok 111, my $db = new BerkeleyDB::Btree, -Filename => $Dfile,
-Flags => DB_CREATE ;
# create some data
my %data = (
"red" => "boat",
"green" => "house",
"blue" => "sea",
) ;
my $ret = 0 ;
while (my ($k, $v) = each %data) {
$ret += $db->db_put($k, $v) ;
}
ok 112, $ret == 0 ;
# do a partial get
my ($pon, $off, $len) = $db->partial_set(0,2) ;
ok 113, ! $pon && $off == 0 && $len == 0 ;
ok 114, $db->db_get("red", $value) == 0 && $value eq "bo" ;
ok 115, $db->db_get("green", $value) == 0 && $value eq "ho" ;
ok 116, $db->db_get("blue", $value) == 0 && $value eq "se" ;
# do a partial get, off end of data
($pon, $off, $len) = $db->partial_set(3,2) ;
ok 117, $pon ;
ok 118, $off == 0 ;
ok 119, $len == 2 ;
ok 120, $db->db_get("red", $value) == 0 && $value eq "t" ;
ok 121, $db->db_get("green", $value) == 0 && $value eq "se" ;
ok 122, $db->db_get("blue", $value) == 0 && $value eq "" ;
# switch of partial mode
($pon, $off, $len) = $db->partial_clear() ;
ok 123, $pon ;
ok 124, $off == 3 ;
ok 125, $len == 2 ;
ok 126, $db->db_get("red", $value) == 0 && $value eq "boat" ;
ok 127, $db->db_get("green", $value) == 0 && $value eq "house" ;
ok 128, $db->db_get("blue", $value) == 0 && $value eq "sea" ;
# now partial put
$db->partial_set(0,2) ;
ok 129, $db->db_put("red", "") == 0 ;
ok 130, $db->db_put("green", "AB") == 0 ;
ok 131, $db->db_put("blue", "XYZ") == 0 ;
ok 132, $db->db_put("new", "KLM") == 0 ;
($pon, $off, $len) = $db->partial_clear() ;
ok 133, $pon ;
ok 134, $off == 0 ;
ok 135, $len == 2 ;
ok 136, $db->db_get("red", $value) == 0 && $value eq "at" ;
ok 137, $db->db_get("green", $value) == 0 && $value eq "ABuse" ;
ok 138, $db->db_get("blue", $value) == 0 && $value eq "XYZa" ;
ok 139, $db->db_get("new", $value) == 0 && $value eq "KLM" ;
# now partial put
($pon, $off, $len) = $db->partial_set(3,2) ;
ok 140, ! $pon ;
ok 141, $off == 0 ;
ok 142, $len == 0 ;
ok 143, $db->db_put("red", "PPP") == 0 ;
ok 144, $db->db_put("green", "Q") == 0 ;
ok 145, $db->db_put("blue", "XYZ") == 0 ;
ok 146, $db->db_put("new", "TU") == 0 ;
$db->partial_clear() ;
ok 147, $db->db_get("red", $value) == 0 && $value eq "at\0PPP" ;
ok 148, $db->db_get("green", $value) == 0 && $value eq "ABuQ" ;
ok 149, $db->db_get("blue", $value) == 0 && $value eq "XYZXYZ" ;
ok 150, $db->db_get("new", $value) == 0 && $value eq "KLMTU" ;
}
{
# partial
# check works via tied hash
my $lex = new LexFile $Dfile ;
my %hash ;
my $value ;
ok 151, my $db = tie %hash, 'BerkeleyDB::Btree', -Filename => $Dfile,
-Flags => DB_CREATE ;
# create some data
my %data = (
"red" => "boat",
"green" => "house",
"blue" => "sea",
) ;
while (my ($k, $v) = each %data) {
$hash{$k} = $v ;
}
# do a partial get
$db->partial_set(0,2) ;
ok 152, $hash{"red"} eq "bo" ;
ok 153, $hash{"green"} eq "ho" ;
ok 154, $hash{"blue"} eq "se" ;
# do a partial get, off end of data
$db->partial_set(3,2) ;
ok 155, $hash{"red"} eq "t" ;
ok 156, $hash{"green"} eq "se" ;
ok 157, $hash{"blue"} eq "" ;
# switch of partial mode
$db->partial_clear() ;
ok 158, $hash{"red"} eq "boat" ;
ok 159, $hash{"green"} eq "house" ;
ok 160, $hash{"blue"} eq "sea" ;
# now partial put
$db->partial_set(0,2) ;
ok 161, $hash{"red"} = "" ;
ok 162, $hash{"green"} = "AB" ;
ok 163, $hash{"blue"} = "XYZ" ;
ok 164, $hash{"new"} = "KLM" ;
$db->partial_clear() ;
ok 165, $hash{"red"} eq "at" ;
ok 166, $hash{"green"} eq "ABuse" ;
ok 167, $hash{"blue"} eq "XYZa" ;
ok 168, $hash{"new"} eq "KLM" ;
# now partial put
$db->partial_set(3,2) ;
ok 169, $hash{"red"} = "PPP" ;
ok 170, $hash{"green"} = "Q" ;
ok 171, $hash{"blue"} = "XYZ" ;
ok 172, $hash{"new"} = "TU" ;
$db->partial_clear() ;
ok 173, $hash{"red"} eq "at\0PPP" ;
ok 174, $hash{"green"} eq "ABuQ" ;
ok 175, $hash{"blue"} eq "XYZXYZ" ;
ok 176, $hash{"new"} eq "KLMTU" ;
}
{
# transaction
my $lex = new LexFile $Dfile ;
my %hash ;
my $value ;
my $home = "./fred" ;
ok 177, my $lexD = new LexDir($home) ;
ok 178, my $env = new BerkeleyDB::Env -Home => $home, @StdErrFile,
-Flags => DB_CREATE|DB_INIT_TXN|
DB_INIT_MPOOL|DB_INIT_LOCK ;
ok 179, my $txn = $env->txn_begin() ;
ok 180, my $db1 = tie %hash, 'BerkeleyDB::Btree', -Filename => $Dfile,
-Flags => DB_CREATE ,
-Env => $env,
-Txn => $txn ;
ok 181, (my $Z = $txn->txn_commit()) == 0 ;
ok 182, $txn = $env->txn_begin() ;
$db1->Txn($txn);
# create some data
my %data = (
"red" => "boat",
"green" => "house",
"blue" => "sea",
) ;
my $ret = 0 ;
while (my ($k, $v) = each %data) {
$ret += $db1->db_put($k, $v) ;
}
ok 183, $ret == 0 ;
# should be able to see all the records
ok 184, my $cursor = $db1->db_cursor() ;
my ($k, $v) = ("", "") ;
my $count = 0 ;
# sequence forwards
while ($cursor->c_get($k, $v, DB_NEXT) == 0) {
++ $count ;
}
ok 185, $count == 3 ;
undef $cursor ;
# now abort the transaction
#ok 151, $txn->txn_abort() == 0 ;
ok 186, ($Z = $txn->txn_abort()) == 0 ;
# there shouldn't be any records in the database
$count = 0 ;
# sequence forwards
ok 187, $cursor = $db1->db_cursor() ;
while ($cursor->c_get($k, $v, DB_NEXT) == 0) {
++ $count ;
}
ok 188, $count == 0 ;
undef $txn ;
undef $cursor ;
undef $db1 ;
undef $env ;
untie %hash ;
}
{
# DB_DUP
my $lex = new LexFile $Dfile ;
my %hash ;
ok 189, my $db = tie %hash, 'BerkeleyDB::Btree', -Filename => $Dfile,
-Property => DB_DUP,
-Flags => DB_CREATE ;
$hash{'Wall'} = 'Larry' ;
$hash{'Wall'} = 'Stone' ;
$hash{'Smith'} = 'John' ;
$hash{'Wall'} = 'Brick' ;
$hash{'Wall'} = 'Brick' ;
$hash{'mouse'} = 'mickey' ;
ok 190, keys %hash == 6 ;
# create a cursor
ok 191, my $cursor = $db->db_cursor() ;
my $key = "Wall" ;
my $value ;
ok 192, $cursor->c_get($key, $value, DB_SET) == 0 ;
ok 193, $key eq "Wall" && $value eq "Larry" ;
ok 194, $cursor->c_get($key, $value, DB_NEXT) == 0 ;
ok 195, $key eq "Wall" && $value eq "Stone" ;
ok 196, $cursor->c_get($key, $value, DB_NEXT) == 0 ;
ok 197, $key eq "Wall" && $value eq "Brick" ;
ok 198, $cursor->c_get($key, $value, DB_NEXT) == 0 ;
ok 199, $key eq "Wall" && $value eq "Brick" ;
#my $ref = $db->db_stat() ;
#ok 200, ($ref->{bt_flags} | DB_DUP) == DB_DUP ;
#print "bt_flags " . $ref->{bt_flags} . " DB_DUP " . DB_DUP ."\n";
undef $db ;
undef $cursor ;
untie %hash ;
}
{
# db_stat
my $lex = new LexFile $Dfile ;
my $recs = ($BerkeleyDB::db_version >= 3.1 ? "bt_ndata" : "bt_nrecs") ;
my %hash ;
my ($k, $v) ;
ok 200, my $db = new BerkeleyDB::Btree -Filename => $Dfile,
-Flags => DB_CREATE,
-Minkey =>3 ,
-Pagesize => 2 **12
;
my $ref = $db->db_stat() ;
ok 201, $ref->{$recs} == 0;
ok 202, $ref->{'bt_minkey'} == 3;
ok 203, $ref->{'bt_pagesize'} == 2 ** 12;
# create some data
my %data = (
"red" => 2,
"green" => "house",
"blue" => "sea",
) ;
my $ret = 0 ;
while (($k, $v) = each %data) {
$ret += $db->db_put($k, $v) ;
}
ok 204, $ret == 0 ;
$ref = $db->db_stat() ;
ok 205, $ref->{$recs} == 3;
}
{
# sub-class test
package Another ;
use strict ;
open(FILE, ">SubDB.pm") or die "Cannot open SubDB.pm: $!\n" ;
print FILE <<'EOM' ;
package SubDB ;
use strict ;
use vars qw( @ISA @EXPORT) ;
require Exporter ;
use BerkeleyDB;
@ISA=qw(BerkeleyDB BerkeleyDB::Btree );
@EXPORT = @BerkeleyDB::EXPORT ;
sub db_put {
my $self = shift ;
my $key = shift ;
my $value = shift ;
$self->SUPER::db_put($key, $value * 3) ;
}
sub db_get {
my $self = shift ;
$self->SUPER::db_get($_[0], $_[1]) ;
$_[1] -= 2 ;
}
sub A_new_method
{
my $self = shift ;
my $key = shift ;
my $value = $self->FETCH($key) ;
return "[[$value]]" ;
}
1 ;
EOM
close FILE ;
BEGIN { push @INC, '.'; }
eval 'use SubDB ; ';
main::ok 206, $@ eq "" ;
my %h ;
my $X ;
eval '
$X = tie(%h, "SubDB", -Filename => "dbbtree.tmp",
-Flags => DB_CREATE,
-Mode => 0640 );
' ;
main::ok 207, $@ eq "" && $X ;
my $ret = eval '$h{"fred"} = 3 ; return $h{"fred"} ' ;
main::ok 208, $@ eq "" ;
main::ok 209, $ret == 7 ;
my $value = 0;
$ret = eval '$X->db_put("joe", 4) ; $X->db_get("joe", $value) ; return $value' ;
main::ok 210, $@ eq "" ;
main::ok 211, $ret == 10 ;
$ret = eval ' DB_NEXT eq main::DB_NEXT ' ;
main::ok 212, $@ eq "" ;
main::ok 213, $ret == 1 ;
$ret = eval '$X->A_new_method("joe") ' ;
main::ok 214, $@ eq "" ;
main::ok 215, $ret eq "[[10]]" ;
undef $X;
untie %h;
unlink "SubDB.pm", "dbbtree.tmp" ;
}
{
# DB_RECNUM, DB_SET_RECNO & DB_GET_RECNO
my $lex = new LexFile $Dfile ;
my %hash ;
my ($k, $v) = ("", "");
ok 216, my $db = new BerkeleyDB::Btree
-Filename => $Dfile,
-Flags => DB_CREATE,
-Property => DB_RECNUM ;
# create some data
my @data = (
"A zero",
"B one",
"C two",
"D three",
"E four"
) ;
my $ix = 0 ;
my $ret = 0 ;
foreach (@data) {
$ret += $db->db_put($_, $ix) ;
++ $ix ;
}
ok 217, $ret == 0 ;
# db_get & DB_SET_RECNO
$k = 1 ;
ok 218, $db->db_get($k, $v, DB_SET_RECNO) == 0;
ok 219, $k eq "B one" && $v == 1 ;
$k = 3 ;
ok 220, $db->db_get($k, $v, DB_SET_RECNO) == 0;
ok 221, $k eq "D three" && $v == 3 ;
$k = 4 ;
ok 222, $db->db_get($k, $v, DB_SET_RECNO) == 0;
ok 223, $k eq "E four" && $v == 4 ;
$k = 0 ;
ok 224, $db->db_get($k, $v, DB_SET_RECNO) == 0;
ok 225, $k eq "A zero" && $v == 0 ;
# cursor & DB_SET_RECNO
# create the cursor
ok 226, my $cursor = $db->db_cursor() ;
$k = 2 ;
ok 227, $db->db_get($k, $v, DB_SET_RECNO) == 0;
ok 228, $k eq "C two" && $v == 2 ;
$k = 0 ;
ok 229, $cursor->c_get($k, $v, DB_SET_RECNO) == 0;
ok 230, $k eq "A zero" && $v == 0 ;
$k = 3 ;
ok 231, $db->db_get($k, $v, DB_SET_RECNO) == 0;
ok 232, $k eq "D three" && $v == 3 ;
# cursor & DB_GET_RECNO
ok 233, $cursor->c_get($k, $v, DB_FIRST) == 0 ;
ok 234, $k eq "A zero" && $v == 0 ;
ok 235, $cursor->c_get($k, $v, DB_GET_RECNO) == 0;
ok 236, $v == 0 ;
ok 237, $cursor->c_get($k, $v, DB_NEXT) == 0 ;
ok 238, $k eq "B one" && $v == 1 ;
ok 239, $cursor->c_get($k, $v, DB_GET_RECNO) == 0;
ok 240, $v == 1 ;
ok 241, $cursor->c_get($k, $v, DB_LAST) == 0 ;
ok 242, $k eq "E four" && $v == 4 ;
ok 243, $cursor->c_get($k, $v, DB_GET_RECNO) == 0;
ok 244, $v == 4 ;
}

74
perl/BerkeleyDB/t/cds.t Normal file
View File

@@ -0,0 +1,74 @@
#!./perl -w
# Tests for Concurrent Data Store mode
use strict ;
use lib 't' ;
use BerkeleyDB;
use util ;
BEGIN
{
if ($BerkeleyDB::db_version < 2) {
print "1..0 # Skip: this needs Berkeley DB 2.x.x or better\n" ;
exit 0 ;
}
}
print "1..12\n";
my $Dfile = "dbhash.tmp";
unlink $Dfile;
umask(0) ;
{
# Error case -- env not opened in CDS mode
my $lex = new LexFile $Dfile ;
my $home = "./fred" ;
ok 1, my $lexD = new LexDir($home) ;
ok 2, my $env = new BerkeleyDB::Env -Flags => DB_CREATE|DB_INIT_MPOOL,
-Home => $home, @StdErrFile ;
ok 3, my $db = new BerkeleyDB::Btree -Filename => $Dfile,
-Env => $env,
-Flags => DB_CREATE ;
ok 4, ! $env->cds_enabled() ;
ok 5, ! $db->cds_enabled() ;
eval { $db->cds_lock() };
ok 6, $@ =~ /CDS not enabled for this database/;
undef $db;
undef $env ;
}
{
my $lex = new LexFile $Dfile ;
my $home = "./fred" ;
ok 7, my $lexD = new LexDir($home) ;
ok 8, my $env = new BerkeleyDB::Env -Flags => DB_INIT_CDB|DB_CREATE|DB_INIT_MPOOL,
-Home => $home, @StdErrFile ;
ok 9, my $db = new BerkeleyDB::Btree -Filename => $Dfile,
-Env => $env,
-Flags => DB_CREATE ;
ok 10, $env->cds_enabled() ;
ok 11, $db->cds_enabled() ;
my $cds = $db->cds_lock() ;
ok 12, $cds ;
undef $db;
undef $env ;
}

View File

@@ -0,0 +1,87 @@
#!./perl -w
# ID: 1.2, 7/17/97
use strict ;
use lib 't';
use BerkeleyDB;
use util ;
BEGIN
{
if ($BerkeleyDB::db_version < 3) {
print "1..0 # Skip: this needs Berkeley DB 3.x or better\n" ;
exit 0 ;
}
}
print "1..14\n";
my $Dfile = "dbhash.tmp";
umask(0);
{
# set_mutexlocks
my $home = "./fred" ;
ok 1, my $lexD = new LexDir($home) ;
chdir "./fred" ;
ok 2, my $env = new BerkeleyDB::Env -Flags => DB_CREATE, @StdErrFile ;
ok 3, $env->set_mutexlocks(0) == 0 ;
chdir ".." ;
undef $env ;
}
{
# c_dup
my $lex = new LexFile $Dfile ;
my %hash ;
my ($k, $v) ;
ok 4, my $db = new BerkeleyDB::Hash -Filename => $Dfile,
-Flags => DB_CREATE ;
# create some data
my @data = (
"green" => "house",
"red" => 2,
"blue" => "sea",
) ;
my $ret = 0 ;
while (@data)
{
my $k = shift @data ;
my $v = shift @data ;
$ret += $db->db_put($k, $v) ;
}
ok 5, $ret == 0 ;
# create a cursor
ok 6, my $cursor = $db->db_cursor() ;
# point to a specific k/v pair
$k = "green" ;
ok 7, $cursor->c_get($k, $v, DB_SET) == 0 ;
ok 8, $v eq "house" ;
# duplicate the cursor
my $dup_cursor = $cursor->c_dup(DB_POSITION);
ok 9, $dup_cursor ;
# move original cursor off green/house
my $s = $cursor->c_get($k, $v, DB_NEXT) ;
ok 10, $k ne "green" ;
ok 11, $v ne "house" ;
# duplicate cursor should still be on green/house
ok 12, $dup_cursor->c_get($k, $v, DB_CURRENT) == 0;
ok 13, $k eq "green" ;
ok 14, $v eq "house" ;
}

242
perl/BerkeleyDB/t/db-3.1.t Normal file
View File

@@ -0,0 +1,242 @@
#!./perl -w
use strict ;
use lib 't';
use util (1);
use Test::More ;
use BerkeleyDB;
plan(skip_all => "1..0 # Skip: this needs Berkeley DB 3.1.x or better\n")
if $BerkeleyDB::db_version < 3.1 ;
plan(tests => 48) ;
my $Dfile = "dbhash.tmp";
my $Dfile2 = "dbhash2.tmp";
my $Dfile3 = "dbhash3.tmp";
unlink $Dfile;
umask(0) ;
{
title "c_count";
my $lex = new LexFile $Dfile ;
my %hash ;
my $db = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile,
-Property => DB_DUP,
-Flags => DB_CREATE ;
ok $db, " open database ok";
$hash{'Wall'} = 'Larry' ;
$hash{'Wall'} = 'Stone' ;
$hash{'Smith'} = 'John' ;
$hash{'Wall'} = 'Brick' ;
$hash{'Wall'} = 'Brick' ;
$hash{'mouse'} = 'mickey' ;
is keys %hash, 6, " keys == 6" ;
# create a cursor
my $cursor = $db->db_cursor() ;
ok $cursor, " created cursor";
my $key = "Wall" ;
my $value ;
cmp_ok $cursor->c_get($key, $value, DB_SET), '==', 0, " c_get ok" ;
is $key, "Wall", " key is 'Wall'";
is $value, "Larry", " value is 'Larry'"; ;
my $count ;
cmp_ok $cursor->c_count($count), '==', 0, " c_count ok" ;
is $count, 4, " count is 4" ;
$key = "Smith" ;
cmp_ok $cursor->c_get($key, $value, DB_SET), '==', 0, " c_get ok" ;
is $key, "Smith", " key is 'Smith'";
is $value, "John", " value is 'John'"; ;
cmp_ok $cursor->c_count($count), '==', 0, " c_count ok" ;
is $count, 1, " count is 1" ;
undef $db ;
undef $cursor ;
untie %hash ;
}
{
title "db_key_range";
my $lex = new LexFile $Dfile ;
my %hash ;
my $db = tie %hash, 'BerkeleyDB::Btree', -Filename => $Dfile,
-Property => DB_DUP,
-Flags => DB_CREATE ;
isa_ok $db, 'BerkeleyDB::Btree', " create database ok";
$hash{'Wall'} = 'Larry' ;
$hash{'Wall'} = 'Stone' ;
$hash{'Smith'} = 'John' ;
$hash{'Wall'} = 'Brick' ;
$hash{'Wall'} = 'Brick' ;
$hash{'mouse'} = 'mickey' ;
is keys %hash, 6, " 6 keys" ;
my $key = "Wall" ;
my ($less, $equal, $greater) ;
cmp_ok $db->db_key_range($key, $less, $equal, $greater), '==', 0, " db_key_range ok" ;
cmp_ok $less, '!=', 0 ;
cmp_ok $equal, '!=', 0 ;
cmp_ok $greater, '!=', 0 ;
$key = "Smith" ;
cmp_ok $db->db_key_range($key, $less, $equal, $greater), '==', 0, " db_key_range ok" ;
cmp_ok $less, '==', 0 ;
cmp_ok $equal, '!=', 0 ;
cmp_ok $greater, '!=', 0 ;
$key = "NotThere" ;
cmp_ok $db->db_key_range($key, $less, $equal, $greater), '==', 0, " db_key_range ok" ;
cmp_ok $less, '==', 0 ;
cmp_ok $equal, '==', 0 ;
cmp_ok $greater, '==', 1 ;
undef $db ;
untie %hash ;
}
{
title "rename a subdb";
my $lex = new LexFile $Dfile ;
my $db1 = new BerkeleyDB::Hash -Filename => $Dfile,
-Subname => "fred" ,
-Flags => DB_CREATE ;
isa_ok $db1, 'BerkeleyDB::Hash', " create database ok";
my $db2 = new BerkeleyDB::Btree -Filename => $Dfile,
-Subname => "joe" ,
-Flags => DB_CREATE ;
isa_ok $db2, 'BerkeleyDB::Btree', " create database ok";
# Add a k/v pair
my %data = qw(
red sky
blue sea
black heart
yellow belley
green grass
) ;
ok addData($db1, %data), " added to db1 ok" ;
ok addData($db2, %data), " added to db2 ok" ;
undef $db1 ;
undef $db2 ;
# now rename
cmp_ok BerkeleyDB::db_rename(-Filename => $Dfile,
-Subname => "fred",
-Newname => "harry"), '==', 0, " rename ok";
my $db3 = new BerkeleyDB::Hash -Filename => $Dfile,
-Subname => "harry" ;
isa_ok $db3, 'BerkeleyDB::Hash', " verify rename";
}
{
title "rename a file";
my $lex = new LexFile $Dfile, $Dfile2 ;
my $db1 = new BerkeleyDB::Hash -Filename => $Dfile,
-Subname => "fred" ,
-Flags => DB_CREATE;
isa_ok $db1, 'BerkeleyDB::Hash', " create database ok";
my $db2 = new BerkeleyDB::Hash -Filename => $Dfile,
-Subname => "joe" ,
-Flags => DB_CREATE ;
isa_ok $db2, 'BerkeleyDB::Hash', " create database ok";
# Add a k/v pair
my %data = qw(
red sky
blue sea
black heart
yellow belley
green grass
) ;
ok addData($db1, %data), " add data to db1" ;
ok addData($db2, %data), " add data to db2" ;
undef $db1 ;
undef $db2 ;
# now rename
cmp_ok BerkeleyDB::db_rename(-Filename => $Dfile, -Newname => $Dfile2),
'==', 0, " rename file to $Dfile2 ok";
my $db3 = new BerkeleyDB::Hash -Filename => $Dfile2,
-Subname => "fred" ;
isa_ok $db3, 'BerkeleyDB::Hash', " verify rename"
or diag "$! $BerkeleyDB::Error";
# TODO add rename with no subname & txn
}
{
title "verify";
my $lex = new LexFile $Dfile, $Dfile2 ;
my $db1 = new BerkeleyDB::Hash -Filename => $Dfile,
-Subname => "fred" ,
-Flags => DB_CREATE ;
isa_ok $db1, 'BerkeleyDB::Hash', " create database ok";
# Add a k/v pair
my %data = qw(
red sky
blue sea
black heart
yellow belley
green grass
) ;
ok addData($db1, %data), " added data ok" ;
undef $db1 ;
# now verify
cmp_ok BerkeleyDB::db_verify(-Filename => $Dfile,
-Subname => "fred",
), '==', 0, " verify ok";
# now verify & dump
cmp_ok BerkeleyDB::db_verify(-Filename => $Dfile,
-Subname => "fred",
-Outfile => $Dfile2,
), '==', 0, " verify and dump ok";
}
# db_remove with env

View File

@@ -0,0 +1,59 @@
#!./perl -w
# ID: %I%, %G%
use strict ;
use lib 't' ;
use BerkeleyDB;
use util ;
BEGIN
{
if ($BerkeleyDB::db_version < 3.2) {
print "1..0 # Skip: this needs Berkeley DB 3.2.x or better\n" ;
exit 0 ;
}
}
print "1..6\n";
my $Dfile = "dbhash.tmp";
my $Dfile2 = "dbhash2.tmp";
my $Dfile3 = "dbhash3.tmp";
unlink $Dfile;
umask(0) ;
{
# set_q_extentsize
ok 1, 1 ;
}
{
# env->set_flags
my $home = "./fred" ;
ok 2, my $lexD = new LexDir($home) ;
ok 3, my $env = new BerkeleyDB::Env -Home => $home, @StdErrFile,
-Flags => DB_CREATE ,
-SetFlags => DB_NOMMAP ;
undef $env ;
}
{
# env->set_flags
my $home = "./fred" ;
ok 4, my $lexD = new LexDir($home) ;
ok 5, my $env = new BerkeleyDB::Env -Home => $home, @StdErrFile,
-Flags => DB_CREATE ;
ok 6, ! $env->set_flags(DB_NOMMAP, 1);
undef $env ;
}

476
perl/BerkeleyDB/t/db-3.3.t Normal file
View File

@@ -0,0 +1,476 @@
#!./perl -w
use strict ;
use lib 't' ;
use BerkeleyDB;
use util ;
BEGIN
{
if ($BerkeleyDB::db_version < 3.3) {
print "1..0 # Skip: this needs Berkeley DB 3.3.x or better\n" ;
exit 0 ;
}
}
umask(0);
print "1..130\n";
{
# db->truncate
my $Dfile;
my $lex = new LexFile $Dfile ;
my %hash ;
my ($k, $v) ;
ok 1, my $db = new BerkeleyDB::Hash -Filename => $Dfile,
-Flags => DB_CREATE ;
# create some data
my %data = (
"red" => 2,
"green" => "house",
"blue" => "sea",
) ;
my $ret = 0 ;
while (($k, $v) = each %data) {
$ret += $db->db_put($k, $v) ;
}
ok 2, $ret == 0 ;
# check there are three records
ok 3, countRecords($db) == 3 ;
# now truncate the database
my $count = 0;
ok 4, $db->truncate($count) == 0 ;
ok 5, $count == 3 ;
ok 6, countRecords($db) == 0 ;
}
{
# db->associate -- secondary keys
sub sec_key
{
#print "in sec_key\n";
my $pkey = shift ;
my $pdata = shift ;
$_[0] = $pdata ;
return 0;
}
my ($Dfile1, $Dfile2);
my $lex = new LexFile $Dfile1, $Dfile2 ;
my %hash ;
my $status;
my ($k, $v, $pk) = ('','','');
# create primary database
ok 7, my $primary = new BerkeleyDB::Hash -Filename => $Dfile1,
-Flags => DB_CREATE ;
# create secondary database
ok 8, my $secondary = new BerkeleyDB::Hash -Filename => $Dfile2,
-Flags => DB_CREATE ;
# associate primary with secondary
ok 9, $primary->associate($secondary, \&sec_key) == 0;
# add data to the primary
my %data = (
"red" => "flag",
"green" => "house",
"blue" => "sea",
) ;
my $ret = 0 ;
while (($k, $v) = each %data) {
my $r = $primary->db_put($k, $v) ;
#print "put $r $BerkeleyDB::Error\n";
$ret += $r;
}
ok 10, $ret == 0 ;
# check the records in the secondary
ok 11, countRecords($secondary) == 3 ;
ok 12, $secondary->db_get("house", $v) == 0;
ok 13, $v eq "house";
ok 14, $secondary->db_get("sea", $v) == 0;
ok 15, $v eq "sea";
ok 16, $secondary->db_get("flag", $v) == 0;
ok 17, $v eq "flag";
# pget to primary database is illegal
ok 18, $primary->db_pget('red', $pk, $v) != 0 ;
# pget to secondary database is ok
ok 19, $secondary->db_pget('house', $pk, $v) == 0 ;
ok 20, $pk eq 'green';
ok 21, $v eq 'house';
ok 22, my $p_cursor = $primary->db_cursor();
ok 23, my $s_cursor = $secondary->db_cursor();
# c_get from primary
$k = 'green';
ok 24, $p_cursor->c_get($k, $v, DB_SET) == 0;
ok 25, $k eq 'green';
ok 26, $v eq 'house';
# c_get from secondary
$k = 'sea';
ok 27, $s_cursor->c_get($k, $v, DB_SET) == 0;
ok 28, $k eq 'sea';
ok 29, $v eq 'sea';
# c_pget from primary database should fail
$k = 1;
ok 30, $p_cursor->c_pget($k, $pk, $v, DB_FIRST) != 0;
# c_pget from secondary database
$k = 'flag';
ok 31, $s_cursor->c_pget($k, $pk, $v, DB_SET) == 0;
ok 32, $k eq 'flag';
ok 33, $pk eq 'red';
ok 34, $v eq 'flag';
# check put to secondary is illegal
ok 35, $secondary->db_put("tom", "dick") != 0;
ok 36, countRecords($secondary) == 3 ;
# delete from primary
ok 37, $primary->db_del("green") == 0 ;
ok 38, countRecords($primary) == 2 ;
# check has been deleted in secondary
ok 39, $secondary->db_get("house", $v) != 0;
ok 40, countRecords($secondary) == 2 ;
# delete from secondary
ok 41, $secondary->db_del('flag') == 0 ;
ok 42, countRecords($secondary) == 1 ;
# check deleted from primary
ok 43, $primary->db_get("red", $v) != 0;
ok 44, countRecords($primary) == 1 ;
}
# db->associate -- multiple secondary keys
# db->associate -- same again but when DB_DUP is specified.
{
# db->associate -- secondary keys, each with a user defined sort
sub sec_key2
{
my $pkey = shift ;
my $pdata = shift ;
#print "in sec_key2 [$pkey][$pdata]\n";
$_[0] = length $pdata ;
return 0;
}
my ($Dfile1, $Dfile2);
my $lex = new LexFile $Dfile1, $Dfile2 ;
my %hash ;
my $status;
my ($k, $v, $pk) = ('','','');
# create primary database
ok 45, my $primary = new BerkeleyDB::Btree -Filename => $Dfile1,
-Compare => sub { return $_[0] cmp $_[1]},
-Flags => DB_CREATE ;
# create secondary database
ok 46, my $secondary = new BerkeleyDB::Btree -Filename => $Dfile2,
-Compare => sub { return $_[0] <=> $_[1]},
-Property => DB_DUP,
-Flags => DB_CREATE ;
# associate primary with secondary
ok 47, $primary->associate($secondary, \&sec_key2) == 0;
# add data to the primary
my %data = (
"red" => "flag",
"orange"=> "custard",
"green" => "house",
"blue" => "sea",
) ;
my $ret = 0 ;
while (($k, $v) = each %data) {
my $r = $primary->db_put($k, $v) ;
#print "put [$r] $BerkeleyDB::Error\n";
$ret += $r;
}
ok 48, $ret == 0 ;
#print "ret $ret\n";
#print "Primary\n" ; dumpdb($primary) ;
#print "Secondary\n" ; dumpdb($secondary) ;
# check the records in the secondary
ok 49, countRecords($secondary) == 4 ;
my $p_data = joinkeys($primary, " ");
#print "primary [$p_data]\n" ;
ok 50, $p_data eq join " ", sort { $a cmp $b } keys %data ;
my $s_data = joinkeys($secondary, " ");
#print "secondary [$s_data]\n" ;
ok 51, $s_data eq join " ", sort { $a <=> $b } map { length } values %data ;
}
{
# db->associate -- primary recno, secondary hash
sub sec_key3
{
#print "in sec_key\n";
my $pkey = shift ;
my $pdata = shift ;
$_[0] = $pdata ;
return 0;
}
my ($Dfile1, $Dfile2);
my $lex = new LexFile $Dfile1, $Dfile2 ;
my %hash ;
my $status;
my ($k, $v, $pk) = ('','','');
# create primary database
ok 52, my $primary = new BerkeleyDB::Recno -Filename => $Dfile1,
-Flags => DB_CREATE ;
# create secondary database
ok 53, my $secondary = new BerkeleyDB::Hash -Filename => $Dfile2,
-Flags => DB_CREATE ;
# associate primary with secondary
ok 54, $primary->associate($secondary, \&sec_key3) == 0;
# add data to the primary
my %data = (
0 => "flag",
1 => "house",
2 => "sea",
) ;
my $ret = 0 ;
while (($k, $v) = each %data) {
my $r = $primary->db_put($k, $v) ;
#print "put $r $BerkeleyDB::Error\n";
$ret += $r;
}
ok 55, $ret == 0 ;
# check the records in the secondary
ok 56, countRecords($secondary) == 3 ;
ok 57, $secondary->db_get("flag", $v) == 0;
ok 58, $v eq "flag";
ok 59, $secondary->db_get("house", $v) == 0;
ok 60, $v eq "house";
ok 61, $secondary->db_get("sea", $v) == 0;
ok 62, $v eq "sea" ;
# pget to primary database is illegal
ok 63, $primary->db_pget(0, $pk, $v) != 0 ;
# pget to secondary database is ok
ok 64, $secondary->db_pget('house', $pk, $v) == 0 ;
ok 65, $pk == 1 ;
ok 66, $v eq 'house';
ok 67, my $p_cursor = $primary->db_cursor();
ok 68, my $s_cursor = $secondary->db_cursor();
# c_get from primary
$k = 1;
ok 69, $p_cursor->c_get($k, $v, DB_SET) == 0;
ok 70, $k == 1;
ok 71, $v eq 'house';
# c_get from secondary
$k = 'sea';
ok 72, $s_cursor->c_get($k, $v, DB_SET) == 0;
ok 73, $k eq 'sea'
or warn "# key [$k]\n";
ok 74, $v eq 'sea';
# c_pget from primary database should fail
$k = 1;
ok 75, $p_cursor->c_pget($k, $pk, $v, DB_FIRST) != 0;
# c_pget from secondary database
$k = 'sea';
ok 76, $s_cursor->c_pget($k, $pk, $v, DB_SET) == 0;
ok 77, $k eq 'sea' ;
ok 78, $pk == 2 ;
ok 79, $v eq 'sea';
# check put to secondary is illegal
ok 80, $secondary->db_put("tom", "dick") != 0;
ok 81, countRecords($secondary) == 3 ;
# delete from primary
ok 82, $primary->db_del(2) == 0 ;
ok 83, countRecords($primary) == 2 ;
# check has been deleted in secondary
ok 84, $secondary->db_get("sea", $v) != 0;
ok 85, countRecords($secondary) == 2 ;
# delete from secondary
ok 86, $secondary->db_del('flag') == 0 ;
ok 87, countRecords($secondary) == 1 ;
# check deleted from primary
ok 88, $primary->db_get(0, $v) != 0;
ok 89, countRecords($primary) == 1 ;
}
{
# db->associate -- primary hash, secondary recno
sub sec_key4
{
#print "in sec_key4\n";
my $pkey = shift ;
my $pdata = shift ;
$_[0] = length $pdata ;
return 0;
}
my ($Dfile1, $Dfile2);
my $lex = new LexFile $Dfile1, $Dfile2 ;
my %hash ;
my $status;
my ($k, $v, $pk) = ('','','');
# create primary database
ok 90, my $primary = new BerkeleyDB::Hash -Filename => $Dfile1,
-Flags => DB_CREATE ;
# create secondary database
ok 91, my $secondary = new BerkeleyDB::Recno -Filename => $Dfile2,
#-Property => DB_DUP,
-Flags => DB_CREATE ;
# associate primary with secondary
ok 92, $primary->associate($secondary, \&sec_key4) == 0;
# add data to the primary
my %data = (
"red" => "flag",
"green" => "house",
"blue" => "sea",
) ;
my $ret = 0 ;
while (($k, $v) = each %data) {
my $r = $primary->db_put($k, $v) ;
#print "put $r $BerkeleyDB::Error\n";
$ret += $r;
}
ok 93, $ret == 0 ;
# check the records in the secondary
ok 94, countRecords($secondary) == 3 ;
ok 95, $secondary->db_get(0, $v) != 0;
ok 96, $secondary->db_get(1, $v) != 0;
ok 97, $secondary->db_get(2, $v) != 0;
ok 98, $secondary->db_get(3, $v) == 0;
ok 99, $v eq "sea";
ok 100, $secondary->db_get(4, $v) == 0;
ok 101, $v eq "flag";
ok 102, $secondary->db_get(5, $v) == 0;
ok 103, $v eq "house";
# pget to primary database is illegal
ok 104, $primary->db_pget(0, $pk, $v) != 0 ;
# pget to secondary database is ok
ok 105, $secondary->db_pget(4, $pk, $v) == 0 ;
ok 106, $pk eq 'red'
or warn "# $pk\n";;
ok 107, $v eq 'flag';
ok 108, my $p_cursor = $primary->db_cursor();
ok 109, my $s_cursor = $secondary->db_cursor();
# c_get from primary
$k = 'green';
ok 110, $p_cursor->c_get($k, $v, DB_SET) == 0;
ok 111, $k eq 'green';
ok 112, $v eq 'house';
# c_get from secondary
$k = 3;
ok 113, $s_cursor->c_get($k, $v, DB_SET) == 0;
ok 114, $k == 3 ;
ok 115, $v eq 'sea';
# c_pget from primary database should fail
$k = 1;
ok 116, $p_cursor->c_pget($k, $pk, $v, DB_SET) != 0;
# c_pget from secondary database
$k = 5;
ok 117, $s_cursor->c_pget($k, $pk, $v, DB_SET) == 0;
ok 118, $k == 5 ;
ok 119, $pk eq 'green';
ok 120, $v eq 'house';
# check put to secondary is illegal
ok 121, $secondary->db_put(77, "dick") != 0;
ok 122, countRecords($secondary) == 3 ;
# delete from primary
ok 123, $primary->db_del("green") == 0 ;
ok 124, countRecords($primary) == 2 ;
# check has been deleted in secondary
ok 125, $secondary->db_get(5, $v) != 0;
ok 126, countRecords($secondary) == 2 ;
# delete from secondary
ok 127, $secondary->db_del(4) == 0 ;
ok 128, countRecords($secondary) == 1 ;
# check deleted from primary
ok 129, $primary->db_get("red", $v) != 0;
ok 130, countRecords($primary) == 1 ;
}

View File

@@ -0,0 +1,57 @@
#!./perl -w
use strict ;
use lib 't' ;
use BerkeleyDB;
use Test::More ;
use util (1);
plan(skip_all => "this needs Berkeley DB 4.4.x or better\n" )
if $BerkeleyDB::db_version < 4.4;
plan tests => 5;
{
title "Testing compact";
# db->db_compact
my $Dfile;
my $lex = new LexFile $Dfile ;
my ($k, $v) ;
ok my $db = new BerkeleyDB::Btree -Filename => $Dfile,
-Flags => DB_CREATE ;
# create some data
my %data = (
"red" => 2,
"green" => "house",
"blue" => "sea",
) ;
my $ret = 0 ;
while (($k, $v) = each %data) {
$ret += $db->db_put($k, $v) ;
}
ok $ret == 0, " Created some data" ;
my $key;
my $end;
my %hash;
$hash{compact_filepercent} = 20;
ok $db->compact("red", "green", \%hash, 0, $end) == 0, " Compacted ok";
if (0)
{
diag "end at $end";
for my $key (sort keys %hash)
{
diag "[$key][$hash{$key}]\n";
}
}
ok $db->compact() == 0, " Compacted ok";
}

View File

@@ -0,0 +1,56 @@
#!./perl -w
use strict ;
use lib 't';
use BerkeleyDB;
use Test::More;
use util (1);
plan(skip_all => "this needs Berkeley DB 4.x.x or better\n" )
if $BerkeleyDB::db_version < 4;
plan tests => 9;
my $Dfile = "dbhash.tmp";
unlink $Dfile;
umask(0) ;
my $db = BerkeleyDB::Btree->new(
-Filename => $Dfile,
-Flags => DB_CREATE,
-Property => DB_DUP | DB_DUPSORT
) || die "Cannot open file $Dfile: $! $BerkeleyDB::Error\n" ;
my $cursor = $db->db_cursor();
my @pairs = qw(
Alabama/Athens
Alabama/Florence
Alaska/Anchorage
Alaska/Fairbanks
Arizona/Avondale
Arizona/Florence
);
for (@pairs) {
$db->db_put(split '/');
}
my @tests = (
["Alaska", "Fa", "Alaska", "Fairbanks"],
["Arizona", "Fl", "Arizona", "Florence"],
["Alaska", "An", "Alaska", "Anchorage"],
);
#my $i;
while (my $test = shift @tests) {
my ($k1, $v1, $k2, $v2) = @$test;
ok $cursor->c_get($k1, $v1, DB_GET_BOTH_RANGE) == 0;
is $k1, $k2;
is $v1, $v2;
}
undef $db;
unlink $Dfile;

View File

@@ -0,0 +1,99 @@
#!./perl -w
use strict ;
use lib 't' ;
use BerkeleyDB;
use util ;
print "1..15\n";
my $Dfile = "dbhash.tmp";
my $home = "./fred" ;
umask(0);
{
# let object destruction kill everything
my $lex = new LexFile $Dfile ;
my %hash ;
my $value ;
ok 1, my $lexD = new LexDir($home) ;
ok 2, my $env = new BerkeleyDB::Env -Home => $home, @StdErrFile,
-Flags => DB_CREATE|DB_INIT_TXN|
DB_INIT_MPOOL|DB_INIT_LOCK ;
ok 3, my $txn = $env->txn_begin() ;
ok 4, my $db1 = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile,
-Flags => DB_CREATE ,
-Env => $env,
-Txn => $txn ;
ok 5, $txn->txn_commit() == 0 ;
ok 6, $txn = $env->txn_begin() ;
$db1->Txn($txn);
# create some data
my %data = (
"red" => "boat",
"green" => "house",
"blue" => "sea",
) ;
my $ret = 0 ;
while (my ($k, $v) = each %data) {
$ret += $db1->db_put($k, $v) ;
}
ok 7, $ret == 0 ;
# should be able to see all the records
ok 8, my $cursor = $db1->db_cursor() ;
my ($k, $v) = ("", "") ;
my $count = 0 ;
# sequence forwards
while ($cursor->c_get($k, $v, DB_NEXT) == 0) {
++ $count ;
}
ok 9, $count == 3 ;
undef $cursor ;
# now abort the transaction
ok 10, $txn->txn_abort() == 0 ;
# there shouldn't be any records in the database
$count = 0 ;
# sequence forwards
ok 11, $cursor = $db1->db_cursor() ;
while ($cursor->c_get($k, $v, DB_NEXT) == 0) {
++ $count ;
}
ok 12, $count == 0 ;
#undef $txn ;
#undef $cursor ;
#undef $db1 ;
#undef $env ;
#untie %hash ;
}
{
my $lex = new LexFile $Dfile ;
my %hash ;
my $cursor ;
my ($k, $v) = ("", "") ;
ok 13, my $db1 = tie %hash, 'BerkeleyDB::Hash',
-Filename => $Dfile,
-Flags => DB_CREATE ;
my $count = 0 ;
# sequence forwards
ok 14, $cursor = $db1->db_cursor() ;
while ($cursor->c_get($k, $v, DB_NEXT) == 0) {
++ $count ;
}
ok 15, $count == 0 ;
}

640
perl/BerkeleyDB/t/encrypt.t Normal file
View File

@@ -0,0 +1,640 @@
#!./perl -w
# ID: %I%, %G%
use strict ;
use lib 't' ;
use BerkeleyDB;
use util ;
BEGIN
{
if ($BerkeleyDB::db_version < 4.1) {
print "1..0 # Skip: this needs Berkeley DB 4.1.x or better\n" ;
exit 0 ;
}
# Is encryption available?
my $env = new BerkeleyDB::Env @StdErrFile,
-Encrypt => {Password => "abc",
Flags => DB_ENCRYPT_AES
};
if ($BerkeleyDB::Error =~ /Operation not supported/)
{
print "1..0 # Skip: encryption support not present\n" ;
exit 0 ;
}
}
umask(0);
print "1..80\n";
{
eval
{
my $env = new BerkeleyDB::Env @StdErrFile,
-Encrypt => 1,
-Flags => DB_CREATE ;
};
ok 1, $@ =~ /^Encrypt parameter must be a hash reference at/;
eval
{
my $env = new BerkeleyDB::Env @StdErrFile,
-Encrypt => {},
-Flags => DB_CREATE ;
};
ok 2, $@ =~ /^Must specify Password and Flags with Encrypt parameter at/;
eval
{
my $env = new BerkeleyDB::Env @StdErrFile,
-Encrypt => {Password => "fred"},
-Flags => DB_CREATE ;
};
ok 3, $@ =~ /^Must specify Password and Flags with Encrypt parameter at/;
eval
{
my $env = new BerkeleyDB::Env @StdErrFile,
-Encrypt => {Flags => 1},
-Flags => DB_CREATE ;
};
ok 4, $@ =~ /^Must specify Password and Flags with Encrypt parameter at/;
eval
{
my $env = new BerkeleyDB::Env @StdErrFile,
-Encrypt => {Fred => 1},
-Flags => DB_CREATE ;
};
ok 5, $@ =~ /^\Qunknown key value(s) Fred at/;
}
{
# new BerkeleyDB::Env -Encrypt =>
# create an environment with a Home
my $home = "./fred" ;
#mkdir $home;
ok 6, my $lexD = new LexDir($home) ;
ok 7, my $env = new BerkeleyDB::Env @StdErrFile,
-Home => $home,
-Encrypt => {Password => "abc",
Flags => DB_ENCRYPT_AES
},
-Flags => DB_CREATE | DB_INIT_MPOOL ;
my $Dfile = "abc.enc";
my $lex = new LexFile $Dfile ;
my %hash ;
my ($k, $v) ;
ok 8, my $db = new BerkeleyDB::Hash -Filename => $Dfile,
-Env => $env,
-Flags => DB_CREATE,
-Property => DB_ENCRYPT ;
# create some data
my %data = (
"red" => 2,
"green" => "house",
"blue" => "sea",
) ;
my $ret = 0 ;
while (($k, $v) = each %data) {
$ret += $db->db_put($k, $v) ;
}
ok 9, $ret == 0 ;
# check there are three records
ok 10, countRecords($db) == 3 ;
undef $db;
# once the database is created, do not need to specify DB_ENCRYPT
ok 11, my $db1 = new BerkeleyDB::Hash -Filename => $Dfile,
-Env => $env,
-Flags => DB_CREATE ;
$v = '';
ok 12, ! $db1->db_get("red", $v) ;
ok 13, $v eq $data{"red"},
undef $db1;
undef $env;
# open a database without specifying encryption
ok 14, ! new BerkeleyDB::Hash -Filename => "$home/$Dfile";
ok 15, ! new BerkeleyDB::Env
-Home => $home,
-Encrypt => {Password => "def",
Flags => DB_ENCRYPT_AES
},
-Flags => DB_CREATE | DB_INIT_MPOOL ;
}
{
eval
{
my $env = new BerkeleyDB::Hash
-Encrypt => 1,
-Flags => DB_CREATE ;
};
ok 16, $@ =~ /^Encrypt parameter must be a hash reference at/;
eval
{
my $env = new BerkeleyDB::Hash
-Encrypt => {},
-Flags => DB_CREATE ;
};
ok 17, $@ =~ /^Must specify Password and Flags with Encrypt parameter at/;
eval
{
my $env = new BerkeleyDB::Hash
-Encrypt => {Password => "fred"},
-Flags => DB_CREATE ;
};
ok 18, $@ =~ /^Must specify Password and Flags with Encrypt parameter at/;
eval
{
my $env = new BerkeleyDB::Hash
-Encrypt => {Flags => 1},
-Flags => DB_CREATE ;
};
ok 19, $@ =~ /^Must specify Password and Flags with Encrypt parameter at/;
eval
{
my $env = new BerkeleyDB::Hash
-Encrypt => {Fred => 1},
-Flags => DB_CREATE ;
};
ok 20, $@ =~ /^\Qunknown key value(s) Fred at/;
}
{
eval
{
my $env = new BerkeleyDB::Btree
-Encrypt => 1,
-Flags => DB_CREATE ;
};
ok 21, $@ =~ /^Encrypt parameter must be a hash reference at/;
eval
{
my $env = new BerkeleyDB::Btree
-Encrypt => {},
-Flags => DB_CREATE ;
};
ok 22, $@ =~ /^Must specify Password and Flags with Encrypt parameter at/;
eval
{
my $env = new BerkeleyDB::Btree
-Encrypt => {Password => "fred"},
-Flags => DB_CREATE ;
};
ok 23, $@ =~ /^Must specify Password and Flags with Encrypt parameter at/;
eval
{
my $env = new BerkeleyDB::Btree
-Encrypt => {Flags => 1},
-Flags => DB_CREATE ;
};
ok 24, $@ =~ /^Must specify Password and Flags with Encrypt parameter at/;
eval
{
my $env = new BerkeleyDB::Btree
-Encrypt => {Fred => 1},
-Flags => DB_CREATE ;
};
ok 25, $@ =~ /^\Qunknown key value(s) Fred at/;
}
{
eval
{
my $env = new BerkeleyDB::Queue
-Encrypt => 1,
-Flags => DB_CREATE ;
};
ok 26, $@ =~ /^Encrypt parameter must be a hash reference at/;
eval
{
my $env = new BerkeleyDB::Queue
-Encrypt => {},
-Flags => DB_CREATE ;
};
ok 27, $@ =~ /^Must specify Password and Flags with Encrypt parameter at/;
eval
{
my $env = new BerkeleyDB::Queue
-Encrypt => {Password => "fred"},
-Flags => DB_CREATE ;
};
ok 28, $@ =~ /^Must specify Password and Flags with Encrypt parameter at/;
eval
{
my $env = new BerkeleyDB::Queue
-Encrypt => {Flags => 1},
-Flags => DB_CREATE ;
};
ok 29, $@ =~ /^Must specify Password and Flags with Encrypt parameter at/;
eval
{
my $env = new BerkeleyDB::Queue
-Encrypt => {Fred => 1},
-Flags => DB_CREATE ;
};
ok 30, $@ =~ /^\Qunknown key value(s) Fred at/;
}
{
eval
{
my $env = new BerkeleyDB::Recno
-Encrypt => 1,
-Flags => DB_CREATE ;
};
ok 31, $@ =~ /^Encrypt parameter must be a hash reference at/;
eval
{
my $env = new BerkeleyDB::Recno
-Encrypt => {},
-Flags => DB_CREATE ;
};
ok 32, $@ =~ /^Must specify Password and Flags with Encrypt parameter at/;
eval
{
my $env = new BerkeleyDB::Recno
-Encrypt => {Password => "fred"},
-Flags => DB_CREATE ;
};
ok 33, $@ =~ /^Must specify Password and Flags with Encrypt parameter at/;
eval
{
my $env = new BerkeleyDB::Recno
-Encrypt => {Flags => 1},
-Flags => DB_CREATE ;
};
ok 34, $@ =~ /^Must specify Password and Flags with Encrypt parameter at/;
eval
{
my $env = new BerkeleyDB::Recno
-Encrypt => {Fred => 1},
-Flags => DB_CREATE ;
};
ok 35, $@ =~ /^\Qunknown key value(s) Fred at/;
}
{
# new BerkeleyDB::Hash -Encrypt =>
my $Dfile = "abcd.enc";
my $lex = new LexFile $Dfile ;
my %hash ;
my ($k, $v) ;
ok 36, my $db = new BerkeleyDB::Hash
-Filename => $Dfile,
-Flags => DB_CREATE,
-Encrypt => {Password => "beta",
Flags => DB_ENCRYPT_AES
},
-Property => DB_ENCRYPT ;
# create some data
my %data = (
"red" => 2,
"green" => "house",
"blue" => "sea",
) ;
my $ret = 0 ;
while (($k, $v) = each %data) {
$ret += $db->db_put($k, $v) ;
}
ok 37, $ret == 0 ;
# check there are three records
ok 38, countRecords($db) == 3 ;
undef $db;
# attempt to open a database without specifying encryption
ok 39, ! new BerkeleyDB::Hash -Filename => $Dfile,
-Flags => DB_CREATE ;
# try opening with the wrong password
ok 40, ! new BerkeleyDB::Hash -Filename => $Dfile,
-Filename => $Dfile,
-Encrypt => {Password => "def",
Flags => DB_ENCRYPT_AES
},
-Property => DB_ENCRYPT ;
# read the encrypted data
ok 41, my $db1 = new BerkeleyDB::Hash -Filename => $Dfile,
-Filename => $Dfile,
-Encrypt => {Password => "beta",
Flags => DB_ENCRYPT_AES
},
-Property => DB_ENCRYPT ;
$v = '';
ok 42, ! $db1->db_get("red", $v) ;
ok 43, $v eq $data{"red"};
# check there are three records
ok 44, countRecords($db1) == 3 ;
undef $db1;
}
{
# new BerkeleyDB::Btree -Encrypt =>
my $Dfile = "abcd.enc";
my $lex = new LexFile $Dfile ;
my %hash ;
my ($k, $v) ;
ok 45, my $db = new BerkeleyDB::Btree
-Filename => $Dfile,
-Flags => DB_CREATE,
-Encrypt => {Password => "beta",
Flags => DB_ENCRYPT_AES
},
-Property => DB_ENCRYPT ;
# create some data
my %data = (
"red" => 2,
"green" => "house",
"blue" => "sea",
) ;
my $ret = 0 ;
while (($k, $v) = each %data) {
$ret += $db->db_put($k, $v) ;
}
ok 46, $ret == 0 ;
# check there are three records
ok 47, countRecords($db) == 3 ;
undef $db;
# attempt to open a database without specifying encryption
ok 48, ! new BerkeleyDB::Btree -Filename => $Dfile,
-Flags => DB_CREATE ;
# try opening with the wrong password
ok 49, ! new BerkeleyDB::Btree -Filename => $Dfile,
-Filename => $Dfile,
-Encrypt => {Password => "def",
Flags => DB_ENCRYPT_AES
},
-Property => DB_ENCRYPT ;
# read the encrypted data
ok 50, my $db1 = new BerkeleyDB::Btree -Filename => $Dfile,
-Filename => $Dfile,
-Encrypt => {Password => "beta",
Flags => DB_ENCRYPT_AES
},
-Property => DB_ENCRYPT ;
$v = '';
ok 51, ! $db1->db_get("red", $v) ;
ok 52, $v eq $data{"red"};
# check there are three records
ok 53, countRecords($db1) == 3 ;
undef $db1;
}
{
# new BerkeleyDB::Queue -Encrypt =>
my $Dfile = "abcd.enc";
my $lex = new LexFile $Dfile ;
my %hash ;
my ($k, $v) ;
ok 54, my $db = new BerkeleyDB::Queue
-Filename => $Dfile,
-Len => 5,
-Pad => "x",
-Flags => DB_CREATE,
-Encrypt => {Password => "beta",
Flags => DB_ENCRYPT_AES
},
-Property => DB_ENCRYPT ;
# create some data
my %data = (
1 => 2,
2 => "house",
3 => "sea",
) ;
my $ret = 0 ;
while (($k, $v) = each %data) {
$ret += $db->db_put($k, $v) ;
}
ok 55, $ret == 0 ;
# check there are three records
ok 56, countRecords($db) == 3 ;
undef $db;
# attempt to open a database without specifying encryption
ok 57, ! new BerkeleyDB::Queue -Filename => $Dfile,
-Len => 5,
-Pad => "x",
-Flags => DB_CREATE ;
# try opening with the wrong password
ok 58, ! new BerkeleyDB::Queue -Filename => $Dfile,
-Len => 5,
-Pad => "x",
-Encrypt => {Password => "def",
Flags => DB_ENCRYPT_AES
},
-Property => DB_ENCRYPT ;
# read the encrypted data
ok 59, my $db1 = new BerkeleyDB::Queue -Filename => $Dfile,
-Len => 5,
-Pad => "x",
-Encrypt => {Password => "beta",
Flags => DB_ENCRYPT_AES
},
-Property => DB_ENCRYPT ;
$v = '';
ok 60, ! $db1->db_get(3, $v) ;
ok 61, $v eq fillout($data{3}, 5, 'x');
# check there are three records
ok 62, countRecords($db1) == 3 ;
undef $db1;
}
{
# new BerkeleyDB::Recno -Encrypt =>
my $Dfile = "abcd.enc";
my $lex = new LexFile $Dfile ;
my %hash ;
my ($k, $v) ;
ok 63, my $db = new BerkeleyDB::Recno
-Filename => $Dfile,
-Flags => DB_CREATE,
-Encrypt => {Password => "beta",
Flags => DB_ENCRYPT_AES
},
-Property => DB_ENCRYPT ;
# create some data
my %data = (
1 => 2,
2 => "house",
3 => "sea",
) ;
my $ret = 0 ;
while (($k, $v) = each %data) {
$ret += $db->db_put($k, $v) ;
}
ok 64, $ret == 0 ;
# check there are three records
ok 65, countRecords($db) == 3 ;
undef $db;
# attempt to open a database without specifying encryption
ok 66, ! new BerkeleyDB::Recno -Filename => $Dfile,
-Flags => DB_CREATE ;
# try opening with the wrong password
ok 67, ! new BerkeleyDB::Recno -Filename => $Dfile,
-Filename => $Dfile,
-Encrypt => {Password => "def",
Flags => DB_ENCRYPT_AES
},
-Property => DB_ENCRYPT ;
# read the encrypted data
ok 68, my $db1 = new BerkeleyDB::Recno -Filename => $Dfile,
-Filename => $Dfile,
-Encrypt => {Password => "beta",
Flags => DB_ENCRYPT_AES
},
-Property => DB_ENCRYPT ;
$v = '';
ok 69, ! $db1->db_get(3, $v) ;
ok 70, $v eq $data{3};
# check there are three records
ok 71, countRecords($db1) == 3 ;
undef $db1;
}
{
# new BerkeleyDB::Unknown -Encrypt =>
my $Dfile = "abcd.enc";
my $lex = new LexFile $Dfile ;
my %hash ;
my ($k, $v) ;
ok 72, my $db = new BerkeleyDB::Hash
-Filename => $Dfile,
-Flags => DB_CREATE,
-Encrypt => {Password => "beta",
Flags => DB_ENCRYPT_AES
},
-Property => DB_ENCRYPT ;
# create some data
my %data = (
"red" => 2,
"green" => "house",
"blue" => "sea",
) ;
my $ret = 0 ;
while (($k, $v) = each %data) {
$ret += $db->db_put($k, $v) ;
}
ok 73, $ret == 0 ;
# check there are three records
ok 74, countRecords($db) == 3 ;
undef $db;
# attempt to open a database without specifying encryption
ok 75, ! new BerkeleyDB::Unknown -Filename => $Dfile,
-Flags => DB_CREATE ;
# try opening with the wrong password
ok 76, ! new BerkeleyDB::Unknown -Filename => $Dfile,
-Filename => $Dfile,
-Encrypt => {Password => "def",
Flags => DB_ENCRYPT_AES
},
-Property => DB_ENCRYPT ;
# read the encrypted data
ok 77, my $db1 = new BerkeleyDB::Unknown -Filename => $Dfile,
-Filename => $Dfile,
-Encrypt => {Password => "beta",
Flags => DB_ENCRYPT_AES
},
-Property => DB_ENCRYPT ;
$v = '';
ok 78, ! $db1->db_get("red", $v) ;
ok 79, $v eq $data{"red"};
# check there are three records
ok 80, countRecords($db1) == 3 ;
undef $db1;
}

271
perl/BerkeleyDB/t/env.t Normal file
View File

@@ -0,0 +1,271 @@
#!./perl -w
use strict ;
use lib 't' ;
BEGIN {
$ENV{LC_ALL} = 'de_DE@euro';
}
use BerkeleyDB;
use util ;
print "1..53\n";
my $Dfile = "dbhash.tmp";
umask(0);
my $version_major = 0;
{
# db version stuff
my ($major, $minor, $patch) = (0, 0, 0) ;
ok 1, my $VER = BerkeleyDB::DB_VERSION_STRING ;
ok 2, my $ver = BerkeleyDB::db_version($version_major, $minor, $patch) ;
ok 3, $VER eq $ver ;
ok 4, $version_major > 1 ;
ok 5, defined $minor ;
ok 6, defined $patch ;
}
{
# Check for invalid parameters
my $env ;
eval ' $env = new BerkeleyDB::Env( -Stupid => 3) ; ' ;
ok 7, $@ =~ /unknown key value\(s\) Stupid/ ;
eval ' $env = new BerkeleyDB::Env( -Bad => 2, -Home => "/tmp", -Stupid => 3) ; ' ;
ok 8, $@ =~ /unknown key value\(s\) (Bad,? |Stupid,? ){2}/ ;
eval ' $env = new BerkeleyDB::Env (-Config => {"fred" => " "} ) ; ' ;
ok 9, !$env ;
ok 10, $BerkeleyDB::Error =~ /^(illegal name-value pair|Invalid argument)/ ;
#print " $BerkeleyDB::Error\n";
}
{
# create a very simple environment
my $home = "./fred" ;
ok 11, my $lexD = new LexDir($home) ;
chdir "./fred" ;
ok 12, my $env = new BerkeleyDB::Env -Flags => DB_CREATE,
@StdErrFile;
chdir ".." ;
undef $env ;
}
{
# create an environment with a Home
my $home = "./fred" ;
ok 13, my $lexD = new LexDir($home) ;
ok 14, my $env = new BerkeleyDB::Env -Home => $home,
-Flags => DB_CREATE ;
undef $env ;
}
{
# make new fail.
my $home = "./not_there" ;
rmtree $home ;
ok 15, ! -d $home ;
my $env = new BerkeleyDB::Env -Home => $home, @StdErrFile,
-Flags => DB_INIT_LOCK ;
ok 16, ! $env ;
ok 17, $! != 0 || $^E != 0 ;
rmtree $home ;
}
{
# Config
use Cwd ;
my $cwd = cwd() ;
my $home = "$cwd/fred" ;
my $data_dir = "$home/data_dir" ;
my $log_dir = "$home/log_dir" ;
my $data_file = "data.db" ;
ok 18, my $lexD = new LexDir($home) ;
ok 19, -d $data_dir ? chmod 0777, $data_dir : mkdir($data_dir, 0777) ;
ok 20, -d $log_dir ? chmod 0777, $log_dir : mkdir($log_dir, 0777) ;
my $env = new BerkeleyDB::Env -Home => $home, @StdErrFile,
-Config => { DB_DATA_DIR => $data_dir,
DB_LOG_DIR => $log_dir
},
-Flags => DB_CREATE|DB_INIT_TXN|DB_INIT_LOG|
DB_INIT_MPOOL|DB_INIT_LOCK ;
ok 21, $env ;
ok 22, my $txn = $env->txn_begin() ;
my %hash ;
ok 23, tie %hash, 'BerkeleyDB::Hash', -Filename => $data_file,
-Flags => DB_CREATE ,
-Env => $env,
-Txn => $txn ;
$hash{"abc"} = 123 ;
$hash{"def"} = 456 ;
$txn->txn_commit() ;
untie %hash ;
undef $txn ;
undef $env ;
}
sub chkMsg
{
my $prefix = shift || '';
$prefix = "$prefix: " if $prefix;
my $ErrMsg = join "|", map { "$prefix$_" }
'illegal flag specified to (db_open|DB->open)',
'DB_AUTO_COMMIT may not be specified in non-transactional environment';
return 1 if $BerkeleyDB::Error =~ /^$ErrMsg/ ;
warn "# $BerkeleyDB::Error\n" ;
return 0;
}
{
# -ErrFile with a filename
my $errfile = "./errfile" ;
my $home = "./fred" ;
ok 24, my $lexD = new LexDir($home) ;
my $lex = new LexFile $errfile ;
ok 25, my $env = new BerkeleyDB::Env( -ErrFile => $errfile,
-Flags => DB_CREATE,
-Home => $home) ;
my $db = new BerkeleyDB::Hash -Filename => $Dfile,
-Env => $env,
-Flags => -1;
ok 26, !$db ;
my $ErrMsg = join "'", 'illegal flag specified to (db_open|DB->open)',
'DB_AUTO_COMMIT may not be specified in non-transactional environment';
ok 27, chkMsg();
ok 28, -e $errfile ;
my $contents = docat($errfile) ;
chomp $contents ;
ok 29, $BerkeleyDB::Error eq $contents ;
undef $env ;
}
{
# -ErrFile with a filehandle
use IO::File ;
my $errfile = "./errfile" ;
my $home = "./fred" ;
ok 30, my $lexD = new LexDir($home) ;
my $lex = new LexFile $errfile ;
my $fh = new IO::File ">$errfile" ;
ok 31, my $env = new BerkeleyDB::Env( -ErrFile => $fh,
-Flags => DB_CREATE,
-Home => $home) ;
my $db = new BerkeleyDB::Hash -Filename => $Dfile,
-Env => $env,
-Flags => -1;
ok 32, !$db ;
ok 33, chkMsg();
ok 34, -e $errfile ;
my $contents = docat($errfile) ;
chomp $contents ;
ok 35, $BerkeleyDB::Error eq $contents ;
undef $env ;
}
{
# -ErrPrefix
my $home = "./fred" ;
ok 36, my $lexD = new LexDir($home) ;
my $errfile = "./errfile" ;
my $lex = new LexFile $errfile ;
ok 37, my $env = new BerkeleyDB::Env( -ErrFile => $errfile,
-ErrPrefix => "PREFIX",
-Flags => DB_CREATE,
-Home => $home) ;
my $db = new BerkeleyDB::Hash -Filename => $Dfile,
-Env => $env,
-Flags => -1;
ok 38, !$db ;
ok 39, chkMsg('PREFIX');
ok 40, -e $errfile ;
my $contents = docat($errfile) ;
chomp $contents ;
ok 41, $BerkeleyDB::Error eq $contents ;
# change the prefix on the fly
my $old = $env->errPrefix("NEW ONE") ;
ok 42, $old eq "PREFIX" ;
$db = new BerkeleyDB::Hash -Filename => $Dfile,
-Env => $env,
-Flags => -1;
ok 43, !$db ;
ok 44, chkMsg('NEW ONE');
$contents = docat($errfile) ;
chomp $contents ;
ok 45, $contents =~ /$BerkeleyDB::Error$/ ;
undef $env ;
}
{
# test db_appexit
use Cwd ;
my $cwd = cwd() ;
my $home = "$cwd/fred" ;
my $data_dir = "$home/data_dir" ;
my $log_dir = "$home/log_dir" ;
my $data_file = "data.db" ;
ok 46, my $lexD = new LexDir($home);
ok 47, -d $data_dir ? chmod 0777, $data_dir : mkdir($data_dir, 0777) ;
ok 48, -d $log_dir ? chmod 0777, $log_dir : mkdir($log_dir, 0777) ;
my $env = new BerkeleyDB::Env -Home => $home, @StdErrFile,
-Config => { DB_DATA_DIR => $data_dir,
DB_LOG_DIR => $log_dir
},
-Flags => DB_CREATE|DB_INIT_TXN|DB_INIT_LOG|
DB_INIT_MPOOL|DB_INIT_LOCK ;
ok 49, $env ;
ok 50, my $txn_mgr = $env->TxnMgr() ;
ok 51, $env->db_appexit() == 0 ;
}
{
# attempt to open a new environment without DB_CREATE
# should fail with Berkeley DB 3.x or better.
my $home = "./fred" ;
ok 52, my $lexD = new LexDir($home) ;
chdir "./fred" ;
my $env = new BerkeleyDB::Env -Home => $home, -Flags => DB_CREATE ;
ok 53, $version_major == 2 ? $env : ! $env ;
# The test below is not portable -- the error message returned by
# $BerkeleyDB::Error is locale dependant.
#ok 54, $version_major == 2 ? 1
# : $BerkeleyDB::Error =~ /No such file or directory/ ;
# or print "# BerkeleyDB::Error is $BerkeleyDB::Error\n";
chdir ".." ;
undef $env ;
}
# test -Verbose
# test -Flags
# db_value_set

View File

@@ -0,0 +1,403 @@
#!./perl -w
use strict ;
BEGIN {
unless(grep /blib/, @INC) {
chdir 't' if -d 't';
@INC = '../lib' if -d '../lib';
}
}
use lib 't';
use BerkeleyDB;
use Test::More;
use util(1);
plan tests => 7;
my $Dfile = "dbhash.tmp";
my $Dfile2 = "dbhash2.tmp";
my $Dfile3 = "dbhash3.tmp";
unlink $Dfile;
umask(0) ;
my $redirect = "xyzt" ;
{
my $x = $BerkeleyDB::Error;
my $redirect = "xyzt" ;
{
my $redirectObj = new Redirect $redirect ;
use strict ;
use BerkeleyDB ;
use vars qw( %h $k $v ) ;
my $filename = "fruit" ;
unlink $filename ;
tie %h, "BerkeleyDB::Hash",
-Filename => $filename,
-Flags => DB_CREATE
or die "Cannot open file $filename: $! $BerkeleyDB::Error\n" ;
# Add a few key/value pairs to the file
$h{"apple"} = "red" ;
$h{"orange"} = "orange" ;
$h{"banana"} = "yellow" ;
$h{"tomato"} = "red" ;
# Check for existence of a key
print "Banana Exists\n\n" if $h{"banana"} ;
# Delete a key/value pair.
delete $h{"apple"} ;
# print the contents of the file
while (($k, $v) = each %h)
{ print "$k -> $v\n" }
untie %h ;
unlink $filename ;
}
#print "[" . docat($redirect) . "]" ;
is(docat_del($redirect), <<'EOM') ;
Banana Exists
orange -> orange
tomato -> red
banana -> yellow
EOM
}
{
my $redirect = "xyzt" ;
{
my $redirectObj = new Redirect $redirect ;
use strict ;
use BerkeleyDB ;
my $filename = "fruit" ;
unlink $filename ;
my $db = new BerkeleyDB::Hash
-Filename => $filename,
-Flags => DB_CREATE
or die "Cannot open file $filename: $! $BerkeleyDB::Error\n" ;
# Add a few key/value pairs to the file
$db->db_put("apple", "red") ;
$db->db_put("orange", "orange") ;
$db->db_put("banana", "yellow") ;
$db->db_put("tomato", "red") ;
# Check for existence of a key
print "Banana Exists\n\n" if $db->db_get("banana", $v) == 0;
# Delete a key/value pair.
$db->db_del("apple") ;
# print the contents of the file
my ($k, $v) = ("", "") ;
my $cursor = $db->db_cursor() ;
while ($cursor->c_get($k, $v, DB_NEXT) == 0)
{ print "$k -> $v\n" }
undef $cursor ;
undef $db ;
unlink $filename ;
}
#print "[" . docat($redirect) . "]" ;
is(docat_del($redirect), <<'EOM') ;
Banana Exists
orange -> orange
tomato -> red
banana -> yellow
EOM
}
{
my $redirect = "xyzt" ;
{
my $redirectObj = new Redirect $redirect ;
use strict ;
use BerkeleyDB ;
my $filename = "tree" ;
unlink $filename ;
my %h ;
tie %h, 'BerkeleyDB::Btree',
-Filename => $filename,
-Flags => DB_CREATE
or die "Cannot open $filename: $! $BerkeleyDB::Error\n" ;
# Add a key/value pair to the file
$h{'Wall'} = 'Larry' ;
$h{'Smith'} = 'John' ;
$h{'mouse'} = 'mickey' ;
$h{'duck'} = 'donald' ;
# Delete
delete $h{"duck"} ;
# Cycle through the keys printing them in order.
# Note it is not necessary to sort the keys as
# the btree will have kept them in order automatically.
foreach (keys %h)
{ print "$_\n" }
untie %h ;
unlink $filename ;
}
#print "[" . docat($redirect) . "]\n" ;
is(docat_del($redirect), <<'EOM') ;
Smith
Wall
mouse
EOM
}
{
my $redirect = "xyzt" ;
{
my $redirectObj = new Redirect $redirect ;
use strict ;
use BerkeleyDB ;
my $filename = "tree" ;
unlink $filename ;
my %h ;
tie %h, 'BerkeleyDB::Btree',
-Filename => $filename,
-Flags => DB_CREATE,
-Compare => sub { lc $_[0] cmp lc $_[1] }
or die "Cannot open $filename: $!\n" ;
# Add a key/value pair to the file
$h{'Wall'} = 'Larry' ;
$h{'Smith'} = 'John' ;
$h{'mouse'} = 'mickey' ;
$h{'duck'} = 'donald' ;
# Delete
delete $h{"duck"} ;
# Cycle through the keys printing them in order.
# Note it is not necessary to sort the keys as
# the btree will have kept them in order automatically.
foreach (keys %h)
{ print "$_\n" }
untie %h ;
unlink $filename ;
}
#print "[" . docat($redirect) . "]\n" ;
is(docat_del($redirect), <<'EOM') ;
mouse
Smith
Wall
EOM
}
{
my $redirect = "xyzt" ;
{
my $redirectObj = new Redirect $redirect ;
use strict ;
use BerkeleyDB ;
my %hash ;
my $filename = "filt.db" ;
unlink $filename ;
my $db = tie %hash, 'BerkeleyDB::Hash',
-Filename => $filename,
-Flags => DB_CREATE
or die "Cannot open $filename: $!\n" ;
# Install DBM Filters
$db->filter_fetch_key ( sub { s/\0$// } ) ;
$db->filter_store_key ( sub { $_ .= "\0" } ) ;
$db->filter_fetch_value( sub { s/\0$// } ) ;
$db->filter_store_value( sub { $_ .= "\0" } ) ;
$hash{"abc"} = "def" ;
my $a = $hash{"ABC"} ;
# ...
undef $db ;
untie %hash ;
$db = tie %hash, 'BerkeleyDB::Hash',
-Filename => $filename,
-Flags => DB_CREATE
or die "Cannot open $filename: $!\n" ;
while (($k, $v) = each %hash)
{ print "$k -> $v\n" }
undef $db ;
untie %hash ;
unlink $filename ;
}
#print "[" . docat($redirect) . "]\n" ;
is(docat_del($redirect), <<"EOM") ;
abc\x00 -> def\x00
EOM
}
{
my $redirect = "xyzt" ;
{
my $redirectObj = new Redirect $redirect ;
use strict ;
use BerkeleyDB ;
my %hash ;
my $filename = "filt.db" ;
unlink $filename ;
my $db = tie %hash, 'BerkeleyDB::Btree',
-Filename => $filename,
-Flags => DB_CREATE
or die "Cannot open $filename: $!\n" ;
$db->filter_fetch_key ( sub { $_ = unpack("i", $_) } ) ;
$db->filter_store_key ( sub { $_ = pack ("i", $_) } ) ;
$hash{123} = "def" ;
# ...
undef $db ;
untie %hash ;
$db = tie %hash, 'BerkeleyDB::Btree',
-Filename => $filename,
-Flags => DB_CREATE
or die "Cannot Open $filename: $!\n" ;
while (($k, $v) = each %hash)
{ print "$k -> $v\n" }
undef $db ;
untie %hash ;
unlink $filename ;
}
my $val = pack("i", 123) ;
#print "[" . docat($redirect) . "]\n" ;
is(docat_del($redirect), <<"EOM") ;
$val -> def
EOM
}
{
my $redirect = "xyzt" ;
{
my $redirectObj = new Redirect $redirect ;
if ($FA) {
use strict ;
use BerkeleyDB ;
my $filename = "text" ;
unlink $filename ;
my @h ;
tie @h, 'BerkeleyDB::Recno',
-Filename => $filename,
-Flags => DB_CREATE,
-Property => DB_RENUMBER
or die "Cannot open $filename: $!\n" ;
# Add a few key/value pairs to the file
$h[0] = "orange" ;
$h[1] = "blue" ;
$h[2] = "yellow" ;
push @h, "green", "black" ;
my $elements = scalar @h ;
print "The array contains $elements entries\n" ;
my $last = pop @h ;
print "popped $last\n" ;
unshift @h, "white" ;
my $first = shift @h ;
print "shifted $first\n" ;
# Check for existence of a key
print "Element 1 Exists with value $h[1]\n" if $h[1] ;
untie @h ;
unlink $filename ;
} else {
use strict ;
use BerkeleyDB ;
my $filename = "text" ;
unlink $filename ;
my @h ;
my $db = tie @h, 'BerkeleyDB::Recno',
-Filename => $filename,
-Flags => DB_CREATE,
-Property => DB_RENUMBER
or die "Cannot open $filename: $!\n" ;
# Add a few key/value pairs to the file
$h[0] = "orange" ;
$h[1] = "blue" ;
$h[2] = "yellow" ;
$db->push("green", "black") ;
my $elements = $db->length() ;
print "The array contains $elements entries\n" ;
my $last = $db->pop ;
print "popped $last\n" ;
$db->unshift("white") ;
my $first = $db->shift ;
print "shifted $first\n" ;
# Check for existence of a key
print "Element 1 Exists with value $h[1]\n" if $h[1] ;
undef $db ;
untie @h ;
unlink $filename ;
}
}
#print "[" . docat($redirect) . "]\n" ;
is(docat_del($redirect), <<"EOM") ;
The array contains 5 entries
popped black
shifted white
Element 1 Exists with value blue
EOM
}

View File

@@ -0,0 +1,417 @@
#!./perl -w
use strict ;
BEGIN {
unless(grep /blib/, @INC) {
chdir 't' if -d 't';
@INC = '../lib' if -d '../lib';
}
}
use lib 't';
use BerkeleyDB;
use Test::More;
use util(1);
plan tests => 7;
my $Dfile = "dbhash.tmp";
my $Dfile2 = "dbhash2.tmp";
my $Dfile3 = "dbhash3.tmp";
unlink $Dfile;
umask(0) ;
my $redirect = "xyzt" ;
{
my $x = $BerkeleyDB::Error;
my $redirect = "xyzt" ;
{
my $redirectObj = new Redirect $redirect ;
## BEGIN simpleHash
use strict ;
use BerkeleyDB ;
use vars qw( %h $k $v ) ;
my $filename = "fruit" ;
unlink $filename ;
tie %h, "BerkeleyDB::Hash",
-Filename => $filename,
-Flags => DB_CREATE
or die "Cannot open file $filename: $! $BerkeleyDB::Error\n" ;
# Add a few key/value pairs to the file
$h{"apple"} = "red" ;
$h{"orange"} = "orange" ;
$h{"banana"} = "yellow" ;
$h{"tomato"} = "red" ;
# Check for existence of a key
print "Banana Exists\n\n" if $h{"banana"} ;
# Delete a key/value pair.
delete $h{"apple"} ;
# print the contents of the file
while (($k, $v) = each %h)
{ print "$k -> $v\n" }
untie %h ;
## END simpleHash
unlink $filename ;
}
#print "[" . docat($redirect) . "]" ;
is(docat_del($redirect), <<'EOM') ;
Banana Exists
orange -> orange
tomato -> red
banana -> yellow
EOM
}
{
my $redirect = "xyzt" ;
{
my $redirectObj = new Redirect $redirect ;
## BEGIN simpleHash2
use strict ;
use BerkeleyDB ;
my $filename = "fruit" ;
unlink $filename ;
my $db = new BerkeleyDB::Hash
-Filename => $filename,
-Flags => DB_CREATE
or die "Cannot open file $filename: $! $BerkeleyDB::Error\n" ;
# Add a few key/value pairs to the file
$db->db_put("apple", "red") ;
$db->db_put("orange", "orange") ;
$db->db_put("banana", "yellow") ;
$db->db_put("tomato", "red") ;
# Check for existence of a key
print "Banana Exists\n\n" if $db->db_get("banana", $v) == 0;
# Delete a key/value pair.
$db->db_del("apple") ;
# print the contents of the file
my ($k, $v) = ("", "") ;
my $cursor = $db->db_cursor() ;
while ($cursor->c_get($k, $v, DB_NEXT) == 0)
{ print "$k -> $v\n" }
undef $cursor ;
undef $db ;
## END simpleHash2
unlink $filename ;
}
#print "[" . docat($redirect) . "]" ;
is(docat_del($redirect), <<'EOM') ;
Banana Exists
orange -> orange
tomato -> red
banana -> yellow
EOM
}
{
my $redirect = "xyzt" ;
{
my $redirectObj = new Redirect $redirect ;
## BEGIN btreeSimple
use strict ;
use BerkeleyDB ;
my $filename = "tree" ;
unlink $filename ;
my %h ;
tie %h, 'BerkeleyDB::Btree',
-Filename => $filename,
-Flags => DB_CREATE
or die "Cannot open $filename: $! $BerkeleyDB::Error\n" ;
# Add a key/value pair to the file
$h{'Wall'} = 'Larry' ;
$h{'Smith'} = 'John' ;
$h{'mouse'} = 'mickey' ;
$h{'duck'} = 'donald' ;
# Delete
delete $h{"duck"} ;
# Cycle through the keys printing them in order.
# Note it is not necessary to sort the keys as
# the btree will have kept them in order automatically.
foreach (keys %h)
{ print "$_\n" }
untie %h ;
## END btreeSimple
unlink $filename ;
}
#print "[" . docat($redirect) . "]\n" ;
is(docat_del($redirect), <<'EOM') ;
Smith
Wall
mouse
EOM
}
{
my $redirect = "xyzt" ;
{
my $redirectObj = new Redirect $redirect ;
## BEGIN btreeSortOrder
use strict ;
use BerkeleyDB ;
my $filename = "tree" ;
unlink $filename ;
my %h ;
tie %h, 'BerkeleyDB::Btree',
-Filename => $filename,
-Flags => DB_CREATE,
-Compare => sub { lc $_[0] cmp lc $_[1] }
or die "Cannot open $filename: $!\n" ;
# Add a key/value pair to the file
$h{'Wall'} = 'Larry' ;
$h{'Smith'} = 'John' ;
$h{'mouse'} = 'mickey' ;
$h{'duck'} = 'donald' ;
# Delete
delete $h{"duck"} ;
# Cycle through the keys printing them in order.
# Note it is not necessary to sort the keys as
# the btree will have kept them in order automatically.
foreach (keys %h)
{ print "$_\n" }
untie %h ;
## END btreeSortOrder
unlink $filename ;
}
#print "[" . docat($redirect) . "]\n" ;
is(docat_del($redirect), <<'EOM') ;
mouse
Smith
Wall
EOM
}
{
my $redirect = "xyzt" ;
{
my $redirectObj = new Redirect $redirect ;
## BEGIN nullFilter
use strict ;
use BerkeleyDB ;
my %hash ;
my $filename = "filt.db" ;
unlink $filename ;
my $db = tie %hash, 'BerkeleyDB::Hash',
-Filename => $filename,
-Flags => DB_CREATE
or die "Cannot open $filename: $!\n" ;
# Install DBM Filters
$db->filter_fetch_key ( sub { s/\0$// } ) ;
$db->filter_store_key ( sub { $_ .= "\0" } ) ;
$db->filter_fetch_value( sub { s/\0$// } ) ;
$db->filter_store_value( sub { $_ .= "\0" } ) ;
$hash{"abc"} = "def" ;
my $a = $hash{"ABC"} ;
# ...
undef $db ;
untie %hash ;
## END nullFilter
$db = tie %hash, 'BerkeleyDB::Hash',
-Filename => $filename,
-Flags => DB_CREATE
or die "Cannot open $filename: $!\n" ;
while (($k, $v) = each %hash)
{ print "$k -> $v\n" }
undef $db ;
untie %hash ;
unlink $filename ;
}
#print "[" . docat($redirect) . "]\n" ;
is(docat_del($redirect), <<"EOM") ;
abc\x00 -> def\x00
EOM
}
{
my $redirect = "xyzt" ;
{
my $redirectObj = new Redirect $redirect ;
## BEGIN intFilter
use strict ;
use BerkeleyDB ;
my %hash ;
my $filename = "filt.db" ;
unlink $filename ;
my $db = tie %hash, 'BerkeleyDB::Btree',
-Filename => $filename,
-Flags => DB_CREATE
or die "Cannot open $filename: $!\n" ;
$db->filter_fetch_key ( sub { $_ = unpack("i", $_) } ) ;
$db->filter_store_key ( sub { $_ = pack ("i", $_) } ) ;
$hash{123} = "def" ;
# ...
undef $db ;
untie %hash ;
## END intFilter
$db = tie %hash, 'BerkeleyDB::Btree',
-Filename => $filename,
-Flags => DB_CREATE
or die "Cannot Open $filename: $!\n" ;
while (($k, $v) = each %hash)
{ print "$k -> $v\n" }
undef $db ;
untie %hash ;
unlink $filename ;
}
my $val = pack("i", 123) ;
#print "[" . docat($redirect) . "]\n" ;
is(docat_del($redirect), <<"EOM") ;
$val -> def
EOM
}
{
my $redirect = "xyzt" ;
{
my $redirectObj = new Redirect $redirect ;
if ($FA) {
## BEGIN simpleRecno
use strict ;
use BerkeleyDB ;
my $filename = "text" ;
unlink $filename ;
my @h ;
tie @h, 'BerkeleyDB::Recno',
-Filename => $filename,
-Flags => DB_CREATE,
-Property => DB_RENUMBER
or die "Cannot open $filename: $!\n" ;
# Add a few key/value pairs to the file
$h[0] = "orange" ;
$h[1] = "blue" ;
$h[2] = "yellow" ;
push @h, "green", "black" ;
my $elements = scalar @h ;
print "The array contains $elements entries\n" ;
my $last = pop @h ;
print "popped $last\n" ;
unshift @h, "white" ;
my $first = shift @h ;
print "shifted $first\n" ;
# Check for existence of a key
print "Element 1 Exists with value $h[1]\n" if $h[1] ;
untie @h ;
## END simpleRecno
unlink $filename ;
} else {
use strict ;
use BerkeleyDB ;
my $filename = "text" ;
unlink $filename ;
my @h ;
my $db = tie @h, 'BerkeleyDB::Recno',
-Filename => $filename,
-Flags => DB_CREATE,
-Property => DB_RENUMBER
or die "Cannot open $filename: $!\n" ;
# Add a few key/value pairs to the file
$h[0] = "orange" ;
$h[1] = "blue" ;
$h[2] = "yellow" ;
$db->push("green", "black") ;
my $elements = $db->length() ;
print "The array contains $elements entries\n" ;
my $last = $db->pop ;
print "popped $last\n" ;
$db->unshift("white") ;
my $first = $db->shift ;
print "shifted $first\n" ;
# Check for existence of a key
print "Element 1 Exists with value $h[1]\n" if $h[1] ;
undef $db ;
untie @h ;
unlink $filename ;
}
}
#print "[" . docat($redirect) . "]\n" ;
is(docat_del($redirect), <<"EOM") ;
The array contains 5 entries
popped black
shifted white
Element 1 Exists with value blue
EOM
}

View File

@@ -0,0 +1,139 @@
#!./perl -w
use strict ;
BEGIN {
unless(grep /blib/, @INC) {
chdir 't' if -d 't';
@INC = '../lib' if -d '../lib';
}
}
use lib 't';
use BerkeleyDB;
use Test::More;
use util (1);
#BEGIN
#{
# if ($BerkeleyDB::db_version < 3) {
# print "1..0 # Skipping test, this needs Berkeley DB 3.x or better\n" ;
# exit 0 ;
# }
#}
plan(skip_all => "this needs Berkeley DB 3.x or better\n" )
if $BerkeleyDB::db_version < 3;
plan tests => 2;
my $Dfile = "dbhash.tmp";
my $Dfile2 = "dbhash2.tmp";
my $Dfile3 = "dbhash3.tmp";
unlink $Dfile;
umask(0) ;
my $redirect = "xyzt" ;
{
my $redirect = "xyzt" ;
{
my $redirectObj = new Redirect $redirect ;
use strict ;
use BerkeleyDB ;
my $filename = "fruit" ;
unlink $filename ;
my $db = new BerkeleyDB::Hash
-Filename => $filename,
-Flags => DB_CREATE,
-Property => DB_DUP
or die "Cannot open file $filename: $! $BerkeleyDB::Error\n" ;
# Add a few key/value pairs to the file
$db->db_put("red", "apple") ;
$db->db_put("orange", "orange") ;
$db->db_put("green", "banana") ;
$db->db_put("yellow", "banana") ;
$db->db_put("red", "tomato") ;
$db->db_put("green", "apple") ;
# print the contents of the file
my ($k, $v) = ("", "") ;
my $cursor = $db->db_cursor() ;
while ($cursor->c_get($k, $v, DB_NEXT) == 0)
{ print "$k -> $v\n" }
undef $cursor ;
undef $db ;
unlink $filename ;
}
#print "[" . docat($redirect) . "]" ;
is(docat_del_sort($redirect), <<'EOM') ;
green -> apple
green -> banana
orange -> orange
red -> apple
red -> tomato
yellow -> banana
EOM
}
{
my $redirect = "xyzt" ;
{
my $redirectObj = new Redirect $redirect ;
use strict ;
use BerkeleyDB ;
my $filename = "fruit" ;
unlink $filename ;
my $db = new BerkeleyDB::Hash
-Filename => $filename,
-Flags => DB_CREATE,
-Property => DB_DUP | DB_DUPSORT
or die "Cannot open file $filename: $! $BerkeleyDB::Error\n" ;
# Add a few key/value pairs to the file
$db->db_put("red", "apple") ;
$db->db_put("orange", "orange") ;
$db->db_put("green", "banana") ;
$db->db_put("yellow", "banana") ;
$db->db_put("red", "tomato") ;
$db->db_put("green", "apple") ;
# print the contents of the file
my ($k, $v) = ("", "") ;
my $cursor = $db->db_cursor() ;
while ($cursor->c_get($k, $v, DB_NEXT) == 0)
{ print "$k -> $v\n" }
undef $cursor ;
undef $db ;
unlink $filename ;
}
#print "[" . docat($redirect) . "]" ;
is(docat_del_sort($redirect), <<'EOM') ;
green -> apple
green -> banana
orange -> orange
red -> apple
red -> tomato
yellow -> banana
EOM
}

View File

@@ -0,0 +1,143 @@
#!./perl -w
use strict ;
BEGIN {
unless(grep /blib/, @INC) {
chdir 't' if -d 't';
@INC = '../lib' if -d '../lib';
}
}
use lib 't';
use BerkeleyDB;
use Test::More;
use util (1);
#BEGIN
#{
# if ($BerkeleyDB::db_version < 3) {
# print "1..0 # Skipping test, this needs Berkeley DB 3.x or better\n" ;
# exit 0 ;
# }
#}
plan(skip_all => "this needs Berkeley DB 3.x or better\n" )
if $BerkeleyDB::db_version < 3;
plan tests => 2;
my $Dfile = "dbhash.tmp";
my $Dfile2 = "dbhash2.tmp";
my $Dfile3 = "dbhash3.tmp";
unlink $Dfile;
umask(0) ;
my $redirect = "xyzt" ;
{
my $redirect = "xyzt" ;
{
my $redirectObj = new Redirect $redirect ;
## BEGIN dupHash
use strict ;
use BerkeleyDB ;
my $filename = "fruit" ;
unlink $filename ;
my $db = new BerkeleyDB::Hash
-Filename => $filename,
-Flags => DB_CREATE,
-Property => DB_DUP
or die "Cannot open file $filename: $! $BerkeleyDB::Error\n" ;
# Add a few key/value pairs to the file
$db->db_put("red", "apple") ;
$db->db_put("orange", "orange") ;
$db->db_put("green", "banana") ;
$db->db_put("yellow", "banana") ;
$db->db_put("red", "tomato") ;
$db->db_put("green", "apple") ;
# print the contents of the file
my ($k, $v) = ("", "") ;
my $cursor = $db->db_cursor() ;
while ($cursor->c_get($k, $v, DB_NEXT) == 0)
{ print "$k -> $v\n" }
undef $cursor ;
undef $db ;
## END dupHash
unlink $filename ;
}
#print "[" . docat($redirect) . "]" ;
is(docat_del_sort($redirect), <<'EOM') ;
green -> apple
green -> banana
orange -> orange
red -> apple
red -> tomato
yellow -> banana
EOM
}
{
my $redirect = "xyzt" ;
{
my $redirectObj = new Redirect $redirect ;
## BEGIN dupSortHash
use strict ;
use BerkeleyDB ;
my $filename = "fruit" ;
unlink $filename ;
my $db = new BerkeleyDB::Hash
-Filename => $filename,
-Flags => DB_CREATE,
-Property => DB_DUP | DB_DUPSORT
or die "Cannot open file $filename: $! $BerkeleyDB::Error\n" ;
# Add a few key/value pairs to the file
$db->db_put("red", "apple") ;
$db->db_put("orange", "orange") ;
$db->db_put("green", "banana") ;
$db->db_put("yellow", "banana") ;
$db->db_put("red", "tomato") ;
$db->db_put("green", "apple") ;
# print the contents of the file
my ($k, $v) = ("", "") ;
my $cursor = $db->db_cursor() ;
while ($cursor->c_get($k, $v, DB_NEXT) == 0)
{ print "$k -> $v\n" }
undef $cursor ;
undef $db ;
## END dupSortHash
unlink $filename ;
}
#print "[" . docat($redirect) . "]" ;
is(docat_del_sort($redirect), <<'EOM') ;
green -> apple
green -> banana
orange -> orange
red -> apple
red -> tomato
yellow -> banana
EOM
}

324
perl/BerkeleyDB/t/filter.t Normal file
View File

@@ -0,0 +1,324 @@
#!./perl -w
# ID: %I%, %G%
use strict ;
use lib 't' ;
use BerkeleyDB;
use util ;
print "1..52\n";
my $Dfile = "dbhash.tmp";
unlink $Dfile;
umask(0) ;
{
# DBM Filter tests
use strict ;
my (%h, $db) ;
my ($fetch_key, $store_key, $fetch_value, $store_value) = ("") x 4 ;
unlink $Dfile;
sub checkOutput
{
my($fk, $sk, $fv, $sv) = @_ ;
return
$fetch_key eq $fk && $store_key eq $sk &&
$fetch_value eq $fv && $store_value eq $sv &&
$_ eq 'original' ;
}
ok 1, $db = tie %h, 'BerkeleyDB::Hash',
-Filename => $Dfile,
-Flags => DB_CREATE;
$db->filter_fetch_key (sub { $fetch_key = $_ }) ;
$db->filter_store_key (sub { $store_key = $_ }) ;
$db->filter_fetch_value (sub { $fetch_value = $_}) ;
$db->filter_store_value (sub { $store_value = $_ }) ;
$_ = "original" ;
$h{"fred"} = "joe" ;
# fk sk fv sv
ok 2, checkOutput( "", "fred", "", "joe") ;
($fetch_key, $store_key, $fetch_value, $store_value) = ("") x 4 ;
ok 3, $h{"fred"} eq "joe";
# fk sk fv sv
ok 4, checkOutput( "", "fred", "joe", "") ;
($fetch_key, $store_key, $fetch_value, $store_value) = ("") x 4 ;
ok 5, $db->FIRSTKEY() eq "fred" ;
# fk sk fv sv
ok 6, checkOutput( "fred", "", "", "") ;
# replace the filters, but remember the previous set
my ($old_fk) = $db->filter_fetch_key
(sub { $_ = uc $_ ; $fetch_key = $_ }) ;
my ($old_sk) = $db->filter_store_key
(sub { $_ = lc $_ ; $store_key = $_ }) ;
my ($old_fv) = $db->filter_fetch_value
(sub { $_ = "[$_]"; $fetch_value = $_ }) ;
my ($old_sv) = $db->filter_store_value
(sub { s/o/x/g; $store_value = $_ }) ;
($fetch_key, $store_key, $fetch_value, $store_value) = ("") x 4 ;
$h{"Fred"} = "Joe" ;
# fk sk fv sv
ok 7, checkOutput( "", "fred", "", "Jxe") ;
($fetch_key, $store_key, $fetch_value, $store_value) = ("") x 4 ;
ok 8, $h{"Fred"} eq "[Jxe]";
print "$h{'Fred'}\n";
# fk sk fv sv
ok 9, checkOutput( "", "fred", "[Jxe]", "") ;
($fetch_key, $store_key, $fetch_value, $store_value) = ("") x 4 ;
ok 10, $db->FIRSTKEY() eq "FRED" ;
# fk sk fv sv
ok 11, checkOutput( "FRED", "", "", "") ;
# put the original filters back
$db->filter_fetch_key ($old_fk);
$db->filter_store_key ($old_sk);
$db->filter_fetch_value ($old_fv);
$db->filter_store_value ($old_sv);
($fetch_key, $store_key, $fetch_value, $store_value) = ("") x 4 ;
$h{"fred"} = "joe" ;
ok 12, checkOutput( "", "fred", "", "joe") ;
($fetch_key, $store_key, $fetch_value, $store_value) = ("") x 4 ;
ok 13, $h{"fred"} eq "joe";
ok 14, checkOutput( "", "fred", "joe", "") ;
($fetch_key, $store_key, $fetch_value, $store_value) = ("") x 4 ;
ok 15, $db->FIRSTKEY() eq "fred" ;
ok 16, checkOutput( "fred", "", "", "") ;
# delete the filters
$db->filter_fetch_key (undef);
$db->filter_store_key (undef);
$db->filter_fetch_value (undef);
$db->filter_store_value (undef);
($fetch_key, $store_key, $fetch_value, $store_value) = ("") x 4 ;
$h{"fred"} = "joe" ;
ok 17, checkOutput( "", "", "", "") ;
($fetch_key, $store_key, $fetch_value, $store_value) = ("") x 4 ;
ok 18, $h{"fred"} eq "joe";
ok 19, checkOutput( "", "", "", "") ;
($fetch_key, $store_key, $fetch_value, $store_value) = ("") x 4 ;
ok 20, $db->FIRSTKEY() eq "fred" ;
ok 21, checkOutput( "", "", "", "") ;
undef $db ;
untie %h;
unlink $Dfile;
}
{
# DBM Filter with a closure
use strict ;
my (%h, $db) ;
unlink $Dfile;
ok 22, $db = tie %h, 'BerkeleyDB::Hash',
-Filename => $Dfile,
-Flags => DB_CREATE;
my %result = () ;
sub Closure
{
my ($name) = @_ ;
my $count = 0 ;
my @kept = () ;
return sub { ++$count ;
push @kept, $_ ;
$result{$name} = "$name - $count: [@kept]" ;
}
}
$db->filter_store_key(Closure("store key")) ;
$db->filter_store_value(Closure("store value")) ;
$db->filter_fetch_key(Closure("fetch key")) ;
$db->filter_fetch_value(Closure("fetch value")) ;
$_ = "original" ;
$h{"fred"} = "joe" ;
ok 23, $result{"store key"} eq "store key - 1: [fred]" ;
ok 24, $result{"store value"} eq "store value - 1: [joe]" ;
ok 25, ! defined $result{"fetch key"} ;
ok 26, ! defined $result{"fetch value"} ;
ok 27, $_ eq "original" ;
ok 28, $db->FIRSTKEY() eq "fred" ;
ok 29, $result{"store key"} eq "store key - 1: [fred]" ;
ok 30, $result{"store value"} eq "store value - 1: [joe]" ;
ok 31, $result{"fetch key"} eq "fetch key - 1: [fred]" ;
ok 32, ! defined $result{"fetch value"} ;
ok 33, $_ eq "original" ;
$h{"jim"} = "john" ;
ok 34, $result{"store key"} eq "store key - 2: [fred jim]" ;
ok 35, $result{"store value"} eq "store value - 2: [joe john]" ;
ok 36, $result{"fetch key"} eq "fetch key - 1: [fred]" ;
ok 37, ! defined $result{"fetch value"} ;
ok 38, $_ eq "original" ;
ok 39, $h{"fred"} eq "joe" ;
ok 40, $result{"store key"} eq "store key - 3: [fred jim fred]" ;
ok 41, $result{"store value"} eq "store value - 2: [joe john]" ;
ok 42, $result{"fetch key"} eq "fetch key - 1: [fred]" ;
ok 43, $result{"fetch value"} eq "fetch value - 1: [joe]" ;
ok 44, $_ eq "original" ;
undef $db ;
untie %h;
unlink $Dfile;
}
{
# DBM Filter recursion detection
use strict ;
my (%h, $db) ;
unlink $Dfile;
ok 45, $db = tie %h, 'BerkeleyDB::Hash',
-Filename => $Dfile,
-Flags => DB_CREATE;
$db->filter_store_key (sub { $_ = $h{$_} }) ;
eval '$h{1} = 1234' ;
ok 46, $@ =~ /^recursion detected in filter_store_key at/ ;
undef $db ;
untie %h;
unlink $Dfile;
}
{
# Check that DBM Filter can cope with read-only $_
#use warnings ;
use strict ;
my (%h, $db) ;
unlink $Dfile;
ok 47, $db = tie %h, 'BerkeleyDB::Hash',
-Filename => $Dfile,
-Flags => DB_CREATE;
$db->filter_fetch_key (sub { }) ;
$db->filter_store_key (sub { }) ;
$db->filter_fetch_value (sub { }) ;
$db->filter_store_value (sub { }) ;
$_ = "original" ;
$h{"fred"} = "joe" ;
ok(48, $h{"fred"} eq "joe");
eval { grep { $h{$_} } (1, 2, 3) };
ok (49, ! $@);
# delete the filters
$db->filter_fetch_key (undef);
$db->filter_store_key (undef);
$db->filter_fetch_value (undef);
$db->filter_store_value (undef);
$h{"fred"} = "joe" ;
ok(50, $h{"fred"} eq "joe");
ok(51, $db->FIRSTKEY() eq "fred") ;
eval { grep { $h{$_} } (1, 2, 3) };
ok (52, ! $@);
undef $db ;
untie %h;
unlink $Dfile;
}
if(0)
{
# Filter without tie
use strict ;
my (%h, $db) ;
unlink $Dfile;
ok 53, $db = tie %h, 'BerkeleyDB::Hash',
-Filename => $Dfile,
-Flags => DB_CREATE;
my %result = () ;
sub INC { return ++ $_[0] }
sub DEC { return -- $_[0] }
#$db->filter_fetch_key (sub { warn "FFK $_\n"; $_ = INC($_); warn "XX\n" }) ;
#$db->filter_store_key (sub { warn "FSK $_\n"; $_ = DEC($_); warn "XX\n" }) ;
#$db->filter_fetch_value (sub { warn "FFV $_\n"; $_ = INC($_); warn "XX\n"}) ;
#$db->filter_store_value (sub { warn "FSV $_\n"; $_ = DEC($_); warn "XX\n" }) ;
$db->filter_fetch_key (sub { warn "FFK $_\n"; $_ = pack("i", $_); warn "XX\n" }) ;
$db->filter_store_key (sub { warn "FSK $_\n"; $_ = unpack("i", $_); warn "XX\n" }) ;
$db->filter_fetch_value (sub { warn "FFV $_\n"; $_ = pack("i", $_); warn "XX\n"}) ;
#$db->filter_store_value (sub { warn "FSV $_\n"; $_ = unpack("i", $_); warn "XX\n" }) ;
#$db->filter_fetch_key (sub { ++ $_ }) ;
#$db->filter_store_key (sub { -- $_ }) ;
#$db->filter_fetch_value (sub { ++ $_ }) ;
#$db->filter_store_value (sub { -- $_ }) ;
my ($k, $v) = (0,0);
ok 54, ! $db->db_put(3,5);
exit;
ok 55, ! $db->db_get(3, $v);
ok 56, $v == 5 ;
$h{4} = 7 ;
ok 57, $h{4} == 7;
$k = 10;
$v = 30;
$h{$k} = $v ;
ok 58, $k == 10;
ok 59, $v == 30;
ok 60, $h{$k} == 30;
$k = 3;
ok 61, ! $db->db_get($k, $v, DB_GET_BOTH);
ok 62, $k == 3 ;
ok 63, $v == 5 ;
my $cursor = $db->db_cursor();
my %tmp = ();
while ($cursor->c_get($k, $v, DB_NEXT) == 0)
{
$tmp{$k} = $v;
}
ok 64, keys %tmp == 3 ;
ok 65, $tmp{3} == 5;
undef $cursor ;
undef $db ;
untie %h;
unlink $Dfile;
}

724
perl/BerkeleyDB/t/hash.t Normal file
View File

@@ -0,0 +1,724 @@
#!./perl -w
# ID: %I%, %G%
use strict ;
use lib 't' ;
use BerkeleyDB;
use util ;
print "1..212\n";
my $Dfile = "dbhash.tmp";
my $Dfile2 = "dbhash2.tmp";
my $Dfile3 = "dbhash3.tmp";
unlink $Dfile;
umask(0) ;
# Check for invalid parameters
{
# Check for invalid parameters
my $db ;
eval ' $db = new BerkeleyDB::Hash -Stupid => 3 ; ' ;
ok 1, $@ =~ /unknown key value\(s\) Stupid/ ;
eval ' $db = new BerkeleyDB::Hash -Bad => 2, -Mode => 0345, -Stupid => 3; ' ;
ok 2, $@ =~ /unknown key value\(s\) (Bad,? |Stupid,? ){2}/ ;
eval ' $db = new BerkeleyDB::Hash -Env => 2 ' ;
ok 3, $@ =~ /^Env not of type BerkeleyDB::Env/ ;
eval ' $db = new BerkeleyDB::Hash -Txn => "fred" ' ;
ok 4, $@ =~ /^Txn not of type BerkeleyDB::Txn/ ;
my $obj = bless [], "main" ;
eval ' $db = new BerkeleyDB::Hash -Env => $obj ' ;
ok 5, $@ =~ /^Env not of type BerkeleyDB::Env/ ;
}
# Now check the interface to HASH
{
my $lex = new LexFile $Dfile ;
ok 6, my $db = new BerkeleyDB::Hash -Filename => $Dfile,
-Flags => DB_CREATE ;
# Add a k/v pair
my $value ;
my $status ;
ok 7, $db->db_put("some key", "some value") == 0 ;
ok 8, $db->status() == 0 ;
ok 9, $db->db_get("some key", $value) == 0 ;
ok 10, $value eq "some value" ;
ok 11, $db->db_put("key", "value") == 0 ;
ok 12, $db->db_get("key", $value) == 0 ;
ok 13, $value eq "value" ;
ok 14, $db->db_del("some key") == 0 ;
ok 15, ($status = $db->db_get("some key", $value)) == DB_NOTFOUND ;
ok 16, $status eq $DB_errors{'DB_NOTFOUND'} ;
ok 17, $db->status() == DB_NOTFOUND ;
ok 18, $db->status() eq $DB_errors{'DB_NOTFOUND'};
ok 19, $db->db_sync() == 0 ;
# Check NOOVERWRITE will make put fail when attempting to overwrite
# an existing record.
ok 20, $db->db_put( 'key', 'x', DB_NOOVERWRITE) == DB_KEYEXIST ;
ok 21, $db->status() eq $DB_errors{'DB_KEYEXIST'};
ok 22, $db->status() == DB_KEYEXIST ;
# check that the value of the key has not been changed by the
# previous test
ok 23, $db->db_get("key", $value) == 0 ;
ok 24, $value eq "value" ;
# test DB_GET_BOTH
my ($k, $v) = ("key", "value") ;
ok 25, $db->db_get($k, $v, DB_GET_BOTH) == 0 ;
($k, $v) = ("key", "fred") ;
ok 26, $db->db_get($k, $v, DB_GET_BOTH) == DB_NOTFOUND ;
($k, $v) = ("another", "value") ;
ok 27, $db->db_get($k, $v, DB_GET_BOTH) == DB_NOTFOUND ;
}
{
# Check simple env works with a hash.
my $lex = new LexFile $Dfile ;
my $home = "./fred" ;
ok 28, my $lexD = new LexDir($home);
ok 29, my $env = new BerkeleyDB::Env -Flags => DB_CREATE| DB_INIT_MPOOL,@StdErrFile,
-Home => $home ;
ok 30, my $db = new BerkeleyDB::Hash -Filename => $Dfile,
-Env => $env,
-Flags => DB_CREATE ;
# Add a k/v pair
my $value ;
ok 31, $db->db_put("some key", "some value") == 0 ;
ok 32, $db->db_get("some key", $value) == 0 ;
ok 33, $value eq "some value" ;
undef $db ;
undef $env ;
}
{
# override default hash
my $lex = new LexFile $Dfile ;
my $value ;
$::count = 0 ;
ok 34, my $db = new BerkeleyDB::Hash -Filename => $Dfile,
-Hash => sub { ++$::count ; length $_[0] },
-Flags => DB_CREATE ;
ok 35, $db->db_put("some key", "some value") == 0 ;
ok 36, $db->db_get("some key", $value) == 0 ;
ok 37, $value eq "some value" ;
ok 38, $::count > 0 ;
}
{
# cursors
my $lex = new LexFile $Dfile ;
my %hash ;
my ($k, $v) ;
ok 39, my $db = new BerkeleyDB::Hash -Filename => $Dfile,
-Flags => DB_CREATE ;
# create some data
my %data = (
"red" => 2,
"green" => "house",
"blue" => "sea",
) ;
my $ret = 0 ;
while (($k, $v) = each %data) {
$ret += $db->db_put($k, $v) ;
}
ok 40, $ret == 0 ;
# create the cursor
ok 41, my $cursor = $db->db_cursor() ;
$k = $v = "" ;
my %copy = %data ;
my $extras = 0 ;
# sequence forwards
while ($cursor->c_get($k, $v, DB_NEXT) == 0) {
if ( $copy{$k} eq $v )
{ delete $copy{$k} }
else
{ ++ $extras }
}
ok 42, $cursor->status() == DB_NOTFOUND ;
ok 43, $cursor->status() eq $DB_errors{'DB_NOTFOUND'} ;
ok 44, keys %copy == 0 ;
ok 45, $extras == 0 ;
# sequence backwards
%copy = %data ;
$extras = 0 ;
my $status ;
for ( $status = $cursor->c_get($k, $v, DB_LAST) ;
$status == 0 ;
$status = $cursor->c_get($k, $v, DB_PREV)) {
if ( $copy{$k} eq $v )
{ delete $copy{$k} }
else
{ ++ $extras }
}
ok 46, $status == DB_NOTFOUND ;
ok 47, $status eq $DB_errors{'DB_NOTFOUND'} ;
ok 48, $cursor->status() == $status ;
ok 49, $cursor->status() eq $status ;
ok 50, keys %copy == 0 ;
ok 51, $extras == 0 ;
($k, $v) = ("green", "house") ;
ok 52, $cursor->c_get($k, $v, DB_GET_BOTH) == 0 ;
($k, $v) = ("green", "door") ;
ok 53, $cursor->c_get($k, $v, DB_GET_BOTH) == DB_NOTFOUND ;
($k, $v) = ("black", "house") ;
ok 54, $cursor->c_get($k, $v, DB_GET_BOTH) == DB_NOTFOUND ;
}
{
# Tied Hash interface
my $lex = new LexFile $Dfile ;
my %hash ;
ok 55, tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile,
-Flags => DB_CREATE ;
# check "each" with an empty database
my $count = 0 ;
while (my ($k, $v) = each %hash) {
++ $count ;
}
ok 56, (tied %hash)->status() == DB_NOTFOUND ;
ok 57, $count == 0 ;
# Add a k/v pair
my $value ;
$hash{"some key"} = "some value";
ok 58, (tied %hash)->status() == 0 ;
ok 59, $hash{"some key"} eq "some value";
ok 60, defined $hash{"some key"} ;
ok 61, (tied %hash)->status() == 0 ;
ok 62, exists $hash{"some key"} ;
ok 63, !defined $hash{"jimmy"} ;
ok 64, (tied %hash)->status() == DB_NOTFOUND ;
ok 65, !exists $hash{"jimmy"} ;
ok 66, (tied %hash)->status() == DB_NOTFOUND ;
delete $hash{"some key"} ;
ok 67, (tied %hash)->status() == 0 ;
ok 68, ! defined $hash{"some key"} ;
ok 69, (tied %hash)->status() == DB_NOTFOUND ;
ok 70, ! exists $hash{"some key"} ;
ok 71, (tied %hash)->status() == DB_NOTFOUND ;
$hash{1} = 2 ;
$hash{10} = 20 ;
$hash{1000} = 2000 ;
my ($keys, $values) = (0,0);
$count = 0 ;
while (my ($k, $v) = each %hash) {
$keys += $k ;
$values += $v ;
++ $count ;
}
ok 72, $count == 3 ;
ok 73, $keys == 1011 ;
ok 74, $values == 2022 ;
# now clear the hash
%hash = () ;
ok 75, keys %hash == 0 ;
untie %hash ;
}
{
# in-memory file
my $lex = new LexFile $Dfile ;
my %hash ;
my $fd ;
my $value ;
ok 76, my $db = tie %hash, 'BerkeleyDB::Hash'
or die $BerkeleyDB::Error;
ok 77, $db->db_put("some key", "some value") == 0 ;
ok 78, $db->db_get("some key", $value) == 0 ;
ok 79, $value eq "some value" ;
undef $db ;
untie %hash ;
}
{
# partial
# check works via API
my $lex = new LexFile $Dfile ;
my %hash ;
my $value ;
ok 80, my $db = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile,
-Flags => DB_CREATE ;
# create some data
my %data = (
"red" => "boat",
"green" => "house",
"blue" => "sea",
) ;
my $ret = 0 ;
while (my ($k, $v) = each %data) {
$ret += $db->db_put($k, $v) ;
}
ok 81, $ret == 0 ;
# do a partial get
my($pon, $off, $len) = $db->partial_set(0,2) ;
ok 82, $pon == 0 && $off == 0 && $len == 0 ;
ok 83, ( $db->db_get("red", $value) == 0) && $value eq "bo" ;
ok 84, ( $db->db_get("green", $value) == 0) && $value eq "ho" ;
ok 85, ( $db->db_get("blue", $value) == 0) && $value eq "se" ;
# do a partial get, off end of data
($pon, $off, $len) = $db->partial_set(3,2) ;
ok 86, $pon ;
ok 87, $off == 0 ;
ok 88, $len == 2 ;
ok 89, $db->db_get("red", $value) == 0 && $value eq "t" ;
ok 90, $db->db_get("green", $value) == 0 && $value eq "se" ;
ok 91, $db->db_get("blue", $value) == 0 && $value eq "" ;
# switch of partial mode
($pon, $off, $len) = $db->partial_clear() ;
ok 92, $pon ;
ok 93, $off == 3 ;
ok 94, $len == 2 ;
ok 95, $db->db_get("red", $value) == 0 && $value eq "boat" ;
ok 96, $db->db_get("green", $value) == 0 && $value eq "house" ;
ok 97, $db->db_get("blue", $value) == 0 && $value eq "sea" ;
# now partial put
($pon, $off, $len) = $db->partial_set(0,2) ;
ok 98, ! $pon ;
ok 99, $off == 0 ;
ok 100, $len == 0 ;
ok 101, $db->db_put("red", "") == 0 ;
ok 102, $db->db_put("green", "AB") == 0 ;
ok 103, $db->db_put("blue", "XYZ") == 0 ;
ok 104, $db->db_put("new", "KLM") == 0 ;
$db->partial_clear() ;
ok 105, $db->db_get("red", $value) == 0 && $value eq "at" ;
ok 106, $db->db_get("green", $value) == 0 && $value eq "ABuse" ;
ok 107, $db->db_get("blue", $value) == 0 && $value eq "XYZa" ;
ok 108, $db->db_get("new", $value) == 0 && $value eq "KLM" ;
# now partial put
$db->partial_set(3,2) ;
ok 109, $db->db_put("red", "PPP") == 0 ;
ok 110, $db->db_put("green", "Q") == 0 ;
ok 111, $db->db_put("blue", "XYZ") == 0 ;
ok 112, $db->db_put("new", "--") == 0 ;
($pon, $off, $len) = $db->partial_clear() ;
ok 113, $pon ;
ok 114, $off == 3 ;
ok 115, $len == 2 ;
ok 116, $db->db_get("red", $value) == 0 && $value eq "at\0PPP" ;
ok 117, $db->db_get("green", $value) == 0 && $value eq "ABuQ" ;
ok 118, $db->db_get("blue", $value) == 0 && $value eq "XYZXYZ" ;
ok 119, $db->db_get("new", $value) == 0 && $value eq "KLM--" ;
}
{
# partial
# check works via tied hash
my $lex = new LexFile $Dfile ;
my %hash ;
my $value ;
ok 120, my $db = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile,
-Flags => DB_CREATE ;
# create some data
my %data = (
"red" => "boat",
"green" => "house",
"blue" => "sea",
) ;
while (my ($k, $v) = each %data) {
$hash{$k} = $v ;
}
# do a partial get
$db->partial_set(0,2) ;
ok 121, $hash{"red"} eq "bo" ;
ok 122, $hash{"green"} eq "ho" ;
ok 123, $hash{"blue"} eq "se" ;
# do a partial get, off end of data
$db->partial_set(3,2) ;
ok 124, $hash{"red"} eq "t" ;
ok 125, $hash{"green"} eq "se" ;
ok 126, $hash{"blue"} eq "" ;
# switch of partial mode
$db->partial_clear() ;
ok 127, $hash{"red"} eq "boat" ;
ok 128, $hash{"green"} eq "house" ;
ok 129, $hash{"blue"} eq "sea" ;
# now partial put
$db->partial_set(0,2) ;
ok 130, $hash{"red"} = "" ;
ok 131, $hash{"green"} = "AB" ;
ok 132, $hash{"blue"} = "XYZ" ;
ok 133, $hash{"new"} = "KLM" ;
$db->partial_clear() ;
ok 134, $hash{"red"} eq "at" ;
ok 135, $hash{"green"} eq "ABuse" ;
ok 136, $hash{"blue"} eq "XYZa" ;
ok 137, $hash{"new"} eq "KLM" ;
# now partial put
$db->partial_set(3,2) ;
ok 138, $hash{"red"} = "PPP" ;
ok 139, $hash{"green"} = "Q" ;
ok 140, $hash{"blue"} = "XYZ" ;
ok 141, $hash{"new"} = "TU" ;
$db->partial_clear() ;
ok 142, $hash{"red"} eq "at\0PPP" ;
ok 143, $hash{"green"} eq "ABuQ" ;
ok 144, $hash{"blue"} eq "XYZXYZ" ;
ok 145, $hash{"new"} eq "KLMTU" ;
}
{
# transaction
my $lex = new LexFile $Dfile ;
my %hash ;
my $value ;
my $home = "./fred" ;
ok 146, my $lexD = new LexDir($home);
ok 147, my $env = new BerkeleyDB::Env -Home => $home,@StdErrFile,
-Flags => DB_CREATE|DB_INIT_TXN|
DB_INIT_MPOOL|DB_INIT_LOCK ;
ok 148, my $txn = $env->txn_begin() ;
ok 149, my $db1 = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile,
-Flags => DB_CREATE ,
-Env => $env,
-Txn => $txn ;
ok 150, $txn->txn_commit() == 0 ;
ok 151, $txn = $env->txn_begin() ;
$db1->Txn($txn);
# create some data
my %data = (
"red" => "boat",
"green" => "house",
"blue" => "sea",
) ;
my $ret = 0 ;
while (my ($k, $v) = each %data) {
$ret += $db1->db_put($k, $v) ;
}
ok 152, $ret == 0 ;
# should be able to see all the records
ok 153, my $cursor = $db1->db_cursor() ;
my ($k, $v) = ("", "") ;
my $count = 0 ;
# sequence forwards
while ($cursor->c_get($k, $v, DB_NEXT) == 0) {
++ $count ;
}
ok 154, $count == 3 ;
undef $cursor ;
# now abort the transaction
ok 155, $txn->txn_abort() == 0 ;
# there shouldn't be any records in the database
$count = 0 ;
# sequence forwards
ok 156, $cursor = $db1->db_cursor() ;
while ($cursor->c_get($k, $v, DB_NEXT) == 0) {
++ $count ;
}
ok 157, $count == 0 ;
undef $txn ;
undef $cursor ;
undef $db1 ;
undef $env ;
untie %hash ;
}
{
# DB_DUP
my $lex = new LexFile $Dfile ;
my %hash ;
ok 158, my $db = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile,
-Property => DB_DUP,
-Flags => DB_CREATE ;
$hash{'Wall'} = 'Larry' ;
$hash{'Wall'} = 'Stone' ;
$hash{'Smith'} = 'John' ;
$hash{'Wall'} = 'Brick' ;
$hash{'Wall'} = 'Brick' ;
$hash{'mouse'} = 'mickey' ;
ok 159, keys %hash == 6 ;
# create a cursor
ok 160, my $cursor = $db->db_cursor() ;
my $key = "Wall" ;
my $value ;
ok 161, $cursor->c_get($key, $value, DB_SET) == 0 ;
ok 162, $key eq "Wall" && $value eq "Larry" ;
ok 163, $cursor->c_get($key, $value, DB_NEXT) == 0 ;
ok 164, $key eq "Wall" && $value eq "Stone" ;
ok 165, $cursor->c_get($key, $value, DB_NEXT) == 0 ;
ok 166, $key eq "Wall" && $value eq "Brick" ;
ok 167, $cursor->c_get($key, $value, DB_NEXT) == 0 ;
ok 168, $key eq "Wall" && $value eq "Brick" ;
#my $ref = $db->db_stat() ;
#ok 143, $ref->{bt_flags} | DB_DUP ;
# test DB_DUP_NEXT
my ($k, $v) = ("Wall", "") ;
ok 169, $cursor->c_get($k, $v, DB_SET) == 0 ;
ok 170, $k eq "Wall" && $v eq "Larry" ;
ok 171, $cursor->c_get($k, $v, DB_NEXT_DUP) == 0 ;
ok 172, $k eq "Wall" && $v eq "Stone" ;
ok 173, $cursor->c_get($k, $v, DB_NEXT_DUP) == 0 ;
ok 174, $k eq "Wall" && $v eq "Brick" ;
ok 175, $cursor->c_get($k, $v, DB_NEXT_DUP) == 0 ;
ok 176, $k eq "Wall" && $v eq "Brick" ;
ok 177, $cursor->c_get($k, $v, DB_NEXT_DUP) == DB_NOTFOUND ;
undef $db ;
undef $cursor ;
untie %hash ;
}
{
# DB_DUP & DupCompare
my $lex = new LexFile $Dfile, $Dfile2;
my ($key, $value) ;
my (%h, %g) ;
my @Keys = qw( 0123 9 12 -1234 9 987654321 9 def ) ;
my @Values = qw( 1 11 3 dd x abc 2 0 ) ;
ok 178, tie %h, "BerkeleyDB::Hash", -Filename => $Dfile,
-DupCompare => sub { $_[0] cmp $_[1] },
-Property => DB_DUP|DB_DUPSORT,
-Flags => DB_CREATE ;
ok 179, tie %g, 'BerkeleyDB::Hash', -Filename => $Dfile2,
-DupCompare => sub { $_[0] <=> $_[1] },
-Property => DB_DUP|DB_DUPSORT,
-Flags => DB_CREATE ;
foreach (@Keys) {
local $^W = 0 ;
my $value = shift @Values ;
$h{$_} = $value ;
$g{$_} = $value ;
}
ok 180, my $cursor = (tied %h)->db_cursor() ;
$key = 9 ; $value = "";
ok 181, $cursor->c_get($key, $value, DB_SET) == 0 ;
ok 182, $key == 9 && $value eq 11 ;
ok 183, $cursor->c_get($key, $value, DB_NEXT) == 0 ;
ok 184, $key == 9 && $value == 2 ;
ok 185, $cursor->c_get($key, $value, DB_NEXT) == 0 ;
ok 186, $key == 9 && $value eq "x" ;
$cursor = (tied %g)->db_cursor() ;
$key = 9 ;
ok 187, $cursor->c_get($key, $value, DB_SET) == 0 ;
ok 188, $key == 9 && $value eq "x" ;
ok 189, $cursor->c_get($key, $value, DB_NEXT) == 0 ;
ok 190, $key == 9 && $value == 2 ;
ok 191, $cursor->c_get($key, $value, DB_NEXT) == 0 ;
ok 192, $key == 9 && $value == 11 ;
}
{
# get_dup etc
my $lex = new LexFile $Dfile;
my %hh ;
ok 193, my $YY = tie %hh, "BerkeleyDB::Hash", -Filename => $Dfile,
-DupCompare => sub { $_[0] cmp $_[1] },
-Property => DB_DUP,
-Flags => DB_CREATE ;
$hh{'Wall'} = 'Larry' ;
$hh{'Wall'} = 'Stone' ; # Note the duplicate key
$hh{'Wall'} = 'Brick' ; # Note the duplicate key
$hh{'Smith'} = 'John' ;
$hh{'mouse'} = 'mickey' ;
# first work in scalar context
ok 194, scalar $YY->get_dup('Unknown') == 0 ;
ok 195, scalar $YY->get_dup('Smith') == 1 ;
ok 196, scalar $YY->get_dup('Wall') == 3 ;
# now in list context
my @unknown = $YY->get_dup('Unknown') ;
ok 197, "@unknown" eq "" ;
my @smith = $YY->get_dup('Smith') ;
ok 198, "@smith" eq "John" ;
{
my @wall = $YY->get_dup('Wall') ;
my %wall ;
@wall{@wall} = @wall ;
ok 199, (@wall == 3 && $wall{'Larry'}
&& $wall{'Stone'} && $wall{'Brick'});
}
# hash
my %unknown = $YY->get_dup('Unknown', 1) ;
ok 200, keys %unknown == 0 ;
my %smith = $YY->get_dup('Smith', 1) ;
ok 201, keys %smith == 1 && $smith{'John'} ;
my %wall = $YY->get_dup('Wall', 1) ;
ok 202, keys %wall == 3 && $wall{'Larry'} == 1 && $wall{'Stone'} == 1
&& $wall{'Brick'} == 1 ;
undef $YY ;
untie %hh ;
}
{
# sub-class test
package Another ;
use strict ;
open(FILE, ">SubDB.pm") or die "Cannot open SubDB.pm: $!\n" ;
print FILE <<'EOM' ;
package SubDB ;
use strict ;
use vars qw( @ISA @EXPORT) ;
require Exporter ;
use BerkeleyDB;
@ISA=qw(BerkeleyDB BerkeleyDB::Hash);
@EXPORT = @BerkeleyDB::EXPORT ;
sub db_put {
my $self = shift ;
my $key = shift ;
my $value = shift ;
$self->SUPER::db_put($key, $value * 3) ;
}
sub db_get {
my $self = shift ;
$self->SUPER::db_get($_[0], $_[1]) ;
$_[1] -= 2 ;
}
sub A_new_method
{
my $self = shift ;
my $key = shift ;
my $value = $self->FETCH($key) ;
return "[[$value]]" ;
}
1 ;
EOM
close FILE ;
BEGIN { push @INC, '.'; }
eval 'use SubDB ; ';
main::ok 203, $@ eq "" ;
my %h ;
my $X ;
eval '
$X = tie(%h, "SubDB", -Filename => "dbhash.tmp",
-Flags => DB_CREATE,
-Mode => 0640 );
' ;
main::ok 204, $@ eq "" ;
my $ret = eval '$h{"fred"} = 3 ; return $h{"fred"} ' ;
main::ok 205, $@ eq "" ;
main::ok 206, $ret == 7 ;
my $value = 0;
$ret = eval '$X->db_put("joe", 4) ; $X->db_get("joe", $value) ; return $value' ;
main::ok 207, $@ eq "" ;
main::ok 208, $ret == 10 ;
$ret = eval ' DB_NEXT eq main::DB_NEXT ' ;
main::ok 209, $@ eq "" ;
main::ok 210, $ret == 1 ;
$ret = eval '$X->A_new_method("joe") ' ;
main::ok 211, $@ eq "" ;
main::ok 212, $ret eq "[[10]]" ;
unlink "SubDB.pm", "dbhash.tmp" ;
}

236
perl/BerkeleyDB/t/join.t Normal file
View File

@@ -0,0 +1,236 @@
#!./perl -w
# ID: %I%, %G%
use strict ;
use lib 't';
use BerkeleyDB;
use util ;
if ($BerkeleyDB::db_ver < 2.005002)
{
print "1..0 # Skip: join needs Berkeley DB 2.5.2 or later\n" ;
exit 0 ;
}
print "1..42\n";
my $Dfile1 = "dbhash1.tmp";
my $Dfile2 = "dbhash2.tmp";
my $Dfile3 = "dbhash3.tmp";
unlink $Dfile1, $Dfile2, $Dfile3 ;
umask(0) ;
{
# error cases
my $lex = new LexFile $Dfile1, $Dfile2, $Dfile3 ;
my %hash1 ;
my $value ;
my $status ;
my $cursor ;
ok 1, my $db1 = tie %hash1, 'BerkeleyDB::Hash',
-Filename => $Dfile1,
-Flags => DB_CREATE,
-DupCompare => sub { $_[0] lt $_[1] },
-Property => DB_DUP|DB_DUPSORT ;
# no cursors supplied
eval '$cursor = $db1->db_join() ;' ;
ok 2, $@ =~ /Usage: \$db->BerkeleyDB::db_join\Q([cursors], flags=0)/;
# empty list
eval '$cursor = $db1->db_join([]) ;' ;
ok 3, $@ =~ /db_join: No cursors in parameter list/;
# cursor list, isn not a []
eval '$cursor = $db1->db_join({}) ;' ;
ok 4, $@ =~ /db_join: first parameter is not an array reference/;
eval '$cursor = $db1->db_join(\1) ;' ;
ok 5, $@ =~ /db_join: first parameter is not an array reference/;
my ($a, $b) = ("a", "b");
$a = bless [], "fred";
$b = bless [], "fred";
eval '$cursor = $db1->db_join($a, $b) ;' ;
ok 6, $@ =~ /db_join: first parameter is not an array reference/;
}
{
# test a 2-way & 3-way join
my $lex = new LexFile $Dfile1, $Dfile2, $Dfile3 ;
my %hash1 ;
my %hash2 ;
my %hash3 ;
my $value ;
my $status ;
my $home = "./fred7" ;
rmtree $home;
ok 7, ! -d $home;
ok 8, my $lexD = new LexDir($home);
ok 9, my $env = new BerkeleyDB::Env -Home => $home, @StdErrFile,
-Flags => DB_CREATE|DB_INIT_TXN
|DB_INIT_MPOOL;
#|DB_INIT_MPOOL| DB_INIT_LOCK;
ok 10, my $txn = $env->txn_begin() ;
ok 11, my $db1 = tie %hash1, 'BerkeleyDB::Hash',
-Filename => $Dfile1,
-Flags => DB_CREATE,
-DupCompare => sub { $_[0] cmp $_[1] },
-Property => DB_DUP|DB_DUPSORT,
-Env => $env,
-Txn => $txn ;
;
ok 12, my $db2 = tie %hash2, 'BerkeleyDB::Hash',
-Filename => $Dfile2,
-Flags => DB_CREATE,
-DupCompare => sub { $_[0] cmp $_[1] },
-Property => DB_DUP|DB_DUPSORT,
-Env => $env,
-Txn => $txn ;
ok 13, my $db3 = tie %hash3, 'BerkeleyDB::Btree',
-Filename => $Dfile3,
-Flags => DB_CREATE,
-DupCompare => sub { $_[0] cmp $_[1] },
-Property => DB_DUP|DB_DUPSORT,
-Env => $env,
-Txn => $txn ;
ok 14, addData($db1, qw( apple Convenience
peach Shopway
pear Farmer
raspberry Shopway
strawberry Shopway
gooseberry Farmer
blueberry Farmer
));
ok 15, addData($db2, qw( red apple
red raspberry
red strawberry
yellow peach
yellow pear
green gooseberry
blue blueberry)) ;
ok 16, addData($db3, qw( expensive apple
reasonable raspberry
expensive strawberry
reasonable peach
reasonable pear
expensive gooseberry
reasonable blueberry)) ;
ok 17, my $cursor2 = $db2->db_cursor() ;
my $k = "red" ;
my $v = "" ;
ok 18, $cursor2->c_get($k, $v, DB_SET) == 0 ;
# Two way Join
ok 19, my $cursor1 = $db1->db_join([$cursor2]) ;
my %expected = qw( apple Convenience
raspberry Shopway
strawberry Shopway
) ;
# sequence forwards
while ($cursor1->c_get($k, $v) == 0) {
delete $expected{$k}
if defined $expected{$k} && $expected{$k} eq $v ;
#print "[$k] [$v]\n" ;
}
ok 20, keys %expected == 0 ;
ok 21, $cursor1->status() == DB_NOTFOUND ;
# Three way Join
ok 22, $cursor2 = $db2->db_cursor() ;
$k = "red" ;
$v = "" ;
ok 23, $cursor2->c_get($k, $v, DB_SET) == 0 ;
ok 24, my $cursor3 = $db3->db_cursor() ;
$k = "expensive" ;
$v = "" ;
ok 25, $cursor3->c_get($k, $v, DB_SET) == 0 ;
ok 26, $cursor1 = $db1->db_join([$cursor2, $cursor3]) ;
%expected = qw( apple Convenience
strawberry Shopway
) ;
# sequence forwards
while ($cursor1->c_get($k, $v) == 0) {
delete $expected{$k}
if defined $expected{$k} && $expected{$k} eq $v ;
#print "[$k] [$v]\n" ;
}
ok 27, keys %expected == 0 ;
ok 28, $cursor1->status() == DB_NOTFOUND ;
# test DB_JOIN_ITEM
# #################
ok 29, $cursor2 = $db2->db_cursor() ;
$k = "red" ;
$v = "" ;
ok 30, $cursor2->c_get($k, $v, DB_SET) == 0 ;
ok 31, $cursor3 = $db3->db_cursor() ;
$k = "expensive" ;
$v = "" ;
ok 32, $cursor3->c_get($k, $v, DB_SET) == 0 ;
ok 33, $cursor1 = $db1->db_join([$cursor2, $cursor3]) ;
%expected = qw( apple 1
strawberry 1
) ;
# sequence forwards
$k = "" ;
$v = "" ;
while ($cursor1->c_get($k, $v, DB_JOIN_ITEM) == 0) {
delete $expected{$k}
if defined $expected{$k} ;
#print "[$k]\n" ;
}
ok 34, keys %expected == 0 ;
ok 35, $cursor1->status() == DB_NOTFOUND ;
ok 36, $cursor1->c_close() == 0 ;
ok 37, $cursor2->c_close() == 0 ;
ok 38, $cursor3->c_close() == 0 ;
ok 39, ($status = $txn->txn_commit()) == 0;
undef $txn ;
ok 40, my $cursor1a = $db1->db_cursor() ;
eval { $cursor1 = $db1->db_join([$cursor1a]) };
ok 41, $@ =~ /BerkeleyDB Aborting: attempted to do a self-join at/;
eval { $cursor1 = $db1->db_join([$cursor1]) } ;
ok 42, $@ =~ /BerkeleyDB Aborting: attempted to do a self-join at/;
undef $cursor1a;
#undef $cursor1;
#undef $cursor2;
#undef $cursor3;
undef $db1 ;
undef $db2 ;
undef $db3 ;
undef $env ;
untie %hash1 ;
untie %hash2 ;
untie %hash3 ;
}
print "# at the end\n";

111
perl/BerkeleyDB/t/mldbm.t Normal file
View File

@@ -0,0 +1,111 @@
#!/usr/bin/perl -w
use strict ;
BEGIN
{
if ($] < 5.005) {
print "1..0 # Skip: this is Perl $], skipping test\n" ;
exit 0 ;
}
eval { require Data::Dumper ; };
if ($@) {
print "1..0 # Skip: Data::Dumper is not installed on this system.\n";
exit 0 ;
}
{
local ($^W) = 0 ;
if ($Data::Dumper::VERSION < 2.08) {
print "1..0 # Skip: Data::Dumper 2.08 or better required (found $Data::Dumper::VERSION).\n";
exit 0 ;
}
}
eval { require MLDBM ; };
if ($@) {
print "1..0 # Skip: MLDBM is not installed on this system.\n";
exit 0 ;
}
}
use lib 't' ;
use util ;
print "1..12\n";
{
package BTREE ;
use BerkeleyDB ;
use MLDBM qw(BerkeleyDB::Btree) ;
use Data::Dumper;
my $filename = "";
my $lex = new LexFile $filename;
$MLDBM::UseDB = "BerkeleyDB::Btree" ;
my %o ;
my $db = tie %o, 'MLDBM', -Filename => $filename,
-Flags => DB_CREATE
or die $!;
::ok 1, $db ;
::ok 2, $db->type() == DB_BTREE ;
my $c = [\'c'];
my $b = {};
my $a = [1, $b, $c];
$b->{a} = $a;
$b->{b} = $a->[1];
$b->{c} = $a->[2];
@o{qw(a b c)} = ($a, $b, $c);
$o{d} = "{once upon a time}";
$o{e} = 1024;
$o{f} = 1024.1024;
my $struct = [@o{qw(a b c)}];
::ok 3, ::_compare([$a, $b, $c], $struct);
::ok 4, $o{d} eq "{once upon a time}" ;
::ok 5, $o{e} == 1024 ;
::ok 6, $o{f} eq 1024.1024 ;
}
{
package HASH ;
use BerkeleyDB ;
use MLDBM qw(BerkeleyDB::Hash) ;
use Data::Dumper;
my $filename = "";
my $lex = new LexFile $filename;
unlink $filename ;
$MLDBM::UseDB = "BerkeleyDB::Hash" ;
my %o ;
my $db = tie %o, 'MLDBM', -Filename => $filename,
-Flags => DB_CREATE
or die $!;
::ok 7, $db ;
::ok 8, $db->type() == DB_HASH ;
my $c = [\'c'];
my $b = {};
my $a = [1, $b, $c];
$b->{a} = $a;
$b->{b} = $a->[1];
$b->{c} = $a->[2];
@o{qw(a b c)} = ($a, $b, $c);
$o{d} = "{once upon a time}";
$o{e} = 1024;
$o{f} = 1024.1024;
my $struct = [@o{qw(a b c)}];
::ok 9, ::_compare([$a, $b, $c], $struct);
::ok 10, $o{d} eq "{once upon a time}" ;
::ok 11, $o{e} == 1024 ;
::ok 12, $o{f} eq 1024.1024 ;
}

18
perl/BerkeleyDB/t/pod.t Normal file
View File

@@ -0,0 +1,18 @@
eval " use Test::More " ;
if ($@)
{
print "1..0 # Skip: Test::More required for testing POD\n" ;
exit 0;
}
eval "use Test::Pod 1.00";
if ($@)
{
print "1..0 # Skip: Test::Pod 1.00 required for testing POD\n" ;
exit 0;
}
all_pod_files_ok();

866
perl/BerkeleyDB/t/queue.t Normal file
View File

@@ -0,0 +1,866 @@
#!./perl -w
# ID: %I%, %G%
use strict ;
use lib 't' ;
use BerkeleyDB;
use Test::More;
use util(1) ;
plan(skip_all => "Queue needs Berkeley DB 3.3.x or better\n" )
if $BerkeleyDB::db_version < 3.3;
plan tests => 253;
my $Dfile = "dbhash.tmp";
my $Dfile2 = "dbhash2.tmp";
my $Dfile3 = "dbhash3.tmp";
unlink $Dfile;
umask(0) ;
# Check for invalid parameters
{
# Check for invalid parameters
my $db ;
eval ' $db = new BerkeleyDB::Queue -Stupid => 3 ; ' ;
ok $@ =~ /unknown key value\(s\) Stupid/ ;
eval ' $db = new BerkeleyDB::Queue -Bad => 2, -Mode => 0345, -Stupid => 3; ' ;
ok $@ =~ /unknown key value\(s\) / ;
eval ' $db = new BerkeleyDB::Queue -Env => 2 ' ;
ok $@ =~ /^Env not of type BerkeleyDB::Env/ ;
eval ' $db = new BerkeleyDB::Queue -Txn => "x" ' ;
ok $@ =~ /^Txn not of type BerkeleyDB::Txn/ ;
my $obj = bless [], "main" ;
eval ' $db = new BerkeleyDB::Queue -Env => $obj ' ;
ok $@ =~ /^Env not of type BerkeleyDB::Env/ ;
}
# Now check the interface to Queue
{
my $lex = new LexFile $Dfile ;
my $rec_len = 10 ;
my $pad = "x" ;
ok my $db = new BerkeleyDB::Queue -Filename => $Dfile,
-Flags => DB_CREATE,
-Len => $rec_len,
-Pad => $pad;
# Add a k/v pair
my $value ;
my $status ;
ok $db->db_put(1, "some value") == 0 ;
ok $db->status() == 0 ;
ok $db->db_get(1, $value) == 0 ;
ok $value eq fillout("some value", $rec_len, $pad) ;
ok $db->db_put(2, "value") == 0 ;
ok $db->db_get(2, $value) == 0 ;
ok $value eq fillout("value", $rec_len, $pad) ;
ok $db->db_put(3, "value") == 0 ;
ok $db->db_get(3, $value) == 0 ;
ok $value eq fillout("value", $rec_len, $pad) ;
ok $db->db_del(2) == 0 ;
ok $db->db_get(2, $value) == DB_KEYEMPTY ;
ok $db->status() == DB_KEYEMPTY ;
ok $db->status() eq $DB_errors{'DB_KEYEMPTY'} ;
ok $db->db_get(7, $value) == DB_NOTFOUND ;
ok $db->status() == DB_NOTFOUND ;
ok $db->status() eq $DB_errors{'DB_NOTFOUND'} ;
ok $db->db_sync() == 0 ;
# Check NOOVERWRITE will make put fail when attempting to overwrite
# an existing record.
ok $db->db_put( 1, 'x', DB_NOOVERWRITE) == DB_KEYEXIST ;
ok $db->status() eq $DB_errors{'DB_KEYEXIST'} ;
ok $db->status() == DB_KEYEXIST ;
# check that the value of the key has not been changed by the
# previous test
ok $db->db_get(1, $value) == 0 ;
ok $value eq fillout("some value", $rec_len, $pad) ;
}
{
# Check simple env works with a array.
# and pad defaults to space
my $lex = new LexFile $Dfile ;
my $home = "./fred" ;
my $rec_len = 11 ;
ok my $lexD = new LexDir($home);
ok my $env = new BerkeleyDB::Env -Flags => DB_CREATE|DB_INIT_MPOOL,@StdErrFile,
-Home => $home ;
ok my $db = new BerkeleyDB::Queue -Filename => $Dfile,
-Env => $env,
-Flags => DB_CREATE,
-Len => $rec_len;
# Add a k/v pair
my $value ;
ok $db->db_put(1, "some value") == 0 ;
ok $db->db_get(1, $value) == 0 ;
ok $value eq fillout("some value", $rec_len) ;
undef $db ;
undef $env ;
}
{
# cursors
my $lex = new LexFile $Dfile ;
my @array ;
my ($k, $v) ;
my $rec_len = 5 ;
ok my $db = new BerkeleyDB::Queue -Filename => $Dfile,
-ArrayBase => 0,
-Flags => DB_CREATE ,
-Len => $rec_len;
# create some data
my @data = (
"red" ,
"green" ,
"blue" ,
) ;
my $i ;
my %data ;
my $ret = 0 ;
for ($i = 0 ; $i < @data ; ++$i) {
$ret += $db->db_put($i, $data[$i]) ;
$data{$i} = $data[$i] ;
}
ok $ret == 0 ;
# create the cursor
ok my $cursor = $db->db_cursor() ;
$k = 0 ; $v = "" ;
my %copy = %data;
my $extras = 0 ;
# sequence forwards
while ($cursor->c_get($k, $v, DB_NEXT) == 0)
{
if ( fillout($copy{$k}, $rec_len) eq $v )
{ delete $copy{$k} }
else
{ ++ $extras }
}
ok $cursor->status() == DB_NOTFOUND ;
ok $cursor->status() eq $DB_errors{'DB_NOTFOUND'} ;
ok keys %copy == 0 ;
ok $extras == 0 ;
# sequence backwards
%copy = %data ;
$extras = 0 ;
my $status ;
for ( $status = $cursor->c_get($k, $v, DB_LAST) ;
$status == 0 ;
$status = $cursor->c_get($k, $v, DB_PREV)) {
if ( fillout($copy{$k}, $rec_len) eq $v )
{ delete $copy{$k} }
else
{ ++ $extras }
}
ok $status == DB_NOTFOUND ;
ok $status eq $DB_errors{'DB_NOTFOUND'} ;
ok $cursor->status() == $status ;
ok $cursor->status() eq $status ;
ok keys %copy == 0 ;
ok $extras == 0 ;
}
{
# Tied Array interface
my $lex = new LexFile $Dfile ;
my @array ;
my $db ;
my $rec_len = 10 ;
ok $db = tie @array, 'BerkeleyDB::Queue', -Filename => $Dfile,
-ArrayBase => 0,
-Flags => DB_CREATE ,
-Len => $rec_len;
ok my $cursor = (tied @array)->db_cursor() ;
# check the database is empty
my $count = 0 ;
my ($k, $v) = (0,"") ;
while ($cursor->c_get($k, $v, DB_NEXT) == 0) {
++ $count ;
}
ok $cursor->status() == DB_NOTFOUND ;
ok $count == 0 ;
ok @array == 0 ;
# Add a k/v pair
my $value ;
$array[1] = "some value";
ok ((tied @array)->status() == 0) ;
ok $array[1] eq fillout("some value", $rec_len);
ok defined $array[1];
ok ((tied @array)->status() == 0) ;
ok !defined $array[3];
ok ((tied @array)->status() == DB_NOTFOUND) ;
$array[1] = 2 ;
$array[10] = 20 ;
$array[100] = 200 ;
my ($keys, $values) = (0,0);
$count = 0 ;
for ( my $status = $cursor->c_get($k, $v, DB_FIRST) ;
$status == 0 ;
$status = $cursor->c_get($k, $v, DB_NEXT)) {
$keys += $k ;
$values += $v ;
++ $count ;
}
ok $count == 3 ;
ok $keys == 111 ;
ok $values == 222 ;
# unshift isn't allowed
# eval {
# $FA ? unshift @array, "red", "green", "blue"
# : $db->unshift("red", "green", "blue" ) ;
# } ;
# ok $@ =~ /^unshift is unsupported with Queue databases/ ;
$array[0] = "red" ;
$array[1] = "green" ;
$array[2] = "blue" ;
$array[4] = 2 ;
ok $array[0] eq fillout("red", $rec_len) ;
ok $cursor->c_get($k, $v, DB_FIRST) == 0 ;
ok $k == 0 ;
ok $v eq fillout("red", $rec_len) ;
ok $array[1] eq fillout("green", $rec_len) ;
ok $cursor->c_get($k, $v, DB_NEXT) == 0 ;
ok $k == 1 ;
ok $v eq fillout("green", $rec_len) ;
ok $array[2] eq fillout("blue", $rec_len) ;
ok $cursor->c_get($k, $v, DB_NEXT) == 0 ;
ok $k == 2 ;
ok $v eq fillout("blue", $rec_len) ;
ok $array[4] == 2 ;
ok $cursor->c_get($k, $v, DB_NEXT) == 0 ;
ok $k == 4 ;
ok $v == 2 ;
# shift
ok (($FA ? shift @array : $db->shift()) eq fillout("red", $rec_len)) ;
ok (($FA ? shift @array : $db->shift()) eq fillout("green", $rec_len)) ;
ok (($FA ? shift @array : $db->shift()) eq fillout("blue", $rec_len)) ;
ok (($FA ? shift @array : $db->shift()) == 2) ;
# push
$FA ? push @array, "the", "end"
: $db->push("the", "end") ;
ok $cursor->c_get($k, $v, DB_LAST) == 0 ;
ok $k == 102 ;
ok $v eq fillout("end", $rec_len) ;
ok $cursor->c_get($k, $v, DB_PREV) == 0 ;
ok $k == 101 ;
ok $v eq fillout("the", $rec_len) ;
ok $cursor->c_get($k, $v, DB_PREV) == 0 ;
ok $k == 100 ;
ok $v == 200 ;
# pop
ok (( $FA ? pop @array : $db->pop ) eq fillout("end", $rec_len)) ;
ok (( $FA ? pop @array : $db->pop ) eq fillout("the", $rec_len)) ;
ok (( $FA ? pop @array : $db->pop ) == 200) ;
# now clear the array
$FA ? @array = ()
: $db->clear() ;
ok $cursor->c_get($k, $v, DB_FIRST) == DB_NOTFOUND ;
undef $cursor ;
undef $db ;
untie @array ;
}
{
# in-memory file
my @array ;
my $fd ;
my $value ;
my $rec_len = 15 ;
ok my $db = tie @array, 'BerkeleyDB::Queue',
-Len => $rec_len;
ok $db->db_put(1, "some value") == 0 ;
ok $db->db_get(1, $value) == 0 ;
ok $value eq fillout("some value", $rec_len) ;
}
{
# partial
# check works via API
my $lex = new LexFile $Dfile ;
my $value ;
my $rec_len = 8 ;
ok my $db = new BerkeleyDB::Queue -Filename => $Dfile,
-Flags => DB_CREATE ,
-Len => $rec_len,
-Pad => " " ;
# create some data
my @data = (
"",
"boat",
"house",
"sea",
) ;
my $ret = 0 ;
my $i ;
for ($i = 0 ; $i < @data ; ++$i) {
my $r = $db->db_put($i, $data[$i]) ;
$ret += $r ;
}
ok $ret == 0 ;
# do a partial get
my ($pon, $off, $len) = $db->partial_set(0,2) ;
ok ! $pon && $off == 0 && $len == 0 ;
ok $db->db_get(1, $value) == 0 && $value eq "bo" ;
ok $db->db_get(2, $value) == 0 && $value eq "ho" ;
ok $db->db_get(3, $value) == 0 && $value eq "se" ;
# do a partial get, off end of data
($pon, $off, $len) = $db->partial_set(3,2) ;
ok $pon ;
ok $off == 0 ;
ok $len == 2 ;
ok $db->db_get(1, $value) == 0 && $value eq fillout("t", 2) ;
ok $db->db_get(2, $value) == 0 && $value eq "se" ;
ok $db->db_get(3, $value) == 0 && $value eq " " ;
# switch of partial mode
($pon, $off, $len) = $db->partial_clear() ;
ok $pon ;
ok $off == 3 ;
ok $len == 2 ;
ok $db->db_get(1, $value) == 0 && $value eq fillout("boat", $rec_len) ;
ok $db->db_get(2, $value) == 0 && $value eq fillout("house", $rec_len) ;
ok $db->db_get(3, $value) == 0 && $value eq fillout("sea", $rec_len) ;
# now partial put
$db->partial_set(0,2) ;
ok $db->db_put(1, "") != 0 ;
ok $db->db_put(2, "AB") == 0 ;
ok $db->db_put(3, "XY") == 0 ;
ok $db->db_put(4, "KLM") != 0 ;
ok $db->db_put(4, "KL") == 0 ;
($pon, $off, $len) = $db->partial_clear() ;
ok $pon ;
ok $off == 0 ;
ok $len == 2 ;
ok $db->db_get(1, $value) == 0 && $value eq fillout("boat", $rec_len) ;
ok $db->db_get(2, $value) == 0 && $value eq fillout("ABuse", $rec_len) ;
ok $db->db_get(3, $value) == 0 && $value eq fillout("XYa", $rec_len) ;
ok $db->db_get(4, $value) == 0 && $value eq fillout("KL", $rec_len) ;
# now partial put
($pon, $off, $len) = $db->partial_set(3,2) ;
ok ! $pon ;
ok $off == 0 ;
ok $len == 0 ;
ok $db->db_put(1, "PP") == 0 ;
ok $db->db_put(2, "Q") != 0 ;
ok $db->db_put(3, "XY") == 0 ;
ok $db->db_put(4, "TU") == 0 ;
$db->partial_clear() ;
ok $db->db_get(1, $value) == 0 && $value eq fillout("boaPP", $rec_len) ;
ok $db->db_get(2, $value) == 0 && $value eq fillout("ABuse",$rec_len) ;
ok $db->db_get(3, $value) == 0 && $value eq fillout("XYaXY", $rec_len) ;
ok $db->db_get(4, $value) == 0 && $value eq fillout("KL TU", $rec_len) ;
}
{
# partial
# check works via tied array
my $lex = new LexFile $Dfile ;
my @array ;
my $value ;
my $rec_len = 8 ;
ok my $db = tie @array, 'BerkeleyDB::Queue', -Filename => $Dfile,
-Flags => DB_CREATE ,
-Len => $rec_len,
-Pad => " " ;
# create some data
my @data = (
"",
"boat",
"house",
"sea",
) ;
my $i ;
my $status = 0 ;
for ($i = 1 ; $i < @data ; ++$i) {
$array[$i] = $data[$i] ;
$status += $db->status() ;
}
ok $status == 0 ;
# do a partial get
$db->partial_set(0,2) ;
ok $array[1] eq fillout("bo", 2) ;
ok $array[2] eq fillout("ho", 2) ;
ok $array[3] eq fillout("se", 2) ;
# do a partial get, off end of data
$db->partial_set(3,2) ;
ok $array[1] eq fillout("t", 2) ;
ok $array[2] eq fillout("se", 2) ;
ok $array[3] eq fillout("", 2) ;
# switch of partial mode
$db->partial_clear() ;
ok $array[1] eq fillout("boat", $rec_len) ;
ok $array[2] eq fillout("house", $rec_len) ;
ok $array[3] eq fillout("sea", $rec_len) ;
# now partial put
$db->partial_set(0,2) ;
$array[1] = "" ;
ok $db->status() != 0 ;
$array[2] = "AB" ;
ok $db->status() == 0 ;
$array[3] = "XY" ;
ok $db->status() == 0 ;
$array[4] = "KL" ;
ok $db->status() == 0 ;
$db->partial_clear() ;
ok $array[1] eq fillout("boat", $rec_len) ;
ok $array[2] eq fillout("ABuse", $rec_len) ;
ok $array[3] eq fillout("XYa", $rec_len) ;
ok $array[4] eq fillout("KL", $rec_len) ;
# now partial put
$db->partial_set(3,2) ;
$array[1] = "PP" ;
ok $db->status() == 0 ;
$array[2] = "Q" ;
ok $db->status() != 0 ;
$array[3] = "XY" ;
ok $db->status() == 0 ;
$array[4] = "TU" ;
ok $db->status() == 0 ;
$db->partial_clear() ;
ok $array[1] eq fillout("boaPP", $rec_len) ;
ok $array[2] eq fillout("ABuse", $rec_len) ;
ok $array[3] eq fillout("XYaXY", $rec_len) ;
ok $array[4] eq fillout("KL TU", $rec_len) ;
}
{
# transaction
my $lex = new LexFile $Dfile ;
my @array ;
my $value ;
my $home = "./fred" ;
ok my $lexD = new LexDir($home);
my $rec_len = 9 ;
ok my $env = new BerkeleyDB::Env -Home => $home,@StdErrFile,
-Flags => DB_CREATE|DB_INIT_TXN|
DB_INIT_MPOOL|DB_INIT_LOCK ;
ok my $txn = $env->txn_begin() ;
ok my $db1 = tie @array, 'BerkeleyDB::Queue',
-Filename => $Dfile,
-ArrayBase => 0,
-Flags => DB_CREATE ,
-Env => $env,
-Txn => $txn ,
-Len => $rec_len,
-Pad => " " ;
ok $txn->txn_commit() == 0 ;
ok $txn = $env->txn_begin() ;
$db1->Txn($txn);
# create some data
my @data = (
"boat",
"house",
"sea",
) ;
my $ret = 0 ;
my $i ;
for ($i = 0 ; $i < @data ; ++$i) {
$ret += $db1->db_put($i, $data[$i]) ;
}
ok $ret == 0 ;
# should be able to see all the records
ok my $cursor = $db1->db_cursor() ;
my ($k, $v) = (0, "") ;
my $count = 0 ;
# sequence forwards
while ($cursor->c_get($k, $v, DB_NEXT) == 0) {
++ $count ;
}
ok $count == 3 ;
undef $cursor ;
# now abort the transaction
ok $txn->txn_abort() == 0 ;
# there shouldn't be any records in the database
$count = 0 ;
# sequence forwards
ok $cursor = $db1->db_cursor() ;
while ($cursor->c_get($k, $v, DB_NEXT) == 0) {
++ $count ;
}
ok $count == 0 ;
undef $txn ;
undef $cursor ;
undef $db1 ;
undef $env ;
untie @array ;
}
{
# db_stat
my $lex = new LexFile $Dfile ;
my $recs = ($BerkeleyDB::db_version >= 3.1 ? "qs_ndata" : "qs_nrecs") ;
my @array ;
my ($k, $v) ;
my $rec_len = 7 ;
ok my $db = new BerkeleyDB::Queue -Filename => $Dfile,
-Flags => DB_CREATE,
-Pagesize => 4 * 1024,
-Len => $rec_len,
-Pad => " "
;
my $ref = $db->db_stat() ;
ok $ref->{$recs} == 0;
ok $ref->{'qs_pagesize'} == 4 * 1024;
# create some data
my @data = (
2,
"house",
"sea",
) ;
my $ret = 0 ;
my $i ;
for ($i = $db->ArrayOffset ; @data ; ++$i) {
$ret += $db->db_put($i, shift @data) ;
}
ok $ret == 0 ;
$ref = $db->db_stat() ;
ok $ref->{$recs} == 3;
}
{
# sub-class test
package Another ;
use strict ;
open(FILE, ">SubDB.pm") or die "Cannot open SubDB.pm: $!\n" ;
print FILE <<'EOM' ;
package SubDB ;
use strict ;
use vars qw( @ISA @EXPORT) ;
require Exporter ;
use BerkeleyDB;
@ISA=qw(BerkeleyDB BerkeleyDB::Queue);
@EXPORT = @BerkeleyDB::EXPORT ;
sub db_put {
my $self = shift ;
my $key = shift ;
my $value = shift ;
$self->SUPER::db_put($key, $value * 3) ;
}
sub db_get {
my $self = shift ;
$self->SUPER::db_get($_[0], $_[1]) ;
$_[1] -= 2 ;
}
sub A_new_method
{
my $self = shift ;
my $key = shift ;
my $value = $self->FETCH($key) ;
return "[[$value]]" ;
}
1 ;
EOM
close FILE ;
BEGIN { push @INC, '.'; }
eval 'use SubDB ; ';
main::ok $@ eq "" ;
my @h ;
my $X ;
my $rec_len = 34 ;
eval '
$X = tie(@h, "SubDB", -Filename => "dbqueue.tmp",
-Flags => DB_CREATE,
-Mode => 0640 ,
-Len => $rec_len,
-Pad => " "
);
' ;
main::ok $@ eq "" ;
my $ret = eval '$h[1] = 3 ; return $h[1] ' ;
main::ok $@ eq "" ;
main::ok $ret == 7 ;
my $value = 0;
$ret = eval '$X->db_put(1, 4) ; $X->db_get(1, $value) ; return $value' ;
main::ok $@ eq "" ;
main::ok $ret == 10 ;
$ret = eval ' DB_NEXT eq main::DB_NEXT ' ;
main::ok $@ eq "" ;
main::ok $ret == 1 ;
$ret = eval '$X->A_new_method(1) ' ;
main::ok $@ eq "" ;
main::ok $ret eq "[[10]]" ;
undef $X ;
untie @h ;
unlink "SubDB.pm", "dbqueue.tmp" ;
}
{
# DB_APPEND
my $lex = new LexFile $Dfile;
my @array ;
my $value ;
my $rec_len = 21 ;
ok my $db = tie @array, 'BerkeleyDB::Queue',
-Filename => $Dfile,
-Flags => DB_CREATE ,
-Len => $rec_len,
-Pad => " " ;
# create a few records
$array[1] = "def" ;
$array[3] = "ghi" ;
my $k = 0 ;
ok $db->db_put($k, "fred", DB_APPEND) == 0 ;
ok $k == 4 ;
ok $array[4] eq fillout("fred", $rec_len) ;
undef $db ;
untie @array ;
}
{
# 23 Sept 2001 -- push into an empty array
my $lex = new LexFile $Dfile ;
my @array ;
my $db ;
my $rec_len = 21 ;
ok $db = tie @array, 'BerkeleyDB::Queue',
-Flags => DB_CREATE ,
-ArrayBase => 0,
-Len => $rec_len,
-Pad => " " ,
-Filename => $Dfile ;
$FA ? push @array, "first"
: $db->push("first") ;
ok (($FA ? pop @array : $db->pop()) eq fillout("first", $rec_len)) ;
undef $db;
untie @array ;
}
{
# Tied Array interface with transactions
my $lex = new LexFile $Dfile ;
my @array ;
my $db ;
my $rec_len = 10 ;
my $home = "./fred" ;
ok my $lexD = new LexDir($home);
ok my $env = new BerkeleyDB::Env -Home => $home,@StdErrFile,
-Flags => DB_CREATE|DB_INIT_TXN|
DB_INIT_MPOOL|DB_INIT_LOCK ;
ok my $txn = $env->txn_begin() ;
ok $db = tie @array, 'BerkeleyDB::Queue', -Filename => $Dfile,
-ArrayBase => 0,
-Flags => DB_CREATE ,
-Env => $env ,
-Txn => $txn ,
-Len => $rec_len;
ok $txn->txn_commit() == 0 ;
ok $txn = $env->txn_begin() ;
$db->Txn($txn);
ok my $cursor = (tied @array)->db_cursor() ;
# check the database is empty
my $count = 0 ;
my ($k, $v) = (0,"") ;
while ($cursor->c_get($k, $v, DB_NEXT) == 0) {
++ $count ;
}
ok $cursor->status() == DB_NOTFOUND ;
ok $count == 0 ;
ok @array == 0 ;
# Add a k/v pair
my $value ;
$array[1] = "some value";
ok ((tied @array)->status() == 0) ;
ok $array[1] eq fillout("some value", $rec_len);
ok defined $array[1];
ok ((tied @array)->status() == 0) ;
ok !defined $array[3];
ok ((tied @array)->status() == DB_NOTFOUND) ;
$array[1] = 2 ;
$array[10] = 20 ;
$array[100] = 200 ;
my ($keys, $values) = (0,0);
$count = 0 ;
for ( my $status = $cursor->c_get($k, $v, DB_FIRST) ;
$status == 0 ;
$status = $cursor->c_get($k, $v, DB_NEXT)) {
$keys += $k ;
$values += $v ;
++ $count ;
}
ok $count == 3 ;
ok $keys == 111 ;
ok $values == 222 ;
# unshift isn't allowed
# eval {
# $FA ? unshift @array, "red", "green", "blue"
# : $db->unshift("red", "green", "blue" ) ;
# } ;
# ok $@ =~ /^unshift is unsupported with Queue databases/ ;
$array[0] = "red" ;
$array[1] = "green" ;
$array[2] = "blue" ;
$array[4] = 2 ;
ok $array[0] eq fillout("red", $rec_len) ;
ok $cursor->c_get($k, $v, DB_FIRST) == 0 ;
ok $k == 0 ;
ok $v eq fillout("red", $rec_len) ;
ok $array[1] eq fillout("green", $rec_len) ;
ok $cursor->c_get($k, $v, DB_NEXT) == 0 ;
ok $k == 1 ;
ok $v eq fillout("green", $rec_len) ;
ok $array[2] eq fillout("blue", $rec_len) ;
ok $cursor->c_get($k, $v, DB_NEXT) == 0 ;
ok $k == 2 ;
ok $v eq fillout("blue", $rec_len) ;
ok $array[4] == 2 ;
ok $cursor->c_get($k, $v, DB_NEXT) == 0 ;
ok $k == 4 ;
ok $v == 2 ;
# shift
ok (($FA ? shift @array : $db->shift()) eq fillout("red", $rec_len)) ;
ok (($FA ? shift @array : $db->shift()) eq fillout("green", $rec_len)) ;
ok (($FA ? shift @array : $db->shift()) eq fillout("blue", $rec_len)) ;
ok (($FA ? shift @array : $db->shift()) == 2) ;
# push
$FA ? push @array, "the", "end"
: $db->push("the", "end") ;
ok $cursor->c_get($k, $v, DB_LAST) == 0 ;
ok $k == 102 ;
ok $v eq fillout("end", $rec_len) ;
ok $cursor->c_get($k, $v, DB_PREV) == 0 ;
ok $k == 101 ;
ok $v eq fillout("the", $rec_len) ;
ok $cursor->c_get($k, $v, DB_PREV) == 0 ;
ok $k == 100 ;
ok $v == 200 ;
# pop
ok (( $FA ? pop @array : $db->pop ) eq fillout("end", $rec_len)) ;
ok (( $FA ? pop @array : $db->pop ) eq fillout("the", $rec_len)) ;
ok (( $FA ? pop @array : $db->pop ) == 200 ) ;
# now clear the array
$FA ? @array = ()
: $db->clear() ;
ok $cursor->c_get($k, $v, DB_FIRST) == DB_NOTFOUND ;
undef $cursor ;
ok $txn->txn_commit() == 0 ;
undef $db ;
untie @array ;
}
__END__
# TODO
#
# DB_DELIMETER DB_FIXEDLEN DB_PAD DB_SNAPSHOT with partial records

907
perl/BerkeleyDB/t/recno.t Normal file
View File

@@ -0,0 +1,907 @@
#!./perl -w
# ID: %I%, %G%
use strict ;
use lib 't' ;
use BerkeleyDB;
use util ;
print "1..226\n";
my $Dfile = "dbhash.tmp";
my $Dfile2 = "dbhash2.tmp";
my $Dfile3 = "dbhash3.tmp";
unlink $Dfile;
umask(0) ;
# Check for invalid parameters
{
# Check for invalid parameters
my $db ;
eval ' $db = new BerkeleyDB::Recno -Stupid => 3 ; ' ;
ok 1, $@ =~ /unknown key value\(s\) Stupid/ ;
eval ' $db = new BerkeleyDB::Recno -Bad => 2, -Mode => 0345, -Stupid => 3; ' ;
ok 2, $@ =~ /unknown key value\(s\) / ;
eval ' $db = new BerkeleyDB::Recno -Env => 2 ' ;
ok 3, $@ =~ /^Env not of type BerkeleyDB::Env/ ;
eval ' $db = new BerkeleyDB::Recno -Txn => "x" ' ;
ok 4, $@ =~ /^Txn not of type BerkeleyDB::Txn/ ;
my $obj = bless [], "main" ;
eval ' $db = new BerkeleyDB::Recno -Env => $obj ' ;
ok 5, $@ =~ /^Env not of type BerkeleyDB::Env/ ;
}
# Now check the interface to Recno
{
my $lex = new LexFile $Dfile ;
ok 6, my $db = new BerkeleyDB::Recno -Filename => $Dfile,
-Flags => DB_CREATE ;
# Add a k/v pair
my $value ;
my $status ;
ok 7, $db->db_put(1, "some value") == 0 ;
ok 8, $db->status() == 0 ;
ok 9, $db->db_get(1, $value) == 0 ;
ok 10, $value eq "some value" ;
ok 11, $db->db_put(2, "value") == 0 ;
ok 12, $db->db_get(2, $value) == 0 ;
ok 13, $value eq "value" ;
ok 14, $db->db_del(1) == 0 ;
ok 15, ($status = $db->db_get(1, $value)) == DB_KEYEMPTY ;
ok 16, $db->status() == DB_KEYEMPTY ;
ok 17, $db->status() eq $DB_errors{'DB_KEYEMPTY'} ;
ok 18, ($status = $db->db_get(7, $value)) == DB_NOTFOUND ;
ok 19, $db->status() == DB_NOTFOUND ;
ok 20, $db->status() eq $DB_errors{'DB_NOTFOUND'} ;
ok 21, $db->db_sync() == 0 ;
# Check NOOVERWRITE will make put fail when attempting to overwrite
# an existing record.
ok 22, $db->db_put( 2, 'x', DB_NOOVERWRITE) == DB_KEYEXIST ;
ok 23, $db->status() eq $DB_errors{'DB_KEYEXIST'} ;
ok 24, $db->status() == DB_KEYEXIST ;
# check that the value of the key has not been changed by the
# previous test
ok 25, $db->db_get(2, $value) == 0 ;
ok 26, $value eq "value" ;
}
{
# Check simple env works with a array.
my $lex = new LexFile $Dfile ;
my $home = "./fred" ;
ok 27, my $lexD = new LexDir($home);
ok 28, my $env = new BerkeleyDB::Env -Flags => DB_CREATE|DB_INIT_MPOOL,@StdErrFile,
-Home => $home ;
ok 29, my $db = new BerkeleyDB::Recno -Filename => $Dfile,
-Env => $env,
-Flags => DB_CREATE ;
# Add a k/v pair
my $value ;
ok 30, $db->db_put(1, "some value") == 0 ;
ok 31, $db->db_get(1, $value) == 0 ;
ok 32, $value eq "some value" ;
undef $db ;
undef $env ;
}
{
# cursors
my $lex = new LexFile $Dfile ;
my @array ;
my ($k, $v) ;
ok 33, my $db = new BerkeleyDB::Recno -Filename => $Dfile,
-ArrayBase => 0,
-Flags => DB_CREATE ;
# create some data
my @data = (
"red" ,
"green" ,
"blue" ,
) ;
my $i ;
my %data ;
my $ret = 0 ;
for ($i = 0 ; $i < @data ; ++$i) {
$ret += $db->db_put($i, $data[$i]) ;
$data{$i} = $data[$i] ;
}
ok 34, $ret == 0 ;
# create the cursor
ok 35, my $cursor = $db->db_cursor() ;
$k = 0 ; $v = "" ;
my %copy = %data;
my $extras = 0 ;
# sequence forwards
while ($cursor->c_get($k, $v, DB_NEXT) == 0)
{
if ( $copy{$k} eq $v )
{ delete $copy{$k} }
else
{ ++ $extras }
}
ok 36, $cursor->status() == DB_NOTFOUND ;
ok 37, $cursor->status() eq $DB_errors{'DB_NOTFOUND'} ;
ok 38, keys %copy == 0 ;
ok 39, $extras == 0 ;
# sequence backwards
%copy = %data ;
$extras = 0 ;
my $status ;
for ( $status = $cursor->c_get($k, $v, DB_LAST) ;
$status == 0 ;
$status = $cursor->c_get($k, $v, DB_PREV)) {
if ( $copy{$k} eq $v )
{ delete $copy{$k} }
else
{ ++ $extras }
}
ok 40, $status == DB_NOTFOUND ;
ok 41, $status eq $DB_errors{'DB_NOTFOUND'} ;
ok 42, $cursor->status() == $status ;
ok 43, $cursor->status() eq $status ;
ok 44, keys %copy == 0 ;
ok 45, $extras == 0 ;
}
{
# Tied Array interface
my $lex = new LexFile $Dfile ;
my @array ;
my $db ;
ok 46, $db = tie @array, 'BerkeleyDB::Recno', -Filename => $Dfile,
-Property => DB_RENUMBER,
-ArrayBase => 0,
-Flags => DB_CREATE ;
ok 47, my $cursor = (tied @array)->db_cursor() ;
# check the database is empty
my $count = 0 ;
my ($k, $v) = (0,"") ;
while ($cursor->c_get($k, $v, DB_NEXT) == 0) {
++ $count ;
}
ok 48, $cursor->status() == DB_NOTFOUND ;
ok 49, $count == 0 ;
ok 50, @array == 0 ;
# Add a k/v pair
my $value ;
$array[1] = "some value";
ok 51, (tied @array)->status() == 0 ;
ok 52, $array[1] eq "some value";
ok 53, defined $array[1];
ok 54, (tied @array)->status() == 0 ;
ok 55, !defined $array[3];
ok 56, (tied @array)->status() == DB_NOTFOUND ;
ok 57, (tied @array)->db_del(1) == 0 ;
ok 58, (tied @array)->status() == 0 ;
ok 59, ! defined $array[1];
ok 60, (tied @array)->status() == DB_NOTFOUND ;
$array[1] = 2 ;
$array[10] = 20 ;
$array[1000] = 2000 ;
my ($keys, $values) = (0,0);
$count = 0 ;
for ( my $status = $cursor->c_get($k, $v, DB_FIRST) ;
$status == 0 ;
$status = $cursor->c_get($k, $v, DB_NEXT)) {
$keys += $k ;
$values += $v ;
++ $count ;
}
ok 61, $count == 3 ;
ok 62, $keys == 1011 ;
ok 63, $values == 2022 ;
# unshift
$FA ? unshift @array, "red", "green", "blue"
: $db->unshift("red", "green", "blue" ) ;
ok 64, $array[1] eq "red" ;
ok 65, $cursor->c_get($k, $v, DB_FIRST) == 0 ;
ok 66, $k == 1 ;
ok 67, $v eq "red" ;
ok 68, $array[2] eq "green" ;
ok 69, $cursor->c_get($k, $v, DB_NEXT) == 0 ;
ok 70, $k == 2 ;
ok 71, $v eq "green" ;
ok 72, $array[3] eq "blue" ;
ok 73, $cursor->c_get($k, $v, DB_NEXT) == 0 ;
ok 74, $k == 3 ;
ok 75, $v eq "blue" ;
ok 76, $array[4] == 2 ;
ok 77, $cursor->c_get($k, $v, DB_NEXT) == 0 ;
ok 78, $k == 4 ;
ok 79, $v == 2 ;
# shift
ok 80, ($FA ? shift @array : $db->shift()) eq "red" ;
ok 81, ($FA ? shift @array : $db->shift()) eq "green" ;
ok 82, ($FA ? shift @array : $db->shift()) eq "blue" ;
ok 83, ($FA ? shift @array : $db->shift()) == 2 ;
# push
$FA ? push @array, "the", "end"
: $db->push("the", "end") ;
ok 84, $cursor->c_get($k, $v, DB_LAST) == 0 ;
ok 85, $k == 1001 ;
ok 86, $v eq "end" ;
ok 87, $cursor->c_get($k, $v, DB_PREV) == 0 ;
ok 88, $k == 1000 ;
ok 89, $v eq "the" ;
ok 90, $cursor->c_get($k, $v, DB_PREV) == 0 ;
ok 91, $k == 999 ;
ok 92, $v == 2000 ;
# pop
ok 93, ( $FA ? pop @array : $db->pop ) eq "end" ;
ok 94, ( $FA ? pop @array : $db->pop ) eq "the" ;
ok 95, ( $FA ? pop @array : $db->pop ) == 2000 ;
# now clear the array
$FA ? @array = ()
: $db->clear() ;
ok 96, $cursor->c_get($k, $v, DB_FIRST) == DB_NOTFOUND ;
undef $cursor ;
undef $db ;
untie @array ;
}
{
# in-memory file
my @array ;
my $fd ;
my $value ;
ok 97, my $db = tie @array, 'BerkeleyDB::Recno' ;
ok 98, $db->db_put(1, "some value") == 0 ;
ok 99, $db->db_get(1, $value) == 0 ;
ok 100, $value eq "some value" ;
}
{
# partial
# check works via API
my $lex = new LexFile $Dfile ;
my $value ;
ok 101, my $db = new BerkeleyDB::Recno, -Filename => $Dfile,
-Flags => DB_CREATE ;
# create some data
my @data = (
"",
"boat",
"house",
"sea",
) ;
my $ret = 0 ;
my $i ;
for ($i = 1 ; $i < @data ; ++$i) {
$ret += $db->db_put($i, $data[$i]) ;
}
ok 102, $ret == 0 ;
# do a partial get
my ($pon, $off, $len) = $db->partial_set(0,2) ;
ok 103, ! $pon && $off == 0 && $len == 0 ;
ok 104, $db->db_get(1, $value) == 0 && $value eq "bo" ;
ok 105, $db->db_get(2, $value) == 0 && $value eq "ho" ;
ok 106, $db->db_get(3, $value) == 0 && $value eq "se" ;
# do a partial get, off end of data
($pon, $off, $len) = $db->partial_set(3,2) ;
ok 107, $pon ;
ok 108, $off == 0 ;
ok 109, $len == 2 ;
ok 110, $db->db_get(1, $value) == 0 && $value eq "t" ;
ok 111, $db->db_get(2, $value) == 0 && $value eq "se" ;
ok 112, $db->db_get(3, $value) == 0 && $value eq "" ;
# switch of partial mode
($pon, $off, $len) = $db->partial_clear() ;
ok 113, $pon ;
ok 114, $off == 3 ;
ok 115, $len == 2 ;
ok 116, $db->db_get(1, $value) == 0 && $value eq "boat" ;
ok 117, $db->db_get(2, $value) == 0 && $value eq "house" ;
ok 118, $db->db_get(3, $value) == 0 && $value eq "sea" ;
# now partial put
$db->partial_set(0,2) ;
ok 119, $db->db_put(1, "") == 0 ;
ok 120, $db->db_put(2, "AB") == 0 ;
ok 121, $db->db_put(3, "XYZ") == 0 ;
ok 122, $db->db_put(4, "KLM") == 0 ;
($pon, $off, $len) = $db->partial_clear() ;
ok 123, $pon ;
ok 124, $off == 0 ;
ok 125, $len == 2 ;
ok 126, $db->db_get(1, $value) == 0 && $value eq "at" ;
ok 127, $db->db_get(2, $value) == 0 && $value eq "ABuse" ;
ok 128, $db->db_get(3, $value) == 0 && $value eq "XYZa" ;
ok 129, $db->db_get(4, $value) == 0 && $value eq "KLM" ;
# now partial put
($pon, $off, $len) = $db->partial_set(3,2) ;
ok 130, ! $pon ;
ok 131, $off == 0 ;
ok 132, $len == 0 ;
ok 133, $db->db_put(1, "PPP") == 0 ;
ok 134, $db->db_put(2, "Q") == 0 ;
ok 135, $db->db_put(3, "XYZ") == 0 ;
ok 136, $db->db_put(4, "TU") == 0 ;
$db->partial_clear() ;
ok 137, $db->db_get(1, $value) == 0 && $value eq "at\0PPP" ;
ok 138, $db->db_get(2, $value) == 0 && $value eq "ABuQ" ;
ok 139, $db->db_get(3, $value) == 0 && $value eq "XYZXYZ" ;
ok 140, $db->db_get(4, $value) == 0 && $value eq "KLMTU" ;
}
{
# partial
# check works via tied array
my $lex = new LexFile $Dfile ;
my @array ;
my $value ;
ok 141, my $db = tie @array, 'BerkeleyDB::Recno', -Filename => $Dfile,
-Flags => DB_CREATE ;
# create some data
my @data = (
"",
"boat",
"house",
"sea",
) ;
my $i ;
for ($i = 1 ; $i < @data ; ++$i) {
$array[$i] = $data[$i] ;
}
# do a partial get
$db->partial_set(0,2) ;
ok 142, $array[1] eq "bo" ;
ok 143, $array[2] eq "ho" ;
ok 144, $array[3] eq "se" ;
# do a partial get, off end of data
$db->partial_set(3,2) ;
ok 145, $array[1] eq "t" ;
ok 146, $array[2] eq "se" ;
ok 147, $array[3] eq "" ;
# switch of partial mode
$db->partial_clear() ;
ok 148, $array[1] eq "boat" ;
ok 149, $array[2] eq "house" ;
ok 150, $array[3] eq "sea" ;
# now partial put
$db->partial_set(0,2) ;
ok 151, $array[1] = "" ;
ok 152, $array[2] = "AB" ;
ok 153, $array[3] = "XYZ" ;
ok 154, $array[4] = "KLM" ;
$db->partial_clear() ;
ok 155, $array[1] eq "at" ;
ok 156, $array[2] eq "ABuse" ;
ok 157, $array[3] eq "XYZa" ;
ok 158, $array[4] eq "KLM" ;
# now partial put
$db->partial_set(3,2) ;
ok 159, $array[1] = "PPP" ;
ok 160, $array[2] = "Q" ;
ok 161, $array[3] = "XYZ" ;
ok 162, $array[4] = "TU" ;
$db->partial_clear() ;
ok 163, $array[1] eq "at\0PPP" ;
ok 164, $array[2] eq "ABuQ" ;
ok 165, $array[3] eq "XYZXYZ" ;
ok 166, $array[4] eq "KLMTU" ;
}
{
# transaction
my $lex = new LexFile $Dfile ;
my @array ;
my $value ;
my $home = "./fred" ;
ok 167, my $lexD = new LexDir($home);
ok 168, my $env = new BerkeleyDB::Env -Home => $home,@StdErrFile,
-Flags => DB_CREATE|DB_INIT_TXN|
DB_INIT_MPOOL|DB_INIT_LOCK ;
ok 169, my $txn = $env->txn_begin() ;
ok 170, my $db1 = tie @array, 'BerkeleyDB::Recno',
-Filename => $Dfile,
-ArrayBase => 0,
-Flags => DB_CREATE ,
-Env => $env,
-Txn => $txn ;
ok 171, $txn->txn_commit() == 0 ;
ok 172, $txn = $env->txn_begin() ;
$db1->Txn($txn);
# create some data
my @data = (
"boat",
"house",
"sea",
) ;
my $ret = 0 ;
my $i ;
for ($i = 0 ; $i < @data ; ++$i) {
$ret += $db1->db_put($i, $data[$i]) ;
}
ok 173, $ret == 0 ;
# should be able to see all the records
ok 174, my $cursor = $db1->db_cursor() ;
my ($k, $v) = (0, "") ;
my $count = 0 ;
# sequence forwards
while ($cursor->c_get($k, $v, DB_NEXT) == 0) {
++ $count ;
}
ok 175, $count == 3 ;
undef $cursor ;
# now abort the transaction
ok 176, $txn->txn_abort() == 0 ;
# there shouldn't be any records in the database
$count = 0 ;
# sequence forwards
ok 177, $cursor = $db1->db_cursor() ;
while ($cursor->c_get($k, $v, DB_NEXT) == 0) {
++ $count ;
}
ok 178, $count == 0 ;
undef $txn ;
undef $cursor ;
undef $db1 ;
undef $env ;
untie @array ;
}
{
# db_stat
my $lex = new LexFile $Dfile ;
my $recs = ($BerkeleyDB::db_version >= 3.1 ? "bt_ndata" : "bt_nrecs") ;
my @array ;
my ($k, $v) ;
ok 179, my $db = new BerkeleyDB::Recno -Filename => $Dfile,
-Flags => DB_CREATE,
-Pagesize => 4 * 1024,
;
my $ref = $db->db_stat() ;
ok 180, $ref->{$recs} == 0;
ok 181, $ref->{'bt_pagesize'} == 4 * 1024;
# create some data
my @data = (
2,
"house",
"sea",
) ;
my $ret = 0 ;
my $i ;
for ($i = $db->ArrayOffset ; @data ; ++$i) {
$ret += $db->db_put($i, shift @data) ;
}
ok 182, $ret == 0 ;
$ref = $db->db_stat() ;
ok 183, $ref->{$recs} == 3;
}
{
# sub-class test
package Another ;
use strict ;
open(FILE, ">SubDB.pm") or die "Cannot open SubDB.pm: $!\n" ;
print FILE <<'EOM' ;
package SubDB ;
use strict ;
use vars qw( @ISA @EXPORT) ;
require Exporter ;
use BerkeleyDB;
@ISA=qw(BerkeleyDB BerkeleyDB::Recno);
@EXPORT = @BerkeleyDB::EXPORT ;
sub db_put {
my $self = shift ;
my $key = shift ;
my $value = shift ;
$self->SUPER::db_put($key, $value * 3) ;
}
sub db_get {
my $self = shift ;
$self->SUPER::db_get($_[0], $_[1]) ;
$_[1] -= 2 ;
}
sub A_new_method
{
my $self = shift ;
my $key = shift ;
my $value = $self->FETCH($key) ;
return "[[$value]]" ;
}
1 ;
EOM
close FILE ;
BEGIN { push @INC, '.'; }
eval 'use SubDB ; ';
main::ok 184, $@ eq "" ;
my @h ;
my $X ;
eval '
$X = tie(@h, "SubDB", -Filename => "dbrecno.tmp",
-Flags => DB_CREATE,
-Mode => 0640 );
' ;
main::ok 185, $@ eq "" ;
my $ret = eval '$h[1] = 3 ; return $h[1] ' ;
main::ok 186, $@ eq "" ;
main::ok 187, $ret == 7 ;
my $value = 0;
$ret = eval '$X->db_put(1, 4) ; $X->db_get(1, $value) ; return $value' ;
main::ok 188, $@ eq "" ;
main::ok 189, $ret == 10 ;
$ret = eval ' DB_NEXT eq main::DB_NEXT ' ;
main::ok 190, $@ eq "" ;
main::ok 191, $ret == 1 ;
$ret = eval '$X->A_new_method(1) ' ;
main::ok 192, $@ eq "" ;
main::ok 193, $ret eq "[[10]]" ;
undef $X;
untie @h;
unlink "SubDB.pm", "dbrecno.tmp" ;
}
{
# variable length records, DB_DELIMETER -- defaults to \n
my $lex = new LexFile $Dfile, $Dfile2 ;
touch $Dfile2 ;
my @array ;
my $value ;
ok 194, tie @array, 'BerkeleyDB::Recno', -Filename => $Dfile,
-ArrayBase => 0,
-Flags => DB_CREATE ,
-Source => $Dfile2 ;
$array[0] = "abc" ;
$array[1] = "def" ;
$array[3] = "ghi" ;
untie @array ;
my $x = docat($Dfile2) ;
ok 195, $x eq "abc\ndef\n\nghi\n" ;
}
{
# variable length records, change DB_DELIMETER
my $lex = new LexFile $Dfile, $Dfile2 ;
touch $Dfile2 ;
my @array ;
my $value ;
ok 196, tie @array, 'BerkeleyDB::Recno', -Filename => $Dfile,
-ArrayBase => 0,
-Flags => DB_CREATE ,
-Source => $Dfile2 ,
-Delim => "-";
$array[0] = "abc" ;
$array[1] = "def" ;
$array[3] = "ghi" ;
untie @array ;
my $x = docat($Dfile2) ;
ok 197, $x eq "abc-def--ghi-";
}
{
# fixed length records, default DB_PAD
my $lex = new LexFile $Dfile, $Dfile2 ;
touch $Dfile2 ;
my @array ;
my $value ;
ok 198, tie @array, 'BerkeleyDB::Recno', -Filename => $Dfile,
-ArrayBase => 0,
-Flags => DB_CREATE ,
-Len => 5,
-Source => $Dfile2 ;
$array[0] = "abc" ;
$array[1] = "def" ;
$array[3] = "ghi" ;
untie @array ;
my $x = docat($Dfile2) ;
ok 199, $x eq "abc def ghi " ;
}
{
# fixed length records, change Pad
my $lex = new LexFile $Dfile, $Dfile2 ;
touch $Dfile2 ;
my @array ;
my $value ;
ok 200, tie @array, 'BerkeleyDB::Recno', -Filename => $Dfile,
-ArrayBase => 0,
-Flags => DB_CREATE ,
-Len => 5,
-Pad => "-",
-Source => $Dfile2 ;
$array[0] = "abc" ;
$array[1] = "def" ;
$array[3] = "ghi" ;
untie @array ;
my $x = docat($Dfile2) ;
ok 201, $x eq "abc--def-------ghi--" ;
}
{
# DB_RENUMBER
my $lex = new LexFile $Dfile;
my @array ;
my $value ;
ok 202, my $db = tie @array, 'BerkeleyDB::Recno', -Filename => $Dfile,
-Property => DB_RENUMBER,
-ArrayBase => 0,
-Flags => DB_CREATE ;
# create a few records
$array[0] = "abc" ;
$array[1] = "def" ;
$array[3] = "ghi" ;
ok 203, my ($length, $joined) = joiner($db, "|") ;
ok 204, $length == 3 ;
ok 205, $joined eq "abc|def|ghi";
ok 206, $db->db_del(1) == 0 ;
ok 207, ($length, $joined) = joiner($db, "|") ;
ok 208, $length == 2 ;
ok 209, $joined eq "abc|ghi";
undef $db ;
untie @array ;
}
{
# DB_APPEND
my $lex = new LexFile $Dfile;
my @array ;
my $value ;
ok 210, my $db = tie @array, 'BerkeleyDB::Recno',
-Filename => $Dfile,
-Flags => DB_CREATE ;
# create a few records
$array[1] = "def" ;
$array[3] = "ghi" ;
my $k = 0 ;
ok 211, $db->db_put($k, "fred", DB_APPEND) == 0 ;
ok 212, $k == 4 ;
undef $db ;
untie @array ;
}
{
# in-memory Btree with an associated text file
my $lex = new LexFile $Dfile2 ;
touch $Dfile2 ;
my @array ;
my $value ;
ok 213, tie @array, 'BerkeleyDB::Recno', -Source => $Dfile2 ,
-ArrayBase => 0,
-Property => DB_RENUMBER,
-Flags => DB_CREATE ;
$array[0] = "abc" ;
$array[1] = "def" ;
$array[3] = "ghi" ;
untie @array ;
my $x = docat($Dfile2) ;
ok 214, $x eq "abc\ndef\n\nghi\n" ;
}
{
# in-memory, variable length records, change DB_DELIMETER
my $lex = new LexFile $Dfile, $Dfile2 ;
touch $Dfile2 ;
my @array ;
my $value ;
ok 215, tie @array, 'BerkeleyDB::Recno',
-ArrayBase => 0,
-Flags => DB_CREATE ,
-Source => $Dfile2 ,
-Property => DB_RENUMBER,
-Delim => "-";
$array[0] = "abc" ;
$array[1] = "def" ;
$array[3] = "ghi" ;
untie @array ;
my $x = docat($Dfile2) ;
ok 216, $x eq "abc-def--ghi-";
}
{
# in-memory, fixed length records, default DB_PAD
my $lex = new LexFile $Dfile, $Dfile2 ;
touch $Dfile2 ;
my @array ;
my $value ;
ok 217, tie @array, 'BerkeleyDB::Recno', -ArrayBase => 0,
-Flags => DB_CREATE ,
-Property => DB_RENUMBER,
-Len => 5,
-Source => $Dfile2 ;
$array[0] = "abc" ;
$array[1] = "def" ;
$array[3] = "ghi" ;
untie @array ;
my $x = docat($Dfile2) ;
ok 218, $x eq "abc def ghi " ;
}
{
# in-memory, fixed length records, change Pad
my $lex = new LexFile $Dfile, $Dfile2 ;
touch $Dfile2 ;
my @array ;
my $value ;
ok 219, tie @array, 'BerkeleyDB::Recno',
-ArrayBase => 0,
-Flags => DB_CREATE ,
-Property => DB_RENUMBER,
-Len => 5,
-Pad => "-",
-Source => $Dfile2 ;
$array[0] = "abc" ;
$array[1] = "def" ;
$array[3] = "ghi" ;
untie @array ;
my $x = docat($Dfile2) ;
ok 220, $x eq "abc--def-------ghi--" ;
}
{
# 23 Sept 2001 -- push into an empty array
my $lex = new LexFile $Dfile ;
my @array ;
my $db ;
ok 221, $db = tie @array, 'BerkeleyDB::Recno',
-ArrayBase => 0,
-Flags => DB_CREATE ,
-Property => DB_RENUMBER,
-Filename => $Dfile ;
$FA ? push @array, "first"
: $db->push("first") ;
ok 222, $array[0] eq "first" ;
ok 223, $FA ? pop @array : $db->pop() eq "first" ;
undef $db;
untie @array ;
}
{
# 23 Sept 2001 -- unshift into an empty array
my $lex = new LexFile $Dfile ;
my @array ;
my $db ;
ok 224, $db = tie @array, 'BerkeleyDB::Recno',
-ArrayBase => 0,
-Flags => DB_CREATE ,
-Property => DB_RENUMBER,
-Filename => $Dfile ;
$FA ? unshift @array, "first"
: $db->unshift("first") ;
ok 225, $array[0] eq "first" ;
ok 226, ($FA ? shift @array : $db->shift()) eq "first" ;
undef $db;
untie @array ;
}
__END__
# TODO
#
# DB_DELIMETER DB_FIXEDLEN DB_PAD DB_SNAPSHOT with partial records

171
perl/BerkeleyDB/t/strict.t Normal file
View File

@@ -0,0 +1,171 @@
#!./perl -w
use strict ;
use lib 't' ;
use BerkeleyDB;
use util ;
print "1..44\n";
my $Dfile = "dbhash.tmp";
my $home = "./fred" ;
umask(0);
{
# closing a database & an environment in the correct order.
my $lex = new LexFile $Dfile ;
my %hash ;
my $status ;
ok 1, my $lexD = new LexDir($home);
ok 2, my $env = new BerkeleyDB::Env -Home => $home,@StdErrFile,
-Flags => DB_CREATE|DB_INIT_TXN|
DB_INIT_MPOOL|DB_INIT_LOCK ;
ok 3, my $db1 = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile,
-Flags => DB_CREATE ,
-Env => $env;
ok 4, $db1->db_close() == 0 ;
eval { $status = $env->db_appexit() ; } ;
ok 5, $status == 0 ;
ok 6, $@ eq "" ;
#print "[$@]\n" ;
}
{
# closing an environment with an open database
my $lex = new LexFile $Dfile ;
my %hash ;
ok 7, my $lexD = new LexDir($home);
ok 8, my $env = new BerkeleyDB::Env -Home => $home,@StdErrFile,
-Flags => DB_CREATE|DB_INIT_TXN|
DB_INIT_MPOOL|DB_INIT_LOCK ;
ok 9, my $db1 = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile,
-Flags => DB_CREATE ,
-Env => $env;
eval { $env->db_appexit() ; } ;
ok 10, $@ =~ /BerkeleyDB Aborting: attempted to close an environment with 1 open database/ ;
#print "[$@]\n" ;
undef $db1 ;
untie %hash ;
undef $env ;
}
{
# closing a transaction & a database
my $lex = new LexFile $Dfile ;
my %hash ;
my $status ;
ok 11, my $lexD = new LexDir($home);
ok 12, my $env = new BerkeleyDB::Env -Home => $home,@StdErrFile,
-Flags => DB_CREATE|DB_INIT_TXN|
DB_INIT_MPOOL|DB_INIT_LOCK ;
ok 13, my $txn = $env->txn_begin() ;
ok 14, my $db = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile,
-Flags => DB_CREATE ,
-Env => $env,
-Txn => $txn ;
ok 15, $txn->txn_commit() == 0 ;
eval { $status = $db->db_close() ; } ;
ok 16, $status == 0 ;
ok 17, $@ eq "" ;
#print "[$@]\n" ;
eval { $status = $env->db_appexit() ; } ;
ok 18, $status == 0 ;
ok 19, $@ eq "" ;
#print "[$@]\n" ;
}
{
# closing a database with an open transaction
my $lex = new LexFile $Dfile ;
my %hash ;
ok 20, my $lexD = new LexDir($home);
ok 21, my $env = new BerkeleyDB::Env -Home => $home,@StdErrFile,
-Flags => DB_CREATE|DB_INIT_TXN|
DB_INIT_MPOOL|DB_INIT_LOCK ;
ok 22, my $txn = $env->txn_begin() ;
ok 23, my $db = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile,
-Flags => DB_CREATE ,
-Env => $env,
-Txn => $txn ;
eval { $db->db_close() ; } ;
ok 24, $@ =~ /BerkeleyDB Aborting: attempted to close a database while a transaction was still open at/ ;
#print "[$@]\n" ;
$txn->txn_abort();
$db->db_close();
}
{
# closing a cursor & a database
my $lex = new LexFile $Dfile ;
my %hash ;
my $status ;
ok 25, my $db = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile,
-Flags => DB_CREATE ;
ok 26, my $cursor = $db->db_cursor() ;
ok 27, $cursor->c_close() == 0 ;
eval { $status = $db->db_close() ; } ;
ok 28, $status == 0 ;
ok 29, $@ eq "" ;
#print "[$@]\n" ;
}
{
# closing a database with an open cursor
my $lex = new LexFile $Dfile ;
my %hash ;
ok 30, my $db = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile,
-Flags => DB_CREATE ;
ok 31, my $cursor = $db->db_cursor() ;
eval { $db->db_close() ; } ;
ok 32, $@ =~ /\QBerkeleyDB Aborting: attempted to close a database with 1 open cursor(s) at/;
#print "[$@]\n" ;
}
{
# closing a transaction & a cursor
my $lex = new LexFile $Dfile ;
my %hash ;
my $status ;
my $home = 'fred1';
ok 33, my $lexD = new LexDir($home);
ok 34, my $env = new BerkeleyDB::Env -Home => $home,@StdErrFile,
-Flags => DB_CREATE|DB_INIT_TXN|
DB_INIT_MPOOL|DB_INIT_LOCK ;
ok 35, my $txn = $env->txn_begin() ;
ok 36, my $db = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile,
-Flags => DB_CREATE ,
-Env => $env,
-Txn => $txn ;
ok 37, my $cursor = $db->db_cursor() ;
eval { $status = $cursor->c_close() ; } ;
ok 38, $status == 0 ;
ok 39, ($status = $txn->txn_commit()) == 0 ;
ok 40, $@ eq "" ;
eval { $status = $db->db_close() ; } ;
ok 41, $status == 0 ;
ok 42, $@ eq "" ;
#print "[$@]\n" ;
eval { $status = $env->db_appexit() ; } ;
ok 43, $status == 0 ;
ok 44, $@ eq "" ;
#print "[$@]\n" ;
}

210
perl/BerkeleyDB/t/subdb.t Normal file
View File

@@ -0,0 +1,210 @@
#!./perl -w
use strict ;
use lib 't' ;
use BerkeleyDB;
use Test::More ;
use util qw(1);
plan(skip_all => "this needs Berkeley DB 3.x or better\n" )
if $BerkeleyDB::db_version < 3;
plan tests => 43;
my $Dfile = "dbhash.tmp";
my $Dfile2 = "dbhash2.tmp";
my $Dfile3 = "dbhash3.tmp";
unlink $Dfile;
umask(0) ;
sub countDatabases
{
my $file = shift ;
ok my $db = new BerkeleyDB::Unknown -Filename => $file ,
-Flags => DB_RDONLY ;
#my $type = $db->type() ; print "type $type\n" ;
ok my $cursor = $db->db_cursor() ;
my ($k, $v) = ("", "") ;
my $status ;
my @dbnames = () ;
while (($status = $cursor->c_get($k, $v, DB_NEXT)) == 0) {
push @dbnames, $k ;
}
ok $status == DB_NOTFOUND;
return wantarray ? sort @dbnames : scalar @dbnames ;
}
# Berkeley DB 3.x specific functionality
# Check for invalid parameters
{
# Check for invalid parameters
my $db ;
eval ' BerkeleyDB::db_remove -Stupid => 3 ; ' ;
ok $@ =~ /unknown key value\(s\) Stupid/ ;
eval ' BerkeleyDB::db_remove -Bad => 2, -Filename => "fred", -Stupid => 3; ' ;
ok $@ =~ /unknown key value\(s\) (Bad,? |Stupid,? ){2}/ ;
eval ' BerkeleyDB::db_remove -Filename => "a", -Env => 2 ' ;
ok $@ =~ /^Env not of type BerkeleyDB::Env/ ;
eval ' BerkeleyDB::db_remove -Subname => "a"' ;
ok $@ =~ /^Must specify a filename/ ;
my $obj = bless [], "main" ;
eval ' BerkeleyDB::db_remove -Filename => "x", -Env => $obj ' ;
ok $@ =~ /^Env not of type BerkeleyDB::Env/ ;
}
{
# subdatabases
# opening a subdatabse in an exsiting database that doesn't have
# subdatabases at all should fail
my $lex = new LexFile $Dfile ;
ok my $db = new BerkeleyDB::Hash -Filename => $Dfile,
-Flags => DB_CREATE ;
# Add a k/v pair
my %data = qw(
red sky
blue sea
black heart
yellow belley
green grass
) ;
ok addData($db, %data) ;
undef $db ;
$db = new BerkeleyDB::Hash -Filename => $Dfile,
-Subname => "fred" ;
ok ! $db ;
ok -e $Dfile ;
ok ! BerkeleyDB::db_remove(-Filename => $Dfile) ;
}
{
# subdatabases
# opening a subdatabse in an exsiting database that does have
# subdatabases at all, but not this one
my $lex = new LexFile $Dfile ;
ok my $db = new BerkeleyDB::Hash -Filename => $Dfile,
-Subname => "fred" ,
-Flags => DB_CREATE ;
# Add a k/v pair
my %data = qw(
red sky
blue sea
black heart
yellow belley
green grass
) ;
ok addData($db, %data) ;
undef $db ;
$db = new BerkeleyDB::Hash -Filename => $Dfile,
-Subname => "joe" ;
ok !$db ;
}
{
# subdatabases
my $lex = new LexFile $Dfile ;
ok my $db = new BerkeleyDB::Hash -Filename => $Dfile,
-Subname => "fred" ,
-Flags => DB_CREATE ;
# Add a k/v pair
my %data = qw(
red sky
blue sea
black heart
yellow belley
green grass
) ;
ok addData($db, %data) ;
undef $db ;
is join(",", countDatabases($Dfile)), "fred";
}
{
# subdatabases
# opening a database with multiple subdatabases - handle should be a list
# of the subdatabase names
my $lex = new LexFile $Dfile ;
ok my $db1 = new BerkeleyDB::Hash -Filename => $Dfile,
-Subname => "fred" ,
-Flags => DB_CREATE ;
ok my $db2 = new BerkeleyDB::Btree -Filename => $Dfile,
-Subname => "joe" ,
-Flags => DB_CREATE ;
# Add a k/v pair
my %data = qw(
red sky
blue sea
black heart
yellow belley
green grass
) ;
ok addData($db1, %data) ;
ok addData($db2, %data) ;
undef $db1 ;
undef $db2 ;
is join(",", countDatabases($Dfile)), "fred,joe";
ok BerkeleyDB::db_remove(-Filename => $Dfile, -Subname => "harry") != 0;
ok BerkeleyDB::db_remove(-Filename => $Dfile, -Subname => "fred") == 0 ;
# should only be one subdatabase
is join(",", countDatabases($Dfile)), "joe";
# can't delete an already deleted subdatabase
ok BerkeleyDB::db_remove(-Filename => $Dfile, -Subname => "fred") != 0;
ok BerkeleyDB::db_remove(-Filename => $Dfile, -Subname => "joe") == 0 ;
# should only be one subdatabase
is countDatabases($Dfile), 0;
ok -e $Dfile ;
ok BerkeleyDB::db_remove(-Filename => $Dfile) == 0 ;
ok ! -e $Dfile ;
ok BerkeleyDB::db_remove(-Filename => $Dfile) != 0 ;
}
# db_remove with env

314
perl/BerkeleyDB/t/txn.t Normal file
View File

@@ -0,0 +1,314 @@
#!./perl -w
use strict ;
use lib 't' ;
use BerkeleyDB;
use util ;
print "1..58\n";
my $Dfile = "dbhash.tmp";
umask(0);
{
# error cases
my $lex = new LexFile $Dfile ;
my %hash ;
my $value ;
my $home = "./fred" ;
ok 1, my $lexD = new LexDir($home);
ok 2, my $env = new BerkeleyDB::Env -Home => $home, @StdErrFile,
-Flags => DB_CREATE| DB_INIT_MPOOL;
eval { $env->txn_begin() ; } ;
ok 3, $@ =~ /^BerkeleyDB Aborting: Transaction Manager not enabled at/ ;
eval { my $txn_mgr = $env->TxnMgr() ; } ;
ok 4, $@ =~ /^BerkeleyDB Aborting: Transaction Manager not enabled at/ ;
undef $env ;
}
{
# transaction - abort works
my $lex = new LexFile $Dfile ;
my %hash ;
my $value ;
my $home = "./fred" ;
ok 5, my $lexD = new LexDir($home);
ok 6, my $env = new BerkeleyDB::Env -Home => $home, @StdErrFile,
-Flags => DB_CREATE|DB_INIT_TXN|
DB_INIT_MPOOL|DB_INIT_LOCK ;
ok 7, my $txn = $env->txn_begin() ;
ok 8, my $db1 = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile,
-Flags => DB_CREATE ,
-Env => $env,
-Txn => $txn ;
ok 9, $txn->txn_commit() == 0 ;
ok 10, $txn = $env->txn_begin() ;
$db1->Txn($txn);
# create some data
my %data = (
"red" => "boat",
"green" => "house",
"blue" => "sea",
) ;
my $ret = 0 ;
while (my ($k, $v) = each %data) {
$ret += $db1->db_put($k, $v) ;
}
ok 11, $ret == 0 ;
# should be able to see all the records
ok 12, my $cursor = $db1->db_cursor() ;
my ($k, $v) = ("", "") ;
my $count = 0 ;
# sequence forwards
while ($cursor->c_get($k, $v, DB_NEXT) == 0) {
++ $count ;
}
ok 13, $count == 3 ;
undef $cursor ;
# now abort the transaction
ok 14, $txn->txn_abort() == 0 ;
# there shouldn't be any records in the database
$count = 0 ;
# sequence forwards
ok 15, $cursor = $db1->db_cursor() ;
while ($cursor->c_get($k, $v, DB_NEXT) == 0) {
++ $count ;
}
ok 16, $count == 0 ;
my $stat = $env->txn_stat() ;
ok 17, $stat->{'st_naborts'} == 1 ;
undef $txn ;
undef $cursor ;
undef $db1 ;
undef $env ;
untie %hash ;
}
{
# transaction - abort works via txnmgr
my $lex = new LexFile $Dfile ;
my %hash ;
my $value ;
my $home = "./fred" ;
ok 18, my $lexD = new LexDir($home);
ok 19, my $env = new BerkeleyDB::Env -Home => $home, @StdErrFile,
-Flags => DB_CREATE|DB_INIT_TXN|
DB_INIT_MPOOL|DB_INIT_LOCK ;
ok 20, my $txn_mgr = $env->TxnMgr() ;
ok 21, my $txn = $txn_mgr->txn_begin() ;
ok 22, my $db1 = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile,
-Flags => DB_CREATE ,
-Env => $env,
-Txn => $txn ;
ok 23, $txn->txn_commit() == 0 ;
ok 24, $txn = $env->txn_begin() ;
$db1->Txn($txn);
# create some data
my %data = (
"red" => "boat",
"green" => "house",
"blue" => "sea",
) ;
my $ret = 0 ;
while (my ($k, $v) = each %data) {
$ret += $db1->db_put($k, $v) ;
}
ok 25, $ret == 0 ;
# should be able to see all the records
ok 26, my $cursor = $db1->db_cursor() ;
my ($k, $v) = ("", "") ;
my $count = 0 ;
# sequence forwards
while ($cursor->c_get($k, $v, DB_NEXT) == 0) {
++ $count ;
}
ok 27, $count == 3 ;
undef $cursor ;
# now abort the transaction
ok 28, $txn->txn_abort() == 0 ;
# there shouldn't be any records in the database
$count = 0 ;
# sequence forwards
ok 29, $cursor = $db1->db_cursor() ;
while ($cursor->c_get($k, $v, DB_NEXT) == 0) {
++ $count ;
}
ok 30, $count == 0 ;
my $stat = $txn_mgr->txn_stat() ;
ok 31, $stat->{'st_naborts'} == 1 ;
undef $txn ;
undef $cursor ;
undef $db1 ;
undef $txn_mgr ;
undef $env ;
untie %hash ;
}
{
# transaction - commit works
my $lex = new LexFile $Dfile ;
my %hash ;
my $value ;
my $home = "./fred" ;
ok 32, my $lexD = new LexDir($home);
ok 33, my $env = new BerkeleyDB::Env -Home => $home, @StdErrFile,
-Flags => DB_CREATE|DB_INIT_TXN|
DB_INIT_MPOOL|DB_INIT_LOCK ;
ok 34, my $txn = $env->txn_begin() ;
ok 35, my $db1 = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile,
-Flags => DB_CREATE ,
-Env => $env,
-Txn => $txn ;
ok 36, $txn->txn_commit() == 0 ;
ok 37, $txn = $env->txn_begin() ;
$db1->Txn($txn);
# create some data
my %data = (
"red" => "boat",
"green" => "house",
"blue" => "sea",
) ;
my $ret = 0 ;
while (my ($k, $v) = each %data) {
$ret += $db1->db_put($k, $v) ;
}
ok 38, $ret == 0 ;
# should be able to see all the records
ok 39, my $cursor = $db1->db_cursor() ;
my ($k, $v) = ("", "") ;
my $count = 0 ;
# sequence forwards
while ($cursor->c_get($k, $v, DB_NEXT) == 0) {
++ $count ;
}
ok 40, $count == 3 ;
undef $cursor ;
# now commit the transaction
ok 41, $txn->txn_commit() == 0 ;
$count = 0 ;
# sequence forwards
ok 42, $cursor = $db1->db_cursor() ;
while ($cursor->c_get($k, $v, DB_NEXT) == 0) {
++ $count ;
}
ok 43, $count == 3 ;
my $stat = $env->txn_stat() ;
ok 44, $stat->{'st_naborts'} == 0 ;
undef $txn ;
undef $cursor ;
undef $db1 ;
undef $env ;
untie %hash ;
}
{
# transaction - commit works via txnmgr
my $lex = new LexFile $Dfile ;
my %hash ;
my $value ;
my $home = "./fred" ;
ok 45, my $lexD = new LexDir($home);
ok 46, my $env = new BerkeleyDB::Env -Home => $home, @StdErrFile,
-Flags => DB_CREATE|DB_INIT_TXN|
DB_INIT_MPOOL|DB_INIT_LOCK ;
ok 47, my $txn_mgr = $env->TxnMgr() ;
ok 48, my $txn = $txn_mgr->txn_begin() ;
ok 49, my $db1 = tie %hash, 'BerkeleyDB::Hash', -Filename => $Dfile,
-Flags => DB_CREATE ,
-Env => $env,
-Txn => $txn ;
ok 50, $txn->txn_commit() == 0 ;
ok 51, $txn = $env->txn_begin() ;
$db1->Txn($txn);
# create some data
my %data = (
"red" => "boat",
"green" => "house",
"blue" => "sea",
) ;
my $ret = 0 ;
while (my ($k, $v) = each %data) {
$ret += $db1->db_put($k, $v) ;
}
ok 52, $ret == 0 ;
# should be able to see all the records
ok 53, my $cursor = $db1->db_cursor() ;
my ($k, $v) = ("", "") ;
my $count = 0 ;
# sequence forwards
while ($cursor->c_get($k, $v, DB_NEXT) == 0) {
++ $count ;
}
ok 54, $count == 3 ;
undef $cursor ;
# now commit the transaction
ok 55, $txn->txn_commit() == 0 ;
$count = 0 ;
# sequence forwards
ok 56, $cursor = $db1->db_cursor() ;
while ($cursor->c_get($k, $v, DB_NEXT) == 0) {
++ $count ;
}
ok 57, $count == 3 ;
my $stat = $txn_mgr->txn_stat() ;
ok 58, $stat->{'st_naborts'} == 0 ;
undef $txn ;
undef $cursor ;
undef $db1 ;
undef $txn_mgr ;
undef $env ;
untie %hash ;
}

170
perl/BerkeleyDB/t/unknown.t Normal file
View File

@@ -0,0 +1,170 @@
#!./perl -w
# ID: %I%, %G%
use strict ;
use lib 't' ;
use BerkeleyDB;
use util ;
print "1..41\n";
my $Dfile = "dbhash.tmp";
unlink $Dfile;
umask(0) ;
# Check for invalid parameters
{
# Check for invalid parameters
my $db ;
eval ' $db = new BerkeleyDB::Unknown -Stupid => 3 ; ' ;
ok 1, $@ =~ /unknown key value\(s\) Stupid/ ;
eval ' $db = new BerkeleyDB::Unknown -Bad => 2, -Mode => 0345, -Stupid => 3; ' ;
ok 2, $@ =~ /unknown key value\(s\) (Bad,? |Stupid,? ){2}/ ;
eval ' $db = new BerkeleyDB::Unknown -Env => 2 ' ;
ok 3, $@ =~ /^Env not of type BerkeleyDB::Env/ ;
eval ' $db = new BerkeleyDB::Unknown -Txn => "fred" ' ;
ok 4, $@ =~ /^Txn not of type BerkeleyDB::Txn/ ;
my $obj = bless [], "main" ;
eval ' $db = new BerkeleyDB::Unknown -Env => $obj ' ;
ok 5, $@ =~ /^Env not of type BerkeleyDB::Env/ ;
}
# check the interface to a rubbish database
{
# first an empty file
my $lex = new LexFile $Dfile ;
ok 6, writeFile($Dfile, "") ;
ok 7, ! (new BerkeleyDB::Unknown -Filename => $Dfile);
# now a non-database file
writeFile($Dfile, "\x2af6") ;
ok 8, ! (new BerkeleyDB::Unknown -Filename => $Dfile);
}
# check the interface to a Hash database
{
my $lex = new LexFile $Dfile ;
# create a hash database
ok 9, my $db = new BerkeleyDB::Hash -Filename => $Dfile,
-Flags => DB_CREATE ;
# Add a few k/v pairs
my $value ;
my $status ;
ok 10, $db->db_put("some key", "some value") == 0 ;
ok 11, $db->db_put("key", "value") == 0 ;
# close the database
undef $db ;
# now open it with Unknown
ok 12, $db = new BerkeleyDB::Unknown -Filename => $Dfile;
ok 13, $db->type() == DB_HASH ;
ok 14, $db->db_get("some key", $value) == 0 ;
ok 15, $value eq "some value" ;
ok 16, $db->db_get("key", $value) == 0 ;
ok 17, $value eq "value" ;
my @array ;
eval { $db->Tie(\@array)} ;
ok 18, $@ =~ /^Tie needs a reference to a hash/ ;
my %hash ;
$db->Tie(\%hash) ;
ok 19, $hash{"some key"} eq "some value" ;
}
# check the interface to a Btree database
{
my $lex = new LexFile $Dfile ;
# create a hash database
ok 20, my $db = new BerkeleyDB::Btree -Filename => $Dfile,
-Flags => DB_CREATE ;
# Add a few k/v pairs
my $value ;
my $status ;
ok 21, $db->db_put("some key", "some value") == 0 ;
ok 22, $db->db_put("key", "value") == 0 ;
# close the database
undef $db ;
# now open it with Unknown
# create a hash database
ok 23, $db = new BerkeleyDB::Unknown -Filename => $Dfile;
ok 24, $db->type() == DB_BTREE ;
ok 25, $db->db_get("some key", $value) == 0 ;
ok 26, $value eq "some value" ;
ok 27, $db->db_get("key", $value) == 0 ;
ok 28, $value eq "value" ;
my @array ;
eval { $db->Tie(\@array)} ;
ok 29, $@ =~ /^Tie needs a reference to a hash/ ;
my %hash ;
$db->Tie(\%hash) ;
ok 30, $hash{"some key"} eq "some value" ;
}
# check the interface to a Recno database
{
my $lex = new LexFile $Dfile ;
# create a recno database
ok 31, my $db = new BerkeleyDB::Recno -Filename => $Dfile,
-Flags => DB_CREATE ;
# Add a few k/v pairs
my $value ;
my $status ;
ok 32, $db->db_put(0, "some value") == 0 ;
ok 33, $db->db_put(1, "value") == 0 ;
# close the database
undef $db ;
# now open it with Unknown
# create a hash database
ok 34, $db = new BerkeleyDB::Unknown -Filename => $Dfile;
ok 35, $db->type() == DB_RECNO ;
ok 36, $db->db_get(0, $value) == 0 ;
ok 37, $value eq "some value" ;
ok 38, $db->db_get(1, $value) == 0 ;
ok 39, $value eq "value" ;
my %hash ;
eval { $db->Tie(\%hash)} ;
ok 40, $@ =~ /^Tie needs a reference to an array/ ;
my @array ;
$db->Tie(\@array) ;
ok 41, $array[1] eq "value" ;
}
# check i/f to text

368
perl/BerkeleyDB/t/util.pm Normal file
View File

@@ -0,0 +1,368 @@
package util ;
use strict;
use vars qw( $wantOK) ;
$wantOK = 1 ;
sub _ok
{
my $no = shift ;
my $result = shift ;
print "not " unless $result ;
print "ok $no\n" ;
return $result;
}
sub import
{
my $class = shift ;
my $no_want_ok = shift ;
$wantOK = 0 if $no_want_ok ;
if (! $no_want_ok)
{
*main::ok = \&_ok ;
}
}
package main ;
use strict ;
use BerkeleyDB ;
use File::Path qw(rmtree);
use vars qw(%DB_errors $FA) ;
use vars qw( @StdErrFile );
@StdErrFile = ( -ErrFile => *STDERR, -ErrPrefix => "\n# " ) ;
$| = 1;
%DB_errors = (
'DB_INCOMPLETE' => "DB_INCOMPLETE: Sync was unable to complete",
'DB_KEYEMPTY' => "DB_KEYEMPTY: Non-existent key/data pair",
'DB_KEYEXIST' => "DB_KEYEXIST: Key/data pair already exists",
'DB_LOCK_DEADLOCK' => "DB_LOCK_DEADLOCK: Locker killed to resolve a deadlock",
'DB_LOCK_NOTGRANTED' => "DB_LOCK_NOTGRANTED: Lock not granted",
'DB_NOTFOUND' => "DB_NOTFOUND: No matching key/data pair found",
'DB_OLD_VERSION' => "DB_OLDVERSION: Database requires a version upgrade",
'DB_RUNRECOVERY' => "DB_RUNRECOVERY: Fatal error, run database recovery",
) ;
# full tied array support started in Perl 5.004_57
# just double check.
$FA = 0 ;
{
sub try::TIEARRAY { bless [], "try" }
sub try::FETCHSIZE { $FA = 1 }
my @a ;
tie @a, 'try' ;
my $a = @a ;
}
{
package LexFile ;
use vars qw( $basename @files ) ;
$basename = "db0000" ;
sub new
{
my $self = shift ;
#my @files = () ;
foreach (@_)
{
$_ = $basename ;
1 while unlink $basename ;
push @files, $basename ;
++ $basename ;
}
bless [ @files ], $self ;
}
sub DESTROY
{
my $self = shift ;
chmod 0777, @{ $self } ;
for (@$self) { 1 while unlink $_ } ;
}
END
{
foreach (@files) { unlink $_ }
}
}
{
package LexDir ;
use File::Path qw(rmtree);
use vars qw( $basename %dirs ) ;
sub new
{
my $self = shift ;
my $dir = shift ;
rmtree $dir if -e $dir ;
mkdir $dir, 0777 or return undef ;
return bless [ $dir ], $self ;
}
sub DESTROY
{
my $self = shift ;
my $dir = $self->[0];
#rmtree $dir;
$dirs{$dir} ++ ;
}
END
{
foreach (keys %dirs) {
rmtree $_ if -d $_ ;
}
}
}
{
package Redirect ;
use Symbol ;
sub new
{
my $class = shift ;
my $filename = shift ;
my $fh = gensym ;
open ($fh, ">$filename") || die "Cannot open $filename: $!" ;
my $real_stdout = select($fh) ;
return bless [$fh, $real_stdout ] ;
}
sub DESTROY
{
my $self = shift ;
close $self->[0] ;
select($self->[1]) ;
}
}
sub normalise
{
my $data = shift ;
$data =~ s#\r\n#\n#g
if $^O eq 'cygwin' ;
return $data ;
}
sub docat
{
my $file = shift;
local $/ = undef;
open(CAT,$file) || die "Cannot open $file:$!";
my $result = <CAT>;
close(CAT);
$result = normalise($result);
return $result;
}
sub docat_del
{
my $file = shift;
local $/ = undef;
open(CAT,$file) || die "Cannot open $file: $!";
my $result = <CAT> || "" ;
close(CAT);
unlink $file ;
$result = normalise($result);
return $result;
}
sub docat_del_sort
{
my $file = shift;
open(CAT,$file) || die "Cannot open $file: $!";
my @got = <CAT>;
@got = sort @got;
my $result = join('', @got) || "" ;
close(CAT);
unlink $file ;
$result = normalise($result);
return $result;
}
sub writeFile
{
my $name = shift ;
open(FH, ">$name") or return 0 ;
print FH @_ ;
close FH ;
return 1 ;
}
sub touch
{
my $file = shift ;
open(CAT,">$file") || die "Cannot open $file:$!";
close(CAT);
}
sub joiner
{
my $db = shift ;
my $sep = shift ;
my ($k, $v) = (0, "") ;
my @data = () ;
my $cursor = $db->db_cursor() or return () ;
for ( my $status = $cursor->c_get($k, $v, DB_FIRST) ;
$status == 0 ;
$status = $cursor->c_get($k, $v, DB_NEXT)) {
push @data, $v ;
}
(scalar(@data), join($sep, @data)) ;
}
sub joinkeys
{
my $db = shift ;
my $sep = shift || " " ;
my ($k, $v) = (0, "") ;
my @data = () ;
my $cursor = $db->db_cursor() or return () ;
for ( my $status = $cursor->c_get($k, $v, DB_FIRST) ;
$status == 0 ;
$status = $cursor->c_get($k, $v, DB_NEXT)) {
push @data, $k ;
}
return join($sep, @data) ;
}
sub dumpdb
{
my $db = shift ;
my $sep = shift || " " ;
my ($k, $v) = (0, "") ;
my @data = () ;
my $cursor = $db->db_cursor() or return () ;
for ( my $status = $cursor->c_get($k, $v, DB_FIRST) ;
$status == 0 ;
$status = $cursor->c_get($k, $v, DB_NEXT)) {
print " [$k][$v]\n" ;
}
}
sub countRecords
{
my $db = shift ;
my ($k, $v) = (0,0) ;
my ($count) = 0 ;
my ($cursor) = $db->db_cursor() ;
#for ($status = $cursor->c_get($k, $v, DB_FIRST) ;
# $status == 0 ;
# $status = $cursor->c_get($k, $v, DB_NEXT) )
while ($cursor->c_get($k, $v, DB_NEXT) == 0)
{ ++ $count }
return $count ;
}
sub addData
{
my $db = shift ;
my @data = @_ ;
die "addData odd data\n" if @data % 2 != 0 ;
my ($k, $v) ;
my $ret = 0 ;
while (@data) {
$k = shift @data ;
$v = shift @data ;
$ret += $db->db_put($k, $v) ;
}
return ($ret == 0) ;
}
# These two subs lifted directly from MLDBM.pm
#
sub _compare {
use vars qw(%compared);
local %compared;
return _cmp(@_);
}
sub _cmp {
my($a, $b) = @_;
# catch circular loops
return(1) if $compared{$a.'&*&*&*&*&*'.$b}++;
# print "$a $b\n";
# print &Data::Dumper::Dumper($a, $b);
if(ref($a) and ref($a) eq ref($b)) {
if(eval { @$a }) {
# print "HERE ".@$a." ".@$b."\n";
@$a == @$b or return 0;
# print @$a, ' ', @$b, "\n";
# print "HERE2\n";
for(0..@$a-1) {
&_cmp($a->[$_], $b->[$_]) or return 0;
}
} elsif(eval { %$a }) {
keys %$a == keys %$b or return 0;
for (keys %$a) {
&_cmp($a->{$_}, $b->{$_}) or return 0;
}
} elsif(eval { $$a }) {
&_cmp($$a, $$b) or return 0;
} else {
die("data $a $b not handled");
}
return 1;
} elsif(! ref($a) and ! ref($b)) {
return ($a eq $b);
} else {
return 0;
}
}
sub fillout
{
my $var = shift ;
my $length = shift ;
my $pad = shift || " " ;
my $template = $pad x $length ;
substr($template, 0, length($var)) = $var ;
return $template ;
}
sub title
{
#diag "" ;
ok(1, $_[0]) ;
#diag "" ;
}
1;

353
perl/BerkeleyDB/typemap Normal file
View File

@@ -0,0 +1,353 @@
# typemap for Perl 5 interface to Berkeley DB version 2 & 3
#
# SCCS: %I%, %G%
#
# written by Paul Marquess <pmqs@cpan.org>
#
#################################### DB SECTION
#
#
SVnull* T_SV_NULL
void * T_PV
u_int T_U_INT
u_int32_t T_U_INT
db_timeout_t T_U_INT
const char * T_PV_NULL
PV_or_NULL T_PV_NULL
IO_or_NULL T_IO_NULL
AV * T_AV
BerkeleyDB T_PTROBJ
BerkeleyDB::Common T_PTROBJ_AV
BerkeleyDB::Hash T_PTROBJ_AV
BerkeleyDB::Btree T_PTROBJ_AV
BerkeleyDB::Recno T_PTROBJ_AV
BerkeleyDB::Queue T_PTROBJ_AV
BerkeleyDB::Cursor T_PTROBJ_AV
BerkeleyDB::TxnMgr T_PTROBJ_AV
BerkeleyDB::Txn T_PTROBJ_AV
BerkeleyDB::Log T_PTROBJ_AV
BerkeleyDB::Lock T_PTROBJ_AV
BerkeleyDB::Env T_PTROBJ_AV
BerkeleyDB::Raw T_RAW
BerkeleyDB::Common::Raw T_RAW
BerkeleyDB::Hash::Raw T_RAW
BerkeleyDB::Btree::Raw T_RAW
BerkeleyDB::Recno::Raw T_RAW
BerkeleyDB::Queue::Raw T_RAW
BerkeleyDB::Cursor::Raw T_RAW
BerkeleyDB::TxnMgr::Raw T_RAW
BerkeleyDB::Txn::Raw T_RAW
BerkeleyDB::Log::Raw T_RAW
BerkeleyDB::Lock::Raw T_RAW
BerkeleyDB::Env::Raw T_RAW
BerkeleyDB::Env::Inner T_INNER
BerkeleyDB::Common::Inner T_INNER
BerkeleyDB::Txn::Inner T_INNER
BerkeleyDB::TxnMgr::Inner T_INNER
# BerkeleyDB__Env T_PTR
DBT T_dbtdatum
DBT_OPT T_dbtdatum_opt
DBT_B T_dbtdatum_btree
DBTKEY T_dbtkeydatum
DBTKEY_B T_dbtkeydatum_btree
DBTKEY_Br T_dbtkeydatum_btree_r
DBTKEY_Bpr T_dbtkeydatum_btree_pr
DBTYPE T_U_INT
DualType T_DUAL
BerkeleyDB_type * T_IV
BerkeleyDB_ENV_type * T_IV
BerkeleyDB_TxnMgr_type * T_IV
BerkeleyDB_Txn_type * T_IV
BerkeleyDB__Cursor_type * T_IV
DB * T_IV
DB_ENV * T_IV
INPUT
T_AV
if (SvROK($arg) && SvTYPE(SvRV($arg)) == SVt_PVAV)
/* if (sv_isa($arg, \"${ntype}\")) */
$var = (AV*)SvRV($arg);
else
croak(\"$var is not an array reference\")
T_RAW
$var = INT2PTR($type,SvIV($arg)
T_U_INT
$var = SvUV($arg)
T_SV_REF_NULL
if ($arg == &PL_sv_undef)
$var = NULL ;
else if (sv_derived_from($arg, \"${ntype}\")) {
IV tmp = SvIV((SV *)GetInternalObject($arg));
$var = INT2PTR($type, tmp);
}
else
croak(\"$var is not of type ${ntype}\")
T_SV_NULL
if ($arg == NULL || $arg == &PL_sv_undef)
$var = NULL ;
else
$var = $arg ;
T_HV_REF_NULL
if ($arg == &PL_sv_undef)
$var = NULL ;
else if (sv_derived_from($arg, \"${ntype}\")) {
HV * hv = (HV *)GetInternalObject($arg);
SV ** svp = hv_fetch(hv, \"db\", 2, FALSE);
IV tmp = SvIV(*svp);
$var = INT2PTR($type, tmp);
}
else
croak(\"$var is not of type ${ntype}\")
T_HV_REF
if (sv_derived_from($arg, \"${ntype}\")) {
HV * hv = (HV *)GetInternalObject($arg);
SV ** svp = hv_fetch(hv, \"db\", 2, FALSE);
IV tmp = SvIV(*svp);
$var = INT2PTR($type, tmp);
}
else
croak(\"$var is not of type ${ntype}\")
T_P_REF
if (sv_derived_from($arg, \"${ntype}\")) {
IV tmp = SvIV((SV*)SvRV($arg));
$var = INT2PTR($type, tmp);
}
else
croak(\"$var is not of type ${ntype}\")
T_INNER
{
HV * hv = (HV *)SvRV($arg);
SV ** svp = hv_fetch(hv, \"db\", 2, FALSE);
IV tmp = SvIV(*svp);
$var = INT2PTR($type, tmp);
}
T_PV_NULL
if ($arg == &PL_sv_undef)
$var = NULL ;
else {
STRLEN len;
$var = ($type)SvPV($arg,len) ;
if (len == 0)
$var = NULL ;
}
T_IO_NULL
if ($arg == &PL_sv_undef)
$var = NULL ;
else
$var = IoOFP(sv_2io($arg))
T_PTROBJ_NULL
if ($arg == &PL_sv_undef)
$var = NULL ;
else if (sv_derived_from($arg, \"${ntype}\")) {
IV tmp = SvIV((SV*)SvRV($arg));
$var = INT2PTR($type, tmp);
}
else
croak(\"$var is not of type ${ntype}\")
T_PTROBJ_SELF
if ($arg == &PL_sv_undef)
$var = NULL ;
else if (sv_derived_from($arg, \"${ntype}\")) {
IV tmp = SvIV((SV*)SvRV($arg));
$var = INT2PTR($type, tmp);
}
else
croak(\"$var is not of type ${ntype}\")
T_PTROBJ_AV
if ($arg == &PL_sv_undef || $arg == NULL)
$var = NULL ;
else if (sv_derived_from($arg, \"${ntype}\")) {
IV tmp = SvIV(getInnerObject($arg)) ;
$var = INT2PTR($type, tmp);
}
else
croak(\"$var is not of type ${ntype}\")
T_dbtkeydatum
{
SV* my_sv = $arg ;
DBM_ckFilter(my_sv, filter_store_key, \"filter_store_key\");
DBT_clear($var) ;
SvGETMAGIC($arg) ;
if (db->recno_or_queue) {
Value = GetRecnoKey(db, SvIV(my_sv)) ;
$var.data = & Value;
$var.size = (int)sizeof(db_recno_t);
}
else {
STRLEN len;
$var.data = SvPV(my_sv, len);
$var.size = (int)len;
}
}
T_dbtkeydatum_btree
{
SV* my_sv = $arg ;
DBM_ckFilter(my_sv, filter_store_key, \"filter_store_key\");
DBT_clear($var) ;
SvGETMAGIC($arg) ;
if (db->recno_or_queue ||
(db->type == DB_BTREE && flagSet(DB_SET_RECNO))) {
Value = GetRecnoKey(db, SvIV(my_sv)) ;
$var.data = & Value;
$var.size = (int)sizeof(db_recno_t);
}
else {
STRLEN len;
$var.data = SvPV(my_sv, len);
$var.size = (int)len;
}
}
T_dbtkeydatum_btree_r
{
SV* my_sv = $arg ;
DBM_ckFilter(my_sv, filter_store_key, \"filter_store_key\");
DBT_clear($var) ;
SvGETMAGIC($arg) ;
if (db->recno_or_queue ||
(db->type == DB_BTREE && flagSet(DB_SET_RECNO))) {
Value = GetRecnoKey(db, SvIV(my_sv)) ;
$var.data = & Value;
$var.size = (int)sizeof(db_recno_t);
}
else {
STRLEN len;
$var.data = SvPV(my_sv, len);
$var.size = (int)len;
}
}
T_dbtkeydatum_btree_pr
{
SV* my_sv = $arg ;
DBM_ckFilter(my_sv, filter_store_key, \"filter_store_key\");
DBT_clear($var) ;
SvGETMAGIC($arg) ;
if (db->recno_or_queue ||
(db->type == DB_BTREE && flagSet(DB_SET_RECNO))) {
Value = GetRecnoKey(db, SvIV(my_sv)) ;
$var.data = & Value;
$var.size = (int)sizeof(db_recno_t);
}
else {
STRLEN len;
$var.data = SvPV(my_sv, len);
$var.size = (int)len;
}
}
T_dbtdatum
{
SV* my_sv = $arg ;
STRLEN len;
DBM_ckFilter(my_sv, filter_store_value, \"filter_store_value\");
DBT_clear($var) ;
SvGETMAGIC($arg) ;
$var.data = SvPV(my_sv, len);
$var.size = (int)len;
$var.flags = db->partial ;
$var.dlen = db->dlen ;
$var.doff = db->doff ;
}
T_dbtdatum_opt
DBT_clear($var) ;
if (flagSetBoth()) {
SV* my_sv = $arg ;
STRLEN len;
DBM_ckFilter(my_sv, filter_store_value, \"filter_store_value\");
SvGETMAGIC($arg) ;
$var.data = SvPV(my_sv, len);
$var.size = (int)len;
$var.flags = db->partial ;
$var.dlen = db->dlen ;
$var.doff = db->doff ;
}
T_dbtdatum_btree
DBT_clear($var) ;
if (flagSetBoth()) {
SV* my_sv = $arg ;
STRLEN len;
DBM_ckFilter(my_sv, filter_store_value, \"filter_store_value\");
SvGETMAGIC($arg) ;
$var.data = SvPV(my_sv, len);
$var.size = (int)len;
$var.flags = db->partial ;
$var.dlen = db->dlen ;
$var.doff = db->doff ;
}
OUTPUT
T_SV_NULL
$arg = $var;
T_RAW
sv_setiv($arg, PTR2IV($var));
T_SV_REF_NULL
sv_setiv($arg, PTR2IV($var));
T_HV_REF_NULL
sv_setiv($arg, PTR2IV($var));
T_HV_REF
sv_setiv($arg, PTR2IV($var));
T_P_REF
sv_setiv($arg, PTR2IV($var));
T_DUAL
setDUALerrno($arg, $var) ;
T_U_INT
sv_setuv($arg, (UV)$var);
T_PV_NULL
sv_setpv((SV*)$arg, $var);
T_dbtkeydatum_btree
OutputKey_B($arg, $var)
T_dbtkeydatum_btree_r
OutputKey_Br($arg, $var)
T_dbtkeydatum_btree_pr
OutputKey_Bpr($arg, $var)
T_dbtkeydatum
OutputKey($arg, $var)
T_dbtdatum
OutputValue($arg, $var)
T_dbtdatum_opt
OutputValue($arg, $var)
T_dbtdatum_btree
OutputValue_B($arg, $var)
T_PTROBJ_NULL
sv_setref_pv($arg, \"${ntype}\", (void*)$var);
T_PTROBJ_SELF
sv_setref_pv($arg, self, (void*)$var);

532
perl/DB_File/Changes Normal file
View File

@@ -0,0 +1,532 @@
1.817 27 March 2008
* Updated dbinfo
* Applied core patch 32299 - Re-apply change #30562
* Applied core patch 32208
* Applied core patch 32884 - use MM->parse_version() in Makefile.PL
* Applied core patch 32883 - Silence new warning grep in void context warning
* Applied core patch 32704 to remove use of PL_na in typemap
* Applied core patch 30562 to fix a build issue on OSF
1.816 28 October 2007
* Clarified the warning about building with a different version of
Berkeley DB that is used at runtime.
* Also made the boot version check less strict.
[rt.cpan.org #30013]
1.815 4 February 2007
* A few casting cleanups for building with C++ from Steve Peters.
* Fixed problem with recno which happened if you changed directory after
opening the database. Problem reported by Andrew Pam.
1.814 11 November 2005
* Fix from Dominic Dunlop to tidy up an OS-X specific warning in
db-btree.t.
* Silenced a warning about $DB_File::Error only being used once.
Issue spotted by Dominic Dunlop.
1.813 31st October 2005
* Updates for Berkeley DB 4.4
1.812 9th October 2005
* Added libscan to Makefile.PL
* Fixed test failing under windows
1.811 12th March 2005
* Fixed DBM filter bug in seq
1.810 7th August 2004
* Fixed db-hash.t for Cygwin
* Added substr tests to db-hast.t
* Documented AIX build problem in README.
1.809 20th June 2004
* Merged core patch 22258
* Merged core patch 22741
* Fixed core bug 30237.
Using substr to pass parameters to the low-level Berkeley DB interface
causes problems with Perl 5.8.1 or better.
typemap fix supplied by Marcus Holland-Moritz.
1.808 22nd December 2003
* Added extra DBM Filter tests.
* Fixed a memory leak in ParseOpenInfo, which whould occur if the
opening of the database failed. Leak spotted by Adrian Enache.
1.807 1st November 2003
* Fixed minor typos on pod documetation - reported by Jeremy Mates &
Mark Jason Dominus.
* dbinfo updated to report when a database is encrypted.
1.806 22nd October 2002
* Fixed problem when trying to build with a multi-threaded perl.
* Tidied up the recursion detetion code.
* merged core patch 17844 - missing dTHX declarations.
* merged core patch 17838
1.805 1st September 2002
* Added support to allow DB_File to build with Berkeley DB 4.1.X
* Tightened up the test harness to test that calls to untie don't generate
the "untie attempted while %d inner references still exist" warning.
* added code to guard against calling the callbacks (compare,hash & prefix)
recursively.
* pasing undef for the flags and/or mode when opening a database could cause
a "Use of uninitialized value in subroutine entry" warning. Now silenced.
* DBM filter code beefed up to cope with read-only $_.
1.804 2nd June 2002
* Perl core patch 14939 added a new warning to "splice". This broke the
db-recno test harness. Fixed.
* merged core patches 16502 & 16540.
1.803 1st March 2002
* Fixed a problem with db-btree.t where it complained about an "our"
variable redeclaation.
* FETCH, STORE & DELETE don't map the flags parameter into the
equivalent Berkeley DB function anymore.
1.802 6th January 2002
* The message about some test failing in db-recno.t had the wrong test
numbers. Fixed.
* merged core patch 13942.
1.801 26th November 2001
* Fixed typo in Makefile.PL
* Added "clean" attribute to Makefile.PL
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.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.78 30th July 2001
* the test in Makefile.PL for AIX used -plthreads. Should have been
-lpthreads
* merged Core patches
10372, 10335, 10372, 10534, 10549, 10643, 11051, 11194, 11432
* added documentation patch regarding duplicate keys from Andrew Johnson
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.
* Minor documentation updates.
* Merged Core patch 9176
* Added a patch from Edward Avis that adds support for splice with
recno databases.
* Modified Makefile.PL to only enable the warnings pragma if using perl
5.6.1 or better.
1.76 15th January 2001
* Added instructions for using LD_PRELOAD to get Berkeley DB 2.x to work
with DB_File on Linux. Thanks to Norbert Bollow for sending details of
this approach.
1.75 17th December 2000
* Fixed perl core patch 7703
* Added suppport to allow DB_File to be built with Berkeley DB 3.2 --
btree_compare, btree_prefix and hash_cb needed to be changed.
* Updated dbinfo to support Berkeley DB 3.2 file format changes.
1.74 10th December 2000
* A "close" call in DB_File.xs needed parenthesised to stop win32 from
thinking it was one of its macros.
* Updated dbinfo to support Berkeley DB 3.1 file format changes.
* DB_File.pm & the test hasness now use the warnings pragma (when
available).
* Included Perl core patch 7703 -- size argument for hash_cb is different
for Berkeley DB 3.x
* Included Perl core patch 7801 -- Give __getBerkeleyDBInfo the ANSI C
treatment.
* @a = () produced the warning 'Argument "" isn't numeric in entersub'
This has been fixed. Thanks to Edward Avis for spotting this bug.
* Added note about building under Linux. Included patches.
* Included Perl core patch 8068 -- fix for bug 20001013.009
When run with warnings enabled "$hash{XX} = undef " produced an
"Uninitialized value" warning. This has been fixed.
1.73 31st May 2000
* Added support in version.c for building with threaded Perl.
* Berkeley DB 3.1 has reenabled support for null keys. The test
harness has been updated to reflect this.
1.72 16th January 2000
* Added hints/sco.pl
* The module will now use XSLoader when it is available. When it
isn't it will use DynaLoader.
* The locking section in DB_File.pm has been discredited. Many thanks
to David Harris for spotting the underlying problem, contributing
the updates to the documentation and writing DB_File::Lock (available
on CPAN).
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.
1.70 4th August 1999
* Initialise $DB_File::db_ver and $DB_File::db_version with
GV_ADD|GV_ADDMULT -- bug spotted by Nick Ing-Simmons.
* Added a BOOT check to test for equivalent versions of db.h &
libdb.a/so.
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
1.68 22nd July 1999
* Merged changes from 5.005_58
* Fixed a bug in R_IBEFORE & R_IAFTER procesing in Berkeley DB
2 databases.
* Added some of the examples in the POD into the test harness.
1.67 6th June 1999
* Added DBM Filter documentation to DB_File.pm
* Fixed DBM Filter code to work with 5.004
* A few instances of newSVpvn were used in 1.66. This isn't available in
Perl 5.004_04 or earlier. Replaced with newSVpv.
1.66 15th March 1999
* Added DBM Filter code
1.65 6th March 1999
* Fixed a bug in the recno PUSH logic.
* The BOOT version check now needs 2.3.4 when using Berkeley DB version 2
1.64 21st February 1999
* Tidied the 1.x to 2.x flag mapping code.
* Added a patch from Mark Kettenis <kettenis@wins.uva.nl> to fix a flag
mapping problem with O_RDONLY on the Hurd
* Updated the message that db-recno.t prints when tests 51, 53 or 55 fail.
1.63 19th December 1998
* Fix to allow DB 2.6.x to build with DB_File
* Documentation updated to use push,pop etc in the RECNO example &
to include the find_dup & del_dup methods.
1.62 30th November 1998
Added hints/dynixptx.pl.
Fixed typemap -- 1.61 used PL_na instead of na
1.61 19th November 1998
Added a note to README about how to build Berkeley DB 2.x when
using HP-UX.
Minor modifications to get the module to build with DB 2.5.x
Fixed a typo in the definition of O_RDONLY, courtesy of Mark Kettenis.
1.60
Changed the test to check for full tied array support
1.59
Updated the license section.
Berkeley DB 2.4.10 disallows zero length keys. Tests 32 & 42 in
db-btree.t and test 27 in db-hash.t failed because of this change.
Those tests have been zapped.
Added dbinfo to the distribution.
1.58
Tied Array support was enhanced in Perl 5.004_57. DB_File now
supports PUSH,POP,SHIFT,UNSHIFT & STORESIZE.
Fixed a problem with the use of sv_setpvn. When the size is
specified as 0, it does a strlen on the data. This was ok for DB
1.x, but isn't for DB 2.x.
1.57
If Perl has been compiled with Threads support,the symbol op will be
defined. This clashes with a field name in db.h, so it needs to be
#undef'ed before db.h is included.
1.56
Documented the Solaris 2.5 mutex bug
1.55
Merged 1.16 changes.
1.54
Fixed a small bug in the test harness when run under win32
The emulation of fd when useing DB 2.x was busted.
1.53
Added DB_RENUMBER to flags for recno.
1.52
Patch from Nick Ing-Simmons now allows DB_File to build on NT.
Merged 1.15 patch.
1.51
Fixed the test harness so that it doesn't expect DB_File to have
been installed by the main Perl build.
Fixed a bug in mapping 1.x O_RDONLY flag to 2.x DB_RDONLY equivalent
1.50
DB_File can now build with either DB 1.x or 2.x, but not both at
the same time.
1.16
A harmless looking tab was causing Makefile.PL to fail on AIX 3.2.5
Small fix for the AIX strict C compiler XLC which doesn't like
__attribute__ being defined via proto.h and redefined via db.h. Fix
courtesy of Jarkko Hietaniemi.
1.15
Patch from Gisle Aas <gisle@aas.no> to suppress "use of undefined
value" warning with db_get and db_seq.
Patch from Gisle Aas <gisle@aas.no> to make DB_File export only the
O_* constants from Fcntl.
Removed the DESTROY method from the DB_File::HASHINFO module.
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.
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.13
Minor changes to DB_FIle.xs and DB_File.pm
1.12
Documented the incompatibility with version 2 of Berkeley DB.
1.11
Documented the untie gotcha.
1.10
Fixed fd method so that it still returns -1 for in-memory files
when db 1.86 is used.
1.09
Minor bug fix in DB_File::HASHINFO, DB_File::RECNOINFO and
DB_File::BTREEINFO.
Changed default mode to 0666.
1.08
Documented operation of bval.
1.07
Fixed bug with RECNO, where bval wasn't defaulting to "\n".
1.06
Minor namespace cleanup: Localized PrintBtree.
1.05
Made all scripts in the documentation strict and -w clean.
Added logic to DB_File.xs to allow the module to be built after
Perl is installed.
1.04
Minor documentation changes.
Fixed a bug in hash_cb. Patches supplied by Dave Hammen,
<hammen@gothamcity.jsc.nasa.govt>.
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 -w clean.
Reworked part of the test harness to be more locale friendly.
1.03
Documentation update.
DB_File now imports the constants (O_RDWR, O_CREAT etc.) from Fcntl
automatically.
The standard hash function exists 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.
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 sync added. Without it the resultant database file was empty.
Added get_dup method.
1.01
Fixed a core dump problem with SunOS.
The return value from TIEHASH wasn't set to NULL when dbopen
returned an error.
1.0
DB_File 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 push method on an empty list didn't work properly. This
has been fixed.
0.3
Added prototype support for multiple btree compare callbacks.
0.2
When DB_File is opening a database file it no longer terminates the
process if dbopen returned an error. This allows file protection
errors to be caught at run time. Thanks to Judith Grass
<grass@cybercash.com> for spotting the bug.
0.1
First Release.

2299
perl/DB_File/DB_File.pm Normal file

File diff suppressed because it is too large Load Diff

1995
perl/DB_File/DB_File.xs Normal file

File diff suppressed because it is too large Load Diff

6
perl/DB_File/DB_File_BS Normal file
View File

@@ -0,0 +1,6 @@
# NeXT needs /usr/lib/libposix.a to load along with DB_File.so
if ( $dlsrc eq "dl_next.xs" ) {
@DynaLoader::dl_resolve_using = ( '/usr/lib/libposix.a' );
}
1;

32
perl/DB_File/MANIFEST Normal file
View File

@@ -0,0 +1,32 @@
Changes
DB_File.pm
DB_File.xs
DB_File_BS
MANIFEST
Makefile.PL
README
config.in
dbinfo
fallback.h
fallback.xs
hints/dynixptx.pl
hints/sco.pl
patches/5.004
patches/5.004_01
patches/5.004_02
patches/5.004_03
patches/5.004_04
patches/5.004_05
patches/5.005
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
t/pod.t
typemap
version.c
META.yml Module meta-data (added by MakeMaker)

13
perl/DB_File/META.yml Normal file
View File

@@ -0,0 +1,13 @@
--- #YAML:1.0
name: DB_File
version: 1.817
abstract: Perl5 access to Berkeley DB version 1.x
license: perl
author:
- Paul Marquess <pmqs@cpan.org>
generated_by: ExtUtils::MakeMaker version 6.44
distribution_type: module
requires:
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.3.html
version: 1.3

359
perl/DB_File/Makefile.PL Normal file
View File

@@ -0,0 +1,359 @@
#! 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 ;
my $DB_NAME ;
my $LIBS ;
my $COMPAT185 = "" ;
ParseCONFIG() ;
my @files = ('DB_File.pm', glob "t/*.t") ;
UpDowngrade(@files);
if (defined $DB_NAME)
{ $LIBS = $DB_NAME }
else {
if ($^O eq 'MSWin32')
{ $LIBS = '-llibdb' }
else
{ $LIBS = '-ldb' }
}
# Solaris is special.
#$LIBS .= " -lthread" if $^O eq 'solaris' ;
# AIX is special.
$LIBS .= " -lpthread" if $^O eq 'aix' ;
# OS2 is a special case, so check for it now.
my $OS2 = "" ;
$OS2 = "-DOS2" if $Config{'osname'} eq 'os2' ;
my $WALL = '' ;
#$WALL = ' -Wall ';
WriteMakefile(
NAME => 'DB_File',
LIBS => ["-L${LIB_DIR} $LIBS"],
#MAN3PODS => {}, # Pods will be built by installman.
INC => "-I$INC_DIR",
VERSION_FROM => 'DB_File.pm',
XS_VERSION => eval MM->parse_version('DB_File.pm'),
XSPROTOARG => '-noprototypes',
DEFINE => "-D_NOT_CORE $OS2 $VER_INFO $COMPAT185 $WALL",
OBJECT => 'version$(OBJ_EXT) DB_File$(OBJ_EXT)',
((ExtUtils::MakeMaker->VERSION() gt '6.30')
? ('LICENSE' => 'perl')
: ()
),
(
$] >= 5.005
? (ABSTRACT_FROM => 'DB_File.pm',
AUTHOR => 'Paul Marquess <pmqs@cpan.org>')
: ()
),
#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'},
);
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\(/ ;
}
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::libscan
{
my $self = shift ;
my $path = shift ;
return undef
if $path =~ /(~|\.bak)$/ ||
$path =~ /^\..*\.swp$/ ;
return $path;
}
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 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
EOM
sub ParseCONFIG
{
my ($k, $v) ;
my @badkey = () ;
my %Info = () ;
my @Options = qw( INCLUDE LIB PREFIX HASH DBNAME COMPAT185 ) ;
my %ValidOption = map {$_, 1} @Options ;
my %Parsed = %ValidOption ;
my $CONFIG = 'config.in' ;
print "Parsing $CONFIG...\n" ;
# DBNAME & COMPAT185 are optional, so pretend they have
# been parsed.
delete $Parsed{'DBNAME'} ;
delete $Parsed{'COMPAT185'} ;
$Info{COMPAT185} = "No" ;
open(F, "$CONFIG") or die "Cannot open file $CONFIG: $!\n" ;
while (<F>) {
s/^\s*|\s*$//g ;
next if /^\s*$/ or /^\s*#/ ;
s/\s*#\s*$// ;
($k, $v) = split(/\s+=\s+/, $_, 2) ;
$k = uc $k ;
if ($ValidOption{$k}) {
delete $Parsed{$k} ;
$Info{$k} = $v ;
}
else {
push(@badkey, $k) ;
}
}
close F ;
print "Unknown keys in $CONFIG ignored [@badkey]\n"
if @badkey ;
# check parsed values
my @missing = () ;
die "The following keys are missing from $CONFIG file: [@missing]\n"
if @missing = keys %Parsed ;
$INC_DIR = $ENV{'DB_FILE_INCLUDE'} || $Info{'INCLUDE'} ;
$LIB_DIR = $ENV{'DB_FILE_LIB'} || $Info{'LIB'} ;
$DB_NAME = $ENV{'DB_FILE_NAME'} || $Info{'DBNAME'} ;
$COMPAT185 = "-DCOMPAT185 -DDB_LIBRARY_COMPATIBILITY_API"
if (defined $ENV{'DB_FILE_COMPAT185'} &&
$ENV{'DB_FILE_COMPAT185'} =~ /^\s*(on|true|1)\s*$/i) ||
$Info{'COMPAT185'} =~ /^\s*(on|true|1)\s*$/i ;
my $PREFIX = $Info{'PREFIX'} ;
my $HASH = $Info{'HASH'} ;
$VER_INFO = "-DmDB_Prefix_t=${PREFIX} -DmDB_Hash_t=${HASH}" ;
print <<EOM if 0 ;
INCLUDE [$INC_DIR]
LIB [$LIB_DIR]
HASH [$HASH]
PREFIX [$PREFIX]
DBNAME [$DB_NAME]
EOM
print "Looks Good.\n" ;
}
sub UpDowngrade
{
my @files = @_ ;
# our is stable from 5.6.0 onward
# warnings is stable from 5.6.1 onward
# 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"
#
# and
#
# From: warnings::warnif(x,y);
# To: $^W && carp(y); # warnif -- x
$warn_sub = sub {
s/^(\s*)(no\s+warnings)/${1}local (\$^W) = 0; #$2/ ;
s/^(\s*)(use\s+warnings)/${1}local (\$^W) = 1; #$2/ ;
s/^(\s*)warnings::warnif\s*\((.*?)\s*,\s*(.*?)\)\s*;/${1}\$^W && carp($3); # warnif - $2/ ;
};
}
else {
# From: local ($^W) = 1; # use|no warnings "blah"
# To: use|no warnings "blah"
#
# and
#
# From: $^W && carp(y); # warnif -- x
# To: warnings::warnif(x,y);
$warn_sub = sub {
s/^(\s*)local\s*\(\$\^W\)\s*=\s*\d+\s*;\s*#\s*((no|use)\s+warnings.*)/$1$2/ ;
s/^(\s*)\$\^W\s+\&\&\s*carp\s*\((.*?)\)\s*;\s*#\s*warnif\s*-\s*(.*)/${1}warnings::warnif($3, $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 doUpDown
{
my $our_sub = shift;
my $warn_sub = shift;
local ($^I) = ".bak" ;
local (@ARGV) = shift;
while (<>)
{
print, last if /^__(END|DATA)__/ ;
&{ $our_sub }();
&{ $warn_sub }();
print ;
}
return if eof ;
while (<>)
{ print }
}
# end of file Makefile.PL

592
perl/DB_File/README Normal file
View File

@@ -0,0 +1,592 @@
DB_File
Version 1.817
27th March 2008
Copyright (c) 1995-2008 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.
IMPORTANT NOTICE
================
If are using the locking technique described in older versions of
DB_File, please read the section called "Locking: The Trouble with fd"
in DB_File.pm immediately. The locking method has been found to be
unsafe. You risk corrupting your data if you continue to use it.
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, 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, 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
of the database types (hash, btree and recno) currently supported by
Berkeley DB.
For further details see the documentation included at the end of the
file DB_File.pm.
PREREQUISITES
-------------
Before you can build DB_File you must have the following installed on
your system:
* Perl 5.004_05 or greater.
* Berkeley DB.
The official web site for Berkeley DB is
http://www.oracle.com/technology/products/berkeley-db/db/index.html
The latest version of Berkeley DB is always available there. It
is recommended that you use the most recent version available.
The one exception to this advice is where you want to use DB_File
to access database files created by a third-party application, like
Sendmail or Netscape. In these cases you must build DB_File with a
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 or 4.x, any version
will do. For Berkeley DB 1.x, use either version 1.85 or 1.86.
BUILDING THE MODULE
-------------------
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, 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.
Step 2 : Edit the file config.in to suit you local installation.
Instructions are given in the file.
Step 3 : Build and test the module using this sequence of commands:
perl Makefile.PL
make
make test
NOTE:
If you have a very old version of Berkeley DB (i.e. pre 1.85),
three of the tests in the recno test harness may fail (tests 51,
53 and 55). You can safely ignore the errors if you're never
going to use the broken functionality (recno databases with a
modified bval). Otherwise you'll have to upgrade your DB
library.
INSTALLATION
------------
make install
UPDATES
=======
The most recent version of DB_File is always available at
http://www.cpan.org/modules/by-module/DB_File/
TROUBLESHOOTING
===============
Here are some of the common problems people encounter when building
DB_File.
Missing db.h or libdb.a
-----------------------
If you get an error like this:
cc -c -I/usr/local/include -Dbool=char -DHAS_BOOL
-O2 -DVERSION=\"1.64\" -DXS_VERSION=\"1.64\" -fpic
-I/usr/local/lib/perl5/i586-linux/5.00404/CORE -DmDB_Prefix_t=size_t
-DmDB_Hash_t=u_int32_t DB_File.c
DB_File.xs:101: db.h: No such file or directory
or this:
LD_RUN_PATH="/lib" cc -o blib/arch/auto/DB_File/DB_File.so -shared
-L/usr/local/lib DB_File.o -L/usr/local/lib -ldb
ld: cannot open -ldb: No such file or directory
This symptom can imply:
1. You don't have Berkeley DB installed on your system at all.
Solution: get & install Berkeley DB.
2. You do have Berkeley DB installed, but it isn't in a standard place.
Solution: Edit config.in and set the LIB and INCLUDE variables to point
to the directories where libdb.a and db.h are installed.
Undefined symbol db_version
---------------------------
DB_File seems to have built correctly, but you get an error like this
when you run the test harness:
$ make test
PERL_DL_NONLAZY=1 /usr/bin/perl5.00404 -I./blib/arch -I./blib/lib
-I/usr/local/lib/perl5/i586-linux/5.00404 -I/usr/local/lib/perl5 -e 'use
Test::Harness qw(&runtests $verbose); $verbose=0; runtests @ARGV;' t/*.t
t/db-btree..........Can't load './blib/arch/auto/DB_File/DB_File.so' for
module DB_File: ./blib/arch/auto/DB_File/DB_File.so: undefined symbol:
db_version at /usr/local/lib/perl5/i586-linux/5.00404/DynaLoader.pm
line 166.
at t/db-btree.t line 21
BEGIN failed--compilation aborted at t/db-btree.t line 21.
dubious Test returned status 2 (wstat 512, 0x200)
This error usually happens when you have two version of Berkeley DB
installed on your system -- specifically, if you have both version 1 and
a newer version (i.e. version 2 or better) of Berkeley DB installed. If
DB_File is built using the db.h for the newer Berkeley DB and the version
1 Berkeley DB library you will trigger this error. Unfortunately the two
versions aren't compatible with each other. The undefined symbol error is
caused because Berkeley DB version 1 doesn't have the symbol db_version.
Solution: Setting the LIB & INCLUDE variables in config.in to point to the
correct directories can sometimes be enough to fix this
problem. If that doesn't work the easiest way to fix the
problem is to either delete or temporarily rename the copies
of db.h and libdb.a that you don't want DB_File to use.
Undefined symbol dbopen
-----------------------
DB_File seems to have built correctly, but you get an error like this
when you run the test harness:
...
t/db-btree..........Can't load 'blib/arch/auto/DB_File/DB_File.so' for
module DB_File: blib/arch/auto/DB_File/DB_File.so: undefined symbol:
dbopen at /usr/local/lib/perl5/5.6.1/i586-linux/DynaLoader.pm line 206.
at t/db-btree.t line 23
Compilation failed in require at t/db-btree.t line 23.
...
This error usually happens when you have both version 1 and a more recent
version of Berkeley DB installed on your system and DB_File attempts
to build using the db.h for Berkeley DB version 1 and the newer version
library. Unfortunately the two versions aren't compatible with each
other. The undefined symbol error is actually caused because versions
of Berkeley DB newer than version 1 doesn't have the symbol dbopen.
Solution: Setting the LIB & INCLUDE variables in config.in to point to the
correct directories can sometimes be enough to fix this
problem. If that doesn't work the easiest way to fix the
problem is to either delete or temporarily rename the copies
of db.h and libdb.a that you don't want DB_File to use.
Incompatible versions of db.h and libdb
---------------------------------------
BerkeleyDB seems to have built correctly, but you get an error like this
when you run the test harness:
$ make test
PERL_DL_NONLAZY=1 /home/paul/perl/install/bin/perl5.00560 -Iblib/arch
-Iblib/lib -I/home/paul/perl/install/5.005_60/lib/5.00560/i586-linux
-I/home/paul/perl/install/5.005_60/lib/5.00560 -e 'use Test::Harness
qw(&runtests $verbose); $verbose=0; runtests @ARGV;' t/*.t
t/db-btree..........
DB_File was build with libdb version 2.3.7
but you are attempting to run it with libdb version 2.7.5
BEGIN failed--compilation aborted at t/db-btree.t line 21.
...
Another variation on the theme of having two versions of Berkeley DB on
your system.
Solution: Setting the LIB & INCLUDE variables in config.in to point to the
correct directories can sometimes be enough to fix this
problem. If that doesn't work the easiest way to fix the
problem is to either delete or temporarily rename the copies
of db.h and libdb.a that you don't want BerkeleyDB to use.
If you are running Linux, please read the Linux Notes section
below.
Solaris build fails with "language optional software package not installed"
---------------------------------------------------------------------------
If you are trying to build this module under Solaris and you get an
error message like this
/usr/ucb/cc: language optional software package not installed
it means that Perl cannot find the C compiler on your system. The cryptic
message is just Sun's way of telling you that you haven't bought their
C compiler.
When you build a Perl module that needs a C compiler, the Perl build
system tries to use the same C compiler that was used to build perl
itself. In this case your Perl binary was built with a C compiler that
lived in /usr/ucb.
To continue with building this module, you need to get a C compiler,
or tell Perl where your C compiler is, if you already have one.
Assuming you have now got a C compiler, what you do next will be dependant
on what C compiler you have installed. If you have just installed Sun's
C compiler, you shouldn't have to do anything. Just try rebuilding
this module.
If you have installed another C compiler, say gcc, you have to tell perl
how to use it instead of /usr/ucb/cc.
This set of options seems to work if you want to use gcc. Your mileage
may vary.
perl Makefile.PL CC=gcc CCCDLFLAGS=-fPIC OPTIMIZE=" "
make test
If that doesn't work for you, it's time to make changes to the Makefile
by hand. Good luck!
Solaris build fails with "gcc: unrecognized option `-KPIC'"
-----------------------------------------------------------
You are running Solaris and you get an error like this when you try to
build this Perl module
gcc: unrecognized option `-KPIC'
This symptom usually means that you are using a Perl binary that has been
built with the Sun C compiler, but you are using gcc to build this module.
When Perl builds modules that need a C compiler, it will attempt to use
the same C compiler and command line options that was used to build perl
itself. In this case "-KPIC" is a valid option for the Sun C compiler,
but not for gcc. The equivalent option for gcc is "-fPIC".
The solution is either:
1. Build both Perl and this module with the same C compiler, either
by using the Sun C compiler for both or gcc for both.
2. Try generating the Makefile for this module like this perl
perl Makefile.PL CC=gcc CCCDLFLAGS=-fPIC OPTIMIZE=" " LD=gcc
make test
This second option seems to work when mixing a Perl binary built
with the Sun C compiler and this module built with gcc. Your
mileage may vary.
Linux Notes
-----------
Some older versions of Linux (e.g. RedHat 6, SuSe 6) ship with a C library
that has version 2.x of Berkeley DB linked into it. This makes it
difficult to build this module with anything other than the version of
Berkeley DB that shipped with your Linux release. If you do try to use
a different version of Berkeley DB you will most likely get the error
described in the "Incompatible versions of db.h and libdb" section of
this file.
To make matters worse, prior to Perl 5.6.1, the perl binary itself
*always* included the Berkeley DB library.
If you want to use a newer version of Berkeley DB with this module, the
easiest solution is to use Perl 5.6.1 (or better) and Berkeley DB 3.x
(or better).
There are two approaches you can use to get older versions of Perl to
work with specific versions of Berkeley DB. Both have their advantages
and disadvantages.
The first approach will only work when you want to build a version of
Perl older than 5.6.1 along with Berkeley DB 3.x. If you want to use
Berkeley DB 2.x, you must use the next approach. This approach involves
rebuilding your existing version of Perl after applying an unofficial
patch. The "patches" directory in the this module's source distribution
contains a number of patch files. There is one patch file for every
stable version of Perl since 5.004. Apply the appropriate patch to your
Perl source tree before re-building and installing Perl from scratch.
For example, assuming you are in the top-level source directory for
Perl 5.6.0, the command below will apply the necessary patch. Remember
to replace the path shown below with one that points to this module's
patches directory.
patch -p1 -N </path/to/DB_File/patches/5.6.0
Now rebuild & install perl. You should now have a perl binary that can
be used to build this module. Follow the instructions in "BUILDING THE
MODULE", remembering to set the INCLUDE and LIB variables in config.in.
The second approach will work with both Berkeley DB 2.x and 3.x.
Start by building Berkeley DB as a shared library. This is from
the Berkeley DB build instructions:
Building Shared Libraries for the GNU GCC compiler
If you're using gcc and there's no better shared library example for
your architecture, the following shared library build procedure will
probably work.
Add the -fpic option to the CFLAGS value in the Makefile.
Rebuild all of your .o files. This will create a Berkeley DB library
that contains .o files with PIC code. To build the shared library,
then take the following steps in the library build directory:
% mkdir tmp
% cd tmp
% ar xv ../libdb.a
% gcc -shared -o libdb.so *.o
% mv libdb.so ..
% cd ..
% rm -rf tmp
Note, you may have to change the gcc line depending on the
requirements of your system.
The file libdb.so is your shared library
Once you have built libdb.so, you will need to store it somewhere safe.
cp libdb.so /usr/local/BerkeleyDB/lib
If you now set the LD_PRELOAD environment variable to point to this
shared library, Perl will use it instead of the version of Berkeley DB
that shipped with your Linux distribution.
export LD_PRELOAD=/usr/local/BerkeleyDB/lib/libdb.so
Finally follow the instructions in "BUILDING THE MODULE" to build,
test and install this module. Don't forget to set the INCLUDE and LIB
variables in config.in.
Remember, you will need to have the LD_PRELOAD variable set anytime you
want to use Perl with Berkeley DB. Also note that if you have LD_PRELOAD
permanently set it will affect ALL commands you execute. This may be a
problem if you run any commands that access a database created by the
version of Berkeley DB that shipped with your Linux distribution.
Solaris Notes
-------------
If you are running Solaris 2.5, and you get this error when you run the
DB_File test harness:
libc internal error: _rmutex_unlock: rmutex not held.
you probably need to install a Sun patch. It has been reported that
Sun patch 103187-25 (or later revisions) fixes this problem.
To find out if you have the patch installed, the command "showrev -p"
will display the patches that are currently installed on your system.
HP-UX 10 Notes
--------------
Some people running HP-UX 10 have reported getting an error like this
when building DB_File with the native HP-UX compiler.
ld: (Warning) At least one PA 2.0 object file (DB_File.o) was detected.
The linked output may not run on a PA 1.x system.
ld: Invalid loader fixup for symbol "$000000A5".
If this is the case for you, Berkeley DB needs to be recompiled with
the +z or +Z option and the resulting library placed in a .sl file. The
following steps should do the trick:
1: Configure the Berkeley DB distribution with the +z or +Z C compiler
flag:
env "CFLAGS=+z" ../dist/configure ...
2: Edit the Berkeley DB Makefile and change:
"libdb= libdb.a" to "libdb= libdb.sl".
3: Build and install the Berkeley DB distribution as usual.
HP-UX 11 Notes
--------------
Some people running the combination of HP-UX 11 and Berkeley DB 2.7.7 have
reported getting this error when the run the test harness for DB_File
...
lib/db-btree.........Can't call method "DELETE" on an undefined value at lib/db-btree.t line 216.
FAILED at test 26
lib/db-hash..........Can't call method "DELETE" on an undefined value at lib/db-hash.t line 183.
FAILED at test 22
...
The fix for this is to rebuild and install Berkeley DB with the bigfile
option disabled.
IRIX NOTES
----------
If you are running IRIX, and want to use Berkeley DB version 1, you can
get it from http://reality.sgi.com/ariel. It has the patches necessary
to compile properly on IRIX 5.3.
AIX NOTES
---------
I've had reports of a build failure like this on AIX 5.2 using the
xlC compiler.
rm -f blib/arch/auto/DB_File/DB_File.so
LD_RUN_PATH="" ld -bhalt:4 -bM:SRE -bI:/usr/local/5.8.1/lib/perl5/5.8.1/aix/CORE/perl.exp -bE:DB_File.exp -bnoentry -lc
-L/usr/local/lib version.o DB_File.o -o blib/arch/auto/DB_File/DB_File.so
-L/usr/local/BerkeleyDB/lib -ldb -lpthread
ld: 0711-317 ERROR: Undefined symbol: .mutex_lock
ld: 0711-317 ERROR: Undefined symbol: .cond_signal
ld: 0711-317 ERROR: Undefined symbol: .mutex_unlock
ld: 0711-317 ERROR: Undefined symbol: .mutex_trylock
ld: 0711-317 ERROR: Undefined symbol: .cond_wait
ld: 0711-317 ERROR: Undefined symbol: .mutex_init
ld: 0711-317 ERROR: Undefined symbol: .cond_init
ld: 0711-317 ERROR: Undefined symbol: .mutex_destroy
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
make: 1254-004 The error code from the last command is 8.
Editing Makefile.PL, and changing the line
$LIBS .= " -lpthread" if $^O eq 'aix' ;
to this
$LIBS .= " -lthread" if $^O eq 'aix' ;
fixed the problem.
FEEDBACK
========
General feedback/questions/bug reports can be sent to me at pmqs@cpan.org.
Alternatively, if you have Usenet access, you can try the
comp.databases.berkeley-db or comp.lang.perl.modules groups.
How to report a problem with DB_File.
-------------------------------------
When reporting any problem, I need the information requested below.
1. The *complete* output from running this
perl -V
Do not edit the output in any way.
Note, I want you to run "perl -V" and NOT "perl -v".
If your perl does not understand the "-V" option it is too
old. DB_File needs Perl version 5.00405 or better.
2. The version of DB_File you have.
If you have successfully installed DB_File, this one-liner will
tell you:
perl -e 'use DB_File; print qq{DB_File ver $DB_File::VERSION\n}'
If you are running windows use this
perl -e "use DB_File; print qq{DB_File ver $DB_File::VERSION\n}"
If you haven't installed DB_File then search DB_File.pm for a line
like this:
$VERSION = "1.20" ;
3. The version of Berkeley DB used to build DB_File and the version
that is used at runtime. (These are usually the same)
If you are using a version older than 1.85, think about upgrading. One
point to note if you are considering upgrading Berkeley DB - the
file formats for 1.85, 1.86, 2.0, 3.0 & 3.1 are all different.
If you have successfully installed DB_File, these commands will display
the versions I need
perl -MDB_File -e 'print qq{Built with Berkeley DB ver $DB_File::db_ver\n}'
perl -MDB_File -e 'print qq{Running with Berkeley DB ver $DB_File::db_version\n}'
If you are running windows use this
perl -e "use DB_File; print qq{Built with Berkeley DB ver $DB_File::db_ver\n}"
perl -e "use DB_File; print qq{Running Berkeley DB ver $DB_File::db_version\n}"
4. A copy the file config.in from the DB_File main source directory.
5. A listing of directories where Berkeley DB is installed.
For example, if Berkeley DB is installed in /usr/BerkeleDB/lib and
/usr/BerkeleyDB/include, I need the output from running this
ls -l /usr/BerkeleyDB/lib
ls -l /usr/BerkeleyDB/include
6. If you are having problems building DB_File, send me a complete log
of what happened. Start by unpacking the DB_File module into a fresh
directory and keep a log of all the steps
[edit config.in, if necessary]
perl Makefile.PL
make
make test TEST_VERBOSE=1
7. Now the difficult one. If you think you have found a bug in DB_File
and you want me to fix it, you will *greatly* enhance the chances
of me being able to track it down by sending me a small
self-contained Perl script that illustrates the problem you are
encountering. Include a summary of what you think the problem is
and a log of what happens when you run the script, in case I can't
reproduce your problem on my system. If possible, don't have the
script dependent on an existing 20Meg database. If the script you
send me can create the database itself then that is preferred.
I realise that in some cases this is easier said than done, so if
you can only reproduce the problem in your existing script, then
you can post me that if you want. Just don't expect me to find your
problem in a hurry, or at all. :-)
CHANGES
-------
See the Changes file.
Paul Marquess <pmqs@cpan.org>

97
perl/DB_File/config.in Normal file
View File

@@ -0,0 +1,97 @@
# Filename: config.in
#
# written by Paul Marquess <Paul.Marquess@btinternet.com>
# last modified 9th Sept 1997
# version 1.55
# 1. Where is the file db.h?
#
# Change the path below to point to the directory where db.h is
# installed on your system.
INCLUDE = /usr/local/BerkeleyDB/include
#INCLUDE = /usr/local/include
#INCLUDE = /usr/include
# 2. Where is libdb?
#
# Change the path below to point to the directory where libdb is
# installed on your system.
LIB = /usr/local/BerkeleyDB/lib
#LIB = /usr/local/lib
#LIB = /usr/lib
# 3. What version of Berkely DB have you got?
#
# If you have version 2.0 or greater, you can skip this question.
#
# If you have Berkeley DB 1.78 or greater you shouldn't have to
# change the definitions for PREFIX and HASH below.
#
# For older versions of Berkeley DB change both PREFIX and HASH to int.
# Version 1.71, 1.72 and 1.73 are known to need this change.
#
# If you don't know what version you have have a look in the file db.h.
#
# Search for the string "DB_VERSION_MAJOR". If it is present, you
# have Berkeley DB version 2 (or greater).
#
# If that didn't work, find the definition of the BTREEINFO typedef.
# Check the return type from the prefix element. It should look like
# this in an older copy of db.h:
#
# int (*prefix) __P((const DBT *, const DBT *));
#
# and like this in a more recent copy:
#
# size_t (*prefix) /* prefix function */
# __P((const DBT *, const DBT *));
#
# Change the definition of PREFIX, below, to reflect the return type
# of the prefix function in your db.h.
#
# Now find the definition of the HASHINFO typedef. Check the return
# type of the hash element. Older versions look like this:
#
# int (*hash) __P((const void *, size_t));
#
# newer like this:
#
# u_int32_t /* hash function */
# (*hash) __P((const void *, size_t));
#
# Change the definition of HASH, below, to reflect the return type of
# the hash function in your db.h.
#
PREFIX = size_t
HASH = u_int32_t
# 4. Is the library called libdb?
#
# If you have copies of both 1.x and 2.x Berkeley DB installed on
# your system it can sometimes be tricky to make sure you are using
# the correct one. Renaming one (or creating a symbolic link) to
# include the version number of the library can help.
#
# For example, if you have both Berkeley DB 2.3.12 and 1.85 on your
# system and you want to use the Berkeley DB version 2 library you
# could rename the version 2 library from libdb.a to libdb-2.3.12.a and
# change the DBNAME line below to look like this:
#
# DBNAME = -ldb-2.3.12
#
# That will ensure you are linking the correct version of the DB
# library.
#
# Note: If you are building this module with Win32, -llibdb will be
# used by default.
#
# If you have changed the name of the library, uncomment the line
# below (by removing the leading #) and edit the line to use the name
# you have picked.
#DBNAME = -ldb-2.4.10
# end of file config.in

133
perl/DB_File/dbinfo Normal file
View File

@@ -0,0 +1,133 @@
#!/usr/local/bin/perl
# Name: dbinfo -- identify berkeley DB version used to create
# a database file
#
# Author: Paul Marquess <Paul.Marquess@btinternet.com>
# Version: 1.06
# Date 27th MArch 2008
#
# Copyright (c) 1998-2008 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.
# Todo: Print more stats on a db file, e.g. no of records
# add log/txn/lock files
use strict ;
my %Data =
(
0x053162 => # DB_BTREEMAGIC
{
Type => "Btree",
Versions => # DB_BTREEVERSION
{
1 => [0, "Unknown (older than 1.71)"],
2 => [0, "Unknown (older than 1.71)"],
3 => [0, "1.71 -> 1.85, 1.86"],
4 => [0, "Unknown"],
5 => [0, "2.0.0 -> 2.3.0"],
6 => [0, "2.3.1 -> 2.7.7"],
7 => [0, "3.0.x"],
8 => [0, "3.1.x -> 4.0.x"],
9 => [1, "4.1.x or greater"],
}
},
0x061561 => # DB_HASHMAGIC
{
Type => "Hash",
Versions => # DB_HASHVERSION
{
1 => [0, "Unknown (older than 1.71)"],
2 => [0, "1.71 -> 1.85"],
3 => [0, "1.86"],
4 => [0, "2.0.0 -> 2.1.0"],
5 => [0, "2.2.6 -> 2.7.7"],
6 => [0, "3.0.x"],
7 => [0, "3.1.x -> 4.0.x"],
8 => [1, "4.1.x or greater"],
9 => [1, "4.6.x or greater"],
}
},
0x042253 => # DB_QAMMAGIC
{
Type => "Queue",
Versions => # DB_QAMVERSION
{
1 => [0, "3.0.x"],
2 => [0, "3.1.x"],
3 => [0, "3.2.x -> 4.0.x"],
4 => [1, "4.1.x or greater"],
}
},
) ;
die "Usage: dbinfo file\n" unless @ARGV == 1 ;
print "testing file $ARGV[0]...\n\n" ;
open (F, "<$ARGV[0]") or die "Cannot open file $ARGV[0]: $!\n" ;
my $buff ;
read F, $buff, 30 ;
my (@info) = unpack("NNNNNNC", $buff) ;
my (@info1) = unpack("VVVVVVC", $buff) ;
my ($magic, $version, $endian, $encrypt) ;
if ($Data{$info[0]}) # first try DB 1.x format, big endian
{
$magic = $info[0] ;
$version = $info[1] ;
$endian = "Big Endian" ;
$encrypt = "Not Supported";
}
elsif ($Data{$info1[0]}) # first try DB 1.x format, little endian
{
$magic = $info1[0] ;
$version = $info1[1] ;
$endian = "Little Endian" ;
$encrypt = "Not Supported";
}
elsif ($Data{$info[3]}) # next DB 2.x big endian
{
$magic = $info[3] ;
$version = $info[4] ;
$endian = "Big Endian" ;
}
elsif ($Data{$info1[3]}) # next DB 2.x little endian
{
$magic = $info1[3] ;
$version = $info1[4] ;
$endian = "Little Endian" ;
}
else
{ die "not a Berkeley DB database file.\n" }
my $type = $Data{$magic} ;
$magic = sprintf "%06X", $magic ;
my $ver_string = "Unknown" ;
if ( defined $type->{Versions}{$version} )
{
$ver_string = $type->{Versions}{$version}[1];
if ($type->{Versions}{$version}[0] )
{ $encrypt = $info[6] ? "Enabled" : "Disabled" }
else
{ $encrypt = "Not Supported" }
}
print <<EOM ;
File Type: Berkeley DB $type->{Type} file.
File Version ID: $version
Built with Berkeley DB: $ver_string
Byte Order: $endian
Magic: $magic
Encryption: $encrypt
EOM
close F ;
exit ;

455
perl/DB_File/fallback.h Normal file
View File

@@ -0,0 +1,455 @@
#define PERL_constant_NOTFOUND 1
#define PERL_constant_NOTDEF 2
#define PERL_constant_ISIV 3
#define PERL_constant_ISNO 4
#define PERL_constant_ISNV 5
#define PERL_constant_ISPV 6
#define PERL_constant_ISPVN 7
#define PERL_constant_ISSV 8
#define PERL_constant_ISUNDEF 9
#define PERL_constant_ISUV 10
#define PERL_constant_ISYES 11
#ifndef NVTYPE
typedef double NV; /* 5.6 and later define NVTYPE, and typedef NV to it. */
#endif
#ifndef aTHX_
#define aTHX_ /* 5.6 or later define this for threading support. */
#endif
#ifndef pTHX_
#define pTHX_ /* 5.6 or later define this for threading support. */
#endif
static int
constant_6 (pTHX_ const char *name, IV *iv_return) {
/* When generated this function returned values for the list of names given
here. However, subsequent manual editing may have added or removed some.
DB_TXN R_LAST R_NEXT R_PREV */
/* Offset 2 gives the best switch position. */
switch (name[2]) {
case 'L':
if (memEQ(name, "R_LAST", 6)) {
/* ^ */
#ifdef R_LAST
*iv_return = R_LAST;
return PERL_constant_ISIV;
#else
return PERL_constant_NOTDEF;
#endif
}
break;
case 'N':
if (memEQ(name, "R_NEXT", 6)) {
/* ^ */
#ifdef R_NEXT
*iv_return = R_NEXT;
return PERL_constant_ISIV;
#else
return PERL_constant_NOTDEF;
#endif
}
break;
case 'P':
if (memEQ(name, "R_PREV", 6)) {
/* ^ */
#ifdef R_PREV
*iv_return = R_PREV;
return PERL_constant_ISIV;
#else
return PERL_constant_NOTDEF;
#endif
}
break;
case '_':
if (memEQ(name, "DB_TXN", 6)) {
/* ^ */
#ifdef DB_TXN
*iv_return = DB_TXN;
return PERL_constant_ISIV;
#else
return PERL_constant_NOTDEF;
#endif
}
break;
}
return PERL_constant_NOTFOUND;
}
static int
constant_7 (pTHX_ const char *name, IV *iv_return) {
/* When generated this function returned values for the list of names given
here. However, subsequent manual editing may have added or removed some.
DB_LOCK R_FIRST R_NOKEY */
/* Offset 3 gives the best switch position. */
switch (name[3]) {
case 'I':
if (memEQ(name, "R_FIRST", 7)) {
/* ^ */
#ifdef R_FIRST
*iv_return = R_FIRST;
return PERL_constant_ISIV;
#else
return PERL_constant_NOTDEF;
#endif
}
break;
case 'L':
if (memEQ(name, "DB_LOCK", 7)) {
/* ^ */
#ifdef DB_LOCK
*iv_return = DB_LOCK;
return PERL_constant_ISIV;
#else
return PERL_constant_NOTDEF;
#endif
}
break;
case 'O':
if (memEQ(name, "R_NOKEY", 7)) {
/* ^ */
#ifdef R_NOKEY
*iv_return = R_NOKEY;
return PERL_constant_ISIV;
#else
return PERL_constant_NOTDEF;
#endif
}
break;
}
return PERL_constant_NOTFOUND;
}
static int
constant_8 (pTHX_ const char *name, IV *iv_return) {
/* When generated this function returned values for the list of names given
here. However, subsequent manual editing may have added or removed some.
DB_SHMEM R_CURSOR R_IAFTER */
/* Offset 5 gives the best switch position. */
switch (name[5]) {
case 'M':
if (memEQ(name, "DB_SHMEM", 8)) {
/* ^ */
#ifdef DB_SHMEM
*iv_return = DB_SHMEM;
return PERL_constant_ISIV;
#else
return PERL_constant_NOTDEF;
#endif
}
break;
case 'S':
if (memEQ(name, "R_CURSOR", 8)) {
/* ^ */
#ifdef R_CURSOR
*iv_return = R_CURSOR;
return PERL_constant_ISIV;
#else
return PERL_constant_NOTDEF;
#endif
}
break;
case 'T':
if (memEQ(name, "R_IAFTER", 8)) {
/* ^ */
#ifdef R_IAFTER
*iv_return = R_IAFTER;
return PERL_constant_ISIV;
#else
return PERL_constant_NOTDEF;
#endif
}
break;
}
return PERL_constant_NOTFOUND;
}
static int
constant_9 (pTHX_ const char *name, IV *iv_return) {
/* When generated this function returned values for the list of names given
here. However, subsequent manual editing may have added or removed some.
HASHMAGIC RET_ERROR R_IBEFORE */
/* Offset 7 gives the best switch position. */
switch (name[7]) {
case 'I':
if (memEQ(name, "HASHMAGIC", 9)) {
/* ^ */
#ifdef HASHMAGIC
*iv_return = HASHMAGIC;
return PERL_constant_ISIV;
#else
return PERL_constant_NOTDEF;
#endif
}
break;
case 'O':
if (memEQ(name, "RET_ERROR", 9)) {
/* ^ */
#ifdef RET_ERROR
*iv_return = RET_ERROR;
return PERL_constant_ISIV;
#else
return PERL_constant_NOTDEF;
#endif
}
break;
case 'R':
if (memEQ(name, "R_IBEFORE", 9)) {
/* ^ */
#ifdef R_IBEFORE
*iv_return = R_IBEFORE;
return PERL_constant_ISIV;
#else
return PERL_constant_NOTDEF;
#endif
}
break;
}
return PERL_constant_NOTFOUND;
}
static int
constant_10 (pTHX_ const char *name, IV *iv_return) {
/* When generated this function returned values for the list of names given
here. However, subsequent manual editing may have added or removed some.
BTREEMAGIC R_FIXEDLEN R_SNAPSHOT __R_UNUSED */
/* Offset 5 gives the best switch position. */
switch (name[5]) {
case 'E':
if (memEQ(name, "R_FIXEDLEN", 10)) {
/* ^ */
#ifdef R_FIXEDLEN
*iv_return = R_FIXEDLEN;
return PERL_constant_ISIV;
#else
return PERL_constant_NOTDEF;
#endif
}
break;
case 'M':
if (memEQ(name, "BTREEMAGIC", 10)) {
/* ^ */
#ifdef BTREEMAGIC
*iv_return = BTREEMAGIC;
return PERL_constant_ISIV;
#else
return PERL_constant_NOTDEF;
#endif
}
break;
case 'N':
if (memEQ(name, "__R_UNUSED", 10)) {
/* ^ */
#ifdef __R_UNUSED
*iv_return = __R_UNUSED;
return PERL_constant_ISIV;
#else
return PERL_constant_NOTDEF;
#endif
}
break;
case 'P':
if (memEQ(name, "R_SNAPSHOT", 10)) {
/* ^ */
#ifdef R_SNAPSHOT
*iv_return = R_SNAPSHOT;
return PERL_constant_ISIV;
#else
return PERL_constant_NOTDEF;
#endif
}
break;
}
return PERL_constant_NOTFOUND;
}
static int
constant_11 (pTHX_ const char *name, IV *iv_return) {
/* When generated this function returned values for the list of names given
here. However, subsequent manual editing may have added or removed some.
HASHVERSION RET_SPECIAL RET_SUCCESS R_RECNOSYNC R_SETCURSOR */
/* Offset 10 gives the best switch position. */
switch (name[10]) {
case 'C':
if (memEQ(name, "R_RECNOSYNC", 11)) {
/* ^ */
#ifdef R_RECNOSYNC
*iv_return = R_RECNOSYNC;
return PERL_constant_ISIV;
#else
return PERL_constant_NOTDEF;
#endif
}
break;
case 'L':
if (memEQ(name, "RET_SPECIAL", 11)) {
/* ^ */
#ifdef RET_SPECIAL
*iv_return = RET_SPECIAL;
return PERL_constant_ISIV;
#else
return PERL_constant_NOTDEF;
#endif
}
break;
case 'N':
if (memEQ(name, "HASHVERSION", 11)) {
/* ^ */
#ifdef HASHVERSION
*iv_return = HASHVERSION;
return PERL_constant_ISIV;
#else
return PERL_constant_NOTDEF;
#endif
}
break;
case 'R':
if (memEQ(name, "R_SETCURSOR", 11)) {
/* ^ */
#ifdef R_SETCURSOR
*iv_return = R_SETCURSOR;
return PERL_constant_ISIV;
#else
return PERL_constant_NOTDEF;
#endif
}
break;
case 'S':
if (memEQ(name, "RET_SUCCESS", 11)) {
/* ^ */
#ifdef RET_SUCCESS
*iv_return = RET_SUCCESS;
return PERL_constant_ISIV;
#else
return PERL_constant_NOTDEF;
#endif
}
break;
}
return PERL_constant_NOTFOUND;
}
static int
constant (pTHX_ const char *name, STRLEN len, IV *iv_return) {
/* Initially switch on the length of the name. */
/* When generated this function returned values for the list of names given
in this section of perl code. Rather than manually editing these functions
to add or remove constants, which would result in this comment and section
of code becoming inaccurate, we recommend that you edit this section of
code, and use it to regenerate a new set of constant functions which you
then use to replace the originals.
Regenerate these constant functions by feeding this entire source file to
perl -x
#!bleedperl -w
use ExtUtils::Constant qw (constant_types C_constant XS_constant);
my $types = {map {($_, 1)} qw(IV)};
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));
print constant_types(); # macro defs
foreach (C_constant ("DB_File", 'constant', 'IV', $types, undef, 3, @names) ) {
print $_, "\n"; # C constant subs
}
print "#### XS Section:\n";
print XS_constant ("DB_File", $types);
__END__
*/
switch (len) {
case 5:
if (memEQ(name, "R_DUP", 5)) {
#ifdef R_DUP
*iv_return = R_DUP;
return PERL_constant_ISIV;
#else
return PERL_constant_NOTDEF;
#endif
}
break;
case 6:
return constant_6 (aTHX_ name, iv_return);
break;
case 7:
return constant_7 (aTHX_ name, iv_return);
break;
case 8:
return constant_8 (aTHX_ name, iv_return);
break;
case 9:
return constant_9 (aTHX_ name, iv_return);
break;
case 10:
return constant_10 (aTHX_ name, iv_return);
break;
case 11:
return constant_11 (aTHX_ name, iv_return);
break;
case 12:
if (memEQ(name, "BTREEVERSION", 12)) {
#ifdef BTREEVERSION
*iv_return = BTREEVERSION;
return PERL_constant_ISIV;
#else
return PERL_constant_NOTDEF;
#endif
}
break;
case 13:
if (memEQ(name, "R_NOOVERWRITE", 13)) {
#ifdef R_NOOVERWRITE
*iv_return = R_NOOVERWRITE;
return PERL_constant_ISIV;
#else
return PERL_constant_NOTDEF;
#endif
}
break;
case 14:
if (memEQ(name, "MAX_REC_NUMBER", 14)) {
#ifdef MAX_REC_NUMBER
*iv_return = MAX_REC_NUMBER;
return PERL_constant_ISIV;
#else
return PERL_constant_NOTDEF;
#endif
}
break;
case 15:
/* Names all of length 15. */
/* MAX_PAGE_NUMBER MAX_PAGE_OFFSET */
/* Offset 9 gives the best switch position. */
switch (name[9]) {
case 'N':
if (memEQ(name, "MAX_PAGE_NUMBER", 15)) {
/* ^ */
#ifdef MAX_PAGE_NUMBER
*iv_return = MAX_PAGE_NUMBER;
return PERL_constant_ISIV;
#else
return PERL_constant_NOTDEF;
#endif
}
break;
case 'O':
if (memEQ(name, "MAX_PAGE_OFFSET", 15)) {
/* ^ */
#ifdef MAX_PAGE_OFFSET
*iv_return = MAX_PAGE_OFFSET;
return PERL_constant_ISIV;
#else
return PERL_constant_NOTDEF;
#endif
}
break;
}
break;
}
return PERL_constant_NOTFOUND;
}

88
perl/DB_File/fallback.xs Normal file
View File

@@ -0,0 +1,88 @@
void
constant(sv)
PREINIT:
#ifdef dXSTARG
dXSTARG; /* Faster if we have it. */
#else
dTARGET;
#endif
STRLEN len;
int type;
IV iv;
/* NV nv; Uncomment this if you need to return NVs */
/* const char *pv; Uncomment this if you need to return PVs */
INPUT:
SV * sv;
const char * s = SvPV(sv, len);
PPCODE:
/* Change this to constant(aTHX_ s, len, &iv, &nv);
if you need to return both NVs and IVs */
type = constant(aTHX_ s, len, &iv);
/* Return 1 or 2 items. First is error message, or undef if no error.
Second, if present, is found value */
switch (type) {
case PERL_constant_NOTFOUND:
sv = sv_2mortal(newSVpvf("%s is not a valid DB_File macro", s));
PUSHs(sv);
break;
case PERL_constant_NOTDEF:
sv = sv_2mortal(newSVpvf(
"Your vendor has not defined DB_File macro %s, used", s));
PUSHs(sv);
break;
case PERL_constant_ISIV:
EXTEND(SP, 1);
PUSHs(&PL_sv_undef);
PUSHi(iv);
break;
/* Uncomment this if you need to return NOs
case PERL_constant_ISNO:
EXTEND(SP, 1);
PUSHs(&PL_sv_undef);
PUSHs(&PL_sv_no);
break; */
/* Uncomment this if you need to return NVs
case PERL_constant_ISNV:
EXTEND(SP, 1);
PUSHs(&PL_sv_undef);
PUSHn(nv);
break; */
/* Uncomment this if you need to return PVs
case PERL_constant_ISPV:
EXTEND(SP, 1);
PUSHs(&PL_sv_undef);
PUSHp(pv, strlen(pv));
break; */
/* Uncomment this if you need to return PVNs
case PERL_constant_ISPVN:
EXTEND(SP, 1);
PUSHs(&PL_sv_undef);
PUSHp(pv, iv);
break; */
/* Uncomment this if you need to return SVs
case PERL_constant_ISSV:
EXTEND(SP, 1);
PUSHs(&PL_sv_undef);
PUSHs(sv);
break; */
/* Uncomment this if you need to return UNDEFs
case PERL_constant_ISUNDEF:
break; */
/* Uncomment this if you need to return UVs
case PERL_constant_ISUV:
EXTEND(SP, 1);
PUSHs(&PL_sv_undef);
PUSHu((UV)iv);
break; */
/* Uncomment this if you need to return YESs
case PERL_constant_ISYES:
EXTEND(SP, 1);
PUSHs(&PL_sv_undef);
PUSHs(&PL_sv_yes);
break; */
default:
sv = sv_2mortal(newSVpvf(
"Unexpected return type %d while processing DB_File macro %s, used",
type, s));
PUSHs(sv);
}

View File

@@ -0,0 +1,3 @@
# Need to add an extra '-lc' to the end to work around a DYNIX/ptx bug
$self->{LIBS} = ['-lm -lc'];

View File

@@ -0,0 +1,2 @@
# osr5 needs to explicitly link against libc to pull in some static symbols
$self->{LIBS} = ['-ldb -lc'] if $Config{'osvers'} =~ '3\.2v5\.0\..' ;

View File

@@ -0,0 +1,93 @@
diff -rc perl5.004.orig/Configure perl5.004/Configure
*** perl5.004.orig/Configure 1997-05-13 18:20:34.000000000 +0100
--- perl5.004/Configure 2003-04-26 16:36:53.000000000 +0100
***************
*** 188,193 ****
--- 188,194 ----
mv=''
nroff=''
perl=''
+ perllibs=''
pg=''
pmake=''
pr=''
***************
*** 9902,9907 ****
--- 9903,9916 ----
shift
extensions="$*"
+ : Remove libraries needed only for extensions
+ : The appropriate ext/Foo/Makefile.PL will add them back in, if
+ : necessary.
+ set X `echo " $libs " |
+ sed -e 's@ -lndbm @ @' -e 's@ -lgdbm @ @' -e 's@ -ldbm @ @' -e 's@ -ldb @ @'`
+ shift
+ perllibs="$*"
+
: Remove build directory name from cppstdin so it can be used from
: either the present location or the final installed location.
echo " "
***************
*** 10370,10375 ****
--- 10379,10385 ----
patchlevel='$patchlevel'
path_sep='$path_sep'
perl='$perl'
+ perllibs='$perllibs'
perladmin='$perladmin'
perlpath='$perlpath'
pg='$pg'
diff -rc perl5.004.orig/Makefile.SH perl5.004/Makefile.SH
*** perl5.004.orig/Makefile.SH 1997-05-01 15:22:39.000000000 +0100
--- perl5.004/Makefile.SH 2003-04-26 16:37:23.000000000 +0100
***************
*** 119,125 ****
ext = \$(dynamic_ext) \$(static_ext)
DYNALOADER = lib/auto/DynaLoader/DynaLoader\$(LIB_EXT)
! libs = $libs $cryptlib
public = perl $suidperl utilities translators
--- 119,125 ----
ext = \$(dynamic_ext) \$(static_ext)
DYNALOADER = lib/auto/DynaLoader/DynaLoader\$(LIB_EXT)
! libs = $perllibs $cryptlib
public = perl $suidperl utilities translators
diff -rc perl5.004.orig/myconfig perl5.004/myconfig
*** perl5.004.orig/myconfig 1996-12-21 01:13:20.000000000 +0000
--- perl5.004/myconfig 2003-04-26 16:37:51.000000000 +0100
***************
*** 35,41 ****
Linker and Libraries:
ld='$ld', ldflags ='$ldflags'
libpth=$libpth
! libs=$libs
libc=$libc, so=$so
useshrplib=$useshrplib, libperl=$libperl
Dynamic Linking:
--- 35,41 ----
Linker and Libraries:
ld='$ld', ldflags ='$ldflags'
libpth=$libpth
! libs=$perllibs
libc=$libc, so=$so
useshrplib=$useshrplib, libperl=$libperl
Dynamic Linking:
diff -rc perl5.004.orig/patchlevel.h perl5.004/patchlevel.h
*** perl5.004.orig/patchlevel.h 1997-05-15 23:15:17.000000000 +0100
--- perl5.004/patchlevel.h 2003-04-26 16:38:11.000000000 +0100
***************
*** 38,43 ****
--- 38,44 ----
*/
static char *local_patches[] = {
NULL
+ ,"NODB-1.0 - remove -ldb from core perl binary."
,NULL
};

View File

@@ -0,0 +1,217 @@
diff -rc perl5.004_01.orig/Configure perl5.004_01/Configure
*** perl5.004_01.orig/Configure Wed Jun 11 00:28:03 1997
--- perl5.004_01/Configure Sun Nov 12 22:12:35 2000
***************
*** 188,193 ****
--- 188,194 ----
mv=''
nroff=''
perl=''
+ perllibs=''
pg=''
pmake=''
pr=''
***************
*** 9907,9912 ****
--- 9908,9921 ----
shift
extensions="$*"
+ : Remove libraries needed only for extensions
+ : The appropriate ext/Foo/Makefile.PL will add them back in, if
+ : necessary.
+ set X `echo " $libs " |
+ sed -e 's@ -lndbm @ @' -e 's@ -lgdbm @ @' -e 's@ -ldbm @ @' -e 's@ -ldb @ @'`
+ shift
+ perllibs="$*"
+
: Remove build directory name from cppstdin so it can be used from
: either the present location or the final installed location.
echo " "
***************
*** 10375,10380 ****
--- 10384,10390 ----
patchlevel='$patchlevel'
path_sep='$path_sep'
perl='$perl'
+ perllibs='$perllibs'
perladmin='$perladmin'
perlpath='$perlpath'
pg='$pg'
diff -rc perl5.004_01.orig/Makefile.SH perl5.004_01/Makefile.SH
*** perl5.004_01.orig/Makefile.SH Thu Jun 12 23:27:56 1997
--- perl5.004_01/Makefile.SH Sun Nov 12 22:12:35 2000
***************
*** 126,132 ****
ext = \$(dynamic_ext) \$(static_ext)
DYNALOADER = lib/auto/DynaLoader/DynaLoader\$(LIB_EXT)
! libs = $libs $cryptlib
public = perl $suidperl utilities translators
--- 126,132 ----
ext = \$(dynamic_ext) \$(static_ext)
DYNALOADER = lib/auto/DynaLoader/DynaLoader\$(LIB_EXT)
! libs = $perllibs $cryptlib
public = perl $suidperl utilities translators
diff -rc perl5.004_01.orig/lib/ExtUtils/Embed.pm perl5.004_01/lib/ExtUtils/Embed.pm
*** perl5.004_01.orig/lib/ExtUtils/Embed.pm Wed Apr 2 22:12:04 1997
--- perl5.004_01/lib/ExtUtils/Embed.pm Sun Nov 12 22:12:35 2000
***************
*** 170,176 ****
@path = $path ? split(/:/, $path) : @INC;
push(@potential_libs, @link_args) if scalar @link_args;
! push(@potential_libs, $Config{libs}) if defined $std;
push(@mods, static_ext()) if $std;
--- 170,176 ----
@path = $path ? split(/:/, $path) : @INC;
push(@potential_libs, @link_args) if scalar @link_args;
! push(@potential_libs, $Config{perllibs}) if defined $std;
push(@mods, static_ext()) if $std;
diff -rc perl5.004_01.orig/lib/ExtUtils/Liblist.pm perl5.004_01/lib/ExtUtils/Liblist.pm
*** perl5.004_01.orig/lib/ExtUtils/Liblist.pm Sat Jun 7 01:19:44 1997
--- perl5.004_01/lib/ExtUtils/Liblist.pm Sun Nov 12 22:13:27 2000
***************
*** 16,33 ****
sub _unix_os2_ext {
my($self,$potential_libs, $Verbose) = @_;
! if ($^O =~ 'os2' and $Config{libs}) {
# Dynamic libraries are not transitive, so we may need including
# the libraries linked against perl.dll again.
$potential_libs .= " " if $potential_libs;
! $potential_libs .= $Config{libs};
}
return ("", "", "", "") unless $potential_libs;
print STDOUT "Potential libraries are '$potential_libs':\n" if $Verbose;
my($so) = $Config{'so'};
! my($libs) = $Config{'libs'};
my $Config_libext = $Config{lib_ext} || ".a";
--- 16,33 ----
sub _unix_os2_ext {
my($self,$potential_libs, $Verbose) = @_;
! if ($^O =~ 'os2' and $Config{perllibs}) {
# Dynamic libraries are not transitive, so we may need including
# the libraries linked against perl.dll again.
$potential_libs .= " " if $potential_libs;
! $potential_libs .= $Config{perllibs};
}
return ("", "", "", "") unless $potential_libs;
print STDOUT "Potential libraries are '$potential_libs':\n" if $Verbose;
my($so) = $Config{'so'};
! my($libs) = $Config{'perllibs'};
my $Config_libext = $Config{lib_ext} || ".a";
***************
*** 186,196 ****
my($self, $potential_libs, $Verbose) = @_;
# If user did not supply a list, we punt.
! # (caller should probably use the list in $Config{libs})
return ("", "", "", "") unless $potential_libs;
my($so) = $Config{'so'};
! my($libs) = $Config{'libs'};
my($libpth) = $Config{'libpth'};
my($libext) = $Config{'lib_ext'} || ".lib";
--- 186,196 ----
my($self, $potential_libs, $Verbose) = @_;
# If user did not supply a list, we punt.
! # (caller should probably use the list in $Config{perllibs})
return ("", "", "", "") unless $potential_libs;
my($so) = $Config{'so'};
! my($libs) = $Config{'perllibs'};
my($libpth) = $Config{'libpth'};
my($libext) = $Config{'lib_ext'} || ".lib";
***************
*** 540,546 ****
=item *
If C<$potential_libs> is empty, the return value will be empty.
! Otherwise, the libraries specified by C<$Config{libs}> (see Config.pm)
will be appended to the list of C<$potential_libs>. The libraries
will be searched for in the directories specified in C<$potential_libs>
as well as in C<$Config{libpth}>. For each library that is found, a
--- 540,546 ----
=item *
If C<$potential_libs> is empty, the return value will be empty.
! Otherwise, the libraries specified by C<$Config{perllibs}> (see Config.pm)
will be appended to the list of C<$potential_libs>. The libraries
will be searched for in the directories specified in C<$potential_libs>
as well as in C<$Config{libpth}>. For each library that is found, a
diff -rc perl5.004_01.orig/lib/ExtUtils/MM_Unix.pm perl5.004_01/lib/ExtUtils/MM_Unix.pm
*** perl5.004_01.orig/lib/ExtUtils/MM_Unix.pm Thu Jun 12 22:06:18 1997
--- perl5.004_01/lib/ExtUtils/MM_Unix.pm Sun Nov 12 22:12:35 2000
***************
*** 2137,2143 ****
MAP_STATIC = ",
join(" \\\n\t", reverse sort keys %static), "
! MAP_PRELIBS = $Config::Config{libs} $Config::Config{cryptlib}
";
if (defined $libperl) {
--- 2137,2143 ----
MAP_STATIC = ",
join(" \\\n\t", reverse sort keys %static), "
! MAP_PRELIBS = $Config::Config{perllibs} $Config::Config{cryptlib}
";
if (defined $libperl) {
diff -rc perl5.004_01.orig/myconfig perl5.004_01/myconfig
*** perl5.004_01.orig/myconfig Sat Dec 21 01:13:20 1996
--- perl5.004_01/myconfig Sun Nov 12 22:12:35 2000
***************
*** 35,41 ****
Linker and Libraries:
ld='$ld', ldflags ='$ldflags'
libpth=$libpth
! libs=$libs
libc=$libc, so=$so
useshrplib=$useshrplib, libperl=$libperl
Dynamic Linking:
--- 35,41 ----
Linker and Libraries:
ld='$ld', ldflags ='$ldflags'
libpth=$libpth
! libs=$perllibs
libc=$libc, so=$so
useshrplib=$useshrplib, libperl=$libperl
Dynamic Linking:
diff -rc perl5.004_01.orig/patchlevel.h perl5.004_01/patchlevel.h
*** perl5.004_01.orig/patchlevel.h Wed Jun 11 03:06:10 1997
--- perl5.004_01/patchlevel.h Sun Nov 12 22:12:35 2000
***************
*** 38,43 ****
--- 38,44 ----
*/
static char *local_patches[] = {
NULL
+ ,"NODB-1.0 - remove -ldb from core perl binary."
,NULL
};

View File

@@ -0,0 +1,217 @@
diff -rc perl5.004_02.orig/Configure perl5.004_02/Configure
*** perl5.004_02.orig/Configure Thu Aug 7 15:08:44 1997
--- perl5.004_02/Configure Sun Nov 12 22:06:24 2000
***************
*** 188,193 ****
--- 188,194 ----
mv=''
nroff=''
perl=''
+ perllibs=''
pg=''
pmake=''
pr=''
***************
*** 9911,9916 ****
--- 9912,9925 ----
shift
extensions="$*"
+ : Remove libraries needed only for extensions
+ : The appropriate ext/Foo/Makefile.PL will add them back in, if
+ : necessary.
+ set X `echo " $libs " |
+ sed -e 's@ -lndbm @ @' -e 's@ -lgdbm @ @' -e 's@ -ldbm @ @' -e 's@ -ldb @ @'`
+ shift
+ perllibs="$*"
+
: Remove build directory name from cppstdin so it can be used from
: either the present location or the final installed location.
echo " "
***************
*** 10379,10384 ****
--- 10388,10394 ----
patchlevel='$patchlevel'
path_sep='$path_sep'
perl='$perl'
+ perllibs='$perllibs'
perladmin='$perladmin'
perlpath='$perlpath'
pg='$pg'
diff -rc perl5.004_02.orig/Makefile.SH perl5.004_02/Makefile.SH
*** perl5.004_02.orig/Makefile.SH Thu Aug 7 13:10:53 1997
--- perl5.004_02/Makefile.SH Sun Nov 12 22:06:24 2000
***************
*** 126,132 ****
ext = \$(dynamic_ext) \$(static_ext)
DYNALOADER = lib/auto/DynaLoader/DynaLoader\$(LIB_EXT)
! libs = $libs $cryptlib
public = perl $suidperl utilities translators
--- 126,132 ----
ext = \$(dynamic_ext) \$(static_ext)
DYNALOADER = lib/auto/DynaLoader/DynaLoader\$(LIB_EXT)
! libs = $perllibs $cryptlib
public = perl $suidperl utilities translators
diff -rc perl5.004_02.orig/lib/ExtUtils/Embed.pm perl5.004_02/lib/ExtUtils/Embed.pm
*** perl5.004_02.orig/lib/ExtUtils/Embed.pm Fri Aug 1 15:08:44 1997
--- perl5.004_02/lib/ExtUtils/Embed.pm Sun Nov 12 22:06:24 2000
***************
*** 178,184 ****
@path = $path ? split(/:/, $path) : @INC;
push(@potential_libs, @link_args) if scalar @link_args;
! push(@potential_libs, $Config{libs}) if defined $std;
push(@mods, static_ext()) if $std;
--- 178,184 ----
@path = $path ? split(/:/, $path) : @INC;
push(@potential_libs, @link_args) if scalar @link_args;
! push(@potential_libs, $Config{perllibs}) if defined $std;
push(@mods, static_ext()) if $std;
diff -rc perl5.004_02.orig/lib/ExtUtils/Liblist.pm perl5.004_02/lib/ExtUtils/Liblist.pm
*** perl5.004_02.orig/lib/ExtUtils/Liblist.pm Fri Aug 1 19:36:58 1997
--- perl5.004_02/lib/ExtUtils/Liblist.pm Sun Nov 12 22:06:24 2000
***************
*** 16,33 ****
sub _unix_os2_ext {
my($self,$potential_libs, $verbose) = @_;
! if ($^O =~ 'os2' and $Config{libs}) {
# Dynamic libraries are not transitive, so we may need including
# the libraries linked against perl.dll again.
$potential_libs .= " " if $potential_libs;
! $potential_libs .= $Config{libs};
}
return ("", "", "", "") unless $potential_libs;
print STDOUT "Potential libraries are '$potential_libs':\n" if $verbose;
my($so) = $Config{'so'};
! my($libs) = $Config{'libs'};
my $Config_libext = $Config{lib_ext} || ".a";
--- 16,33 ----
sub _unix_os2_ext {
my($self,$potential_libs, $verbose) = @_;
! if ($^O =~ 'os2' and $Config{perllibs}) {
# Dynamic libraries are not transitive, so we may need including
# the libraries linked against perl.dll again.
$potential_libs .= " " if $potential_libs;
! $potential_libs .= $Config{perllibs};
}
return ("", "", "", "") unless $potential_libs;
print STDOUT "Potential libraries are '$potential_libs':\n" if $verbose;
my($so) = $Config{'so'};
! my($libs) = $Config{'perllibs'};
my $Config_libext = $Config{lib_ext} || ".a";
***************
*** 186,196 ****
my($self, $potential_libs, $verbose) = @_;
# If user did not supply a list, we punt.
! # (caller should probably use the list in $Config{libs})
return ("", "", "", "") unless $potential_libs;
my($so) = $Config{'so'};
! my($libs) = $Config{'libs'};
my($libpth) = $Config{'libpth'};
my($libext) = $Config{'lib_ext'} || ".lib";
--- 186,196 ----
my($self, $potential_libs, $verbose) = @_;
# If user did not supply a list, we punt.
! # (caller should probably use the list in $Config{perllibs})
return ("", "", "", "") unless $potential_libs;
my($so) = $Config{'so'};
! my($libs) = $Config{'perllibs'};
my($libpth) = $Config{'libpth'};
my($libext) = $Config{'lib_ext'} || ".lib";
***************
*** 540,546 ****
=item *
If C<$potential_libs> is empty, the return value will be empty.
! Otherwise, the libraries specified by C<$Config{libs}> (see Config.pm)
will be appended to the list of C<$potential_libs>. The libraries
will be searched for in the directories specified in C<$potential_libs>
as well as in C<$Config{libpth}>. For each library that is found, a
--- 540,546 ----
=item *
If C<$potential_libs> is empty, the return value will be empty.
! Otherwise, the libraries specified by C<$Config{perllibs}> (see Config.pm)
will be appended to the list of C<$potential_libs>. The libraries
will be searched for in the directories specified in C<$potential_libs>
as well as in C<$Config{libpth}>. For each library that is found, a
diff -rc perl5.004_02.orig/lib/ExtUtils/MM_Unix.pm perl5.004_02/lib/ExtUtils/MM_Unix.pm
*** perl5.004_02.orig/lib/ExtUtils/MM_Unix.pm Tue Aug 5 14:28:08 1997
--- perl5.004_02/lib/ExtUtils/MM_Unix.pm Sun Nov 12 22:06:25 2000
***************
*** 2224,2230 ****
MAP_STATIC = ",
join(" \\\n\t", reverse sort keys %static), "
! MAP_PRELIBS = $Config::Config{libs} $Config::Config{cryptlib}
";
if (defined $libperl) {
--- 2224,2230 ----
MAP_STATIC = ",
join(" \\\n\t", reverse sort keys %static), "
! MAP_PRELIBS = $Config::Config{perllibs} $Config::Config{cryptlib}
";
if (defined $libperl) {
diff -rc perl5.004_02.orig/myconfig perl5.004_02/myconfig
*** perl5.004_02.orig/myconfig Sat Dec 21 01:13:20 1996
--- perl5.004_02/myconfig Sun Nov 12 22:06:25 2000
***************
*** 35,41 ****
Linker and Libraries:
ld='$ld', ldflags ='$ldflags'
libpth=$libpth
! libs=$libs
libc=$libc, so=$so
useshrplib=$useshrplib, libperl=$libperl
Dynamic Linking:
--- 35,41 ----
Linker and Libraries:
ld='$ld', ldflags ='$ldflags'
libpth=$libpth
! libs=$perllibs
libc=$libc, so=$so
useshrplib=$useshrplib, libperl=$libperl
Dynamic Linking:
diff -rc perl5.004_02.orig/patchlevel.h perl5.004_02/patchlevel.h
*** perl5.004_02.orig/patchlevel.h Fri Aug 1 15:07:34 1997
--- perl5.004_02/patchlevel.h Sun Nov 12 22:06:25 2000
***************
*** 38,43 ****
--- 38,44 ----
*/
static char *local_patches[] = {
NULL
+ ,"NODB-1.0 - remove -ldb from core perl binary."
,NULL
};

View File

@@ -0,0 +1,223 @@
diff -rc perl5.004_03.orig/Configure perl5.004_03/Configure
*** perl5.004_03.orig/Configure Wed Aug 13 16:09:46 1997
--- perl5.004_03/Configure Sun Nov 12 21:56:18 2000
***************
*** 188,193 ****
--- 188,194 ----
mv=''
nroff=''
perl=''
+ perllibs=''
pg=''
pmake=''
pr=''
***************
*** 9911,9916 ****
--- 9912,9925 ----
shift
extensions="$*"
+ : Remove libraries needed only for extensions
+ : The appropriate ext/Foo/Makefile.PL will add them back in, if
+ : necessary.
+ set X `echo " $libs " |
+ sed -e 's@ -lndbm @ @' -e 's@ -lgdbm @ @' -e 's@ -ldbm @ @' -e 's@ -ldb @ @'`
+ shift
+ perllibs="$*"
+
: Remove build directory name from cppstdin so it can be used from
: either the present location or the final installed location.
echo " "
***************
*** 10379,10384 ****
--- 10388,10394 ----
patchlevel='$patchlevel'
path_sep='$path_sep'
perl='$perl'
+ perllibs='$perllibs'
perladmin='$perladmin'
perlpath='$perlpath'
pg='$pg'
Only in perl5.004_03: Configure.orig
diff -rc perl5.004_03.orig/Makefile.SH perl5.004_03/Makefile.SH
*** perl5.004_03.orig/Makefile.SH Mon Aug 18 19:24:29 1997
--- perl5.004_03/Makefile.SH Sun Nov 12 21:56:18 2000
***************
*** 126,132 ****
ext = \$(dynamic_ext) \$(static_ext)
DYNALOADER = lib/auto/DynaLoader/DynaLoader\$(LIB_EXT)
! libs = $libs $cryptlib
public = perl $suidperl utilities translators
--- 126,132 ----
ext = \$(dynamic_ext) \$(static_ext)
DYNALOADER = lib/auto/DynaLoader/DynaLoader\$(LIB_EXT)
! libs = $perllibs $cryptlib
public = perl $suidperl utilities translators
Only in perl5.004_03: Makefile.SH.orig
diff -rc perl5.004_03.orig/lib/ExtUtils/Embed.pm perl5.004_03/lib/ExtUtils/Embed.pm
*** perl5.004_03.orig/lib/ExtUtils/Embed.pm Fri Aug 1 15:08:44 1997
--- perl5.004_03/lib/ExtUtils/Embed.pm Sun Nov 12 21:56:18 2000
***************
*** 178,184 ****
@path = $path ? split(/:/, $path) : @INC;
push(@potential_libs, @link_args) if scalar @link_args;
! push(@potential_libs, $Config{libs}) if defined $std;
push(@mods, static_ext()) if $std;
--- 178,184 ----
@path = $path ? split(/:/, $path) : @INC;
push(@potential_libs, @link_args) if scalar @link_args;
! push(@potential_libs, $Config{perllibs}) if defined $std;
push(@mods, static_ext()) if $std;
diff -rc perl5.004_03.orig/lib/ExtUtils/Liblist.pm perl5.004_03/lib/ExtUtils/Liblist.pm
*** perl5.004_03.orig/lib/ExtUtils/Liblist.pm Fri Aug 1 19:36:58 1997
--- perl5.004_03/lib/ExtUtils/Liblist.pm Sun Nov 12 21:57:17 2000
***************
*** 16,33 ****
sub _unix_os2_ext {
my($self,$potential_libs, $verbose) = @_;
! if ($^O =~ 'os2' and $Config{libs}) {
# Dynamic libraries are not transitive, so we may need including
# the libraries linked against perl.dll again.
$potential_libs .= " " if $potential_libs;
! $potential_libs .= $Config{libs};
}
return ("", "", "", "") unless $potential_libs;
print STDOUT "Potential libraries are '$potential_libs':\n" if $verbose;
my($so) = $Config{'so'};
! my($libs) = $Config{'libs'};
my $Config_libext = $Config{lib_ext} || ".a";
--- 16,33 ----
sub _unix_os2_ext {
my($self,$potential_libs, $verbose) = @_;
! if ($^O =~ 'os2' and $Config{perllibs}) {
# Dynamic libraries are not transitive, so we may need including
# the libraries linked against perl.dll again.
$potential_libs .= " " if $potential_libs;
! $potential_libs .= $Config{perllibs};
}
return ("", "", "", "") unless $potential_libs;
print STDOUT "Potential libraries are '$potential_libs':\n" if $verbose;
my($so) = $Config{'so'};
! my($libs) = $Config{'perllibs'};
my $Config_libext = $Config{lib_ext} || ".a";
***************
*** 186,196 ****
my($self, $potential_libs, $verbose) = @_;
# If user did not supply a list, we punt.
! # (caller should probably use the list in $Config{libs})
return ("", "", "", "") unless $potential_libs;
my($so) = $Config{'so'};
! my($libs) = $Config{'libs'};
my($libpth) = $Config{'libpth'};
my($libext) = $Config{'lib_ext'} || ".lib";
--- 186,196 ----
my($self, $potential_libs, $verbose) = @_;
# If user did not supply a list, we punt.
! # (caller should probably use the list in $Config{perllibs})
return ("", "", "", "") unless $potential_libs;
my($so) = $Config{'so'};
! my($libs) = $Config{'perllibs'};
my($libpth) = $Config{'libpth'};
my($libext) = $Config{'lib_ext'} || ".lib";
***************
*** 540,546 ****
=item *
If C<$potential_libs> is empty, the return value will be empty.
! Otherwise, the libraries specified by C<$Config{libs}> (see Config.pm)
will be appended to the list of C<$potential_libs>. The libraries
will be searched for in the directories specified in C<$potential_libs>
as well as in C<$Config{libpth}>. For each library that is found, a
--- 540,546 ----
=item *
If C<$potential_libs> is empty, the return value will be empty.
! Otherwise, the libraries specified by C<$Config{perllibs}> (see Config.pm)
will be appended to the list of C<$potential_libs>. The libraries
will be searched for in the directories specified in C<$potential_libs>
as well as in C<$Config{libpth}>. For each library that is found, a
Only in perl5.004_03/lib/ExtUtils: Liblist.pm.orig
Only in perl5.004_03/lib/ExtUtils: Liblist.pm.rej
diff -rc perl5.004_03.orig/lib/ExtUtils/MM_Unix.pm perl5.004_03/lib/ExtUtils/MM_Unix.pm
*** perl5.004_03.orig/lib/ExtUtils/MM_Unix.pm Mon Aug 18 19:16:12 1997
--- perl5.004_03/lib/ExtUtils/MM_Unix.pm Sun Nov 12 21:56:19 2000
***************
*** 2224,2230 ****
MAP_STATIC = ",
join(" \\\n\t", reverse sort keys %static), "
! MAP_PRELIBS = $Config::Config{libs} $Config::Config{cryptlib}
";
if (defined $libperl) {
--- 2224,2230 ----
MAP_STATIC = ",
join(" \\\n\t", reverse sort keys %static), "
! MAP_PRELIBS = $Config::Config{perllibs} $Config::Config{cryptlib}
";
if (defined $libperl) {
Only in perl5.004_03/lib/ExtUtils: MM_Unix.pm.orig
diff -rc perl5.004_03.orig/myconfig perl5.004_03/myconfig
*** perl5.004_03.orig/myconfig Sat Dec 21 01:13:20 1996
--- perl5.004_03/myconfig Sun Nov 12 21:56:19 2000
***************
*** 35,41 ****
Linker and Libraries:
ld='$ld', ldflags ='$ldflags'
libpth=$libpth
! libs=$libs
libc=$libc, so=$so
useshrplib=$useshrplib, libperl=$libperl
Dynamic Linking:
--- 35,41 ----
Linker and Libraries:
ld='$ld', ldflags ='$ldflags'
libpth=$libpth
! libs=$perllibs
libc=$libc, so=$so
useshrplib=$useshrplib, libperl=$libperl
Dynamic Linking:
diff -rc perl5.004_03.orig/patchlevel.h perl5.004_03/patchlevel.h
*** perl5.004_03.orig/patchlevel.h Wed Aug 13 11:42:01 1997
--- perl5.004_03/patchlevel.h Sun Nov 12 21:56:19 2000
***************
*** 38,43 ****
--- 38,44 ----
*/
static char *local_patches[] = {
NULL
+ ,"NODB-1.0 - remove -ldb from core perl binary."
,NULL
};
Only in perl5.004_03: patchlevel.h.orig

View File

@@ -0,0 +1,209 @@
diff -rc perl5.004_04.orig/Configure perl5.004_04/Configure
*** perl5.004_04.orig/Configure Fri Oct 3 18:57:39 1997
--- perl5.004_04/Configure Sun Nov 12 21:50:51 2000
***************
*** 188,193 ****
--- 188,194 ----
mv=''
nroff=''
perl=''
+ perllibs=''
pg=''
pmake=''
pr=''
***************
*** 9910,9915 ****
--- 9911,9924 ----
shift
extensions="$*"
+ : Remove libraries needed only for extensions
+ : The appropriate ext/Foo/Makefile.PL will add them back in, if
+ : necessary.
+ set X `echo " $libs " |
+ sed -e 's@ -lndbm @ @' -e 's@ -lgdbm @ @' -e 's@ -ldbm @ @' -e 's@ -ldb @ @'`
+ shift
+ perllibs="$*"
+
: Remove build directory name from cppstdin so it can be used from
: either the present location or the final installed location.
echo " "
***************
*** 10378,10383 ****
--- 10387,10393 ----
patchlevel='$patchlevel'
path_sep='$path_sep'
perl='$perl'
+ perllibs='$perllibs'
perladmin='$perladmin'
perlpath='$perlpath'
pg='$pg'
diff -rc perl5.004_04.orig/Makefile.SH perl5.004_04/Makefile.SH
*** perl5.004_04.orig/Makefile.SH Wed Oct 15 10:33:16 1997
--- perl5.004_04/Makefile.SH Sun Nov 12 21:50:51 2000
***************
*** 129,135 ****
ext = \$(dynamic_ext) \$(static_ext)
DYNALOADER = lib/auto/DynaLoader/DynaLoader\$(LIB_EXT)
! libs = $libs $cryptlib
public = perl $suidperl utilities translators
--- 129,135 ----
ext = \$(dynamic_ext) \$(static_ext)
DYNALOADER = lib/auto/DynaLoader/DynaLoader\$(LIB_EXT)
! libs = $perllibs $cryptlib
public = perl $suidperl utilities translators
diff -rc perl5.004_04.orig/lib/ExtUtils/Embed.pm perl5.004_04/lib/ExtUtils/Embed.pm
*** perl5.004_04.orig/lib/ExtUtils/Embed.pm Fri Aug 1 15:08:44 1997
--- perl5.004_04/lib/ExtUtils/Embed.pm Sun Nov 12 21:50:51 2000
***************
*** 178,184 ****
@path = $path ? split(/:/, $path) : @INC;
push(@potential_libs, @link_args) if scalar @link_args;
! push(@potential_libs, $Config{libs}) if defined $std;
push(@mods, static_ext()) if $std;
--- 178,184 ----
@path = $path ? split(/:/, $path) : @INC;
push(@potential_libs, @link_args) if scalar @link_args;
! push(@potential_libs, $Config{perllibs}) if defined $std;
push(@mods, static_ext()) if $std;
diff -rc perl5.004_04.orig/lib/ExtUtils/Liblist.pm perl5.004_04/lib/ExtUtils/Liblist.pm
*** perl5.004_04.orig/lib/ExtUtils/Liblist.pm Tue Sep 9 17:41:32 1997
--- perl5.004_04/lib/ExtUtils/Liblist.pm Sun Nov 12 21:51:33 2000
***************
*** 16,33 ****
sub _unix_os2_ext {
my($self,$potential_libs, $verbose) = @_;
! if ($^O =~ 'os2' and $Config{libs}) {
# Dynamic libraries are not transitive, so we may need including
# the libraries linked against perl.dll again.
$potential_libs .= " " if $potential_libs;
! $potential_libs .= $Config{libs};
}
return ("", "", "", "") unless $potential_libs;
warn "Potential libraries are '$potential_libs':\n" if $verbose;
my($so) = $Config{'so'};
! my($libs) = $Config{'libs'};
my $Config_libext = $Config{lib_ext} || ".a";
--- 16,33 ----
sub _unix_os2_ext {
my($self,$potential_libs, $verbose) = @_;
! if ($^O =~ 'os2' and $Config{perllibs}) {
# Dynamic libraries are not transitive, so we may need including
# the libraries linked against perl.dll again.
$potential_libs .= " " if $potential_libs;
! $potential_libs .= $Config{perllibs};
}
return ("", "", "", "") unless $potential_libs;
warn "Potential libraries are '$potential_libs':\n" if $verbose;
my($so) = $Config{'so'};
! my($libs) = $Config{'perllibs'};
my $Config_libext = $Config{lib_ext} || ".a";
***************
*** 189,195 ****
return ("", "", "", "") unless $potential_libs;
my($so) = $Config{'so'};
! my($libs) = $Config{'libs'};
my($libpth) = $Config{'libpth'};
my($libext) = $Config{'lib_ext'} || ".lib";
--- 189,195 ----
return ("", "", "", "") unless $potential_libs;
my($so) = $Config{'so'};
! my($libs) = $Config{'perllibs'};
my($libpth) = $Config{'libpth'};
my($libext) = $Config{'lib_ext'} || ".lib";
***************
*** 539,545 ****
=item *
If C<$potential_libs> is empty, the return value will be empty.
! Otherwise, the libraries specified by C<$Config{libs}> (see Config.pm)
will be appended to the list of C<$potential_libs>. The libraries
will be searched for in the directories specified in C<$potential_libs>
as well as in C<$Config{libpth}>. For each library that is found, a
--- 539,545 ----
=item *
If C<$potential_libs> is empty, the return value will be empty.
! Otherwise, the libraries specified by C<$Config{perllibs}> (see Config.pm)
will be appended to the list of C<$potential_libs>. The libraries
will be searched for in the directories specified in C<$potential_libs>
as well as in C<$Config{libpth}>. For each library that is found, a
diff -rc perl5.004_04.orig/lib/ExtUtils/MM_Unix.pm perl5.004_04/lib/ExtUtils/MM_Unix.pm
*** perl5.004_04.orig/lib/ExtUtils/MM_Unix.pm Wed Oct 8 14:13:51 1997
--- perl5.004_04/lib/ExtUtils/MM_Unix.pm Sun Nov 12 21:50:51 2000
***************
*** 2229,2235 ****
MAP_STATIC = ",
join(" \\\n\t", reverse sort keys %static), "
! MAP_PRELIBS = $Config::Config{libs} $Config::Config{cryptlib}
";
if (defined $libperl) {
--- 2229,2235 ----
MAP_STATIC = ",
join(" \\\n\t", reverse sort keys %static), "
! MAP_PRELIBS = $Config::Config{perllibs} $Config::Config{cryptlib}
";
if (defined $libperl) {
diff -rc perl5.004_04.orig/myconfig perl5.004_04/myconfig
*** perl5.004_04.orig/myconfig Mon Oct 6 18:26:49 1997
--- perl5.004_04/myconfig Sun Nov 12 21:50:51 2000
***************
*** 35,41 ****
Linker and Libraries:
ld='$ld', ldflags ='$ldflags'
libpth=$libpth
! libs=$libs
libc=$libc, so=$so
useshrplib=$useshrplib, libperl=$libperl
Dynamic Linking:
--- 35,41 ----
Linker and Libraries:
ld='$ld', ldflags ='$ldflags'
libpth=$libpth
! libs=$perllibs
libc=$libc, so=$so
useshrplib=$useshrplib, libperl=$libperl
Dynamic Linking:
diff -rc perl5.004_04.orig/patchlevel.h perl5.004_04/patchlevel.h
*** perl5.004_04.orig/patchlevel.h Wed Oct 15 10:55:19 1997
--- perl5.004_04/patchlevel.h Sun Nov 12 21:50:51 2000
***************
*** 39,44 ****
--- 39,45 ----
/* The following line and terminating '};' are read by perlbug.PL. Don't alter. */
static char *local_patches[] = {
NULL
+ ,"NODB-1.0 - remove -ldb from core perl binary."
,NULL
};

View File

@@ -0,0 +1,209 @@
diff -rc perl5.004_05.orig/Configure perl5.004_05/Configure
*** perl5.004_05.orig/Configure Thu Jan 6 22:05:49 2000
--- perl5.004_05/Configure Sun Nov 12 21:36:25 2000
***************
*** 188,193 ****
--- 188,194 ----
mv=''
nroff=''
perl=''
+ perllibs=''
pg=''
pmake=''
pr=''
***************
*** 10164,10169 ****
--- 10165,10178 ----
shift
extensions="$*"
+ : Remove libraries needed only for extensions
+ : The appropriate ext/Foo/Makefile.PL will add them back in, if
+ : necessary.
+ set X `echo " $libs " |
+ sed -e 's@ -lndbm @ @' -e 's@ -lgdbm @ @' -e 's@ -ldbm @ @' -e 's@ -ldb @ @'`
+ shift
+ perllibs="$*"
+
: Remove build directory name from cppstdin so it can be used from
: either the present location or the final installed location.
echo " "
***************
*** 10648,10653 ****
--- 10657,10663 ----
patchlevel='$patchlevel'
path_sep='$path_sep'
perl='$perl'
+ perllibs='$perllibs'
perladmin='$perladmin'
perlpath='$perlpath'
pg='$pg'
diff -rc perl5.004_05.orig/Makefile.SH perl5.004_05/Makefile.SH
*** perl5.004_05.orig/Makefile.SH Thu Jan 6 22:05:49 2000
--- perl5.004_05/Makefile.SH Sun Nov 12 21:36:25 2000
***************
*** 151,157 ****
ext = \$(dynamic_ext) \$(static_ext)
DYNALOADER = lib/auto/DynaLoader/DynaLoader\$(LIB_EXT)
! libs = $libs $cryptlib
public = perl $suidperl utilities translators
--- 151,157 ----
ext = \$(dynamic_ext) \$(static_ext)
DYNALOADER = lib/auto/DynaLoader/DynaLoader\$(LIB_EXT)
! libs = $perllibs $cryptlib
public = perl $suidperl utilities translators
diff -rc perl5.004_05.orig/lib/ExtUtils/Embed.pm perl5.004_05/lib/ExtUtils/Embed.pm
*** perl5.004_05.orig/lib/ExtUtils/Embed.pm Fri Aug 1 15:08:44 1997
--- perl5.004_05/lib/ExtUtils/Embed.pm Sun Nov 12 21:36:25 2000
***************
*** 178,184 ****
@path = $path ? split(/:/, $path) : @INC;
push(@potential_libs, @link_args) if scalar @link_args;
! push(@potential_libs, $Config{libs}) if defined $std;
push(@mods, static_ext()) if $std;
--- 178,184 ----
@path = $path ? split(/:/, $path) : @INC;
push(@potential_libs, @link_args) if scalar @link_args;
! push(@potential_libs, $Config{perllibs}) if defined $std;
push(@mods, static_ext()) if $std;
diff -rc perl5.004_05.orig/lib/ExtUtils/Liblist.pm perl5.004_05/lib/ExtUtils/Liblist.pm
*** perl5.004_05.orig/lib/ExtUtils/Liblist.pm Thu Jan 6 22:05:54 2000
--- perl5.004_05/lib/ExtUtils/Liblist.pm Sun Nov 12 21:45:31 2000
***************
*** 16,33 ****
sub _unix_os2_ext {
my($self,$potential_libs, $verbose) = @_;
! if ($^O =~ 'os2' and $Config{libs}) {
# Dynamic libraries are not transitive, so we may need including
# the libraries linked against perl.dll again.
$potential_libs .= " " if $potential_libs;
! $potential_libs .= $Config{libs};
}
return ("", "", "", "") unless $potential_libs;
warn "Potential libraries are '$potential_libs':\n" if $verbose;
my($so) = $Config{'so'};
! my($libs) = $Config{'libs'};
my $Config_libext = $Config{lib_ext} || ".a";
--- 16,33 ----
sub _unix_os2_ext {
my($self,$potential_libs, $verbose) = @_;
! if ($^O =~ 'os2' and $Config{perllibs}) {
# Dynamic libraries are not transitive, so we may need including
# the libraries linked against perl.dll again.
$potential_libs .= " " if $potential_libs;
! $potential_libs .= $Config{perllibs};
}
return ("", "", "", "") unless $potential_libs;
warn "Potential libraries are '$potential_libs':\n" if $verbose;
my($so) = $Config{'so'};
! my($libs) = $Config{'perllibs'};
my $Config_libext = $Config{lib_ext} || ".a";
***************
*** 196,202 ****
my $BC = 1 if $cc =~ /^bcc/i;
my $GC = 1 if $cc =~ /^gcc/i;
my $so = $Config{'so'};
! my $libs = $Config{'libs'};
my $libpth = $Config{'libpth'};
my $libext = $Config{'lib_ext'} || ".lib";
--- 196,202 ----
my $BC = 1 if $cc =~ /^bcc/i;
my $GC = 1 if $cc =~ /^gcc/i;
my $so = $Config{'so'};
! my $libs = $Config{'perllibs'};
my $libpth = $Config{'libpth'};
my $libext = $Config{'lib_ext'} || ".lib";
***************
*** 590,596 ****
=item *
If C<$potential_libs> is empty, the return value will be empty.
! Otherwise, the libraries specified by C<$Config{libs}> (see Config.pm)
will be appended to the list of C<$potential_libs>. The libraries
will be searched for in the directories specified in C<$potential_libs>
as well as in C<$Config{libpth}>. For each library that is found, a
--- 590,596 ----
=item *
If C<$potential_libs> is empty, the return value will be empty.
! Otherwise, the libraries specified by C<$Config{perllibs}> (see Config.pm)
will be appended to the list of C<$potential_libs>. The libraries
will be searched for in the directories specified in C<$potential_libs>
as well as in C<$Config{libpth}>. For each library that is found, a
diff -rc perl5.004_05.orig/lib/ExtUtils/MM_Unix.pm perl5.004_05/lib/ExtUtils/MM_Unix.pm
*** perl5.004_05.orig/lib/ExtUtils/MM_Unix.pm Thu Jan 6 22:05:54 2000
--- perl5.004_05/lib/ExtUtils/MM_Unix.pm Sun Nov 12 21:36:25 2000
***************
*** 2246,2252 ****
MAP_STATIC = ",
join(" \\\n\t", reverse sort keys %static), "
! MAP_PRELIBS = $Config::Config{libs} $Config::Config{cryptlib}
";
if (defined $libperl) {
--- 2246,2252 ----
MAP_STATIC = ",
join(" \\\n\t", reverse sort keys %static), "
! MAP_PRELIBS = $Config::Config{perllibs} $Config::Config{cryptlib}
";
if (defined $libperl) {
diff -rc perl5.004_05.orig/myconfig perl5.004_05/myconfig
*** perl5.004_05.orig/myconfig Thu Jan 6 22:05:55 2000
--- perl5.004_05/myconfig Sun Nov 12 21:43:54 2000
***************
*** 34,40 ****
Linker and Libraries:
ld='$ld', ldflags ='$ldflags'
libpth=$libpth
! libs=$libs
libc=$libc, so=$so
useshrplib=$useshrplib, libperl=$libperl
Dynamic Linking:
--- 34,40 ----
Linker and Libraries:
ld='$ld', ldflags ='$ldflags'
libpth=$libpth
! libs=$perllibs
libc=$libc, so=$so
useshrplib=$useshrplib, libperl=$libperl
Dynamic Linking:
diff -rc perl5.004_05.orig/patchlevel.h perl5.004_05/patchlevel.h
*** perl5.004_05.orig/patchlevel.h Thu Jan 6 22:05:48 2000
--- perl5.004_05/patchlevel.h Sun Nov 12 21:36:25 2000
***************
*** 39,44 ****
--- 39,45 ----
/* The following line and terminating '};' are read by perlbug.PL. Don't alter. */
static char *local_patches[] = {
NULL
+ ,"NODB-1.0 - remove -ldb from core perl binary."
,NULL
};

209
perl/DB_File/patches/5.005 Normal file
View File

@@ -0,0 +1,209 @@
diff -rc perl5.005.orig/Configure perl5.005/Configure
*** perl5.005.orig/Configure Wed Jul 15 08:05:44 1998
--- perl5.005/Configure Sun Nov 12 21:30:40 2000
***************
*** 234,239 ****
--- 234,240 ----
nm=''
nroff=''
perl=''
+ perllibs=''
pg=''
pmake=''
pr=''
***************
*** 11279,11284 ****
--- 11280,11293 ----
shift
extensions="$*"
+ : Remove libraries needed only for extensions
+ : The appropriate ext/Foo/Makefile.PL will add them back in, if
+ : necessary.
+ set X `echo " $libs " |
+ sed -e 's@ -lndbm @ @' -e 's@ -lgdbm @ @' -e 's@ -ldbm @ @' -e 's@ -ldb @ @'`
+ shift
+ perllibs="$*"
+
: Remove build directory name from cppstdin so it can be used from
: either the present location or the final installed location.
echo " "
***************
*** 11804,11809 ****
--- 11813,11819 ----
patchlevel='$patchlevel'
path_sep='$path_sep'
perl='$perl'
+ perllibs='$perllibs'
perladmin='$perladmin'
perlpath='$perlpath'
pg='$pg'
diff -rc perl5.005.orig/Makefile.SH perl5.005/Makefile.SH
*** perl5.005.orig/Makefile.SH Sun Jul 19 08:06:35 1998
--- perl5.005/Makefile.SH Sun Nov 12 21:30:40 2000
***************
*** 150,156 ****
ext = \$(dynamic_ext) \$(static_ext) \$(nonxs_ext)
DYNALOADER = lib/auto/DynaLoader/DynaLoader\$(LIB_EXT)
! libs = $libs $cryptlib
public = perl $suidperl utilities translators
--- 150,156 ----
ext = \$(dynamic_ext) \$(static_ext) \$(nonxs_ext)
DYNALOADER = lib/auto/DynaLoader/DynaLoader\$(LIB_EXT)
! libs = $perllibs $cryptlib
public = perl $suidperl utilities translators
diff -rc perl5.005.orig/lib/ExtUtils/Embed.pm perl5.005/lib/ExtUtils/Embed.pm
*** perl5.005.orig/lib/ExtUtils/Embed.pm Wed Jul 22 07:45:02 1998
--- perl5.005/lib/ExtUtils/Embed.pm Sun Nov 12 21:30:40 2000
***************
*** 194,200 ****
@path = $path ? split(/:/, $path) : @INC;
push(@potential_libs, @link_args) if scalar @link_args;
! push(@potential_libs, $Config{libs}) if defined $std;
push(@mods, static_ext()) if $std;
--- 194,200 ----
@path = $path ? split(/:/, $path) : @INC;
push(@potential_libs, @link_args) if scalar @link_args;
! push(@potential_libs, $Config{perllibs}) if defined $std;
push(@mods, static_ext()) if $std;
diff -rc perl5.005.orig/lib/ExtUtils/Liblist.pm perl5.005/lib/ExtUtils/Liblist.pm
*** perl5.005.orig/lib/ExtUtils/Liblist.pm Wed Jul 22 07:09:42 1998
--- perl5.005/lib/ExtUtils/Liblist.pm Sun Nov 12 21:30:40 2000
***************
*** 16,33 ****
sub _unix_os2_ext {
my($self,$potential_libs, $verbose) = @_;
! if ($^O =~ 'os2' and $Config{libs}) {
# Dynamic libraries are not transitive, so we may need including
# the libraries linked against perl.dll again.
$potential_libs .= " " if $potential_libs;
! $potential_libs .= $Config{libs};
}
return ("", "", "", "") unless $potential_libs;
warn "Potential libraries are '$potential_libs':\n" if $verbose;
my($so) = $Config{'so'};
! my($libs) = $Config{'libs'};
my $Config_libext = $Config{lib_ext} || ".a";
--- 16,33 ----
sub _unix_os2_ext {
my($self,$potential_libs, $verbose) = @_;
! if ($^O =~ 'os2' and $Config{perllibs}) {
# Dynamic libraries are not transitive, so we may need including
# the libraries linked against perl.dll again.
$potential_libs .= " " if $potential_libs;
! $potential_libs .= $Config{perllibs};
}
return ("", "", "", "") unless $potential_libs;
warn "Potential libraries are '$potential_libs':\n" if $verbose;
my($so) = $Config{'so'};
! my($libs) = $Config{'perllibs'};
my $Config_libext = $Config{lib_ext} || ".a";
***************
*** 290,296 ****
$self->{CCFLAS} || $Config{'ccflags'};
@crtls = ( ($dbgqual =~ m-/Debug-i ? $Config{'dbgprefix'} : '')
. 'PerlShr/Share' );
! push(@crtls, grep { not /\(/ } split /\s+/, $Config{'libs'});
push(@crtls, grep { not /\(/ } split /\s+/, $Config{'libc'});
# In general, we pass through the basic libraries from %Config unchanged.
# The one exception is that if we're building in the Perl source tree, and
--- 290,296 ----
$self->{CCFLAS} || $Config{'ccflags'};
@crtls = ( ($dbgqual =~ m-/Debug-i ? $Config{'dbgprefix'} : '')
. 'PerlShr/Share' );
! push(@crtls, grep { not /\(/ } split /\s+/, $Config{'perllibs'});
push(@crtls, grep { not /\(/ } split /\s+/, $Config{'libc'});
# In general, we pass through the basic libraries from %Config unchanged.
# The one exception is that if we're building in the Perl source tree, and
***************
*** 598,604 ****
=item *
If C<$potential_libs> is empty, the return value will be empty.
! Otherwise, the libraries specified by C<$Config{libs}> (see Config.pm)
will be appended to the list of C<$potential_libs>. The libraries
will be searched for in the directories specified in C<$potential_libs>
as well as in C<$Config{libpth}>. For each library that is found, a
--- 598,604 ----
=item *
If C<$potential_libs> is empty, the return value will be empty.
! Otherwise, the libraries specified by C<$Config{perllibs}> (see Config.pm)
will be appended to the list of C<$potential_libs>. The libraries
will be searched for in the directories specified in C<$potential_libs>
as well as in C<$Config{libpth}>. For each library that is found, a
diff -rc perl5.005.orig/lib/ExtUtils/MM_Unix.pm perl5.005/lib/ExtUtils/MM_Unix.pm
*** perl5.005.orig/lib/ExtUtils/MM_Unix.pm Tue Jul 14 04:39:12 1998
--- perl5.005/lib/ExtUtils/MM_Unix.pm Sun Nov 12 21:30:41 2000
***************
*** 2281,2287 ****
MAP_STATIC = ",
join(" \\\n\t", reverse sort keys %static), "
! MAP_PRELIBS = $Config::Config{libs} $Config::Config{cryptlib}
";
if (defined $libperl) {
--- 2281,2287 ----
MAP_STATIC = ",
join(" \\\n\t", reverse sort keys %static), "
! MAP_PRELIBS = $Config::Config{perllibs} $Config::Config{cryptlib}
";
if (defined $libperl) {
diff -rc perl5.005.orig/myconfig perl5.005/myconfig
*** perl5.005.orig/myconfig Fri Apr 3 01:20:35 1998
--- perl5.005/myconfig Sun Nov 12 21:30:41 2000
***************
*** 34,40 ****
Linker and Libraries:
ld='$ld', ldflags ='$ldflags'
libpth=$libpth
! libs=$libs
libc=$libc, so=$so, useshrplib=$useshrplib, libperl=$libperl
Dynamic Linking:
dlsrc=$dlsrc, dlext=$dlext, d_dlsymun=$d_dlsymun, ccdlflags='$ccdlflags'
--- 34,40 ----
Linker and Libraries:
ld='$ld', ldflags ='$ldflags'
libpth=$libpth
! libs=$perllibs
libc=$libc, so=$so, useshrplib=$useshrplib, libperl=$libperl
Dynamic Linking:
dlsrc=$dlsrc, dlext=$dlext, d_dlsymun=$d_dlsymun, ccdlflags='$ccdlflags'
diff -rc perl5.005.orig/patchlevel.h perl5.005/patchlevel.h
*** perl5.005.orig/patchlevel.h Wed Jul 22 19:22:01 1998
--- perl5.005/patchlevel.h Sun Nov 12 21:30:41 2000
***************
*** 39,44 ****
--- 39,45 ----
*/
static char *local_patches[] = {
NULL
+ ,"NODB-1.0 - remove -ldb from core perl binary."
,NULL
};

View File

@@ -0,0 +1,209 @@
diff -rc perl5.005_01.orig/Configure perl5.005_01/Configure
*** perl5.005_01.orig/Configure Wed Jul 15 08:05:44 1998
--- perl5.005_01/Configure Sun Nov 12 20:55:58 2000
***************
*** 234,239 ****
--- 234,240 ----
nm=''
nroff=''
perl=''
+ perllibs=''
pg=''
pmake=''
pr=''
***************
*** 11279,11284 ****
--- 11280,11293 ----
shift
extensions="$*"
+ : Remove libraries needed only for extensions
+ : The appropriate ext/Foo/Makefile.PL will add them back in, if
+ : necessary.
+ set X `echo " $libs " |
+ sed -e 's@ -lndbm @ @' -e 's@ -lgdbm @ @' -e 's@ -ldbm @ @' -e 's@ -ldb @ @'`
+ shift
+ perllibs="$*"
+
: Remove build directory name from cppstdin so it can be used from
: either the present location or the final installed location.
echo " "
***************
*** 11804,11809 ****
--- 11813,11819 ----
patchlevel='$patchlevel'
path_sep='$path_sep'
perl='$perl'
+ perllibs='$perllibs'
perladmin='$perladmin'
perlpath='$perlpath'
pg='$pg'
diff -rc perl5.005_01.orig/Makefile.SH perl5.005_01/Makefile.SH
*** perl5.005_01.orig/Makefile.SH Sun Jul 19 08:06:35 1998
--- perl5.005_01/Makefile.SH Sun Nov 12 20:55:58 2000
***************
*** 150,156 ****
ext = \$(dynamic_ext) \$(static_ext) \$(nonxs_ext)
DYNALOADER = lib/auto/DynaLoader/DynaLoader\$(LIB_EXT)
! libs = $libs $cryptlib
public = perl $suidperl utilities translators
--- 150,156 ----
ext = \$(dynamic_ext) \$(static_ext) \$(nonxs_ext)
DYNALOADER = lib/auto/DynaLoader/DynaLoader\$(LIB_EXT)
! libs = $perllibs $cryptlib
public = perl $suidperl utilities translators
diff -rc perl5.005_01.orig/lib/ExtUtils/Embed.pm perl5.005_01/lib/ExtUtils/Embed.pm
*** perl5.005_01.orig/lib/ExtUtils/Embed.pm Wed Jul 22 07:45:02 1998
--- perl5.005_01/lib/ExtUtils/Embed.pm Sun Nov 12 20:55:58 2000
***************
*** 194,200 ****
@path = $path ? split(/:/, $path) : @INC;
push(@potential_libs, @link_args) if scalar @link_args;
! push(@potential_libs, $Config{libs}) if defined $std;
push(@mods, static_ext()) if $std;
--- 194,200 ----
@path = $path ? split(/:/, $path) : @INC;
push(@potential_libs, @link_args) if scalar @link_args;
! push(@potential_libs, $Config{perllibs}) if defined $std;
push(@mods, static_ext()) if $std;
diff -rc perl5.005_01.orig/lib/ExtUtils/Liblist.pm perl5.005_01/lib/ExtUtils/Liblist.pm
*** perl5.005_01.orig/lib/ExtUtils/Liblist.pm Wed Jul 22 07:09:42 1998
--- perl5.005_01/lib/ExtUtils/Liblist.pm Sun Nov 12 20:55:58 2000
***************
*** 16,33 ****
sub _unix_os2_ext {
my($self,$potential_libs, $verbose) = @_;
! if ($^O =~ 'os2' and $Config{libs}) {
# Dynamic libraries are not transitive, so we may need including
# the libraries linked against perl.dll again.
$potential_libs .= " " if $potential_libs;
! $potential_libs .= $Config{libs};
}
return ("", "", "", "") unless $potential_libs;
warn "Potential libraries are '$potential_libs':\n" if $verbose;
my($so) = $Config{'so'};
! my($libs) = $Config{'libs'};
my $Config_libext = $Config{lib_ext} || ".a";
--- 16,33 ----
sub _unix_os2_ext {
my($self,$potential_libs, $verbose) = @_;
! if ($^O =~ 'os2' and $Config{perllibs}) {
# Dynamic libraries are not transitive, so we may need including
# the libraries linked against perl.dll again.
$potential_libs .= " " if $potential_libs;
! $potential_libs .= $Config{perllibs};
}
return ("", "", "", "") unless $potential_libs;
warn "Potential libraries are '$potential_libs':\n" if $verbose;
my($so) = $Config{'so'};
! my($libs) = $Config{'perllibs'};
my $Config_libext = $Config{lib_ext} || ".a";
***************
*** 290,296 ****
$self->{CCFLAS} || $Config{'ccflags'};
@crtls = ( ($dbgqual =~ m-/Debug-i ? $Config{'dbgprefix'} : '')
. 'PerlShr/Share' );
! push(@crtls, grep { not /\(/ } split /\s+/, $Config{'libs'});
push(@crtls, grep { not /\(/ } split /\s+/, $Config{'libc'});
# In general, we pass through the basic libraries from %Config unchanged.
# The one exception is that if we're building in the Perl source tree, and
--- 290,296 ----
$self->{CCFLAS} || $Config{'ccflags'};
@crtls = ( ($dbgqual =~ m-/Debug-i ? $Config{'dbgprefix'} : '')
. 'PerlShr/Share' );
! push(@crtls, grep { not /\(/ } split /\s+/, $Config{'perllibs'});
push(@crtls, grep { not /\(/ } split /\s+/, $Config{'libc'});
# In general, we pass through the basic libraries from %Config unchanged.
# The one exception is that if we're building in the Perl source tree, and
***************
*** 598,604 ****
=item *
If C<$potential_libs> is empty, the return value will be empty.
! Otherwise, the libraries specified by C<$Config{libs}> (see Config.pm)
will be appended to the list of C<$potential_libs>. The libraries
will be searched for in the directories specified in C<$potential_libs>
as well as in C<$Config{libpth}>. For each library that is found, a
--- 598,604 ----
=item *
If C<$potential_libs> is empty, the return value will be empty.
! Otherwise, the libraries specified by C<$Config{perllibs}> (see Config.pm)
will be appended to the list of C<$potential_libs>. The libraries
will be searched for in the directories specified in C<$potential_libs>
as well as in C<$Config{libpth}>. For each library that is found, a
diff -rc perl5.005_01.orig/lib/ExtUtils/MM_Unix.pm perl5.005_01/lib/ExtUtils/MM_Unix.pm
*** perl5.005_01.orig/lib/ExtUtils/MM_Unix.pm Tue Jul 14 04:39:12 1998
--- perl5.005_01/lib/ExtUtils/MM_Unix.pm Sun Nov 12 20:55:58 2000
***************
*** 2281,2287 ****
MAP_STATIC = ",
join(" \\\n\t", reverse sort keys %static), "
! MAP_PRELIBS = $Config::Config{libs} $Config::Config{cryptlib}
";
if (defined $libperl) {
--- 2281,2287 ----
MAP_STATIC = ",
join(" \\\n\t", reverse sort keys %static), "
! MAP_PRELIBS = $Config::Config{perllibs} $Config::Config{cryptlib}
";
if (defined $libperl) {
diff -rc perl5.005_01.orig/myconfig perl5.005_01/myconfig
*** perl5.005_01.orig/myconfig Fri Apr 3 01:20:35 1998
--- perl5.005_01/myconfig Sun Nov 12 20:55:58 2000
***************
*** 34,40 ****
Linker and Libraries:
ld='$ld', ldflags ='$ldflags'
libpth=$libpth
! libs=$libs
libc=$libc, so=$so, useshrplib=$useshrplib, libperl=$libperl
Dynamic Linking:
dlsrc=$dlsrc, dlext=$dlext, d_dlsymun=$d_dlsymun, ccdlflags='$ccdlflags'
--- 34,40 ----
Linker and Libraries:
ld='$ld', ldflags ='$ldflags'
libpth=$libpth
! libs=$perllibs
libc=$libc, so=$so, useshrplib=$useshrplib, libperl=$libperl
Dynamic Linking:
dlsrc=$dlsrc, dlext=$dlext, d_dlsymun=$d_dlsymun, ccdlflags='$ccdlflags'
diff -rc perl5.005_01.orig/patchlevel.h perl5.005_01/patchlevel.h
*** perl5.005_01.orig/patchlevel.h Mon Jan 3 11:07:45 2000
--- perl5.005_01/patchlevel.h Sun Nov 12 20:55:58 2000
***************
*** 39,44 ****
--- 39,45 ----
*/
static char *local_patches[] = {
NULL
+ ,"NODB-1.0 - remove -ldb from core perl binary."
,NULL
};

View File

@@ -0,0 +1,264 @@
diff -rc perl5.005_02.orig/Configure perl5.005_02/Configure
*** perl5.005_02.orig/Configure Mon Jan 3 11:12:20 2000
--- perl5.005_02/Configure Sun Nov 12 20:50:51 2000
***************
*** 234,239 ****
--- 234,240 ----
nm=''
nroff=''
perl=''
+ perllibs=''
pg=''
pmake=''
pr=''
***************
*** 11334,11339 ****
--- 11335,11348 ----
shift
extensions="$*"
+ : Remove libraries needed only for extensions
+ : The appropriate ext/Foo/Makefile.PL will add them back in, if
+ : necessary.
+ set X `echo " $libs " |
+ sed -e 's@ -lndbm @ @' -e 's@ -lgdbm @ @' -e 's@ -ldbm @ @' -e 's@ -ldb @ @'`
+ shift
+ perllibs="$*"
+
: Remove build directory name from cppstdin so it can be used from
: either the present location or the final installed location.
echo " "
***************
*** 11859,11864 ****
--- 11868,11874 ----
patchlevel='$patchlevel'
path_sep='$path_sep'
perl='$perl'
+ perllibs='$perllibs'
perladmin='$perladmin'
perlpath='$perlpath'
pg='$pg'
Only in perl5.005_02: Configure.orig
diff -rc perl5.005_02.orig/Makefile.SH perl5.005_02/Makefile.SH
*** perl5.005_02.orig/Makefile.SH Sun Jul 19 08:06:35 1998
--- perl5.005_02/Makefile.SH Sun Nov 12 20:50:51 2000
***************
*** 150,156 ****
ext = \$(dynamic_ext) \$(static_ext) \$(nonxs_ext)
DYNALOADER = lib/auto/DynaLoader/DynaLoader\$(LIB_EXT)
! libs = $libs $cryptlib
public = perl $suidperl utilities translators
--- 150,156 ----
ext = \$(dynamic_ext) \$(static_ext) \$(nonxs_ext)
DYNALOADER = lib/auto/DynaLoader/DynaLoader\$(LIB_EXT)
! libs = $perllibs $cryptlib
public = perl $suidperl utilities translators
Only in perl5.005_02: Makefile.SH.orig
diff -rc perl5.005_02.orig/lib/ExtUtils/Embed.pm perl5.005_02/lib/ExtUtils/Embed.pm
*** perl5.005_02.orig/lib/ExtUtils/Embed.pm Wed Jul 22 07:45:02 1998
--- perl5.005_02/lib/ExtUtils/Embed.pm Sun Nov 12 20:50:51 2000
***************
*** 194,200 ****
@path = $path ? split(/:/, $path) : @INC;
push(@potential_libs, @link_args) if scalar @link_args;
! push(@potential_libs, $Config{libs}) if defined $std;
push(@mods, static_ext()) if $std;
--- 194,200 ----
@path = $path ? split(/:/, $path) : @INC;
push(@potential_libs, @link_args) if scalar @link_args;
! push(@potential_libs, $Config{perllibs}) if defined $std;
push(@mods, static_ext()) if $std;
diff -rc perl5.005_02.orig/lib/ExtUtils/Liblist.pm perl5.005_02/lib/ExtUtils/Liblist.pm
*** perl5.005_02.orig/lib/ExtUtils/Liblist.pm Mon Jan 3 11:12:21 2000
--- perl5.005_02/lib/ExtUtils/Liblist.pm Sun Nov 12 20:50:51 2000
***************
*** 16,33 ****
sub _unix_os2_ext {
my($self,$potential_libs, $verbose) = @_;
! if ($^O =~ 'os2' and $Config{libs}) {
# Dynamic libraries are not transitive, so we may need including
# the libraries linked against perl.dll again.
$potential_libs .= " " if $potential_libs;
! $potential_libs .= $Config{libs};
}
return ("", "", "", "") unless $potential_libs;
warn "Potential libraries are '$potential_libs':\n" if $verbose;
my($so) = $Config{'so'};
! my($libs) = $Config{'libs'};
my $Config_libext = $Config{lib_ext} || ".a";
--- 16,33 ----
sub _unix_os2_ext {
my($self,$potential_libs, $verbose) = @_;
! if ($^O =~ 'os2' and $Config{perllibs}) {
# Dynamic libraries are not transitive, so we may need including
# the libraries linked against perl.dll again.
$potential_libs .= " " if $potential_libs;
! $potential_libs .= $Config{perllibs};
}
return ("", "", "", "") unless $potential_libs;
warn "Potential libraries are '$potential_libs':\n" if $verbose;
my($so) = $Config{'so'};
! my($libs) = $Config{'perllibs'};
my $Config_libext = $Config{lib_ext} || ".a";
***************
*** 196,202 ****
my $BC = 1 if $cc =~ /^bcc/i;
my $GC = 1 if $cc =~ /^gcc/i;
my $so = $Config{'so'};
! my $libs = $Config{'libs'};
my $libpth = $Config{'libpth'};
my $libext = $Config{'lib_ext'} || ".lib";
--- 196,202 ----
my $BC = 1 if $cc =~ /^bcc/i;
my $GC = 1 if $cc =~ /^gcc/i;
my $so = $Config{'so'};
! my $libs = $Config{'perllibs'};
my $libpth = $Config{'libpth'};
my $libext = $Config{'lib_ext'} || ".lib";
***************
*** 333,339 ****
$self->{CCFLAS} || $Config{'ccflags'};
@crtls = ( ($dbgqual =~ m-/Debug-i ? $Config{'dbgprefix'} : '')
. 'PerlShr/Share' );
! push(@crtls, grep { not /\(/ } split /\s+/, $Config{'libs'});
push(@crtls, grep { not /\(/ } split /\s+/, $Config{'libc'});
# In general, we pass through the basic libraries from %Config unchanged.
# The one exception is that if we're building in the Perl source tree, and
--- 333,339 ----
$self->{CCFLAS} || $Config{'ccflags'};
@crtls = ( ($dbgqual =~ m-/Debug-i ? $Config{'dbgprefix'} : '')
. 'PerlShr/Share' );
! push(@crtls, grep { not /\(/ } split /\s+/, $Config{'perllibs'});
push(@crtls, grep { not /\(/ } split /\s+/, $Config{'libc'});
# In general, we pass through the basic libraries from %Config unchanged.
# The one exception is that if we're building in the Perl source tree, and
***************
*** 623,629 ****
=item *
If C<$potential_libs> is empty, the return value will be empty.
! Otherwise, the libraries specified by C<$Config{libs}> (see Config.pm)
will be appended to the list of C<$potential_libs>. The libraries
will be searched for in the directories specified in C<$potential_libs>
as well as in C<$Config{libpth}>. For each library that is found, a
--- 623,629 ----
=item *
If C<$potential_libs> is empty, the return value will be empty.
! Otherwise, the libraries specified by C<$Config{perllibs}> (see Config.pm)
will be appended to the list of C<$potential_libs>. The libraries
will be searched for in the directories specified in C<$potential_libs>
as well as in C<$Config{libpth}>. For each library that is found, a
***************
*** 666,672 ****
alphanumeric characters are treated as flags. Unknown flags will be ignored.
An entry that matches C</:nodefault/i> disables the appending of default
! libraries found in C<$Config{libs}> (this should be only needed very rarely).
An entry that matches C</:nosearch/i> disables all searching for
the libraries specified after it. Translation of C<-Lfoo> and
--- 666,672 ----
alphanumeric characters are treated as flags. Unknown flags will be ignored.
An entry that matches C</:nodefault/i> disables the appending of default
! libraries found in C<$Config{perllibs}> (this should be only needed very rarely).
An entry that matches C</:nosearch/i> disables all searching for
the libraries specified after it. Translation of C<-Lfoo> and
***************
*** 676,682 ****
An entry that matches C</:search/i> reenables searching for
the libraries specified after it. You can put it at the end to
! enable searching for default libraries specified by C<$Config{libs}>.
=item *
--- 676,682 ----
An entry that matches C</:search/i> reenables searching for
the libraries specified after it. You can put it at the end to
! enable searching for default libraries specified by C<$Config{perllibs}>.
=item *
Only in perl5.005_02/lib/ExtUtils: Liblist.pm.orig
diff -rc perl5.005_02.orig/lib/ExtUtils/MM_Unix.pm perl5.005_02/lib/ExtUtils/MM_Unix.pm
*** perl5.005_02.orig/lib/ExtUtils/MM_Unix.pm Tue Jul 14 04:39:12 1998
--- perl5.005_02/lib/ExtUtils/MM_Unix.pm Sun Nov 12 20:50:51 2000
***************
*** 2281,2287 ****
MAP_STATIC = ",
join(" \\\n\t", reverse sort keys %static), "
! MAP_PRELIBS = $Config::Config{libs} $Config::Config{cryptlib}
";
if (defined $libperl) {
--- 2281,2287 ----
MAP_STATIC = ",
join(" \\\n\t", reverse sort keys %static), "
! MAP_PRELIBS = $Config::Config{perllibs} $Config::Config{cryptlib}
";
if (defined $libperl) {
Only in perl5.005_02/lib/ExtUtils: MM_Unix.pm.orig
diff -rc perl5.005_02.orig/myconfig perl5.005_02/myconfig
*** perl5.005_02.orig/myconfig Fri Apr 3 01:20:35 1998
--- perl5.005_02/myconfig Sun Nov 12 20:50:51 2000
***************
*** 34,40 ****
Linker and Libraries:
ld='$ld', ldflags ='$ldflags'
libpth=$libpth
! libs=$libs
libc=$libc, so=$so, useshrplib=$useshrplib, libperl=$libperl
Dynamic Linking:
dlsrc=$dlsrc, dlext=$dlext, d_dlsymun=$d_dlsymun, ccdlflags='$ccdlflags'
--- 34,40 ----
Linker and Libraries:
ld='$ld', ldflags ='$ldflags'
libpth=$libpth
! libs=$perllibs
libc=$libc, so=$so, useshrplib=$useshrplib, libperl=$libperl
Dynamic Linking:
dlsrc=$dlsrc, dlext=$dlext, d_dlsymun=$d_dlsymun, ccdlflags='$ccdlflags'
diff -rc perl5.005_02.orig/patchlevel.h perl5.005_02/patchlevel.h
*** perl5.005_02.orig/patchlevel.h Mon Jan 3 11:12:19 2000
--- perl5.005_02/patchlevel.h Sun Nov 12 20:50:51 2000
***************
*** 40,45 ****
--- 40,46 ----
*/
static char *local_patches[] = {
NULL
+ ,"NODB-1.0 - remove -ldb from core perl binary."
,NULL
};

View File

@@ -0,0 +1,250 @@
diff -rc perl5.005_03.orig/Configure perl5.005_03/Configure
*** perl5.005_03.orig/Configure Sun Mar 28 17:12:57 1999
--- perl5.005_03/Configure Sun Sep 17 22:19:16 2000
***************
*** 208,213 ****
--- 208,214 ----
nm=''
nroff=''
perl=''
+ perllibs=''
pg=''
pmake=''
pr=''
***************
*** 11642,11647 ****
--- 11643,11656 ----
shift
extensions="$*"
+ : Remove libraries needed only for extensions
+ : The appropriate ext/Foo/Makefile.PL will add them back in, if
+ : necessary.
+ set X `echo " $libs " |
+ sed -e 's@ -lndbm @ @' -e 's@ -lgdbm @ @' -e 's@ -ldbm @ @' -e 's@ -ldb @ @'`
+ shift
+ perllibs="$*"
+
: Remove build directory name from cppstdin so it can be used from
: either the present location or the final installed location.
echo " "
***************
*** 12183,12188 ****
--- 12192,12198 ----
patchlevel='$patchlevel'
path_sep='$path_sep'
perl='$perl'
+ perllibs='$perllibs'
perladmin='$perladmin'
perlpath='$perlpath'
pg='$pg'
diff -rc perl5.005_03.orig/Makefile.SH perl5.005_03/Makefile.SH
*** perl5.005_03.orig/Makefile.SH Thu Mar 4 02:35:25 1999
--- perl5.005_03/Makefile.SH Sun Sep 17 22:21:01 2000
***************
*** 58,67 ****
shrpldflags="-H512 -T512 -bhalt:4 -bM:SRE -bE:perl.exp"
case "$osvers" in
3*)
! shrpldflags="$shrpldflags -e _nostart $ldflags $libs $cryptlib"
;;
*)
! shrpldflags="$shrpldflags -b noentry $ldflags $libs $cryptlib"
;;
esac
aixinstdir=`pwd | sed 's/\/UU$//'`
--- 58,67 ----
shrpldflags="-H512 -T512 -bhalt:4 -bM:SRE -bE:perl.exp"
case "$osvers" in
3*)
! shrpldflags="$shrpldflags -e _nostart $ldflags $perllibs $cryptlib"
;;
*)
! shrpldflags="$shrpldflags -b noentry $ldflags $perllibs $cryptlib"
;;
esac
aixinstdir=`pwd | sed 's/\/UU$//'`
***************
*** 155,161 ****
ext = \$(dynamic_ext) \$(static_ext) \$(nonxs_ext)
DYNALOADER = lib/auto/DynaLoader/DynaLoader\$(LIB_EXT)
! libs = $libs $cryptlib
public = perl $suidperl utilities translators
--- 155,161 ----
ext = \$(dynamic_ext) \$(static_ext) \$(nonxs_ext)
DYNALOADER = lib/auto/DynaLoader/DynaLoader\$(LIB_EXT)
! libs = $perllibs $cryptlib
public = perl $suidperl utilities translators
diff -rc perl5.005_03.orig/lib/ExtUtils/Embed.pm perl5.005_03/lib/ExtUtils/Embed.pm
*** perl5.005_03.orig/lib/ExtUtils/Embed.pm Wed Jan 6 02:17:50 1999
--- perl5.005_03/lib/ExtUtils/Embed.pm Sun Sep 17 22:19:16 2000
***************
*** 194,200 ****
@path = $path ? split(/:/, $path) : @INC;
push(@potential_libs, @link_args) if scalar @link_args;
! push(@potential_libs, $Config{libs}) if defined $std;
push(@mods, static_ext()) if $std;
--- 194,200 ----
@path = $path ? split(/:/, $path) : @INC;
push(@potential_libs, @link_args) if scalar @link_args;
! push(@potential_libs, $Config{perllibs}) if defined $std;
push(@mods, static_ext()) if $std;
diff -rc perl5.005_03.orig/lib/ExtUtils/Liblist.pm perl5.005_03/lib/ExtUtils/Liblist.pm
*** perl5.005_03.orig/lib/ExtUtils/Liblist.pm Wed Jan 6 02:17:47 1999
--- perl5.005_03/lib/ExtUtils/Liblist.pm Sun Sep 17 22:19:16 2000
***************
*** 16,33 ****
sub _unix_os2_ext {
my($self,$potential_libs, $verbose) = @_;
! if ($^O =~ 'os2' and $Config{libs}) {
# Dynamic libraries are not transitive, so we may need including
# the libraries linked against perl.dll again.
$potential_libs .= " " if $potential_libs;
! $potential_libs .= $Config{libs};
}
return ("", "", "", "") unless $potential_libs;
warn "Potential libraries are '$potential_libs':\n" if $verbose;
my($so) = $Config{'so'};
! my($libs) = $Config{'libs'};
my $Config_libext = $Config{lib_ext} || ".a";
--- 16,33 ----
sub _unix_os2_ext {
my($self,$potential_libs, $verbose) = @_;
! if ($^O =~ 'os2' and $Config{perllibs}) {
# Dynamic libraries are not transitive, so we may need including
# the libraries linked against perl.dll again.
$potential_libs .= " " if $potential_libs;
! $potential_libs .= $Config{perllibs};
}
return ("", "", "", "") unless $potential_libs;
warn "Potential libraries are '$potential_libs':\n" if $verbose;
my($so) = $Config{'so'};
! my($libs) = $Config{'perllibs'};
my $Config_libext = $Config{lib_ext} || ".a";
***************
*** 196,202 ****
my $BC = 1 if $cc =~ /^bcc/i;
my $GC = 1 if $cc =~ /^gcc/i;
my $so = $Config{'so'};
! my $libs = $Config{'libs'};
my $libpth = $Config{'libpth'};
my $libext = $Config{'lib_ext'} || ".lib";
--- 196,202 ----
my $BC = 1 if $cc =~ /^bcc/i;
my $GC = 1 if $cc =~ /^gcc/i;
my $so = $Config{'so'};
! my $libs = $Config{'perllibs'};
my $libpth = $Config{'libpth'};
my $libext = $Config{'lib_ext'} || ".lib";
***************
*** 336,342 ****
$self->{CCFLAS} || $Config{'ccflags'};
@crtls = ( ($dbgqual =~ m-/Debug-i ? $Config{'dbgprefix'} : '')
. 'PerlShr/Share' );
! push(@crtls, grep { not /\(/ } split /\s+/, $Config{'libs'});
push(@crtls, grep { not /\(/ } split /\s+/, $Config{'libc'});
# In general, we pass through the basic libraries from %Config unchanged.
# The one exception is that if we're building in the Perl source tree, and
--- 336,342 ----
$self->{CCFLAS} || $Config{'ccflags'};
@crtls = ( ($dbgqual =~ m-/Debug-i ? $Config{'dbgprefix'} : '')
. 'PerlShr/Share' );
! push(@crtls, grep { not /\(/ } split /\s+/, $Config{'perllibs'});
push(@crtls, grep { not /\(/ } split /\s+/, $Config{'libc'});
# In general, we pass through the basic libraries from %Config unchanged.
# The one exception is that if we're building in the Perl source tree, and
***************
*** 626,632 ****
=item *
If C<$potential_libs> is empty, the return value will be empty.
! Otherwise, the libraries specified by C<$Config{libs}> (see Config.pm)
will be appended to the list of C<$potential_libs>. The libraries
will be searched for in the directories specified in C<$potential_libs>,
C<$Config{libpth}>, and in C<$Config{installarchlib}/CORE>.
--- 626,632 ----
=item *
If C<$potential_libs> is empty, the return value will be empty.
! Otherwise, the libraries specified by C<$Config{perllibs}> (see Config.pm)
will be appended to the list of C<$potential_libs>. The libraries
will be searched for in the directories specified in C<$potential_libs>,
C<$Config{libpth}>, and in C<$Config{installarchlib}/CORE>.
***************
*** 670,676 ****
alphanumeric characters are treated as flags. Unknown flags will be ignored.
An entry that matches C</:nodefault/i> disables the appending of default
! libraries found in C<$Config{libs}> (this should be only needed very rarely).
An entry that matches C</:nosearch/i> disables all searching for
the libraries specified after it. Translation of C<-Lfoo> and
--- 670,676 ----
alphanumeric characters are treated as flags. Unknown flags will be ignored.
An entry that matches C</:nodefault/i> disables the appending of default
! libraries found in C<$Config{perllibs}> (this should be only needed very rarely).
An entry that matches C</:nosearch/i> disables all searching for
the libraries specified after it. Translation of C<-Lfoo> and
***************
*** 680,686 ****
An entry that matches C</:search/i> reenables searching for
the libraries specified after it. You can put it at the end to
! enable searching for default libraries specified by C<$Config{libs}>.
=item *
--- 680,686 ----
An entry that matches C</:search/i> reenables searching for
the libraries specified after it. You can put it at the end to
! enable searching for default libraries specified by C<$Config{perllibs}>.
=item *
diff -rc perl5.005_03.orig/lib/ExtUtils/MM_Unix.pm perl5.005_03/lib/ExtUtils/MM_Unix.pm
*** perl5.005_03.orig/lib/ExtUtils/MM_Unix.pm Fri Mar 5 00:34:20 1999
--- perl5.005_03/lib/ExtUtils/MM_Unix.pm Sun Sep 17 22:19:16 2000
***************
*** 2284,2290 ****
MAP_STATIC = ",
join(" \\\n\t", reverse sort keys %static), "
! MAP_PRELIBS = $Config::Config{libs} $Config::Config{cryptlib}
";
if (defined $libperl) {
--- 2284,2290 ----
MAP_STATIC = ",
join(" \\\n\t", reverse sort keys %static), "
! MAP_PRELIBS = $Config::Config{perllibs} $Config::Config{cryptlib}
";
if (defined $libperl) {

294
perl/DB_File/patches/5.6.0 Normal file
View File

@@ -0,0 +1,294 @@
diff -cr perl-5.6.0.orig/Configure perl-5.6.0/Configure
*** perl-5.6.0.orig/Configure Wed Mar 22 20:36:37 2000
--- perl-5.6.0/Configure Sun Sep 17 23:40:15 2000
***************
*** 217,222 ****
--- 217,223 ----
nm=''
nroff=''
perl=''
+ perllibs=''
pg=''
pmake=''
pr=''
***************
*** 14971,14976 ****
--- 14972,14985 ----
shift
extensions="$*"
+ : Remove libraries needed only for extensions
+ : The appropriate ext/Foo/Makefile.PL will add them back in, if
+ : necessary.
+ set X `echo " $libs " |
+ sed -e 's@ -lndbm @ @' -e 's@ -lgdbm @ @' -e 's@ -ldbm @ @' -e 's@ -ldb @ @'`
+ shift
+ perllibs="$*"
+
: Remove build directory name from cppstdin so it can be used from
: either the present location or the final installed location.
echo " "
***************
*** 15640,15645 ****
--- 15649,15655 ----
path_sep='$path_sep'
perl5='$perl5'
perl='$perl'
+ perllibs='$perllibs'
perladmin='$perladmin'
perlpath='$perlpath'
pg='$pg'
diff -cr perl-5.6.0.orig/Makefile.SH perl-5.6.0/Makefile.SH
*** perl-5.6.0.orig/Makefile.SH Sat Mar 11 16:05:24 2000
--- perl-5.6.0/Makefile.SH Sun Sep 17 23:40:15 2000
***************
*** 70,76 ****
*) shrpldflags="$shrpldflags -b noentry"
;;
esac
! shrpldflags="$shrpldflags $ldflags $libs $cryptlib"
linklibperl="-L $archlibexp/CORE -L `pwd | sed 's/\/UU$//'` -lperl"
;;
hpux*)
--- 70,76 ----
*) shrpldflags="$shrpldflags -b noentry"
;;
esac
! shrpldflags="$shrpldflags $ldflags $perllibs $cryptlib"
linklibperl="-L $archlibexp/CORE -L `pwd | sed 's/\/UU$//'` -lperl"
;;
hpux*)
***************
*** 176,182 ****
ext = \$(dynamic_ext) \$(static_ext) \$(nonxs_ext)
DYNALOADER = lib/auto/DynaLoader/DynaLoader\$(LIB_EXT)
! libs = $libs $cryptlib
public = perl $suidperl utilities translators
--- 176,182 ----
ext = \$(dynamic_ext) \$(static_ext) \$(nonxs_ext)
DYNALOADER = lib/auto/DynaLoader/DynaLoader\$(LIB_EXT)
! libs = $perllibs $cryptlib
public = perl $suidperl utilities translators
***************
*** 333,339 ****
case "$osname" in
aix)
$spitshell >>Makefile <<!GROK!THIS!
! LIBS = $libs
# In AIX we need to change this for building Perl itself from
# its earlier definition (which is for building external
# extensions *after* Perl has been built and installed)
--- 333,339 ----
case "$osname" in
aix)
$spitshell >>Makefile <<!GROK!THIS!
! LIBS = $perllibs
# In AIX we need to change this for building Perl itself from
# its earlier definition (which is for building external
# extensions *after* Perl has been built and installed)
diff -cr perl-5.6.0.orig/lib/ExtUtils/Embed.pm perl-5.6.0/lib/ExtUtils/Embed.pm
*** perl-5.6.0.orig/lib/ExtUtils/Embed.pm Sun Jan 23 12:08:32 2000
--- perl-5.6.0/lib/ExtUtils/Embed.pm Sun Sep 17 23:40:15 2000
***************
*** 193,199 ****
@path = $path ? split(/:/, $path) : @INC;
push(@potential_libs, @link_args) if scalar @link_args;
! push(@potential_libs, $Config{libs}) if defined $std;
push(@mods, static_ext()) if $std;
--- 193,199 ----
@path = $path ? split(/:/, $path) : @INC;
push(@potential_libs, @link_args) if scalar @link_args;
! push(@potential_libs, $Config{perllibs}) if defined $std;
push(@mods, static_ext()) if $std;
diff -cr perl-5.6.0.orig/lib/ExtUtils/Liblist.pm perl-5.6.0/lib/ExtUtils/Liblist.pm
*** perl-5.6.0.orig/lib/ExtUtils/Liblist.pm Wed Mar 22 16:16:31 2000
--- perl-5.6.0/lib/ExtUtils/Liblist.pm Sun Sep 17 23:40:15 2000
***************
*** 17,34 ****
sub _unix_os2_ext {
my($self,$potential_libs, $verbose) = @_;
! if ($^O =~ 'os2' and $Config{libs}) {
# Dynamic libraries are not transitive, so we may need including
# the libraries linked against perl.dll again.
$potential_libs .= " " if $potential_libs;
! $potential_libs .= $Config{libs};
}
return ("", "", "", "") unless $potential_libs;
warn "Potential libraries are '$potential_libs':\n" if $verbose;
my($so) = $Config{'so'};
! my($libs) = $Config{'libs'};
my $Config_libext = $Config{lib_ext} || ".a";
--- 17,34 ----
sub _unix_os2_ext {
my($self,$potential_libs, $verbose) = @_;
! if ($^O =~ 'os2' and $Config{perllibs}) {
# Dynamic libraries are not transitive, so we may need including
# the libraries linked against perl.dll again.
$potential_libs .= " " if $potential_libs;
! $potential_libs .= $Config{perllibs};
}
return ("", "", "", "") unless $potential_libs;
warn "Potential libraries are '$potential_libs':\n" if $verbose;
my($so) = $Config{'so'};
! my($libs) = $Config{'perllibs'};
my $Config_libext = $Config{lib_ext} || ".a";
***************
*** 198,204 ****
my $BC = 1 if $cc =~ /^bcc/i;
my $GC = 1 if $cc =~ /^gcc/i;
my $so = $Config{'so'};
! my $libs = $Config{'libs'};
my $libpth = $Config{'libpth'};
my $libext = $Config{'lib_ext'} || ".lib";
--- 198,204 ----
my $BC = 1 if $cc =~ /^bcc/i;
my $GC = 1 if $cc =~ /^gcc/i;
my $so = $Config{'so'};
! my $libs = $Config{'perllibs'};
my $libpth = $Config{'libpth'};
my $libext = $Config{'lib_ext'} || ".lib";
***************
*** 338,344 ****
$self->{CCFLAS} || $Config{'ccflags'};
@crtls = ( ($dbgqual =~ m-/Debug-i ? $Config{'dbgprefix'} : '')
. 'PerlShr/Share' );
! push(@crtls, grep { not /\(/ } split /\s+/, $Config{'libs'});
push(@crtls, grep { not /\(/ } split /\s+/, $Config{'libc'});
# In general, we pass through the basic libraries from %Config unchanged.
# The one exception is that if we're building in the Perl source tree, and
--- 338,344 ----
$self->{CCFLAS} || $Config{'ccflags'};
@crtls = ( ($dbgqual =~ m-/Debug-i ? $Config{'dbgprefix'} : '')
. 'PerlShr/Share' );
! push(@crtls, grep { not /\(/ } split /\s+/, $Config{'perllibs'});
push(@crtls, grep { not /\(/ } split /\s+/, $Config{'libc'});
# In general, we pass through the basic libraries from %Config unchanged.
# The one exception is that if we're building in the Perl source tree, and
***************
*** 624,630 ****
=item *
If C<$potential_libs> is empty, the return value will be empty.
! Otherwise, the libraries specified by C<$Config{libs}> (see Config.pm)
will be appended to the list of C<$potential_libs>. The libraries
will be searched for in the directories specified in C<$potential_libs>,
C<$Config{libpth}>, and in C<$Config{installarchlib}/CORE>.
--- 624,630 ----
=item *
If C<$potential_libs> is empty, the return value will be empty.
! Otherwise, the libraries specified by C<$Config{perllibs}> (see Config.pm)
will be appended to the list of C<$potential_libs>. The libraries
will be searched for in the directories specified in C<$potential_libs>,
C<$Config{libpth}>, and in C<$Config{installarchlib}/CORE>.
***************
*** 668,674 ****
alphanumeric characters are treated as flags. Unknown flags will be ignored.
An entry that matches C</:nodefault/i> disables the appending of default
! libraries found in C<$Config{libs}> (this should be only needed very rarely).
An entry that matches C</:nosearch/i> disables all searching for
the libraries specified after it. Translation of C<-Lfoo> and
--- 668,674 ----
alphanumeric characters are treated as flags. Unknown flags will be ignored.
An entry that matches C</:nodefault/i> disables the appending of default
! libraries found in C<$Config{perllibs}> (this should be only needed very rarely).
An entry that matches C</:nosearch/i> disables all searching for
the libraries specified after it. Translation of C<-Lfoo> and
***************
*** 678,684 ****
An entry that matches C</:search/i> reenables searching for
the libraries specified after it. You can put it at the end to
! enable searching for default libraries specified by C<$Config{libs}>.
=item *
--- 678,684 ----
An entry that matches C</:search/i> reenables searching for
the libraries specified after it. You can put it at the end to
! enable searching for default libraries specified by C<$Config{perllibs}>.
=item *
diff -cr perl-5.6.0.orig/lib/ExtUtils/MM_Unix.pm perl-5.6.0/lib/ExtUtils/MM_Unix.pm
*** perl-5.6.0.orig/lib/ExtUtils/MM_Unix.pm Thu Mar 2 17:52:52 2000
--- perl-5.6.0/lib/ExtUtils/MM_Unix.pm Sun Sep 17 23:40:15 2000
***************
*** 2450,2456 ****
MAP_STATIC = ",
join(" \\\n\t", reverse sort keys %static), "
! MAP_PRELIBS = $Config::Config{libs} $Config::Config{cryptlib}
";
if (defined $libperl) {
--- 2450,2456 ----
MAP_STATIC = ",
join(" \\\n\t", reverse sort keys %static), "
! MAP_PRELIBS = $Config::Config{perllibs} $Config::Config{cryptlib}
";
if (defined $libperl) {
diff -cr perl-5.6.0.orig/myconfig.SH perl-5.6.0/myconfig.SH
*** perl-5.6.0.orig/myconfig.SH Sat Feb 26 06:34:49 2000
--- perl-5.6.0/myconfig.SH Sun Sep 17 23:41:17 2000
***************
*** 48,54 ****
Linker and Libraries:
ld='$ld', ldflags ='$ldflags'
libpth=$libpth
! libs=$libs
libc=$libc, so=$so, useshrplib=$useshrplib, libperl=$libperl
Dynamic Linking:
dlsrc=$dlsrc, dlext=$dlext, d_dlsymun=$d_dlsymun, ccdlflags='$ccdlflags'
--- 48,54 ----
Linker and Libraries:
ld='$ld', ldflags ='$ldflags'
libpth=$libpth
! libs=$perllibs
libc=$libc, so=$so, useshrplib=$useshrplib, libperl=$libperl
Dynamic Linking:
dlsrc=$dlsrc, dlext=$dlext, d_dlsymun=$d_dlsymun, ccdlflags='$ccdlflags'
diff -cr perl-5.6.0.orig/patchlevel.h perl-5.6.0/patchlevel.h
*** perl-5.6.0.orig/patchlevel.h Wed Mar 22 20:23:11 2000
--- perl-5.6.0/patchlevel.h Sun Sep 17 23:40:15 2000
***************
*** 70,75 ****
--- 70,76 ----
#if !defined(PERL_PATCHLEVEL_H_IMPLICIT) && !defined(LOCAL_PATCH_COUNT)
static char *local_patches[] = {
NULL
+ ,"NODB-1.0 - remove -ldb from core perl binary."
,NULL
};

364
perl/DB_File/ppport.h Normal file
View File

@@ -0,0 +1,364 @@
/* This file is Based on output from
* Perl/Pollution/Portability Version 2.0000 */
#ifndef _P_P_PORTABILITY_H_
#define _P_P_PORTABILITY_H_
#ifndef PERL_REVISION
# ifndef __PATCHLEVEL_H_INCLUDED__
# include "patchlevel.h"
# endif
# ifndef PERL_REVISION
# define PERL_REVISION (5)
/* Replace: 1 */
# define PERL_VERSION PATCHLEVEL
# define PERL_SUBVERSION SUBVERSION
/* Replace PERL_PATCHLEVEL with PERL_VERSION */
/* Replace: 0 */
# endif
#endif
#define PERL_BCDVERSION ((PERL_REVISION * 0x1000000L) + (PERL_VERSION * 0x1000L) + PERL_SUBVERSION)
#ifndef ERRSV
# define ERRSV perl_get_sv("@",FALSE)
#endif
#if (PERL_VERSION < 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION <= 5))
/* Replace: 1 */
# define PL_Sv Sv
# define PL_compiling compiling
# define PL_copline copline
# define PL_curcop curcop
# define PL_curstash curstash
# define PL_defgv defgv
# define PL_dirty dirty
# define PL_hints hints
# define PL_na na
# define PL_perldb perldb
# define PL_rsfp_filters rsfp_filters
# define PL_rsfp rsfp
# define PL_stdingv stdingv
# define PL_sv_no sv_no
# define PL_sv_undef sv_undef
# define PL_sv_yes sv_yes
/* Replace: 0 */
#endif
#ifndef pTHX
# define pTHX
# define pTHX_
# define aTHX
# define aTHX_
#endif
#ifndef PTR2IV
# define PTR2IV(d) (IV)(d)
#endif
#ifndef INT2PTR
# define INT2PTR(any,d) (any)(d)
#endif
#ifndef dTHR
# ifdef WIN32
# define dTHR extern int Perl___notused
# else
# define dTHR extern int errno
# endif
#endif
#ifndef boolSV
# define boolSV(b) ((b) ? &PL_sv_yes : &PL_sv_no)
#endif
#ifndef gv_stashpvn
# define gv_stashpvn(str,len,flags) gv_stashpv(str,flags)
#endif
#ifndef newSVpvn
# define newSVpvn(data,len) ((len) ? newSVpv ((data), (len)) : newSVpv ("", 0))
#endif
#ifndef newRV_inc
/* Replace: 1 */
# define newRV_inc(sv) newRV(sv)
/* Replace: 0 */
#endif
/* DEFSV appears first in 5.004_56 */
#ifndef DEFSV
# define DEFSV GvSV(PL_defgv)
#endif
#ifndef SAVE_DEFSV
# define SAVE_DEFSV SAVESPTR(GvSV(PL_defgv))
#endif
#ifndef newRV_noinc
# ifdef __GNUC__
# define newRV_noinc(sv) \
({ \
SV *nsv = (SV*)newRV(sv); \
SvREFCNT_dec(sv); \
nsv; \
})
# else
# if defined(CRIPPLED_CC) || defined(USE_THREADS)
static SV * newRV_noinc (SV * sv)
{
SV *nsv = (SV*)newRV(sv);
SvREFCNT_dec(sv);
return nsv;
}
# else
# define newRV_noinc(sv) \
((PL_Sv=(SV*)newRV(sv), SvREFCNT_dec(sv), (SV*)PL_Sv)
# endif
# endif
#endif
/* Provide: newCONSTSUB */
/* newCONSTSUB from IO.xs is in the core starting with 5.004_63 */
#if (PERL_VERSION < 4) || ((PERL_VERSION == 4) && (PERL_SUBVERSION < 63))
#if defined(NEED_newCONSTSUB)
static
#else
extern void newCONSTSUB _((HV * stash, char * name, SV *sv));
#endif
#if defined(NEED_newCONSTSUB) || defined(NEED_newCONSTSUB_GLOBAL)
void
newCONSTSUB(stash,name,sv)
HV *stash;
char *name;
SV *sv;
{
U32 oldhints = PL_hints;
HV *old_cop_stash = PL_curcop->cop_stash;
HV *old_curstash = PL_curstash;
line_t oldline = PL_curcop->cop_line;
PL_curcop->cop_line = PL_copline;
PL_hints &= ~HINT_BLOCK_SCOPE;
if (stash)
PL_curstash = PL_curcop->cop_stash = stash;
newSUB(
#if (PERL_VERSION < 3) || ((PERL_VERSION == 3) && (PERL_SUBVERSION < 22))
/* before 5.003_22 */
start_subparse(),
#else
# if (PERL_VERSION == 3) && (PERL_SUBVERSION == 22)
/* 5.003_22 */
start_subparse(0),
# else
/* 5.003_23 onwards */
start_subparse(FALSE, 0),
# endif
#endif
newSVOP(OP_CONST, 0, newSVpv(name,0)),
newSVOP(OP_CONST, 0, &PL_sv_no), /* SvPV(&PL_sv_no) == "" -- GMB */
newSTATEOP(0, Nullch, newSVOP(OP_CONST, 0, sv))
);
PL_hints = oldhints;
PL_curcop->cop_stash = old_cop_stash;
PL_curstash = old_curstash;
PL_curcop->cop_line = oldline;
}
#endif
#endif /* newCONSTSUB */
#ifndef START_MY_CXT
/*
* Boilerplate macros for initializing and accessing interpreter-local
* data from C. All statics in extensions should be reworked to use
* this, if you want to make the extension thread-safe. See ext/re/re.xs
* for an example of the use of these macros.
*
* Code that uses these macros is responsible for the following:
* 1. #define MY_CXT_KEY to a unique string, e.g. "DynaLoader_guts"
* 2. Declare a typedef named my_cxt_t that is a structure that contains
* all the data that needs to be interpreter-local.
* 3. Use the START_MY_CXT macro after the declaration of my_cxt_t.
* 4. Use the MY_CXT_INIT macro such that it is called exactly once
* (typically put in the BOOT: section).
* 5. Use the members of the my_cxt_t structure everywhere as
* MY_CXT.member.
* 6. Use the dMY_CXT macro (a declaration) in all the functions that
* access MY_CXT.
*/
#if defined(MULTIPLICITY) || defined(PERL_OBJECT) || \
defined(PERL_CAPI) || defined(PERL_IMPLICIT_CONTEXT)
/* This must appear in all extensions that define a my_cxt_t structure,
* right after the definition (i.e. at file scope). The non-threads
* case below uses it to declare the data as static. */
#define START_MY_CXT
#if PERL_REVISION == 5 && \
(PERL_VERSION < 4 || (PERL_VERSION == 4 && PERL_SUBVERSION < 68 ))
/* Fetches the SV that keeps the per-interpreter data. */
#define dMY_CXT_SV \
SV *my_cxt_sv = perl_get_sv(MY_CXT_KEY, FALSE)
#else /* >= perl5.004_68 */
#define dMY_CXT_SV \
SV *my_cxt_sv = *hv_fetch(PL_modglobal, MY_CXT_KEY, \
sizeof(MY_CXT_KEY)-1, TRUE)
#endif /* < perl5.004_68 */
/* This declaration should be used within all functions that use the
* interpreter-local data. */
#define dMY_CXT \
dMY_CXT_SV; \
my_cxt_t *my_cxtp = INT2PTR(my_cxt_t*,SvUV(my_cxt_sv))
/* Creates and zeroes the per-interpreter data.
* (We allocate my_cxtp in a Perl SV so that it will be released when
* the interpreter goes away.) */
#define MY_CXT_INIT \
dMY_CXT_SV; \
/* newSV() allocates one more than needed */ \
my_cxt_t *my_cxtp = (my_cxt_t*)SvPVX(newSV(sizeof(my_cxt_t)-1));\
Zero(my_cxtp, 1, my_cxt_t); \
sv_setuv(my_cxt_sv, PTR2UV(my_cxtp))
/* This macro must be used to access members of the my_cxt_t structure.
* e.g. MYCXT.some_data */
#define MY_CXT (*my_cxtp)
/* Judicious use of these macros can reduce the number of times dMY_CXT
* is used. Use is similar to pTHX, aTHX etc. */
#define pMY_CXT my_cxt_t *my_cxtp
#define pMY_CXT_ pMY_CXT,
#define _pMY_CXT ,pMY_CXT
#define aMY_CXT my_cxtp
#define aMY_CXT_ aMY_CXT,
#define _aMY_CXT ,aMY_CXT
#else /* single interpreter */
#ifndef NOOP
# define NOOP (void)0
#endif
#ifdef HASATTRIBUTE
# define PERL_UNUSED_DECL __attribute__((unused))
#else
# define PERL_UNUSED_DECL
#endif
#ifndef dNOOP
# define dNOOP extern int Perl___notused PERL_UNUSED_DECL
#endif
#define START_MY_CXT static my_cxt_t my_cxt;
#define dMY_CXT_SV dNOOP
#define dMY_CXT dNOOP
#define MY_CXT_INIT NOOP
#define MY_CXT my_cxt
#define pMY_CXT void
#define pMY_CXT_
#define _pMY_CXT
#define aMY_CXT
#define aMY_CXT_
#define _aMY_CXT
#endif
#endif /* START_MY_CXT */
#ifdef SvPVbyte
# if PERL_REVISION == 5 && PERL_VERSION < 7
/* SvPVbyte does not work in perl-5.6.1, borrowed version for 5.7.3 */
# undef SvPVbyte
# define SvPVbyte(sv, lp) \
((SvFLAGS(sv) & (SVf_POK|SVf_UTF8)) == (SVf_POK) \
? ((lp = SvCUR(sv)), SvPVX(sv)) : my_sv_2pvbyte(aTHX_ sv, &lp))
static char *
my_sv_2pvbyte(pTHX_ register SV *sv, STRLEN *lp)
{
sv_utf8_downgrade(sv,0);
return SvPV(sv,*lp);
}
# endif
#else
# define SvPVbyte SvPV
#endif
#ifndef SvUTF8_off
# define SvUTF8_off(s)
#endif
#if 1
#ifdef DBM_setFilter
#undef DBM_setFilter
#undef DBM_ckFilter
#endif
#endif
#ifndef DBM_setFilter
/*
The DBM_setFilter & DBM_ckFilter macros are only used by
the *DB*_File modules
*/
#define DBM_setFilter(db_type,code) \
{ \
if (db_type) \
RETVAL = sv_mortalcopy(db_type) ; \
ST(0) = RETVAL ; \
if (db_type && (code == &PL_sv_undef)) { \
SvREFCNT_dec(db_type) ; \
db_type = NULL ; \
} \
else if (code) { \
if (db_type) \
sv_setsv(db_type, code) ; \
else \
db_type = newSVsv(code) ; \
} \
}
#define DBM_ckFilter(arg,type,name) \
if (db->type) { \
/*printf("ckFilter %s\n", name);*/ \
if (db->filtering) { \
croak("recursion detected in %s", name) ; \
} \
ENTER ; \
SAVETMPS ; \
SAVEINT(db->filtering) ; \
db->filtering = TRUE ; \
SAVESPTR(DEFSV) ; \
if (name[7] == 's') \
arg = newSVsv(arg); \
DEFSV = arg ; \
SvTEMP_off(arg) ; \
PUSHMARK(SP) ; \
PUTBACK ; \
(void) perl_call_sv(db->type, G_DISCARD); \
SPAGAIN ; \
PUTBACK ; \
FREETMPS ; \
LEAVE ; \
if (name[7] == 's'){ \
arg = sv_2mortal(arg); \
} \
SvOKp(arg); \
}
#endif /* DBM_setFilter */
#endif /* _P_P_PORTABILITY_H_ */

1664
perl/DB_File/t/db-btree.t Normal file

File diff suppressed because it is too large Load Diff

1232
perl/DB_File/t/db-hash.t Normal file

File diff suppressed because it is too large Load Diff

1603
perl/DB_File/t/db-recno.t Normal file

File diff suppressed because it is too large Load Diff

18
perl/DB_File/t/pod.t Normal file
View File

@@ -0,0 +1,18 @@
eval " use Test::More " ;
if ($@)
{
print "1..0 # Skip: Test::More required for testing POD\n" ;
exit 0;
}
eval "use Test::Pod 1.00";
if ($@)
{
print "1..0 # Skip: Test::Pod 1.00 required for testing POD\n" ;
exit 0;
}
all_pod_files_ok();

57
perl/DB_File/typemap Normal file
View File

@@ -0,0 +1,57 @@
# typemap for Perl 5 interface to Berkeley
#
# written by Paul Marquess <Paul.Marquess@btinternet.com>
# last modified 20th June 2004
# version 1.809
#
#################################### DB SECTION
#
#
u_int T_U_INT
DB_File T_PTROBJ
DBT T_dbtdatum
DBTKEY T_dbtkeydatum
INPUT
T_dbtkeydatum
{
SV * my_sv = $arg;
DBM_ckFilter(my_sv, filter_store_key, \"filter_store_key\");
DBT_clear($var) ;
SvGETMAGIC(my_sv) ;
if (db->type == DB_RECNO) {
if (SvOK(my_sv))
Value = GetRecnoKey(aTHX_ db, SvIV(my_sv)) ;
else
Value = 1 ;
$var.data = & Value;
$var.size = (int)sizeof(recno_t);
}
else if (SvOK(my_sv)) {
STRLEN len;
$var.data = SvPVbyte(my_sv, len);
$var.size = (int)len;
}
}
T_dbtdatum
{
SV * my_sv = $arg;
DBM_ckFilter(my_sv, filter_store_value, \"filter_store_value\");
DBT_clear($var) ;
SvGETMAGIC(my_sv) ;
if (SvOK(my_sv)) {
STRLEN len;
$var.data = SvPVbyte(my_sv, len);
$var.size = (int)len;
}
}
OUTPUT
T_dbtkeydatum
OutputKey($arg, $var)
T_dbtdatum
OutputValue($arg, $var)
T_PTROBJ
sv_setref_pv($arg, dbtype, (void*)$var);

83
perl/DB_File/version.c Normal file
View File

@@ -0,0 +1,83 @@
/*
version.c -- Perl 5 interface to Berkeley DB
written by Paul Marquess <Paul.Marquess@btinternet.com>
last modified 2nd Jan 2002
version 1.802
All comments/suggestions/problems are welcome
Copyright (c) 1995-2002 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.
1.72 - No change.
1.73 - Added support for threading
1.74 - Added Perl core patch 7801.
*/
#define PERL_NO_GET_CONTEXT
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include <db.h>
void
#ifdef CAN_PROTOTYPE
__getBerkeleyDBInfo(void)
#else
__getBerkeleyDBInfo()
#endif
{
#ifdef dTHX
dTHX;
#endif
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 was build with libdb version %d.%d.%d,\nbut you are attempting to run it with 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 */
}