Codebase list libberkeleydb-perl / 5761a34
Imported Upstream version 0.41 Marco d'Itri 9 years ago
7 changed file(s) with 186 addition(s) and 44 deletion(s). Raw diff Collapse all Expand all
11 package BerkeleyDB;
22
33
4 # Copyright (c) 1997-2009 Paul Marquess. All rights reserved.
4 # Copyright (c) 1997-2010 Paul Marquess. All rights reserved.
55 # This program is free software; you can redistribute it and/or
66 # modify it under the same terms as Perl itself.
77 #
1616 use vars qw($VERSION @ISA @EXPORT $AUTOLOAD
1717 $use_XSLoader);
1818
19 $VERSION = '0.39';
19 $VERSION = '0.41';
2020
2121 require Exporter;
2222 #require DynaLoader;
655655 }
656656 }
657657
658 use UNIVERSAL qw( isa ) ;
658 use UNIVERSAL ;
659659
660660 sub env_remove
661661 {
705705 if ! defined $got->{Filename} ;
706706
707707 croak("Env not of type BerkeleyDB::Env")
708 if defined $got->{Env} and ! isa($got->{Env},'BerkeleyDB::Env');
708 if defined $got->{Env} and ! UNIVERSAL::isa($got->{Env},'BerkeleyDB::Env');
709709
710710 return _db_remove($got);
711711 }
723723 }, @_) ;
724724
725725 croak("Env not of type BerkeleyDB::Env")
726 if defined $got->{Env} and ! isa($got->{Env},'BerkeleyDB::Env');
726 if defined $got->{Env} and ! UNIVERSAL::isa($got->{Env},'BerkeleyDB::Env');
727727
728728 croak("Must specify a filename")
729729 if ! defined $got->{Filename} ;
749749 }, @_) ;
750750
751751 croak("Env not of type BerkeleyDB::Env")
752 if defined $got->{Env} and ! isa($got->{Env},'BerkeleyDB::Env');
752 if defined $got->{Env} and ! UNIVERSAL::isa($got->{Env},'BerkeleyDB::Env');
753753
754754 croak("Must specify a filename")
755755 if ! defined $got->{Filename} ;
759759
760760 package BerkeleyDB::Env ;
761761
762 use UNIVERSAL qw( isa ) ;
762 use UNIVERSAL ;
763763 use Carp ;
764764 use IO::File;
765765 use vars qw( %valid_config_keys ) ;
768768 {
769769 my $fh = shift ;
770770
771 return ((isa($fh,'GLOB') or isa(\$fh,'GLOB')) and defined fileno($fh) )
771 return ((UNIVERSAL::isa($fh,'GLOB') or UNIVERSAL::isa(\$fh,'GLOB')) and defined fileno($fh) )
772772
773773 }
774774
806806 SetFlags => 0,
807807 Cachesize => 0,
808808 LockDetect => 0,
809 TxMax => 0,
810 LogConfig => 0,
811 MaxLockers => 0,
812 MaxLocks => 0,
813 MaxObjects => 0,
809814 Verbose => 0,
810815 Config => undef,
811816 Encrypt => undef,
904909
905910 use vars qw(@ISA) ;
906911 @ISA = qw( BerkeleyDB::Common BerkeleyDB::_tiedHash ) ;
907 use UNIVERSAL qw( isa ) ;
912 use UNIVERSAL ;
908913 use Carp ;
909914
910915 sub new
941946 }, @_) ;
942947
943948 croak("Env not of type BerkeleyDB::Env")
944 if defined $got->{Env} and ! isa($got->{Env},'BerkeleyDB::Env');
949 if defined $got->{Env} and ! UNIVERSAL::isa($got->{Env},'BerkeleyDB::Env');
945950
946951 croak("Txn not of type BerkeleyDB::Txn")
947 if defined $got->{Txn} and ! isa($got->{Txn},'BerkeleyDB::Txn');
952 if defined $got->{Txn} and ! UNIVERSAL::isa($got->{Txn},'BerkeleyDB::Txn');
948953
949954 croak("-Tie needs a reference to a hash")
950955 if defined $got->{Tie} and $got->{Tie} !~ /HASH/ ;
969974
970975 use vars qw(@ISA) ;
971976 @ISA = qw( BerkeleyDB::Common BerkeleyDB::_tiedHash ) ;
972 use UNIVERSAL qw( isa ) ;
977 use UNIVERSAL ;
973978 use Carp ;
974979
975980 sub new
10011006 }, @_) ;
10021007
10031008 croak("Env not of type BerkeleyDB::Env")
1004 if defined $got->{Env} and ! isa($got->{Env},'BerkeleyDB::Env');
1009 if defined $got->{Env} and ! UNIVERSAL::isa($got->{Env},'BerkeleyDB::Env');
10051010
10061011 croak("Txn not of type BerkeleyDB::Txn")
1007 if defined $got->{Txn} and ! isa($got->{Txn},'BerkeleyDB::Txn');
1012 if defined $got->{Txn} and ! UNIVERSAL::isa($got->{Txn},'BerkeleyDB::Txn');
10081013
10091014 croak("-Tie needs a reference to a hash")
10101015 if defined $got->{Tie} and $got->{Tie} !~ /HASH/ ;
10461051
10471052 use vars qw(@ISA) ;
10481053 @ISA = qw( BerkeleyDB::Common BerkeleyDB::_tiedArray ) ;
1049 use UNIVERSAL qw( isa ) ;
1054 use UNIVERSAL ;
10501055 use Carp ;
10511056
10521057 sub new
10781083 }, @_) ;
10791084
10801085 croak("Env not of type BerkeleyDB::Env")
1081 if defined $got->{Env} and ! isa($got->{Env},'BerkeleyDB::Env');
1086 if defined $got->{Env} and ! UNIVERSAL::isa($got->{Env},'BerkeleyDB::Env');
10821087
10831088 croak("Txn not of type BerkeleyDB::Txn")
1084 if defined $got->{Txn} and ! isa($got->{Txn},'BerkeleyDB::Txn');
1089 if defined $got->{Txn} and ! UNIVERSAL::isa($got->{Txn},'BerkeleyDB::Txn');
10851090
10861091 croak("Tie needs a reference to an array")
10871092 if defined $got->{Tie} and $got->{Tie} !~ /ARRAY/ ;
11121117
11131118 use vars qw(@ISA) ;
11141119 @ISA = qw( BerkeleyDB::Common BerkeleyDB::_tiedArray ) ;
1115 use UNIVERSAL qw( isa ) ;
1120 use UNIVERSAL ;
11161121 use Carp ;
11171122
11181123 sub new
11431148 }, @_) ;
11441149
11451150 croak("Env not of type BerkeleyDB::Env")
1146 if defined $got->{Env} and ! isa($got->{Env},'BerkeleyDB::Env');
1151 if defined $got->{Env} and ! UNIVERSAL::isa($got->{Env},'BerkeleyDB::Env');
11471152
11481153 croak("Txn not of type BerkeleyDB::Txn")
1149 if defined $got->{Txn} and ! isa($got->{Txn},'BerkeleyDB::Txn');
1154 if defined $got->{Txn} and ! UNIVERSAL::isa($got->{Txn},'BerkeleyDB::Txn');
11501155
11511156 croak("Tie needs a reference to an array")
11521157 if defined $got->{Tie} and $got->{Tie} !~ /ARRAY/ ;
11811186 ##
11821187 ## use vars qw(@ISA) ;
11831188 ## @ISA = qw( BerkeleyDB::Common BerkeleyDB::_tiedArray ) ;
1184 ## use UNIVERSAL qw( isa ) ;
1189 ## use UNIVERSAL ;
11851190 ## use Carp ;
11861191 ##
11871192 ## sub new
12321237
12331238 use vars qw(@ISA) ;
12341239 @ISA = qw( BerkeleyDB::Common BerkeleyDB::_tiedArray ) ;
1235 use UNIVERSAL qw( isa ) ;
1240 use UNIVERSAL ;
12361241 use Carp ;
12371242
12381243 sub new
12581263 }, @_) ;
12591264
12601265 croak("Env not of type BerkeleyDB::Env")
1261 if defined $got->{Env} and ! isa($got->{Env},'BerkeleyDB::Env');
1266 if defined $got->{Env} and ! UNIVERSAL::isa($got->{Env},'BerkeleyDB::Env');
12621267
12631268 croak("Txn not of type BerkeleyDB::Txn")
1264 if defined $got->{Txn} and ! isa($got->{Txn},'BerkeleyDB::Txn');
1269 if defined $got->{Txn} and ! UNIVERSAL::isa($got->{Txn},'BerkeleyDB::Txn');
12651270
12661271 croak("-Tie needs a reference to a hash")
12671272 if defined $got->{Tie} and $got->{Tie} !~ /HASH/ ;
160160 [ -Flags => number, ]
161161 [ -SetFlags => bitmask, ]
162162 [ -LockDetect => number, ]
163 [ -TxMax => number, ]
164 [ -LogConfig => number, ]
165 [ -MaxLockers => number, ]
166 [ -MaxLocks => number, ]
167 [ -MaxObjects => number, ]
163168 [ -SharedMemKey => number, ]
164169 [ -Verbose => boolean, ]
165170 [ -Encrypt => { Password => "string",
216221
217222 If present, this parameter sets the size of the environments shared memory
218223 buffer pool.
224
225 =item -TxMax
226
227 If present, this parameter sets the number of simultaneous
228 transactions that are allowed. Default 100. This default is
229 definitely too low for programs using the MVCC capabilities.
230
231 =item -LogConfig
232
233 If present, this parameter is used to configure log options.
234
235 =item -MaxLockers
236
237 If present, this parameter is used to configure the maximum number of
238 processes doing locking on the database. Default 1000.
239
240 =item -MaxLocks
241
242 If present, this parameter is used to configure the maximum number of
243 locks on the database. Default 1000. This is often lower than required.
244
245 =item -MaxObjects
246
247 If present, this parameter is used to configure the maximum number of
248 locked objects. Default 1000. This is often lower than required.
219249
220250 =item -SharedMemKey
221251
160160 [ -Flags => number, ]
161161 [ -SetFlags => bitmask, ]
162162 [ -LockDetect => number, ]
163 [ -TxMax => number, ]
164 [ -LogConfig => number, ]
165 [ -MaxLockers => number, ]
166 [ -MaxLocks => number, ]
167 [ -MaxObjects => number, ]
163168 [ -SharedMemKey => number, ]
164169 [ -Verbose => boolean, ]
165170 [ -Encrypt => { Password => "string",
216221
217222 If present, this parameter sets the size of the environments shared memory
218223 buffer pool.
224
225 =item -TxMax
226
227 If present, this parameter sets the number of simultaneous
228 transactions that are allowed. Default 100. This default is
229 definitely too low for programs using the MVCC capabilities.
230
231 =item -LogConfig
232
233 If present, this parameter is used to configure log options.
234
235 =item -MaxLockers
236
237 If present, this parameter is used to configure the maximum number of
238 processes doing locking on the database. Default 1000.
239
240 =item -MaxLocks
241
242 If present, this parameter is used to configure the maximum number of
243 locks on the database. Default 1000. This is often lower than required.
244
245 =item -MaxObjects
246
247 If present, this parameter is used to configure the maximum number of
248 locked objects. Default 1000. This is often lower than required.
219249
220250 =item -SharedMemKey
221251
55
66 All comments/suggestions/problems are welcome
77
8 Copyright (c) 1997-2009 Paul Marquess. All rights reserved.
8 Copyright (c) 1997-2010 Paul Marquess. All rights reserved.
99 This program is free software; you can redistribute it and/or
1010 modify it under the same terms as Perl itself.
1111
17161716 {
17171717 SV ** svp;
17181718 svp = hv_fetch(hash, key, strlen(key), FALSE);
1719 if (svp && SvOK(*svp))
1720 return *svp ;
1719
1720 if (svp) {
1721 if (SvGMAGICAL(*svp))
1722 mg_get(*svp);
1723 if (SvOK(*svp))
1724 return *svp;
1725 }
1726
17211727 return NULL ;
17221728 }
17231729
23452351 int setflags = 0 ;
23462352 int cachesize = 0 ;
23472353 int lk_detect = 0 ;
2354 int tx_max = 0 ;
2355 int log_config = 0 ;
2356 int max_lockers = 0 ;
2357 int max_locks = 0 ;
2358 int max_objects = 0 ;
23482359 long shm_key = 0 ;
23492360 char* data_dir = 0;
23502361 char* log_dir = 0;
23672378 SetValue_pv(server, "Server", char *) ;
23682379 SetValue_iv(cachesize, "Cachesize") ;
23692380 SetValue_iv(lk_detect, "LockDetect") ;
2381 SetValue_iv(tx_max, "TxMax") ;
2382 SetValue_iv(log_config,"LogConfig") ;
2383 SetValue_iv(max_lockers,"MaxLockers") ;
2384 SetValue_iv(max_locks, "MaxLocks") ;
2385 SetValue_iv(max_objects,"MaxObjects") ;
23702386 SetValue_iv(shm_key, "SharedMemKey") ;
23712387 SetValue_iv(thread_count, "ThreadCount") ;
23722388 SetValue_pv(data_dir, "DB_DATA_DIR", char*) ;
23832399 if (server)
23842400 softCrash("-Server needs Berkeley DB 3.1 or better") ;
23852401 #endif /* ! AT_LEAST_DB_3_1 */
2402 #ifndef AT_LEAST_DB_3_2
2403 if (max_lockers)
2404 softCrash("-MaxLockers needs Berkeley DB 3.2 or better") ;
2405 if (max_locks)
2406 softCrash("-MaxLocks needs Berkeley DB 3.2 or better") ;
2407 if (max_objects)
2408 softCrash("-MaxObjects needs Berkeley DB 3.2 or better") ;
2409 #endif /* ! AT_LEAST_DB_3_2 */
23862410 #ifndef AT_LEAST_DB_4_1
23872411 if (enc_passwd)
23882412 softCrash("-Encrypt needs Berkeley DB 4.x or better") ;
23992423 if (thread_count)
24002424 softCrash("-ThreadCount needs Berkeley DB 4.4 or better") ;
24012425 #endif /* ! AT_LEAST_DB_4_4 */
2426 #ifndef AT_LEAST_DB_4_7
2427 if (log_config)
2428 softCrash("-LogConfig needs Berkeley DB 4.7 or better") ;
2429 #endif /* ! AT_LEAST_DB_4_7 */
24022430 Trace(("_db_appinit(config=[%d], home=[%s],errprefix=[%s],flags=[%d]\n",
24032431 config, home, errprefix, flags)) ;
24042432 #ifdef TRACE
25092537 Trace(("set_lk_detect [%d] returned %s\n",
25102538 lk_detect, my_db_strerror(status)));
25112539 }
2540
2541 if (status == 0 && tx_max) {
2542 status = env->set_tx_max(env, tx_max) ;
2543 Trace(("set_tx_max [%d] returned %s\n",
2544 tx_max, my_db_strerror(status)));
2545 }
2546 #ifdef AT_LEAST_DB_4_7
2547 if (status == 0 && log_config) {
2548 status = env->log_set_config(env, log_config, 1) ;
2549 Trace(("log_set_config [%d] returned %s\n",
2550 log_config, my_db_strerror(status)));
2551 }
2552 #endif /* AT_LEAST_DB_4_7 */
2553 #ifdef AT_LEAST_DB_3_2
2554 if (status == 0 && max_lockers) {
2555 status = env->set_lk_max_lockers(env, max_lockers) ;
2556 Trace(("set_lk_max_lockers [%d] returned %s\n",
2557 max_lockers, my_db_strerror(status)));
2558 }
2559
2560 if (status == 0 && max_locks) {
2561 status = env->set_lk_max_locks(env, max_locks) ;
2562 Trace(("set_lk_max_locks [%d] returned %s\n",
2563 max_locks, my_db_strerror(status)));
2564 }
2565
2566 if (status == 0 && max_objects) {
2567 status = env->set_lk_max_objects(env, max_objects) ;
2568 Trace(("set_lk_max_objects [%d] returned %s\n",
2569 max_objects, my_db_strerror(status)));
2570 }
2571 #endif /* AT_LEAST_DB_3_2 */
25122572 #ifdef AT_LEAST_DB_4_1
25132573 /* set encryption */
25142574 if (enc_passwd && status == 0)
49314991 RETVAL
49324992
49334993 int
4934 set_tx_max(txn, max)
4935 BerkeleyDB::Txn txn
4994 set_tx_max(env, max)
4995 BerkeleyDB::Env env
49364996 u_int32_t max
49374997 PREINIT:
49384998 dMY_CXT;
49394999 INIT:
4940 ckActive_Transaction(txn->active) ;
5000 ckActive_Database(env->active) ;
49415001 CODE:
49425002 #ifndef AT_LEAST_DB_2_3
49435003 softCrash("$env->set_tx_max needs Berkeley DB 2_3.x or better") ;
49445004 #else
4945 RETVAL = txn->Status = txn->txn->set_tx_max(txn->txn, max);
5005 dieIfEnvOpened(env, "set_tx_max");
5006 RETVAL = env->Status = env->Env->set_tx_max(env->Env, max);
49465007 #endif
49475008 OUTPUT:
49485009 RETVAL
49495010
49505011 int
4951 get_tx_max(txn, max)
4952 BerkeleyDB::Txn txn
5012 get_tx_max(env, max)
5013 BerkeleyDB::Env env
49535014 u_int32_t max = NO_INIT
49545015 PREINIT:
49555016 dMY_CXT;
49565017 INIT:
4957 ckActive_Transaction(txn->active) ;
5018 ckActive_Database(env->active) ;
49585019 CODE:
49595020 #ifndef AT_LEAST_DB_2_3
49605021 softCrash("$env->get_tx_max needs Berkeley DB 2_3.x or better") ;
49615022 #else
4962 RETVAL = txn->Status = txn->txn->get_tx_max(txn->txn, &max);
5023 RETVAL = env->Status = env->Env->get_tx_max(env->Env, &max);
49635024 #endif
49645025 OUTPUT:
49655026 RETVAL
52225283 RETVAL = 0;
52235284 if (seq->active) {
52245285 -- seq->db->open_sequences;
5225 RETVAL = seq->seq->close(seq->seq, flags);
5286 RETVAL = (seq->seq->close)(seq->seq, flags);
52265287 }
52275288 seq->active = FALSE;
52285289 #endif
52575318 CODE:
52585319 #ifdef AT_LEAST_DB_4_3
52595320 if (seq->active)
5260 seq->seq->close(seq->seq, 0);
5321 (seq->seq->close)(seq->seq, 0);
52615322 Safefree(seq);
52625323 #endif
52635324
54145475 (void)db_version(&Major, &Minor, &Patch) ;
54155476 /* Check that the versions of db.h and libdb.a are the same */
54165477 if (Major != DB_VERSION_MAJOR || Minor != DB_VERSION_MINOR
5417 || Patch != DB_VERSION_PATCH)
5478 || Patch != DB_VERSION_PATCH)
54185479 croak("\nBerkeleyDB needs compatible versions of libdb & db.h\n\tyou have db.h version %d.%d.%d and libdb version %d.%d.%d\n",
54195480 DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH,
54205481 Major, Minor, Patch) ;
00 Revision history for Perl extension BerkeleyDB.
1
2 0.41 8th January 2010
3
4 * Silence "UNIVERSAL->import is deprecated" in perl 5.11
5 RT# 53518
6
7 0.40 7th January 2010
8
9 * Added support for set_tx_max, log_set_config, set_lk_max_lockers,
10 set_lk_max_locks, set_lk_max_objects via the Env constructor.
11 Parameter names are TxMax, LogConfig, MaxLockers, MaxLocks &
12 MaxObjects respectively.
13 RT# 50456
14
15 * seq->seq->close doesn't compile on win32.
16 RT# 49474
117
218 0.39 6th June 2009
319
00 --- #YAML:1.0
11 name: BerkeleyDB
2 version: 0.39
2 version: 0.41
33 abstract: Perl extension for Berkeley DB version 2, 3 or 4
44 author:
55 - Paul Marquess <pmqs@cpan.org>
1414 directory:
1515 - t
1616 - inc
17 generated_by: ExtUtils::MakeMaker version 6.52
17 generated_by: ExtUtils::MakeMaker version 6.54
1818 meta-spec:
1919 url: http://module-build.sourceforge.net/META-spec-v1.4.html
2020 version: 1.4
00 BerkeleyDB
11
2 Version 0.39
3
4 6th June 2009
2 Version 0.41
3
4 8th January 2010
55
66
7 Copyright (c) 1997-2009 Paul Marquess. All rights reserved. This
7 Copyright (c) 1997-2010 Paul Marquess. All rights reserved. This
88 program is free software; you can redistribute it and/or modify
99 it under the same terms as Perl itself.
1010