[Dbix-class] Last stable version of DBIx::Class and DB2 V9.1

Andreas Mock andreas.mock at drumedar.de
Tue Feb 3 07:54:59 GMT 2009


Hi Peter,

> -----Ursprüngliche Nachricht-----
> Von: "Peter Rabbitson" <rabbit+dbic at rabbit.us>
> Gesendet: 02.02.09 21:41:21
> An: DBIx::Class user and developer list <dbix-class at lists.scsys.co.uk>
> Betreff: Re: [Dbix-class] Last stable version of DBIx::Class and DB2 V9.1

>
> Sorry for the late reply.

No problem. I'm thankful to get an answer.

> The ability to pass connection attributes in db handle
> calls seems to be DBD dependent, and does not seem to be implemented by DB2.

I'm pretty sure I have to disagree with you. I just made a little program to test
what you said. But my test program gives me the feeling that dynamically changing
the connect attributes via db handle works pretty well. See below for source.

> any case the test is now fixed[1], and will get into the next official maintenance
> release (which *fingercross* should happen in a week or so). The second part of
> your question is fixed too[2]. In any case 08010 is still fine to use, all failing
> tests are due to defficiences in the tests themselves, not problems with the dbic
> library.

That is really something you have to think about. When I download, compile AND test
such a big library/module and I'm willing to learn the functionality I want to feel
confident at least by working tests. Tests which work wrong are much worse than
no tests at all.

You can see by my very first posts to the mailing list that I really don't feel confident
at the moment. It's a big decision to replace a core functionality like database access
by a big package as DBIC is. So the errors in the tests caused an "Ooohhhh" with me. :-))

I'm willing to help you to get the tests for DB2 correct as I do have the appropriate
software at the moment.

So, please check the issue with "RaiseError" and "PrintError" in the current implementation.
There must be something wrong as soon as "$dbh" is exactly the db handle of the underlying
database connection. DBD::DB2 does honor dynamically set connection attributes.
(See source below, change database name, user and password).

Thank you in advance
Andreas

---------------------------------8<---------------------------------------------------------------------------------
#!/usr/bin/perl
use strict;
use warnings;

use DBI;
use Data::Dumper;

my $username = 'user';
my $auth = 'password';
my $dbname = 'something';


my %attr = (
'RaiseError' => 0,
'PrintError' => 0,
);
my $statement = "";
my $dbh = DBI->connect("dbi:DB2:$dbname", $username, $auth, \%attr);
# Should work anyway
print "INFO: Should work\n";
$statement = q|select 1 from sysibm.sysdummy1|;
my $ary_ref = $dbh->selectall_arrayref($statement);
print Dumper($ary_ref), "\n";

# Should NOT Work
print "INFO: Should NOT work\n";
$statement = q|select blabla from sysibm.sysdummy1|;
$ary_ref = $dbh->selectall_arrayref($statement);
unless(defined($ary_ref)) {
print "ERROR: An error occured: ".$dbh->errstr."\n";
}
print Dumper($ary_ref), "\n";

# Now turn on raising and printing erros via db-handle
print "INFO: Should NOT work and RAISE exception\n";
$dbh->{'RaiseError'} = 1;
$dbh->{'PrintError'} = 1;
$statement = q|drop table is_really_not_here|;
my $rv = undef;
$rv = $dbh->do($statement);

print "ERROR: If you see this something went wrong.\n";
$dbh->disconnect;



More information about the DBIx-Class mailing list