| 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
Condition66%2/3
defined $schema and $schema =~ /\A\w+\z/
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/
| |||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||
| 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")
MC/DC0%0/1
$names->{$_} // Carp::croak("Informix introspection: no column number $_ in syscolumns")
$names->{$_}
Truth table50%1/2
A
A= $names->{$_}
| |||||||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||||||