PgSQL/Cursor.pm

filter: Statementstmt 12.5% 8 / 64 Branchbran 0.0% 0 / 18 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 15.3% 2 / 13 Podpod 0.0% 0 / 11 totaltotal 8.4% 10 / 119 CC 14 SCAR 32.7
CC
14
Cov
9%
exec
72.0
new
12.0
fetch
12.0
CRAP 26.4
« PgSQL.pm ↑ Summary test1.pl »
1 package PgSQL::Cursor;
2  
3 # This perl module is Copyright (c) 1998 Göran Thyni, Sweden.
4 # All rights reserved.
5 # You may distribute under the terms of either
6 # the GNU General Public License version 2 (or later)
7 # or the Artistic License, as specified in the Perl README file.
8 #
9 # $Id: Cursor.pm,v 1.5 1998/08/15 15:09:49 goran Exp $
10  
11  
12 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 1 $VERSION = '0.51';
17  
18  
19 sub new
20 0 ▶ {
Subroutine new: not called CC=3 SCAR=24.8
Pod undocumented
21 0 my ($class,$socket,$name,$query) = @_;
22 0 my $self = {};
23 0 bless $self,$class;
24 0 $self->{SOCKET} = $socket;
25 0 ▶ $self->{NAME} = $name if $name;
Branch: 1 branch
BranchTrueFalseTotal
if $name 0 0 0
26 0 ▶ $self->{QUERY} = $query if $query;
Branch: 1 branch
BranchTrueFalseTotal
if $query 0 0 0
27 0 $self;
28 }
29  
30 sub exec
31 0 ▶ {
Subroutine exec: not called CC=8 SCAR=42.8
Pod undocumented
32 0 my ($self, @params) = @_;
33 0 my $sock = $self->{SOCKET};
34 0 my $query = $self->{QUERY};
35 0 my $is_select = $query =~ /^\s*select\s/i;
36 0 my $complete = 0;
37 0 $sock->errmsg(0);
38 0 $sock->flush_input;
39 0 for (@params) { $query =~ s/\?/'$_'/; }
40 0 ▶ return 0 if !$sock->sendQuery($query);
Branch: 1 branch
BranchTrueFalseTotal
unless $sock->sendQuery($query) 0 0 0
41 0 $sock->wait(1,0);
42 0 my $lastResult = undef;
43 0 while (1)
44 {
45 0 my ($result, @rest) = $sock->parseInput;
46 # print STDERR "exec: $result\n" if $result;
47 0 ▶ $complete++ if $result eq 'C' or $result eq 'I';
Branch: 1 branch
BranchTrueFalseTotal
if $result eq "C" or $result eq "I" 0 0 0
Condition0%0/3
$result eq "C" or $result eq "I"
l!l&&r!l&&!r
000
MC/DC0%0/2
$result eq "C" or $result eq "I"
$result eq "C" $result eq "I"
Truth table0%0/3
A or B
A= $result eq "C"B= $result eq "I"
ABresult
1X1
011
000
48 0 ▶ last if $complete and $result eq 'Z';
Branch: 1 branch
BranchTrueFalseTotal
if $complete and $result eq "Z" 0 0 0
Condition0%0/3
$complete and $result eq "Z"
!ll&&!rl&&r
000
MC/DC0%0/2
$complete and $result eq "Z"
$complete $result eq "Z"
Truth table0%0/3
A and B
A= $completeB= $result eq "Z"
ABresult
0X0
100
111
49 0 $lastResult = $result;
50 # last if ($result == PGRES_COPY_IN || $result == PGRES_COPY_OUT);
51 }
52 0 my $err = $sock->errmsg;
53 0 ▶ return $err ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
$err ? : 0 0 0
54 }
55
56 sub execute
57 0 ▶ {
Subroutine execute: not called CC=1 SCAR=6.9
Pod undocumented
58 0 shift->exec(@_);
59 }
60  
61 sub nfields
62 0 ▶ {
Subroutine nfields: not called CC=2 SCAR=17.9
Pod undocumented
63 0 my ($self,$val) = @_;
64 0 ▶ $self->{NFIELDS} = $val if defined $val;
Branch: 1 branch
BranchTrueFalseTotal
if defined $val 0 0 0
65 0 $self->{NFIELDS};
66 }
67  
68 sub fields
69 0 ▶ {
Subroutine fields: not called CC=2 SCAR=17.9
Pod undocumented
70 0 my ($self,$val) = @_;
71 0 ▶ $self->{FIELDS} = $val if defined $val;
Branch: 1 branch
BranchTrueFalseTotal
if defined $val 0 0 0
72 0 $self->{NTUPLES} = 0;
73 0 $self->{COUNT} = 0;
74 0 $self->{FIELDS};
75 }
76  
77 sub add
78 0 ▶ {
Subroutine add: not called CC=1 SCAR=6.9
Pod undocumented
79 0 my ($self,$tuple) = @_;
80 0 $self->{NTUPLES}++;
81 0 push @{$self->{TUPLES}}, $tuple;
82 }
83  
84 sub fetch
85 0 ▶ {
Subroutine fetch: not called CC=3 SCAR=24.8
Pod undocumented
86 0 my $self = shift;
87 0 my $aref = $self->{TUPLES};
88 0 my $count = \$self->{COUNT};
89 0 ▶ $$count ||= 0;
Condition0%0/2
$$count ||= 0
l!l
00
MC/DC0%0/1
$$count ||= 0
$$count
Truth table0%0/2
A
A= $$count
Aresult
11
00
90 0 ▶ return 0 unless $$count < $self->{NTUPLES};
Branch: 1 branch
BranchTrueFalseTotal
unless $$count < $self->{"NTUPLES"} 0 0 0
91 0 return $aref->[$$count++];
92 }
93  
94 sub finish
95 0 ▶ {
Subroutine finish: not called CC=1 SCAR=6.9
Pod undocumented
96 0 my $self = shift;
97 0 $self->fields;
98 0 $self->{NFIELDS} = $self->{NTUPLES} = 0;
99 0 delete $self->{TUPLES};
100 0 1;
101 }
102  
103 sub bind_param
104 0 ▶ {
Subroutine bind_param: not called CC=1 SCAR=6.9
Pod undocumented
105 0 my $self = shift;
106 0 0; # dummy
107 }
108  
109 sub bind_columns
110 0 ▶ {
Subroutine bind_columns: not called CC=1 SCAR=6.9
Pod undocumented
111 0 my $self = shift;
112 0 0; # dummy
113 }
114  
115 sub rows
116 0 ▶ {
Subroutine rows: not called CC=1 SCAR=6.9
Pod undocumented
117 0 my $self = shift;
118 0 $self->{NTUPLES};
119 }
120  
121 1 1;
122  
123  
« PgSQL.pm ↑ Summary test1.pl »