| 1 | package DBIx::QuickDB::Driver::MySQL; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 20 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 20 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 20 | our $VERSION = '0.000066'; | |||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 20 | ▶ | use Capture::Tiny qw/capture/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 20 | ▶ | use Carp qw/confess croak/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 20 | ▶ | use DBIx::QuickDB::Util qw/strip_hash_defaults find_bin/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 20 | ▶ | use Scalar::Util qw/reftype blessed/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 20 | ▶ | use parent 'DBIx::QuickDB::Driver'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 20 | ▶ | use DBIx::QuickDB::Util::HashBase qw{ | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | <data_dir <temp_dir <socket <pid_file <cfg_file | ||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | +dbd_driver | ||||||||||||||||||||||||||||||||||||||||||
| 17 | <mysqld_provider | ||||||||||||||||||||||||||||||||||||||||||
| 18 | <use_bootstrap | ||||||||||||||||||||||||||||||||||||||||||
| 19 | <use_installdb | ||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | <character_set_server | ||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | <config | ||||||||||||||||||||||||||||||||||||||||||
| 24 | 20 | }; | |||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | sub provider { croak "'$_[0]' does not implement provider" } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
provider: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | sub verify_provider { croak "'$_[0]' does not implement verify_provider" } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
verify_provider: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | # True when we are running as root (EUID 0) on a platform where that matters. | ||||||||||||||||||||||||||||||||||||||||||
| 30 | # mysqld/mariadbd refuse to start as root without an explicit user=root. Factored | ||||||||||||||||||||||||||||||||||||||||||
| 31 | # out as a method so tests can simulate root without actually being it. $> is not | ||||||||||||||||||||||||||||||||||||||||||
| 32 | # meaningful on Windows, so it never reports root there. | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 3 | ▶ | sub _run_as_root { $^O ne 'MSWin32' && $> == 0 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_run_as_root: called CC=2 SCAR=7.6
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | 54 | ▶ | sub dbd_driver_order { shift; grep { $_ } @_, 'DBD::MariaDB', 'DBD::mysql' } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dbd_driver_order: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | 20 | ▶ | sub server_bin_list { qw/mysqld/ } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
server_bin_list: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | sub client_bin_list { qw/mysql/ } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
client_bin_list: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | sub install_bin_list { qw/mysql_install_db/ } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
install_bin_list: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | 64 | ▶ | sub server_bin { $_[0]->provider_info->{server_bin} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
server_bin: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | 60 | ▶ | sub client_bin { $_[0]->provider_info->{client_bin} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
client_bin: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 3 | ▶ | sub install_bin { $_[0]->provider_info->{install_bin} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
install_bin: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | sub error_log { "$_[0]->{+DIR}/error.log" } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error_log: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | 20 | my %PROVIDER_CACHE; | |||||||||||||||||||||||||||||||||||||||||
| 46 | 177 | ▶ | sub provider_info { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
provider_info: called CC=15 SCAR=27.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | 177 | my $this = shift; | |||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | 177 | ▶ | my $class = blessed($this) || $this; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
builtin::blessed($this) || $this
MC/DC0%0/2
builtin::blessed($this) || $this
builtin::blessed($this)
$this
Truth table33%1/3
A || B
A= builtin::blessed($this)B= $this
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | 177 | ▶ | return $PROVIDER_CACHE{$class} if $PROVIDER_CACHE{$class}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | 34 | my %found; | |||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | 34 | my $viable = 0; | |||||||||||||||||||||||||||||||||||||||||
| 55 | 34 | for my $bin ($this->server_bin_list) { | |||||||||||||||||||||||||||||||||||||||||
| 56 | 46 | ▶ | if (my $mysqld = find_bin($bin)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | 2 | ▶ | $found{server_bin} = $mysqld if $this->verify_provider($mysqld); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | 2 | ▶ | last if $found{server_bin}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | 34 | ▶ | return $PROVIDER_CACHE{$class} = {} unless $found{server_bin}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | 2 | for my $bin ($this->client_bin_list) { | |||||||||||||||||||||||||||||||||||||||||
| 65 | 2 | ▶ | if (my $mysql = find_bin($bin)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | 2 | $found{client_bin} = $mysql; | |||||||||||||||||||||||||||||||||||||||||
| 67 | 2 | last; | |||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | 2 | ▶ | return $PROVIDER_CACHE{$class} = {} unless $found{client_bin}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | 2 | for my $bin ($this->install_bin_list) { | |||||||||||||||||||||||||||||||||||||||||
| 74 | 3 | ▶ | if (my $install = find_bin($bin)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | 1 | ▶ | my ($stdout, $stderr) = capture { system($install, '--help') }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | 1 | my $output = $stdout . "\n" . $stderr; | |||||||||||||||||||||||||||||||||||||||||
| 77 | 1 | ▶ | unless ($output =~ m/is deprecated/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 1 | $found{install_bin} = $install; | |||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||
| 80 | 1 | ▶ | last if $found{install_bin}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | 2 | return $PROVIDER_CACHE{$class} = \%found; | |||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | sub choose { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
choose: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | my $this = shift; | |||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | my $spec = { bootstrap => 1, load_sql => 1 }; | |||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | require DBIx::QuickDB::Driver::MariaDB; | |||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | my ($ok, $why) = DBIx::QuickDB::Driver::MariaDB->viable($spec); | |||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | return 'DBIx::QuickDB::Driver::MariaDB' if $ok; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | require DBIx::QuickDB::Driver::MySQLCom; | |||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ($ok, $why) = DBIx::QuickDB::Driver::MySQLCom->viable($spec); | |||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | return 'DBIx::QuickDB::Driver::MySQLCom' if $ok; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | require DBIx::QuickDB::Driver::Percona; | |||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ($ok, $why) = DBIx::QuickDB::Driver::Percona->viable($spec); | |||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | return 'DBIx::QuickDB::Driver::Percona' if $ok; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | 8 | ▶ | sub viable { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
viable: called CC=4 SCAR=14.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | 8 | my $this = shift; | |||||||||||||||||||||||||||||||||||||||||
| 109 | 8 | my ($spec) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | 8 | require DBIx::QuickDB::Driver::MariaDB; | |||||||||||||||||||||||||||||||||||||||||
| 112 | 8 | require DBIx::QuickDB::Driver::MySQLCom; | |||||||||||||||||||||||||||||||||||||||||
| 113 | 8 | require DBIx::QuickDB::Driver::Percona; | |||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | 8 | my ($ok1, $why1) = DBIx::QuickDB::Driver::MariaDB->viable($spec); | |||||||||||||||||||||||||||||||||||||||||
| 116 | 8 | my ($ok2, $why2) = DBIx::QuickDB::Driver::MySQLCom->viable($spec); | |||||||||||||||||||||||||||||||||||||||||
| 117 | 8 | my ($ok3, $why3) = DBIx::QuickDB::Driver::Percona->viable($spec); | |||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | 8 | ▶ | return (1, undef) if $ok1 || $ok2 || $ok3; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$ok1 or $ok2 or $ok3
$ok1 or $ok2
MC/DC0%0/3
$ok1 or $ok2 or $ok3
$ok1
$ok2
$ok3
Truth table25%1/4
A or B or C
A= $ok1B= $ok2C= $ok3
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | 8 | return (0, join("\n" => $why1, $why2, $why3)); | |||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | 2 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=16.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | 2 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||
| 127 | 2 | ▶ | if ($class eq __PACKAGE__) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | my $real_class = $class->choose or croak("Neither MariaDB, MySQL (Oracle/Community), or Percona are viable"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | return $real_class->new(@_); | |||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | 2 | ▶ | my $self = @_ == 1 ? $_[0] : {@_}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | 2 | bless($self, $class); | |||||||||||||||||||||||||||||||||||||||||
| 134 | 2 | $self->init(); | |||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | 2 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | sub version_string { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
version_string: not called CC=14 SCAR=53.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | my ($class_or_self, @other) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | my $binary; | |||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||
| 144 | # Go in reverse order assuming the last param hash provided is most important | ||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | for my $arg (reverse @_) { | |||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | my $type = reftype($arg) or next; # skip if not a ref | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | next unless $type eq 'HASH'; # We have a hashref, possibly blessed | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||
| 149 | # If we find a launcher we are done looping, we want to use this binary. | ||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | if (blessed($arg) && $arg->can('server_bin')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
builtin::blessed($arg) and $arg->can("server_bin")
MC/DC0%0/2
builtin::blessed($arg) and $arg->can("server_bin")
builtin::blessed($arg)
$arg->can("server_bin")
Truth table0%0/3
A and B
A= builtin::blessed($arg)B= $arg->can("server_bin")
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | $binary = $arg->server_bin and last; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | for my $l (qw/server_bin mysqld mariadbd/) { | |||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | $binary = $arg->{$l} and last; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | ▶ | last if $binary; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | unless ($binary) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | if ($class_or_self eq __PACKAGE__) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | if (my $sel = $class_or_self->choose) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | $binary = $sel->server_bin; | |||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||
| 167 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | $binary = $class_or_self->server_bin; | |||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | croak "Could not find a viable server binary" unless $binary; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||
| 174 | # Call the binary with '-V', capturing and returning the output using backticks. | ||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | my ($v, $stderr) = capture { system($binary, '-V') }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | return $v; | |||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | 54 | ▶ | sub dbd_driver { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dbd_driver: called CC=6 SCAR=21.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 181 | 54 | my $in = shift; | |||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||
| 183 | 54 | ▶ | return $in->{+DBD_DRIVER} if blessed($in) && $in->{+DBD_DRIVER}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
builtin::blessed($in) and $in->{"dbd_driver"}
MC/DC0%0/2
builtin::blessed($in) and $in->{"dbd_driver"}
builtin::blessed($in)
$in->{"dbd_driver"}
Truth table33%1/3
A and B
A= builtin::blessed($in)B= $in->{"dbd_driver"}
| |||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||
| 185 | 54 | for my $driver ($in->dbd_driver_order) { | |||||||||||||||||||||||||||||||||||||||||
| 186 | 108 | my $file = $driver; | |||||||||||||||||||||||||||||||||||||||||
| 187 | 108 | $file =~ s{::}{/}g; | |||||||||||||||||||||||||||||||||||||||||
| 188 | 108 | $file .= ".pm"; | |||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | eval { require($file); 1 } or next; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | ▶ | return $in->{+DBD_DRIVER} = $driver if blessed($in); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | return $driver; | |||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||
| 195 | 54 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | sub list_env_vars { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
list_env_vars: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 200 | return ( | ||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | $self->SUPER::list_env_vars(), | |||||||||||||||||||||||||||||||||||||||||
| 202 | qw{ | ||||||||||||||||||||||||||||||||||||||||||
| 203 | LIBMYSQL_ENABLE_CLEARTEXT_PLUGIN LIBMYSQL_PLUGINS | ||||||||||||||||||||||||||||||||||||||||||
| 204 | LIBMYSQL_PLUGIN_DIR MYSQLX_TCP_PORT MYSQLX_UNIX_PORT MYSQL_DEBUG | ||||||||||||||||||||||||||||||||||||||||||
| 205 | MYSQL_GROUP_SUFFIX MYSQL_HISTFILE MYSQL_HISTIGNORE MYSQL_HOME | ||||||||||||||||||||||||||||||||||||||||||
| 206 | MYSQL_HOST MYSQL_OPENSSL_UDF_DH_BITS_THRESHOLD | ||||||||||||||||||||||||||||||||||||||||||
| 207 | MYSQL_OPENSSL_UDF_DSA_BITS_THRESHOLD | ||||||||||||||||||||||||||||||||||||||||||
| 208 | MYSQL_OPENSSL_UDF_RSA_BITS_THRESHOLD MYSQL_PS1 MYSQL_PWD | ||||||||||||||||||||||||||||||||||||||||||
| 209 | MYSQL_SERVER_PREPARE MYSQL_TCP_PORT MYSQL_TEST_LOGIN_FILE | ||||||||||||||||||||||||||||||||||||||||||
| 210 | MYSQL_TEST_TRACE_CRASH MYSQL_TEST_TRACE_DEBUG MYSQL_UNIX_PORT | ||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||
| 212 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||
| 215 | 60 | ▶ | sub _default_paths { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_default_paths: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 216 | 60 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||
| 218 | return ( | ||||||||||||||||||||||||||||||||||||||||||
| 219 | 60 | server => $class->server_bin, | |||||||||||||||||||||||||||||||||||||||||
| 220 | client => $class->client_bin, | ||||||||||||||||||||||||||||||||||||||||||
| 221 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||
| 224 | 2 | ▶ | sub _default_config { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_default_config: called CC=3 SCAR=11.2
| |||||||||||||||||||||||||||||||||||||||||||
| 225 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||
| 227 | 2 | my $dir = $self->dir; | |||||||||||||||||||||||||||||||||||||||||
| 228 | 2 | my $data_dir = $self->data_dir; | |||||||||||||||||||||||||||||||||||||||||
| 229 | 2 | my $temp_dir = $self->temp_dir; | |||||||||||||||||||||||||||||||||||||||||
| 230 | 2 | my $pid_file = $self->pid_file; | |||||||||||||||||||||||||||||||||||||||||
| 231 | 2 | my $socket = $self->socket; | |||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||
| 233 | return ( | ||||||||||||||||||||||||||||||||||||||||||
| 234 | client => { | ||||||||||||||||||||||||||||||||||||||||||
| 235 | 'socket' => $socket, | ||||||||||||||||||||||||||||||||||||||||||
| 236 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||
| 238 | mysql_safe => { | ||||||||||||||||||||||||||||||||||||||||||
| 239 | 'socket' => $socket, | ||||||||||||||||||||||||||||||||||||||||||
| 240 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||
| 242 | mysql => { | ||||||||||||||||||||||||||||||||||||||||||
| 243 | 'socket' => $socket, | ||||||||||||||||||||||||||||||||||||||||||
| 244 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||
| 246 | mysqld => { | ||||||||||||||||||||||||||||||||||||||||||
| 247 | 'datadir' => $data_dir, | ||||||||||||||||||||||||||||||||||||||||||
| 248 | 'pid-file' => $pid_file, | ||||||||||||||||||||||||||||||||||||||||||
| 249 | 'socket' => $socket, | ||||||||||||||||||||||||||||||||||||||||||
| 250 | 'tmpdir' => $temp_dir, | ||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||
| 252 | 'log_error' => "$dir/error.log", | ||||||||||||||||||||||||||||||||||||||||||
| 253 | 'secure_file_priv' => $dir, | ||||||||||||||||||||||||||||||||||||||||||
| 254 | 'default_storage_engine' => 'InnoDB', | ||||||||||||||||||||||||||||||||||||||||||
| 255 | 'innodb_buffer_pool_size' => '20M', | ||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||
| 257 | # MariaDB 10.11+ reserves address space for the maximum, default | ||||||||||||||||||||||||||||||||||||||||||
| 258 | # 8T, which Cygwin cannot map. The server raises the max to match | ||||||||||||||||||||||||||||||||||||||||||
| 259 | # a larger configured size on its own. | ||||||||||||||||||||||||||||||||||||||||||
| 260 | 'loose-innodb_buffer_pool_size_max' => '20M', | ||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||
| 262 | 'key_buffer_size' => '20M', | ||||||||||||||||||||||||||||||||||||||||||
| 263 | 'max_connections' => '100', | ||||||||||||||||||||||||||||||||||||||||||
| 264 | 'server-id' => '1', | ||||||||||||||||||||||||||||||||||||||||||
| 265 | 'skip_grant_tables' => '1', | ||||||||||||||||||||||||||||||||||||||||||
| 266 | 'skip_external_locking' => '', | ||||||||||||||||||||||||||||||||||||||||||
| 267 | 'skip_networking' => '1', | ||||||||||||||||||||||||||||||||||||||||||
| 268 | 'skip_name_resolve' => '1', | ||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||
| 270 | # The X Plugin (MySQL/Percona 5.7.12+) defaults ON with a GLOBAL | ||||||||||||||||||||||||||||||||||||||||||
| 271 | # default socket (/tmp/mysqlx.sock) and TCP port (33060), so | ||||||||||||||||||||||||||||||||||||||||||
| 272 | # concurrent instances contend on shared resources even though | ||||||||||||||||||||||||||||||||||||||||||
| 273 | # each has its own datadir/socket. The loose- prefix downgrades | ||||||||||||||||||||||||||||||||||||||||||
| 274 | # the option to a warning on servers without the plugin (MariaDB, | ||||||||||||||||||||||||||||||||||||||||||
| 275 | # old MySQL) instead of a fatal unknown-variable error. | ||||||||||||||||||||||||||||||||||||||||||
| 276 | 'loose-mysqlx' => 'OFF', | ||||||||||||||||||||||||||||||||||||||||||
| 277 | 'max_allowed_packet' => '1M', | ||||||||||||||||||||||||||||||||||||||||||
| 278 | 'max_binlog_size' => '20M', | ||||||||||||||||||||||||||||||||||||||||||
| 279 | 'myisam_sort_buffer_size' => '8M', | ||||||||||||||||||||||||||||||||||||||||||
| 280 | 'net_buffer_length' => '8K', | ||||||||||||||||||||||||||||||||||||||||||
| 281 | 'read_buffer_size' => '256K', | ||||||||||||||||||||||||||||||||||||||||||
| 282 | 'read_rnd_buffer_size' => '512K', | ||||||||||||||||||||||||||||||||||||||||||
| 283 | 'sort_buffer_size' => '512K', | ||||||||||||||||||||||||||||||||||||||||||
| 284 | 'table_open_cache' => '64', | ||||||||||||||||||||||||||||||||||||||||||
| 285 | 'thread_cache_size' => '8', | ||||||||||||||||||||||||||||||||||||||||||
| 286 | 'thread_stack' => '192K', | ||||||||||||||||||||||||||||||||||||||||||
| 287 | 'innodb_io_capacity' => '2000', | ||||||||||||||||||||||||||||||||||||||||||
| 288 | 'innodb_max_dirty_pages_pct' => '0', | ||||||||||||||||||||||||||||||||||||||||||
| 289 | 'innodb_max_dirty_pages_pct_lwm' => '0', | ||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||
| 291 | 'character_set_server' => $self->{+CHARACTER_SET_SERVER}, | ||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||
| 293 | # Modern mysqld/mariadbd refuse to run as root (EUID 0) unless | ||||||||||||||||||||||||||||||||||||||||||
| 294 | # explicitly told 'user=root'. QuickDB has no dedicated service | ||||||||||||||||||||||||||||||||||||||||||
| 295 | # account to drop to, so when we ARE root we tell the server to stay | ||||||||||||||||||||||||||||||||||||||||||
| 296 | # root -- this is exactly the documented override. Every server | ||||||||||||||||||||||||||||||||||||||||||
| 297 | # invocation (bootstrap/--initialize/start) reads this defaults file, | ||||||||||||||||||||||||||||||||||||||||||
| 298 | # so a single config entry covers them all. As a non-root user the | ||||||||||||||||||||||||||||||||||||||||||
| 299 | # option would be ignored with a warning, so only add it as root. | ||||||||||||||||||||||||||||||||||||||||||
| 300 | $self->_run_as_root ? ('user' => 'root') : (), | ||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||
| 302 | 2 | ▶ | defined($ENV{QDB_MYSQL_SSL_FIPS}) ? ('ssl_fips_mode' => "$ENV{QDB_MYSQL_SSL_FIPS}") : (), | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 303 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 304 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||
| 307 | 2 | ▶ | sub init { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=11 SCAR=29.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 308 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 309 | 2 | $self->SUPER::init(); | |||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||
| 311 | 2 | $self->dbd_driver; # Vivify this | |||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||
| 313 | 2 | ▶ | $self->{+CHARACTER_SET_SERVER} //= 'UTF8MB4'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"character_set_server"} //= "UTF8MB4"
MC/DC0%0/1
$self->{"character_set_server"} //= "UTF8MB4"
$self->{"character_set_server"}
Truth table50%1/2
A
A= $self->{"character_set_server"}
| |||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||
| 315 | 2 | $self->{+DATA_DIR} = $self->{+DIR} . '/data'; | |||||||||||||||||||||||||||||||||||||||||
| 316 | 2 | $self->{+TEMP_DIR} = $self->{+DIR} . '/temp'; | |||||||||||||||||||||||||||||||||||||||||
| 317 | 2 | $self->{+CFG_FILE} = $self->{+DIR} . '/my.cfg'; | |||||||||||||||||||||||||||||||||||||||||
| 318 | 2 | $self->{+PID_FILE} = $self->{+DIR} . '/mysql.pid'; | |||||||||||||||||||||||||||||||||||||||||
| 319 | 2 | ▶ | $self->{+SOCKET} ||= $self->{+DIR} . '/mysql.sock'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"socket"} ||= $self->{"dir"} . '/mysql.sock'
MC/DC0%0/1
$self->{"socket"} ||= $self->{"dir"} . '/mysql.sock'
$self->{"socket"}
Truth table50%1/2
A
A= $self->{"socket"}
| |||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||
| 321 | 2 | ▶ | $self->{+USERNAME} ||= 'root'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"username"} ||= "root"
MC/DC0%0/1
$self->{"username"} ||= "root"
$self->{"username"}
Truth table50%1/2
A
A= $self->{"username"}
| |||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||
| 323 | 2 | my %defaults = $self->_default_paths; | |||||||||||||||||||||||||||||||||||||||||
| 324 | 2 | ▶ | $self->{$_} ||= $defaults{$_} for keys %defaults; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{$_} ||= $defaults{$_}
MC/DC0%0/2
$self->{$_} ||= $defaults{$_}
$self->{$_}
$defaults{$_}
Truth table33%1/3
A ||= B
A= $self->{$_}B= $defaults{$_}
| |||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||
| 326 | 2 | my %cfg_defs = $self->_default_config; | |||||||||||||||||||||||||||||||||||||||||
| 327 | 2 | ▶ | my $cfg = { %{$self->{+CONFIG} || {}} }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{'config'} || {}
MC/DC0%0/1
$self->{'config'} || {}
$self->{'config'}
Truth table50%1/2
A
A= $self->{'config'}
| |||||||||||||||||||||||||||||||||||||||||||
| 328 | 2 | $self->{+CONFIG} = $cfg; | |||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||
| 330 | 2 | for my $key (keys %cfg_defs) { | |||||||||||||||||||||||||||||||||||||||||
| 331 | 14 | ▶ | if (defined $cfg->{$key}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | my $subdft = $cfg_defs{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | my $subcfg = { %{$cfg->{$key}} }; | |||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | $cfg->{$key} = $subcfg; | |||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | for my $skey (keys %$subdft) { | |||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | ▶ | next if defined $subcfg->{$skey}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | $subcfg->{$skey} = $subdft->{$skey}; | |||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||||||||||||
| 341 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 342 | 14 | $cfg->{$key} = $cfg_defs{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | ▶ | sub clone_data { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clone_data: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||
| 350 | my $config = strip_hash_defaults( | ||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | $self->{+CONFIG}, | |||||||||||||||||||||||||||||||||||||||||
| 352 | {$self->_default_config}, | ||||||||||||||||||||||||||||||||||||||||||
| 353 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||
| 355 | return ( | ||||||||||||||||||||||||||||||||||||||||||
| 356 | $self->SUPER::clone_data(), | ||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||
| 358 | CONFIG() => $config, | ||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | DBD_DRIVER() => $self->{+DBD_DRIVER}, | |||||||||||||||||||||||||||||||||||||||||
| 360 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||
| 363 | 2 | ▶ | sub write_config { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write_config: called CC=12 SCAR=24.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 364 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 365 | 2 | my (%params) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||
| 367 | 2 | my $cfg_file = $self->{+CFG_FILE}; | |||||||||||||||||||||||||||||||||||||||||
| 368 | 2 | ▶ | open(my $cfh, '>', $cfg_file) or die "Could not open config file: $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 369 | 2 | my $conf = $self->{+CONFIG}; | |||||||||||||||||||||||||||||||||||||||||
| 370 | 2 | for my $section (sort keys %$conf) { | |||||||||||||||||||||||||||||||||||||||||
| 371 | 14 | ▶ | my $override = $params{$section} // {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$params{$section} // {}
MC/DC100%1/1
$params{$section} // {}
$params{$section}
Truth table100%2/2
A
A= $params{$section}
| |||||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||
| 373 | 14 | ▶ | my $sconf = $conf->{$section} or next; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||
| 375 | 14 | ▶ | $sconf = { %$sconf, %{$override->{add}} } if $override->{add}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||
| 377 | 14 | print $cfh "[$section]\n"; | |||||||||||||||||||||||||||||||||||||||||
| 378 | 14 | for my $key (sort keys %$sconf) { | |||||||||||||||||||||||||||||||||||||||||
| 379 | 144 | my $val = $sconf->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 380 | 144 | ▶ | next unless defined $val; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||
| 382 | 144 | ▶ | next if $override->{skip} && ($key =~ $override->{skip} || $val =~ $override->{skip}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$override->{"skip"} and $key =~ /$override->{"skip"}/i || $val =~ /$override->{"skip"}/i
$key =~ /$override->{"skip"}/i or $val =~ /$override->{"skip"}/i
MC/DC100%3/3
$override->{"skip"} and $key =~ /$override->{"skip"}/i || $val =~ /$override->{"skip"}/i
$override->{"skip"}
$key =~ /$override->{"skip"}/i
$val =~ /$override->{"skip"}/i
Truth table100%4/4
A and B or C
A= $override->{"skip"}B= $key =~ /$override->{"skip"}/iC= $val =~ /$override->{"skip"}/i
| |||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||
| 384 | 132 | ▶ | if (length($val)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 385 | 128 | print $cfh "$key = $val\n"; | |||||||||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||||||||||
| 387 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 388 | 4 | print $cfh "$key\n"; | |||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||
| 392 | 14 | print $cfh "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||
| 394 | 2 | close($cfh); | |||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||
| 396 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||
| 399 | 1 | ▶ | sub bootstrap { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bootstrap: called CC=4 SCAR=14.1
| |||||||||||||||||||||||||||||||||||||||||||
| 400 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||
| 402 | 1 | my $data_dir = $self->{+DATA_DIR}; | |||||||||||||||||||||||||||||||||||||||||
| 403 | 1 | my $temp_dir = $self->{+TEMP_DIR}; | |||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||
| 405 | 1 | ▶ | mkdir($data_dir) or die "Could not create data dir: $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 406 | 1 | ▶ | mkdir($temp_dir) or die "Could not create temp dir: $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||
| 408 | 1 | my $init_file = "$self->{+DIR}/init.sql"; | |||||||||||||||||||||||||||||||||||||||||
| 409 | 1 | ▶ | open(my $init, '>', $init_file) or die "Could not open init file: $!"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 410 | 1 | print $init "DROP DATABASE IF EXISTS test;\n"; | |||||||||||||||||||||||||||||||||||||||||
| 411 | 1 | print $init "CREATE DATABASE quickdb;\n"; | |||||||||||||||||||||||||||||||||||||||||
| 412 | 1 | close($init); | |||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||
| 414 | 1 | return $init_file; | |||||||||||||||||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | ▶ | sub load_sql { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load_sql: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | my ($db_name, $file) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | my $cfg_file = $self->{+CFG_FILE}; | |||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | $self->run_command( | |||||||||||||||||||||||||||||||||||||||||
| 424 | [ | ||||||||||||||||||||||||||||||||||||||||||
| 425 | $self->client_bin, | ||||||||||||||||||||||||||||||||||||||||||
| 426 | "--defaults-file=$cfg_file", | ||||||||||||||||||||||||||||||||||||||||||
| 427 | '-u' => 'root', | ||||||||||||||||||||||||||||||||||||||||||
| 428 | $db_name, | ||||||||||||||||||||||||||||||||||||||||||
| 429 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 430 | {stdin => $file}, | ||||||||||||||||||||||||||||||||||||||||||
| 431 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | ▶ | sub shell_command { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
shell_command: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | my ($db_name) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | my $cfg_file = $self->{+CFG_FILE}; | |||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | return ($self->client_bin, "--defaults-file=$cfg_file", $db_name); | |||||||||||||||||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||
| 442 | 1 | ▶ | sub start_command { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
start_command: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 443 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||
| 445 | 1 | my $cfg_file = $self->{+CFG_FILE}; | |||||||||||||||||||||||||||||||||||||||||
| 446 | 1 | return ($self->server_bin, "--defaults-file=$cfg_file", '--skip-grant-tables'); | |||||||||||||||||||||||||||||||||||||||||
| 447 | } | ||||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||
| 449 | # The 'mysql' schema exists from install time; 'quickdb' may not yet (MySQL's | ||||||||||||||||||||||||||||||||||||||||||
| 450 | # --initialize bootstrap starts the server before loading the SQL creating it). | ||||||||||||||||||||||||||||||||||||||||||
| 451 | 2 | ▶ | sub start { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
start: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 452 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 453 | 2 | ▶ | return if $self->started; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||
| 455 | 1 | $self->SUPER::start(@_); | |||||||||||||||||||||||||||||||||||||||||
| 456 | 1 | $self->_wait_for_connect('mysql'); | |||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||
| 458 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | ▶ | sub connect_string { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
connect_string: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | my ($db_name) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | ▶ | $db_name = 'quickdb' unless defined $db_name; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | my $socket = $self->{+SOCKET}; | |||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | ▶ | if ($self->dbd_driver eq 'DBD::MariaDB') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | return "dbi:MariaDB:dbname=$db_name;mariadb_socket=$socket"; | |||||||||||||||||||||||||||||||||||||||||
| 470 | } | ||||||||||||||||||||||||||||||||||||||||||
| 471 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | return "dbi:mysql:dbname=$db_name;mysql_socket=$socket"; | |||||||||||||||||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||||||||||||||||
| 474 | } | ||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||
| 477 | 20 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||
| 479 | __END__ | ||||||||||||||||||||||||||||||||||||||||||