« blib/lib/DBIO/Test/AsyncParity.pm
↑ Summary
blib/lib/DBIO/DeploymentHandler/DeployMethod/Native.pm »
| 1 | # ABSTRACT: One credential identity pinned to one host | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | package DBIO::AccessBroker::HostBound; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 45 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 45 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 45 | our $VERSION = '0.900007'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 45 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 45 | ▶ | use Scalar::Util qw(blessed); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 45 | ▶ | use base 'DBIO::AccessBroker'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 45 | ▶ | use DBIO::Storage::DBI (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 45 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 45 | __PACKAGE__->mk_group_accessors('simple' => qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | _broker _host _port | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | )); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 190 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 190 | my ($class, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 190 | my $broker = $args{broker}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 190 | ▶ | croak "HostBound requires 'broker'" unless defined $broker; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 188 | ▶ | croak "HostBound 'broker' must be a DBIO::AccessBroker instance" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
builtin::blessed($broker) and $broker->isa("DBIO::AccessBroker")
MC/DC100%2/2
builtin::blessed($broker) and $broker->isa("DBIO::AccessBroker")
builtin::blessed($broker)
$broker->isa("DBIO::AccessBroker")
Truth table100%3/3
A and B
A= builtin::blessed($broker)B= $broker->isa("DBIO::AccessBroker")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | unless blessed($broker) && $broker->isa('DBIO::AccessBroker'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 184 | ▶ | croak "HostBound requires 'host'" unless defined $args{host}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 178 | my $self = $class->SUPER::new(%args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 178 | $self->_broker($broker); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 178 | $self->_host($args{host}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 178 | ▶ | $self->_port($args{port}) if defined $args{port}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 178 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | # The wrapped broker is the real CredentialSource. The view holds no | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | # credentials of its own; callers that need the underlying identity | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | # (e.g. to compare two views sharing one lease) read it here. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 18 | ▶ | sub underlying_broker { $_[0]->_broker } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
underlying_broker: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 3 | ▶ | sub host { $_[0]->_host } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
host: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 3 | ▶ | sub port { $_[0]->_port } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
port: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | # Lifecycle delegates entirely to the wrapped CredentialSource: one lease, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | # one rotation schedule, shared across every host this credential serves. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 260 | ▶ | sub needs_refresh { $_[0]->_broker->needs_refresh } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
needs_refresh: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 8 | ▶ | sub refresh { $_[0]->_broker->refresh } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
refresh: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 20 | ▶ | sub has_rotating_credentials { $_[0]->_broker->has_rotating_credentials } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_rotating_credentials: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 25 | ▶ | sub is_transaction_safe { $_[0]->_broker->is_transaction_safe } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_transaction_safe: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | # Attaching the view to a storage must also reach the underlying broker, so | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | # storage-aware credential lookups and storage-tied rotation keep working. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 128 | ▶ | sub set_storage { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_storage: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 128 | my ($self, $storage) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 128 | $self->SUPER::set_storage($storage); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 128 | $self->_broker->set_storage($storage); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 128 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 4 | ▶ | sub unset_storage { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unset_storage: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 4 | my ($self, $storage) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 4 | $self->SUPER::unset_storage($storage); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 4 | $self->_broker->unset_storage($storage); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 4 | return $storage; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 37 | ▶ | sub connect_info_for { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
connect_info_for: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 37 | my ($self, $mode) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | # The storage whose class may bind the host: the view's one storage, when | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | # it has exactly one. With none or several there is no class to ask. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 37 | my @attached = $self->_attached_storages; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 37 | ▶ | return $self->_bind_host( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | $self->_broker->connect_info_for($mode), @attached == 1 ? $attached[0] : undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 265 | ▶ | sub connect_info_for_storage { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
connect_info_for_storage: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 265 | my ($self, $storage, $mode) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 265 | return $self->_bind_host( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | $self->_broker->connect_info_for_storage($storage, $mode), $storage | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | # Inject this view's host into whatever connect-info shape the wrapped broker | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | # produces, without the broker ever knowing the host list. Two shapes occur | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | # in the wild: the hashref form ({host,port,dbname,...}, e.g. Static) and the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | # DBI-arrayref form ([$dsn,$user,$pass,\%attrs], e.g. Vault). A DSN string is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | # bound through the driver seam (_bind_host_into_dsn); what cannot be bound | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | # is refused, naming the form and never the DSN (karr k276). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 300 | ▶ | sub _bind_host { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_bind_host: called CC=13 SCAR=25.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 300 | my ($self, $info, $storage) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 300 | my $host = $self->_host; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 300 | my $port = $self->_port; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | # An empty hash is no answer: binding a host into it would make it one, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | # and the storage would open a connection with host and port alone instead | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | # of refusing the broker (karr k253). Hand it on as it came. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 300 | ▶ | if (ref $info eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 142 | ▶ | return $info unless %$info; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | $self->_cannot_bind('dbh_maker: code opens the connection') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 135 | ▶ | if defined $info->{dbh_maker}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 134 | my %bound = %$info; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 134 | ▶ | if (defined $bound{dsn} && !ref $bound{dsn} && length $bound{dsn}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
defined $bound{"dsn"} and not ref $bound{"dsn"} and length $bound{"dsn"}
defined $bound{"dsn"} and not ref $bound{"dsn"}
MC/DC66%2/3
defined $bound{"dsn"} and not ref $bound{"dsn"} and length $bound{"dsn"}
defined $bound{"dsn"}
not ref $bound{"dsn"}
length $bound{"dsn"}
Truth table75%3/4
A and not(B) and C
A= defined $bound{"dsn"}B= not ref $bound{"dsn"}C= length $bound{"dsn"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 56 | $bound{dsn} = $self->_bind_host_into_dsn($bound{dsn}, $storage); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 56 | return \%bound; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 78 | $bound{host} = $host; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 78 | ▶ | $bound{port} = $port if defined $port; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 78 | return \%bound; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 158 | ▶ | if (ref $info eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 138 | my @bound = @$info; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 138 | ▶ | if (ref $bound[0]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 1 | ▶ | $self->_cannot_bind('a code reference in place of a DSN') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | if ref $bound[0] eq 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | ▶ | elsif (defined $bound[0] && length $bound[0]) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
defined $bound[0] and length $bound[0]
MC/DC100%2/2
defined $bound[0] and length $bound[0]
defined $bound[0]
length $bound[0]
Truth table100%3/3
A and B
A= defined $bound[0]B= length $bound[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 116 | $bound[0] = $self->_bind_host_into_dsn($bound[0], $storage); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 123 | return \@bound; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 20 | return $info; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | # The DSN with this view's host and port bound, by the first driver seam that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | # is not core's default; else by the default; or a refusal naming the form. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 172 | ▶ | sub _bind_host_into_dsn { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_bind_host_into_dsn: called CC=16 SCAR=27.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 172 | my ($self, $dsn, $storage) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 172 | my ($host, $port) = ($self->_host, $self->_port); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | # Before any seam is asked: a driver never sees a value that would split | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | # the DSN. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 172 | ▶ | $self->_cannot_bind("host/port containing ';'") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$host =~ /;/ or defined $port and $port =~ /;/
defined $port and $port =~ /;/
MC/DC100%3/3
$host =~ /;/ or defined $port and $port =~ /;/
$host =~ /;/
defined $port
$port =~ /;/
Truth table100%4/4
A or B and C
A= $host =~ /;/B= defined $portC= $port =~ /;/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | if $host =~ /;/ || (defined $port && $port =~ /;/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 170 | my ($dbd) = $dsn =~ /^dbi:([^:(]*)/i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 170 | ▶ | $dbd //= ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$dbd //= ""
MC/DC100%1/1
$dbd //= ""
$dbd
Truth table100%2/2
A
A= $dbd
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 170 | my $default = \&DBIO::Storage::DBI::_bind_host_into_dsn; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 170 | my @candidates; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 170 | ▶ | push @candidates, ref $storage || $storage | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%6/9
defined $storage and builtin::blessed($storage) and $storage->can("_bind_host_into_dsn")
defined $storage and builtin::blessed($storage)
ref $storage || $storage
MC/DC66%2/3
defined $storage and builtin::blessed($storage) and $storage->can("_bind_host_into_dsn")
defined $storage
builtin::blessed($storage)
$storage->can("_bind_host_into_dsn")
MC/DC0%0/2
ref $storage || $storage
ref $storage
$storage
Truth table75%3/4
A and B and C
A= defined $storageB= builtin::blessed($storage)C= $storage->can("_bind_host_into_dsn")
Truth table33%1/3
A || B
A= ref $storageB= $storage
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | if defined $storage && blessed($storage) && $storage->can('_bind_host_into_dsn'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 170 | ▶ | if (length $dbd) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 169 | my $class = DBIO::Storage::DBI->driver_storage_class($dbd); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 169 | ▶ | push @candidates, $class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $class and $class->can("_bind_host_into_dsn")
MC/DC100%2/2
defined $class and $class->can("_bind_host_into_dsn")
defined $class
$class->can("_bind_host_into_dsn")
Truth table100%3/3
A and B
A= defined $classB= $class->can("_bind_host_into_dsn")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | if defined $class && $class->can('_bind_host_into_dsn'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 170 | my $seam_class = 'DBIO::Storage::DBI'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 170 | for my $candidate (@candidates) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 242 | ▶ | next if $candidate->can('_bind_host_into_dsn') == $default; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 6 | $seam_class = $candidate; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 6 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 170 | my ($bound, $form) = $seam_class->_bind_host_into_dsn($dbd, $dsn, $host, $port); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 170 | ▶ | return $bound if defined $bound; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 12 | ▶ | $self->_cannot_bind($form // 'a DSN form the driver does not name'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$form // "a DSN form the driver does not name"
MC/DC0%0/1
$form // "a DSN form the driver does not name"
$form
Truth table50%1/2
A
A= $form
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | # Refuse; the form is a key or a dialect, never a value of the answer. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 16 | ▶ | sub _cannot_bind { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_cannot_bind: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 16 | my ($self, $form) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 16 | croak 'HostBound view over ' . ref($self->_broker) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | . " cannot bind its host into the answer: $form. The storage's driver " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | . 'seam _bind_host_into_dsn (ADR 0013, addendum 2026-10-09) translates ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | . 'the DSN forms its DBD takes; give the answer as connection parameters ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | . 'or a DSN naming its server with host=/port=.'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 45 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||