The following simple tests show something changed from 1.15 to 1.19 when it
comes to inheriting and ultimately subclassing the DBI.  Can anyone help me
see what it is?

This simple script works fine with our new Perl 5.6.1 and DBI 1.19 install,
thus I know that our sysadmin put everything in correctly:

dbi.new.pl
-----------------------------------------------
#!/home/local/perl/bin/perl -w
use diagnostics;
use strict;
use DBI;

my $dbh =
DBI->connect('dbi:Oracle:BLAH.world','scott','tiger',{RaiseError=>1})
  or die;
my $foo = $dbh->quote('foo');
my $sth = $dbh->prepare("SELECT $foo  FROM dual");
$sth->execute;
$foo = $sth->fetchrow_array;
print $foo, "\n";
$sth->finish;
$dbh->disconnect;
-----------------------------------------------

Also, the following test script regarding inheritence works fine under the
new Perl as under the old, so Perl 5.6.1 doesn't seem the culprit:
-----------------------------------------------
#!/home/local/perl/bin/perl -w

package AAA;
sub foo {
    my $proto = shift;
    my $class = ref($proto) || $proto;
    my $self = {};
    bless ($self,$class);
    return $self;
}

package BBB;
use base AAA;
sub new {
    my $proto = shift;
    my $class = ref($proto) || $proto;
    my $b = $class->foo;
}

package CCC;
use base BBB;
sub new {
    my $proto = shift;
    my $class = ref($proto) || $proto;
    my $c = $class->foo;
}

package main;
print 'a: ', AAA->foo, "\n";
print 'b: ', BBB->new, "\n";
print 'c: ', CCC->new, "\n";
-----------------------------------------------


Nonetheless, the following simple subclass module and script fail:  [STDERR
follows scripts]

DBI_SUBCLASS.pm
-----------------------------------------------
package DBI_SUBCLASS;
use base 'DBI';

package DBI_SUBCLASS::db;
use base 'DBI::db';

package DBI_SUBCLASS::st;
use base 'DBI::st';

1;
-----------------------------------------------

dbi_subclass.new.pl
-----------------------------------------------
#!/home/local/perl/bin/perl -w
use diagnostics;
use lib './';
use DBI_SUBCLASS;
-----------------------------------------------

STDERR:
Uncaught exception from user code:
        Uncaught exception from user code:
        Uncaught exception from user code:
        Uncaught exception from user code:
        Uncaught exception from user code:
        Can't locate DBI/db.pm in @INC (@INC contains:
          ./ /home/local/perl/lib/5.6.1/aix
          /home/local/perl/lib/5.6.1
          /home/local/perl/lib/site_perl/5.6.1/aix
          /home/local/perl/lib/site_perl/5.6.1
          /home/local/perl/lib/site_perl
        .) at (eval 3) line 3.
        eval 'require DBI::db;' called at
          /home/local/perl/lib/5.6.1/base.pm line 59
        base::import('base', 'DBI::db') called at
          /DBI_SUBCLASS.pm line 5
        DBI_SUBCLASS::db::BEGIN() called at
          DBI/db.pm line 0
        eval {...} called at DBI/db.pm line 0
        require DBI_SUBCLASS.pm called at
          ./dbi_subclass.new.pl line 4
        main::BEGIN() called at DBI/db.pm line 0
        eval {...} called at DBI/db.pm line 0
        ...propagated at
          /home/local/perl/lib/5.6.1/base.pm line 62.
        base::import('base', 'DBI::db')
          called at /DBI_SUBCLASS.pm line 5
        DBI_SUBCLASS::db::BEGIN()
          called at /DBI_SUBCLASS.pm line 5
        eval {...} called at /DBI_SUBCLASS.pm line 5
        require DBI_SUBCLASS.pm
          called at ./dbi_subclass.new.pl line 4
        main::BEGIN() called at /DBI_SUBCLASS.pm line 5
        eval {...} called at /DBI_SUBCLASS.pm line 5
BEGIN failed--compilation aborted at
  /DBI_SUBCLASS.pm line 5.
        require DBI_SUBCLASS.pm called at
          ./dbi_subclass.new.pl line 4
        main::BEGIN() called at /DBI_SUBCLASS.pm line 5
        eval {...} called at /DBI_SUBCLASS.pm line 5
Compilation failed in require at
  ./dbi_subclass.new.pl line 4.
        main::BEGIN() called at /DBI_SUBCLASS.pm line 4
        eval {...} called at /DBI_SUBCLASS.pm line 4
BEGIN failed--compilation aborted at
  ./dbi_subclass.new.pl line 4.


if I switch the shebang in the script to point at our Perl 5.004 and DBI 1.15
install it produces no STDERR, i.e. everything is fine!

dbi_subclass.old.pl
-----------------------------------------------
#!/usr/local/bin/perl -w
use diagnostics;
use lib './';
use DBI_SUBCLASS;
-----------------------------------------------


Does anyone spot what I'm missing?

Phil R Lawrence

Reply via email to