blib/lib/Langertha/Holmgang/Sim/Linux/MariaDB.pm

filter: Statementstmt 85.1% 718 / 843 Branchbran 65.0% 414 / 636 Conditioncond 45.7% 268 / 586 MC/DCmcdc 19.2% 62 / 322 Subroutinesub 95.5% 43 / 45 Podpod 100% 6 / 6 totaltotal 61.9% 1511 / 2438 CC 593 SCAR 70.9
CC
593
Cov
68%
_statement
2836.8
client
639.9
_value
106.3
CRAP 1195.3
↑ Summary blib/lib/Langertha/Holmgang/Sim/Linux/Redis.pm »
1 package Langertha::Holmgang::Sim::Linux::MariaDB;
2 # ABSTRACT: MariaDB on a simulated Linux server — mysql/mariadb client, variables, users, binlogs, replica
3  
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use Digest::SHA ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use JSON::MaybeXS ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use Langertha::Holmgang::Sim::Linux ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 2 our $VERSION = '0.001';
13  
14  
15 2 our @GAPS;
16  
17 # Variablen: Vorgabe, dynamisch?, Art (int|size|bool|str|enum)
18 2 our %VAR = (
19 max_connections => [ '151', 1, 'int' ],
20 max_user_connections => [ '0', 1, 'int' ],
21 bind_address => [ '127.0.0.1', 0, 'str' ],
22 port => [ '3306', 0, 'int' ],
23 socket => [ '/run/mysqld/mysqld.sock', 0, 'str' ],
24 datadir => [ '/var/lib/mysql/', 0, 'str' ],
25 tmpdir => [ '/tmp', 0, 'str' ],
26 log_error => [ '', 0, 'str' ],
27 log_bin => [ 'OFF', 0, 'bool' ],
28 log_bin_basename => [ '', 0, 'str' ],
29 server_id => [ '1', 1, 'int' ],
30 expire_logs_days => [ '0.000000', 1, 'days' ],
31 binlog_expire_logs_seconds => [ '0', 1, 'int' ],
32 max_binlog_size => [ '1073741824', 1, 'size' ],
33 binlog_format => [ 'MIXED', 1, 'str' ],
34 innodb_buffer_pool_size => [ '134217728', 1, 'size' ],
35 innodb_log_file_size => [ '100663296', 0, 'size' ],
36 innodb_flush_log_at_trx_commit => [ '1', 1, 'int' ],
37 innodb_file_per_table => [ 'ON', 0, 'bool' ],
38 max_allowed_packet => [ '16777216', 1, 'size' ],
39 wait_timeout => [ '28800', 1, 'int' ],
40 interactive_timeout => [ '28800', 1, 'int' ],
41 slow_query_log => [ 'OFF', 1, 'bool' ],
42 slow_query_log_file => [ 'mariadb-slow.log', 1, 'str' ],
43 long_query_time => [ '10.000000', 1, 'float' ],
44 general_log => [ 'OFF', 1, 'bool' ],
45 character_set_server => [ 'utf8mb4', 1, 'str' ],
46 collation_server => [ 'utf8mb4_general_ci', 1, 'str' ],
47 sql_mode => [ 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION', 1, 'str' ],
48 read_only => [ 'OFF', 1, 'bool' ],
49 skip_name_resolve => [ 'OFF', 0, 'bool' ],
50 table_open_cache => [ '2000', 1, 'int' ],
51 thread_cache_size => [ '151', 1, 'int' ],
52 tmp_table_size => [ '16777216', 1, 'size' ],
53 max_heap_table_size => [ '16777216', 1, 'size' ],
54 open_files_limit => [ '32768', 0, 'int' ],
55 query_cache_size => [ '1048576', 1, 'size' ],
56 query_cache_type => [ 'OFF', 1, 'str' ],
57 relay_log => [ '', 0, 'str' ],
58 sql_slave_skip_counter => [ '0', 1, 'int' ],
59 slave_skip_errors => [ 'OFF', 0, 'str' ],
60 slave_parallel_threads => [ '0', 1, 'int' ],
61 slave_parallel_mode => [ 'optimistic', 1, 'str' ],
62 slave_parallel_max_queued => [ '131072', 1, 'int' ],
63 max_connect_errors => [ '100', 1, 'int' ],
64 version => [ '10.11.6-MariaDB-0+deb12u1-log', 0, 'ro' ],
65 );
66  
67 # Neue Namen (replica_*) sind in 10.11 Aliase der alten
68 2 our %VAR_ALIAS = ( replica_parallel_threads => 'slave_parallel_threads', replica_parallel_mode => 'slave_parallel_mode',
69 replica_parallel_max_queued => 'slave_parallel_max_queued' );
70  
71 87 ▶sub _norm_name { my ($n) = @_; $n = lc $n; $n =~ s/-/_/g; return $VAR_ALIAS{$n} // $n }
Subroutine _norm_name: called CC=2 SCAR=7.0
Condition66%2/3
$Langertha::Holmgang::Sim::Linux::MariaDB::VAR_ALIAS{$n} // $n
l!l&&r!l&&!r
1860
MC/DC0%0/2
$Langertha::Holmgang::Sim::Linux::MariaDB::VAR_ALIAS{$n} // $n
$Langertha::Holmgang::Sim::Linux::MariaDB::VAR_ALIAS{$n} $n
Truth table66%2/3
A // B
A= $Langertha::Holmgang::Sim::Linux::MariaDB::VAR_ALIAS{$n}B= $n
ABresult
1X1
011
000
72  
73 6 ▶sub _size {
Subroutine _size: called CC=4 SCAR=14.9
74 6 my ($v) = @_;
75 6 ▶ return undef unless defined $v && $v =~ /\A\s*(\d+)\s*([kmgt])?\s*\z/i;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $v and $v =~ /\A\s*(\d+)\s*([kmgt])?\s*\z/i 0 6 6
Condition33%1/3
defined $v and $v =~ /\A\s*(\d+)\s*([kmgt])?\s*\z/i
!ll&&!rl&&r
006
MC/DC0%0/2
defined $v and $v =~ /\A\s*(\d+)\s*([kmgt])?\s*\z/i
defined $v $v =~ /\A\s*(\d+)\s*([kmgt])?\s*\z/i
Truth table33%1/3
A and B
A= defined $vB= $v =~ /\A\s*(\d+)\s*([kmgt])?\s*\z/i
ABresult
0X0
100
111
76 6 ▶ return $1 * { '' => 1, k => 1024, m => 1024**2, g => 1024**3, t => 1024**4 }->{ lc( $2 // '' ) };
Condition100%2/2
$2 // ""
l!l
51
MC/DC100%1/1
$2 // ""
$2
Truth table100%2/2
A
A= $2
Aresult
11
00
77 }
78  
79 # Wert einer Variablen pruefen: ( normalisiert ) oder ( undef, fehler )
80 48 ▶sub _value {
Subroutine _value: called CC=19 SCAR=46.7
81 48 my ( $n, $v ) = @_;
82 48 my $kind = $VAR{$n}[2];
83 48 ▶ $v = '' unless defined $v;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $v 0 48 48
84 48 $v =~ s/\A(['"])(.*)\1\z/$2/;
85 48 ▶ if ( $kind eq 'size' ) { my $b = _size($v); return defined $b ? ("$b") : ( undef, "Incorrect argument type to variable '$n'" ) }
Branch: 2 branches
BranchTrueFalseTotal
if ($kind eq "size") 6 42 48
defined $b ? : 6 0 6
86 42 ▶ if ( $kind eq 'int' ) { return $v =~ /\A\d+\z/ ? ("$v") : ( undef, "Incorrect argument type to variable '$n'" ) }
Branch: 2 branches
BranchTrueFalseTotal
if ($kind eq "int") 21 21 42
$v =~ /\A\d+\z/ ? : 21 0 21
87 0 ▶ if ( $kind eq 'float' ) { return $v =~ /\A\d+(?:\.\d+)?\z/ ? ( sprintf '%.6f', $v ) : ( undef, "Incorrect argument type to variable '$n'" ) }
Branch: 2 branches
BranchTrueFalseTotal
if ($kind eq "float") 0 21 21
$v =~ /\A\d+(?:\.\d+)?\z/ ? : 0 0 0
88 0 ▶ if ( $kind eq 'days' ) { return $v =~ /\A\d+(?:\.\d+)?\z/ ? ( sprintf '%.6f', $v ) : ( undef, "Incorrect argument type to variable '$n'" ) }
Branch: 2 branches
BranchTrueFalseTotal
if ($kind eq "days") 0 21 21
$v =~ /\A\d+(?:\.\d+)?\z/ ? : 0 0 0
89 21 ▶ if ( $kind eq 'bool' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "bool") 0 21 21
90 0 my $x = uc $v;
91 0 ▶ return ('ON') if $x eq '' || $x eq 'ON' || $x eq '1' || $x eq 'TRUE';
Branch: 1 branch
BranchTrueFalseTotal
if $x eq "" or $x eq "ON" or $x eq 1 or $x eq "TRUE" 0 0 0
Condition0%0/9
$x eq "" or $x eq "ON" or $x eq 1 or $x eq "TRUE"
l!l&&r!l&&!r
000
$x eq "" or $x eq "ON" or $x eq 1
l!l&&r!l&&!r
000
$x eq "" or $x eq "ON"
l!l&&r!l&&!r
000
MC/DC0%0/4
$x eq "" or $x eq "ON" or $x eq 1 or $x eq "TRUE"
$x eq "" $x eq "ON" $x eq 1 $x eq "TRUE"
Truth table0%0/5
A or B or C or D
A= $x eq ""B= $x eq "ON"C= $x eq 1D= $x eq "TRUE"
ABCDresult
1XXX1
01XX1
001X1
00011
00000
92 0 ▶ return ('OFF') if $x eq 'OFF' || $x eq '0' || $x eq 'FALSE';
Branch: 1 branch
BranchTrueFalseTotal
if $x eq "OFF" or $x eq 0 or $x eq "FALSE" 0 0 0
Condition0%0/6
$x eq "OFF" or $x eq 0 or $x eq "FALSE"
l!l&&r!l&&!r
000
$x eq "OFF" or $x eq 0
l!l&&r!l&&!r
000
MC/DC0%0/3
$x eq "OFF" or $x eq 0 or $x eq "FALSE"
$x eq "OFF" $x eq 0 $x eq "FALSE"
Truth table0%0/4
A or B or C
A= $x eq "OFF"B= $x eq 0C= $x eq "FALSE"
ABCresult
1XX1
01X1
0011
0000
93 0 ▶ return ( 'ON' ) if $n eq 'log_bin'; # log_bin = name
Branch: 1 branch
BranchTrueFalseTotal
if $n eq "log_bin" 0 0 0
94 0 return ( undef, "Variable '$n' can't be set to the value of '$v'" );
95 }
96 21 return ($v);
97 }
98  
99 18 ▶sub _file_text {
Subroutine _file_text: called CC=5 SCAR=19.2
100 18 my ( $dev, $p ) = @_;
101 18 ▶ my $e = ( $dev->{files} || {} )->{$p};
Condition50%1/2
$$dev{'files'} || {}
l!l
180
MC/DC0%0/1
$$dev{'files'} || {}
$$dev{'files'}
Truth table50%1/2
A
A= $$dev{'files'}
Aresult
11
00
102 18 ▶ return undef unless defined $e;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $e 0 18 18
103 18 ▶ return ref $e eq 'HASH' ? $e->{content} // '' : $e;
Branch: 1 branch
BranchTrueFalseTotal
ref $e eq 'HASH' ? : 0 18 18
Condition0%0/2
$$e{"content"} // ""
l!l
00
MC/DC0%0/1
$$e{"content"} // ""
$$e{"content"}
Truth table0%0/2
A
A= $$e{"content"}
Aresult
11
00
104 }
105  
106 18 ▶sub _conf_files { my ($dev) = @_; my $c = $dev->{mariadb}{conf} // ['/etc/mysql/mariadb.conf.d/50-server.cnf']; return ref $c ? @$c : ($c) }
Subroutine _conf_files: called CC=3 SCAR=11.7
Branch: 1 branch
BranchTrueFalseTotal
ref $c ? : 18 0 18
Condition50%1/2
$$dev{"mariadb"}{"conf"} // ["/etc/mysql/mariadb.conf.d/50-server.cnf"]
l!l
180
MC/DC0%0/1
$$dev{"mariadb"}{"conf"} // ["/etc/mysql/mariadb.conf.d/50-server.cnf"]
$$dev{"mariadb"}{"conf"}
Truth table50%1/2
A
A= $$dev{"mariadb"}{"conf"}
Aresult
11
00
107  
108  
109 18 ▶sub parse_conf {
Subroutine parse_conf: called CC=18 SCAR=30.0
Pod documented
110 18 my ($dev) = @_;
111 18 my %v = map { $_ => $VAR{$_}[0] } keys %VAR;
112 18 for my $f ( _conf_files($dev) ) {
113 18 ▶ my $t = _file_text( $dev, $f ) // next;
Condition50%1/2
_file_text($dev, $f) // (next)
l!l
180
MC/DC0%0/1
_file_text($dev, $f) // (next)
_file_text($dev, $f)
Truth table50%1/2
A
A= _file_text($dev, $f)
Aresult
11
00
114 18 my $sec = '';
115 18 for my $line ( split /\n/, $t ) {
116 135 ▶ next if $line =~ /\A\s*(?:[#;]|\z)/;
Branch: 1 branch
BranchTrueFalseTotal
if $line =~ /\A\s*(?:[#;]|\z)/ 18 117 135
117 117 ▶ if ( $line =~ /\A\s*\[([^\]]+)\]/ ) { $sec = lc $1; next }
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /\A\s*\[([^\]]+)\]/) 36 81 117
118 81 ▶ next unless $sec =~ /\A(?:mysqld|mariadb|server|mariadbd|mariadb-10\.11)\z/;
Branch: 1 branch
BranchTrueFalseTotal
unless $sec =~ /\A(?:mysqld|mariadb|server|mariadbd|mariadb-10\.11)\z/ 0 81 81
119 81 ▶ my ( $k, $val ) = $line =~ /\A\s*([\w-]+)\s*(?:=\s*(.*?))?\s*\z/ or return ( undef, $f, $line, 'syntax' );
Branch: 1 branch
BranchTrueFalseTotal
() = $line =~ /\A\s*([\w-]+)\s*(?:=\s*(.*?))?\s*\z/ or return undef, $f, $line, "syntax" 81 0 81
120 81 $k = _norm_name($k);
121 81 ▶ $k = 'log_bin' if $k eq 'log_bin';
Branch: 1 branch
BranchTrueFalseTotal
if $k eq "log_bin" 18 63 81
122 81 ▶ if ( $k eq 'log_bin' ) { $v{log_bin} = 'ON'; $v{log_bin_basename} = '/var/lib/mysql/' . ( $val // 'mysqld-bin' ) =~ s{.*/}{}r =~ s/\.\w+\z//r; next }
Branch: 1 branch
BranchTrueFalseTotal
if ($k eq "log_bin") 18 63 81
Condition50%1/2
$val // "mysqld-bin"
l!l
180
MC/DC0%0/1
$val // "mysqld-bin"
$val
Truth table50%1/2
A
A= $val
Aresult
11
00
123 63 ▶ next if $k =~ /\A(?:user|pid_file|basedir|lc_messages_dir|lc_messages|expire_logs|skip_external_locking|log_slave_updates|log_replica_updates|innodb_buffer_pool_instances|key_buffer_size|myisam_recover_options)\z/;
Branch: 1 branch
BranchTrueFalseTotal
if $k =~ /\A(?:user|pid_file|basedir|lc_messages_dir|lc_messages|expire_logs|skip_external_locking|log_slave_updates|log_replica_updates|innodb_buffer_pool_instances|key_buffer_size|myisam_recover_options)\z/ 18 45 63
124 45 ▶ return ( undef, $f, $line, "unknown variable '" . ( $line =~ s/\A\s+|\s+\z//gr =~ s/\s*=\s*/=/r ) . "'" ) unless exists $VAR{$k} && $VAR{$k}[2] ne 'ro';
Branch: 1 branch
BranchTrueFalseTotal
unless exists $Langertha::Holmgang::Sim::Linux::MariaDB::VAR{$k} and $Langertha::Holmgang::Sim::Linux::MariaDB::VAR{$k}[2] ne "ro" 1 44 45
Condition66%2/3
exists $Langertha::Holmgang::Sim::Linux::MariaDB::VAR{$k} and $Langertha::Holmgang::Sim::Linux::MariaDB::VAR{$k}[2] ne "ro"
!ll&&!rl&&r
1044
MC/DC50%1/2
exists $Langertha::Holmgang::Sim::Linux::MariaDB::VAR{$k} and $Langertha::Holmgang::Sim::Linux::MariaDB::VAR{$k}[2] ne "ro"
exists $Langertha::Holmgang::Sim::Linux::MariaDB::VAR{$k} $Langertha::Holmgang::Sim::Linux::MariaDB::VAR{$k}[2] ne "ro"
Truth table66%2/3
A and B
A= exists $Langertha::Holmgang::Sim::Linux::MariaDB::VAR{$k}B= $Langertha::Holmgang::Sim::Linux::MariaDB::VAR{$k}[2] ne "ro"
ABresult
0X0
100
111
125 44 my ( $x, $e ) = _value( $k, $val );
126 44 ▶ return ( undef, $f, $line, "Error while setting value '" . ( $val // '' ) . "' to '$k'" ) unless defined $x;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $x 0 44 44
Condition0%0/2
$val // ""
l!l
00
MC/DC0%0/1
$val // ""
$val
Truth table0%0/2
A
A= $val
Aresult
11
00
127 44 $v{$k} = $x;
128 }
129 }
130 17 ▶ { my ( $s, $d ) = ( "$v{binlog_expire_logs_seconds}", "$v{expire_logs_days}" ); $v{expire_logs_days} = sprintf "%.6f", $s / 86400 if $s && $d == 0 } # Kopien: Zahlenkontext aendert die JSON-Form nicht
Branch: 1 branch
BranchTrueFalseTotal
if $s and $d == 0 0 17 17
Condition33%1/3
$s and $d == 0
!ll&&!rl&&r
1700
MC/DC0%0/2
$s and $d == 0
$s $d == 0
Truth table33%1/3
A and B
A= $sB= $d == 0
ABresult
0X0
100
111
131 17 return ( \%v );
132 }
133  
134  
135 5 ▶sub conf_error {
Subroutine conf_error: called CC=13 SCAR=27.0
Pod documented
136 5 my ($dev) = @_;
137 5 ▶ return undef unless $dev->{mariadb};
Branch: 1 branch
BranchTrueFalseTotal
unless $$dev{"mariadb"} 0 5 5
138 5 my ( $v, $f, $line, $why ) = parse_conf($dev);
139 5 ▶ if ($v) {
Branch: 1 branch
BranchTrueFalseTotal
if ($v) 4 1 5
140 # tmpdir muss fuer mysql schreibbar sein (Verzeichnis im Zustand: Eigentuemer, Gruppe, Rechte)
141 4 ▶ ( my $t = $v->{tmpdir} // '/tmp' ) =~ s{(?<=.)/+\z}{};
Condition50%1/2
$$v{"tmpdir"} // "/tmp"
l!l
40
MC/DC0%0/1
$$v{"tmpdir"} // "/tmp"
$$v{"tmpdir"}
Truth table50%1/2
A
A= $$v{"tmpdir"}
Aresult
11
00
142 4 ▶ my $d = ( $dev->{dirs} || {} )->{$t} or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $d = ($$dev{"dirs"} || {})->{$t} or return undef 2 2 4
Condition100%2/2
$$dev{'dirs'} || {}
l!l
22
MC/DC100%1/1
$$dev{'dirs'} || {}
$$dev{'dirs'}
Truth table100%2/2
A
A= $$dev{'dirs'}
Aresult
11
00
143 2 ▶ my $m = oct( $d->{mode} // '0755' );
Condition50%1/2
$$d{"mode"} // "0755"
l!l
20
MC/DC0%0/1
$$d{"mode"} // "0755"
$$d{"mode"}
Truth table50%1/2
A
A= $$d{"mode"}
Aresult
11
00
144 2 ▶ my $u = ( $d->{owner} // 'root' ) eq 'mysql' ? $m & 0200 : ( $d->{group} // 'root' ) eq 'mysql' ? $m & 020 : $m & 002;
Branch: 2 branches
BranchTrueFalseTotal
($$d{'owner'} // 'root') eq 'mysql' ? : 1 1 2
($$d{'group'} // 'root') eq 'mysql' ? : 0 1 1
Condition50%2/4
$$d{"owner"} // "root"
l!l
20
$$d{"group"} // "root"
l!l
10
MC/DC0%0/1
$$d{"owner"} // "root"
$$d{"owner"}
MC/DC0%0/1
$$d{"group"} // "root"
$$d{"group"}
Truth table50%1/2
A
A= $$d{"owner"}
Aresult
11
00
Truth table50%1/2
A
A= $$d{"group"}
Aresult
11
00
145 2 ▶ return undef if $u;
Branch: 1 branch
BranchTrueFalseTotal
if $u 1 1 2
146 1 return [ "[ERROR] mariadbd: Can't create/write to file '$t/ibXXXXXX' (Errcode: 13 \"Permission denied\")",
147 '[ERROR] InnoDB: Unable to create temporary file; errno: 13', '[ERROR] Aborting' ];
148 }
149 1 ▶ return [ "[ERROR] /usr/sbin/mariadbd: $why", '[ERROR] Aborting' ] if $why =~ /\Aunknown variable/;
Branch: 1 branch
BranchTrueFalseTotal
if $why =~ /\Aunknown variable/ 1 0 1
150 0 return [ "[ERROR] mariadbd: $why ($f)", '[ERROR] Aborting' ];
151 }
152  
153 121 ▶sub _vars {
Subroutine _vars: called CC=3 SCAR=11.2
154 121 my ($dev) = @_;
155 121 my $m = $dev->{mariadb};
156 0 ▶ if ( !$m->{variables} ) { my ($v) = parse_conf($dev); $m->{variables} = $v // { map { $_ => $VAR{$_}[0] } keys %VAR } }
Branch: 1 branch
BranchTrueFalseTotal
unless ($$m{"variables"}) 10 111 121
Condition50%1/2
$v // {map({$_, $Langertha::Holmgang::Sim::Linux::MariaDB::VAR{$_}[0];} keys %Langertha::Holmgang::Sim::Linux::MariaDB::VAR)}
l!l
100
MC/DC0%0/1
$v // {map({$_, $Langertha::Holmgang::Sim::Linux::MariaDB::VAR{$_}[0];} keys %Langertha::Holmgang::Sim::Linux::MariaDB::VAR)}
$v
Truth table50%1/2
A
A= $v
Aresult
11
00
157 121 return $m->{variables};
158 }
159  
160  
161 5 ▶sub service_event {
Subroutine service_event: called CC=12 SCAR=27.2
Pod documented
162 5 my ( $dev, $verb ) = @_;
163 5 ▶ my $m = $dev->{mariadb} or return;
Branch: 1 branch
BranchTrueFalseTotal
my $m = $$dev{"mariadb"} or return 5 0 5
164 5 ▶ if ( $verb eq 'start' || $verb eq 'restart' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($verb eq "start" or $verb eq "restart") 3 2 5
Condition100%3/3
$verb eq "start" or $verb eq "restart"
l!l&&r!l&&!r
212
MC/DC100%2/2
$verb eq "start" or $verb eq "restart"
$verb eq "start" $verb eq "restart"
Truth table100%3/3
A or B
A= $verb eq "start"B= $verb eq "restart"
ABresult
1X1
011
000
165 3 my ($v) = parse_conf($dev);
166 3 ▶ $m->{variables} = $v if $v;
Branch: 1 branch
BranchTrueFalseTotal
if $v 3 0 3
167 # Verbindungen sind weg; die Anwendungen verbinden sich neu (einmal je Eintrag)
168 3 ▶ if ( $m->{processlist} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$m{"processlist"}) 3 0 3
169 3 ▶ my @p = map { +{ %$_, count => 1, time => 0 } } grep { ( $_->{user} // '' ) ne 'system user' } @{ $m->{processlist} };
Condition50%1/2
$$_{"user"} // ""
l!l
30
MC/DC0%0/1
$$_{"user"} // ""
$$_{"user"}
Truth table50%1/2
A
A= $$_{"user"}
Aresult
11
00
170 3 $m->{processlist} = \@p;
171 3 my $n = 0;
172 3 ▶ $n += $_->{count} // 1 for @p;
Condition50%1/2
$$_{"count"} // 1
l!l
30
MC/DC0%0/1
$$_{"count"} // 1
$$_{"count"}
Truth table50%1/2
A
A= $$_{"count"}
Aresult
11
00
173 3 ▶ $m->{status}{Threads_connected} = $n if $m->{status};
Branch: 1 branch
BranchTrueFalseTotal
if $$m{"status"} 3 0 3
174 }
175 0 ▶ if ( my $r = $m->{replica} ) { $r->{io} = 'Yes'; $r->{sql} = $r->{last_errno} ? 'No' : 'Yes' }
Branch: 2 branches
BranchTrueFalseTotal
if (my $r = $$m{"replica"}) 0 3 3
$$r{'last_errno'} ? : 0 0 0
176 }
177 5 return;
178 }
179  
180 63 ▶sub _active {
Subroutine _active: called CC=5 SCAR=16.8
181 63 my ($dev) = @_;
182 63 ▶ my $svc = ( $dev->{services} || {} )->{ $dev->{mariadb}{service} // 'mariadb' };
Condition50%2/4
$$dev{'services'} || {}
l!l
630
$$dev{"mariadb"}{"service"} // "mariadb"
l!l
630
MC/DC0%0/1
$$dev{'services'} || {}
$$dev{'services'}
MC/DC0%0/1
$$dev{"mariadb"}{"service"} // "mariadb"
$$dev{"mariadb"}{"service"}
Truth table50%1/2
A
A= $$dev{'services'}
Aresult
11
00
Truth table50%1/2
A
A= $$dev{"mariadb"}{"service"}
Aresult
11
00
183 63 ▶ return $svc && $svc->{active} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$svc && $$svc{'active'} ? : 62 1 63
Condition66%2/3
$svc and $$svc{"active"}
!ll&&!rl&&r
0162
MC/DC50%1/2
$svc and $$svc{"active"}
$svc $$svc{"active"}
Truth table66%2/3
A and B
A= $svcB= $$svc{"active"}
ABresult
0X0
100
111
184 }
185  
186 # --- Ausgabe ---------------------------------------------------------------------
187  
188 35 ▶sub _render {
Subroutine _render: called CC=15 SCAR=36.4
189 35 my ( $o, $cols, $rows ) = @_;
190 35 ▶ if ( $o->{vertical} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$o{"vertical"}) 3 32 35
191 3 my $w = 0;
192 3 ▶ $w = length > $w ? length : $w for @$cols;
Branch: 1 branch
BranchTrueFalseTotal
length $_ > $w ? : 12 48 60
193 3 my @l;
194 3 my $i = 0;
195 3 for my $r (@$rows) {
196 3 $i++;
197 3 push @l, ( '*' x 27 ) . " $i. row " . ( '*' x 27 );
198 3 ▶ push @l, sprintf( "%*s: %s", $w, $cols->[$_], $r->[$_] // 'NULL' ) for 0 .. $#$cols;
Condition50%1/2
$$r[$_] // "NULL"
l!l
600
MC/DC0%0/1
$$r[$_] // "NULL"
$$r[$_]
Truth table50%1/2
A
A= $$r[$_]
Aresult
11
00
199 }
200 3 return join "\n", @l;
201 }
202 32 ▶ if ( $o->{table} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$o{"table"}) 0 32 32
203 0 my @w = map { length $_ } @$cols;
204 0 ▶ for my $r (@$rows) { for my $i ( 0 .. $#$cols ) { my $l = length( $r->[$i] // 'NULL' ); $w[$i] = $l if $l > $w[$i] } }
Branch: 1 branch
BranchTrueFalseTotal
if $l > $w[$i] 0 0 0
Condition0%0/2
$$r[$i] // "NULL"
l!l
00
MC/DC0%0/1
$$r[$i] // "NULL"
$$r[$i]
Truth table0%0/2
A
A= $$r[$i]
Aresult
11
00
205 0 my $sep = '+' . join( '+', map { '-' x ( $_ + 2 ) } @w ) . '+';
206 0 ▶ my $fmt = sub { my @v = @_; '| ' . join( ' | ', map { sprintf '%-*s', $w[$_], $v[$_] // 'NULL' } 0 .. $#w ) . ' |' };
Subroutine __ANON__: not called CC=2 SCAR=17.9
Condition0%0/2
$v[$_] // "NULL"
l!l
00
MC/DC0%0/1
$v[$_] // "NULL"
$v[$_]
Truth table0%0/2
A
A= $v[$_]
Aresult
11
00
207 0 return join "\n", $sep, $fmt->(@$cols), $sep, ( map { $fmt->(@$_) } @$rows ), $sep;
208 }
209 32 my @l;
210 32 ▶ push @l, join "\t", @$cols unless $o->{skip_names};
Branch: 1 branch
BranchTrueFalseTotal
unless $$o{"skip_names"} 9 23 32
211 32 ▶ push @l, join "\t", map { $_ // 'NULL' } @$_ for @$rows;
Condition50%1/2
$_ // "NULL"
l!l
710
MC/DC0%0/1
$_ // "NULL"
$_
Truth table50%1/2
A
A= $_
Aresult
11
00
212 32 return join "\n", @l;
213 }
214  
215 8 ▶sub _like {
Subroutine _like: called CC=4 SCAR=13.9
216 8 my ($pat) = @_;
217 8 ▶ return undef unless defined $pat;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $pat 1 7 8
218 7 $pat =~ s/\A['"]|['"]\z//g;
219 7 ▶ my $re = join '', map { $_ eq '%' ? '.*' : $_ eq '_' ? '.' : quotemeta $_ } split //, $pat;
Branch: 2 branches
BranchTrueFalseTotal
$_ eq '%' ? : 6 29 35
$_ eq '_' ? : 1 28 29
220 7 return qr/\A$re\z/i;
221 }
222  
223 # --- Benutzer und Rechte -------------------------------------------------------------
224  
225 9 ▶sub _account {
Subroutine _account: called CC=3 SCAR=11.4
226 9 my ($s) = @_; # 'u'@'h' | u@h | `u`@`h` | 'u'
227 9 $s =~ s/\s+//g;
228 9 ▶ my ( $u, $h ) = $s =~ /\A['"`]?([^'"`@]*)['"`]?(?:@['"`]?([^'"`]*)['"`]?)?\z/ or return;
Branch: 1 branch
BranchTrueFalseTotal
() = $s =~ /\A['"`]?([^'"`\@]*)['"`]?(?:\@['"`]?([^'"`]*)['"`]?)?\z/ or return 9 0 9
229 9 ▶ return ( $u, $h // '%' );
Condition50%1/2
$h // "%"
l!l
90
MC/DC0%0/1
$h // "%"
$h
Truth table50%1/2
A
A= $h
Aresult
11
00
230 }
231  
232 10 ▶sub _host_match {
Subroutine _host_match: called CC=9 SCAR=25.5
233 10 my ( $pat, $host ) = @_;
234 10 ▶ return 1 if $pat eq '%';
Branch: 1 branch
BranchTrueFalseTotal
if $pat eq "%" 0 10 10
235 10 ▶ return 1 if $pat eq $host;
Branch: 1 branch
BranchTrueFalseTotal
if $pat eq $host 5 5 10
236 5 ▶ return 1 if $pat eq 'localhost' && ( $host eq 'localhost' || $host eq '127.0.0.1' );
Branch: 1 branch
BranchTrueFalseTotal
if $pat eq "localhost" and $host eq "localhost" || $host eq "127.0.0.1" 0 5 5
Condition16%1/6
$pat eq "localhost" and $host eq "localhost" || $host eq "127.0.0.1"
!ll&&!rl&&r
500
$host eq "localhost" or $host eq "127.0.0.1"
l!l&&r!l&&!r
000
MC/DC0%0/3
$pat eq "localhost" and $host eq "localhost" || $host eq "127.0.0.1"
$pat eq "localhost" $host eq "localhost" $host eq "127.0.0.1"
Truth table25%1/4
A and B or C
A= $pat eq "localhost"B= $host eq "localhost"C= $host eq "127.0.0.1"
ABCresult
0XX0
1000
11X1
1011
237 5 ▶ my $re = join '', map { $_ eq '%' ? '.*' : $_ eq '_' ? '.' : quotemeta $_ } split //, $pat;
Branch: 2 branches
BranchTrueFalseTotal
$_ eq '%' ? : 5 40 45
$_ eq '_' ? : 0 40 40
238 5 ▶ return $host =~ /\A$re\z/ ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$host =~ /\A$re\z/ ? : 0 5 5
239 }
240  
241 # bestes Konto fuer user@host (genauester Host zuerst)
242 5 ▶sub _find_account {
Subroutine _find_account: called CC=4 SCAR=15.0
243 5 my ( $m, $user, $host ) = @_;
244 5 ▶ my @c = grep { my ( $u, $h ) = split /@/, $_, 2; $u eq $user && _host_match( $h, $host ) } keys %{ $m->{users} || {} };
Condition80%4/5
$u eq $user && _host_match($h, $host)
!ll&&!rl&&r
555
$$m{'users'} || {}
l!l
50
MC/DC100%2/2
$u eq $user && _host_match($h, $host)
$u eq $user _host_match($h, $host)
MC/DC0%0/1
$$m{'users'} || {}
$$m{'users'}
Truth table100%3/3
A && B
A= $u eq $userB= _host_match($h, $host)
ABresult
0X0
100
111
Truth table50%1/2
A
A= $$m{'users'}
Aresult
11
00
245 0 ▶ my ($best) = sort { ( ( split /@/, $a, 2 )[1] =~ tr/%_// ) <=> ( ( split /@/, $b, 2 )[1] =~ tr/%_// ) || length( $b ) <=> length( $a ) } @c;
Condition0%0/3
(split(/@/, $a, 2))[1] =~ tr/%_// <=> (split(/@/, $b, 2))[1] =~ tr/%_// || length $b <=> length $a
l!l&&r!l&&!r
000
MC/DC0%0/2
(split(/@/, $a, 2))[1] =~ tr/%_// <=> (split(/@/, $b, 2))[1] =~ tr/%_// || length $b <=> length $a
(split(/@/, $a, 2))[1] =~ tr/%_// <=> (split(/@/, $b, 2))[1] =~ tr/%_// length $b <=> length $a
Truth table0%0/3
A || B
A= (split(/@/, $a, 2))[1] =~ tr/%_// <=> (split(/@/, $b, 2))[1] =~ tr/%_//B= length $b <=> length $a
ABresult
1X1
011
000
246 5 return $best;
247 }
248  
249 # mysql_native_password: '*' . SHA1(SHA1(passwort)) in Grossbuchstaben
250 29 ▶sub _pwhash { my ($pw) = @_; return '*' . uc Digest::SHA::sha1_hex( Digest::SHA::sha1( $pw // '' ) ) }
Subroutine _pwhash: called CC=2 SCAR=7.2
Condition50%1/2
$pw // ""
l!l
290
MC/DC0%0/1
$pw // ""
$pw
Truth table50%1/2
A
A= $pw
Aresult
11
00
251  
252 # Klartext zu einem Hash aus den bekannten Konten (IDENTIFIED BY PASSWORD '*…'), sonst undef
253 1 ▶sub _pw_from_hash {
Subroutine _pw_from_hash: called CC=7 SCAR=24.2
254 1 my ( $m, $hash ) = @_;
255 1 ▶ return undef unless defined $hash && $hash =~ /\A\*[0-9A-Fa-f]{40}\z/;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $hash and $hash =~ /\A\*[0-9A-Fa-f]{40}\z/ 0 1 1
Condition33%1/3
defined $hash and $hash =~ /\A\*[0-9A-Fa-f]{40}\z/
!ll&&!rl&&r
001
MC/DC0%0/2
defined $hash and $hash =~ /\A\*[0-9A-Fa-f]{40}\z/
defined $hash $hash =~ /\A\*[0-9A-Fa-f]{40}\z/
Truth table33%1/3
A and B
A= defined $hashB= $hash =~ /\A\*[0-9A-Fa-f]{40}\z/
ABresult
0X0
100
111
256 1 ▶ for my $a ( values %{ $m->{users} || {} } ) {
Condition50%1/2
$$m{'users'} || {}
l!l
10
MC/DC0%0/1
$$m{'users'} || {}
$$m{'users'}
Truth table50%1/2
A
A= $$m{'users'}
Aresult
11
00
257 1 ▶ return $a->{password} if defined $a->{password} && _pwhash( $a->{password} ) eq uc $hash;
Branch: 1 branch
BranchTrueFalseTotal
if defined $$a{"password"} and _pwhash($$a{"password"}) eq uc $hash 1 0 1
Condition33%1/3
defined $$a{"password"} and _pwhash($$a{"password"}) eq uc $hash
!ll&&!rl&&r
001
MC/DC0%0/2
defined $$a{"password"} and _pwhash($$a{"password"}) eq uc $hash
defined $$a{"password"} _pwhash($$a{"password"}) eq uc $hash
Truth table33%1/3
A and B
A= defined $$a{"password"}B= _pwhash($$a{"password"}) eq uc $hash
ABresult
0X0
100
111
258 }
259 0 return undef;
260 }
261  
262 18 ▶sub _norm_obj {
Subroutine _norm_obj: called CC=4 SCAR=14.5
263 18 my ($o) = @_;
264 18 $o =~ s/\s+//g;
265 18 $o =~ s/[`'"]//g;
266 18 my ( $db, $t ) = split /\./, $o, 2;
267 18 ▶ $t //= '*';
Condition50%1/2
$t //= "*"
l!l
180
MC/DC0%0/1
$t //= "*"
$t
Truth table50%1/2
A
A= $t
Aresult
11
00
268 18 ▶ return ( $db eq '*' ? '*' : "`$db`" ) . '.' . ( $t eq '*' ? '*' : "`$t`" );
Branch: 2 branches
BranchTrueFalseTotal
$db eq '*' ? : 0 18 18
$t eq '*' ? : 18 0 18
269 }
270  
271 2 our @PRIV_ORDER = ( 'SELECT', 'INSERT', 'UPDATE', 'DELETE', 'CREATE', 'DROP', 'RELOAD', 'SHUTDOWN', 'PROCESS', 'FILE', 'REFERENCES', 'INDEX', 'ALTER',
272 'SHOW DATABASES', 'SUPER', 'CREATE TEMPORARY TABLES', 'LOCK TABLES', 'EXECUTE', 'REPLICATION SLAVE', 'BINLOG MONITOR', 'CREATE VIEW', 'SHOW VIEW',
273 'CREATE ROUTINE', 'ALTER ROUTINE', 'CREATE USER', 'EVENT', 'TRIGGER', 'REPLICATION CLIENT', 'SLAVE MONITOR' );
274  
275 # Spalten von mysql.db
276 2 our @DB_PRIVS = ( 'SELECT', 'INSERT', 'UPDATE', 'DELETE', 'CREATE', 'DROP', 'REFERENCES', 'INDEX', 'ALTER', 'CREATE TEMPORARY TABLES',
277 'LOCK TABLES', 'CREATE VIEW', 'SHOW VIEW', 'CREATE ROUTINE', 'ALTER ROUTINE', 'EXECUTE', 'EVENT', 'TRIGGER' );
278 2 our %DB_PRIV = ( map { my $x = lc $_; $x =~ s/ /_/g; $_ => ucfirst($x) . '_priv' } @DB_PRIVS );
279 2 $DB_PRIV{'CREATE TEMPORARY TABLES'} = 'Create_tmp_table_priv';
280  
281 20 ▶sub _priv_list {
Subroutine _priv_list: called CC=6 SCAR=18.4
282 20 my ($s) = @_;
283 20 my @p = map { my $x = uc $_; $x =~ s/\s+/ /g; $x =~ s/\A\s|\s\z//g; $x } split /,/, $s;
284 20 ▶ return ('ALL PRIVILEGES') if grep { $_ eq 'ALL' || $_ eq 'ALL PRIVILEGES' } @p;
Branch: 1 branch
BranchTrueFalseTotal
if grep {$_ eq "ALL" or $_ eq "ALL PRIVILEGES";} @p 11 9 20
Condition66%2/3
$_ eq 'ALL' || $_ eq 'ALL PRIVILEGES'
l!l&&r!l&&!r
01112
MC/DC50%1/2
$_ eq 'ALL' || $_ eq 'ALL PRIVILEGES'
$_ eq 'ALL' $_ eq 'ALL PRIVILEGES'
Truth table66%2/3
A || B
A= $_ eq 'ALL'B= $_ eq 'ALL PRIVILEGES'
ABresult
1X1
011
000
285 9 my %rank = map { $PRIV_ORDER[$_] => $_ } 0 .. $#PRIV_ORDER;
286 9 ▶ return sort { ( $rank{$a} // 99 ) <=> ( $rank{$b} // 99 ) || $a cmp $b } @p;
Condition42%3/7
($rank{$a} // 99) <=> ($rank{$b} // 99) || $a cmp $b
l!l&&r!l&&!r
300
$rank{$a} // 99
l!l
30
$rank{$b} // 99
l!l
30
MC/DC0%0/2
($rank{$a} // 99) <=> ($rank{$b} // 99) || $a cmp $b
$rank{$a} $a cmp $b
MC/DC0%0/1
$rank{$b} // 99
$rank{$b}
Truth table33%1/3
A || B
A= $rank{$a}B= $a cmp $b
ABresult
1X1
011
000
Truth table50%1/2
A
A= $rank{$b}
Aresult
11
00
287 }
288  
289 # grants: [ "SELECT, INSERT ON `shop`.*", … ] <-> { obj => [privs] }
290 18 ▶sub _grant_map {
Subroutine _grant_map: called CC=4 SCAR=13.9
291 18 my ($acc) = @_;
292 18 my %g;
293 18 ▶ for my $line ( @{ $acc->{grants} || [] } ) {
Condition100%2/2
$$acc{'grants'} || []
l!l
171
MC/DC100%1/1
$$acc{'grants'} || []
$$acc{'grants'}
Truth table100%2/2
A
A= $$acc{'grants'}
Aresult
11
00
294 15 ▶ my ( $p, $obj ) = $line =~ /\A(.+?)\s+ON\s+(\S+)\z/ or next;
Branch: 1 branch
BranchTrueFalseTotal
() = $line =~ /\A(.+?)\s+ON\s+(\S+)\z/ or next 15 0 15
295 15 $g{ _norm_obj($obj) } = [ _priv_list($p) ];
296 }
297 18 return \%g;
298 }
299  
300 3 ▶sub _store_grants {
Subroutine _store_grants: called CC=1 SCAR=0.0
301 3 my ( $acc, $g ) = @_;
302 3 $acc->{grants} = [ map { join( ', ', @{ $g->{$_} } ) . " ON $_" } sort grep { @{ $g->{$_} } } keys %$g ];
303 3 return;
304 }
305  
306 115 ▶sub _has_priv {
Subroutine _has_priv: called CC=7 SCAR=23.7
307 115 my ( $m, $acc, $priv ) = @_;
308 115 ▶ return 1 if ( $acc // '' ) =~ /\Aroot@/;
Branch: 1 branch
BranchTrueFalseTotal
if ($acc // "") =~ /\Aroot@/ 107 8 115
Condition50%1/2
$acc // ""
l!l
1150
MC/DC0%0/1
$acc // ""
$acc
Truth table50%1/2
A
A= $acc
Aresult
11
00
309 8 ▶ my $a = $m->{users}{ $acc // '' } or return 0;
Branch: 1 branch
BranchTrueFalseTotal
my $a = $$m{"users"}{$acc // ""} or return 0 8 0 8
Condition50%1/2
$acc // ""
l!l
80
MC/DC0%0/1
$acc // ""
$acc
Truth table50%1/2
A
A= $acc
Aresult
11
00
310 8 ▶ my $g = _grant_map($a)->{'*.*'} || [];
Condition50%1/2
_grant_map($a)->{'*.*'} || []
l!l
08
MC/DC0%0/1
_grant_map($a)->{'*.*'} || []
_grant_map($a)->{'*.*'}
Truth table50%1/2
A
A= _grant_map($a)->{'*.*'}
Aresult
11
00
311 0 ▶ return scalar grep { $_ eq 'ALL PRIVILEGES' || $_ eq $priv } @$g;
Condition0%0/3
$_ eq 'ALL PRIVILEGES' || $_ eq $priv
l!l&&r!l&&!r
000
MC/DC0%0/2
$_ eq 'ALL PRIVILEGES' || $_ eq $priv
$_ eq 'ALL PRIVILEGES' $_ eq $priv
Truth table0%0/3
A || B
A= $_ eq 'ALL PRIVILEGES'B= $_ eq $priv
ABresult
1X1
011
000
312 }
313  
314 # --- SQL ----------------------------------------------------------------------------
315  
316 52 ▶sub _split_sql {
Subroutine _split_sql: called CC=12 SCAR=24.9
317 52 my ($s) = @_;
318 52 my @st;
319 52 my $cur = '';
320 52 my $q;
321 52 for my $c ( split //, $s ) {
322 2252 ▶ if ($q) { $q = undef if $c eq $q; $cur .= $c; next }
Branch: 2 branches
BranchTrueFalseTotal
if ($q) 367 1885 2252
if $c eq $q 43 324 367
323 1885 ▶ if ( $c eq "'" || $c eq '"' || $c eq '`' ) { $q = $c; $cur .= $c; next }
Branch: 1 branch
BranchTrueFalseTotal
if ($c eq "'" or $c eq "\"" or $c eq "`") 43 1842 1885
Condition100%6/6
$c eq "'" or $c eq "\"" or $c eq "`"
l!l&&r!l&&!r
4211842
$c eq "'" or $c eq "\""
l!l&&r!l&&!r
4021843
MC/DC100%3/3
$c eq "'" or $c eq "\"" or $c eq "`"
$c eq "'" $c eq "\"" $c eq "`"
Truth table100%4/4
A or B or C
A= $c eq "'"B= $c eq "\""C= $c eq "`"
ABCresult
1XX1
01X1
0011
0000
324 1842 ▶ if ( $c eq ';' ) { push @st, $cur; $cur = ''; next }
Branch: 1 branch
BranchTrueFalseTotal
if ($c eq ";") 5 1837 1842
325 1837 $cur .= $c;
326 }
327 52 push @st, $cur;
328 52 my @out;
329 52 for (@st) {
330 57 my $x = $_;
331 57 ▶ while ( $x =~ s/\\G// ) { }
Branch: 1 branch
BranchTrueFalseTotal
if ($x =~ s/\\G//) 3 57 60
332 57 ▶ my $vert = $_ =~ /\\G\s*\z/ ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$_ =~ /\\G\s*\z/ ? : 3 54 57
333 57 $x =~ s/\A\s+|\s+\z//g;
334 57 ▶ push @out, [ $x, $vert ] if length $x;
Branch: 1 branch
BranchTrueFalseTotal
if length $x 57 0 57
335 }
336 52 return @out;
337 }
338  
339 4 ▶sub _err { my ( $code, $state, $msg ) = @_; return ( "ERROR $code ($state) at line 1: $msg", 0 ) }
Subroutine _err: called CC=1 SCAR=0.0
340  
341 # an Kommas der obersten Ebene trennen (nicht in Klammern oder Anfuehrungszeichen)
342 25 ▶sub _split_top {
Subroutine _split_top: called CC=10 SCAR=23.0
343 25 my ($s) = @_;
344 25 my @p;
345 25 my ( $cur, $depth, $q ) = ( '', 0, '' );
346 25 for my $ch ( split //, $s ) {
347 311 ▶ if ($q) { $q = '' if $ch eq $q; $cur .= $ch; next }
Branch: 2 branches
BranchTrueFalseTotal
if ($q) 25 286 311
if $ch eq $q 7 18 25
348 286 ▶ if ( $ch eq "'" || $ch eq '"' ) { $q = $ch; $cur .= $ch; next }
Branch: 1 branch
BranchTrueFalseTotal
if ($ch eq "'" or $ch eq "\"") 7 279 286
Condition66%2/3
$ch eq "'" or $ch eq "\""
l!l&&r!l&&!r
70279
MC/DC50%1/2
$ch eq "'" or $ch eq "\""
$ch eq "'" $ch eq "\""
Truth table66%2/3
A or B
A= $ch eq "'"B= $ch eq "\""
ABresult
1X1
011
000
349 279 ▶ $depth++ if $ch eq '(';
Branch: 1 branch
BranchTrueFalseTotal
if $ch eq "(" 8 271 279
350 279 ▶ $depth-- if $ch eq ')';
Branch: 1 branch
BranchTrueFalseTotal
if $ch eq ")" 8 271 279
351 279 ▶ if ( $ch eq ',' && !$depth ) { push @p, $cur; $cur = ''; next }
Branch: 1 branch
BranchTrueFalseTotal
if ($ch eq "," and not $depth) 12 267 279
Condition100%3/3
$ch eq "," and not $depth
!ll&&!rl&&r
264312
MC/DC100%2/2
$ch eq "," and not $depth
$ch eq "," not $depth
Truth table100%3/3
A and not(B)
A= $ch eq ","B= not $depth
ABresult
0X0
100
111
352 267 $cur .= $ch;
353 }
354 25 push @p, $cur;
355 25 return map { s/\A\s+|\s+\z//gr } @p;
356 }
357  
358 # Spaltenliste eines SELECT: [ { expr, label } ]; Alias mit AS oder nachgestellt, sonst der
359 # Ausdruck wie geschrieben (ein Text ohne Anfuehrungszeichen) als Ueberschrift
360 19 ▶sub _sel_items {
Subroutine _sel_items: called CC=5 SCAR=16.2
361 19 my ($cols) = @_;
362 return [ map {
363 19 ▶ my ( $e, $al ) = /\A(.+?)\s+(?:AS\s+)?[`"]?(\w+)[`"]?\z/is ? ( $1, $2 ) : ( $_, undef );
Branch: 1 branch
BranchTrueFalseTotal
/\A(.+?)\s+(?:AS\s+)?[`"]?(\w+)[`"]?\z/is ? : 4 22 26
364 26 ▶ ( $e, $al ) = ( $_, undef ) if $e =~ /\A'[^']*\z/; # Leerzeichen im Text, kein Alias
Branch: 1 branch
BranchTrueFalseTotal
if $e =~ /\A'[^']*\z/ 0 26 26
365 26 ▶ +{ expr => $e, label => $al // ( $e =~ /\A'(.*)'\z/s ? $1 =~ s/''/'/gr : $e ) }
Branch: 1 branch
BranchTrueFalseTotal
$e =~ /\A'(.*)'\z/s ? : 1 21 22
Condition66%2/3
$al // ($e =~ /\A'(.*)'\z/s ? $1 =~ s/''/'/gr : $e)
l!l&&r!l&&!r
4220
MC/DC0%0/2
$al // ($e =~ /\A'(.*)'\z/s ? $1 =~ s/''/'/gr : $e)
$al ($e =~ /\A'(.*)'\z/s ? $1 =~ s/''/'/gr : $e)
Truth table66%2/3
A // B
A= $alB= ($e =~ /\A'(.*)'\z/s ? $1 =~ s/''/'/gr : $e)
ABresult
1X1
011
000
366 } _split_top($cols) ];
367 }
368  
369 # Wert eines Ausdrucks in einer Zeile: Spalte, Zahl, 'Text', NOW(), USER(), VERSION(), CONCAT,
370 # LEFT, RIGHT, LENGTH, CHAR_LENGTH, UPPER, LOWER, PASSWORD; undef = nicht nachgebildet (Luecke)
371 45 ▶sub _sql_val {
Subroutine _sql_val: called CC=33 SCAR=43.9
372 45 my ( $e, $row, $env ) = @_;
373 45 $e =~ s/\A\s+|\s+\z//g;
374 45 ▶ return $1 =~ s/''/'/gr if $e =~ /\A'((?:[^']|'')*)'\z/s;
Branch: 1 branch
BranchTrueFalseTotal
if $e =~ /\A'((?:[^']|'')*)'\z/s 5 40 45
375 40 ▶ return $e if $e =~ /\A-?\d+(?:\.\d+)?\z/;
Branch: 1 branch
BranchTrueFalseTotal
if $e =~ /\A-?\d+(?:\.\d+)?\z/ 6 34 40
376 34 ▶ if ( $e =~ /\A(\w+)\s*\((.*)\)\z/s ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($e =~ /\A(\w+)\s*\((.*)\)\z/s) 7 27 34
377 7 my ( $f, $in ) = ( uc $1, $2 );
378 7 ▶ return $env->{now} if $f eq 'NOW' && $in !~ /\S/;
Branch: 1 branch
BranchTrueFalseTotal
if $f eq "NOW" and not $in =~ /\S/ 0 7 7
Condition33%1/3
$f eq "NOW" and not $in =~ /\S/
!ll&&!rl&&r
700
MC/DC0%0/2
$f eq "NOW" and not $in =~ /\S/
$f eq "NOW" not $in =~ /\S/
Truth table33%1/3
A and not(B)
A= $f eq "NOW"B= not $in =~ /\S/
ABresult
0X0
100
111
379 7 ▶ return $env->{user} if ( $f eq 'USER' || $f eq 'CURRENT_USER' ) && $in !~ /\S/;
Branch: 1 branch
BranchTrueFalseTotal
if $f eq "USER" || $f eq "CURRENT_USER" and not $in =~ /\S/ 1 6 7
Condition66%4/6
$f eq "USER" || $f eq "CURRENT_USER" and not $in =~ /\S/
!ll&&!rl&&r
601
$f eq "USER" or $f eq "CURRENT_USER"
l!l&&r!l&&!r
106
MC/DC33%1/3
$f eq "USER" || $f eq "CURRENT_USER" and not $in =~ /\S/
$f eq "USER" $f eq "CURRENT_USER" not $in =~ /\S/
Truth table40%2/5
A or B and not(C)
A= $f eq "USER"B= $f eq "CURRENT_USER"C= not $in =~ /\S/
ABCresult
00X0
1X00
0100
1X11
0111
380 6 ▶ return $env->{version} if $f eq 'VERSION' && $in !~ /\S/;
Branch: 1 branch
BranchTrueFalseTotal
if $f eq "VERSION" and not $in =~ /\S/ 0 6 6
Condition33%1/3
$f eq "VERSION" and not $in =~ /\S/
!ll&&!rl&&r
600
MC/DC0%0/2
$f eq "VERSION" and not $in =~ /\S/
$f eq "VERSION" not $in =~ /\S/
Truth table33%1/3
A and not(B)
A= $f eq "VERSION"B= not $in =~ /\S/
ABresult
0X0
100
111
381 6 my @a = map { _sql_val( $_, $row, $env ) } _split_top($in);
382 6 ▶ return undef if !@a || grep { !defined } @a;
Branch: 1 branch
BranchTrueFalseTotal
if not @a or grep {not defined $_;} @a 0 6 6
Condition33%1/3
not @a or grep {not defined $_;} @a
l!l&&r!l&&!r
006
MC/DC0%0/2
not @a or grep {not defined $_;} @a
not @a grep {not defined $_;} @a
Truth table33%1/3
not(A) or B
A= not @aB= grep {not defined $_;} @a
ABresult
1X1
011
000
383 6 ▶ return join( '', @a ) if $f eq 'CONCAT';
Branch: 1 branch
BranchTrueFalseTotal
if $f eq "CONCAT" 2 4 6
384 4 ▶ return substr( $a[0], 0, $a[1] ) if $f eq 'LEFT' && @a == 2 && $a[1] =~ /\A\d+\z/;
Branch: 1 branch
BranchTrueFalseTotal
if $f eq "LEFT" and @a == 2 and $a[1] =~ /\A\d+\z/ 1 3 4
Condition66%4/6
$f eq "LEFT" and @a == 2 and $a[1] =~ /\A\d+\z/
!ll&&!rl&&r
301
$f eq "LEFT" and @a == 2
!ll&&!rl&&r
301
MC/DC33%1/3
$f eq "LEFT" and @a == 2 and $a[1] =~ /\A\d+\z/
$f eq "LEFT" @a == 2 $a[1] =~ /\A\d+\z/
Truth table50%2/4
A and B and C
A= $f eq "LEFT"B= @a == 2C= $a[1] =~ /\A\d+\z/
ABCresult
0XX0
10X0
1100
1111
385 3 ▶ return $a[1] ? substr( $a[0], -$a[1] ) : '' if $f eq 'RIGHT' && @a == 2 && $a[1] =~ /\A\d+\z/;
Branch: 2 branches
BranchTrueFalseTotal
if $f eq "RIGHT" and @a == 2 and $a[1] =~ /\A\d+\z/ 0 3 3
$a[1] ? : 0 0 0
Condition33%2/6
$f eq "RIGHT" and @a == 2 and $a[1] =~ /\A\d+\z/
!ll&&!rl&&r
300
$f eq "RIGHT" and @a == 2
!ll&&!rl&&r
300
MC/DC0%0/3
$f eq "RIGHT" and @a == 2 and $a[1] =~ /\A\d+\z/
$f eq "RIGHT" @a == 2 $a[1] =~ /\A\d+\z/
Truth table25%1/4
A and B and C
A= $f eq "RIGHT"B= @a == 2C= $a[1] =~ /\A\d+\z/
ABCresult
0XX0
10X0
1100
1111
386 3 ▶ if ( @a == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@a == 1) 3 0 3
387 0 ▶ if ( $f eq 'LENGTH' ) { require Encode; return length Encode::encode( 'UTF-8', $a[0] ) }
Branch: 1 branch
BranchTrueFalseTotal
if ($f eq "LENGTH") 0 3 3
388 3 ▶ return length $a[0] if $f eq 'CHAR_LENGTH' || $f eq 'CHARACTER_LENGTH';
Branch: 1 branch
BranchTrueFalseTotal
if $f eq "CHAR_LENGTH" or $f eq "CHARACTER_LENGTH" 1 2 3
Condition66%2/3
$f eq "CHAR_LENGTH" or $f eq "CHARACTER_LENGTH"
l!l&&r!l&&!r
102
MC/DC50%1/2
$f eq "CHAR_LENGTH" or $f eq "CHARACTER_LENGTH"
$f eq "CHAR_LENGTH" $f eq "CHARACTER_LENGTH"
Truth table66%2/3
A or B
A= $f eq "CHAR_LENGTH"B= $f eq "CHARACTER_LENGTH"
ABresult
1X1
011
000
389 2 ▶ return uc $a[0] if $f eq 'UPPER' || $f eq 'UCASE';
Branch: 1 branch
BranchTrueFalseTotal
if $f eq "UPPER" or $f eq "UCASE" 0 2 2
Condition33%1/3
$f eq "UPPER" or $f eq "UCASE"
l!l&&r!l&&!r
002
MC/DC0%0/2
$f eq "UPPER" or $f eq "UCASE"
$f eq "UPPER" $f eq "UCASE"
Truth table33%1/3
A or B
A= $f eq "UPPER"B= $f eq "UCASE"
ABresult
1X1
011
000
390 2 ▶ return lc $a[0] if $f eq 'LOWER' || $f eq 'LCASE';
Branch: 1 branch
BranchTrueFalseTotal
if $f eq "LOWER" or $f eq "LCASE" 0 2 2
Condition33%1/3
$f eq "LOWER" or $f eq "LCASE"
l!l&&r!l&&!r
002
MC/DC0%0/2
$f eq "LOWER" or $f eq "LCASE"
$f eq "LOWER" $f eq "LCASE"
Truth table33%1/3
A or B
A= $f eq "LOWER"B= $f eq "LCASE"
ABresult
1X1
011
000
391 2 ▶ return _pwhash( $a[0] ) if $f eq 'PASSWORD';
Branch: 1 branch
BranchTrueFalseTotal
if $f eq "PASSWORD" 1 1 2
392 }
393 1 return undef;
394 }
395 27 ▶ return $row->{ lc $1 } if $e =~ /\A`?(\w+)`?\z/ && $row && exists $row->{ lc $1 };
Branch: 1 branch
BranchTrueFalseTotal
if $e =~ /\A`?(\w+)`?\z/ and $row and exists $$row{lc $1} 27 0 27
Condition33%2/6
$e =~ /\A`?(\w+)`?\z/ and $row and exists $$row{lc $1}
!ll&&!rl&&r
0027
$e =~ /\A`?(\w+)`?\z/ and $row
!ll&&!rl&&r
0027
MC/DC0%0/3
$e =~ /\A`?(\w+)`?\z/ and $row and exists $$row{lc $1}
$e =~ /\A`?(\w+)`?\z/ $row exists $$row{lc $1}
Truth table25%1/4
A and B and C
A= $e =~ /\A`?(\w+)`?\z/B= $rowC= exists $$row{lc $1}
ABCresult
0XX0
10X0
1100
1111
396 0 return undef;
397 }
398  
399 # Ergebnis einer Spaltenliste ueber Zeilen: nur COUNT(*) -> eine Zeile mit der Anzahl;
400 # ( \@ueberschriften, \@zeilen ) oder () wenn ein Ausdruck nicht nachgebildet ist
401 19 ▶sub _sel_rows {
Subroutine _sel_rows: called CC=6 SCAR=17.9
402 19 my ( $items, $rows, $env ) = @_;
403 19 my @h = map { $_->{label} } @$items;
404 19 ▶ if ( !grep { $_->{expr} !~ /\ACOUNT\s*\(\s*\*\s*\)\z/i } @$items ) { return ( \@h, [ [ map { scalar @$rows } @$items ] ] ) }
Branch: 1 branch
BranchTrueFalseTotal
unless (grep {not $$_{"expr"} =~ /\ACOUNT\s*\(\s*\*\s*\)\z/i;} @$items) 2 17 19
405 17 ▶ return if grep { $_->{expr} =~ /\A\w+\s*\(\s*(?:\*|DISTINCT\b)/i } @$items;
Branch: 1 branch
BranchTrueFalseTotal
if grep {$$_{"expr"} =~ /\A\w+\s*\(\s*(?:\*|DISTINCT\b)/i;} @$items 0 17 17
406 17 my @out;
407 17 for my $r (@$rows) {
408 23 my @v;
409 23 ▶ for (@$items) { my $x = _sql_val( $_->{expr}, $r, $env ); return unless defined $x; push @v, $x }
Branch: 1 branch
BranchTrueFalseTotal
unless defined $x 1 33 34
410 22 push @out, \@v;
411 }
412 16 return ( \@h, \@out );
413 }
414  
415 57 ▶sub _statement {
Subroutine _statement: called CC=247 SCAR=79.5
416 57 my ( $dev, $sql, $o, $acc ) = @_;
417 57 my $m = $dev->{mariadb};
418 57 my $v = _vars($dev);
419 57 ▶ my $super = _has_priv( $m, $acc, 'SUPER' ) || _has_priv( $m, $acc, 'ALL PRIVILEGES' );
Condition66%2/3
_has_priv($m, $acc, 'SUPER') || _has_priv($m, $acc, 'ALL PRIVILEGES')
l!l&&r!l&&!r
5601
MC/DC50%1/2
_has_priv($m, $acc, 'SUPER') || _has_priv($m, $acc, 'ALL PRIVILEGES')
_has_priv($m, $acc, 'SUPER') _has_priv($m, $acc, 'ALL PRIVILEGES')
Truth table66%2/3
A || B
A= _has_priv($m, $acc, 'SUPER')B= _has_priv($m, $acc, 'ALL PRIVILEGES')
ABresult
1X1
011
000
420 57 ( my $s = $sql ) =~ s/\s+/ /g;
421 my $env = { user => $acc // '', version => $v->{version},
422 57 ▶ now => '2026-10-24 ' . ( ( $dev->{clock} // '' ) =~ /(\d+:\d+)\z/ ? "$1:00" : '09:12:00' ) };
Branch: 1 branch
BranchTrueFalseTotal
($$dev{'clock'} // '') =~ /(\d+:\d+)\z/ ? : 57 0 57
Condition50%2/4
$acc // ""
l!l
570
$$dev{"clock"} // ""
l!l
570
MC/DC0%0/1
$acc // ""
$acc
MC/DC0%0/1
$$dev{"clock"} // ""
$$dev{"clock"}
Truth table50%1/2
A
A= $acc
Aresult
11
00
Truth table50%1/2
A
A= $$dev{"clock"}
Aresult
11
00
423  
424 57 ▶ if ( $s =~ /\ASHOW (?:(GLOBAL|SESSION) )?VARIABLES(?: (?:LIKE (\S+)|WHERE .*))?\z/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s =~ /\ASHOW (?:(GLOBAL|SESSION) )?VARIABLES(?: (?:LIKE (\S+)|WHERE .*))?\z/i) 1 56 57
425 1 my $re = _like($2);
426 1 ▶ my @r = map { [ $_, $v->{$_} ] } grep { !defined $re || $_ =~ $re } sort keys %$v;
Condition66%2/3
!defined($re) || $_ =~ /$re/
l!l&&r!l&&!r
0145
MC/DC50%1/2
!defined($re) || $_ =~ /$re/
!defined($re) $_ =~ /$re/
Truth table66%2/3
not(A) || B
A= !defined($re)B= $_ =~ /$re/
ABresult
1X1
011
000
427 1 return ( _render( $o, [qw( Variable_name Value )], \@r ), 1 );
428 }
429 56 ▶ if ( $s =~ /\ASHOW (?:(GLOBAL|SESSION) )?STATUS(?: LIKE (\S+))?\z/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s =~ /\ASHOW (?:(GLOBAL|SESSION) )?STATUS(?: LIKE (\S+))?\z/i) 0 56 56
430 0 my $re = _like($2);
431 0 ▶ my %st = ( Uptime => 1728000, Threads_running => 2, %{ $m->{status} || {} } );
Condition0%0/2
$$m{'status'} || {}
l!l
00
MC/DC0%0/1
$$m{'status'} || {}
$$m{'status'}
Truth table0%0/2
A
A= $$m{'status'}
Aresult
11
00
432 0 ▶ my @r = map { [ $_, $st{$_} ] } grep { !defined $re || $_ =~ $re } sort keys %st;
Condition0%0/3
!defined($re) || $_ =~ /$re/
l!l&&r!l&&!r
000
MC/DC0%0/2
!defined($re) || $_ =~ /$re/
!defined($re) $_ =~ /$re/
Truth table0%0/3
not(A) || B
A= !defined($re)B= $_ =~ /$re/
ABresult
1X1
011
000
433 0 return ( _render( $o, [qw( Variable_name Value )], \@r ), 1 );
434 }
435 56 ▶ if ( $s =~ /\ASELECT (\@\@.+?)\s*\z/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s =~ /\ASELECT (\@\@.+?)\s*\z/i) 3 53 56
436 3 my @cols = split /\s*,\s*/, $1;
437 3 my @vals;
438 my @names;
439 3 for my $c (@cols) {
440 4 my ( $expr, $alias ) = $c =~ /\A(.+?)(?:\s+AS\s+[`'"]?(\w+)[`'"]?)?\z/i;
441 4 my $bad;
442 4 my $num = $expr;
443 4 for my $n ( $expr =~ /\@\@(?:global\.|session\.)?(\w+)/g ) {
444 4 my $k = lc $n;
445 0 ▶ if ( !exists $v->{$k} ) { $bad = [ 1, $k ]; last }
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $$v{$k}) 0 4 4
446 4 my $x = $v->{$k};
447 4 ▶ if ( $x =~ /\A-?\d+(?:\.\d+)?\z/ ) { $num =~ s/\@\@(?:global\.|session\.)?\Q$n\E\b/($x)/ }
Branch: 1 branch
BranchTrueFalseTotal
if ($x =~ /\A-?\d+(?:\.\d+)?\z/) { } 4 0 4
448 0 ▶ else { $bad //= [ 0, $k ] }
Condition0%0/2
$bad //= [0, $k]
l!l
00
MC/DC0%0/1
$bad //= [0, $k]
$bad
Truth table0%0/2
A
A= $bad
Aresult
11
00
449 }
450 4 ▶ return _err( 1193, 'HY000', "Unknown system variable '$bad->[1]'" ) if $bad && $bad->[0];
Branch: 1 branch
BranchTrueFalseTotal
if $bad and $$bad[0] 0 4 4
Condition33%1/3
$bad and $$bad[0]
!ll&&!rl&&r
400
MC/DC0%0/2
$bad and $$bad[0]
$bad $$bad[0]
Truth table33%1/3
A and B
A= $badB= $$bad[0]
ABresult
0X0
100
111
451 4 ▶ if ( $expr =~ /\A\s*\@\@(?:global\.|session\.)?\w+\s*\z/ ) { my ($n) = $expr =~ /(\w+)\s*\z/; push @vals, $v->{ lc $n } }
Branch: 2 branches
BranchTrueFalseTotal
if ($expr =~ /\A\s*\@\@(?:global\.|session\.)?\w+\s*\z/) { } 3 1 4
elsif (not $bad and $num =~ m[\A[\d\s.+\-*/()]+\z]) { } 1 0 1
452 ▶ elsif ( !$bad && $num =~ m{\A[\d\s.+\-*/()]+\z} ) {
Condition33%1/3
not $bad and $num =~ m[\A[\d\s.+\-*/()]+\z]
!ll&&!rl&&r
001
MC/DC0%0/2
not $bad and $num =~ m[\A[\d\s.+\-*/()]+\z]
not $bad $num =~ m[\A[\d\s.+\-*/()]+\z]
Truth table33%1/3
not(A) and B
A= not $badB= $num =~ m[\A[\d\s.+\-*/()]+\z]
ABresult
0X0
100
111
453 1 my $r = eval $num;
454 1 ▶ return _gap($sql) unless defined $r;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $r 0 1 1
455 1 ▶ push @vals, $num =~ m{/} ? sprintf( '%.4f', $r ) : $r;
Branch: 1 branch
BranchTrueFalseTotal
$num =~ m[/] ? : 1 0 1
456 }
457 0 else { return _gap($sql) }
458 4 ▶ push @names, $alias // $expr;
Condition66%2/3
$alias // $expr
l!l&&r!l&&!r
130
MC/DC0%0/2
$alias // $expr
$alias $expr
Truth table66%2/3
A // B
A= $aliasB= $expr
ABresult
1X1
011
000
459 }
460 3 return ( _render( $o, \@names, [ \@vals ] ), 1 );
461 }
462 53 ▶ if ( $s =~ /\ASET (?:(GLOBAL|SESSION|PERSIST) |\@\@(?:global|GLOBAL)\.)?(.+)\z/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s =~ /\ASET (?:(GLOBAL|SESSION|PERSIST) |\@\@(?:global|GLOBAL)\.)?(.+)\z/i) 6 47 53
463 6 my ( $scope, $rest ) = ( $1, $2 );
464 6 ▶ my $glob = ( $s =~ /\ASET (?:GLOBAL |\@\@global\.)/i ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$s =~ /\ASET (?:GLOBAL |\@\@global\.)/i ? : 6 0 6
465 6 for my $as ( split /\s*,\s*(?=(?:GLOBAL |\@\@)?[\w.]+\s*=)/i, $rest ) {
466 6 $as =~ s/\A(?:GLOBAL\s+|\@\@global\.)//i;
467 6 ▶ my ( $n, $val ) = $as =~ /\A\@?\@?([\w.]+)\s*=\s*(.+?)\s*\z/ or return _gap($sql);
Branch: 1 branch
BranchTrueFalseTotal
() = $as =~ /\A\@?\@?([\w.]+)\s*=\s*(.+?)\s*\z/ or return _gap($sql) 6 0 6
468 6 $n = _norm_name($n);
469 6 ▶ return _err( 1193, 'HY000', "Unknown system variable '$n'" ) unless exists $VAR{$n};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $Langertha::Holmgang::Sim::Linux::MariaDB::VAR{$n} 0 6 6
470 6 ▶ return _err( 1238, 'HY000', "Variable '$n' is a read only variable" ) unless $VAR{$n}[1];
Branch: 1 branch
BranchTrueFalseTotal
unless $Langertha::Holmgang::Sim::Linux::MariaDB::VAR{$n}[1] 1 5 6
471 5 ▶ return _err( 1229, 'HY000', "Variable '$n' is a GLOBAL variable and should be set with SET GLOBAL" ) unless $glob;
Branch: 1 branch
BranchTrueFalseTotal
unless $glob 0 5 5
472 5 ▶ return _err( 1227, '42000', 'Access denied; you need (at least one of) the SUPER privilege(s) for this operation' ) unless $super;
Branch: 1 branch
BranchTrueFalseTotal
unless $super 0 5 5
473 # parallele Replikation: nur bei angehaltenem SQL-Thread
474 5 ▶ if ( $n =~ /\Aslave_parallel_(?:threads|mode)\z/ && $m->{replica} && $m->{replica}{sql} eq 'Yes' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($n =~ /\Aslave_parallel_(?:threads|mode)\z/ and $$m{"replica"} and $$m{"replica"}{"sql"} eq "Yes") 1 4 5
Condition83%5/6
$n =~ /\Aslave_parallel_(?:threads|mode)\z/ and $$m{"replica"} and $$m{"replica"}{"sql"} eq "Yes"
!ll&&!rl&&r
311
$n =~ /\Aslave_parallel_(?:threads|mode)\z/ and $$m{"replica"}
!ll&&!rl&&r
302
MC/DC66%2/3
$n =~ /\Aslave_parallel_(?:threads|mode)\z/ and $$m{"replica"} and $$m{"replica"}{"sql"} eq "Yes"
$n =~ /\Aslave_parallel_(?:threads|mode)\z/ $$m{"replica"} $$m{"replica"}{"sql"} eq "Yes"
Truth table75%3/4
A and B and C
A= $n =~ /\Aslave_parallel_(?:threads|mode)\z/B= $$m{"replica"}C= $$m{"replica"}{"sql"} eq "Yes"
ABCresult
0XX0
10X0
1100
1111
475 1 return _err( 1198, 'HY000', "This operation cannot be performed as you have a running slave ''; run STOP SLAVE '' first" );
476 }
477 4 ▶ if ( $n eq 'sql_slave_skip_counter' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($n eq "sql_slave_skip_counter") 1 3 4
478 1 ▶ my $r = $m->{replica} or return _err( 1200, 'HY000', 'Misconfigured slave: MASTER_HOST was not set; Fix in config file or with CHANGE MASTER TO' );
Branch: 1 branch
BranchTrueFalseTotal
my $r = $$m{"replica"} or return _err(1200, "HY000", "Misconfigured slave: MASTER_HOST was not set; Fix in config file or with CHANGE MASTER TO") 1 0 1
479 1 ▶ return _err( 1198, 'HY000', 'This operation cannot be performed as you have a running slave; run STOP SLAVE first' ) if $r->{sql} eq 'Yes';
Branch: 1 branch
BranchTrueFalseTotal
if $$r{"sql"} eq "Yes" 0 1 1
480 }
481 # SET GLOBAL x = 256*1024*1024 — einfache Rechnung wie MariaDB
482 4 ▶ if ( $val =~ m{\A[\d\s()+\-*/]+\z} && $val =~ m{[+\-*/]} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($val =~ m[\A[\d\s()+\-*/]+\z] and $val =~ m[[+\-*/]]) 1 3 4
Condition66%2/3
$val =~ m[\A[\d\s()+\-*/]+\z] and $val =~ m[[+\-*/]]
!ll&&!rl&&r
031
MC/DC50%1/2
$val =~ m[\A[\d\s()+\-*/]+\z] and $val =~ m[[+\-*/]]
$val =~ m[\A[\d\s()+\-*/]+\z] $val =~ m[[+\-*/]]
Truth table66%2/3
A and B
A= $val =~ m[\A[\d\s()+\-*/]+\z]B= $val =~ m[[+\-*/]]
ABresult
0X0
100
111
483 1 my $r = eval $val;
484 1 ▶ $val = int($r) if defined $r;
Branch: 1 branch
BranchTrueFalseTotal
if defined $r 1 0 1
485 }
486 4 my ( $x, $e ) = _value( $n, $val );
487 4 ▶ return _err( 1232, '42000', $e ) unless defined $x;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $x 0 4 4
488 4 $v->{$n} = $x;
489 4 ▶ $v->{expire_logs_days} = sprintf '%.6f', $x / 86400 if $n eq 'binlog_expire_logs_seconds';
Branch: 1 branch
BranchTrueFalseTotal
if $n eq "binlog_expire_logs_seconds" 0 4 4
490 4 ▶ $v->{binlog_expire_logs_seconds} = int( $x * 86400 ) . '' if $n eq 'expire_logs_days';
Branch: 1 branch
BranchTrueFalseTotal
if $n eq "expire_logs_days" 0 4 4
491 }
492 4 return ( '', 1 );
493 }
494 # information_schema.processlist: dieselben Verbindungen wie SHOW PROCESSLIST
495 47 ▶ if ( $s =~ /\ASELECT (.+?) FROM information_schema\.processlist(?: WHERE (.+?))?(?: ORDER BY (\w+)(?: (ASC|DESC))?)?(?: LIMIT (\d+))?\z/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s =~ /\ASELECT (.+?) FROM information_schema\.processlist(?: WHERE (.+?))?(?: ORDER BY (\w+)(?: (ASC|DESC))?)?(?: LIMIT (\d+))?\z/i) 3 44 47
496 3 my ( $cols, $where, $ord, $dir, $lim ) = ( $1, $2, $3, $4, $5 );
497 3 my @all = qw( ID USER HOST DB COMMAND TIME STATE INFO );
498 3 ▶ my @c = $cols eq '*' ? @all : map { s/[`\s]//gr } split /,/, $cols;
Branch: 1 branch
BranchTrueFalseTotal
$cols eq '*' ? : 0 3 3
499 3 my @r;
500 3 ▶ for my $p ( @{ $m->{processlist} || [] } ) {
Condition50%1/2
$$m{'processlist'} || []
l!l
30
MC/DC0%0/1
$$m{'processlist'} || []
$$m{'processlist'}
Truth table50%1/2
A
A= $$m{'processlist'}
Aresult
11
00
501 9 ▶ for my $i ( 0 .. ( $p->{count} // 1 ) - 1 ) {
Condition100%2/2
$$p{"count"} // 1
l!l
36
MC/DC100%1/1
$$p{"count"} // 1
$$p{"count"}
Truth table100%2/2
A
A= $$p{"count"}
Aresult
11
00
502 my %row = ( id => $p->{id} + $i, user => $p->{user}, host => $p->{host} // 'localhost', db => $p->{db} // 'NULL',
503 12 ▶ command => $p->{command} // 'Sleep', time => $p->{time} // 0, state => $p->{state} // '', info => $p->{info} // 'NULL' );
Condition66%8/12
$$p{"host"} // "localhost"
l!l
012
$$p{"db"} // "NULL"
l!l
012
$$p{"command"} // "Sleep"
l!l
120
$$p{"time"} // 0
l!l
120
$$p{"state"} // ""
l!l
39
$$p{"info"} // "NULL"
l!l
39
MC/DC0%0/1
$$p{"host"} // "localhost"
$$p{"host"}
MC/DC0%0/1
$$p{"db"} // "NULL"
$$p{"db"}
MC/DC0%0/1
$$p{"command"} // "Sleep"
$$p{"command"}
MC/DC0%0/1
$$p{"time"} // 0
$$p{"time"}
MC/DC100%1/1
$$p{"state"} // ""
$$p{"state"}
MC/DC100%1/1
$$p{"info"} // "NULL"
$$p{"info"}
Truth table50%1/2
A
A= $$p{"host"}
Aresult
11
00
Truth table50%1/2
A
A= $$p{"db"}
Aresult
11
00
Truth table50%1/2
A
A= $$p{"command"}
Aresult
11
00
Truth table50%1/2
A
A= $$p{"time"}
Aresult
11
00
Truth table100%2/2
A
A= $$p{"state"}
Aresult
11
00
Truth table100%2/2
A
A= $$p{"info"}
Aresult
11
00
504 12 ▶ my $keep = _where( \%row, $where ) // return _gap($sql);
Condition50%1/2
_where(\%row, $where) // (return _gap($sql))
l!l
120
MC/DC0%0/1
_where(\%row, $where) // (return _gap($sql))
_where(\%row, $where)
Truth table50%1/2
A
A= _where(\%row, $where)
Aresult
11
00
505 12 ▶ push @r, \%row if $keep;
Branch: 1 branch
BranchTrueFalseTotal
if $keep 4 8 12
506 }
507 }
508 3 ▶ if ( defined $ord ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ord) 1 2 3
509 1 my $k = lc $ord;
510 1 ▶ return _gap($sql) unless grep { lc $_ eq $k } @all;
Branch: 1 branch
BranchTrueFalseTotal
unless grep {lc $_ eq $k;} @all 0 1 1
511 1 ▶ @r = sort { $a->{$k} =~ /\A-?\d+\z/ && $b->{$k} =~ /\A-?\d+\z/ ? $a->{$k} <=> $b->{$k} : $a->{$k} cmp $b->{$k} } @r;
Branch: 1 branch
BranchTrueFalseTotal
$$a{$k} =~ /\A-?\d+\z/ && $$b{$k} =~ /\A-?\d+\z/ ? : 1 0 1
Condition33%1/3
$$a{$k} =~ /\A-?\d+\z/ and $$b{$k} =~ /\A-?\d+\z/
!ll&&!rl&&r
001
MC/DC0%0/2
$$a{$k} =~ /\A-?\d+\z/ and $$b{$k} =~ /\A-?\d+\z/
$$a{$k} =~ /\A-?\d+\z/ $$b{$k} =~ /\A-?\d+\z/
Truth table33%1/3
A and B
A= $$a{$k} =~ /\A-?\d+\z/B= $$b{$k} =~ /\A-?\d+\z/
ABresult
0X0
100
111
512 1 ▶ @r = reverse @r if uc( $dir // '' ) eq 'DESC';
Branch: 1 branch
BranchTrueFalseTotal
if uc($dir // "") eq "DESC" 1 0 1
Condition50%1/2
$dir // ""
l!l
10
MC/DC0%0/1
$dir // ""
$dir
Truth table50%1/2
A
A= $dir
Aresult
11
00
513 }
514 3 ▶ splice @r, $lim if defined $lim && @r > $lim;
Branch: 1 branch
BranchTrueFalseTotal
if defined $lim and @r > $lim 1 2 3
Condition66%2/3
defined $lim and @r > $lim
!ll&&!rl&&r
201
MC/DC50%1/2
defined $lim and @r > $lim
defined $lim @r > $lim
Truth table66%2/3
A and B
A= defined $limB= @r > $lim
ABresult
0X0
100
111
515 3 ▶ return ( _render( $o, \@c, [ map { my $x = $_; [ map { $x->{ lc $_ } // return _gap($sql) } @c ] } @r ] ), 1 );
Condition50%1/2
$$x{lc $_} // (return _gap($sql))
l!l
50
MC/DC0%0/1
$$x{lc $_} // (return _gap($sql))
$$x{lc $_}
Truth table50%1/2
A
A= $$x{lc $_}
Aresult
11
00
516 }
517 44 ▶ if ( $s =~ /\ASHOW (FULL )?PROCESSLIST\z/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s =~ /\ASHOW (FULL )?PROCESSLIST\z/i) 0 44 44
518 0 my @r;
519 0 ▶ for my $p ( @{ $m->{processlist} || [] } ) {
Condition0%0/2
$$m{'processlist'} || []
l!l
00
MC/DC0%0/1
$$m{'processlist'} || []
$$m{'processlist'}
Truth table0%0/2
A
A= $$m{'processlist'}
Aresult
11
00
520 0 ▶ for my $i ( 0 .. ( $p->{count} // 1 ) - 1 ) {
Condition0%0/2
$$p{"count"} // 1
l!l
00
MC/DC0%0/1
$$p{"count"} // 1
$$p{"count"}
Truth table0%0/2
A
A= $$p{"count"}
Aresult
11
00
521 push @r, [ $p->{id} + $i, $p->{user}, $p->{host} // 'localhost', $p->{db} // 'NULL', $p->{command} // 'Sleep', $p->{time} // 0,
522 0 ▶ $p->{state} // '', $p->{info} // 'NULL', '0.000' ];
Condition0%0/12
$$p{"host"} // "localhost"
l!l
00
$$p{"db"} // "NULL"
l!l
00
$$p{"command"} // "Sleep"
l!l
00
$$p{"time"} // 0
l!l
00
$$p{"state"} // ""
l!l
00
$$p{"info"} // "NULL"
l!l
00
MC/DC0%0/1
$$p{"host"} // "localhost"
$$p{"host"}
MC/DC0%0/1
$$p{"db"} // "NULL"
$$p{"db"}
MC/DC0%0/1
$$p{"command"} // "Sleep"
$$p{"command"}
MC/DC0%0/1
$$p{"time"} // 0
$$p{"time"}
MC/DC0%0/1
$$p{"state"} // ""
$$p{"state"}
MC/DC0%0/1
$$p{"info"} // "NULL"
$$p{"info"}
Truth table0%0/2
A
A= $$p{"host"}
Aresult
11
00
Truth table0%0/2
A
A= $$p{"db"}
Aresult
11
00
Truth table0%0/2
A
A= $$p{"command"}
Aresult
11
00
Truth table0%0/2
A
A= $$p{"time"}
Aresult
11
00
Truth table0%0/2
A
A= $$p{"state"}
Aresult
11
00
Truth table0%0/2
A
A= $$p{"info"}
Aresult
11
00
523 }
524 }
525 0 return ( _render( $o, [qw( Id User Host db Command Time State Info Progress )], \@r ), 1 );
526 }
527 44 ▶ if ( $s =~ /\AKILL (?:CONNECTION )?(\d+)\z/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s =~ /\AKILL (?:CONNECTION )?(\d+)\z/i) 0 44 44
528 0 my $id = $1;
529 0 ▶ for my $p ( @{ $m->{processlist} || [] } ) {
Condition0%0/2
$$m{'processlist'} || []
l!l
00
MC/DC0%0/1
$$m{'processlist'} || []
$$m{'processlist'}
Truth table0%0/2
A
A= $$m{'processlist'}
Aresult
11
00
530 0 ▶ next unless $id >= $p->{id} && $id < $p->{id} + ( $p->{count} // 1 );
Branch: 1 branch
BranchTrueFalseTotal
unless $id >= $$p{"id"} and $id < $$p{"id"} + ($$p{"count"} // 1) 0 0 0
Condition0%0/5
$id >= $$p{"id"} and $id < $$p{"id"} + ($$p{"count"} // 1)
!ll&&!rl&&r
000
$$p{"count"} // 1
l!l
00
MC/DC0%0/2
$id >= $$p{"id"} and $id < $$p{"id"} + ($$p{"count"} // 1)
$id >= $$p{"id"} $id < $$p{"id"} + ($$p{"count"} // 1)
MC/DC0%0/1
$$p{"count"} // 1
$$p{"count"}
Truth table0%0/3
A and B
A= $id >= $$p{"id"}B= $id < $$p{"id"} + ($$p{"count"} // 1)
ABresult
0X0
100
111
Truth table0%0/2
A
A= $$p{"count"}
Aresult
11
00
531 0 ▶ $p->{count} = ( $p->{count} // 1 ) - 1;
Condition0%0/2
$$p{"count"} // 1
l!l
00
MC/DC0%0/1
$$p{"count"} // 1
$$p{"count"}
Truth table0%0/2
A
A= $$p{"count"}
Aresult
11
00
532 0 ▶ $m->{status}{Threads_connected}-- if $m->{status} && $m->{status}{Threads_connected};
Branch: 1 branch
BranchTrueFalseTotal
if $$m{"status"} and $$m{"status"}{"Threads_connected"} 0 0 0
Condition0%0/3
$$m{"status"} and $$m{"status"}{"Threads_connected"}
!ll&&!rl&&r
000
MC/DC0%0/2
$$m{"status"} and $$m{"status"}{"Threads_connected"}
$$m{"status"} $$m{"status"}{"Threads_connected"}
Truth table0%0/3
A and B
A= $$m{"status"}B= $$m{"status"}{"Threads_connected"}
ABresult
0X0
100
111
533 0 ▶ $m->{processlist} = [ grep { ( $_->{count} // 1 ) > 0 } @{ $m->{processlist} } ];
Condition0%0/2
$$_{"count"} // 1
l!l
00
MC/DC0%0/1
$$_{"count"} // 1
$$_{"count"}
Truth table0%0/2
A
A= $$_{"count"}
Aresult
11
00
534 0 return ( '', 1 );
535 }
536 0 return _err( 1094, 'HY000', "Unknown thread id: $id" );
537 }
538 44 ▶ if ( $s =~ /\ASHOW DATABASES(?: LIKE (\S+))?\z/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s =~ /\ASHOW DATABASES(?: LIKE (\S+))?\z/i) 2 42 44
539 2 my $pat = $1;
540 2 my $re = _like($pat);
541 2 ▶ my @d = grep { !defined $re || $_ =~ $re } sort( qw( information_schema mysql performance_schema sys ), @{ $m->{databases} || [] } );
Condition80%4/5
!defined($re) || $_ =~ /$re/
l!l&&r!l&&!r
514
$$m{'databases'} || []
l!l
20
MC/DC100%2/2
!defined($re) || $_ =~ /$re/
!defined($re) $_ =~ /$re/
MC/DC0%0/1
$$m{'databases'} || []
$$m{'databases'}
Truth table100%3/3
not(A) || B
A= !defined($re)B= $_ =~ /$re/
ABresult
1X1
011
000
Truth table50%1/2
A
A= $$m{'databases'}
Aresult
11
00
542 2 ▶ return ( _render( $o, [ defined $pat ? "Database ($pat)" =~ s/['"]//gr : 'Database' ], [ map { [$_] } @d ] ), 1 );
Branch: 1 branch
BranchTrueFalseTotal
defined $pat ? : 1 1 2
543 }
544 42 ▶ if ( $s =~ /\ASELECT (.+?) FROM mysql\.user(?: WHERE (.+?))?(?: ORDER BY .+)?\z/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s =~ /\ASELECT (.+?) FROM mysql\.user(?: WHERE (.+?))?(?: ORDER BY .+)?\z/i) 9 33 42
545 9 my ( $cols, $where ) = ( $1, $2 );
546 9 ▶ $cols = 'Host,User' if $cols =~ /\A\s*\*\s*\z/;
Branch: 1 branch
BranchTrueFalseTotal
if $cols =~ /\A\s*\*\s*\z/ 0 9 9
547 9 my @rows;
548 9 ▶ for my $k ( sort keys %{ $m->{users} || {} } ) {
Condition50%1/2
$$m{'users'} || {}
l!l
90
MC/DC0%0/1
$$m{'users'} || {}
$$m{'users'}
Truth table50%1/2
A
A= $$m{'users'}
Aresult
11
00
549 33 my ( $u, $h ) = split /@/, $k, 2;
550 33 my $a = $m->{users}{$k};
551 33 ▶ my $hash = defined $a->{password} ? _pwhash( $a->{password} ) : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $$a{'password'} ? : 24 9 33
552 33 ▶ my %row = ( user => $u, host => $h, plugin => ( $a->{auth} // 'mysql_native_password' ), authentication_string => $hash,
Condition100%2/2
$$a{"auth"} // "mysql_native_password"
l!l
924
MC/DC100%1/1
$$a{"auth"} // "mysql_native_password"
$$a{"auth"}
Truth table100%2/2
A
A= $$a{"auth"}
Aresult
11
00
553 password => $hash, account_locked => 'N', password_expired => 'N' );
554 33 ▶ my $keep = _where( \%row, $where ) // return _gap($sql);
Condition50%1/2
_where(\%row, $where) // (return _gap($sql))
l!l
330
MC/DC0%0/1
_where(\%row, $where) // (return _gap($sql))
_where(\%row, $where)
Truth table50%1/2
A
A= _where(\%row, $where)
Aresult
11
00
555 33 ▶ push @rows, \%row if $keep;
Branch: 1 branch
BranchTrueFalseTotal
if $keep 19 14 33
556 }
557 9 ▶ my ( $hd, $r ) = _sel_rows( _sel_items($cols), \@rows, $env ) or return _gap($sql);
Branch: 1 branch
BranchTrueFalseTotal
() = _sel_rows(_sel_items($cols), \@rows, $env) or return _gap($sql) 8 1 9
558 8 return ( _render( $o, $hd, $r ), 1 );
559 }
560 # mysql.db: Rechte je Datenbank aus den Grants (db.*)
561 33 ▶ if ( $s =~ /\ASELECT (.+?) FROM mysql\.db(?: WHERE (.+?))?(?: ORDER BY .+)?\z/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s =~ /\ASELECT (.+?) FROM mysql\.db(?: WHERE (.+?))?(?: ORDER BY .+)?\z/i) 1 32 33
562 1 my ( $cols, $where ) = ( $1, $2 );
563 1 my @c = map { s/[`\s]//gr } split /,/, $cols;
564 0 ▶ @c = ( qw( Host Db User ), map { $DB_PRIV{$_} } @DB_PRIVS ) if $c[0] eq '*';
Branch: 1 branch
BranchTrueFalseTotal
if $c[0] eq "*" 0 1 1
565 1 my @r;
566 1 ▶ for my $k ( sort keys %{ $m->{users} || {} } ) {
Condition50%1/2
$$m{'users'} || {}
l!l
10
MC/DC0%0/1
$$m{'users'} || {}
$$m{'users'}
Truth table50%1/2
A
A= $$m{'users'}
Aresult
11
00
567 5 my ( $u, $h ) = split /@/, $k, 2;
568 5 my $g = _grant_map( $m->{users}{$k} );
569 5 for my $obj ( sort keys %$g ) {
570 3 ▶ my ($db) = $obj =~ /\A`([^`]+)`\.\*\z/ or next;
Branch: 1 branch
BranchTrueFalseTotal
my($db) = $obj =~ /\A`([^`]+)`\.\*\z/ or next 3 0 3
571 3 my %have = map { $_ => 1 } @{ $g->{$obj} };
572 my %row = ( host => $h, db => $db, user => $u,
573 3 ▶ map { lc $DB_PRIV{$_} => ( $have{'ALL PRIVILEGES'} || $have{$_} ? 'Y' : 'N' ) } @DB_PRIVS );
Branch: 1 branch
BranchTrueFalseTotal
$have{'ALL PRIVILEGES'} || $have{$_} ? : 37 17 54
Condition100%3/3
$have{"ALL PRIVILEGES"} or $have{$_}
l!l&&r!l&&!r
36117
MC/DC100%2/2
$have{"ALL PRIVILEGES"} or $have{$_}
$have{"ALL PRIVILEGES"} $have{$_}
Truth table100%3/3
A or B
A= $have{"ALL PRIVILEGES"}B= $have{$_}
ABresult
1X1
011
000
574 3 $row{grant_priv} = 'N';
575 3 ▶ my $keep = _where( \%row, $where ) // return _gap($sql);
Condition50%1/2
_where(\%row, $where) // (return _gap($sql))
l!l
30
MC/DC0%0/1
_where(\%row, $where) // (return _gap($sql))
_where(\%row, $where)
Truth table50%1/2
A
A= _where(\%row, $where)
Aresult
11
00
576 3 ▶ next unless $keep;
Branch: 1 branch
BranchTrueFalseTotal
unless $keep 1 2 3
577 2 ▶ push @r, [ map { $row{ lc $_ } // return _gap($sql) } @c ];
Condition50%1/2
$row{lc $_} // (return _gap($sql))
l!l
80
MC/DC0%0/1
$row{lc $_} // (return _gap($sql))
$row{lc $_}
Truth table50%1/2
A
A= $row{lc $_}
Aresult
11
00
578 }
579 }
580 1 return ( _render( $o, \@c, \@r ), 1 );
581 }
582 # SELECT ohne FROM: Konstanten und Funktionen (SELECT 1 AS ok, SELECT NOW(), CONCAT(…))
583 32 ▶ if ( $s =~ /\ASELECT (.+)\z/i && $1 !~ /\bFROM\b|\@\@|\(\s*SELECT\b/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s =~ /\ASELECT (.+)\z/i and not $1 =~ /\bFROM\b|\@\@|\(\s*SELECT\b/i) 8 24 32
Condition100%3/3
$s =~ /\ASELECT (.+)\z/i and not $1 =~ /\bFROM\b|\@\@|\(\s*SELECT\b/i
!ll&&!rl&&r
2048
MC/DC100%2/2
$s =~ /\ASELECT (.+)\z/i and not $1 =~ /\bFROM\b|\@\@|\(\s*SELECT\b/i
$s =~ /\ASELECT (.+)\z/i not $1 =~ /\bFROM\b|\@\@|\(\s*SELECT\b/i
Truth table100%3/3
A and not(B)
A= $s =~ /\ASELECT (.+)\z/iB= not $1 =~ /\bFROM\b|\@\@|\(\s*SELECT\b/i
ABresult
0X0
100
111
584 8 ▶ my ( $h, $r ) = _sel_rows( _sel_items($1), [ {} ], $env ) or return _gap($sql);
Branch: 1 branch
BranchTrueFalseTotal
() = _sel_rows(_sel_items($1), [{}], $env) or return _gap($sql) 8 0 8
585 8 return ( _render( $o, $h, $r ), 1 );
586 }
587 # Tabellen der Anwendung: nur, was der Fall unter mariadb.tables vorgibt
588 24 ▶ if ( $s =~ /\ASELECT (.+?) FROM `?(\w+)`?\.`?(\w+)`?(?: WHERE (.+?))?(?: LIMIT \d+)?\z/i && lc $2 ne 'mysql' && lc $2 ne 'information_schema' && lc $2 ne 'performance_schema' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s =~ /\ASELECT (.+?) FROM `?(\w+)`?\.`?(\w+)`?(?: WHERE (.+?))?(?: LIMIT \d+)?\z/i and lc $2 ne "mysql" and lc $2 ne "information_schema" and lc $2 ne "performance_schema") 4 20 24
Condition66%6/9
$s =~ /\ASELECT (.+?) FROM `?(\w+)`?\.`?(\w+)`?(?: WHERE (.+?))?(?: LIMIT \d+)?\z/i and lc $2 ne "mysql" and lc $2 ne "information_schema" and lc $2 ne "performance_schema"
!ll&&!rl&&r
2004
$s =~ /\ASELECT (.+?) FROM `?(\w+)`?\.`?(\w+)`?(?: WHERE (.+?))?(?: LIMIT \d+)?\z/i and lc $2 ne "mysql" and lc $2 ne "information_schema"
!ll&&!rl&&r
2004
$s =~ /\ASELECT (.+?) FROM `?(\w+)`?\.`?(\w+)`?(?: WHERE (.+?))?(?: LIMIT \d+)?\z/i and lc $2 ne "mysql"
!ll&&!rl&&r
2004
MC/DC25%1/4
$s =~ /\ASELECT (.+?) FROM `?(\w+)`?\.`?(\w+)`?(?: WHERE (.+?))?(?: LIMIT \d+)?\z/i and lc $2 ne "mysql" and lc $2 ne "information_schema" and lc $2 ne "performance_schema"
$s =~ /\ASELECT (.+?) FROM `?(\w+)`?\.`?(\w+)`?(?: WHERE (.+?))?(?: LIMIT \d+)?\z/i lc $2 ne "mysql" lc $2 ne "information_schema" lc $2 ne "performance_schema"
Truth table40%2/5
A and B and C and D
A= $s =~ /\ASELECT (.+?) FROM `?(\w+)`?\.`?(\w+)`?(?: WHERE (.+?))?(?: LIMIT \d+)?\z/iB= lc $2 ne "mysql"C= lc $2 ne "information_schema"D= lc $2 ne "performance_schema"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
589 4 my ( $cols, $db, $tb, $where ) = ( $1, $2, $3, $4 );
590 4 ▶ my $t = ( $m->{tables} || {} )->{"$db.$tb"};
Condition50%1/2
$$m{'tables'} || {}
l!l
40
MC/DC0%0/1
$$m{'tables'} || {}
$$m{'tables'}
Truth table50%1/2
A
A= $$m{'tables'}
Aresult
11
00
591 4 ▶ if ( !$t ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($t) 2 2 4
592 2 ▶ return _err( 1049, '42000', "Unknown database '$db'" ) unless grep { $_ eq $db } @{ $m->{databases} || [] };
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_ eq $db;} @{$$m{"databases"} or [];} 1 1 2
Condition50%1/2
$$m{'databases'} || []
l!l
20
MC/DC0%0/1
$$m{'databases'} || []
$$m{'databases'}
Truth table50%1/2
A
A= $$m{'databases'}
Aresult
11
00
593 1 return _gap($sql);
594 }
595 2 ▶ my @all = @{ $t->{columns} || [] };
Condition50%1/2
$$t{'columns'} || []
l!l
20
MC/DC0%0/1
$$t{'columns'} || []
$$t{'columns'}
Truth table50%1/2
A
A= $$t{'columns'}
Aresult
11
00
596 2 my @r;
597 2 ▶ for my $row ( @{ $t->{rows} || [] } ) {
Condition50%1/2
$$t{'rows'} || []
l!l
20
MC/DC0%0/1
$$t{'rows'} || []
$$t{'rows'}
Truth table50%1/2
A
A= $$t{'rows'}
Aresult
11
00
598 4 my %row = map { lc $all[$_] => $row->[$_] } 0 .. $#all;
599 4 ▶ my $keep = _where( \%row, $where ) // return _gap($sql);
Condition50%1/2
_where(\%row, $where) // (return _gap($sql))
l!l
40
MC/DC0%0/1
_where(\%row, $where) // (return _gap($sql))
_where(\%row, $where)
Truth table50%1/2
A
A= _where(\%row, $where)
Aresult
11
00
600 4 ▶ push @r, \%row if $keep;
Branch: 1 branch
BranchTrueFalseTotal
if $keep 3 1 4
601 }
602 2 ▶ my ( $hd, $r ) = _sel_rows( _sel_items( $cols eq '*' ? join( ',', @all ) : $cols ), \@r, $env ) or return _gap($sql);
Branch: 2 branches
BranchTrueFalseTotal
() = _sel_rows(_sel_items($cols eq "*" ? join(",", @all) : $cols), \@r, $env) or return _gap($sql) 2 0 2
$cols eq '*' ? : 1 1 2
603 2 return ( _render( $o, $hd, $r ), 1 );
604 }
605 20 ▶ if ( $s =~ /\ASHOW CREATE USER (.+?)\z/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s =~ /\ASHOW CREATE USER (.+?)\z/i) 1 19 20
606 1 ▶ my ( $u, $h ) = _account($1) or return _gap($sql);
Branch: 1 branch
BranchTrueFalseTotal
() = _account($1) or return _gap($sql) 1 0 1
607 1 ▶ my $a = $m->{users}{"$u\@$h"} or return _err( 1396, 'HY000', "Operation SHOW CREATE USER failed for '$u'\@'$h'" );
Branch: 1 branch
BranchTrueFalseTotal
my $a = $$m{"users"}{"$u\@$h"} or return _err(1396, "HY000", "Operation SHOW CREATE USER failed for '${u}'\@'${h}'") 1 0 1
608 1 ▶ my $ident = ( $a->{auth} // '' ) eq 'unix_socket' ? ' IDENTIFIED VIA unix_socket' : defined $a->{password} ? " IDENTIFIED BY PASSWORD '" . _pwhash( $a->{password} ) . "'" : '';
Branch: 2 branches
BranchTrueFalseTotal
($$a{'auth'} // '') eq 'unix_socket' ? : 0 1 1
defined $$a{'password'} ? : 1 0 1
Condition50%1/2
$$a{"auth"} // ""
l!l
01
MC/DC0%0/1
$$a{"auth"} // ""
$$a{"auth"}
Truth table50%1/2
A
A= $$a{"auth"}
Aresult
11
00
609 1 return ( _render( $o, ["CREATE USER for $u\@$h"], [ ["CREATE USER `$u`\@`$h`$ident"] ] ), 1 );
610 }
611 19 ▶ if ( $s =~ /\ASHOW GRANTS(?: FOR (.+?))?\z/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s =~ /\ASHOW GRANTS(?: FOR (.+?))?\z/i) 2 17 19
612 2 my $who = $1;
613 2 my $key;
614 2 ▶ if ( defined $who && $who !~ /\ACURRENT_USER/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $who and not $who =~ /\ACURRENT_USER/i) { } 2 0 2
Condition33%1/3
defined $who and not $who =~ /\ACURRENT_USER/i
!ll&&!rl&&r
002
MC/DC0%0/2
defined $who and not $who =~ /\ACURRENT_USER/i
defined $who not $who =~ /\ACURRENT_USER/i
Truth table33%1/3
A and not(B)
A= defined $whoB= not $who =~ /\ACURRENT_USER/i
ABresult
0X0
100
111
615 2 ▶ my ( $u, $h ) = _account($who) or return _gap($sql);
Branch: 1 branch
BranchTrueFalseTotal
() = _account($who) or return _gap($sql) 2 0 2
616 2 $key = "$u\@$h";
617 2 ▶ return _err( 1141, '42000', "There is no such grant defined for user '$u' on host '$h'" ) unless $m->{users}{$key};
Branch: 1 branch
BranchTrueFalseTotal
unless $$m{"users"}{$key} 0 2 2
618 }
619 0 else { $key = $acc }
620 2 my ( $u, $h ) = split /@/, $key, 2;
621 2 ▶ my $a = $m->{users}{$key} || {};
Condition50%1/2
$$m{'users'}{$key} || {}
l!l
20
MC/DC0%0/1
$$m{'users'}{$key} || {}
$$m{'users'}{$key}
Truth table50%1/2
A
A= $$m{'users'}{$key}
Aresult
11
00
622 2 my $g = _grant_map($a);
623 2 my @l;
624 2 ▶ my $ident = $a->{auth} && $a->{auth} eq 'unix_socket' ? ' IDENTIFIED VIA unix_socket' : defined $a->{password} ? " IDENTIFIED BY PASSWORD '" . _pwhash( $a->{password} ) . "'" : '';
Branch: 2 branches
BranchTrueFalseTotal
$$a{'auth'} && $$a{'auth'} eq 'unix_socket' ? : 0 2 2
defined $$a{'password'} ? : 2 0 2
Condition33%1/3
$$a{"auth"} and $$a{"auth"} eq "unix_socket"
!ll&&!rl&&r
200
MC/DC0%0/2
$$a{"auth"} and $$a{"auth"} eq "unix_socket"
$$a{"auth"} $$a{"auth"} eq "unix_socket"
Truth table33%1/3
A and B
A= $$a{"auth"}B= $$a{"auth"} eq "unix_socket"
ABresult
0X0
100
111
625 0 ▶ my $global = $g->{'*.*'} ? join( ', ', @{ $g->{'*.*'} } ) : 'USAGE';
Branch: 1 branch
BranchTrueFalseTotal
$$g{'*.*'} ? : 0 2 2
626 2 ▶ push @l, "GRANT $global ON *.* TO `$u`\@`$h`$ident" . ( $u eq 'root' ? ' WITH GRANT OPTION' : '' );
Branch: 1 branch
BranchTrueFalseTotal
$u eq 'root' ? : 0 2 2
627 2 push @l, 'GRANT ' . join( ', ', @{ $g->{$_} } ) . " ON $_ TO `$u`\@`$h`" for sort grep { $_ ne '*.*' } keys %$g;
628 2 return ( _render( $o, ["Grants for $u\@$h"], [ map { [$_] } @l ] ), 1 );
629 }
630 17 ▶ if ( $s =~ /\ACREATE USER (IF NOT EXISTS )?(\S+)(?: IDENTIFIED BY (PASSWORD )?(['"])(.*)\4)?\z/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s =~ /\ACREATE USER (IF NOT EXISTS )?(\S+)(?: IDENTIFIED BY (PASSWORD )?(['"])(.*)\4)?\z/i) 3 14 17
631 3 ▶ my ( $ine, $who, $pw ) = ( $1, $2, $3 ? _pw_from_hash( $m, $5 ) : $5 );
Branch: 1 branch
BranchTrueFalseTotal
$3 ? : 1 2 3
632 3 ▶ return _err( 1372, 'HY000', 'Password hash should be a 41-digit hexadecimal number' ) if $3 && !defined $pw;
Branch: 1 branch
BranchTrueFalseTotal
if $3 and not defined $pw 0 3 3
Condition66%2/3
$3 and not defined $pw
!ll&&!rl&&r
210
MC/DC0%0/2
$3 and not defined $pw
$3 not defined $pw
Truth table66%2/3
A and not(B)
A= $3B= not defined $pw
ABresult
0X0
100
111
633 3 ▶ return _err( 1227, '42000', 'Access denied; you need (at least one of) the CREATE USER privilege(s) for this operation' ) unless $super;
Branch: 1 branch
BranchTrueFalseTotal
unless $super 0 3 3
634 3 ▶ my ( $u, $h ) = _account($who) or return _gap($sql);
Branch: 1 branch
BranchTrueFalseTotal
() = _account($who) or return _gap($sql) 3 0 3
635 3 ▶ if ( $m->{users}{"$u\@$h"} ) { return ( '', 1 ) if $ine; return _err( 1396, 'HY000', "Operation CREATE USER failed for '$u'\@'$h'" ) }
Branch: 2 branches
BranchTrueFalseTotal
if ($$m{"users"}{"$u\@$h"}) 1 2 3
if $ine 0 1 1
636 2 ▶ $m->{users}{"$u\@$h"} = { defined $pw ? ( password => $pw ) : (), grants => [] };
Branch: 1 branch
BranchTrueFalseTotal
defined $pw ? : 2 0 2
637 2 return ( '', 1 );
638 }
639 14 ▶ if ( $s =~ /\ADROP USER (IF EXISTS )?(.+)\z/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s =~ /\ADROP USER (IF EXISTS )?(.+)\z/i) 0 14 14
640 0 my ( $ie, $list ) = ( $1, $2 );
641 0 ▶ return _err( 1227, '42000', 'Access denied; you need (at least one of) the CREATE USER privilege(s) for this operation' ) unless $super;
Branch: 1 branch
BranchTrueFalseTotal
unless $super 0 0 0
642 0 for my $who ( split /\s*,\s*/, $list ) {
643 0 ▶ my ( $u, $h ) = _account($who) or return _gap($sql);
Branch: 1 branch
BranchTrueFalseTotal
() = _account($who) or return _gap($sql) 0 0 0
644 0 ▶ next if !$m->{users}{"$u\@$h"} && $ie;
Branch: 1 branch
BranchTrueFalseTotal
if not $$m{"users"}{"$u\@$h"} and $ie 0 0 0
Condition0%0/3
not $$m{"users"}{"$u\@$h"} and $ie
!ll&&!rl&&r
000
MC/DC0%0/2
not $$m{"users"}{"$u\@$h"} and $ie
not $$m{"users"}{"$u\@$h"} $ie
Truth table0%0/3
not(A) and B
A= not $$m{"users"}{"$u\@$h"}B= $ie
ABresult
0X0
100
111
645 0 ▶ return _err( 1396, 'HY000', "Operation DROP USER failed for '$u'\@'$h'" ) unless delete $m->{users}{"$u\@$h"};
Branch: 1 branch
BranchTrueFalseTotal
unless delete $$m{"users"}{"$u\@$h"} 0 0 0
646 }
647 0 return ( '', 1 );
648 }
649 14 ▶ if ( $s =~ /\A(?:ALTER USER|SET PASSWORD FOR) (\S+) (?:IDENTIFIED BY (PASSWORD )?(['"])(.*)\3|= PASSWORD\((['"])(.*)\5\))\z/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s =~ /\A(?:ALTER USER|SET PASSWORD FOR) (\S+) (?:IDENTIFIED BY (PASSWORD )?(['"])(.*)\3|= PASSWORD\((['"])(.*)\5\))\z/i) 0 14 14
650 0 ▶ my ( $who, $pw ) = ( $1, $2 ? _pw_from_hash( $m, $4 ) : $4 // $6 );
Branch: 1 branch
BranchTrueFalseTotal
$2 ? : 0 0 0
Condition0%0/3
$4 // $6
l!l&&r!l&&!r
000
MC/DC0%0/2
$4 // $6
$4 $6
Truth table0%0/3
A // B
A= $4B= $6
ABresult
1X1
011
000
651 0 ▶ return _err( 1372, 'HY000', 'Password hash should be a 41-digit hexadecimal number' ) if $2 && !defined $pw;
Branch: 1 branch
BranchTrueFalseTotal
if $2 and not defined $pw 0 0 0
Condition0%0/3
$2 and not defined $pw
!ll&&!rl&&r
000
MC/DC0%0/2
$2 and not defined $pw
$2 not defined $pw
Truth table0%0/3
A and not(B)
A= $2B= not defined $pw
ABresult
0X0
100
111
652 0 ▶ my ( $u, $h ) = _account($who) or return _gap($sql);
Branch: 1 branch
BranchTrueFalseTotal
() = _account($who) or return _gap($sql) 0 0 0
653 0 ▶ return _err( 1396, 'HY000', "Operation ALTER USER failed for '$u'\@'$h'" ) unless $m->{users}{"$u\@$h"};
Branch: 1 branch
BranchTrueFalseTotal
unless $$m{"users"}{"$u\@$h"} 0 0 0
654 0 $m->{users}{"$u\@$h"}{password} = $pw;
655 0 return ( '', 1 );
656 }
657 14 ▶ if ( $s =~ /\A(GRANT|REVOKE) (.+?) ON (?:TABLE )?(\S+) (TO|FROM) (\S+)(?: IDENTIFIED BY (PASSWORD )?(['"])(.*)\7)?(?: WITH GRANT OPTION)?\z/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s =~ /\A(GRANT|REVOKE) (.+?) ON (?:TABLE )?(\S+) (TO|FROM) (\S+)(?: IDENTIFIED BY (PASSWORD )?(['"])(.*)\7)?(?: WITH GRANT OPTION)?\z/i) 3 11 14
658 3 ▶ my ( $verb, $privs, $obj, $who, $pw ) = ( uc $1, $2, $3, $5, $6 ? _pw_from_hash( $m, $8 ) : $8 );
Branch: 1 branch
BranchTrueFalseTotal
$6 ? : 0 3 3
659 3 ▶ return _err( 1227, '42000', 'Access denied; you need (at least one of) the GRANT OPTION privilege(s) for this operation' ) unless $super;
Branch: 1 branch
BranchTrueFalseTotal
unless $super 0 3 3
660 3 ▶ my ( $u, $h ) = _account($who) or return _gap($sql);
Branch: 1 branch
BranchTrueFalseTotal
() = _account($who) or return _gap($sql) 3 0 3
661 3 my $a = $m->{users}{"$u\@$h"};
662 3 ▶ if ( !$a ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($a) 0 3 3
663 0 ▶ return _err( 1141, '42000', "There is no such grant defined for user '$u' on host '$h'" ) if $verb eq 'REVOKE';
Branch: 1 branch
BranchTrueFalseTotal
if $verb eq "REVOKE" 0 0 0
664 0 ▶ return _err( 1133, '28000', "Can't find any matching row in the user table" ) unless defined $pw;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $pw 0 0 0
665 0 $a = $m->{users}{"$u\@$h"} = { password => $pw, grants => [] };
666 }
667 3 ▶ $a->{password} = $pw if defined $pw;
Branch: 1 branch
BranchTrueFalseTotal
if defined $pw 0 3 3
668 3 my $g = _grant_map($a);
669 3 my $k = _norm_obj($obj);
670 3 my @p = _priv_list($privs);
671 3 ▶ if ( $verb eq 'GRANT' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($verb eq 'GRANT') { } 2 1 3
672 2 ▶ my %have = map { $_ => 1 } @{ $g->{$k} || [] }, @p;
Condition100%2/2
$$g{$k} || []
l!l
11
MC/DC100%1/1
$$g{$k} || []
$$g{$k}
Truth table100%2/2
A
A= $$g{$k}
Aresult
11
00
673 2 ▶ $g->{$k} = $have{'ALL PRIVILEGES'} ? ['ALL PRIVILEGES'] : [ _priv_list( join ',', keys %have ) ];
Branch: 1 branch
BranchTrueFalseTotal
$have{'ALL PRIVILEGES'} ? : 0 2 2
674 }
675 else {
676 1 ▶ return _err( 1141, '42000', "There is no such grant defined for user '$u' on host '$h'" ) unless $g->{$k};
Branch: 1 branch
BranchTrueFalseTotal
unless $$g{$k} 0 1 1
677 1 my %drop = map { $_ => 1 } @p;
678 1 ▶ $g->{$k} = $drop{'ALL PRIVILEGES'} ? [] : [ grep { !$drop{$_} } @{ $g->{$k} } ];
Branch: 1 branch
BranchTrueFalseTotal
$drop{'ALL PRIVILEGES'} ? : 0 1 1
679 }
680 3 _store_grants( $a, $g );
681 3 return ( '', 1 );
682 }
683 11 ▶ return ( '', 1 ) if $s =~ /\AFLUSH (?:PRIVILEGES|LOGS|TABLES|STATUS|HOSTS)\z/i;
Branch: 1 branch
BranchTrueFalseTotal
if $s =~ /\AFLUSH (?:PRIVILEGES|LOGS|TABLES|STATUS|HOSTS)\z/i 0 11 11
684 0 ▶ if ( $s =~ /\AFLUSH BINARY LOGS\z/i ) { _rotate_binlog($dev); return ( '', 1 ) }
Branch: 1 branch
BranchTrueFalseTotal
if ($s =~ /\AFLUSH BINARY LOGS\z/i) 0 11 11
685 11 ▶ if ( $s =~ /\ASHOW (?:BINARY|MASTER) LOGS\z/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s =~ /\ASHOW (?:BINARY|MASTER) LOGS\z/i) 1 10 11
686 1 ▶ return _err( 1381, 'HY000', 'You are not using binary logging' ) unless ( $v->{log_bin} // 'OFF' ) eq 'ON';
Branch: 1 branch
BranchTrueFalseTotal
unless ($$v{"log_bin"} // "OFF") eq "ON" 0 1 1
Condition50%1/2
$$v{"log_bin"} // "OFF"
l!l
10
MC/DC0%0/1
$$v{"log_bin"} // "OFF"
$$v{"log_bin"}
Truth table50%1/2
A
A= $$v{"log_bin"}
Aresult
11
00
687 1 ▶ return ( _render( $o, [qw( Log_name File_size )], [ map { [ $_->{name}, _binlog_size( $dev, $_ ) ] } @{ $m->{binlogs} || [] } ] ), 1 );
Condition50%1/2
$$m{'binlogs'} || []
l!l
10
MC/DC0%0/1
$$m{'binlogs'} || []
$$m{'binlogs'}
Truth table50%1/2
A
A= $$m{'binlogs'}
Aresult
11
00
688 }
689 10 ▶ if ( $s =~ /\ASHOW (?:MASTER|BINLOG) STATUS\z/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s =~ /\ASHOW (?:MASTER|BINLOG) STATUS\z/i) 0 10 10
690 0 ▶ my $last = ( $m->{binlogs} || [] )->[-1] or return ( '', 1 );
Branch: 1 branch
BranchTrueFalseTotal
my $last = ($$m{"binlogs"} || [])->[-1] or return "", 1 0 0 0
Condition0%0/2
$$m{'binlogs'} || []
l!l
00
MC/DC0%0/1
$$m{'binlogs'} || []
$$m{'binlogs'}
Truth table0%0/2
A
A= $$m{'binlogs'}
Aresult
11
00
691 0 ▶ return ( _render( $o, [qw( File Position Binlog_Do_DB Binlog_Ignore_DB )], [ [ $last->{name}, $last->{position} // 4211, '', '' ] ] ), 1 );
Condition0%0/2
$$last{"position"} // 4211
l!l
00
MC/DC0%0/1
$$last{"position"} // 4211
$$last{"position"}
Truth table0%0/2
A
A= $$last{"position"}
Aresult
11
00
692 }
693 10 ▶ if ( $s =~ /\APURGE (?:BINARY|MASTER) LOGS (TO|BEFORE) (['"])(.+)\2\z/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s =~ /\APURGE (?:BINARY|MASTER) LOGS (TO|BEFORE) (['"])(.+)\2\z/i) 2 8 10
694 2 my ( $how, $what ) = ( uc $1, $3 );
695 2 ▶ return _err( 1227, '42000', 'Access denied; you need (at least one of) the SUPER, BINLOG ADMIN privilege(s) for this operation' ) unless $super;
Branch: 1 branch
BranchTrueFalseTotal
unless $super 0 2 2
696 2 ▶ my @b = @{ $m->{binlogs} || [] };
Condition50%1/2
$$m{'binlogs'} || []
l!l
20
MC/DC0%0/1
$$m{'binlogs'} || []
$$m{'binlogs'}
Truth table50%1/2
A
A= $$m{'binlogs'}
Aresult
11
00
697 2 my @drop;
698 2 ▶ if ( $how eq 'TO' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($how eq 'TO') { } 2 0 2
699 2 my ($i) = grep { $b[$_]{name} eq $what } 0 .. $#b;
700 2 ▶ return _err( 1373, 'HY000', 'Target log not found in binlog index' ) unless defined $i;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $i 0 2 2
701 2 @drop = @b[ 0 .. $i - 1 ];
702 }
703 else {
704 0 ▶ @drop = grep { defined $_->{mtime} && $_->{mtime} lt $what } @b[ 0 .. $#b - 1 ];
Condition0%0/3
defined $$_{'mtime'} && $$_{'mtime'} lt $what
!ll&&!rl&&r
000
MC/DC0%0/2
defined $$_{'mtime'} && $$_{'mtime'} lt $what
defined $$_{'mtime'} $$_{'mtime'} lt $what
Truth table0%0/3
A && B
A= defined $$_{'mtime'}B= $$_{'mtime'} lt $what
ABresult
0X0
100
111
705 }
706 2 _drop_binlogs( $dev, @drop );
707 2 return ( '', 1 );
708 }
709 8 ▶ if ( $s =~ /\ASHOW (?:SLAVE|REPLICA) STATUS\z/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s =~ /\ASHOW (?:SLAVE|REPLICA) STATUS\z/i) 3 5 8
710 3 ▶ my $r = $m->{replica} or return ( '', 1 );
Branch: 1 branch
BranchTrueFalseTotal
my $r = $$m{"replica"} or return "", 1 3 0 3
711 3 my @c = qw( Slave_IO_State Master_Host Master_User Master_Port Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Master_Log_File
712 Slave_IO_Running Slave_SQL_Running Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Seconds_Behind_Master Last_IO_Errno Last_IO_Error
713 Last_SQL_Errno Last_SQL_Error Using_Gtid );
714 3 ▶ my $err = $r->{sql} eq 'No' ? ( $r->{last_error} // '' ) : '';
Branch: 1 branch
BranchTrueFalseTotal
$$r{'sql'} eq 'No' ? : 1 2 3
Condition50%1/2
$$r{"last_error"} // ""
l!l
10
MC/DC0%0/1
$$r{"last_error"} // ""
$$r{"last_error"}
Truth table50%1/2
A
A= $$r{"last_error"}
Aresult
11
00
715 my %row = (
716 Slave_IO_State => $r->{io} eq 'Yes' ? 'Waiting for master to send event' : '', Master_Host => $r->{master_host}, Master_User => $r->{master_user} // 'repl',
717 Master_Port => $r->{master_port} // 3306, Master_Log_File => $r->{master_log_file} // 'mariadb-bin.000412', Read_Master_Log_Pos => $r->{read_pos} // 8811204,
718 Relay_Log_File => 'mysqld-relay-bin.000077', Relay_Master_Log_File => $r->{master_log_file} // 'mariadb-bin.000412', Slave_IO_Running => $r->{io},
719 Slave_SQL_Running => $r->{sql}, Last_Errno => $r->{sql} eq 'No' ? $r->{last_errno} // 0 : 0, Last_Error => $err,
720 Skip_Counter => $v->{sql_slave_skip_counter} // 0, Exec_Master_Log_Pos => $r->{exec_pos} // 8810770,
721 Seconds_Behind_Master => $r->{sql} eq q{Yes} && $r->{io} eq q{Yes} ? $r->{behind} // 0 : q{NULL}, Last_IO_Errno => $r->{io} eq 'No' ? $r->{last_io_errno} // 2003 : 0,
722 3 ▶ Last_IO_Error => $r->{io} eq 'No' ? $r->{last_io_error} // '' : '', Last_SQL_Errno => $r->{sql} eq 'No' ? $r->{last_errno} // 0 : 0,
Branch: 6 branches
BranchTrueFalseTotal
$$r{'io'} eq 'Yes' ? : 3 0 3
$$r{'sql'} eq 'No' ? : 1 2 3
$$r{'sql'} eq 'Yes' && $$r{'io'} eq 'Yes' ? : 2 1 3
$$r{'io'} eq 'No' ? : 0 3 3
$$r{'io'} eq 'No' ? : 0 3 3
$$r{'sql'} eq 'No' ? : 1 2 3
Condition48%13/27
$$r{"master_user"} // "repl"
l!l
03
$$r{"master_port"} // 3306
l!l
03
$$r{"master_log_file"} // "mariadb-bin.000412"
l!l
03
$$r{"read_pos"} // 8811204
l!l
03
$$r{"master_log_file"} // "mariadb-bin.000412"
l!l
03
$$r{"last_errno"} // 0
l!l
10
$$v{"sql_slave_skip_counter"} // 0
l!l
30
$$r{"exec_pos"} // 8810770
l!l
03
$$r{"sql"} eq "Yes" and $$r{"io"} eq "Yes"
!ll&&!rl&&r
102
$$r{"behind"} // 0
l!l
11
$$r{"last_io_errno"} // 2003
l!l
00
$$r{"last_io_error"} // ""
l!l
00
$$r{"last_errno"} // 0
l!l
10
MC/DC0%0/1
$$r{"master_user"} // "repl"
$$r{"master_user"}
MC/DC0%0/1
$$r{"master_port"} // 3306
$$r{"master_port"}
MC/DC0%0/1
$$r{"master_log_file"} // "mariadb-bin.000412"
$$r{"master_log_file"}
MC/DC0%0/1
$$r{"read_pos"} // 8811204
$$r{"read_pos"}
MC/DC0%0/1
$$r{"master_log_file"} // "mariadb-bin.000412"
$$r{"master_log_file"}
MC/DC0%0/1
$$r{"last_errno"} // 0
$$r{"last_errno"}
MC/DC0%0/1
$$v{"sql_slave_skip_counter"} // 0
$$v{"sql_slave_skip_counter"}
MC/DC0%0/1
$$r{"exec_pos"} // 8810770
$$r{"exec_pos"}
MC/DC50%1/2
$$r{"sql"} eq "Yes" and $$r{"io"} eq "Yes"
$$r{"sql"} eq "Yes" $$r{"io"} eq "Yes"
MC/DC100%1/1
$$r{"behind"} // 0
$$r{"behind"}
MC/DC0%0/1
$$r{"last_io_errno"} // 2003
$$r{"last_io_errno"}
MC/DC0%0/1
$$r{"last_io_error"} // ""
$$r{"last_io_error"}
MC/DC0%0/1
$$r{"last_errno"} // 0
$$r{"last_errno"}
Truth table50%1/2
A
A= $$r{"master_user"}
Aresult
11
00
Truth table50%1/2
A
A= $$r{"master_port"}
Aresult
11
00
Truth table50%1/2
A
A= $$r{"master_log_file"}
Aresult
11
00
Truth table50%1/2
A
A= $$r{"read_pos"}
Aresult
11
00
Truth table50%1/2
A
A= $$r{"master_log_file"}
Aresult
11
00
Truth table50%1/2
A
A= $$r{"last_errno"}
Aresult
11
00
Truth table50%1/2
A
A= $$v{"sql_slave_skip_counter"}
Aresult
11
00
Truth table50%1/2
A
A= $$r{"exec_pos"}
Aresult
11
00
Truth table66%2/3
A and B
A= $$r{"sql"} eq "Yes"B= $$r{"io"} eq "Yes"
ABresult
0X0
100
111
Truth table100%2/2
A
A= $$r{"behind"}
Aresult
11
00
Truth table0%0/2
A
A= $$r{"last_io_errno"}
Aresult
11
00
Truth table0%0/2
A
A= $$r{"last_io_error"}
Aresult
11
00
Truth table50%1/2
A
A= $$r{"last_errno"}
Aresult
11
00
723 Last_SQL_Error => $err, Using_Gtid => 'No',
724 );
725 3 return ( _render( $o, \@c, [ [ map { $row{$_} } @c ] ] ), 1 );
726 }
727 5 ▶ if ( $s =~ /\A(STOP|START) (?:SLAVE|REPLICA)(?: (IO_THREAD|SQL_THREAD))?\z/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s =~ /\A(STOP|START) (?:SLAVE|REPLICA)(?: (IO_THREAD|SQL_THREAD))?\z/i) 4 1 5
728 4 ▶ my ( $verb, $which ) = ( uc $1, uc( $2 // '' ) );
Condition100%2/2
$2 // ""
l!l
22
MC/DC100%1/1
$2 // ""
$2
Truth table100%2/2
A
A= $2
Aresult
11
00
729 4 ▶ my $r = $m->{replica} or return _err( 1200, 'HY000', 'Misconfigured slave: MASTER_HOST was not set; Fix in config file or with CHANGE MASTER TO' );
Branch: 1 branch
BranchTrueFalseTotal
my $r = $$m{"replica"} or return _err(1200, "HY000", "Misconfigured slave: MASTER_HOST was not set; Fix in config file or with CHANGE MASTER TO") 4 0 4
730 4 ▶ if ( $verb eq 'STOP' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($verb eq "STOP") 2 2 4
731 2 ▶ $r->{io} = 'No' if $which ne 'SQL_THREAD';
Branch: 1 branch
BranchTrueFalseTotal
if $which ne "SQL_THREAD" 1 1 2
732 2 ▶ $r->{sql} = 'No' if $which ne 'IO_THREAD';
Branch: 1 branch
BranchTrueFalseTotal
if $which ne "IO_THREAD" 2 0 2
733 2 return ( '', 1 );
734 }
735 2 ▶ $r->{io} = 'Yes' if $which ne 'SQL_THREAD';
Branch: 1 branch
BranchTrueFalseTotal
if $which ne "SQL_THREAD" 1 1 2
736 2 ▶ if ( $which ne 'IO_THREAD' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($which ne "IO_THREAD") 2 0 2
737 2 ▶ my $skip = $v->{sql_slave_skip_counter} // 0;
Condition50%1/2
$$v{"sql_slave_skip_counter"} // 0
l!l
20
MC/DC0%0/1
$$v{"sql_slave_skip_counter"} // 0
$$v{"sql_slave_skip_counter"}
Truth table50%1/2
A
A= $$v{"sql_slave_skip_counter"}
Aresult
11
00
738 2 ▶ if ( $r->{last_errno} && $skip > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$r{"last_errno"} and $skip > 0) 1 1 2
Condition66%2/3
$$r{"last_errno"} and $skip > 0
!ll&&!rl&&r
101
MC/DC50%1/2
$$r{"last_errno"} and $skip > 0
$$r{"last_errno"} $skip > 0
Truth table66%2/3
A and B
A= $$r{"last_errno"}B= $skip > 0
ABresult
0X0
100
111
739 1 ▶ $r->{skipped} = ( $r->{skipped} // 0 ) + $skip;
Condition50%1/2
$$r{"skipped"} // 0
l!l
01
MC/DC0%0/1
$$r{"skipped"} // 0
$$r{"skipped"}
Truth table50%1/2
A
A= $$r{"skipped"}
Aresult
11
00
740 1 $v->{sql_slave_skip_counter} = '0';
741 1 ▶ delete @{$r}{qw( last_errno last_error )} if $r->{skipped} >= ( $r->{bad_events} // 1 );
Branch: 1 branch
BranchTrueFalseTotal
if $$r{"skipped"} >= ($$r{"bad_events"} // 1) 1 0 1
Condition50%1/2
$$r{"bad_events"} // 1
l!l
01
MC/DC0%0/1
$$r{"bad_events"} // 1
$$r{"bad_events"}
Truth table50%1/2
A
A= $$r{"bad_events"}
Aresult
11
00
742 }
743 2 ▶ $r->{sql} = $r->{last_errno} ? 'No' : 'Yes';
Branch: 1 branch
BranchTrueFalseTotal
$$r{'last_errno'} ? : 0 2 2
744 # mit parallelen Threads holt das Replikat auf (behind_parallel)
745 2 ▶ $r->{behind} = $r->{behind_parallel} if $r->{sql} eq 'Yes' && defined $r->{behind_parallel} && ( $v->{slave_parallel_threads} // 0 ) >= 2;
Branch: 1 branch
BranchTrueFalseTotal
if $$r{"sql"} eq "Yes" and defined $$r{"behind_parallel"} and ($$v{"slave_parallel_threads"} // 0) >= 2 1 1 2
Condition62%5/8
$$r{"sql"} eq "Yes" and defined $$r{"behind_parallel"} and ($$v{"slave_parallel_threads"} // 0) >= 2
!ll&&!rl&&r
101
$$r{"sql"} eq "Yes" and defined $$r{"behind_parallel"}
!ll&&!rl&&r
011
$$v{"slave_parallel_threads"} // 0
l!l
10
MC/DC33%1/3
$$r{"sql"} eq "Yes" and defined $$r{"behind_parallel"} and ($$v{"slave_parallel_threads"} // 0) >= 2
$$r{"sql"} eq "Yes" defined $$r{"behind_parallel"} $$v{"slave_parallel_threads"}
Truth table50%2/4
A and B and C
A= $$r{"sql"} eq "Yes"B= defined $$r{"behind_parallel"}C= $$v{"slave_parallel_threads"}
ABCresult
0XX0
10X0
1100
1111
746 }
747 2 return ( '', 1 );
748 }
749 1 ▶ if ( $s =~ /\A(?:RESET (?:SLAVE|REPLICA)|CHANGE MASTER TO)/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s =~ /\A(?:RESET (?:SLAVE|REPLICA)|CHANGE MASTER TO)/i) 0 1 1
750 0 ▶ my $r = $m->{replica} or return _gap($sql);
Branch: 1 branch
BranchTrueFalseTotal
my $r = $$m{"replica"} or return _gap($sql) 0 0 0
751 0 $r->{reset} = JSON::MaybeXS::true();
752 0 $r->{io} = $r->{sql} = 'No';
753 0 return ( '', 1 );
754 }
755 0 ▶ if ( $s =~ /\A(?:SELECT VERSION\(\)|SELECT \@\@VERSION)\z/i ) { return ( _render( $o, ['VERSION()'], [ [ $v->{version} ] ] ), 1 ) }
Branch: 1 branch
BranchTrueFalseTotal
if ($s =~ /\A(?:SELECT VERSION\(\)|SELECT \@\@VERSION)\z/i) 0 1 1
756 0 ▶ if ( $s =~ /\AUSE (\S+)\z/i ) { return ( '', 1 ) }
Branch: 1 branch
BranchTrueFalseTotal
if ($s =~ /\AUSE (\S+)\z/i) 0 1 1
757 0 ▶ if ( $s =~ /\ASTATUS\z/i ) { return _gap($sql) }
Branch: 1 branch
BranchTrueFalseTotal
if ($s =~ /\ASTATUS\z/i) 0 1 1
758 1 return _gap($sql);
759 }
760  
761 # WHERE a = 'x' AND b LIKE 'y%' AND id = 5 auf einer Zeile (Spalten klein); undef: nicht nachgebildet
762 52 ▶sub _where {
Subroutine _where: called CC=25 SCAR=34.2
763 52 my ( $row, $where ) = @_;
764 52 ▶ return 1 unless defined $where;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $where 13 39 52
765 39 for my $cond ( split /\s+AND\s+/i, $where ) {
766 47 ▶ if ( my ( $f, $not, $list ) = $cond =~ /\A\s*`?(\w+)`?\s+(NOT\s+)?IN\s*\((.*)\)\s*\z/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = $cond =~ /\A\s*`?(\w+)`?\s+(NOT\s+)?IN\s*\((.*)\)\s*\z/i) 7 40 47
767 7 my @v = map { s/\A\s*['"]?|['"]?\s*\z//gr } split /,/, $list;
768 7 ▶ my $have = $row->{ lc $f } // return undef;
Condition50%1/2
$$row{lc $f} // (return undef)
l!l
70
MC/DC0%0/1
$$row{lc $f} // (return undef)
$$row{lc $f}
Truth table50%1/2
A
A= $$row{lc $f}
Aresult
11
00
769 7 my $hit = grep { lc $_ eq lc $have } @v;
770 7 ▶ return 0 if $not ? $hit : !$hit;
Branch: 2 branches
BranchTrueFalseTotal
if $not ? $hit : !$hit 3 4 7
$not ? : 0 7 7
771 4 next;
772 }
773 40 ▶ if ( my ( $f, $not ) = $cond =~ /\A\s*`?(\w+)`?\s+IS\s+(NOT\s+)?NULL\s*\z/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = $cond =~ /\A\s*`?(\w+)`?\s+IS\s+(NOT\s+)?NULL\s*\z/i) 4 36 40
774 4 ▶ return undef unless exists $row->{ lc $f };
Branch: 1 branch
BranchTrueFalseTotal
unless exists $$row{lc $f} 0 4 4
775 4 ▶ my $null = !defined $row->{ lc $f } || $row->{ lc $f } eq 'NULL';
Condition66%2/3
!defined($$row{lc $f}) || $$row{lc $f} eq 'NULL'
l!l&&r!l&&!r
031
MC/DC50%1/2
!defined($$row{lc $f}) || $$row{lc $f} eq 'NULL'
!defined($$row{lc $f}) $$row{lc $f} eq 'NULL'
Truth table66%2/3
not(A) || B
A= !defined($$row{lc $f})B= $$row{lc $f} eq 'NULL'
ABresult
1X1
011
000
776 4 ▶ return 0 if $not ? $null : !$null;
Branch: 2 branches
BranchTrueFalseTotal
if $not ? $null : !$null 3 1 4
$not ? : 4 0 4
777 1 next;
778 }
779 36 ▶ if ( my ( $f, $op, $n ) = $cond =~ /\A\s*`?(\w+)`?\s*(>=|<=|>|<)\s*(-?\d+(?:\.\d+)?)\s*\z/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = $cond =~ /\A\s*`?(\w+)`?\s*(>=|<=|>|<)\s*(-?\d+(?:\.\d+)?)\s*\z/) 3 33 36
780 3 ▶ my $have = $row->{ lc $f } // return undef;
Condition50%1/2
$$row{lc $f} // (return undef)
l!l
30
MC/DC0%0/1
$$row{lc $f} // (return undef)
$$row{lc $f}
Truth table50%1/2
A
A= $$row{lc $f}
Aresult
11
00
781 3 ▶ return undef unless $have =~ /\A-?\d+(?:\.\d+)?\z/;
Branch: 1 branch
BranchTrueFalseTotal
unless $have =~ /\A-?\d+(?:\.\d+)?\z/ 0 3 3
782 3 ▶ my $hit = $op eq '>' ? $have > $n : $op eq '<' ? $have < $n : $op eq '>=' ? $have >= $n : $have <= $n;
Branch: 3 branches
BranchTrueFalseTotal
$op eq '>' ? : 3 0 3
$op eq '<' ? : 0 0 0
$op eq '>=' ? : 0 0 0
783 3 ▶ return 0 unless $hit;
Branch: 1 branch
BranchTrueFalseTotal
unless $hit 2 1 3
784 1 next;
785 }
786 33 ▶ my ( $f, $op, $val ) = $cond =~ /\A\s*`?(\w+)`?\s*(=|!=|<>|LIKE|NOT LIKE)\s*(?:['"]([^'"]*)['"]|(-?\d+))\s*\z/i or return undef;
Branch: 1 branch
BranchTrueFalseTotal
() = $cond =~ /\A\s*`?(\w+)`?\s*(=|!=|<>|LIKE|NOT LIKE)\s*(?:['"]([^'"]*)['"]|(-?\d+))\s*\z/i or return undef 33 0 33
787 33 ▶ $val //= $4;
Condition66%2/3
$val //= $4
l!l&&r!l&&!r
3120
MC/DC0%0/2
$val //= $4
$val $4
Truth table66%2/3
A //= B
A= $valB= $4
ABresult
1X1
011
000
788 33 ▶ my $have = $row->{ lc $f } // return undef;
Condition50%1/2
$$row{lc $f} // (return undef)
l!l
330
MC/DC0%0/1
$$row{lc $f} // (return undef)
$$row{lc $f}
Truth table50%1/2
A
A= $$row{lc $f}
Aresult
11
00
789 33 ▶ my $hit = $op =~ /LIKE/i ? $have =~ _like("'$val'") : lc $have eq lc $val;
Branch: 1 branch
BranchTrueFalseTotal
$op =~ /LIKE/i ? : 5 28 33
790 33 ▶ $hit = !$hit if $op =~ /\A(?:!=|<>|NOT LIKE)\z/i;
Branch: 1 branch
BranchTrueFalseTotal
if $op =~ /\A(?:!=|<>|NOT LIKE)\z/i 0 33 33
791 33 ▶ return 0 unless $hit;
Branch: 1 branch
BranchTrueFalseTotal
unless $hit 16 17 33
792 }
793 15 return 1;
794 }
795  
796 3 ▶sub _gap { my ($st) = @_; push @GAPS, "mysql: $st"; return ( '', 0 ) }
Subroutine _gap: called CC=1 SCAR=0.0
797  
798 3 ▶sub _binlog_size {
Subroutine _binlog_size: called CC=6 SCAR=21.4
799 3 my ( $dev, $b ) = @_;
800 3 ▶ my $dir = _vars($dev)->{datadir} // '/var/lib/mysql/';
Condition50%1/2
_vars($dev)->{"datadir"} // "/var/lib/mysql/"
l!l
30
MC/DC0%0/1
_vars($dev)->{"datadir"} // "/var/lib/mysql/"
_vars($dev)->{"datadir"}
Truth table50%1/2
A
A= _vars($dev)->{"datadir"}
Aresult
11
00
801 3 $dir =~ s{/?\z}{/};
802 3 ▶ my $e = ( $dev->{files} || {} )->{"$dir$b->{name}"};
Condition50%1/2
$$dev{'files'} || {}
l!l
30
MC/DC0%0/1
$$dev{'files'} || {}
$$dev{'files'}
Truth table50%1/2
A
A= $$dev{'files'}
Aresult
11
00
803 3 ▶ return $b->{size} // 1073741824 unless ref $e eq 'HASH' && defined $e->{size};
Branch: 1 branch
BranchTrueFalseTotal
unless ref $e eq "HASH" and defined $$e{"size"} 0 3 3
Condition20%1/5
ref $e eq "HASH" and defined $$e{"size"}
!ll&&!rl&&r
003
$$b{"size"} // 1073741824
l!l
00
MC/DC0%0/2
ref $e eq "HASH" and defined $$e{"size"}
ref $e eq "HASH" defined $$e{"size"}
MC/DC0%0/1
$$b{"size"} // 1073741824
$$b{"size"}
Truth table33%1/3
A and B
A= ref $e eq "HASH"B= defined $$e{"size"}
ABresult
0X0
100
111
Truth table0%0/2
A
A= $$b{"size"}
Aresult
11
00
804 3 return Langertha::Holmgang::Sim::Linux::_bytes( $e->{size} );
805 }
806  
807 2 ▶sub _drop_binlogs {
Subroutine _drop_binlogs: called CC=9 SCAR=27.0
808 2 my ( $dev, @drop ) = @_;
809 2 my $m = $dev->{mariadb};
810 2 my %gone = map { $_->{name} => 1 } @drop;
811 2 ▶ return unless %gone;
Branch: 1 branch
BranchTrueFalseTotal
unless %gone 0 2 2
812 2 ▶ $m->{binlogs} = [ grep { !$gone{ $_->{name} } } @{ $m->{binlogs} || [] } ];
Condition50%1/2
$$m{'binlogs'} || []
l!l
20
MC/DC0%0/1
$$m{'binlogs'} || []
$$m{'binlogs'}
Truth table50%1/2
A
A= $$m{'binlogs'}
Aresult
11
00
813 2 ▶ my $dir = _vars($dev)->{datadir} // '/var/lib/mysql/';
Condition50%1/2
_vars($dev)->{"datadir"} // "/var/lib/mysql/"
l!l
20
MC/DC0%0/1
_vars($dev)->{"datadir"} // "/var/lib/mysql/"
_vars($dev)->{"datadir"}
Truth table50%1/2
A
A= _vars($dev)->{"datadir"}
Aresult
11
00
814 2 $dir =~ s{/?\z}{/};
815 2 delete $dev->{files}{"$dir$_"} for keys %gone;
816 2 ▶ my $idx = "$dir" . ( ( $m->{binlogs}[0] // {} )->{name} // 'mariadb-bin.000001' ) =~ s/\.\d+\z/.index/r;
Condition50%2/4
($$m{"binlogs"}[0] // {})->{"name"} // "mariadb-bin.000001"
l!l
20
$$m{"binlogs"}[0] // {}
l!l
20
MC/DC0%0/1
($$m{"binlogs"}[0] // {})->{"name"} // "mariadb-bin.000001"
$$m{"binlogs"}[0]
Truth table50%1/2
A
A= $$m{"binlogs"}[0]
Aresult
11
00
817 2 ▶ if ( exists $dev->{files}{$idx} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $$dev{"files"}{$idx}) 0 2 2
818 0 my $e = $dev->{files}{$idx};
819 0 my $t = join '', map {"./$_->{name}\n"} @{ $m->{binlogs} };
820 0 ▶ if ( ref $e eq 'HASH' ) { $e->{content} = $t } else { $dev->{files}{$idx} = $t }
Branch: 1 branch
BranchTrueFalseTotal
if (ref $e eq 'HASH') { } 0 0 0
821 }
822 2 _check_replicas($dev);
823 2 return;
824 }
825  
826 # Replikate, deren Binlog fehlt, brechen
827 3 ▶sub _check_replicas {
Subroutine _check_replicas: called CC=6 SCAR=18.2
828 3 my ($dev) = @_;
829 3 my $m = $dev->{mariadb};
830 3 ▶ my %have = map { $_->{name} => 1 } @{ $m->{binlogs} || [] };
Condition50%1/2
$$m{'binlogs'} || []
l!l
30
MC/DC0%0/1
$$m{'binlogs'} || []
$$m{'binlogs'}
Truth table50%1/2
A
A= $$m{'binlogs'}
Aresult
11
00
831 3 ▶ for my $r ( sort keys %{ $m->{replicas} || {} } ) {
Condition50%1/2
$$m{'replicas'} || {}
l!l
30
MC/DC0%0/1
$$m{'replicas'} || {}
$$m{'replicas'}
Truth table50%1/2
A
A= $$m{'replicas'}
Aresult
11
00
832 3 my $need = $m->{replicas}{$r};
833 3 ▶ $m->{broken_replicas}{$r} = $need unless $have{$need} || $need eq 'broken';
Branch: 1 branch
BranchTrueFalseTotal
unless $have{$need} or $need eq "broken" 2 1 3
Condition66%2/3
$have{$need} or $need eq "broken"
l!l&&r!l&&!r
102
MC/DC50%1/2
$have{$need} or $need eq "broken"
$have{$need} $need eq "broken"
Truth table66%2/3
A or B
A= $have{$need}B= $need eq "broken"
ABresult
1X1
011
000
834 }
835 3 return;
836 }
837  
838  
839 1 ▶sub file_removed {
Subroutine file_removed: called CC=6 SCAR=18.4
Pod documented
840 1 my ( $dev, $path ) = @_;
841 1 ▶ my $m = $dev->{mariadb} or return;
Branch: 1 branch
BranchTrueFalseTotal
my $m = $$dev{"mariadb"} or return 1 0 1
842 1 ▶ my $dir = _vars($dev)->{datadir} // '/var/lib/mysql/';
Condition50%1/2
_vars($dev)->{"datadir"} // "/var/lib/mysql/"
l!l
10
MC/DC0%0/1
_vars($dev)->{"datadir"} // "/var/lib/mysql/"
_vars($dev)->{"datadir"}
Truth table50%1/2
A
A= _vars($dev)->{"datadir"}
Aresult
11
00
843 1 $dir =~ s{/?\z}{/};
844 1 ▶ return unless index( $path, $dir ) == 0;
Branch: 1 branch
BranchTrueFalseTotal
unless index($path, $dir) == 0 0 1 1
845 1 my $name = substr( $path, length $dir );
846 1 ▶ return unless grep { $_->{name} eq $name } @{ $m->{binlogs} || [] };
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$$_{"name"} eq $name;} @{$$m{"binlogs"} or [];} 0 1 1
Condition50%1/2
$$m{'binlogs'} || []
l!l
10
MC/DC0%0/1
$$m{'binlogs'} || []
$$m{'binlogs'}
Truth table50%1/2
A
A= $$m{'binlogs'}
Aresult
11
00
847 # von Hand geloescht: das Index-File nennt die Datei weiter, der Server merkt es erst spaeter
848 1 $m->{binlogs_missing}{$name} = 1;
849 1 $m->{binlogs} = [ grep { $_->{name} ne $name } @{ $m->{binlogs} } ];
850 1 _check_replicas($dev);
851 1 return;
852 }
853  
854 0 ▶sub _rotate_binlog {
Subroutine _rotate_binlog: not called CC=4 SCAR=30.0
855 0 my ($dev) = @_;
856 0 my $m = $dev->{mariadb};
857 0 ▶ my $last = ( $m->{binlogs} || [] )->[-1] or return;
Branch: 1 branch
BranchTrueFalseTotal
my $last = ($$m{"binlogs"} || [])->[-1] or return 0 0 0
Condition0%0/2
$$m{'binlogs'} || []
l!l
00
MC/DC0%0/1
$$m{'binlogs'} || []
$$m{'binlogs'}
Truth table0%0/2
A
A= $$m{'binlogs'}
Aresult
11
00
858 0 ▶ my ( $base, $n ) = $last->{name} =~ /\A(.+)\.(\d+)\z/ or return;
Branch: 1 branch
BranchTrueFalseTotal
() = $$last{"name"} =~ /\A(.+)\.(\d+)\z/ or return 0 0 0
859 0 push @{ $m->{binlogs} }, { name => sprintf( '%s.%06d', $base, $n + 1 ), size => 365 };
860 0 return;
861 }
862  
863 # --- Verbindung ---------------------------------------------------------------------
864  
865  
866 58 ▶sub client {
Subroutine client: called CC=81 SCAR=64.6
Pod documented
867 58 my ( $dev, $av, $ctx, $stdin, $os_user, $prog ) = @_;
868 58 my @a = @$av;
869 58 my %o;
870 58 my ( $user, $pw, $host, @exec, $db );
871 58 my $pw_prompt;
872 58 ▶ while (@a) {
Branch: 1 branch
BranchTrueFalseTotal
if (@a) 98 58 156
873 98 my $x = shift @a;
874 98 ▶ if ( $x eq '-u' || $x eq '--user' ) { $user = shift @a }
Branch: 17 branches
BranchTrueFalseTotal
if ($x eq '-u' or $x eq '--user') { } 6 92 98
elsif ($x =~ /\A-u(.+)\z/ or $x =~ /\A--user=(.+)\z/) { } 0 92 92
elsif ($x eq '-p' or $x eq '--password') { } 0 92 92
elsif ($x =~ /\A-p(.+)\z/ or $x =~ /\A--password=(.*)\z/) { } 6 86 92
elsif ($x eq '-h' or $x eq '--host') { } 1 85 86
elsif ($x =~ /\A-h(.+)\z/ or $x =~ /\A--host=(.+)\z/) { } 0 85 85
elsif ($x eq '-P' or $x eq '--port') { } 1 84 85
elsif ($x eq '--connect-timeout') { } 0 84 84
elsif ($x =~ /\A--(?:connect-timeout|port)=\d+\z/) { } 1 83 84
elsif ($x eq '-D' or $x eq '--database') { } 0 83 83
elsif ($x eq '-e' or $x eq '--execute') { } 58 25 83
elsif ($x =~ /\A--execute=(.*)\z/s) { } 0 25 25
elsif ($x eq '-N' or $x eq '--skip-column-names') { } 25 0 25
elsif ($x eq '-t' or $x eq '--table') { } 0 0 0
elsif ($x eq '-E' or $x eq '--vertical') { } 0 0 0
elsif ($x =~ /\A-[BsrnNA]+\z/ or $x =~ /\A--(?:batch|silent|raw|skip-pager|no-auto-rehash|protocol=\w+|defaults-file=\S+|socket=\S+)\z/) { } 0 0 0
elsif ($x =~ /\A-/) { } 0 0 0
Condition66%2/3
$x eq "-u" or $x eq "--user"
l!l&&r!l&&!r
6092
MC/DC50%1/2
$x eq "-u" or $x eq "--user"
$x eq "-u" $x eq "--user"
Truth table66%2/3
A or B
A= $x eq "-u"B= $x eq "--user"
ABresult
1X1
011
000
875 0 ▶ elsif ( $x =~ /\A-u(.+)\z/ || $x =~ /\A--user=(.+)\z/ ) { $user = $1 }
Condition33%1/3
$x =~ /\A-u(.+)\z/ or $x =~ /\A--user=(.+)\z/
l!l&&r!l&&!r
0092
MC/DC0%0/2
$x =~ /\A-u(.+)\z/ or $x =~ /\A--user=(.+)\z/
$x =~ /\A-u(.+)\z/ $x =~ /\A--user=(.+)\z/
Truth table33%1/3
A or B
A= $x =~ /\A-u(.+)\z/B= $x =~ /\A--user=(.+)\z/
ABresult
1X1
011
000
876 0 ▶ elsif ( $x eq '-p' || $x eq '--password' ) { $pw_prompt = 1 }
Condition33%1/3
$x eq "-p" or $x eq "--password"
l!l&&r!l&&!r
0092
MC/DC0%0/2
$x eq "-p" or $x eq "--password"
$x eq "-p" $x eq "--password"
Truth table33%1/3
A or B
A= $x eq "-p"B= $x eq "--password"
ABresult
1X1
011
000
877 6 ▶ elsif ( $x =~ /\A-p(.+)\z/ || $x =~ /\A--password=(.*)\z/ ) { $pw = $1 }
Condition66%2/3
$x =~ /\A-p(.+)\z/ or $x =~ /\A--password=(.*)\z/
l!l&&r!l&&!r
6086
MC/DC50%1/2
$x =~ /\A-p(.+)\z/ or $x =~ /\A--password=(.*)\z/
$x =~ /\A-p(.+)\z/ $x =~ /\A--password=(.*)\z/
Truth table66%2/3
A or B
A= $x =~ /\A-p(.+)\z/B= $x =~ /\A--password=(.*)\z/
ABresult
1X1
011
000
878 1 ▶ elsif ( $x eq '-h' || $x eq '--host' ) { $host = shift @a }
Condition66%2/3
$x eq "-h" or $x eq "--host"
l!l&&r!l&&!r
1085
MC/DC50%1/2
$x eq "-h" or $x eq "--host"
$x eq "-h" $x eq "--host"
Truth table66%2/3
A or B
A= $x eq "-h"B= $x eq "--host"
ABresult
1X1
011
000
879 0 ▶ elsif ( $x =~ /\A-h(.+)\z/ || $x =~ /\A--host=(.+)\z/ ) { $host = $1 }
Condition33%1/3
$x =~ /\A-h(.+)\z/ or $x =~ /\A--host=(.+)\z/
l!l&&r!l&&!r
0085
MC/DC0%0/2
$x =~ /\A-h(.+)\z/ or $x =~ /\A--host=(.+)\z/
$x =~ /\A-h(.+)\z/ $x =~ /\A--host=(.+)\z/
Truth table33%1/3
A or B
A= $x =~ /\A-h(.+)\z/B= $x =~ /\A--host=(.+)\z/
ABresult
1X1
011
000
880 1 ▶ elsif ( $x eq '-P' || $x eq '--port' ) { shift @a }
Condition66%2/3
$x eq "-P" or $x eq "--port"
l!l&&r!l&&!r
1084
MC/DC50%1/2
$x eq "-P" or $x eq "--port"
$x eq "-P" $x eq "--port"
Truth table66%2/3
A or B
A= $x eq "-P"B= $x eq "--port"
ABresult
1X1
011
000
881 0 elsif ( $x eq '--connect-timeout' ) { shift @a }
882 elsif ( $x =~ /\A--(?:connect-timeout|port)=\d+\z/ ) { }
883 0 ▶ elsif ( $x eq '-D' || $x eq '--database' ) { $db = shift @a }
Condition33%1/3
$x eq "-D" or $x eq "--database"
l!l&&r!l&&!r
0083
MC/DC0%0/2
$x eq "-D" or $x eq "--database"
$x eq "-D" $x eq "--database"
Truth table33%1/3
A or B
A= $x eq "-D"B= $x eq "--database"
ABresult
1X1
011
000
884 58 ▶ elsif ( $x eq '-e' || $x eq '--execute' ) { push @exec, shift(@a) // '' }
Condition60%3/5
$x eq "-e" or $x eq "--execute"
l!l&&r!l&&!r
58025
shift @a // ""
l!l
580
MC/DC50%1/2
$x eq "-e" or $x eq "--execute"
$x eq "-e" $x eq "--execute"
MC/DC0%0/1
shift @a // ""
shift @a
Truth table66%2/3
A or B
A= $x eq "-e"B= $x eq "--execute"
ABresult
1X1
011
000
Truth table50%1/2
A
A= shift @a
Aresult
11
00
885 0 elsif ( $x =~ /\A--execute=(.*)\z/s ) { push @exec, $1 }
886 25 ▶ elsif ( $x eq '-N' || $x eq '--skip-column-names' ) { $o{skip_names} = 1 }
Condition33%1/3
$x eq "-N" or $x eq "--skip-column-names"
l!l&&r!l&&!r
2500
MC/DC0%0/2
$x eq "-N" or $x eq "--skip-column-names"
$x eq "-N" $x eq "--skip-column-names"
Truth table33%1/3
A or B
A= $x eq "-N"B= $x eq "--skip-column-names"
ABresult
1X1
011
000
887 0 ▶ elsif ( $x eq '-t' || $x eq '--table' ) { $o{table} = 1 }
Condition0%0/3
$x eq "-t" or $x eq "--table"
l!l&&r!l&&!r
000
MC/DC0%0/2
$x eq "-t" or $x eq "--table"
$x eq "-t" $x eq "--table"
Truth table0%0/3
A or B
A= $x eq "-t"B= $x eq "--table"
ABresult
1X1
011
000
888 0 ▶ elsif ( $x eq '-E' || $x eq '--vertical' ) { $o{vertical} = 1 }
Condition0%0/3
$x eq "-E" or $x eq "--vertical"
l!l&&r!l&&!r
000
MC/DC0%0/2
$x eq "-E" or $x eq "--vertical"
$x eq "-E" $x eq "--vertical"
Truth table0%0/3
A or B
A= $x eq "-E"B= $x eq "--vertical"
ABresult
1X1
011
000
889 ▶ elsif ( $x =~ /\A-[BsrnNA]+\z/ || $x =~ /\A--(?:batch|silent|raw|skip-pager|no-auto-rehash|protocol=\w+|defaults-file=\S+|socket=\S+)\z/ ) {
Condition0%0/3
$x =~ /\A-[BsrnNA]+\z/ or $x =~ /\A--(?:batch|silent|raw|skip-pager|no-auto-rehash|protocol=\w+|defaults-file=\S+|socket=\S+)\z/
l!l&&r!l&&!r
000
MC/DC0%0/2
$x =~ /\A-[BsrnNA]+\z/ or $x =~ /\A--(?:batch|silent|raw|skip-pager|no-auto-rehash|protocol=\w+|defaults-file=\S+|socket=\S+)\z/
$x =~ /\A-[BsrnNA]+\z/ $x =~ /\A--(?:batch|silent|raw|skip-pager|no-auto-rehash|protocol=\w+|defaults-file=\S+|socket=\S+)\z/
Truth table0%0/3
A or B
A= $x =~ /\A-[BsrnNA]+\z/B= $x =~ /\A--(?:batch|silent|raw|skip-pager|no-auto-rehash|protocol=\w+|defaults-file=\S+|socket=\S+)\z/
ABresult
1X1
011
000
890 0 ▶ $o{skip_names} = 1 if $x =~ /N/ && $x =~ /\A-[A-Za-z]+\z/;
Branch: 1 branch
BranchTrueFalseTotal
if $x =~ /N/ and $x =~ /\A-[A-Za-z]+\z/ 0 0 0
Condition0%0/3
$x =~ /N/ and $x =~ /\A-[A-Za-z]+\z/
!ll&&!rl&&r
000
MC/DC0%0/2
$x =~ /N/ and $x =~ /\A-[A-Za-z]+\z/
$x =~ /N/ $x =~ /\A-[A-Za-z]+\z/
Truth table0%0/3
A and B
A= $x =~ /N/B= $x =~ /\A-[A-Za-z]+\z/
ABresult
0X0
100
111
891 }
892 0 ▶ elsif ( $x =~ /\A-/ ) { push @GAPS, join( ' ', $prog // 'mysql', @$av ); return ( '', 0 ) }
Condition0%0/2
$prog // "mysql"
l!l
00
MC/DC0%0/1
$prog // "mysql"
$prog
Truth table0%0/2
A
A= $prog
Aresult
11
00
893 0 ▶ else { $db //= $x }
Condition0%0/3
$db //= $x
l!l&&r!l&&!r
000
MC/DC0%0/2
$db //= $x
$db $x
Truth table0%0/3
A //= B
A= $dbB= $x
ABresult
1X1
011
000
894 }
895 58 ▶ $prog //= 'mysql';
Condition50%1/2
$prog //= "mysql"
l!l
580
MC/DC0%0/1
$prog //= "mysql"
$prog
Truth table50%1/2
A
A= $prog
Aresult
11
00
896 58 my $m = $dev->{mariadb};
897 58 my $sock = "Can't connect to local server through socket '/run/mysqld/mysqld.sock' (2)";
898 58 ▶ return ( "ERROR 2002 (HY000): $sock", 0 ) unless $m && _active($dev);
Branch: 1 branch
BranchTrueFalseTotal
unless $m and _active($dev) 1 57 58
Condition66%2/3
$m and _active($dev)
!ll&&!rl&&r
0157
MC/DC50%1/2
$m and _active($dev)
$m _active($dev)
Truth table66%2/3
A and B
A= $mB= _active($dev)
ABresult
0X0
100
111
899 57 my $v = _vars($dev);
900 57 my $from = 'localhost';
901 57 ▶ if ( defined $host && $host ne 'localhost' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $host and $host ne "localhost") 1 56 57
Condition66%2/3
defined $host and $host ne "localhost"
!ll&&!rl&&r
5601
MC/DC50%1/2
defined $host and $host ne "localhost"
defined $host $host ne "localhost"
Truth table66%2/3
A and B
A= defined $hostB= $host ne "localhost"
ABresult
0X0
100
111
902 1 ▶ my @b = split /\s*,\s*/, $v->{bind_address} // '127.0.0.1';
Condition50%1/2
$$v{"bind_address"} // "127.0.0.1"
l!l
10
MC/DC0%0/1
$$v{"bind_address"} // "127.0.0.1"
$$v{"bind_address"}
Truth table50%1/2
A
A= $$v{"bind_address"}
Aresult
11
00
903 1 ▶ my $ok = grep { $_ eq '0.0.0.0' || $_ eq '*' || $_ eq '::' || $_ eq $host } @b;
Condition33%3/9
$_ eq '0.0.0.0' || $_ eq '*' || $_ eq '::' || $_ eq $host
l!l&&r!l&&!r
001
$_ eq "0.0.0.0" or $_ eq "*" or $_ eq "::"
l!l&&r!l&&!r
001
$_ eq "0.0.0.0" or $_ eq "*"
l!l&&r!l&&!r
001
MC/DC0%0/4
$_ eq '0.0.0.0' || $_ eq '*' || $_ eq '::' || $_ eq $host
$_ eq "0.0.0.0" $_ eq "*" $_ eq "::" $_ eq $host
Truth table20%1/5
A or B or C || D
A= $_ eq "0.0.0.0"B= $_ eq "*"C= $_ eq "::"D= $_ eq $host
ABCDresult
1XXX1
01XX1
001X1
00011
00000
904 1 ▶ return ( "ERROR 2002 (HY000): Can't connect to server on '$host' (115)", 0 ) unless $ok;
Branch: 1 branch
BranchTrueFalseTotal
unless $ok 1 0 1
905 0 ▶ $from = $host eq '127.0.0.1' ? 'localhost' : $host;
Branch: 1 branch
BranchTrueFalseTotal
$host eq '127.0.0.1' ? : 0 0 0
906 }
907 56 ▶ if ( $pw_prompt && !defined $pw ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pw_prompt and not defined $pw) 0 56 56
Condition33%1/3
$pw_prompt and not defined $pw
!ll&&!rl&&r
5600
MC/DC0%0/2
$pw_prompt and not defined $pw
$pw_prompt not defined $pw
Truth table33%1/3
A and not(B)
A= $pw_promptB= not defined $pw
ABresult
0X0
100
111
908 # ohne Terminal liest -p von stdin — hier eine Luecke (interaktiv)
909 0 push @GAPS, "$prog -p (Passwortabfrage)";
910 0 return ( 'Enter password: ', 0 );
911 }
912 56 ▶ $user //= $os_user // 'root';
Condition75%3/4
$user //= $os_user // "root"
l!l
551
$os_user // "root"
l!l
510
MC/DC100%1/1
$user //= $os_user // "root"
$user
Truth table100%2/2
A
A= $user
Aresult
11
00
913 56 my $acc;
914 56 ▶ if ( $user eq 'root' && $from eq 'localhost' && ( $os_user // 'root' ) eq 'root' && !defined $pw ) { $acc = 'root@localhost' }
Branch: 1 branch
BranchTrueFalseTotal
if ($user eq 'root' and $from eq 'localhost' and ($os_user // 'root') eq 'root' and not defined $pw) { } 51 5 56
Condition63%7/11
$user eq "root" and $from eq "localhost" and ($os_user // "root") eq "root" and not defined $pw
!ll&&!rl&&r
5051
$user eq "root" and $from eq "localhost" and ($os_user // "root") eq "root"
!ll&&!rl&&r
5051
$user eq "root" and $from eq "localhost"
!ll&&!rl&&r
5051
$os_user // "root"
l!l
510
MC/DC25%1/4
$user eq "root" and $from eq "localhost" and ($os_user // "root") eq "root" and not defined $pw
$user eq "root" $from eq "localhost" $os_user not defined $pw
Truth table40%2/5
A and B and C and not(D)
A= $user eq "root"B= $from eq "localhost"C= $os_userD= not defined $pw
ABCDresult
0XXX0
10XX0
110X0
11100
11111
915 else {
916 5 $acc = _find_account( $m, $user, $from );
917 5 ▶ my $a = $acc ? $m->{users}{$acc} : undef;
Branch: 1 branch
BranchTrueFalseTotal
$acc ? : 5 0 5
918 my $good = $a && ( ( $a->{auth} // '' ) eq 'unix_socket' ? ( $os_user // 'root' ) eq $user && !defined $pw
919 5 ▶ : defined $a->{password} ? ( defined $pw && $pw eq $a->{password} ) : !defined $pw );
Branch: 2 branches
BranchTrueFalseTotal
($$a{'auth'} // '') eq 'unix_socket' ? : 0 5 5
defined $$a{'password'} ? : 5 0 5
Condition38%5/13
$a && (($$a{'auth'} // '') eq 'unix_socket' ? ($os_user // 'root') eq $user && !defined($pw) : (defined $$a{'password'} ? defined $pw && $pw eq $$a{'password'} : !defined($pw)))
!ll&&!rl&&r
023
$$a{"auth"} // ""
l!l
05
($os_user // "root") eq $user and not defined $pw
!ll&&!rl&&r
000
$os_user // "root"
l!l
00
defined $pw and $pw eq $$a{"password"}
!ll&&!rl&&r
023
MC/DC0%0/2
$a && (($$a{'auth'} // '') eq 'unix_socket' ? ($os_user // 'root') eq $user && !defined($pw) : (defined $$a{'password'} ? defined $pw && $pw eq $$a{'password'} : !defined($pw)))
$a $$a{"auth"}
MC/DC0%0/2
($os_user // "root") eq $user and not defined $pw
$os_user not defined $pw
MC/DC50%1/2
defined $pw and $pw eq $$a{"password"}
defined $pw $pw eq $$a{"password"}
Truth table33%1/3
A && B
A= $aB= $$a{"auth"}
ABresult
0X0
100
111
Truth table0%0/3
A and not(B)
A= $os_userB= not defined $pw
ABresult
0X0
100
111
Truth table66%2/3
A and B
A= defined $pwB= $pw eq $$a{"password"}
ABresult
0X0
100
111
920 5 ▶ return ( "ERROR 1045 (28000): Access denied for user '$user'\@'$from' (using password: " . ( defined $pw ? 'YES' : 'NO' ) . ')', 0 ) unless $good;
Branch: 2 branches
BranchTrueFalseTotal
unless $good 2 3 5
defined $pw ? : 2 0 2
921 }
922 54 ▶ my $tc = ( $m->{status} || {} )->{Threads_connected} // 1;
Condition50%2/4
($$m{"status"} || {})->{"Threads_connected"} // 1
l!l
540
$$m{'status'} || {}
l!l
540
MC/DC0%0/1
($$m{"status"} || {})->{"Threads_connected"} // 1
$$m{'status'}
Truth table50%1/2
A
A= $$m{'status'}
Aresult
11
00
923 54 ▶ my $super = _has_priv( $m, $acc, 'SUPER' ) || _has_priv( $m, $acc, 'ALL PRIVILEGES' );
Condition66%2/3
_has_priv($m, $acc, 'SUPER') || _has_priv($m, $acc, 'ALL PRIVILEGES')
l!l&&r!l&&!r
5103
MC/DC50%1/2
_has_priv($m, $acc, 'SUPER') || _has_priv($m, $acc, 'ALL PRIVILEGES')
_has_priv($m, $acc, 'SUPER') _has_priv($m, $acc, 'ALL PRIVILEGES')
Truth table66%2/3
A || B
A= _has_priv($m, $acc, 'SUPER')B= _has_priv($m, $acc, 'ALL PRIVILEGES')
ABresult
1X1
011
000
924 54 ▶ return ( 'ERROR 1040 (HY000): Too many connections', 0 ) if $tc >= ( my $mc = "" . ( $v->{max_connections} // 151 ) ) + ( $super ? 1 : 0 );
Branch: 2 branches
BranchTrueFalseTotal
if $tc >= (my $mc = '' . ($$v{"max_connections"} // 151)) + ($super ? 1 : 0) 2 52 54
$super ? : 51 3 54
Condition50%1/2
$$v{"max_connections"} // 151
l!l
540
MC/DC0%0/1
$$v{"max_connections"} // 151
$$v{"max_connections"}
Truth table50%1/2
A
A= $$v{"max_connections"}
Aresult
11
00
925 52 ▶ my $sql = @exec ? join( ';', @exec ) : $stdin // '';
Branch: 1 branch
BranchTrueFalseTotal
@exec ? : 52 0 52
Condition0%0/2
$stdin // ""
l!l
00
MC/DC0%0/1
$stdin // ""
$stdin
Truth table0%0/2
A
A= $stdin
Aresult
11
00
926 0 ▶ if ( $sql !~ /\S/ ) { push @GAPS, "$prog (interaktiv)"; return ( '', 0 ) }
Branch: 1 branch
BranchTrueFalseTotal
unless ($sql =~ /\S/) 0 52 52
927 52 my @out;
928 52 for my $st ( _split_sql($sql) ) {
929 57 ▶ my ( $t, $k ) = _statement( $dev, $st->[0], { %o, vertical => $o{vertical} || $st->[1] }, $acc );
Condition66%2/3
$o{'vertical'} || $$st[1]
l!l&&r!l&&!r
0354
MC/DC50%1/2
$o{'vertical'} || $$st[1]
$o{'vertical'} $$st[1]
Truth table66%2/3
A || B
A= $o{'vertical'}B= $$st[1]
ABresult
1X1
011
000
930 57 ▶ push @out, $t if defined $t && length $t;
Branch: 1 branch
BranchTrueFalseTotal
if defined $t and length $t 39 18 57
Condition66%2/3
defined $t and length $t
!ll&&!rl&&r
01839
MC/DC50%1/2
defined $t and length $t
defined $t length $t
Truth table66%2/3
A and B
A= defined $tB= length $t
ABresult
0X0
100
111
931 57 ▶ return ( join( "\n", @out ), 0 ) unless $k;
Branch: 1 branch
BranchTrueFalseTotal
unless $k 7 50 57
932 }
933 45 return ( join( "\n", @out ), 1 );
934 }
935  
936  
937 5 ▶sub mysqladmin {
Subroutine mysqladmin: called CC=27 SCAR=35.9
Pod documented
938 5 my ( $dev, $av, $ctx, $os_user ) = @_;
939 5 my ( @opts, @cmd );
940 5 my @a = @$av;
941 5 ▶ while (@a) {
Branch: 1 branch
BranchTrueFalseTotal
if (@a) 14 5 19
942 14 my $x = shift @a;
943 14 ▶ if ( $x =~ /\A-[uhP]\z/ || $x =~ /\A--(?:user|host|port)\z/ ) { push @opts, $x, shift(@a) // '' }
Branch: 4 branches
BranchTrueFalseTotal
if ($x =~ /\A-[uhP]\z/ or $x =~ /\A--(?:user|host|port)\z/) { } 5 9 14
elsif ($x eq '-S' or $x eq '--socket') { } 1 8 9
elsif ($x =~ /\A-S./ or $x =~ /\A--socket=/) { } 0 8 8
elsif ($x =~ /\A-/) { } 3 5 8
Condition60%3/5
$x =~ /\A-[uhP]\z/ or $x =~ /\A--(?:user|host|port)\z/
l!l&&r!l&&!r
509
shift @a // ""
l!l
50
MC/DC50%1/2
$x =~ /\A-[uhP]\z/ or $x =~ /\A--(?:user|host|port)\z/
$x =~ /\A-[uhP]\z/ $x =~ /\A--(?:user|host|port)\z/
MC/DC0%0/1
shift @a // ""
shift @a
Truth table66%2/3
A or B
A= $x =~ /\A-[uhP]\z/B= $x =~ /\A--(?:user|host|port)\z/
ABresult
1X1
011
000
Truth table50%1/2
A
A= shift @a
Aresult
11
00
944 1 ▶ elsif ( $x eq '-S' || $x eq '--socket' ) { shift @a } # Socket: immer der des Servers
Condition66%2/3
$x eq "-S" or $x eq "--socket"
l!l&&r!l&&!r
108
MC/DC50%1/2
$x eq "-S" or $x eq "--socket"
$x eq "-S" $x eq "--socket"
Truth table66%2/3
A or B
A= $x eq "-S"B= $x eq "--socket"
ABresult
1X1
011
000
945 ▶ elsif ( $x =~ /\A-S./ || $x =~ /\A--socket=/ ) { }
Condition33%1/3
$x =~ /\A-S./ or $x =~ /\A--socket=/
l!l&&r!l&&!r
008
MC/DC0%0/2
$x =~ /\A-S./ or $x =~ /\A--socket=/
$x =~ /\A-S./ $x =~ /\A--socket=/
Truth table33%1/3
A or B
A= $x =~ /\A-S./B= $x =~ /\A--socket=/
ABresult
1X1
011
000
946 3 elsif ( $x =~ /\A-/ ) { push @opts, $x }
947 5 else { push @cmd, $x }
948 }
949 5 ▶ my ($host) = map { /\A(?:-h|--host=)(.+)\z/ ? $1 : () } @opts;
Branch: 1 branch
BranchTrueFalseTotal
/\A(?:-h|--host=)(.+)\z/ ? : 0 13 13
950 5 ▶ for my $i ( 0 .. $#opts - 1 ) { $host = $opts[ $i + 1 ] if $opts[$i] =~ /\A(?:-h|--host)\z/ }
Branch: 1 branch
BranchTrueFalseTotal
if $opts[$i] =~ /\A(?:-h|--host)\z/ 1 9 10
951 5 ▶ $host //= 'localhost';
Condition100%2/2
$host //= "localhost"
l!l
14
MC/DC100%1/1
$host //= "localhost"
$host
Truth table100%2/2
A
A= $host
Aresult
11
00
952 5 my $map = { variables => 'SHOW GLOBAL VARIABLES', status => undef, processlist => 'SHOW PROCESSLIST', 'flush-privileges' => 'FLUSH PRIVILEGES',
953 'flush-logs' => 'FLUSH LOGS', ping => undef, version => 'SELECT VERSION()' };
954 5 ▶ my $c = $cmd[0] // '';
Condition50%1/2
$cmd[0] // ""
l!l
50
MC/DC0%0/1
$cmd[0] // ""
$cmd[0]
Truth table50%1/2
A
A= $cmd[0]
Aresult
11
00
955 return ( "mysqladmin: connect to server at '$host' failed\nerror: 'Can't connect to local server through socket '/run/mysqld/mysqld.sock' (2)'", 0 )
956 5 ▶ unless $dev->{mariadb} && _active($dev);
Branch: 1 branch
BranchTrueFalseTotal
unless $$dev{"mariadb"} and _active($dev) 0 5 5
Condition33%1/3
$$dev{"mariadb"} and _active($dev)
!ll&&!rl&&r
005
MC/DC0%0/2
$$dev{"mariadb"} and _active($dev)
$$dev{"mariadb"} _active($dev)
Truth table33%1/3
A and B
A= $$dev{"mariadb"}B= _active($dev)
ABresult
0X0
100
111
957 0 ▶ if ( !exists $map->{$c} ) { push @GAPS, join( ' ', 'mysqladmin', @$av ); return ( '', 0 ) }
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $$map{$c}) 0 5 5
958 # Verbindung und Anmeldung wie beim Client (bind-address, Konten, max_connections)
959 5 my ( $e, $ok ) = client( $dev, [ @opts, '-e', 'SELECT 1' ], $ctx, undef, $os_user, 'mysqladmin' );
960 5 ▶ if ( !$ok ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ok) 3 2 5
961 3 ▶ return ( $e, 0 ) unless ( $e // '' ) =~ /\AERROR \d+ \(\w+\): (.*)\z/s;
Branch: 1 branch
BranchTrueFalseTotal
unless ($e // "") =~ /\AERROR \d+ \(\w+\): (.*)\z/s 0 3 3
Condition50%1/2
$e // ""
l!l
30
MC/DC0%0/1
$e // ""
$e
Truth table50%1/2
A
A= $e
Aresult
11
00
962 3 my $msg = $1;
963 # ping: Der Server laeuft, auch wenn er die Anmeldung verweigert (Exit 0)
964 3 ▶ return ( "mysqladmin: connect to server at '$host' failed\nerror: '$msg'", $c eq 'ping' && $msg =~ /\AAccess denied/ ? 1 : 0 );
Branch: 1 branch
BranchTrueFalseTotal
$c eq 'ping' && $msg =~ /\AAccess denied/ ? : 1 2 3
Condition100%3/3
$c eq "ping" and $msg =~ /\AAccess denied/
!ll&&!rl&&r
111
MC/DC100%2/2
$c eq "ping" and $msg =~ /\AAccess denied/
$c eq "ping" $msg =~ /\AAccess denied/
Truth table100%3/3
A and B
A= $c eq "ping"B= $msg =~ /\AAccess denied/
ABresult
0X0
100
111
965 }
966 2 ▶ return ( 'mysqld is alive', 1 ) if $c eq 'ping';
Branch: 1 branch
BranchTrueFalseTotal
if $c eq "ping" 1 1 2
967 1 ▶ if ( $c eq 'status' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c eq "status") 1 0 1
968 1 ▶ my $st = $dev->{mariadb}{status} || {};
Condition50%1/2
$$dev{'mariadb'}{'status'} || {}
l!l
10
MC/DC0%0/1
$$dev{'mariadb'}{'status'} || {}
$$dev{'mariadb'}{'status'}
Truth table50%1/2
A
A= $$dev{'mariadb'}{'status'}
Aresult
11
00
969 1 ▶ return ( 'Uptime: 1728000 Threads: ' . ( $st->{Threads_connected} // 1 ) . ' Questions: 88120441 Slow queries: 12 Opens: 2210 Open tables: 2000 Queries per second avg: 51.000', 1 );
Condition50%1/2
$$st{"Threads_connected"} // 1
l!l
10
MC/DC0%0/1
$$st{"Threads_connected"} // 1
$$st{"Threads_connected"}
Truth table50%1/2
A
A= $$st{"Threads_connected"}
Aresult
11
00
970 }
971 0 return client( $dev, [ @opts, '-t', '-e', $map->{$c} ], $ctx, undef, $os_user, 'mysqladmin' );
972 }
973  
974 2 1;
975  
976 __END__
↑ Summary blib/lib/Langertha/Holmgang/Sim/Linux/Redis.pm »