Author: timbo
Date: Thu Mar 4 05:02:50 2004
New Revision: 181
Modified:
dbi/trunk/DBI.pm
dbi/trunk/DBI.xs
dbi/trunk/lib/DBD/DBM.pm
dbi/trunk/t/50dbm.t
Log:
Add dbm_ to driver registry.
Fix handling of Driver DSN attributes
Silence undefs. Thanks to Beau Cox.
Modified: dbi/trunk/DBI.pm
==============================================================================
--- dbi/trunk/DBI.pm (original)
+++ dbi/trunk/DBI.pm Thu Mar 4 05:02:50 2004
@@ -303,6 +303,7 @@
best_ => { class => 'DBD::BestWins', },
csv_ => { class => 'DBD::CSV', },
db2_ => { class => 'DBD::DB2', },
+ dbm_ => { class => 'DBD::DBM', },
dbi_ => { class => 'DBI', },
df_ => { class => 'DBD::DF', },
f_ => { class => 'DBD::File', },
Modified: dbi/trunk/DBI.xs
==============================================================================
--- dbi/trunk/DBI.xs (original)
+++ dbi/trunk/DBI.xs Thu Mar 4 05:02:50 2004
@@ -205,7 +205,6 @@
static void
dbi_bootinit(dbistate_t * parent_dbis)
{
- char *p = Nullch;
INIT_PERINTERP;
Newz(dummy, DBIS, 1, dbistate_t);
Modified: dbi/trunk/lib/DBD/DBM.pm
==============================================================================
--- dbi/trunk/lib/DBD/DBM.pm (original)
+++ dbi/trunk/lib/DBD/DBM.pm Thu Mar 4 05:02:50 2004
@@ -22,6 +22,7 @@
package DBD::DBM;
#################
use DBD::File ();
+use Carp;
use vars qw($VERSION $ATTRIBUTION $methods_already_installed);
use base qw( DBD::File );
$VERSION = '0.01'; # CHANGE THIS !
@@ -79,7 +80,7 @@
#
# the attrs here *must* start with dbm_ or foo_ or f_
#
- $this->{f_valid_attrs} = {
+ $this->{f_valid_attrs} = my $valid_attrs = {
dbm_tables => 1 # per-table information
, dbm_type => 1 # the global DBM type e.g. SDBM_File
, dbm_mldbm => 1 # the global MLDBM serializer
@@ -107,16 +108,16 @@
$var = $1;
($val = $2) =~ s/\\(.)/$1/g;
- # in the connect string the attr names
- # can either have dbm_ (or foo_) prepended or not
- # this will add the prefix if it's missing
- #
- $var = 'dbm_' . $var unless $var =~ /^dbm_/
- or $var eq 'f_dir';
- if (!$this->{f_valid_attrs}->{$var}) {
- die "Invalid attribute in connect: '$var'!\n"
- }
- $this->{$var} = $val;
+ # Add dbm_ prefix to attributes that need it
+ # (attributes for DBD::Foo in the Driver DSN portion
+ # of the DSN string are allowed to skip the "foo_" prefix)
+ $var = 'dbm_' . $var if !$valid_attrs->{$var}
+ && $valid_attrs->{"dbm_$var"};
+
+ # place the attribute in $attr (possibly replacing an exiting value)
+ # so DBI->connect will then call our STORE on it for us.
+ # Our STORE method (inherited from DBD::File's) should validate it
+ $attr->{$var} = $val;
}
}
$this->{f_version} = $DBD::File::VERSION;
Modified: dbi/trunk/t/50dbm.t
==============================================================================
--- dbi/trunk/t/50dbm.t (original)
+++ dbi/trunk/t/50dbm.t Thu Mar 4 05:02:50 2004
@@ -29,10 +29,10 @@
#
printf "\n%s %s\n%s %s\n%s %s\n%s %s\n",
- 'DBD::DBM' , $dbh->{Driver}->{Version}
- , 'DBD::File' , $dbh->{Driver}->{file_version}
- , 'DBI::SQL::Nano' , $dbh->{Driver}->{nano_version}
- , 'SQL::Statement' , $dbh->{Driver}->{statement_version}
+ 'DBD::DBM' , $dbh->{Driver}->{Version} || 'undef'
+ , 'DBD::File' , $dbh->{Driver}->{file_version} || 'undef'
+ , 'DBI::SQL::Nano' , $dbh->{Driver}->{nano_version} || 'undef'
+ , 'SQL::Statement' , $dbh->{Driver}->{statement_version} || 'undef'
;
for my $sql (split /;\s*\n+/,join '',<DATA>) {