blib/lib/DBIx/QuickDB/Driver/MySQLCom.pm

filter: Statementstmt 52.5% 41 / 78 Branchbran 28.2% 13 / 46 Conditioncond 12.5% 3 / 24 MC/DCmcdc 6.6% 1 / 15 Subroutinesub 71.4% 10 / 14 Podpod 40.0% 2 / 5 totaltotal 38.4% 70 / 182 CC 32 SCAR 45.2
CC
32
Cov
39%
viable
186.0
init
20.0
bootstrap
20.0
CRAP 91.4
« blib/lib/DBIx/QuickDB.pm ↑ Summary blib/lib/DBIx/QuickDB/Pool.pm »
1 package DBIx::QuickDB::Driver::MySQLCom;
2 15 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 15 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 15 our $VERSION = '0.000066';
6  
7 15 ▶use Capture::Tiny qw/capture/;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 15 ▶use parent 'DBIx::QuickDB::Driver::MySQL';
Subroutine BEGIN: called CC=1 SCAR=0.0
10 15 ▶use DBIx::QuickDB::Util::HashBase;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 36 ▶sub provider { 'MySQL Community Server' }
Subroutine provider: called CC=1 SCAR=0.0
Pod undocumented
13  
14 35 ▶sub dbd_driver_order { my $class = shift; $class->SUPER::dbd_driver_order($ENV{QDB_MYSQLD_DBD}) }
Subroutine dbd_driver_order: called CC=1 SCAR=0.0
Pod undocumented
15  
16 0 ▶sub init {
Subroutine init: not called CC=4 SCAR=30.0
Pod documented
17 0 my $self = shift;
18  
19 0 my $binary = $self->server_bin;
20 0 ▶ my ($help, $stderr) = capture { system($binary, '--help', '--verbose') };
Subroutine __ANON__: not called CC=1 SCAR=6.9
21  
22 0 ▶ if ($help =~ m/--initialize/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($help =~ /--initialize/) { } 0 0 0
elsif ($help =~ /--bootstrap/) { } 0 0 0
23 0 $self->{+USE_BOOTSTRAP} = 0;
24 }
25 elsif ($help =~ m/--bootstrap/) {
26 0 $self->{+USE_BOOTSTRAP} = 1;
27  
28 0 ▶ $self->{+USE_INSTALLDB} = $self->install_bin ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->install_bin ? : 0 0 0
29 }
30  
31 0 $self->SUPER::init();
32 }
33  
34 14 ▶sub verify_provider {
Subroutine verify_provider: called CC=6 SCAR=18.0
Pod undocumented
35 14 my $class = shift;
36 14 my ($bin, $provider) = @_;
37  
38 14 ▶ $provider //= $class->provider;
Condition33%1/3
$provider //= $class->provider
l!l&&r!l&&!r
0140
MC/DC0%0/2
$provider //= $class->provider
$provider $class->provider
Truth table33%1/3
A //= B
A= $providerB= $class->provider
ABresult
1X1
011
000
39  
40 14 ▶ my ($v, $stderr) = capture { system($bin, '-V') };
Subroutine __ANON__: called CC=1 SCAR=0.0
41 14 ▶ return 1 if $v =~ m/$provider/i;
Branch: 1 branch
BranchTrueFalseTotal
if $v =~ /$provider/i 2 12 14
42  
43 # Distro builds of Oracle MySQL (Ubuntu, Debian, Homebrew, ports) print
44 # their own marker instead of the provider name. MariaDB and Percona always
45 # name themselves, so anything else is Oracle MySQL.
46 12 ▶ return 0 unless $provider eq __PACKAGE__->provider;
Branch: 1 branch
BranchTrueFalseTotal
unless $provider eq __PACKAGE__->provider 6 6 12
47 6 ▶ return 0 if $v =~ m/MariaDB|Percona/i;
Branch: 1 branch
BranchTrueFalseTotal
if $v =~ /MariaDB|Percona/i 2 4 6
48 4 ▶ return $v =~ m/\bVer\s+\d/ ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$v =~ /\bVer\s+\d/ ? : 3 1 4
49 }
50  
51 35 ▶sub viable {
Subroutine viable: called CC=21 SCAR=52.3
Pod documented
52 35 my $this = shift;
53 35 my ($spec) = @_;
54  
55 35 ▶ my %check = (ref($this) ? %$this : (), $this->_default_paths, %$spec);
Branch: 1 branch
BranchTrueFalseTotal
ref $this ? : 0 35 35
56  
57 35 my @bad;
58  
59 35 ▶ push @bad => "Could not load either 'DBD::MariaDB' or 'DBD::mysql', needed for everything"
Branch: 1 branch
BranchTrueFalseTotal
unless $this->dbd_driver 35 0 35
60 unless $this->dbd_driver;
61  
62 35 ▶ push @bad => $this->_watcher_unsupported_reason($spec) // ();
Condition66%2/3
$this->_watcher_unsupported_reason($spec) // ()
l!l&&r!l&&!r
2033
MC/DC50%1/2
$this->_watcher_unsupported_reason($spec) // ()
$this->_watcher_unsupported_reason($spec) ()
Truth table66%2/3
A // B
A= $this->_watcher_unsupported_reason($spec)B= ()
ABresult
1X1
011
000
63  
64 35 ▶ if (!keys %{$this->provider_info}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not keys %{$this->provider_info;}) { } 35 0 35
65 35 push @bad => "Installed MySQL is not " . $this->provider;
66 }
67 else {
68 0 ▶ if ($spec->{bootstrap}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($spec->{'bootstrap'}) { } 0 0 0
elsif ($spec->{'autostart'}) { } 0 0 0
69 0 ▶ push @bad => "'mysqld' command is missing, needed for bootstrap" unless $check{server} && -x $check{server};
Branch: 1 branch
BranchTrueFalseTotal
unless $check{"server"} and -x $check{"server"} 0 0 0
Condition0%0/3
$check{"server"} and -x $check{"server"}
!ll&&!rl&&r
000
MC/DC0%0/2
$check{"server"} and -x $check{"server"}
$check{"server"} -x $check{"server"}
Truth table0%0/3
A and B
A= $check{"server"}B= -x $check{"server"}
ABresult
0X0
100
111
70 }
71 elsif ($spec->{autostart}) {
72 0 ▶ push @bad => "'mysqld' command is missing, needed for autostart" unless $check{server} && -x $check{server};
Branch: 1 branch
BranchTrueFalseTotal
unless $check{"server"} and -x $check{"server"} 0 0 0
Condition0%0/3
$check{"server"} and -x $check{"server"}
!ll&&!rl&&r
000
MC/DC0%0/2
$check{"server"} and -x $check{"server"}
$check{"server"} -x $check{"server"}
Truth table0%0/3
A and B
A= $check{"server"}B= -x $check{"server"}
ABresult
0X0
100
111
73 }
74  
75 0 ▶ if ($spec->{load_sql}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($spec->{"load_sql"}) 0 0 0
76 0 ▶ push @bad => "'mysql' command is missing, needed for load_sql" unless $check{client} && -x $check{client};
Branch: 1 branch
BranchTrueFalseTotal
unless $check{"client"} and -x $check{"client"} 0 0 0
Condition0%0/3
$check{"client"} and -x $check{"client"}
!ll&&!rl&&r
000
MC/DC0%0/2
$check{"client"} and -x $check{"client"}
$check{"client"} -x $check{"client"}
Truth table0%0/3
A and B
A= $check{"client"}B= -x $check{"client"}
ABresult
0X0
100
111
77 }
78 }
79  
80 35 ▶ if ($check{server}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($check{"server"}) 0 35 35
81 0 my $version = $this->version_string;
82 0 ▶ if ($version && $version =~ m/(\d+)\.(\d+)\.(\d+)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($version and $version =~ /(\d+)\.(\d+)\.(\d+)/) 0 0 0
Condition0%0/3
$version and $version =~ /(\d+)\.(\d+)\.(\d+)/
!ll&&!rl&&r
000
MC/DC0%0/2
$version and $version =~ /(\d+)\.(\d+)\.(\d+)/
$version $version =~ /(\d+)\.(\d+)\.(\d+)/
Truth table0%0/3
A and B
A= $versionB= $version =~ /(\d+)\.(\d+)\.(\d+)/
ABresult
0X0
100
111
83 0 my ($a, $b, $c) = ($1, $2, $3);
84 0 ▶ push @bad => "'mysqld' is too old ($a.$b.$c), need at least 5.6.0"
Branch: 1 branch
BranchTrueFalseTotal
if $a < 5 or $a == 5 and $b < 6 0 0 0
Condition0%0/6
$a < 5 or $a == 5 and $b < 6
l!l&&r!l&&!r
000
$a == 5 and $b < 6
!ll&&!rl&&r
000
MC/DC0%0/3
$a < 5 or $a == 5 and $b < 6
$a < 5 $a == 5 $b < 6
Truth table0%0/4
A or B and C
A= $a < 5B= $a == 5C= $b < 6
ABCresult
1XX1
0111
00X0
0100
85 if $a < 5 || ($a == 5 && $b < 6);
86 }
87 }
88  
89 35 ▶ return (1, undef) unless @bad;
Branch: 1 branch
BranchTrueFalseTotal
unless @bad 0 35 35
90 35 return (0, join "\n" => @bad);
91 }
92  
93 0 ▶sub bootstrap {
Subroutine bootstrap: not called CC=4 SCAR=30.0
94 0 my $self = shift;
95  
96 0 my $init_file = $self->SUPER::bootstrap(@_);
97 0 my $data_dir = $self->{+DATA_DIR};
98  
99 0 ▶ if ($self->{+USE_BOOTSTRAP}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'use_bootstrap'}) { } 0 0 0
100 0 ▶ if ($self->{+USE_INSTALLDB}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"use_installdb"}) 0 0 0
101 0 local $ENV{PERL5LIB} = "";
102 # mysql_install_db does not read our defaults file, so the config's
103 # user=root (added when running as root) does not reach it -- pass it
104 # explicitly here so bootstrap works as root too. See MySQL.pm's
105 # _default_config for the rationale.
106 0 ▶ my @root = $self->_run_as_root ? ('--user=root') : ();
Branch: 1 branch
BranchTrueFalseTotal
$self->_run_as_root ? : 0 0 0
107 0 $self->run_command([$self->install_bin, '--datadir=' . $data_dir, @root]);
108 }
109 0 $self->write_config();
110 0 $self->run_command([$self->start_command, '--bootstrap'], {stdin => $init_file});
111 }
112 else {
113 0 $self->write_config();
114 0 $self->run_command([$self->start_command, '--initialize']);
115 0 $self->start;
116 0 $self->load_sql("", $init_file);
117 }
118  
119 0 return;
120 }
121  
122 0 ▶sub _default_config {
Subroutine _default_config: not called CC=1 SCAR=6.9
123 0 my $self = shift;
124  
125 0 my %config = $self->SUPER::_default_config(@_);
126  
127 0 $config{mysql}->{'no-auto-rehash'} = '';
128  
129 0 return %config;
130 }
131  
132 15 1;
133  
134 __END__
« blib/lib/DBIx/QuickDB.pm ↑ Summary blib/lib/DBIx/QuickDB/Pool.pm »