« blib/lib/DBIO/PostgreSQL/Diff/Table.pm
↑ Summary
blib/lib/DBIO/PostgreSQL/Introspect/Extensions.pm »
| 1 | package DBIO::PostgreSQL::Introspect::Schemas; | ||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Introspect PostgreSQL schemas (namespaces) | ||||||||||||||||||||||||||||
| 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=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 14 | 0 | my ($class, $dbh, $filter) = @_; | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 0 | my $sql = q{ | |||||||||||||||||||||||||||
| 17 | SELECT | ||||||||||||||||||||||||||||
| 18 | n.nspname AS schema_name, | ||||||||||||||||||||||||||||
| 19 | n.oid AS schema_oid, | ||||||||||||||||||||||||||||
| 20 | pg_catalog.obj_description(n.oid, 'pg_namespace') AS comment | ||||||||||||||||||||||||||||
| 21 | FROM pg_catalog.pg_namespace n | ||||||||||||||||||||||||||||
| 22 | WHERE 1=1 | ||||||||||||||||||||||||||||
| 23 | }; | ||||||||||||||||||||||||||||
| 24 | 0 | $sql .= DBIO::PostgreSQL::Introspect->system_schema_filter('n'); | |||||||||||||||||||||||||||
| 25 | 0 | $sql .= DBIO::PostgreSQL::Introspect->extension_member_filter('pg_namespace', 'n.oid'); | |||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 0 | my @bind; | |||||||||||||||||||||||||||
| 28 | 0 | ▶ | if ($filter && @$filter) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$filter and @$filter
MC/DC0%0/2
$filter and @$filter
$filter
@$filter
Truth table0%0/3
A and B
A= $filterB= @$filter
| |||||||||||||||||||||||||||||
| 29 | 0 | $sql .= ' AND n.nspname = ANY($1)'; | |||||||||||||||||||||||||||
| 30 | 0 | push @bind, $filter; | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 0 | $sql .= ' ORDER BY n.nspname'; | |||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 0 | my $sth = $dbh->prepare($sql); | |||||||||||||||||||||||||||
| 36 | 0 | $sth->execute(@bind); | |||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 0 | my %schemas; | |||||||||||||||||||||||||||
| 39 | 0 | ▶ | while (my $row = $sth->fetchrow_hashref) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | $schemas{ $row->{schema_name} } = { | ||||||||||||||||||||||||||||
| 41 | oid => $row->{schema_oid}, | ||||||||||||||||||||||||||||
| 42 | comment => $row->{comment}, | ||||||||||||||||||||||||||||
| 43 | 0 | }; | |||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 0 | return \%schemas; | |||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 171 | 1; | |||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | __END__ | ||||||||||||||||||||||||||||