Informix/Introspect/Util.pm

filter: Statementstmt 100% 38 / 38 Branchbran 87.5% 7 / 8 Conditioncond 60.0% 3 / 5 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 100% 9 / 9 Podpod 100% 4 / 4 totaltotal 92.5% 62 / 67 CC 8 SCAR 8.8
CC
8
Cov
94%
qualifier
4.1
part_columns
3.0
names_for
2.0
CRAP 2.4
« Informix/Introspect/UniqueConstraints.pm ↑ Summary Informix/Diff.pm »
1 package DBIO::Informix::Introspect::Util;
2 # ABSTRACT: Shared helpers of the Informix catalog readers
3  
4 22 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 22 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 22 our $VERSION = '0.900007';
8  
9 22 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11  
12  
13 11 ▶sub qualifier {
Subroutine qualifier: called CC=4 SCAR=14.2
Pod documented
14 11 my ($schema) = @_;
15 11 ▶ Carp::croak('Informix introspection: invalid schema name '
Branch: 2 branches
BranchTrueFalseTotal
unless defined $schema and $schema =~ /\A\w+\z/ 4 7 11
defined $schema ? : 4 0 4
Condition66%2/3
defined $schema and $schema =~ /\A\w+\z/
!ll&&!rl&&r
047
MC/DC50%1/2
defined $schema and $schema =~ /\A\w+\z/
defined $schema $schema =~ /\A\w+\z/
Truth table66%2/3
A and B
A= defined $schemaB= $schema =~ /\A\w+\z/
ABresult
0X0
100
111
16 . (defined $schema ? "'$schema'" : '(undef)') . ' (expected \w+)')
17 unless defined $schema && $schema =~ /\A\w+\z/;
18 7 return qq{"$schema":informix};
19 }
20  
21  
22 6 ▶sub part_columns {
Subroutine part_columns: called CC=3 SCAR=11.0
Pod documented
23 6 my ($row, $prefix) = @_;
24 6 my @colnos;
25 6 for my $n (1 .. 16) {
26 96 my $part = $row->{"$prefix$n"};
27 96 ▶ next unless $part;
Branch: 1 branch
BranchTrueFalseTotal
unless $part 88 8 96
28 8 push @colnos, abs($part);
29 }
30 6 return @colnos;
31 }
32  
33  
34 3 ▶sub column_names {
Subroutine column_names: called CC=2 SCAR=6.9
Pod documented
35 3 my ($dbh, $q, $tabid) = @_;
36 3 my $sth = $dbh->prepare(
37 "SELECT colno, colname FROM $q.syscolumns WHERE tabid = ?"
38 );
39 3 $sth->execute($tabid);
40 3 my %names;
41 3 ▶ while (my $row = $sth->fetchrow_hashref) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $row = $sth->fetchrow_hashref) 12 3 15
42 12 $names{ $row->{colno} } = $row->{colname};
43 }
44 3 $sth->finish;
45 3 return \%names;
46 }
47  
48  
49 4 ▶sub names_for {
Subroutine names_for: called CC=2 SCAR=7.1
Pod documented
50 4 my ($names, @colnos) = @_;
51 return map {
52 4 ▶ $names->{$_} // Carp::croak("Informix introspection: no column number $_ in syscolumns")
Condition50%1/2
$names->{$_} // Carp::croak("Informix introspection: no column number $_ in syscolumns")
l!l
50
MC/DC0%0/1
$names->{$_} // Carp::croak("Informix introspection: no column number $_ in syscolumns")
$names->{$_}
Truth table50%1/2
A
A= $names->{$_}
Aresult
11
00
53 } @colnos;
54 }
55  
56 22 my $parts = join ', ', map { "i.part$_" } 1 .. 16;
57 22 my $rparts = join ', ', map { "ri.part$_ AS rpart$_" } 1 .. 16;
58 5 ▶sub _parts_sql { $parts }
Subroutine _parts_sql: called CC=1 SCAR=0.0
59 1 ▶sub _rparts_sql { $rparts }
Subroutine _rparts_sql: called CC=1 SCAR=0.0
60  
61 22 1;
62  
63 __END__
« Informix/Introspect/UniqueConstraints.pm ↑ Summary Informix/Diff.pm »