| 1 | package DBIO::PostgreSQL::Introspect::OutsideDependents; | ||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Introspect what stands on a table, a type or a schema of the model and is not in 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 | # The kinds of relation whose columns can be of a type. | ||||||||||||||||||||||||||||
| 14 | 171 | my $COLUMN_RELKINDS = q{'r', 'p', 'f', 'm', 'v', 'c'}; | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 171 | my %PROKIND = ( | |||||||||||||||||||||||||||
| 17 | f => 'function', | ||||||||||||||||||||||||||||
| 18 | p => 'procedure', | ||||||||||||||||||||||||||||
| 19 | a => 'aggregate', | ||||||||||||||||||||||||||||
| 20 | w => 'window function', | ||||||||||||||||||||||||||||
| 21 | ); | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 171 | my %RELKIND = ( | |||||||||||||||||||||||||||
| 24 | v => 'view', | ||||||||||||||||||||||||||||
| 25 | m => 'materialized view', | ||||||||||||||||||||||||||||
| 26 | ); | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 171 | my @SCHEMA_CATALOGS = qw( | |||||||||||||||||||||||||||
| 29 | pg_operator pg_opclass pg_opfamily pg_collation pg_conversion | ||||||||||||||||||||||||||||
| 30 | pg_ts_config pg_ts_dict pg_ts_parser pg_ts_template pg_statistic_ext | ||||||||||||||||||||||||||||
| 31 | ); | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 0 | ▶ | sub _outside { | ||||||||||||||||||||||||||
|
Subroutine
_outside: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 34 | 0 | my ($alias) = @_; | |||||||||||||||||||||||||||
| 35 | 0 | return "AND NOT ($alias.nspname = ANY(\$1))\n " | |||||||||||||||||||||||||||
| 36 | . DBIO::PostgreSQL::Introspect->system_schema_filter($alias); | ||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 0 | ▶ | sub fetch { | ||||||||||||||||||||||||||
|
Subroutine
fetch: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 40 | 0 | my ($class, $dbh, $filter) = @_; | |||||||||||||||||||||||||||
| 41 | 0 | my %result = ( tables => {}, types => {}, schemas => {} ); | |||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 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
| |||||||||||||||||||||||||||||
| 44 | 0 | $class->_tables($dbh, $filter, $result{tables}); | |||||||||||||||||||||||||||
| 45 | 0 | $class->_types($dbh, $filter, $result{types}); | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | 0 | $class->_schemas($dbh, $filter, $result{schemas}); | |||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 0 | return \%result; | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 0 | ▶ | sub _add { | ||||||||||||||||||||||||||
|
Subroutine
_add: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 53 | 0 | my ($into, $key, %entry) = @_; | |||||||||||||||||||||||||||
| 54 | 0 | push @{ $into->{$key} }, \%entry; | |||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 0 | ▶ | sub _rows { | ||||||||||||||||||||||||||
|
Subroutine
_rows: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 58 | 0 | my ($dbh, $sql, @bind) = @_; | |||||||||||||||||||||||||||
| 59 | 0 | return $dbh->selectall_arrayref($sql, { Slice => {} }, @bind); | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 0 | ▶ | sub _tables { | ||||||||||||||||||||||||||
|
Subroutine
_tables: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||
| 63 | 0 | my ($class, $dbh, $filter, $into) = @_; | |||||||||||||||||||||||||||
| 64 | 0 | ▶ | my $key = sub { DBIO::PostgreSQL::Introspect->qualified_key(@_) }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 0 | my $views = q{ | |||||||||||||||||||||||||||
| 67 | SELECT DISTINCT rn.nspname AS schema_name, r.relname AS table_name, | ||||||||||||||||||||||||||||
| 68 | v.relkind AS dep_kind, vn.nspname AS dep_schema, v.relname AS dep_name | ||||||||||||||||||||||||||||
| 69 | FROM pg_catalog.pg_class r | ||||||||||||||||||||||||||||
| 70 | JOIN pg_catalog.pg_namespace rn ON rn.oid = r.relnamespace | ||||||||||||||||||||||||||||
| 71 | JOIN pg_catalog.pg_depend d | ||||||||||||||||||||||||||||
| 72 | ON d.refclassid = 'pg_catalog.pg_class'::pg_catalog.regclass | ||||||||||||||||||||||||||||
| 73 | AND d.refobjid = r.oid | ||||||||||||||||||||||||||||
| 74 | AND d.classid = 'pg_catalog.pg_rewrite'::pg_catalog.regclass | ||||||||||||||||||||||||||||
| 75 | JOIN pg_catalog.pg_rewrite rw ON rw.oid = d.objid | ||||||||||||||||||||||||||||
| 76 | JOIN pg_catalog.pg_class v ON v.oid = rw.ev_class AND v.oid <> r.oid | ||||||||||||||||||||||||||||
| 77 | JOIN pg_catalog.pg_namespace vn ON vn.oid = v.relnamespace | ||||||||||||||||||||||||||||
| 78 | WHERE r.relkind IN ('r', 'p', 'f') | ||||||||||||||||||||||||||||
| 79 | AND v.relkind IN ('v', 'm') | ||||||||||||||||||||||||||||
| 80 | AND rn.nspname = ANY($1) | ||||||||||||||||||||||||||||
| 81 | } . _outside('vn') | ||||||||||||||||||||||||||||
| 82 | . DBIO::PostgreSQL::Introspect->extension_member_filter('pg_class', 'v.oid') | ||||||||||||||||||||||||||||
| 83 | . q{ ORDER BY 1, 2, 4, 5}; | ||||||||||||||||||||||||||||
| 84 | 0 | for my $row (@{ _rows($dbh, $views, $filter) }) { | |||||||||||||||||||||||||||
| 85 | 0 | _add($into, $key->(@{$row}{qw( schema_name table_name )}), | |||||||||||||||||||||||||||
| 86 | 0 | kind => $RELKIND{ $row->{dep_kind} }, name => $key->(@{$row}{qw( dep_schema dep_name )})); | |||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 0 | my $foreign_keys = q{ | |||||||||||||||||||||||||||
| 90 | SELECT rn.nspname AS schema_name, r.relname AS table_name, | ||||||||||||||||||||||||||||
| 91 | c.conname AS constraint_name, hn.nspname AS on_schema, h.relname AS on_table | ||||||||||||||||||||||||||||
| 92 | FROM pg_catalog.pg_constraint c | ||||||||||||||||||||||||||||
| 93 | JOIN pg_catalog.pg_class r ON r.oid = c.confrelid | ||||||||||||||||||||||||||||
| 94 | JOIN pg_catalog.pg_namespace rn ON rn.oid = r.relnamespace | ||||||||||||||||||||||||||||
| 95 | JOIN pg_catalog.pg_class h ON h.oid = c.conrelid | ||||||||||||||||||||||||||||
| 96 | JOIN pg_catalog.pg_namespace hn ON hn.oid = h.relnamespace | ||||||||||||||||||||||||||||
| 97 | WHERE c.contype = 'f' | ||||||||||||||||||||||||||||
| 98 | AND rn.nspname = ANY($1) | ||||||||||||||||||||||||||||
| 99 | } . _outside('hn') | ||||||||||||||||||||||||||||
| 100 | . q{ ORDER BY 1, 2, 4, 5, 3}; | ||||||||||||||||||||||||||||
| 101 | 0 | for my $row (@{ _rows($dbh, $foreign_keys, $filter) }) { | |||||||||||||||||||||||||||
| 102 | 0 | _add($into, $key->(@{$row}{qw( schema_name table_name )}), | |||||||||||||||||||||||||||
| 103 | kind => 'foreign key', name => $row->{constraint_name}, | ||||||||||||||||||||||||||||
| 104 | 0 | on => $key->(@{$row}{qw( on_schema on_table )})); | |||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | 0 | my $children = q{ | |||||||||||||||||||||||||||
| 108 | SELECT rn.nspname AS schema_name, r.relname AS table_name, | ||||||||||||||||||||||||||||
| 109 | ch.relispartition AS is_partition, cn.nspname AS child_schema, ch.relname AS child_name | ||||||||||||||||||||||||||||
| 110 | FROM pg_catalog.pg_inherits i | ||||||||||||||||||||||||||||
| 111 | JOIN pg_catalog.pg_class r ON r.oid = i.inhparent | ||||||||||||||||||||||||||||
| 112 | JOIN pg_catalog.pg_namespace rn ON rn.oid = r.relnamespace | ||||||||||||||||||||||||||||
| 113 | JOIN pg_catalog.pg_class ch ON ch.oid = i.inhrelid | ||||||||||||||||||||||||||||
| 114 | JOIN pg_catalog.pg_namespace cn ON cn.oid = ch.relnamespace | ||||||||||||||||||||||||||||
| 115 | WHERE rn.nspname = ANY($1) | ||||||||||||||||||||||||||||
| 116 | } . _outside('cn') | ||||||||||||||||||||||||||||
| 117 | . q{ ORDER BY 1, 2, 4, 5}; | ||||||||||||||||||||||||||||
| 118 | 0 | for my $row (@{ _rows($dbh, $children, $filter) }) { | |||||||||||||||||||||||||||
| 119 | 0 | ▶ | _add($into, $key->(@{$row}{qw( schema_name table_name )}), | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 120 | kind => ($row->{is_partition} ? 'partition' : 'inheriting table'), | ||||||||||||||||||||||||||||
| 121 | 0 | name => $key->(@{$row}{qw( child_schema child_name )})); | |||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | 0 | ▶ | sub _types { | ||||||||||||||||||||||||||
|
Subroutine
_types: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||
| 126 | 0 | my ($class, $dbh, $filter, $into) = @_; | |||||||||||||||||||||||||||
| 127 | 0 | ▶ | my $key = sub { DBIO::PostgreSQL::Introspect->qualified_key(@_) }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 128 | 0 | my $ext_type = DBIO::PostgreSQL::Introspect->extension_member_filter('pg_type', 't.oid'); | |||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | 0 | my $columns = qq{ | |||||||||||||||||||||||||||
| 131 | SELECT DISTINCT tn.nspname AS schema_name, t.typname AS type_name, | ||||||||||||||||||||||||||||
| 132 | cn.nspname AS rel_schema, c.relname AS rel_name, a.attname AS column_name | ||||||||||||||||||||||||||||
| 133 | FROM pg_catalog.pg_type t | ||||||||||||||||||||||||||||
| 134 | JOIN pg_catalog.pg_namespace tn ON tn.oid = t.typnamespace | ||||||||||||||||||||||||||||
| 135 | JOIN pg_catalog.pg_attribute a | ||||||||||||||||||||||||||||
| 136 | ON a.atttypid = ANY(ARRAY[t.oid, t.typarray]) AND a.attnum > 0 AND NOT a.attisdropped | ||||||||||||||||||||||||||||
| 137 | JOIN pg_catalog.pg_class c ON c.oid = a.attrelid AND c.oid <> t.typrelid | ||||||||||||||||||||||||||||
| 138 | JOIN pg_catalog.pg_namespace cn ON cn.oid = c.relnamespace | ||||||||||||||||||||||||||||
| 139 | WHERE tn.nspname = ANY(\$1) | ||||||||||||||||||||||||||||
| 140 | AND (t.typtype IN ('e', 'r') | ||||||||||||||||||||||||||||
| 141 | OR (t.typtype = 'c' AND EXISTS ( | ||||||||||||||||||||||||||||
| 142 | SELECT 1 FROM pg_catalog.pg_class tc WHERE tc.oid = t.typrelid AND tc.relkind = 'c'))) | ||||||||||||||||||||||||||||
| 143 | AND c.relkind IN ($COLUMN_RELKINDS) | ||||||||||||||||||||||||||||
| 144 | } . _outside('cn') . $ext_type | ||||||||||||||||||||||||||||
| 145 | . DBIO::PostgreSQL::Introspect->extension_member_filter('pg_class', 'c.oid') | ||||||||||||||||||||||||||||
| 146 | . q{ ORDER BY 1, 2, 3, 4, 5}; | ||||||||||||||||||||||||||||
| 147 | 0 | for my $row (@{ _rows($dbh, $columns, $filter) }) { | |||||||||||||||||||||||||||
| 148 | 0 | _add($into, $key->(@{$row}{qw( schema_name type_name )}), | |||||||||||||||||||||||||||
| 149 | kind => 'column', | ||||||||||||||||||||||||||||
| 150 | 0 | name => join '.', @{$row}{qw( rel_schema rel_name column_name )}); | |||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | 0 | my $routines = q{ | |||||||||||||||||||||||||||
| 154 | SELECT DISTINCT tn.nspname AS schema_name, t.typname AS type_name, | ||||||||||||||||||||||||||||
| 155 | p.prokind AS prokind, p.oid::pg_catalog.regprocedure::pg_catalog.text AS routine | ||||||||||||||||||||||||||||
| 156 | FROM pg_catalog.pg_type t | ||||||||||||||||||||||||||||
| 157 | JOIN pg_catalog.pg_namespace tn ON tn.oid = t.typnamespace | ||||||||||||||||||||||||||||
| 158 | JOIN pg_catalog.pg_proc p | ||||||||||||||||||||||||||||
| 159 | ON p.prorettype = ANY(ARRAY[t.oid, t.typarray]) | ||||||||||||||||||||||||||||
| 160 | OR p.proargtypes::pg_catalog.oid[] && ARRAY[t.oid, t.typarray] | ||||||||||||||||||||||||||||
| 161 | OR p.proallargtypes && ARRAY[t.oid, t.typarray] | ||||||||||||||||||||||||||||
| 162 | JOIN pg_catalog.pg_namespace pn ON pn.oid = p.pronamespace | ||||||||||||||||||||||||||||
| 163 | WHERE tn.nspname = ANY($1) | ||||||||||||||||||||||||||||
| 164 | AND (t.typtype IN ('e', 'r') | ||||||||||||||||||||||||||||
| 165 | OR (t.typtype = 'c' AND EXISTS ( | ||||||||||||||||||||||||||||
| 166 | SELECT 1 FROM pg_catalog.pg_class tc WHERE tc.oid = t.typrelid AND tc.relkind = 'c'))) | ||||||||||||||||||||||||||||
| 167 | } . _outside('pn') . $ext_type | ||||||||||||||||||||||||||||
| 168 | . DBIO::PostgreSQL::Introspect->extension_member_filter('pg_proc', 'p.oid') | ||||||||||||||||||||||||||||
| 169 | . q{ ORDER BY 1, 2, 4}; | ||||||||||||||||||||||||||||
| 170 | 0 | for my $row (@{ _rows($dbh, $routines, $filter) }) { | |||||||||||||||||||||||||||
| 171 | 0 | ▶ | _add($into, $key->(@{$row}{qw( schema_name type_name )}), | ||||||||||||||||||||||||||
|
Condition0%0/2
$PROKIND{$row->{"prokind"}} // "function"
MC/DC0%0/1
$PROKIND{$row->{"prokind"}} // "function"
$PROKIND{$row->{"prokind"}}
Truth table0%0/2
A
A= $PROKIND{$row->{"prokind"}}
| |||||||||||||||||||||||||||||
| 172 | 0 | kind => $PROKIND{ $row->{prokind} } // 'function', name => $row->{routine}); | |||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | 0 | my $domains = q{ | |||||||||||||||||||||||||||
| 176 | SELECT DISTINCT tn.nspname AS schema_name, t.typname AS type_name, | ||||||||||||||||||||||||||||
| 177 | dn.nspname AS dom_schema, d.typname AS dom_name | ||||||||||||||||||||||||||||
| 178 | FROM pg_catalog.pg_type t | ||||||||||||||||||||||||||||
| 179 | JOIN pg_catalog.pg_namespace tn ON tn.oid = t.typnamespace | ||||||||||||||||||||||||||||
| 180 | JOIN pg_catalog.pg_type d ON d.typtype = 'd' AND d.typbasetype = ANY(ARRAY[t.oid, t.typarray]) | ||||||||||||||||||||||||||||
| 181 | JOIN pg_catalog.pg_namespace dn ON dn.oid = d.typnamespace | ||||||||||||||||||||||||||||
| 182 | WHERE tn.nspname = ANY($1) | ||||||||||||||||||||||||||||
| 183 | AND (t.typtype IN ('e', 'r') | ||||||||||||||||||||||||||||
| 184 | OR (t.typtype = 'c' AND EXISTS ( | ||||||||||||||||||||||||||||
| 185 | SELECT 1 FROM pg_catalog.pg_class tc WHERE tc.oid = t.typrelid AND tc.relkind = 'c'))) | ||||||||||||||||||||||||||||
| 186 | } . _outside('dn') . $ext_type | ||||||||||||||||||||||||||||
| 187 | . DBIO::PostgreSQL::Introspect->extension_member_filter('pg_type', 'd.oid') | ||||||||||||||||||||||||||||
| 188 | . q{ ORDER BY 1, 2, 3, 4}; | ||||||||||||||||||||||||||||
| 189 | 0 | for my $row (@{ _rows($dbh, $domains, $filter) }) { | |||||||||||||||||||||||||||
| 190 | 0 | _add($into, $key->(@{$row}{qw( schema_name type_name )}), | |||||||||||||||||||||||||||
| 191 | 0 | kind => 'domain', name => $key->(@{$row}{qw( dom_schema dom_name )})); | |||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | 0 | ▶ | sub _schemas { | ||||||||||||||||||||||||||
|
Subroutine
_schemas: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||
| 196 | 0 | my ($class, $dbh, $filter, $into) = @_; | |||||||||||||||||||||||||||
| 197 | 0 | ▶ | my @bind = $filter && @$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
| |||||||||||||||||||||||||||||
| 198 | 0 | ▶ | my $scope = @bind ? 'AND n.nspname = ANY($1)' : ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 199 | 0 | my $system = DBIO::PostgreSQL::Introspect->system_schema_filter('n'); | |||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | 0 | my $domains = qq{ | |||||||||||||||||||||||||||
| 202 | SELECT n.nspname AS schema_name, t.typname AS dom_name | ||||||||||||||||||||||||||||
| 203 | FROM pg_catalog.pg_type t | ||||||||||||||||||||||||||||
| 204 | JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace | ||||||||||||||||||||||||||||
| 205 | WHERE t.typtype = 'd' | ||||||||||||||||||||||||||||
| 206 | $scope | ||||||||||||||||||||||||||||
| 207 | $system | ||||||||||||||||||||||||||||
| 208 | } . DBIO::PostgreSQL::Introspect->extension_member_filter('pg_type', 't.oid') | ||||||||||||||||||||||||||||
| 209 | . q{ ORDER BY 1, 2}; | ||||||||||||||||||||||||||||
| 210 | 0 | for my $row (@{ _rows($dbh, $domains, @bind) }) { | |||||||||||||||||||||||||||
| 211 | _add($into, $row->{schema_name}, kind => 'domain', | ||||||||||||||||||||||||||||
| 212 | 0 | name => DBIO::PostgreSQL::Introspect->qualified_key(@{$row}{qw( schema_name dom_name )})); | |||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | 0 | my $classes = join ', ', map { "'pg_catalog.$_'::pg_catalog.regclass" } @SCHEMA_CATALOGS; | |||||||||||||||||||||||||||
| 216 | 0 | my $others = qq{ | |||||||||||||||||||||||||||
| 217 | SELECT n.nspname AS schema_name, | ||||||||||||||||||||||||||||
| 218 | pg_catalog.pg_describe_object(d.classid, d.objid, d.objsubid) AS description | ||||||||||||||||||||||||||||
| 219 | FROM pg_catalog.pg_depend d | ||||||||||||||||||||||||||||
| 220 | JOIN pg_catalog.pg_namespace n | ||||||||||||||||||||||||||||
| 221 | ON n.oid = d.refobjid AND d.refclassid = 'pg_catalog.pg_namespace'::pg_catalog.regclass | ||||||||||||||||||||||||||||
| 222 | WHERE d.deptype = 'n' | ||||||||||||||||||||||||||||
| 223 | AND d.classid IN ($classes) | ||||||||||||||||||||||||||||
| 224 | $scope | ||||||||||||||||||||||||||||
| 225 | $system | ||||||||||||||||||||||||||||
| 226 | AND NOT EXISTS ( | ||||||||||||||||||||||||||||
| 227 | SELECT 1 FROM pg_catalog.pg_depend ext_dep | ||||||||||||||||||||||||||||
| 228 | WHERE ext_dep.classid = d.classid AND ext_dep.objid = d.objid AND ext_dep.deptype = 'e') | ||||||||||||||||||||||||||||
| 229 | ORDER BY 1, 2 | ||||||||||||||||||||||||||||
| 230 | }; | ||||||||||||||||||||||||||||
| 231 | 0 | for my $row (@{ _rows($dbh, $others, @bind) }) { | |||||||||||||||||||||||||||
| 232 | 0 | _add($into, $row->{schema_name}, name => $row->{description}); | |||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||
| 236 | 171 | 1; | |||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||
| 238 | __END__ | ||||||||||||||||||||||||||||