PostgreSQL/Introspect/Extensions.pm

filter: Statementstmt 46.6% 7 / 15 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 2 / 3 Podpod 100% 1 / 1 totaltotal 43.4% 10 / 23 CC 3 SCAR 20.3
CC
3
Cov
37%
fetch
12.0
BEGIN
1.0
BEGIN
1.0
CRAP 7.6
« PostgreSQL/Diff/Trigger.pm ↑ Summary PostgreSQL/Diff/Type.pm »
1 package DBIO::PostgreSQL::Introspect::Extensions;
2 # ABSTRACT: Introspect PostgreSQL extensions
3  
4 15 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 15 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7  
8  
9 0 ▶sub fetch {
Subroutine fetch: not called CC=3 SCAR=24.8
Pod documented
10 0 my ($class, $dbh) = @_;
11  
12 0 my $sql = q{
13 SELECT
14 e.extname AS extension_name,
15 e.extversion AS version,
16 n.nspname AS schema_name,
17 e.extrelocatable AS relocatable
18 FROM pg_catalog.pg_extension e
19 JOIN pg_catalog.pg_namespace n ON n.oid = e.extnamespace
20 WHERE e.extname != 'plpgsql'
21 ORDER BY e.extname
22 };
23  
24 0 my $sth = $dbh->prepare($sql);
25 0 $sth->execute;
26  
27 0 my %extensions;
28 0 ▶ while (my $row = $sth->fetchrow_hashref) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $row = $sth->fetchrow_hashref) 0 0 0
29 $extensions{ $row->{extension_name} } = {
30 extension_name => $row->{extension_name},
31 version => $row->{version},
32 schema_name => $row->{schema_name},
33 0 ▶ relocatable => $row->{relocatable} ? 1 : 0,
Branch: 1 branch
BranchTrueFalseTotal
$row->{'relocatable'} ? : 0 0 0
34 };
35 }
36  
37 0 return \%extensions;
38 }
39  
40 15 1;
41  
42 __END__
43  
44 =pod
45  
46 =encoding UTF-8
47  
48 =head1 NAME
49  
50 DBIO::PostgreSQL::Introspect::Extensions - Introspect PostgreSQL extensions
51  
52 =head1 VERSION
53  
54 version 0.900001
55  
56 =head1 DESCRIPTION
57  
58 Fetches installed PostgreSQL extension metadata from
59 C<pg_catalog.pg_extension>. The built-in C<plpgsql> extension is excluded
60 since it is always present.
61  
62 =head1 METHODS
63  
64 =head2 fetch
65  
66 my $extensions = DBIO::PostgreSQL::Introspect::Extensions->fetch($dbh);
67  
68 Returns a hashref keyed by extension name. Each entry has:
69 C<extension_name>, C<version>, C<schema_name> (the schema the extension's
70 objects live in), C<relocatable>.
71  
72 No schema filter is accepted — extensions are database-level objects.
73  
74 =head1 AUTHOR
75  
76 DBIO & DBIx::Class Authors
77  
78 =head1 COPYRIGHT AND LICENSE
79  
80 Copyright (C) 2026 DBIO Authors
81 Portions Copyright (C) 2005-2025 DBIx::Class Authors
82 Based on DBIx::Class, heavily modified.
83  
84 This is free software; you can redistribute it and/or modify it under
85 the same terms as the Perl 5 programming language system itself.
86  
87 =cut
« PostgreSQL/Diff/Trigger.pm ↑ Summary PostgreSQL/Diff/Type.pm »