On Fri, 15 May 2009 17:30:44 +0200, "H.Merijn Brand"
<[email protected]> wrote:
> How strict should handler attributes be checked?
> Isn't barfing on fetchrow_hashref () not a tad bit too late in below
> described situation?
>
> /tmp > cat test.pl
> #!/pro/bin/perl
>
> use strict;
> use warnings;
>
> use DBI;
> use Data::Peek;
>
> my ($dsn, $fhkn) = @ARGV;
>
> my $dbh = DBI->connect ($dsn, $ENV{DBI_USER}, $ENV{DBI_PASS}, {
> FetchHashKeyName => $fhkn,
> PrintError => 1,
> RaiseError => 1,
> }) or die $DBI::errstr;
>
> my $sth = $dbh->prepare ("select * from test");
> $sth->execute;
> DDumper $sth->fetchrow_hashref;
> /tmp >
>
> /tmp > perl test.pl dbi:Pg: NAME_lc
> $VAR1 = {
> c_test => '1',
> test => 'test'
> };
> /tmp > perl test.pl dbi:Pg: NAME_uc
> $VAR1 = {
> C_TEST => '1',
> TEST => 'test'
> };
> /tmp > perl test.pl dbi:Pg: NAME
> $VAR1 = {
> c_test => '1',
> test => 'test'
> };
> /tmp > perl test.pl dbi:Pg: 1
> DBD::Pg::st fetchrow_hashref failed: Can't use attribute '1' because it
> doesn't contain a reference to an array (undef) at test.pl line 19.
> DBD::Pg::st fetchrow_hashref failed: Can't use attribute '1' because it
> doesn't contain a reference to an array (undef) at test.pl line 19.
> Exit 255
> /tmp >
>
>
> /tmp > perl test.pl dbi:CSV: NAME_lc
> $VAR1 = {
> c_test => '1',
> test => 'test'
> };
> /tmp > perl test.pl dbi:CSV: NAME_uc
> $VAR1 = {
> C_TEST => '1',
> TEST => 'test'
> };
> /tmp > perl test.pl dbi:CSV: NAME
> $VAR1 = {
> c_test => '1',
> test => 'test'
> };
> /tmp > perl test.pl dbi:CSV: 1
> DBD::CSV::st fetchrow_hashref failed: Can't use attribute '1' because it
> doesn't contain a reference to an array (undef) [for Statement "select * from
> test"] at test.pl line 19.
> DBD::CSV::st fetchrow_hashref failed: Can't use attribute '1' because it
> doesn't contain a reference to an array (undef) [for Statement "select * from
> test"] at test.pl line 19.
> Exit 255
> /tmp >
It is obviously just any of the known statement handle attributes.
I suggest to make it barf early
/tmp > perl test.pl dbi:CSV: TYPE
Use of uninitialized value in subroutine entry at test.pl line 19.
Use of uninitialized value in subroutine entry at test.pl line 19.
$VAR1 = {
=> 'test'
};
/tmp > perl test.pl dbi:CSV: PRECISION
Use of uninitialized value in subroutine entry at test.pl line 19.
Use of uninitialized value in subroutine entry at test.pl line 19.
$VAR1 = {
=> 'test'
};
I'm willing to patch DBI if people agree on this
--
H.Merijn Brand http://tux.nl Perl Monger http://amsterdam.pm.org/
using & porting perl 5.6.2, 5.8.x, 5.10.x, 5.11.x on HP-UX 10.20, 11.00,
11.11, 11.23, and 11.31, OpenSuSE 10.3, 11.0, and 11.1, AIX 5.2 and 5.3.
http://mirrors.develooper.com/hpux/ http://www.test-smoke.org/
http://qa.perl.org http://www.goldmark.org/jeff/stupid-disclaimers/