DBIx/QuickDB/Driver/MySQL.pm

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