Date: | Wed, 22 Dec 2004 05:02:28 -0500 |
From: | Jim Mahoney <mahoney [...] marlboro.edu> |
To: | tony [...] tmtm.com |
Subject: | "use uninitialized value" warning in DBIx-ContextualFetch 1.01 |
Hi.
Just dropping a note about a problem I had this week with
DBIx::ContextualFetch-1.01, since you're listed as the
maintainer.
I'm using
perl 5.8.6
Class::DBI 0.96
Class::DBI::SQLite 0.06
DBD::SQLite 1.07
on a linux box.
I create a simple table
CREATE TABLE sessions (
id INTEGER PRIMARY KEY,
a_session TEXT
);
which has an autoincrementing id, as described
in the SQLite documentation.
Here's the code I was testing it with.
package Data;
use base 'Class::DBI::SQLite';
__PACKAGE__->set_db('Main', "dbi:SQLite:dbname=$database" );
package Session;
use base 'Data';
__PACKAGE__->set_up_table('sessions');
package main;
my $session = Session->create( { a_session=>'testing '.rand() } );
print " session id is '" . $session->id . "'\n";
print " session text is '" . $session->a_session . "'\n";
If I add id=>100 in the create({}) hash, it runs without errors.
As shown above, or with id=>undef, it seems to work OK
but produces the following warning :
Use of uninitialized value in subroutine entry at
.../lib/perl5/site_perl/5.8.6/DBIx/ContextualFetch.pm line 51.
Use of uninitialized value in subroutine entry at
.../lib/perl5/site_perl/5.8.6/DBIx/ContextualFetch.pm line 51.
session id is '102'
session text is 'testing 0.826044933012785'
Of course the undefined id here imples a SQL NULL value
which tells the engine to autoincrement that value.
That line which is given in the error is in ContextualFetch,
within this routine
# local $sth->{Taint} leaks in old perls :(
sub _untaint_execute {
my $sth = shift;
my $old_value = $sth->{Taint};
$sth->{Taint} = 0;
my $ret = $sth->SUPER::execute(@_); # <<< line 51
$sth->{Taint} = $old_value;
return $ret;
}
and I find that I can turn off the error messages by
changing "use warnings" to "no warnings" in that module.
I haven't investigated further; just figured I'd pass along my experience.
Regards,
Jim Mahoney
Marlboro College
mahoney@marlboro.edu