| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
MC/DC0%0/2
$provider //= $class->provider
$provider
$class->provider
Truth table33%1/3
A //= B
A= $providerB= $class->provider
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | 6 | ▶ | return 0 if $v =~ m/MariaDB|Percona/i; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | 4 | ▶ | return $v =~ m/\bVer\s+\d/ ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | unless $this->dbd_driver; | ||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | 35 | ▶ | push @bad => $this->_watcher_unsupported_reason($spec) // (); | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$this->_watcher_unsupported_reason($spec) // ()
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= ()
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | 35 | ▶ | if (!keys %{$this->provider_info}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | 35 | push @bad => "Installed MySQL is not " . $this->provider; | |||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||
| 67 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | if ($spec->{bootstrap}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | push @bad => "'mysqld' command is missing, needed for bootstrap" unless $check{server} && -x $check{server}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$check{"server"} and -x $check{"server"}
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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition0%0/3
$check{"server"} and -x $check{"server"}
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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | if ($spec->{load_sql}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | push @bad => "'mysql' command is missing, needed for load_sql" unless $check{client} && -x $check{client}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$check{"client"} and -x $check{"client"}
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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | 35 | ▶ | if ($check{server}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | my $version = $this->version_string; | |||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | if ($version && $version =~ m/(\d+)\.(\d+)\.(\d+)/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$version and $version =~ /(\d+)\.(\d+)\.(\d+)/
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+)/
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition0%0/6
$a < 5 or $a == 5 and $b < 6
$a == 5 and $b < 6
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
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | if $a < 5 || ($a == 5 && $b < 6); | ||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | 35 | ▶ | return (1, undef) unless @bad; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | if ($self->{+USE_INSTALLDB}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||||||||||||||||