blib/lib/DBIO/PostgreSQL/Introspect/OutsideReaders.pm

filter: Statementstmt 40.7% 11 / 27 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 75.0% 3 / 4 Podpod 100% 1 / 1 totaltotal 35.7% 15 / 42 CC 5 SCAR 29.5
CC
5
Cov
32%
fetch
30.0
BEGIN
1.0
BEGIN
1.0
CRAP 19.1
« blib/lib/DBIO/PostgreSQL/Diff/Index.pm ↑ Summary blib/lib/DBIO/PostgreSQL/Diff/Type.pm »
1 package DBIO::PostgreSQL::Introspect::OutsideReaders;
2 # ABSTRACT: Introspect the views outside the schema filter that read columns inside it
3  
4 171 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 171 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 171 our $VERSION = '0.900007';
8  
9 171 ▶use DBIO::PostgreSQL::Introspect ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11  
12  
13 0 ▶sub fetch {
Subroutine fetch: not called CC=5 SCAR=34.0
Pod documented
14 0 my ($class, $dbh, $filter) = @_;
15 0 ▶ return {} unless $filter && @$filter;
Branch: 1 branch
BranchTrueFalseTotal
unless $filter and @$filter 0 0 0
Condition0%0/3
$filter and @$filter
!ll&&!rl&&r
000
MC/DC0%0/2
$filter and @$filter
$filter @$filter
Truth table0%0/3
A and B
A= $filterB= @$filter
ABresult
0X0
100
111
16  
17 0 my $sql = q{
18 SELECT DISTINCT
19 n.nspname AS schema_name,
20 c.relname AS table_name,
21 c.relkind AS kind,
22 rn.nspname AS ref_schema,
23 r.relname AS ref_name,
24 a.attname AS ref_column
25 FROM pg_catalog.pg_rewrite rw
26 JOIN pg_catalog.pg_class c ON c.oid = rw.ev_class
27 JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
28 JOIN pg_catalog.pg_depend d
29 ON d.classid = 'pg_catalog.pg_rewrite'::pg_catalog.regclass
30 AND d.objid = rw.oid
31 AND d.refclassid = 'pg_catalog.pg_class'::pg_catalog.regclass
32 AND d.refobjsubid > 0
33 JOIN pg_catalog.pg_class r ON r.oid = d.refobjid AND r.oid <> c.oid
34 JOIN pg_catalog.pg_namespace rn ON rn.oid = r.relnamespace
35 JOIN pg_catalog.pg_attribute a ON a.attrelid = d.refobjid AND a.attnum = d.refobjsubid
36 WHERE c.relkind IN ('v', 'm')
37 AND rn.nspname = ANY($1)
38 AND NOT (n.nspname = ANY($1))
39 };
40 0 $sql .= DBIO::PostgreSQL::Introspect->system_schema_filter('n');
41 0 $sql .= DBIO::PostgreSQL::Introspect->extension_member_filter('pg_class', 'c.oid');
42 0 $sql .= ' ORDER BY n.nspname, c.relname, rn.nspname, r.relname, a.attname';
43  
44 0 my $rows = $dbh->selectall_arrayref($sql, { Slice => {} }, $filter);
45  
46 0 my %readers;
47 0 for my $row (@$rows) {
48 0 my $key = DBIO::PostgreSQL::Introspect->qualified_key($row);
49 0 my $read = DBIO::PostgreSQL::Introspect->qualified_key(@{$row}{qw( ref_schema ref_name )});
50 my $view = $readers{$key} //= {
51 schema_name => $row->{schema_name},
52 table_name => $row->{table_name},
53 kind => $row->{kind},
54 0 ▶ depends_on_columns => {},
Condition0%0/2
$readers{$key} //= {"schema_name", $row->{"schema_name"}, "table_name", $row->{"table_name"}, "kind", $row->{"kind"}, "depends_on_columns", {}}
l!l
00
MC/DC0%0/1
$readers{$key} //= {"schema_name", $row->{"schema_name"}, "table_name", $row->{"table_name"}, "kind", $row->{"kind"}, "depends_on_columns", {}}
$readers{$key}
Truth table0%0/2
A
A= $readers{$key}
Aresult
11
00
55 };
56 0 push @{ $view->{depends_on_columns}{$read} }, $row->{ref_column};
57 }
58  
59 0 return \%readers;
60 }
61  
62 171 1;
63  
64 __END__
« blib/lib/DBIO/PostgreSQL/Diff/Index.pm ↑ Summary blib/lib/DBIO/PostgreSQL/Diff/Type.pm »