| 1 | package DBIO::Sybase::Storage; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Base class for drivers using L<DBD::Sybase> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 35 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 35 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 35 | our $VERSION = '0.900007'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 35 | ▶ | use Try::Tiny; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 35 | ▶ | use DBIO::Util qw(old_mro); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 35 | ▶ | use DBIO::Storage::Composed (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 35 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 35 | ▶ | use base qw/DBIO::Storage::DBI/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 35 | __PACKAGE__->register_driver('Sybase' => __PACKAGE__); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | ▶ | sub dbio_deploy_class { 'DBIO::Sybase::Deploy' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dbio_deploy_class: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 160 | ▶ | sub _adapt_to_access_path { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_adapt_to_access_path: called CC=10 SCAR=23.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 160 | my ($self, $dbd) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | # Only the declared base moves. A subclass pinned by hand has to stay an | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | # instance of itself -- core checks that after the hook and throws. A storage | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | # pinned to the ASE class itself is where it was put, but the placeholder | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | # decision is taken for it (karr k78); a class below that, and the NoBindVars | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | # class the decision may end in, are left alone. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 160 | my $composition = DBIO::Storage::Composed->composition_of(ref $self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 160 | ▶ | my $declared = $composition ? $composition->{base} : ref $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 160 | my $ase = __PACKAGE__ . '::ASE'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 160 | my $pinned_ase = $declared eq $ase; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 160 | ▶ | return unless $declared eq __PACKAGE__ or $pinned_ase; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$declared eq __PACKAGE__ or $pinned_ase
MC/DC100%2/2
$declared eq __PACKAGE__ or $pinned_ase
$declared eq __PACKAGE__
$pinned_ase
Truth table100%3/3
A or B
A= $declared eq __PACKAGE__B= $pinned_ase
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | # A connection coderef names no DBD until it has run, and core does not run | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | # it for the hook. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | $dbd = $self->_get_dbh->{Driver}{Name} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 123 | ▶ | if not defined $dbd and ref $self->_dbi_connect_info->[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $dbd and ref $self->_dbi_connect_info->[0]
MC/DC50%1/2
not defined $dbd and ref $self->_dbi_connect_info->[0]
not defined $dbd
ref $self->_dbi_connect_info->[0]
Truth table66%2/3
not(A) and B
A= not defined $dbdB= ref $self->_dbi_connect_info->[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | # The DBD of another driver, or one nobody knows: core judges that, and the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | # ASE class is built on DBD::Sybase. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 123 | ▶ | return unless defined $dbd and $dbd eq 'Sybase'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $dbd and $dbd eq "Sybase"
MC/DC50%1/2
defined $dbd and $dbd eq "Sybase"
defined $dbd
$dbd eq "Sybase"
Truth table66%2/3
A and B
A= defined $dbdB= $dbd eq "Sybase"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 120 | ▶ | if ($pinned_ase) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | # The writer and the bulk storage ASE's _init makes of its own class have | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | # a parent that decided already, and auto_cast is copied from it: they | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | # decide nothing, and probe nothing. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 56 | ▶ | return if $self->_parent_storage; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | # The server is looked at before the placeholder decision (karr k94): the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | # declared base does it, and a pinned class meets the same server. A | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | # refusal (driver_strict) must come before anything is probed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 26 | $self->_reject_foreign_server; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 25 | $self->_adapt_to_placeholder_support; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 25 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | # The storage connects here, while it still has its layers: what is left to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | # decide is the client library's to answer, and ASE's _init needs the handle | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | # in any case. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 64 | $self->_reject_foreign_server; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 62 | $self->ensure_class_loaded($ase); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 62 | bless $self, $ase; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 62 | $self->_adapt_to_placeholder_support; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 62 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | # DBD::Sybase sends "select @@version" by itself at every login and keeps | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | # the answer. Nothing is asked for this. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 90 | ▶ | sub _reject_foreign_server { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_reject_foreign_server: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 90 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 90 | my $server = $self->_get_dbh->{syb_server_version_string}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 90 | ▶ | $self->_driver_mismatch( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $server and $server =~ /\bMicrosoft SQL Server\b/i
MC/DC100%2/2
defined $server and $server =~ /\bMicrosoft SQL Server\b/i
defined $server
$server =~ /\bMicrosoft SQL Server\b/i
Truth table100%3/3
A and B
A= defined $serverB= $server =~ /\bMicrosoft SQL Server\b/i
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 'the server answers as Microsoft SQL Server, not as Sybase ASE' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | ) if defined $server and $server =~ /\bMicrosoft SQL Server\b/i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 87 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 160 | ▶ | sub _init { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_init: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | # once the driver is determined see if we need to insert the DBD::Sybase w/ FreeTDS fixups | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | # this is a dirty version of "instance role application", \o/ DO WANT Moo \o/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 160 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | # Only synthesize a "<ref>::FreeTDS" trait once we have reblessed into a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | # concrete server subclass. On the bare base the synthetic trait name would | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | # collide with the real DBIO::Sybase::Storage::FreeTDS module and its @ISA | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | # rewrite would make that class inherit from itself (recursive inheritance). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 160 | ▶ | if ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
ref $self ne __PACKAGE__ and not $self->isa("DBIO::Sybase::Storage::FreeTDS") and $self->_using_freetds
ref $self ne __PACKAGE__ and not $self->isa("DBIO::Sybase::Storage::FreeTDS")
MC/DC100%3/3
ref $self ne __PACKAGE__ and not $self->isa("DBIO::Sybase::Storage::FreeTDS") and $self->_using_freetds
ref $self ne __PACKAGE__
not $self->isa("DBIO::Sybase::Storage::FreeTDS")
$self->_using_freetds
Truth table100%4/4
A and not(B) and C
A= ref $self ne __PACKAGE__B= not $self->isa("DBIO::Sybase::Storage::FreeTDS")C= $self->_using_freetds
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | ref($self) ne __PACKAGE__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | ! $self->isa('DBIO::Sybase::Storage::FreeTDS') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | $self->_using_freetds | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 31 | require DBIO::Sybase::Storage::FreeTDS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | # A layered storage is an instance of a DBIO::Storage::Composed class. The | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | # trait goes over the BASE of the composition, and the layers are composed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | # again over the trait class, so they stay ahead of the driver -- the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | # FreeTDS class included -- and core still knows the class (karr k77). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 31 | my $entry_class = ref $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 31 | my $composition = DBIO::Storage::Composed->composition_of($entry_class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 31 | ▶ | my @isa = @{mro::get_linear_isa($composition ? $composition->{base} : $entry_class)}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 31 | my $class = shift @isa; # this is the class the trait goes over | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 31 | my $trait_class = $class . '::FreeTDS'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 31 | mro::set_mro ($trait_class, 'c3'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 35 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 31 | @{"${trait_class}::ISA"} = ($class, 'DBIO::Sybase::Storage::FreeTDS', @isa); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 31 | ▶ | bless ($self, $composition | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | ? DBIO::Storage::Composed->recompose($entry_class, $trait_class) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | : $trait_class | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 31 | ▶ | Class::C3->reinitialize() if old_mro(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | # No $self->_init(@_) on the new class (karr k68): this is the _init that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | # is running, and the chain it was reached through goes on below with | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | # next::method -- which follows the new class, whose only additions are the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | # trait classes, and neither has an _init. Calling it again ran the whole | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | # chain twice: ASE's _init above this one did its work a second time | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | # (_set_max_connect, the writer storage), and with a broker that was one | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | # login more. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 160 | $self->next::method(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | sub _ping { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ping: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | my $dbh = $self->_dbh or return 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | local $dbh->{RaiseError} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | local $dbh->{PrintError} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | ( try { $dbh->do('select 1'); 1 } ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | ? 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | : 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 151 | ▶ | sub _set_max_connect { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_set_max_connect: called CC=5 SCAR=16.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 151 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 151 | ▶ | my $val = shift // 256; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() // 256
MC/DC0%0/1
shift() // 256
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 151 | my $dsn = $self->_dbi_connect_info->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 151 | ▶ | return if ref($dsn) eq 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | # remembered for _finish_connect_dsn: with an AccessBroker the stored DSN | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | # patched below is not the one connected with (karr k60) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 150 | $self->_max_connect_value($val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 150 | ▶ | if ($dsn !~ /maxConnect=/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 150 | $self->_dbi_connect_info->[0] = "$dsn;maxConnect=$val"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 150 | my $connected = defined $self->_dbh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 150 | $self->disconnect; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 150 | ▶ | $self->ensure_connected if $connected; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | # Core asks this for the DSN of every connect with a string DSN, a broker's | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | # answer included (karr k60). maxConnect, once _set_max_connect has run, and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | # bulkLogin for the bulk storage are added here, so they reach DBI->connect | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | # whether the DSN comes from the stored connect info or is formed anew by a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | # broker. Idempotent: a part the DSN carries is not added again. Bulk storages | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | # exist on DBIO::Sybase::Storage::ASE only, hence the can(). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 325 | ▶ | sub _finish_connect_dsn { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_finish_connect_dsn: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 325 | my ($self, $dsn) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 325 | $dsn = $self->next::method($dsn); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 325 | my $max = $self->_max_connect_value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 325 | ▶ | $dsn .= ";maxConnect=$max" if defined $max and $dsn !~ /maxConnect=/i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $max and not $dsn =~ /maxConnect=/i
MC/DC100%2/2
defined $max and not $dsn =~ /maxConnect=/i
defined $max
not $dsn =~ /maxConnect=/i
Truth table100%3/3
A and not(B)
A= defined $maxB= not $dsn =~ /maxConnect=/i
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 325 | ▶ | $dsn .= ';bulkLogin=1' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$self->can("_is_bulk_storage") and $self->_is_bulk_storage and not $dsn =~ /bulkLogin=/i
$self->can("_is_bulk_storage") and $self->_is_bulk_storage
MC/DC100%3/3
$self->can("_is_bulk_storage") and $self->_is_bulk_storage and not $dsn =~ /bulkLogin=/i
$self->can("_is_bulk_storage")
$self->_is_bulk_storage
not $dsn =~ /bulkLogin=/i
Truth table100%4/4
A and B and not(C)
A= $self->can("_is_bulk_storage")B= $self->_is_bulk_storageC= not $dsn =~ /bulkLogin=/i
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | if $self->can('_is_bulk_storage') and $self->_is_bulk_storage | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | and $dsn !~ /bulkLogin=/i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 325 | return $dsn; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 35 | __PACKAGE__->mk_group_accessors(simple => '_max_connect_value'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 21 | ▶ | sub _bind_host_into_dsn { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_bind_host_into_dsn: called CC=7 SCAR=19.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 21 | my ($self, $driver, $dsn, $host, $port) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | # server=NAME names an entry of the interfaces file or freetds.conf, which | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | # holds no host to replace. Core declines it too, but this driver can say | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | # what to write instead. The form is named, never the DSN: it may carry a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | # password. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | # Only DBD::Sybase's own form: DBIO::MSSQL::Storage::Sybase inherits this | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | # seam ahead of DBIO::MSSQL::Storage, whose ODBC DSNs name Server=. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 21 | ▶ | if (defined $driver and lc $driver eq 'sybase' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%6/9
defined $driver and lc $driver eq "sybase" and defined $dsn and $dsn =~ /^dbi:[^:]*:(.*)\z/is
defined $driver and lc $driver eq "sybase" and defined $dsn
defined $driver and lc $driver eq "sybase"
MC/DC25%1/4
defined $driver and lc $driver eq "sybase" and defined $dsn and $dsn =~ /^dbi:[^:]*:(.*)\z/is
defined $driver
lc $driver eq "sybase"
defined $dsn
$dsn =~ /^dbi:[^:]*:(.*)\z/is
Truth table40%2/5
A and B and C and D
A= defined $driverB= lc $driver eq "sybase"C= defined $dsnD= $dsn =~ /^dbi:[^:]*:(.*)\z/is
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | and defined $dsn and $dsn =~ /^dbi:[^:]*:(.*)\z/is) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 20 | for my $token (grep { length } split /;/, $1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 40 | ▶ | return (undef, "the key 'server', a name of the interfaces file or " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | . 'freetds.conf that holds no host to replace (write host=<host>;' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | . 'port=<port> in the DSN to have a host bound)') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | if $token =~ /^\s*server\s*=/i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | # host= and port= are DBD::Sybase's keys and what core's default translates. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 13 | return $self->next::method($driver, $dsn, $host, $port); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 77 | ▶ | sub _connect_params_dsn { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_connect_params_dsn: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 77 | my ($self, $driver, $params) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | # host=, port= and database= are DBD::Sybase's keys, so the DSN names | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | # DBD::Sybase rather than $driver -- which is 'Sybase' whenever core asks. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 77 | my ($dbname, $host, $port) = @{$params}{qw(dbname host port)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 77 | my $pair = 'DBD::Sybase reaches a server by its address only when it has ' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | . 'both (dbi:Sybase:host=<host>;port=<port>)'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 77 | my $way_out = 'supply a dsn instead (dbi:Sybase:server=<name>;... for a ' | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | . 'server the interfaces file or freetds.conf knows by name)'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 77 | ▶ | $self->throw_exception( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $host and not defined $port
MC/DC100%2/2
defined $host and not defined $port
defined $host
not defined $port
Truth table100%3/3
A and not(B)
A= defined $hostB= not defined $port
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 'Cannot build a DBD::Sybase DSN from the connection parameter host ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | . "without a port: $pair, and a host alone it ignores. No port is assumed " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | . "here -- a server listens where it was configured to. Give port as well, " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | . "or $way_out." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | ) if defined $host && !defined $port; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 68 | ▶ | $self->throw_exception( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $port and not defined $host
MC/DC100%2/2
defined $port and not defined $host
defined $port
not defined $host
Truth table100%3/3
A and not(B)
A= defined $portB= not defined $host
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 'Cannot build a DBD::Sybase DSN from the connection parameter port ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | . "without a host: $pair, and a port alone it ignores. Give host as well, " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | . "leave port out, or $way_out." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | ) if defined $port && !defined $host; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 59 | ▶ | return 'dbi:Sybase:' . join ';', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | ( defined $host ? ("host=$host", "port=$port") : () ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | ( defined $dbname ? "database=$dbname" : () ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | # Whether or not DBD::Sybase was compiled against FreeTDS. If false, it means | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | # the Sybase OpenClient libraries were used. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 709 | ▶ | sub _using_freetds { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_using_freetds: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 709 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 709 | ▶ | return ($self->_get_dbh->{syb_oc_version}||'') =~ /freetds/i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->_get_dbh->{'syb_oc_version'} || ''
MC/DC0%0/1
$self->_get_dbh->{'syb_oc_version'} || ''
$self->_get_dbh->{'syb_oc_version'}
Truth table50%1/2
A
A= $self->_get_dbh->{'syb_oc_version'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | # Either returns the FreeTDS version against which DBD::Sybase was compiled, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | # 0 if can't be determined, or undef otherwise | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 45 | ▶ | sub _using_freetds_version { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_using_freetds_version: called CC=4 SCAR=15.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 45 | my $inf = shift->_get_dbh->{syb_oc_version}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 45 | ▶ | return undef unless ($inf||'') =~ /freetds/i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$inf || ''
MC/DC0%0/1
$inf || ''
$inf
Truth table50%1/2
A
A= $inf
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 45 | ▶ | return $inf =~ /v([0-9\.]+)/ ? $1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 35 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||