DBIx/QuickDB/Driver/MariaDB.pm

filter: Statementstmt 48.5% 34 / 70 Branchbran 16.6% 4 / 24 Conditioncond 0.0% 0 / 12 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 58.8% 10 / 17 Podpod 25.0% 2 / 8 totaltotal 35.9% 50 / 139 CC 17 SCAR 35.4
CC
17
Cov
36%
viable
76.1
verify_provider
12.0
_default_config
6.0
CRAP 34.3
« DBIx/QuickDB/Driver.pm ↑ Summary DBIx/QuickDB/Driver/PostgreSQL.pm »
1 package DBIx::QuickDB::Driver::MariaDB;
2 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 7 our $VERSION = '0.000047';
6  
7 7 ▶use IPC::Cmd qw/can_run/;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 7 ▶use Capture::Tiny qw/capture/;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 7 ▶use parent 'DBIx::QuickDB::Driver::MySQL';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 7 ▶use DBIx::QuickDB::Util::HashBase;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 13 ▶sub provider { 'MariaDB' }
Subroutine provider: called CC=1 SCAR=0.0
Pod undocumented
14  
15 sub verify_provider {
16 0 ▶ my $class = shift;
Subroutine verify_provider: not called CC=3 SCAR=24.8
Pod undocumented
17 0 my ($bin, $provider) = @_;
18  
19 0 ▶ $provider //= $class->provider;
Condition0%0/3
$provider //= $class->provider
l!l&&r!l&&!r
000
MC/DC0%0/2
$provider //= $class->provider
$provider $class->provider
Truth table0%0/3
A //= B
A= $providerB= $class->provider
ABresult
1X1
011
000
20  
21 0 ▶ my ($v, $stderr) = capture { system($bin, '-V') };
Subroutine __ANON__: not called CC=1 SCAR=6.9
22 0 ▶ return 1 if $v =~ m/$provider/i;
Branch: 1 branch
BranchTrueFalseTotal
if $v =~ /$provider/i 0 0 0
23 0 return 0;
24 }
25  
26 7 ▶sub server_bin_list { qw/mariadbd mysqld/ }
Subroutine server_bin_list: called CC=1 SCAR=0.0
Pod undocumented
27 0 ▶sub client_bin_list { qw/mariadb mysql/ }
Subroutine client_bin_list: not called CC=1 SCAR=6.9
Pod undocumented
28 0 ▶sub install_bin_list { qw/mariadb-install-db mysql_install_db/ }
Subroutine install_bin_list: not called CC=1 SCAR=6.9
Pod undocumented
29  
30 13 ▶sub dbd_driver_order { my $class = shift; $class->SUPER::dbd_driver_order($ENV{QDB_MARIADB_DBD}, $ENV{QDB_MYSQLD_DBD}) }
Subroutine dbd_driver_order: called CC=1 SCAR=0.0
Pod undocumented
31  
32 sub list_env_vars {
33 0 ▶ my $self = shift;
Subroutine list_env_vars: not called CC=1 SCAR=6.9
Pod documented
34  
35 0 my @list = $self->SUPER::list_env_vars();
36  
37 return (
38 @list,
39 0 map { my $x = "$_"; $x =~ s/MYSQL/MARIADB/g; $x } @list,
40 );
41 }
42  
43 sub _default_config {
44 0 ▶ my $self = shift;
Subroutine _default_config: not called CC=2 SCAR=17.9
45  
46 0 my %config = $self->SUPER::_default_config(@_);
47  
48 0 ▶ if (defined($ENV{QDB_MARIADB_SSL_FIPS})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ENV{"QDB_MARIADB_SSL_FIPS"}) 0 0 0
49 0 $config{mysqld}->{'ssl_fips_mode'} = "$ENV{QDB_MARIADB_SSL_FIPS}";
50 }
51  
52 0 $config{mysqld}->{'query_cache_limit'} = '1M';
53 0 $config{mysqld}->{'query_cache_size'} = '20M';
54  
55 0 $config{mariadbd} = $config{mysqld};
56 0 $config{mariadb} = $config{mysql};
57 0 $config{mariadb_safe} = $config{mysql_safe};
58  
59 0 return %config;
60 }
61  
62 sub viable {
63 13 ▶ my $this = shift;
Subroutine viable: called CC=14 SCAR=43.3
Pod documented
64 13 my ($spec) = @_;
65  
66 13 ▶ my %check = (ref($this) ? %$this : (), $this->_default_paths, %$spec);
Branch: 1 branch
BranchTrueFalseTotal
ref $this ? : 0 13 13
67  
68 13 my @bad;
69  
70 13 ▶ push @bad => "Could not load either 'DBD::MariaDB' or 'DBD::mysql', needed for everything"
Branch: 1 branch
BranchTrueFalseTotal
unless $this->dbd_driver 13 0 13
71 unless $this->dbd_driver;
72  
73 13 ▶ if (!keys %{$this->provider_info}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not keys %{$this->provider_info;}) { } 13 0 13
74 13 push @bad => "Installed MySQL is not " . $this->provider;
75 }
76 else {
77 0 ▶ if ($spec->{bootstrap}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($spec->{'bootstrap'}) { } 0 0 0
elsif ($spec->{'autostart'}) { } 0 0 0
78 0 ▶ push @bad => "'mysqld' and 'mariadbd' commands are 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
79 }
80 elsif ($spec->{autostart}) {
81 0 ▶ push @bad => "'mysqld' and 'mariadbd' commands are 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
82 }
83  
84 0 ▶ if ($spec->{load_sql}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($spec->{"load_sql"}) 0 0 0
85 0 ▶ push @bad => "'mysql' and 'mariadb' commands are 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
86 }
87 }
88  
89 13 ▶ return (1, undef) unless @bad;
Branch: 1 branch
BranchTrueFalseTotal
unless @bad 0 13 13
90 13 return (0, join "\n" => @bad);
91 }
92  
93 sub bootstrap {
94 0 ▶ my $self = shift;
Subroutine bootstrap: not called CC=1 SCAR=6.9
95  
96 0 my $init_file = $self->SUPER::bootstrap(@_);
97  
98 # Bootstrap is much faster without InnoDB, we will turn InnoDB back on later, and things will use it.
99 0 $self->write_config(
100 mariadbd => {
101 skip => qr/innodb/i,
102 add => {'default-storage-engine' => 'MyISAM'}
103 },
104 mysqld => {
105 skip => qr/innodb/i,
106 add => {'default-storage-engine' => 'MyISAM'}
107 }
108 );
109 0 $self->run_command([$self->start_command, '--bootstrap'], {stdin => $init_file});
110  
111 # Turn InnoDB back on
112 0 $self->write_config();
113  
114 0 return;
115 }
116  
117 7 1;
118  
119 __END__
« DBIx/QuickDB/Driver.pm ↑ Summary DBIx/QuickDB/Driver/PostgreSQL.pm »