File Coverage

blib/lib/ResourcePool/Command/DBI/SelectRow.pm
Criterion Covered Total %
statement 18 37 48.6
branch 0 4 0.0
condition 0 6 0.0
subroutine 6 7 85.7
pod 1 1 100.0
total 25 55 45.4


line stmt bran cond sub pod time code
1             #*********************************************************************
2             #*** lib/ResourcePool/Command/DBI/SelectRow.pm
3             #*** Copyright (c) 2004 by Markus Winand
4             #*** $Id: SelectRow.pm,v 1.3 2004/05/02 07:48:55 mws Exp $
5             #*********************************************************************
6             package ResourcePool::Command::DBI::SelectRow;
7              
8 1     1   561 use ResourcePool::Command;
  1         2  
  1         38  
9 1     1   6 use ResourcePool::Command::NoFailoverException;
  1         2  
  1         19  
10 1     1   5 use ResourcePool::Command::DBI::Select;
  1         2  
  1         18  
11 1     1   5 use strict;
  1         1  
  1         32  
12 1     1   10 use DBI;
  1         2  
  1         33  
13 1     1   5 use vars qw(@ISA $VERSION);
  1         1  
  1         313  
14              
15             $VERSION = "1.0101";
16             push @ISA, qw(ResourcePool::Command::DBI::Select);
17              
18             sub execute($$@) {
19 0     0 1   my ($self, $dbh, @args) = @_;
20            
21 0           my $sth = $self->SUPER::execute($dbh, @args);
22              
23 0           my (@ret, $rc);
24 0           eval {
25 0           @ret = $sth->fetchrow_array();
26 0           $rc = $sth->err;
27             };
28 0           my $ex = $@;
29 0           my $rcstr = $sth->errstr;
30              
31 0           eval {
32 0           $sth->finish();
33             }; # irgnore errors
34              
35 0 0 0       if ((! $rc) && (! $ex)) {
36 0           return (@ret); # this list might be empty
37             } else {
38             # test if failover should occure
39 0           my $rc2;
40 0           eval {
41 0           $rc2 = $dbh->ping();
42             };
43 0           my $sql = $self->getSQLfromargs(\@args);
44 0 0 0       if ($rc2 && !$@) {
45 0           die ref($self) . ': Execution of "' . $sql . '" failed: ' . $ex . "(" . $rc . ")\n";
46             } else {
47 0           die ResourcePool::Command::NoFailoverException->new(
48             ref($self) . ': Execution of "' . $sql . '" failed: ' . $ex . "(" . $rc . ")\n"
49             );
50             }
51             }
52             }
53              
54              
55             1;