| 1 | package DBIO::Extension; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Base class of a database extension (PostGIS, AGE, pgvector, ...) known to deploy, introspection and diff | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 11 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 11 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 11 | our $VERSION = '0.900007'; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 11 | ▶ | use DBIO::Exception; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | # The extension interface (ADR 0066 section 5.3). INTERFACE_CURRENT is the | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | # version this core implements; @INTERFACE_VERSIONS is the set it accepts. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | # Until the family's first release the set is exactly the current version; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | # afterwards it holds the current and the previous one for one release, and | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | # that is a change of this list only. | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 11 | our $INTERFACE_CURRENT = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 11 | our @INTERFACE_VERSIONS = (1); | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 2 | ▶ | sub extension_interface { undef } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
extension_interface: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 8 | ▶ | sub name { undef } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 2 | ▶ | sub driver { undef } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
driver: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 66 | ▶ | sub inspect { undef } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
inspect: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 96 | ▶ | sub claims { [] } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
claims: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 101 | ▶ | sub annotate { [] } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
annotate: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 65 | ▶ | sub verdict { undef } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
verdict: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 41 | ▶ | sub activation { undef } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
activation: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 1 | ▶ | sub storage_layer { undef } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
storage_layer: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 1 | ▶ | sub components { () } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
components: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 1 | ▶ | sub interface_current { $INTERFACE_CURRENT } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
interface_current: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 66 | ▶ | sub interface_versions { @INTERFACE_VERSIONS } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
interface_versions: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 65 | ▶ | sub check_interface { | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
check_interface: called CC=8 SCAR=21.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 65 | my ($self, $class) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 65 | ▶ | DBIO::Exception->throw("Extension class '" . ($class // 'undef') . "' does not derive from DBIO::Extension") | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%4/8
defined $class and not ref $class and $class->isa(__PACKAGE__)
defined $class and not ref $class
$class // "undef"
MC/DC33%1/3
defined $class and not ref $class and $class->isa(__PACKAGE__)
defined $class
not ref $class
$class->isa(__PACKAGE__)
MC/DC0%0/1
$class // "undef"
$class
Truth table50%2/4
A and not(B) and C
A= defined $classB= not ref $classC= $class->isa(__PACKAGE__)
Truth table50%1/2
A
A= $class
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | unless defined $class && !ref $class && $class->isa(__PACKAGE__); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 64 | my $version = $class->extension_interface; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 64 | my @accepted = $self->interface_versions; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 64 | ▶ | DBIO::Exception->throw( | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | "Extension $class states no extension_interface; this DBIO core supports " | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | . "interface version(s) " . join(', ', @accepted) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | . ". Add 'sub extension_interface { $INTERFACE_CURRENT }' to the extension." | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | ) unless defined $version; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 63 | ▶ | return 1 if grep { $_ eq $version } @accepted; | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | my ($min, $max) = (sort { $a <=> $b } @accepted)[0, -1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 4 | ▶ | my $side = $version > $max | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | ? 'upgrade DBIO core' | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | : 'upgrade the extension'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 4 | DBIO::Exception->throw( | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | "Extension $class implements interface version $version; this DBIO core " | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | . "supports interface version(s) " . join(', ', @accepted) . ". To fix: $side." | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 11 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||