Skip Menu |

This queue is for tickets about the BerkeleyDB CPAN distribution.

Report information
The Basics
Id: 12038
Status: resolved
Priority: 0/
Queue: BerkeleyDB

People
Owner: pmqs [...] cpan.org
Requestors: barborak [...] basikgroup.com
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)

Attachments


Subject: request for enhancements to version 0.26
In building my BerkeleyDB application, I have made a few enhancements to the BerkeleyDB Perl module. Perhaps you would consider adding them to the standard package? It would be great for me and perhaps useful for others as well. Thanks, Mike * Support for the panic callback. This is useful in detecting when the environment might need recovery. In the patch, setting the callback is done with an argument to the new method of the BerkeleyDB::Env package. Then in the XS file when the environment is opened, the callback is stored in the BerkeleyDB_ENV_type data structure and the BerkeleyDB API DB_ENV->set_paniccall is called to register the new function env_paniccall as the panic callback. Also, in the environment's app_private variable (provided by the BerekeleyDB API to store application-specific data along with it's data structure) is stored a pointer to the Perl BerkeleyDB environment object. So on a database panic, env_paniccall is called. It pushes a pointer to the Perl BerkeleyDB environment object (from the app_private variable) and the error value on to the stack. It then calls the registered Perl callback. To use the callback feature then, you first open the environment someway like this: $dbEnv = BerkeleyDB::Env->new ( ... -PanicCall => \&panicCall ); where panicCall is defined perhaps like this: sub panicCall { my $dbEnv = shift; my $errVal = shift; my $envSettings = $dbEnv->get_settings ( ); my $dbEnvPath = $envSettings->{ home }; my $dbLock = synchronizeDB ( undef, $dbEnvPath ); # One process at a time. setRecoveryFlag ( $dbEnvPath, $dbInRecovery ? 2 : 1 ); synchronizeDB ( $dbLock, $dbEnvPath ) if $dbLock; exit ( 1 ); } * New method to get the settings of an environment. When dealing with multiple environments at once, it is necessary to have a way to differentiate one from another via an environment pointer. For example, in the panicCall callback in the example above, it is necessary to be able to retrieve some settings about the environment in order to know in which one the database panic occurred. To support that there is a new method defined in the BerkeleyDB::Env package in BerkeleyDB.xs called get_settings. It returns a hash reference with the home path of the environment (with key "home") and the flags (with key "flags") used when opening the environment. To support this method there is a new helper function call hv_store_pv. (This function is really just the BerkeleyDB APIs DB_ENV->get_home and DB_ENV->get_open_flags rolled up into one. In hindsight, I would have simply added these two methods rather than inventing this new one.) * Support for setting environment and transaction timeouts. To avoid deadlocks from tying up the system, it is useful to have the DB_ENV->set_timeout and DB_TXN->set_timeout APIs. Two new methods were added to the BerkeleyDB::Env package in BerkeleyDB.xs to support this. * Support ability to remove an environment. To be able to delete an environment, it is useful to have the DB_ENV->remove API. A new method was added to the BerkeleyDB::Env package in BerkeleyDB.xs to support this.
Download patches.tar.gz
application/x-gzip 1.9k

Message body not shown because it is not plain text.

Hi Mike, many thanks for the patch. I'm a bit snowed under with (real) work at the moment, but once I get a chance to review what you've sent me I will certainly merge your changes into my development copy. Whether the inferface you picked for each of your changes remains exactly the same once I've merged it remains to be seen -- the important thing is that the the new features will be available. One thing I'll probably do is drop your get_settings in favour of providing an interface to get_home and get_open_flags as you suggest yourself. cheers and thanks again Paul
I hear you about being snowed under and appreciate the serious amount of time you've obviously put into this module. Along the lines of enhancements, I have another selfish request for a rather obscure API. This time, it's for lsn_reset. My desire for it is based on the advice given by Keith Bostic in this thread: http://groups-beta.google.com/group/comp.databases.berkeley-db/browse_thread/thread/13a3ec4f3afa28b2/6658ed4eb06589a3#6658ed4eb06589a3 If you're interested, this is the code I added to the BerkeleyDB::Env module of BerkeleyDB.xs version 0.26 to support this API: int lsn_reset(env, file, flags) BerkeleyDB::Env env char * file u_int32_t flags INIT: ckActive_Environment(env->active) ; CODE: { #ifndef AT_LEAST_DB_4_3 softCrash("$env->lsn_reset needs Berkeley DB 4.3 or better") ; #else RETVAL = env->Status = env->Env->lsn_reset(env->Env, file, flags); #endif } OUTPUT: RETVAL Note that Keith's documentation for this API calls for the file parameter to be a const char * (which seems right) but db.h has it as just a char *. Thanks again! Mike
Hi Mike, thanks for the patch. Once the snow melts a bit, I will add this to my development copy. cheers Paul [guest - Fri May 13 14:19:22 2005]: Show quoted text
> I hear you about being snowed under and appreciate the serious amount > of > time you've obviously put into this module. Along the lines of > enhancements, I have another selfish request for a rather obscure API. > This time, it's for lsn_reset. My desire for it is based on the advice > given by Keith Bostic in this thread: > > http://groups-beta.google.com/group/comp.databases.berkeley- >
db/browse_thread/thread/13a3ec4f3afa28b2/6658ed4eb06589a3#6658ed4eb06589 a3 Show quoted text
> > If you're interested, this is the code I added to the BerkeleyDB::Env > module of BerkeleyDB.xs version 0.26 to support this API: > > int > lsn_reset(env, file, flags) > BerkeleyDB::Env env > char * file > u_int32_t flags > INIT: > ckActive_Environment(env->active) ; > CODE: > { > #ifndef AT_LEAST_DB_4_3 > softCrash("$env->lsn_reset needs Berkeley DB 4.3 or
better") ; Show quoted text
> #else > RETVAL = env->Status = env->Env->lsn_reset(env->Env,
file, flags); Show quoted text
> #endif > } > OUTPUT: > RETVAL > > Note that Keith's documentation for this API calls for the file > parameter to be a const char * (which seems right) but db.h has it as > just a char *. > > Thanks again! > Mike