SimpleOps.pm

filter: Statementstmt 65.9% 915 / 1388 Branchbran 53.0% 535 / 1008 Conditioncond 40.8% 136 / 333 MC/DCmcdc 21.6% 42 / 194 Subroutinesub 84.1% 69 / 82 Podpod 79.1% 19 / 24 totaltotal 56.6% 1716 / 3029 CC 648 SCAR 66.8
CC
648
Cov
58%
_Call
4758.5
_SelectCursor
1384.7
new
733.6
CRAP 793.4
↑ Summary SimpleOps/DBI/MySQL.pm »
1 ## ABSTRACT SQL Simple Operations Commands
2 #
3 ## LICENSE AND COPYRIGHT
4 #
5 ## Copyright (C) Carlos Celso
6 #
7 ## This program is free software: you can redistribute it and/or modify
8 ## it under the terms of the GNU General Public License as published by
9 ## the Free Software Foundation, either version 3 of the License, or
10 ## (at your option) any later version.
11 #
12 ## This program is distributed in the hope that it will be useful,
13 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ## GNU General Public License for more details.
16 #
17 ## You should have received a copy of the GNU General Public License
18 ## along with this program. If not, see L<http://www.gnu.org/licenses/>.
19 #
20 package SQL::SimpleOps;
21  
22 4 ▶ use 5.006001;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 4 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 4 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 4 ▶ use Exporter;
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 4 ▶ use DBI;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 4 ▶ use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30 ## dynamic modules
31  
32 ## option configfile=
33 ## JSON
34  
35 ## option driver=[drivername]
36 ## SQL::SimpleOps::[interface]::[driver]
37  
38 ## option message_log=1 (used as "required")
39 ## Sys::Syslog
40  
41 ## option sql_save=1 (used as "required")
42 ## Calc::Date
43 ## File::Path
44 ## IO::File
45  
46 ################################################################################
47 ## global initialization
48  
49 4 our @ISA = qw ( Exporter );
50  
51 4 our @EXPORT = qw(
52 new
53 Open Select SelectCursor Delete Insert Update Commit Close Call Wait
54 Join SelectSubQuery
55 getDBH getMessage getRC getRows getLastCursor getLastSQL getLastSave
56 getWhere getAliasTable getAliasCols
57 setDumper
58  
59 SQL_SIMPLE_ALIAS_INSERT
60 SQL_SIMPLE_ALIAS_UPDATE
61 SQL_SIMPLE_ALIAS_DELETE
62 SQL_SIMPLE_ALIAS_SELECT
63 SQL_SIMPLE_ALIAS_WHERE
64 SQL_SIMPLE_ALIAS_GROUPBY
65 SQL_SIMPLE_ALIAS_ORDERBY
66  
67 SQL_SIMPLE_CURSOR_BACK
68 SQL_SIMPLE_CURSOR_NEXT
69 SQL_SIMPLE_CURSOR_TOP
70 SQL_SIMPLE_CURSOR_LAST
71 SQL_SIMPLE_CURSOR_RELOAD
72  
73 SQL_SIMPLE_ORDER_OFF
74 SQL_SIMPLE_ORDER_ASC
75 SQL_SIMPLE_ORDER_DESC
76  
77 SQL_SIMPLE_CMD_OFF
78 SQL_SIMPLE_CMD_ON
79 SQL_SIMPLE_CMD_ALL
80  
81 SQL_SIMPLE_LOG_OFF
82 SQL_SIMPLE_LOG_STD
83 SQL_SIMPLE_LOG_SYS
84 SQL_SIMPLE_LOG_ALL
85  
86 SQL_SIMPLE_RC_SYNTAX
87 SQL_SIMPLE_RC_OK
88 SQL_SIMPLE_RC_ERROR
89 SQL_SIMPLE_RC_EMPTY
90  
91 $VERSION
92 $errstr
93 $err
94 );
95  
96 4 our $VERSION = "2026.131.1";
97  
98 4 our @EXPORT_OK = @EXPORT;
99  
100 4 our %EXPORT_TAGS = ( all => [@EXPORT_OK] );
101  
102 ################################################################################
103 ## literals initialization
104  
105 4 ▶ use constant SQL_SIMPLE_ALIAS_INSERT => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
106 4 ▶ use constant SQL_SIMPLE_ALIAS_UPDATE => 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
107 4 ▶ use constant SQL_SIMPLE_ALIAS_DELETE => 4;
Subroutine BEGIN: called CC=1 SCAR=0.0
108 4 ▶ use constant SQL_SIMPLE_ALIAS_SELECT => 8;
Subroutine BEGIN: called CC=1 SCAR=0.0
109 4 ▶ use constant SQL_SIMPLE_ALIAS_WHERE => 16;
Subroutine BEGIN: called CC=1 SCAR=0.0
110 4 ▶ use constant SQL_SIMPLE_ALIAS_GROUPBY => 32;
Subroutine BEGIN: called CC=1 SCAR=0.0
111 4 ▶ use constant SQL_SIMPLE_ALIAS_ORDERBY => 64;
Subroutine BEGIN: called CC=1 SCAR=0.0
112 4 ▶ use constant SQL_SIMPLE_ALIAS_FQDN => 32768;
Subroutine BEGIN: called CC=1 SCAR=0.0
113  
114 4 ▶ use constant SQL_SIMPLE_CURSOR_TOP => 1; # page first
Subroutine BEGIN: called CC=1 SCAR=0.0
115 4 ▶ use constant SQL_SIMPLE_CURSOR_BACK => 2; # page backward
Subroutine BEGIN: called CC=1 SCAR=0.0
116 4 ▶ use constant SQL_SIMPLE_CURSOR_NEXT => 3; # page next
Subroutine BEGIN: called CC=1 SCAR=0.0
117 4 ▶ use constant SQL_SIMPLE_CURSOR_LAST => 4; # page last
Subroutine BEGIN: called CC=1 SCAR=0.0
118 4 ▶ use constant SQL_SIMPLE_CURSOR_RELOAD => 5; # page current
Subroutine BEGIN: called CC=1 SCAR=0.0
119  
120 4 ▶ use constant SQL_SIMPLE_ORDER_OFF => undef; # order disabled
Subroutine BEGIN: called CC=1 SCAR=0.0
121 4 ▶ use constant SQL_SIMPLE_ORDER_ASC => "ASC"; # order asceding
Subroutine BEGIN: called CC=1 SCAR=0.0
122 4 ▶ use constant SQL_SIMPLE_ORDER_DESC => "DESC"; # order descending
Subroutine BEGIN: called CC=1 SCAR=0.0
123  
124 4 ▶ use constant SQL_SIMPLE_CMD_OFF => 0; # sql_save disabled
Subroutine BEGIN: called CC=1 SCAR=0.0
125 4 ▶ use constant SQL_SIMPLE_CMD_ON => 1; # sql_save update
Subroutine BEGIN: called CC=1 SCAR=0.0
126 4 ▶ use constant SQL_SIMPLE_CMD_ALL => 2; # sql_save read/update
Subroutine BEGIN: called CC=1 SCAR=0.0
127  
128 4 ▶ use constant SQL_SIMPLE_LOG_OFF => 0; # log disabled
Subroutine BEGIN: called CC=1 SCAR=0.0
129 4 ▶ use constant SQL_SIMPLE_LOG_SYS => 1; # log syslog
Subroutine BEGIN: called CC=1 SCAR=0.0
130 4 ▶ use constant SQL_SIMPLE_LOG_STD => 2; # log stderr
Subroutine BEGIN: called CC=1 SCAR=0.0
131 4 ▶ use constant SQL_SIMPLE_LOG_ALL => 3; # log stderr/syslog
Subroutine BEGIN: called CC=1 SCAR=0.0
132  
133 4 ▶ use constant SQL_SIMPLE_RC_SYNTAX => -1; # syntax error
Subroutine BEGIN: called CC=1 SCAR=0.0
134 4 ▶ use constant SQL_SIMPLE_RC_OK => 0; # sql successul
Subroutine BEGIN: called CC=1 SCAR=0.0
135 4 ▶ use constant SQL_SIMPLE_RC_ERROR => 1; # sql error
Subroutine BEGIN: called CC=1 SCAR=0.0
136 4 ▶ use constant SQL_SIMPLE_RC_EMPTY => 2; # sql successul, empty
Subroutine BEGIN: called CC=1 SCAR=0.0
137  
138 4 our $SQL_SIMPLE_CURSOR_ORDER =
139 {
140 1 => SQL_SIMPLE_ORDER_ASC, # top
141 2 => SQL_SIMPLE_ORDER_DESC, # last
142 3 => SQL_SIMPLE_ORDER_ASC, # next
143 4 => SQL_SIMPLE_ORDER_DESC, # last
144 5 => SQL_SIMPLE_ORDER_ASC, # reload
145 };
146  
147 ################################################################################
148 ## local environments
149
150 4 our $SQL_SIMPLE_CLASS = "SQL::SimpleOps";
151  
152 4 our %SQL_SIMPLE_TABLE_OF_MSGS =
153 (
154 "001" => { T=>"E", M=>"[%s] Database is missing" },
155 "002" => { T=>"E", M=>"[%s] Server is missing" },
156 "003" => { T=>"E", M=>"[%s] Interface invalid" },
157 "004" => { T=>"S", M=>"[%s] The Database driver is omitted or empty" },
158 "005" => { T=>"E", M=>"[%s] Table is missing or invalid" },
159 "006" => { T=>"E", M=>"[%s] Table invalid, must be single-value or array" },
160 "007" => { T=>"E", M=>"[%s] Fields invalid, must be array" },
161 "008" => { T=>"E", M=>"[%s] Group_by invalid, must be single-value or array" },
162 "009" => { T=>"E", M=>"[%s] Order_by invalid, must be single-value or array-pairs" },
163 "010" => { T=>"E", M=>"[%s] Field '%s' not mapped in table list" },
164 "011" => { T=>"E", M=>"[%s} Stat File error, %s" },
165 "012" => { T=>"I", M=>"[%s] Key not found" },
166 "013" => { T=>"E", M=>"[%s] Cursor is missing or invalid" },
167 "014" => { T=>"E", M=>"[%s] Cursor Key is missing or invalid" },
168 "015" => { T=>"E", M=>"[%s] Cursor Command invalid" },
169 "016" => { T=>"W", M=>"[%s] Key is missing, option 'force' is required" },
170 "017" => { T=>"E", M=>"[%s] Fields is missing" },
171 "018" => { T=>"E", M=>"[%s] Fields Format error, must be hash-pairs or arrayref" },
172 "019" => { T=>"W", M=>"[%s] Interface '%s::%s' missing" },
173 "020" => { T=>"E", M=>"[%s] Where Clause invalid" },
174 "021" => { T=>"E", M=>"[%s] Where invalid, must be single-value or array" },
175 "022" => { T=>"E", M=>"[%s] Database is not open" },
176 "023" => { T=>"E", M=>"[%s] SQL Command is missing" },
177 "024" => { T=>"E", M=>"[%s] Buffer Type invalid, must be hashref, arrayref, scalaref or callback_ref" },
178 "025" => { T=>"S", M=>"[%s] Make Folder error, %s" },
179 "026" => { T=>"S", M=>"[%s] Open File error, %s" },
180 "027" => { T=>"S", M=>"[%s] Values is missing" },
181 "028" => { T=>"E", M=>"[%s] Table/Field Value invalid, must be single-value or array" },
182 "029" => { T=>"E", M=>"[%s] TCP Port invalid, must be numeric and between 1-65536" },
183 "030" => { T=>"E", M=>"[%s] Aliass Table is not a hashref" },
184 "031" => { T=>"E", M=>"[%s] Aliases '%s' invalid, table_cols must be hashref" },
185 "032" => { T=>"E", M=>"[%s] Aliases '%s' invalid, table_cols invalid format" },
186 "033" => { T=>"E", M=>"[%s] Table '%s' already, there can be only one" },
187 "034" => { T=>"E", M=>"[%s] Aliases '%s' invalid, table_name is missing" },
188 "035" => { T=>"S", M=>"[%s] Interface '%s::%s' error, %s" },
189 "036" => { T=>"S", M=>"[%s] Interface '%s::%s' load error" },
190 "037" => { T=>"S", M=>"[%s] Interface '%s::%s' aborted, %s" },
191 "038" => { T=>"E", M=>"[%s] Syslog Facility invalid, must be 'local0' to 'local7'" },
192 "039" => { T=>"E", M=>"[%s] Syslog Service invalid, must contains 'alphanumeric' characters" },
193 "040" => { T=>"E", M=>"[%s] Log File invalid, must contains 'alphanumeric' characters" },
194 "041" => { T=>"E", M=>"[%s] Values Format error, must be arrayref" },
195 "042" => { T=>"E", M=>"[%s] Conflict/Duplicate Format error, must be hashref" },
196 "043" => { T=>"E", M=>"[%s] Limit is missing" },
197 "044" => { T=>"E", M=>"[%s] Buffer hashkey invalid, buffer is not hashref" },
198 "045" => { T=>"E", M=>"[%s] Buffer hashkey not mapped" },
199 "046" => { T=>"E", M=>"[%s] Buffer hashkey must be scalaref or arrayref" },
200 "047" => { T=>"E", M=>"[%s] Buffer arrayref Off not allowed for multiple field list" },
201 "048" => { T=>"E", M=>"[%s] Buffer hashindex must be arrayref" },
202 "049" => { T=>"E", M=>"[%s] Cursor_order invalid" },
203 "050" => { T=>"E", M=>"[%s] Buffer reverse invalid, buffer is not arrayref" },
204 "099" => { T=>"S", M=>"[%s] %s" },
205 );
206  
207 4 our $errstr = ""; # last message
208 4 our $err = 0; # last return code
209  
210 4 1;
211  
212 ################################################################################
213 ## action: create object
214 ## return:
215 ## null falure to loaded, system error
216 ## bless is successful loaded
217  
218 sub new()
219 3 ▶{
Subroutine new: called CC=63 SCAR=66.0
Pod undocumented
220 3 ▶ my $class = shift; $class = ref($class) || $class || $SQL_SIMPLE_CLASS;
Condition33%2/6
ref $class || $class || $SQL::SimpleOps::SQL_SIMPLE_CLASS
l!l&&r!l&&!r
300
ref $class or $class
l!l&&r!l&&!r
030
MC/DC0%0/3
ref $class || $class || $SQL::SimpleOps::SQL_SIMPLE_CLASS
ref $class $class $SQL::SimpleOps::SQL_SIMPLE_CLASS
Truth table25%1/4
A or B || C
A= ref $classB= $classC= $SQL::SimpleOps::SQL_SIMPLE_CLASS
ABCresult
1XX1
01X1
0011
0000
221 3 my $self = {};
222  
223 3 $self->{argv} = {@_};
224  
225 ## checking for configfile
226 3 ▶ if (defined($self->{argv}{configfile}))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"argv"}{"configfile"}) 0 3 3
227 {
228 0 ▶ if (!stat($self->{argv}{configfile}))
Branch: 1 branch
BranchTrueFalseTotal
unless (stat $self->{"argv"}{"configfile"}) 0 0 0
229 {
230 0 &_setMessage($self,"new",SQL_SIMPLE_RC_SYNTAX,"011",$self->{argv}{configfile});
231 0 return undef;
232 }
233 0 my $fh = new IO::File($self->{argv}{configfile});
234 0 ▶ if (!defined($fh))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $fh) 0 0 0
235 {
236 0 &_setMessage($self,"new",SQL_SIMPLE_RC_SYNTAX,"026",$!);
237 0 return undef;
238 }
239 0 require JSON;
240 0 ▶ my $st; while (!$fh->eof) { $st .= <$fh>; }; undef($fh);
Branch: 1 branch
BranchTrueFalseTotal
unless ($fh->eof) 0 0 0
241 0 my $pt = new JSON(); $self->{argv} = $pt->decode($st); undef($pt);
242 }
243  
244 ## defaults
245 3 ▶ $self->{argv}{interface} = "dbi" if (!defined($self->{argv}{interface}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"argv"}{"interface"} 3 0 3
246 3 ▶ $self->{argv}{quote} = "'" if (!defined($self->{argv}{quote}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"argv"}{"quote"} 3 0 3
247 3 ▶ $self->{argv}{connect} = 1 if (!defined($self->{argv}{connect}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"argv"}{"connect"} 0 3 3
248 3 ▶ $self->{argv}{message_log} = SQL_SIMPLE_LOG_STD if (!defined($self->{argv}{message_log}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"argv"}{"message_log"} 1 2 3
249 3 ▶ $self->{argv}{port} = "" if (!defined($self->{argv}{port}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"argv"}{"port"} 3 0 3
250  
251 ## check interfaces
252 3 ▶ if (!grep(/^$self->{argv}{interface}$/i,"dbi"))
Branch: 1 branch
BranchTrueFalseTotal
unless (grep /^$self->{"argv"}{"interface"}$/i, "dbi") 0 3 3
253 {
254 0 &_setMessage($self,"new",SQL_SIMPLE_RC_SYNTAX,"003");
255 0 return undef;
256 }
257  
258 ## check driver
259 3 ▶ if (!defined($self->{argv}{driver}) || $self->{argv}{driver} eq "")
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $self->{"argv"}{"driver"} or $self->{"argv"}{"driver"} eq "") 0 3 3
Condition33%1/3
not defined $self->{"argv"}{"driver"} or $self->{"argv"}{"driver"} eq ""
l!l&&r!l&&!r
003
MC/DC0%0/2
not defined $self->{"argv"}{"driver"} or $self->{"argv"}{"driver"} eq ""
not defined $self->{"argv"}{"driver"} $self->{"argv"}{"driver"} eq ""
Truth table33%1/3
not(A) or B
A= not defined $self->{"argv"}{"driver"}B= $self->{"argv"}{"driver"} eq ""
ABresult
1X1
011
000
260 {
261 0 &_setMessage($self,"new",SQL_SIMPLE_RC_SYNTAX,"004");
262 0 return undef;
263 }
264  
265 ## check database
266 3 ▶ if ((!defined($self->{argv}{db}) || $self->{argv}{db} eq "") && !defined($self->{argv}{dsname}))
Branch: 1 branch
BranchTrueFalseTotal
if (!defined($self->{"argv"}{"db"}) || $self->{"argv"}{"db"} eq "" and not defined $self->{"argv"}{"dsname"}) 0 3 3
Condition33%2/6
!defined($self->{"argv"}{"db"}) || $self->{"argv"}{"db"} eq "" and not defined $self->{"argv"}{"dsname"}
!ll&&!rl&&r
300
not defined $self->{"argv"}{"db"} or $self->{"argv"}{"db"} eq ""
l!l&&r!l&&!r
003
MC/DC0%0/3
!defined($self->{"argv"}{"db"}) || $self->{"argv"}{"db"} eq "" and not defined $self->{"argv"}{"dsname"}
not defined $self->{"argv"}{"db"} $self->{"argv"}{"db"} eq "" not defined $self->{"argv"}{"dsname"}
Truth table20%1/5
not(A) or B and not(C)
A= not defined $self->{"argv"}{"db"}B= $self->{"argv"}{"db"} eq ""C= not defined $self->{"argv"}{"dsname"}
ABCresult
00X0
1X00
0100
1X11
0111
267 {
268 0 &_setMessage($self,"new",SQL_SIMPLE_RC_SYNTAX,"001");
269 0 return undef;
270 }
271  
272 ## check aliases table
273 3 ▶ if (defined($self->{argv}{tables}))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"argv"}{"tables"}) 1 2 3
274 {
275 1 ▶ if (ref($self->{argv}{tables}) ne "HASH")
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->{"argv"}{"tables"} ne "HASH") 0 1 1
276 {
277 0 &_setMessage($self,"new",SQL_SIMPLE_RC_SYNTAX,"030");
278 0 return undef;
279 }
280 1 foreach my $table(keys(%{$self->{argv}{tables}}))
281 {
282 3 ▶ if (!defined($self->{argv}{tables}{$table}{name}) || $self->{argv}{tables}{$table}{name} eq "")
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $self->{"argv"}{"tables"}{$table}{"name"} or $self->{"argv"}{"tables"}{$table}{"name"} eq "") 0 3 3
Condition33%1/3
not defined $self->{"argv"}{"tables"}{$table}{"name"} or $self->{"argv"}{"tables"}{$table}{"name"} eq ""
l!l&&r!l&&!r
003
MC/DC0%0/2
not defined $self->{"argv"}{"tables"}{$table}{"name"} or $self->{"argv"}{"tables"}{$table}{"name"} eq ""
not defined $self->{"argv"}{"tables"}{$table}{"name"} $self->{"argv"}{"tables"}{$table}{"name"} eq ""
Truth table33%1/3
not(A) or B
A= not defined $self->{"argv"}{"tables"}{$table}{"name"}B= $self->{"argv"}{"tables"}{$table}{"name"} eq ""
ABresult
1X1
011
000
283 {
284 0 &_setMessage($self,"new",SQL_SIMPLE_RC_SYNTAX,"034",$table);
285 0 return undef;
286 }
287 3 ▶ if (defined($self->{init}{table_realname}{$self->{argv}{tables}{$table}{name}}))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"init"}{"table_realname"}{$self->{"argv"}{"tables"}{$table}{"name"}}) 0 3 3
288 {
289 0 &_setMessage($self,"new",SQL_SIMPLE_RC_SYNTAX,"034",$table);
290 0 return undef;
291 }
292 3 ▶ if (defined($self->{argv}{tables}{$self->{argv}{tables}{$table}{name}}))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"argv"}{"tables"}{$self->{"argv"}{"tables"}{$table}{"name"}}) 0 3 3
293 {
294 0 &_setMessage($self,"new",SQL_SIMPLE_RC_SYNTAX,"034",$table);
295 0 return undef;
296 }
297 3 $self->{init}{table_realname}{$self->{argv}{tables}{$table}{name}} = $table;
298 3 ▶ if (defined($self->{argv}{tables}{$table}{cols}))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"argv"}{"tables"}{$table}{"cols"}) 2 1 3
299 {
300 2 ▶ if (ref($self->{argv}{tables}{$table}{cols}) ne "HASH")
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->{"argv"}{"tables"}{$table}{"cols"} ne "HASH") 0 2 2
301 {
302 0 &_setMessage($self,"new",SQL_SIMPLE_RC_SYNTAX,"031",$table);
303 0 return undef;
304 }
305 2 my $myTable = $self->{argv}{tables}{$table}{name};
306 2 foreach my $field(keys(%{$self->{argv}{tables}{$table}{cols}}))
307 {
308 6 ▶ if ($self->{argv}{tables}{$table}{cols}{$field} eq "")
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"argv"}{"tables"}{$table}{"cols"}{$field} eq "") 0 6 6
309 {
310 0 &_setMessage($self,"new",SQL_SIMPLE_RC_SYNTAX,"032",$field);
311 0 return undef;
312 }
313 6 push(@{$self->{init}{fields_xref}{$field}},[$table,$self->{argv}{tables}{$table}{cols}{$field}]);
314 }
315 }
316 }
317 }
318  
319 ## check syslog options
320 3 ▶ if (defined($self->{argv}{message_syslog_facility}) && !($self->{argv}{message_syslog_facility} =~ /^local[0-7]$/i))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"argv"}{"message_syslog_facility"} and not $self->{"argv"}{"message_syslog_facility"} =~ /^local[0-7]$/i) 0 3 3
Condition33%1/3
defined $self->{"argv"}{"message_syslog_facility"} and not $self->{"argv"}{"message_syslog_facility"} =~ /^local[0-7]$/i
!ll&&!rl&&r
300
MC/DC0%0/2
defined $self->{"argv"}{"message_syslog_facility"} and not $self->{"argv"}{"message_syslog_facility"} =~ /^local[0-7]$/i
defined $self->{"argv"}{"message_syslog_facility"} not $self->{"argv"}{"message_syslog_facility"} =~ /^local[0-7]$/i
Truth table33%1/3
A and not(B)
A= defined $self->{"argv"}{"message_syslog_facility"}B= not $self->{"argv"}{"message_syslog_facility"} =~ /^local[0-7]$/i
ABresult
0X0
100
111
321 {
322 0 &_setMessage($self,"new",SQL_SIMPLE_RC_SYNTAX,"038",$self->{argv}{message_syslog_facility});
323 0 return undef;
324 }
325 3 ▶ if (defined($self->{argv}{message_syslog_service}) && ($self->{argv}{message_syslog_service} =~ s/[a-zA-Z0-9\-\_]//g))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"argv"}{"message_syslog_service"} and $self->{"argv"}{"message_syslog_service"} =~ s/[a-zA-Z0-9\-\_]//g) 0 3 3
Condition33%1/3
defined $self->{"argv"}{"message_syslog_service"} and $self->{"argv"}{"message_syslog_service"} =~ s/[a-zA-Z0-9\-\_]//g
!ll&&!rl&&r
300
MC/DC0%0/2
defined $self->{"argv"}{"message_syslog_service"} and $self->{"argv"}{"message_syslog_service"} =~ s/[a-zA-Z0-9\-\_]//g
defined $self->{"argv"}{"message_syslog_service"} $self->{"argv"}{"message_syslog_service"} =~ s/[a-zA-Z0-9\-\_]//g
Truth table33%1/3
A and B
A= defined $self->{"argv"}{"message_syslog_service"}B= $self->{"argv"}{"message_syslog_service"} =~ s/[a-zA-Z0-9\-\_]//g
ABresult
0X0
100
111
326 {
327 0 &_setMessage($self,"new",SQL_SIMPLE_RC_SYNTAX,"039",$self->{argv}{message_syslog_service});
328 0 return undef;
329 }
330 3 ▶ if (defined($self->{argv}{sql_save_name}) && ($self->{argv}{sql_save_name} =~ s/[a-zA-Z0-9\-\_]//g))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"argv"}{"sql_save_name"} and $self->{"argv"}{"sql_save_name"} =~ s/[a-zA-Z0-9\-\_]//g) 0 3 3
Condition33%1/3
defined $self->{"argv"}{"sql_save_name"} and $self->{"argv"}{"sql_save_name"} =~ s/[a-zA-Z0-9\-\_]//g
!ll&&!rl&&r
300
MC/DC0%0/2
defined $self->{"argv"}{"sql_save_name"} and $self->{"argv"}{"sql_save_name"} =~ s/[a-zA-Z0-9\-\_]//g
defined $self->{"argv"}{"sql_save_name"} $self->{"argv"}{"sql_save_name"} =~ s/[a-zA-Z0-9\-\_]//g
Truth table33%1/3
A and B
A= defined $self->{"argv"}{"sql_save_name"}B= $self->{"argv"}{"sql_save_name"} =~ s/[a-zA-Z0-9\-\_]//g
ABresult
0X0
100
111
331 {
332 0 &_setMessage($self,"new",SQL_SIMPLE_RC_SYNTAX,"040",$self->{argv}{sql_save_name});
333 0 return undef;
334 }
335  
336 ## interface defaults values
337 3 $self->{argv}{interface} = uc($self->{argv}{interface});
338 3 ▶ $self->{argv}{interface_options}{RaiseError} = 0 if (!defined($self->{argv}{interface_options}{RaiseError}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"argv"}{"interface_options"}{"RaiseError"} 3 0 3
339 3 ▶ $self->{argv}{interface_options}{PrintError} = 0 if (!defined($self->{argv}{interface_options}{PrintError}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"argv"}{"interface_options"}{"PrintError"} 3 0 3
340  
341 ## standards plugins
342 3 ▶ if (!$self->{argv}{ignore_plugin})
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"argv"}{"ignore_plugin"}) 3 0 3
343 {
344 0 ▶ if (grep(/^$self->{argv}{driver}$/i,"mysql","mariadb")) {$self->{init}{plugin_id} = "MySQL";}
Branch: 4 branches
BranchTrueFalseTotal
if (grep /^$self->{'argv'}{'driver'}$/i, 'mysql', 'mariadb') { } 0 3 3
elsif (grep /^$self->{'argv'}{'driver'}$/i, 'pg', 'postgres', 'postsql', 'pgsql') { } 0 3 3
elsif (grep /^$self->{'argv'}{'driver'}$/i, 'sqlite', 'sqlite3') { } 3 0 3
elsif (grep /^$self->{'argv'}{'driver'}$/i, 'odbc') { } 0 0 0
345 0 elsif (grep(/^$self->{argv}{driver}$/i,"pg","postgres","postsql","pgsql")) {$self->{init}{plugin_id} = "PG";}
346 3 elsif (grep(/^$self->{argv}{driver}$/i,"sqlite","sqlite3")) {$self->{init}{plugin_id} = "SQLite";}
347 0 elsif (grep(/^$self->{argv}{driver}$/i,"odbc")) {$self->{init}{plugin_id} = "ODBC";}
348 0 else {$self->{init}{plugin_id} = $self->{argv}{driver};}
349  
350 ## load pluging
351 3 my $fn;
352 3 my $plugin = $SQL_SIMPLE_CLASS."::".$self->{argv}{interface}."::".$self->{init}{plugin_id};
353 3 foreach my $dir(@INC)
354 {
355 6 $fn = File::Spec->catdir($dir,split(/::/,$plugin)).".pm";
356 6 ▶ next if (!stat($fn));
Branch: 1 branch
BranchTrueFalseTotal
unless stat $fn 3 3 6
357  
358 ## load plugin if exists
359 eval
360 3 {
361 3 require $fn;
362 3 $self->{init}{plugin_fh} = $plugin->new(sql_simple => $self);
363 };
364 3 ▶ if ($@)
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 3 3
365 {
366 0 &_setMessage($self,"new",SQL_SIMPLE_RC_SYNTAX,"035",$self->{argv}{interface},$self->{init}{plugin_id},$@);
367 0 return undef;
368 }
369 3 ▶ if (!defined($self->{init}{plugin_fh}))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"init"}{"plugin_fh"}) 0 3 3
370 {
371 0 &_setMessage($self,"new",SQL_SIMPLE_RC_SYNTAX,"035",$self->{argv}{interface},$self->{init}{plugin_id},$@);
372 0 return undef;
373 }
374 3 last;
375 }
376 3 ▶ &_setMessage($self,"new",SQL_SIMPLE_RC_SYNTAX,"019",$self->{argv}{interface},$self->{init}{plugin_id}) if (!defined($self->{init}{plugin_fh}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"init"}{"plugin_fh"} 0 3 3
377  
378 3 ▶ $self->{init}{test_server} = 1 if (defined($self->{argv}{server}) && $self->{argv}{server} ne "");
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"argv"}{"server"} and $self->{"argv"}{"server"} ne "" 0 3 3
Condition33%1/3
defined $self->{"argv"}{"server"} and $self->{"argv"}{"server"} ne ""
!ll&&!rl&&r
300
MC/DC0%0/2
defined $self->{"argv"}{"server"} and $self->{"argv"}{"server"} ne ""
defined $self->{"argv"}{"server"} $self->{"argv"}{"server"} ne ""
Truth table33%1/3
A and B
A= defined $self->{"argv"}{"server"}B= $self->{"argv"}{"server"} ne ""
ABresult
0X0
100
111
379  
380 ## test server, the 'test_server' env must be defined on plugin
381 3 ▶ if ($self->{init}{test_server})
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"init"}{"test_server"}) 0 3 3
382 {
383 0 ▶ if (!defined($self->{argv}{server}) || $self->{argv}{server} eq "")
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $self->{"argv"}{"server"} or $self->{"argv"}{"server"} eq "") 0 0 0
Condition0%0/3
not defined $self->{"argv"}{"server"} or $self->{"argv"}{"server"} eq ""
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $self->{"argv"}{"server"} or $self->{"argv"}{"server"} eq ""
not defined $self->{"argv"}{"server"} $self->{"argv"}{"server"} eq ""
Truth table0%0/3
not(A) or B
A= not defined $self->{"argv"}{"server"}B= $self->{"argv"}{"server"} eq ""
ABresult
1X1
011
000
384 {
385 0 &_setMessage($self,"new",SQL_SIMPLE_RC_SYNTAX,"002");
386 0 return undef;
387 }
388 0 ▶ if (defined($self->{argv}{port}) && $self->{argv}{port} ne "" && (($self->{argv}{port} =~ /^\D+$/) || ($self->{argv}{port} < 1 || $self->{argv}{port} > 65535)))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"argv"}{"port"} and $self->{"argv"}{"port"} ne "" and $self->{"argv"}{"port"} =~ /^\D+$/ || ($self->{"argv"}{"port"} < 1 || $self->{"argv"}{"port"} > 65535)) 0 0 0
Condition0%0/12
defined $self->{"argv"}{"port"} and $self->{"argv"}{"port"} ne "" and $self->{"argv"}{"port"} =~ /^\D+$/ || ($self->{"argv"}{"port"} < 1 || $self->{"argv"}{"port"} > 65535)
!ll&&!rl&&r
000
defined $self->{"argv"}{"port"} and $self->{"argv"}{"port"} ne ""
!ll&&!rl&&r
000
$self->{"argv"}{"port"} =~ /^\D+$/ or ($self->{"argv"}{"port"} < 1 or $self->{"argv"}{"port"} > 65535)
l!l&&r!l&&!r
000
$self->{"argv"}{"port"} < 1 or $self->{"argv"}{"port"} > 65535
l!l&&r!l&&!r
000
MC/DC0%0/5
defined $self->{"argv"}{"port"} and $self->{"argv"}{"port"} ne "" and $self->{"argv"}{"port"} =~ /^\D+$/ || ($self->{"argv"}{"port"} < 1 || $self->{"argv"}{"port"} > 65535)
defined $self->{"argv"}{"port"} $self->{"argv"}{"port"} ne "" $self->{"argv"}{"port"} =~ /^\D+$/ $self->{"argv"}{"port"} < 1 $self->{"argv"}{"port"} > 65535
Truth table0%0/6
A and B and C or D or E
A= defined $self->{"argv"}{"port"}B= $self->{"argv"}{"port"} ne ""C= $self->{"argv"}{"port"} =~ /^\D+$/D= $self->{"argv"}{"port"} < 1E= $self->{"argv"}{"port"} > 65535
ABCDEresult
0XXXX0
10XXX0
110000
111XX1
1101X1
110011
389 {
390 0 &_setMessage($self,"new",SQL_SIMPLE_RC_SYNTAX,"029");
391 0 return undef;
392 }
393 }
394 }
395  
396 ## review the defaults flags plugins args versus args envs
397 3 ▶ $self->{init}{alias_with_as} = $self->{argv}{alias_with_as} if (defined($self->{argv}{alias_with_as}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"argv"}{"alias_with_as"} 0 3 3
398 3 ▶ $self->{init}{schema} = 1 if (defined($self->{argv}{schema}) && $self->{argv}{schema} ne "");
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"argv"}{"schema"} and $self->{"argv"}{"schema"} ne "" 0 3 3
Condition33%1/3
defined $self->{"argv"}{"schema"} and $self->{"argv"}{"schema"} ne ""
!ll&&!rl&&r
300
MC/DC0%0/2
defined $self->{"argv"}{"schema"} and $self->{"argv"}{"schema"} ne ""
defined $self->{"argv"}{"schema"} $self->{"argv"}{"schema"} ne ""
Truth table33%1/3
A and B
A= defined $self->{"argv"}{"schema"}B= $self->{"argv"}{"schema"} ne ""
ABresult
0X0
100
111
399  
400 ## new object
401 3 my $bless = bless($self,$class);
402 3 ▶ return undef if (!defined($bless));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $bless 0 3 3
403  
404 ## my first connect
405 3 ▶ return undef if ($self->{argv}{connect} && $self->Open());
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"argv"}{"connect"} and $self->Open 0 3 3
Condition33%1/3
$self->{"argv"}{"connect"} and $self->Open
!ll&&!rl&&r
300
MC/DC0%0/2
$self->{"argv"}{"connect"} and $self->Open
$self->{"argv"}{"connect"} $self->Open
Truth table33%1/3
A and B
A= $self->{"argv"}{"connect"}B= $self->Open
ABresult
0X0
100
111
406  
407 ## successful
408 3 return $bless;
409 }
410  
411 ################################################################################
412 ## action: open database
413 ## return:
414 ## rc<0 syntax error
415 ## rc=0 successful
416 ## rc>0 sql return code
417  
418 sub Open()
419 2 ▶{
Subroutine Open: called CC=5 SCAR=19.0
Pod documented
420 2 my $self = shift;
421  
422 2 $self->_resetSession();
423 2 ▶ if ($self->{init}{plugin_fh})
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'init'}{'plugin_fh'}) { } 2 0 2
424 {
425 2 ▶ if ($self->{init}{plugin_fh}->can('Open') && $self->{init}{plugin_fh}->Open())
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"init"}{"plugin_fh"}->can("Open") and $self->{"init"}{"plugin_fh"}->Open) 0 2 2
Condition33%1/3
$self->{"init"}{"plugin_fh"}->can("Open") and $self->{"init"}{"plugin_fh"}->Open
!ll&&!rl&&r
020
MC/DC0%0/2
$self->{"init"}{"plugin_fh"}->can("Open") and $self->{"init"}{"plugin_fh"}->Open
$self->{"init"}{"plugin_fh"}->can("Open") $self->{"init"}{"plugin_fh"}->Open
Truth table33%1/3
A and B
A= $self->{"init"}{"plugin_fh"}->can("Open")B= $self->{"init"}{"plugin_fh"}->Open
ABresult
0X0
100
111
426 {
427 0 $self->_setMessage("open",SQL_SIMPLE_RC_SYNTAX,"037",$self->{argv}{interface},$self->{argv}{driver},$self->getMessage());
428 0 return SQL_SIMPLE_RC_SYNTAX;
429 }
430 }
431 else
432 {
433 0 $self->{argv}{dsname} = $self->{argv}{interface}.':'.$self->{argv}{driver}.':'.$self->{argv}{dsname};
434 }
435 2 ▶ if ($self->{argv}{interface} =~ /^dbi$/i)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"argv"}{"interface"} =~ /^dbi$/i) 2 0 2
436 {
437 2 $self->{init}{dbh} = DBI->connect($self->{argv}{dsname}, $self->{argv}{login}, $self->{argv}{password}, \%{$self->{argv}{interface_options}});
438 2 $self->_setMessage("open");
439 2 return $self->getRC();
440 }
441 0 return SQL_SIMPLE_RC_SYNTAX;
442 }
443  
444 ################################################################################
445 ## action: create select command to inject as subquery
446 ## return:
447 ## rc<0 syntax error
448 ## rc=0 returns SQL STRING COMMAND
449 ## rc=1 sql error
450 ## rc=2 successful, no lines selected (no match or empty)
451  
452 sub SelectSubQuery()
453 4 ▶{
Subroutine SelectSubQuery: called CC=1 SCAR=0.0
Pod documented
454 4 my $self = shift;
455 4 my $argv = {@_};
456  
457 4 $argv->{subquery} = 1;
458  
459 4 return $self->Select(%{$argv});
460 }
461  
462 ################################################################################
463 ## action: select as fetch command, buffers of lines based cursor
464 ## return:
465 ## rc<0 syntax error
466 ## rc=0 successful
467 ## rc=1 sql error
468 ## rc=2 successful, no lines selected (no match or empty)
469  
470 sub SelectCursor()
471 17 ▶{
Subroutine SelectCursor: called CC=11 SCAR=27.8
Pod documented
472 17 my $self = shift;
473 17 my $argv = {@_};
474  
475 17 $self->_resetSession();
476 17 $self->_Dumper("selectcursor",$argv);
477 17 ▶ $self->Open() if (!defined($self->{init}{dbh}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"init"}{"dbh"} 0 17 17
478  
479 ## define the command in load
480 17 $self->{work}{command} = SQL_SIMPLE_ALIAS_SELECT;
481  
482 17 ▶ if ($self->{init}{plugin_fh} && $self->{init}{plugin_fh}->can('SelectCursor') && $self->{init}{plugin_fh}->SelectCursor($argv))
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"init"}{"plugin_fh"} and $self->{"init"}{"plugin_fh"}->can("SelectCursor") and $self->{"init"}{"plugin_fh"}->SelectCursor($argv)) 0 17 17
Condition33%2/6
$self->{"init"}{"plugin_fh"} and $self->{"init"}{"plugin_fh"}->can("SelectCursor") and $self->{"init"}{"plugin_fh"}->SelectCursor($argv)
!ll&&!rl&&r
1700
$self->{"init"}{"plugin_fh"} and $self->{"init"}{"plugin_fh"}->can("SelectCursor")
!ll&&!rl&&r
0170
MC/DC0%0/3
$self->{"init"}{"plugin_fh"} and $self->{"init"}{"plugin_fh"}->can("SelectCursor") and $self->{"init"}{"plugin_fh"}->SelectCursor($argv)
$self->{"init"}{"plugin_fh"} $self->{"init"}{"plugin_fh"}->can("SelectCursor") $self->{"init"}{"plugin_fh"}->SelectCursor($argv)
Truth table25%1/4
A and B and C
A= $self->{"init"}{"plugin_fh"}B= $self->{"init"}{"plugin_fh"}->can("SelectCursor")C= $self->{"init"}{"plugin_fh"}->SelectCursor($argv)
ABCresult
0XX0
10X0
1100
1111
483 {
484 0 $self->_setMessage("select",SQL_SIMPLE_RC_SYNTAX,"037",$self->{argv}{interface},$self->{argv}{driver},$self->getMessage());
485 0 return SQL_SIMPLE_RC_SYNTAX;
486 }
487  
488 17 ▶ my $saved_message_log = $self->_setLogMessage($argv->{message_log}) if (defined($argv->{message_log}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $argv->{"message_log"} 0 17 17
489 17 ▶ my $saved_quote = $self->_setQuote($argv->{quote}) if (defined($argv->{quote}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $argv->{"quote"} 0 17 17
490 17 ▶ my $saved_sql_save = $self->_setSqlSave($argv->{sql_save}) if (defined($argv->{sql_save}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $argv->{"sql_save"} 0 17 17
491  
492 17 my $rc = $self->_SelectCursor(%{$argv});
493  
494 17 ▶ $self->setMessgeLog($saved_message_log) if (defined($argv->{message_log}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $argv->{"message_log"} 0 17 17
495 17 ▶ $self->_setQuote($saved_quote) if (defined($argv->{quote}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $argv->{"quote"} 0 17 17
496 17 ▶ $self->_setSqlSave($saved_sql_save) if (defined($argv->{sql_save}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $argv->{"sql_save"} 0 17 17
497  
498 17 return $rc;
499 }
500  
501 sub _SelectCursor()
502 17 ▶{
Subroutine _SelectCursor: called CC=93 SCAR=72.3
503 17 my $self = shift;
504 17 my $argv = {@_};
505  
506 ## validate cursor-key
507 0 ▶ if (!defined($argv->{cursor_key})) { @{$self->{work}{cursor_key}} = []; }
Branch: 3 branches
BranchTrueFalseTotal
if (not defined $argv->{'cursor_key'}) { } 0 17 17
elsif (ref $argv->{'cursor_key'} eq '') { } 9 8 17
elsif (ref $argv->{'cursor_key'} eq 'ARRAY') { } 8 0 8
508 9 elsif (ref($argv->{cursor_key}) eq "") { @{$self->{work}{cursor_key}} = ($argv->{cursor_key}); }
509 8 elsif (ref($argv->{cursor_key}) eq "ARRAY") { @{$self->{work}{cursor_key}} = @{$argv->{cursor_key}}; }
510 else
511 {
512 0 $self->_setMessage("select",SQL_SIMPLE_RC_SYNTAX,"014");
513 0 return SQL_SIMPLE_RC_SYNTAX;
514 }
515  
516 ## validate cursor, must be similar type of cursor-key
517 17 ▶ if (!defined($argv->{cursor})) {}
Branch: 3 branches
BranchTrueFalseTotal
if (not defined $argv->{'cursor'}) { } 17 0 17
elsif (ref $argv->{'cursor'} eq '' and @{$self->{'work'}{'cursor_key'};} == 1) { } 0 0 0
elsif (ref $argv->{'cursor'} eq 'ARRAY' and $self->{'work'}{'cursor_key'} == @{$argv->{'cursor'};} + 0) { } 0 0 0
518 0 ▶ elsif (ref($argv->{cursor}) eq "" && @{$self->{work}{cursor_key}} == 1) {}
Condition0%0/3
ref $argv->{"cursor"} eq "" and @{$self->{"work"}{"cursor_key"};} == 1
!ll&&!rl&&r
000
MC/DC0%0/2
ref $argv->{"cursor"} eq "" and @{$self->{"work"}{"cursor_key"};} == 1
ref $argv->{"cursor"} eq "" @{$self->{"work"}{"cursor_key"};} == 1
Truth table0%0/3
A and B
A= ref $argv->{"cursor"} eq ""B= @{$self->{"work"}{"cursor_key"};} == 1
ABresult
0X0
100
111
519 0 ▶ elsif (ref($argv->{cursor}) eq "ARRAY" && $self->{work}{cursor_key} == @{$argv->{cursor}}+0) {}
Condition0%0/3
ref $argv->{"cursor"} eq "ARRAY" and $self->{"work"}{"cursor_key"} == @{$argv->{"cursor"};} + 0
!ll&&!rl&&r
000
MC/DC0%0/2
ref $argv->{"cursor"} eq "ARRAY" and $self->{"work"}{"cursor_key"} == @{$argv->{"cursor"};} + 0
ref $argv->{"cursor"} eq "ARRAY" $self->{"work"}{"cursor_key"} == @{$argv->{"cursor"};} + 0
Truth table0%0/3
A and B
A= ref $argv->{"cursor"} eq "ARRAY"B= $self->{"work"}{"cursor_key"} == @{$argv->{"cursor"};} + 0
ABresult
0X0
100
111
520 else
521 {
522 0 $self->_setMessage("select",SQL_SIMPLE_RC_SYNTAX,"013");
523 0 return SQL_SIMPLE_RC_SYNTAX;
524 }
525  
526 ## enforce cursor as top if missed
527 17 ▶ $argv->{cursor_command} = SQL_SIMPLE_CURSOR_TOP if (!defined($argv->{cursor_command}) || $argv->{cursor_command} eq "");
Branch: 1 branch
BranchTrueFalseTotal
if not defined $argv->{"cursor_command"} or $argv->{"cursor_command"} eq "" 3 14 17
Condition66%2/3
not defined $argv->{"cursor_command"} or $argv->{"cursor_command"} eq ""
l!l&&r!l&&!r
3014
MC/DC50%1/2
not defined $argv->{"cursor_command"} or $argv->{"cursor_command"} eq ""
not defined $argv->{"cursor_command"} $argv->{"cursor_command"} eq ""
Truth table66%2/3
not(A) or B
A= not defined $argv->{"cursor_command"}B= $argv->{"cursor_command"} eq ""
ABresult
1X1
011
000
528  
529 17 ▶ if ($argv->{cursor_command} != SQL_SIMPLE_CURSOR_TOP && $argv->{cursor_command} != SQL_SIMPLE_CURSOR_LAST)
Branch: 1 branch
BranchTrueFalseTotal
if ($argv->{"cursor_command"} != 1 and $argv->{"cursor_command"} != 4) 9 8 17
Condition100%3/3
$argv->{"cursor_command"} != 1 and $argv->{"cursor_command"} != 4
!ll&&!rl&&r
629
MC/DC100%2/2
$argv->{"cursor_command"} != 1 and $argv->{"cursor_command"} != 4
$argv->{"cursor_command"} != 1 $argv->{"cursor_command"} != 4
Truth table100%3/3
A and B
A= $argv->{"cursor_command"} != 1B= $argv->{"cursor_command"} != 4
ABresult
0X0
100
111
530 {
531 ## if im not using cursor the cursor_info is required
532 9 ▶ if (!defined($argv->{cursor}) || $argv->{cursor} eq "")
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $argv->{"cursor"} or $argv->{"cursor"} eq "") 9 0 9
Condition33%1/3
not defined $argv->{"cursor"} or $argv->{"cursor"} eq ""
l!l&&r!l&&!r
900
MC/DC0%0/2
not defined $argv->{"cursor"} or $argv->{"cursor"} eq ""
not defined $argv->{"cursor"} $argv->{"cursor"} eq ""
Truth table33%1/3
not(A) or B
A= not defined $argv->{"cursor"}B= $argv->{"cursor"} eq ""
ABresult
1X1
011
000
533 {
534 9 ▶ if (!defined($argv->{cursor_info}))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $argv->{"cursor_info"}) 0 9 9
535 {
536 0 $self->_setMessage("select",SQL_SIMPLE_RC_SYNTAX,"013");
537 0 return SQL_SIMPLE_RC_SYNTAX;
538 }
539  
540 ## getting the last and first cursors
541 9 my ($first,$last);
542 9 ▶ if (ref($argv->{cursor_info}) eq "HASH")
Branch: 3 branches
BranchTrueFalseTotal
if (ref $argv->{'cursor_info'} eq 'HASH') { } 9 0 9
elsif (ref $argv->{'cursor_info'} eq 'ARRAY') { } 0 0 0
elsif (ref $argv->{'cursor_info'} eq 'SCALAR') { } 0 0 0
543 {
544 9 ($first,$last) = ($argv->{cursor_info}{first},$argv->{cursor_info}{last});
545 }
546 elsif (ref($argv->{cursor_info}) eq "ARRAY")
547 {
548 0 ($first,$last) = ($argv->{cursor_info}[2],$argv->{cursor_info}[3]);
549 }
550 elsif (ref($argv->{cursor_info}) eq "SCALAR")
551 {
552 ## scalar cursor_info mismatch with multiple keys
553 0 ▶ if (@{$self->{work}{cursor_key}} > 1)
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->{"work"}{"cursor_key"};} > 1) 0 0 0
554 {
555 0 $self->_setMessage("select",SQL_SIMPLE_RC_SYNTAX,"013");
556 0 return SQL_SIMPLE_RC_SYNTAX;
557 }
558 0 my @a=split(" ",$argv->{cursor_info}); ($first,$last) = ($a[2],$a[3]);
559 }
560 else
561 {
562 0 $self->_setMessage("select",SQL_SIMPLE_RC_SYNTAX,"013");
563 0 return SQL_SIMPLE_RC_SYNTAX;
564 }
565  
566 ## adjusting cursor if cursor_key is array
567 9 ▶ if (ref($argv->{cursor_key}) eq "ARRAY")
Branch: 1 branch
BranchTrueFalseTotal
if (ref $argv->{"cursor_key"} eq "ARRAY") 4 5 9
568 {
569 4 ▶ $first = [] if (ref($first) ne "ARRAY");
Branch: 1 branch
BranchTrueFalseTotal
if ref $first ne "ARRAY" 0 4 4
570 4 ▶ $last = [] if (ref($last) ne "ARRAY");
Branch: 1 branch
BranchTrueFalseTotal
if ref $last ne "ARRAY" 0 4 4
571 }
572  
573 ## adjusting cursor
574 9 ▶ if ($argv->{cursor_command} == SQL_SIMPLE_CURSOR_NEXT)
Branch: 3 branches
BranchTrueFalseTotal
if ($argv->{'cursor_command'} == 3) { } 3 6 9
elsif ($argv->{'cursor_command'} == 2) { } 3 3 6
elsif ($argv->{'cursor_command'} == 5) { } 3 0 3
575 {
576 3 $argv->{cursor} = $last;
577 3 ▶ $argv->{cursor_command} = SQL_SIMPLE_CURSOR_TOP if (!defined($last));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $last 1 2 3
578 }
579 elsif ($argv->{cursor_command} == SQL_SIMPLE_CURSOR_BACK)
580 {
581 3 $argv->{cursor} = $first;
582 3 ▶ $argv->{cursor_command} = SQL_SIMPLE_CURSOR_LAST if (!defined($first));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $first 1 2 3
583 }
584 elsif ($argv->{cursor_command} == SQL_SIMPLE_CURSOR_RELOAD)
585 {
586 3 $argv->{cursor} = $first;
587 }
588 }
589
590 ## enforce rerun last command if exists and request is reload
591 9 ▶ if ($argv->{cursor_command} == SQL_SIMPLE_CURSOR_RELOAD)
Branch: 1 branch
BranchTrueFalseTotal
if ($argv->{"cursor_command"} == 5) 3 6 9
592 {
593 3 $self->{work}{cursor_command_reload} = 1;
594 3 ▶ if (ref($argv->{cursor_info}) eq "HASH")
Branch: 2 branches
BranchTrueFalseTotal
if (ref $argv->{'cursor_info'} eq 'HASH') { } 3 0 3
elsif (ref $argv->{'cursor_info'} eq 'ARRAY') { } 0 0 0
595 {
596 3 ▶ $argv->{cursor_command} = $argv->{cursor_info}{previouscmd} if (defined($argv->{cursor_info}{previouscmd}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $argv->{"cursor_info"}{"previouscmd"} 0 3 3
597 }
598 elsif (ref($argv->{cursor_info}) eq "ARRAY")
599 {
600 0 ▶ $argv->{cursor_command} = $argv->{cursor_info}[ @{$argv->{cursor_info}}-1 ] if (@{$argv->{cursor_info}} >= 5);
Branch: 1 branch
BranchTrueFalseTotal
if @{$argv->{"cursor_info"};} >= 5 0 0 0
601 }
602 else
603 {
604 0 my @a = split(" ",$argv->{cursor_info});
605 0 ▶ my $b = (@{$self->{work}{cursor_key}} < 2) ? 2 : @{$self->{work}{cursor_key}} * 2;
Branch: 1 branch
BranchTrueFalseTotal
@{$self->{'work'}{'cursor_key'};} < 2 ? : 0 0 0
606 0 ▶ $argv->{cursor_command} = $a[@a-1] if (@a > (2 + $b));
Branch: 1 branch
BranchTrueFalseTotal
if @a > 2 + $b 0 0 0
607 }
608 }
609 }
610  
611 ## validade where
612 17 ▶ if (defined($argv->{where}) && ref($argv->{where}) ne "ARRAY")
Branch: 1 branch
BranchTrueFalseTotal
if (defined $argv->{"where"} and ref $argv->{"where"} ne "ARRAY") 0 17 17
Condition66%2/3
defined $argv->{"where"} and ref $argv->{"where"} ne "ARRAY"
!ll&&!rl&&r
1520
MC/DC0%0/2
defined $argv->{"where"} and ref $argv->{"where"} ne "ARRAY"
defined $argv->{"where"} ref $argv->{"where"} ne "ARRAY"
Truth table66%2/3
A and B
A= defined $argv->{"where"}B= ref $argv->{"where"} ne "ARRAY"
ABresult
0X0
100
111
613 {
614 0 $self->_setMessage("select",SQL_SIMPLE_RC_SYNTAX,"021");
615 0 return SQL_SIMPLE_RC_SYNTAX;
616 }
617  
618 ## have order by?
619 17 my @order;
620 17 ▶ if (!defined($argv->{order_by})) {}
Branch: 4 branches
BranchTrueFalseTotal
if (not defined $argv->{'order_by'}) { } 17 0 17
elsif (ref $argv->{'order_by'} eq 'ARRAY') { } 0 0 0
elsif (ref $argv->{'order_by'} eq 'HASH') { } 0 0 0
elsif (ref $argv->{'order_by'} eq '') { } 0 0 0
621 0 elsif (ref($argv->{order_by}) eq "ARRAY") { @order = @{$argv->{order_by}}; }
622 0 elsif (ref($argv->{order_by}) eq "HASH") { @order = ($argv->{order_by}); }
623 0 elsif (ref($argv->{order_by}) eq "") { @order = ($argv->{order_by}); }
624 else
625 {
626 0 $self->_setMessage("select",SQL_SIMPLE_RC_SYNTAX,"009");
627 0 return SQL_SIMPLE_RC_SYNTAX;
628 }
629  
630 ## test the type of cursor and adjust where clause
631 17 ▶ if ($argv->{cursor_command} == SQL_SIMPLE_CURSOR_TOP)
Branch: 4 branches
BranchTrueFalseTotal
if ($argv->{'cursor_command'} == 1) { } 7 10 17
elsif ($argv->{'cursor_command'} == 2) { } 2 8 10
elsif ($argv->{'cursor_command'} == 3 or $argv->{'cursor_command'} == 5) { } 5 3 8
elsif ($argv->{'cursor_command'} == 4) { } 3 0 3
632 {
633 7 my @o;
634 7 ▶ foreach my $key( (ref($argv->{cursor_key}) eq "ARRAY") ? @{$argv->{cursor_key}} : $argv->{cursor_key} )
Branch: 1 branch
BranchTrueFalseTotal
ref $argv->{'cursor_key'} eq 'ARRAY' ? : 3 4 7
635 {
636 10 push(@o,{$key => SQL_SIMPLE_ORDER_ASC});
637 }
638 7 unshift(@order,@o);
639 }
640 elsif ($argv->{cursor_command} == SQL_SIMPLE_CURSOR_BACK)
641 {
642 2 ▶ my $oper = ($self->{work}{cursor_command_reload}) ? "<=" : "<";
Branch: 1 branch
BranchTrueFalseTotal
$self->{'work'}{'cursor_command_reload'} ? : 0 2 2
643 2 ▶ if (ref($argv->{cursor_key}) ne "ARRAY")
Branch: 1 branch
BranchTrueFalseTotal
if (ref $argv->{'cursor_key'} ne 'ARRAY') { } 1 1 2
644 {
645 1 unshift(@order,{$argv->{cursor_key} => SQL_SIMPLE_ORDER_DESC});
646 1 unshift(@{$argv->{where}}, $argv->{cursor_key} => [ $oper, $argv->{cursor} ]);
647 }
648 else
649 {
650 1 my @w;
651 my @o;
652 1 ▶ for (my $i=0; $i < @{$argv->{cursor_key}}; $i++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @{$argv->{"cursor_key"};}) 2 1 3
653 {
654 2 push(@o,{$argv->{cursor_key}[$i] => SQL_SIMPLE_ORDER_DESC});
655 2 my @s;
656 2 ▶ for (my $j=0; $j < $i; $j++)
Branch: 1 branch
BranchTrueFalseTotal
if ($j < $i) 1 2 3
657 {
658 1 push(@s,$argv->{cursor_key}[$j] => $argv->{cursor}[$j]);
659 }
660 2 push(@s,$argv->{cursor_key}[$i] => [ $oper, $argv->{cursor}[$i]]);
661 2 ▶ push(@w,"or") if (@w);
Branch: 1 branch
BranchTrueFalseTotal
if @w 1 1 2
662 2 push(@w,\@s);
663 }
664 1 ▶ push(@{$argv->{where}},(@{$argv->{where}}) ? [\@w] : \@w);
Branch: 1 branch
BranchTrueFalseTotal
@{$argv->{'where'};} ? : 0 1 1
665 1 unshift(@order,@o);
666 }
667 }
668 ▶ elsif ($argv->{cursor_command} == SQL_SIMPLE_CURSOR_NEXT || $argv->{cursor_command} == SQL_SIMPLE_CURSOR_RELOAD)
Condition100%3/3
$argv->{"cursor_command"} == 3 or $argv->{"cursor_command"} == 5
l!l&&r!l&&!r
233
MC/DC100%2/2
$argv->{"cursor_command"} == 3 or $argv->{"cursor_command"} == 5
$argv->{"cursor_command"} == 3 $argv->{"cursor_command"} == 5
Truth table100%3/3
A or B
A= $argv->{"cursor_command"} == 3B= $argv->{"cursor_command"} == 5
ABresult
1X1
011
000
669 {
670 5 ▶ my $oper = ($argv->{cursor_command} == SQL_SIMPLE_CURSOR_RELOAD || $self->{work}{cursor_command_reload}) ? ">=" : ">";
Branch: 1 branch
BranchTrueFalseTotal
$argv->{'cursor_command'} == 5 || $self->{'work'}{'cursor_command_reload'} ? : 3 2 5
Condition66%2/3
$argv->{"cursor_command"} == 5 or $self->{"work"}{"cursor_command_reload"}
l!l&&r!l&&!r
302
MC/DC50%1/2
$argv->{"cursor_command"} == 5 or $self->{"work"}{"cursor_command_reload"}
$argv->{"cursor_command"} == 5 $self->{"work"}{"cursor_command_reload"}
Truth table66%2/3
A or B
A= $argv->{"cursor_command"} == 5B= $self->{"work"}{"cursor_command_reload"}
ABresult
1X1
011
000
671 5 ▶ if (ref($argv->{cursor_key}) ne "ARRAY")
Branch: 1 branch
BranchTrueFalseTotal
if (ref $argv->{'cursor_key'} ne 'ARRAY') { } 2 3 5
672 {
673 2 unshift(@order,{$argv->{cursor_key} => SQL_SIMPLE_ORDER_ASC});
674 2 unshift(@{$argv->{where}}, $argv->{cursor_key} => [ $oper, $argv->{cursor} ]);
675 }
676 else
677 {
678 3 my @w;
679 my @o;
680 3 ▶ for (my $i=0; $i < @{$argv->{cursor_key}}; $i++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @{$argv->{"cursor_key"};}) 6 3 9
681 {
682 6 push(@o,{$argv->{cursor_key}[$i] => SQL_SIMPLE_ORDER_ASC});
683 6 my @s;
684 6 ▶ for (my $j=0; $j < $i; $j++)
Branch: 1 branch
BranchTrueFalseTotal
if ($j < $i) 3 6 9
685 {
686 3 push(@s,$argv->{cursor_key}[$j] => $argv->{cursor}[$j]);
687 }
688 6 push(@s,$argv->{cursor_key}[$i] => [ $oper, $argv->{cursor}[$i]]);
689 6 ▶ push(@w,"or") if (@w);
Branch: 1 branch
BranchTrueFalseTotal
if @w 3 3 6
690 6 push(@w,\@s);
691 }
692 3 ▶ push(@{$argv->{where}},(@{$argv->{where}}) ? [\@w] : \@w);
Branch: 1 branch
BranchTrueFalseTotal
@{$argv->{'where'};} ? : 1 2 3
693 3 unshift(@order,@o);
694 }
695 }
696 elsif ($argv->{cursor_command} == SQL_SIMPLE_CURSOR_LAST)
697 {
698 3 my @o;
699 3 ▶ foreach my $key( (ref($argv->{cursor_key}) eq "ARRAY") ? @{$argv->{cursor_key}} : $argv->{cursor_key} )
Branch: 1 branch
BranchTrueFalseTotal
ref $argv->{'cursor_key'} eq 'ARRAY' ? : 1 2 3
700 {
701 4 push(@o,{$key => SQL_SIMPLE_ORDER_DESC});
702 }
703 3 unshift(@order,@o);
704 }
705 else
706 {
707 0 $self->_setMessage("select",SQL_SIMPLE_RC_SYNTAX,"015");
708 0 return SQL_SIMPLE_RC_SYNTAX;
709 }
710 17 $argv->{order_by} = \@order;
711  
712 ## validate cursor_order option
713 17 ▶ if (!defined($argv->{cursor_order})) { }
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $argv->{'cursor_order'}) { } 17 0 17
elsif ($argv->{'cursor_order'} eq 'ASC' or $argv->{'cursor_order'} eq 'DESC') { } 0 0 0
714 ▶ elsif ($argv->{cursor_order} eq SQL_SIMPLE_ORDER_ASC || $argv->{cursor_order} eq SQL_SIMPLE_ORDER_DESC)
Condition0%0/3
$argv->{"cursor_order"} eq "ASC" or $argv->{"cursor_order"} eq "DESC"
l!l&&r!l&&!r
000
MC/DC0%0/2
$argv->{"cursor_order"} eq "ASC" or $argv->{"cursor_order"} eq "DESC"
$argv->{"cursor_order"} eq "ASC" $argv->{"cursor_order"} eq "DESC"
Truth table0%0/3
A or B
A= $argv->{"cursor_order"} eq "ASC"B= $argv->{"cursor_order"} eq "DESC"
ABresult
1X1
011
000
715 {
716 0 $self->{work}{cursor_order} = ($argv->{cursor_order} eq $SQL_SIMPLE_CURSOR_ORDER->{$argv->{cursor_command}})+0;
717 }
718 else
719 {
720 0 $self->_setMessage("select",SQL_SIMPLE_RC_SYNTAX,"049");
721 0 return SQL_SIMPLE_RC_SYNTAX;
722 }
723  
724 ## validate limits
725 17 ▶ if (!defined($argv->{limit}) || $argv->{limit} eq "")
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $argv->{"limit"} or $argv->{"limit"} eq "") 0 17 17
Condition33%1/3
not defined $argv->{"limit"} or $argv->{"limit"} eq ""
l!l&&r!l&&!r
0017
MC/DC0%0/2
not defined $argv->{"limit"} or $argv->{"limit"} eq ""
not defined $argv->{"limit"} $argv->{"limit"} eq ""
Truth table33%1/3
not(A) or B
A= not defined $argv->{"limit"}B= $argv->{"limit"} eq ""
ABresult
1X1
011
000
726 {
727 0 $self->_setMessage("select",SQL_SIMPLE_RC_SYNTAX,"043");
728 0 return SQL_SIMPLE_RC_SYNTAX;
729 }
730  
731 ## define notfound if not exists
732 17 ▶ $argv->{notfound} = 1 if (!defined($argv->{notfound}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $argv->{"notfound"} 17 0 17
733  
734 ## execute and save cursor info
735 17 ▶ return $self->{init}{cursor}{rc} if ($self->{init}{cursor}{rc} = $self->_Select(%{$argv}));
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"init"}{"cursor"}{"rc"} = $self->_Select(%{$argv;}) 17 0 17
736  
737 0 $self->{init}{cursor}{lines} = $self->getRows();
738 0 ▶ if (!$self->{init}{cursor}{lines})
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"init"}{"cursor"}{"lines"}) 0 0 0
739 {
740 0 $self->{init}{cursor}{first} = [];
741 0 $self->{init}{cursor}{last} = [];
742 }
743  
744 ## return cursor info
745 0 ▶ if (!defined($argv->{cursor_info})) {}
Branch: 4 branches
BranchTrueFalseTotal
if (not defined $argv->{'cursor_info'}) { } 0 0 0
elsif (ref $argv->{'cursor_info'} eq 'HASH') { } 0 0 0
elsif (ref $argv->{'cursor_info'} eq 'ARRAY') { } 0 0 0
elsif (ref $argv->{'cursor_info'} eq 'SCALAR') { } 0 0 0
746 elsif (ref($argv->{cursor_info}) eq "HASH")
747 {
748 0 $argv->{cursor_info}->{rc} = $self->{init}{cursor}{rc};
749 0 $argv->{cursor_info}->{lines} = $self->{init}{cursor}{lines};
750  
751 0 ▶ if ($argv->{cursor_command} == SQL_SIMPLE_CURSOR_BACK || $argv->{cursor_command} == SQL_SIMPLE_CURSOR_LAST)
Branch: 1 branch
BranchTrueFalseTotal
if ($argv->{'cursor_command'} == 2 or $argv->{'cursor_command'} == 4) { } 0 0 0
Condition0%0/3
$argv->{"cursor_command"} == 2 or $argv->{"cursor_command"} == 4
l!l&&r!l&&!r
000
MC/DC0%0/2
$argv->{"cursor_command"} == 2 or $argv->{"cursor_command"} == 4
$argv->{"cursor_command"} == 2 $argv->{"cursor_command"} == 4
Truth table0%0/3
A or B
A= $argv->{"cursor_command"} == 2B= $argv->{"cursor_command"} == 4
ABresult
1X1
011
000
752 {
753 0 ▶ $argv->{cursor_info}{first} = (ref($argv->{cursor_key}) eq "ARRAY") ? $self->{init}{cursor}{last} : $self->{init}{cursor}{last}[0];
Branch: 1 branch
BranchTrueFalseTotal
ref $argv->{'cursor_key'} eq 'ARRAY' ? : 0 0 0
754 0 ▶ $argv->{cursor_info}{last} = (ref($argv->{cursor_key}) eq "ARRAY") ? $self->{init}{cursor}{first} : $self->{init}{cursor}{first}[0];
Branch: 1 branch
BranchTrueFalseTotal
ref $argv->{'cursor_key'} eq 'ARRAY' ? : 0 0 0
755 }
756 else
757 {
758 0 ▶ $argv->{cursor_info}{first} = (ref($argv->{cursor_key}) eq "ARRAY") ? $self->{init}{cursor}{first} :$self->{init}{cursor}{first}[0];
Branch: 1 branch
BranchTrueFalseTotal
ref $argv->{'cursor_key'} eq 'ARRAY' ? : 0 0 0
759 0 ▶ $argv->{cursor_info}{last} = (ref($argv->{cursor_key}) eq "ARRAY") ? $self->{init}{cursor}{last} : $self->{init}{cursor}{last}[0];
Branch: 1 branch
BranchTrueFalseTotal
ref $argv->{'cursor_key'} eq 'ARRAY' ? : 0 0 0
760 }
761 0 $argv->{cursor_info}{previouscmd} = $argv->{cursor_command};
762 }
763 elsif (ref($argv->{cursor_info}) eq "ARRAY")
764 {
765 0 $argv->{cursor_info} = [];
766 0 push(@{$argv->{cursor_info}},$self->{init}{cursor}{rc},$self->{init}{cursor}{lines});
767 0 ▶ if ($argv->{cursor_command} == SQL_SIMPLE_CURSOR_BACK || $argv->{cursor_command} == SQL_SIMPLE_CURSOR_LAST)
Branch: 1 branch
BranchTrueFalseTotal
if ($argv->{'cursor_command'} == 2 or $argv->{'cursor_command'} == 4) { } 0 0 0
Condition0%0/3
$argv->{"cursor_command"} == 2 or $argv->{"cursor_command"} == 4
l!l&&r!l&&!r
000
MC/DC0%0/2
$argv->{"cursor_command"} == 2 or $argv->{"cursor_command"} == 4
$argv->{"cursor_command"} == 2 $argv->{"cursor_command"} == 4
Truth table0%0/3
A or B
A= $argv->{"cursor_command"} == 2B= $argv->{"cursor_command"} == 4
ABresult
1X1
011
000
768 {
769 0 ▶ push(@{$argv->{cursor_info}},(ref($argv->{cursor_key}) eq "ARRAY") ? $self->{init}{cursor}{last} : $self->{init}{cursor}{last}[0]);
Branch: 1 branch
BranchTrueFalseTotal
ref $argv->{'cursor_key'} eq 'ARRAY' ? : 0 0 0
770 0 ▶ push(@{$argv->{cursor_info}},(ref($argv->{cursor_key}) eq "ARRAY") ? $self->{init}{cursor}{first} : $self->{init}{cursor}{first}[0]);
Branch: 1 branch
BranchTrueFalseTotal
ref $argv->{'cursor_key'} eq 'ARRAY' ? : 0 0 0
771 }
772 else
773 {
774 0 ▶ push(@{$argv->{cursor_info}},(ref($argv->{cursor_key}) eq "ARRAY") ? $self->{init}{cursor}{first} :$self->{init}{cursor}{first}[0]);
Branch: 1 branch
BranchTrueFalseTotal
ref $argv->{'cursor_key'} eq 'ARRAY' ? : 0 0 0
775 0 ▶ push(@{$argv->{cursor_info}},(ref($argv->{cursor_key}) eq "ARRAY") ? $self->{init}{cursor}{last} : $self->{init}{cursor}{last}[0]);
Branch: 1 branch
BranchTrueFalseTotal
ref $argv->{'cursor_key'} eq 'ARRAY' ? : 0 0 0
776 }
777 0 push(@{$argv->{cursor_info}},$argv->{cursor_command});
778 }
779 elsif (ref($argv->{cursor_info}) eq "SCALAR")
780 {
781 0 my @a;
782 0 ▶ if ($argv->{cursor_command} == SQL_SIMPLE_CURSOR_BACK || $argv->{cursor_command} == SQL_SIMPLE_CURSOR_LAST)
Branch: 1 branch
BranchTrueFalseTotal
if ($argv->{'cursor_command'} == 2 or $argv->{'cursor_command'} == 4) { } 0 0 0
Condition0%0/3
$argv->{"cursor_command"} == 2 or $argv->{"cursor_command"} == 4
l!l&&r!l&&!r
000
MC/DC0%0/2
$argv->{"cursor_command"} == 2 or $argv->{"cursor_command"} == 4
$argv->{"cursor_command"} == 2 $argv->{"cursor_command"} == 4
Truth table0%0/3
A or B
A= $argv->{"cursor_command"} == 2B= $argv->{"cursor_command"} == 4
ABresult
1X1
011
000
783 {
784 push(@a,
785 0 ▶ (ref($argv->{cursor_key}) eq "ARRAY") ? join(" ",@{$self->{init}{cursor}{last}}) : $self->{init}{cursor}{last}[0],
Branch: 1 branch
BranchTrueFalseTotal
ref $argv->{'cursor_key'} eq 'ARRAY' ? : 0 0 0
786 0 ▶ (ref($argv->{cursor_key}) eq "ARRAY") ? join(" ",@{$self->{init}{cursor}{first}}) : $self->{init}{cursor}{first}[0],
Branch: 1 branch
BranchTrueFalseTotal
ref $argv->{'cursor_key'} eq 'ARRAY' ? : 0 0 0
787 );
788 }
789 else
790 {
791 push(@a,
792 0 ▶ (ref($argv->{cursor_key}) eq "ARRAY") ? join(" ",@{$self->{init}{cursor}{first}}) : $self->{init}{cursor}{first}[0],
Branch: 1 branch
BranchTrueFalseTotal
ref $argv->{'cursor_key'} eq 'ARRAY' ? : 0 0 0
793 0 ▶ (ref($argv->{cursor_key}) eq "ARRAY") ? join(" ",@{$self->{init}{cursor}{last}}) : $self->{init}{cursor}{last}[0],
Branch: 1 branch
BranchTrueFalseTotal
ref $argv->{'cursor_key'} eq 'ARRAY' ? : 0 0 0
794 );
795 }
796 0 ${$argv->{cursor_info}} = join(" ",$self->{init}{cursor}{rc},$self->{init}{cursor}{lines},@a,$argv->{cursor_command});
797 }
798 0 return SQL_SIMPLE_RC_OK;
799 }
800  
801 ################################################################################
802 ## action: select command
803 ## return:
804 ## rc<0 syntax error
805 ## rc=0 successful
806 ## rc=1 sql error
807 ## rc=2 no selected found (no match where found)
808  
809 sub Select()
810 195 ▶{
Subroutine Select: called CC=14 SCAR=28.8
Pod documented
811 195 my $self = shift;
812 195 my $argv = {@_};
813  
814 195 ▶ $argv->{make_only} = 1 if ($argv->{subquery});
Branch: 1 branch
BranchTrueFalseTotal
if $argv->{"subquery"} 8 187 195
815  
816 195 $self->_resetSession();
817 195 $self->_Dumper("select",$argv);
818 195 ▶ $self->Open() if (!defined($self->{init}{dbh}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"init"}{"dbh"} 0 195 195
819  
820 ## define the command in load
821 195 $self->{work}{command} = SQL_SIMPLE_ALIAS_SELECT;
822  
823 195 ▶ if ($self->{init}{plugin_fh} && $self->{init}{plugin_fh}->can('Select') && $self->{init}{plugin_fh}->Select($argv))
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"init"}{"plugin_fh"} and $self->{"init"}{"plugin_fh"}->can("Select") and $self->{"init"}{"plugin_fh"}->Select($argv)) 0 195 195
Condition33%2/6
$self->{"init"}{"plugin_fh"} and $self->{"init"}{"plugin_fh"}->can("Select") and $self->{"init"}{"plugin_fh"}->Select($argv)
!ll&&!rl&&r
19500
$self->{"init"}{"plugin_fh"} and $self->{"init"}{"plugin_fh"}->can("Select")
!ll&&!rl&&r
01950
MC/DC0%0/3
$self->{"init"}{"plugin_fh"} and $self->{"init"}{"plugin_fh"}->can("Select") and $self->{"init"}{"plugin_fh"}->Select($argv)
$self->{"init"}{"plugin_fh"} $self->{"init"}{"plugin_fh"}->can("Select") $self->{"init"}{"plugin_fh"}->Select($argv)
Truth table25%1/4
A and B and C
A= $self->{"init"}{"plugin_fh"}B= $self->{"init"}{"plugin_fh"}->can("Select")C= $self->{"init"}{"plugin_fh"}->Select($argv)
ABCresult
0XX0
10X0
1100
1111
824 {
825 0 $self->_setMessage("select",SQL_SIMPLE_RC_SYNTAX,"037",$self->{argv}{interface},$self->{argv}{driver},$self->getMessage());
826 0 return SQL_SIMPLE_RC_SYNTAX;
827 }
828  
829 195 ▶ my $saved_message_log = $self->_setLogMessage($argv->{message_log}) if (defined($argv->{message_log}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $argv->{"message_log"} 0 195 195
830 195 ▶ my $saved_quote = $self->_setQuote($argv->{quote}) if (defined($argv->{quote}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $argv->{"quote"} 0 195 195
831 195 ▶ my $saved_sql_save = $self->_setSqlSave($argv->{sql_save}) if (defined($argv->{sql_save}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $argv->{"sql_save"} 1 194 195
832  
833 195 my $rc = $self->_Select(%{$argv});
834  
835 195 ▶ $self->setMessgeLog($saved_message_log) if (defined($argv->{message_log}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $argv->{"message_log"} 0 195 195
836 195 ▶ $self->_setQuote($saved_quote) if (defined($argv->{quote}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $argv->{"quote"} 0 195 195
837 195 ▶ $self->_setSqlSave($saved_sql_save) if (defined($argv->{sql_save}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $argv->{"sql_save"} 1 194 195
838  
839 195 ▶ return "\\(". ( ($self->getRC()==0) ? $self->getLastSQL() : "**".$self->getMessage()."**" ) .")" if ($argv->{subquery});
Branch: 2 branches
BranchTrueFalseTotal
if $argv->{"subquery"} 8 187 195
$self->getRC == 0 ? : 8 0 8
840 187 return $rc;
841 }
842  
843 sub _Select()
844 212 ▶{
Subroutine _Select: called CC=90 SCAR=52.9
845 212 my $self = shift;
846 212 my $argv = {@_};
847  
848 212 ▶ return SQL_SIMPLE_RC_SYNTAX if ($self->_checkTablesEntries("select",$argv) != SQL_SIMPLE_RC_OK);
Branch: 1 branch
BranchTrueFalseTotal
if $self->_checkTablesEntries("select", $argv) != 0 0 212 212
849  
850 ## testing buffer options
851 212 ▶ if (!defined($argv->{buffer})){}
Branch: 7 branches
BranchTrueFalseTotal
if (not defined $argv->{'buffer'}) { } 212 0 212
elsif (ref $argv->{'buffer'} eq 'ARRAY') { } 0 0 0
elsif (defined $argv->{'buffer_reverse'}) { } 0 0 0
elsif (ref $argv->{'buffer'} ne 'HASH') { } 0 0 0
elsif (not defined $argv->{'buffer_hashkey'}) { } 0 0 0
elsif (not defined $argv->{'buffer_hashindex'}) { } 0 0 0
elsif (ref $argv->{'buffer_hashindex'} ne 'ARRAY') { } 0 0 0
852 ## buffer array options
853 elsif (ref($argv->{buffer}) eq "ARRAY"){}
854 elsif (defined($argv->{buffer_reverse}))
855 {
856 0 $self->_setMessage("select",SQL_SIMPLE_RC_SYNTAX,"050");
857 0 return SQL_SIMPLE_RC_SYNTAX;
858 }
859 ## others buffers type
860 elsif (ref($argv->{buffer}) ne "HASH"){}
861 ## buffer hash options
862 elsif (!defined($argv->{buffer_hashkey})){}
863 elsif (!defined($argv->{buffer_hashindex})){}
864 elsif (ref($argv->{buffer_hashindex}) ne "ARRAY")
865 {
866 0 $self->_setMessage("select",SQL_SIMPLE_RC_SYNTAX,"048");
867 0 return SQL_SIMPLE_RC_SYNTAX;
868 }
869  
870 ## testing fields
871 212 my @fields_work;
872 my %fields_distinct;
873 212 my %fields_aliases;
874  
875 212 ▶ if (defined($argv->{fields}))
Branch: 2 branches
BranchTrueFalseTotal
if (defined $argv->{'fields'}) { } 199 13 212
elsif (defined $self->{'argv'}{'tables'}) { } 6 7 13
876 {
877 199 my $fields_argv;
878 199 ▶ if (ref($argv->{fields}) eq "ARRAY") { $fields_argv = $argv->{fields}; }
Branch: 2 branches
BranchTrueFalseTotal
if (ref $argv->{'fields'} eq 'ARRAY') { } 188 11 199
elsif (ref $argv->{'fields'} eq '') { } 11 0 11
879 11 elsif (ref($argv->{fields}) eq "") { $fields_argv = [ $argv->{fields} ]; }
880 else
881 {
882 0 $self->_setMessage("select",SQL_SIMPLE_RC_SYNTAX,"007");
883 0 return SQL_SIMPLE_RC_SYNTAX;
884 }
885 199 ▶ if (@{$fields_argv} != 1 || $fields_argv->[0] ne "*")
Branch: 1 branch
BranchTrueFalseTotal
if (@{$fields_argv;} != 1 or $fields_argv->[0] ne "*") 196 3 199
Condition100%3/3
@{$fields_argv;} != 1 or $fields_argv->[0] ne "*"
l!l&&r!l&&!r
571393
MC/DC100%2/2
@{$fields_argv;} != 1 or $fields_argv->[0] ne "*"
@{$fields_argv;} != 1 $fields_argv->[0] ne "*"
Truth table100%3/3
A or B
A= @{$fields_argv;} != 1B= $fields_argv->[0] ne "*"
ABresult
1X1
011
000
886 {
887 196 ▶ for (my $ix=0; $ix < @{$fields_argv}; $ix++)
Branch: 1 branch
BranchTrueFalseTotal
if ($ix < @{$fields_argv;}) 279 179 458
888 {
889 279 my $field = $fields_argv->[$ix];
890 279 my $distinct;
891 my $alias;
892 279 ▶ if (ref($field) eq "HASH")
Branch: 1 branch
BranchTrueFalseTotal
if (ref $field eq "HASH") 80 199 279
893 {
894 80 $alias = $field;
895 80 ($fields_aliases{$alias}{f},$fields_aliases{$alias}{a}) = %{$field};
896 80 $field = $fields_aliases{$alias}{f};
897 80 $self->{work}{field_alias}{$fields_aliases{$alias}{a}} = $fields_aliases{$alias}{f};
898 80 $self->{work}{field_realname}{$fields_aliases{$alias}{f}} = $fields_aliases{$alias}{a};
899 80 ▶ $self->{work}{field_cols}{$1}{$fields_aliases{$alias}{a}} = $2 if ($fields_aliases{$alias}{f} =~ /^(.*?)\.(.*?)$/);
Branch: 1 branch
BranchTrueFalseTotal
if $fields_aliases{$alias}{"f"} =~ /^(.*?)\.(.*?)$/ 51 29 80
900 }
901 279 ▶ if ($field =~ /^distinct$/i)
Branch: 2 branches
BranchTrueFalseTotal
if ($field =~ /^distinct$/i) { } 3 276 279
elsif ($field =~ /^distinct\s+(.*)/i) { } 0 276 276
902 {
903 3 $field = $fields_argv->[++$ix];
904 3 $distinct = 1;
905 }
906 elsif ($field =~ /^distinct\s+(.*)/i)
907 {
908 0 $field = $1;
909 0 $distinct = 1;
910 }
911 279 ▶ if (!($field =~ /^\\/))
Branch: 1 branch
BranchTrueFalseTotal
unless ($field =~ /^\\/) 276 3 279
912 {
913 276 ▶ my $value = ($field =~ /^(.*?)\((.*?)\,(.*)\)/) ? $2 : ($field =~ /^(.*?)\((.*)\)/) ? $2 : $field;
Branch: 2 branches
BranchTrueFalseTotal
$field =~ /^(.*?)\((.*?)\,(.*)\)/ ? : 1 275 276
$field =~ /^(.*?)\((.*)\)/ ? : 18 257 275
914 276 ▶ if ($value =~ /^(.*)\.(.*)$/)
Branch: 1 branch
BranchTrueFalseTotal
if ($value =~ /^(.*)\.(.*)$/) 129 147 276
915 {
916 129 ▶ if (!grep(/^$1$/,@{$self->{work}{tables_valids}}))
Branch: 1 branch
BranchTrueFalseTotal
unless (grep /^$1$/, @{$$self{"work"}{"tables_valids"};}) 17 112 129
917 {
918 17 $self->_setMessage("select",SQL_SIMPLE_RC_SYNTAX,"010",$field);
919 17 return SQL_SIMPLE_RC_SYNTAX;
920 }
921 }
922 }
923 262 ▶ push(@fields_work,$alias || $field);
Condition66%2/3
$alias || $field
l!l&&r!l&&!r
721900
MC/DC0%0/2
$alias || $field
$alias $field
Truth table66%2/3
A || B
A= $aliasB= $field
ABresult
1X1
011
000
924 262 ▶ $fields_distinct{$field} = 1 if ($distinct);
Branch: 1 branch
BranchTrueFalseTotal
if $distinct 3 259 262
925 }
926 }
927 }
928 elsif (defined($self->{argv}{tables}))
929 {
930 6 ▶ if (@{$self->{work}{tables_inuse}} > 1)
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->{'work'}{'tables_inuse'};} > 1) { } 1 5 6
931 {
932 1 my $any=0;
933 1 foreach my $table(@{$self->{work}{tables_inuse}})
934 {
935 2 my $temp;
936 2 ▶ if (!defined($self->{argv}{tables}{$table}) || !defined($self->{argv}{tables}{$table}{cols}))
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $self->{'argv'}{'tables'}{$table} && defined $self->{'argv'}{'tables'}{$table}{'cols'}) { } 2 0 2
Condition33%1/3
defined $self->{'argv'}{'tables'}{$table} && defined $self->{'argv'}{'tables'}{$table}{'cols'}
!ll&&!rl&&r
200
MC/DC0%0/2
defined $self->{'argv'}{'tables'}{$table} && defined $self->{'argv'}{'tables'}{$table}{'cols'}
defined $self->{'argv'}{'tables'}{$table} defined $self->{'argv'}{'tables'}{$table}{'cols'}
Truth table33%1/3
A && B
A= defined $self->{'argv'}{'tables'}{$table}B= defined $self->{'argv'}{'tables'}{$table}{'cols'}
ABresult
0X0
100
111
937 {
938 2 ▶ if (!defined($self->{init}{table_realname}{$table}))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"init"}{"table_realname"}{$table}) 2 0 2
939 {
940 2 $any=1;
941 2 next;
942 }
943 0 $temp = $self->{init}{table_realname}{$table};
944 }
945 else
946 {
947 0 $temp = $table;
948 }
949 0 foreach my $field(sort(keys(%{$self->{argv}{tables}{$temp}{cols}})))
950 {
951 0 push(@fields_work,$table.".".$field);
952 }
953 }
954 1 ▶ if ($any && @fields_work)
Branch: 1 branch
BranchTrueFalseTotal
if ($any and @fields_work) 0 1 1
Condition33%1/3
$any and @fields_work
!ll&&!rl&&r
010
MC/DC0%0/2
$any and @fields_work
$any @fields_work
Truth table33%1/3
A and B
A= $anyB= @fields_work
ABresult
0X0
100
111
955 {
956 0 $self->_setMessage("select",SQL_SIMPLE_RC_SYNTAX,"010","*");
957 0 return SQL_SIMPLE_RC_SYNTAX;
958 }
959 }
960 else
961 {
962 5 ▶ my $temp = (!defined($self->{init}{table_realname}{$self->{work}{tables_inuse}[0]})) ? $self->{work}{tables_inuse}[0] : $self->{init}{table_realname}{$self->{work}{tables_inuse}[0]};
Branch: 1 branch
BranchTrueFalseTotal
!defined($self->{'init'}{'table_realname'}{$self->{'work'}{'tables_inuse'}[0]}) ? : 3 2 5
963 5 ▶ if (defined($self->{argv}{tables}{$temp}) && defined($self->{argv}{tables}{$temp}{cols}))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"argv"}{"tables"}{$temp} and defined $self->{"argv"}{"tables"}{$temp}{"cols"}) 2 3 5
Condition66%2/3
defined $self->{"argv"}{"tables"}{$temp} and defined $self->{"argv"}{"tables"}{$temp}{"cols"}
!ll&&!rl&&r
302
MC/DC50%1/2
defined $self->{"argv"}{"tables"}{$temp} and defined $self->{"argv"}{"tables"}{$temp}{"cols"}
defined $self->{"argv"}{"tables"}{$temp} defined $self->{"argv"}{"tables"}{$temp}{"cols"}
Truth table66%2/3
A and B
A= defined $self->{"argv"}{"tables"}{$temp}B= defined $self->{"argv"}{"tables"}{$temp}{"cols"}
ABresult
0X0
100
111
964 {
965 2 push(@fields_work,sort(keys(%{$self->{argv}{tables}{$temp}{cols}})));
966 }
967 }
968 }
969 ## testing groupby
970 195 my @group_work;
971 195 ▶ if (defined($argv->{group_by}))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $argv->{"group_by"}) 15 180 195
972 {
973 0 ▶ if (ref($argv->{group_by}) eq "") { @group_work = ($argv->{group_by}); }
Branch: 2 branches
BranchTrueFalseTotal
if (ref $argv->{'group_by'} eq '') { } 0 15 15
elsif (ref $argv->{'group_by'} eq 'ARRAY') { } 15 0 15
974 15 elsif (ref($argv->{group_by}) eq "ARRAY") { push(@group_work,@{$argv->{group_by}}); }
975 else
976 {
977 0 $self->_setMessage("select",SQL_SIMPLE_RC_SYNTAX,"008");
978 0 return SQL_SIMPLE_RC_SYNTAX;
979 }
980 }
981
982 ## testing orderby
983 195 my @order_work;
984 195 ▶ if (defined($argv->{order_by}))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $argv->{"order_by"}) 42 153 195
985 {
986 42 ▶ if (ref($argv->{order_by}) eq "") { @order_work = ($argv->{order_by}); }
Branch: 3 branches
BranchTrueFalseTotal
if (ref $argv->{'order_by'} eq '') { } 2 40 42
elsif (ref $argv->{'order_by'} eq 'HASH') { } 2 38 40
elsif (ref $argv->{'order_by'} eq 'ARRAY') { } 38 0 38
987 2 elsif (ref($argv->{order_by}) eq "HASH") { @order_work = ($argv->{order_by}); }
988 elsif (ref($argv->{order_by}) eq "ARRAY")
989 {
990 38 push(@order_work,@{$argv->{order_by}});
991 }
992 else
993 {
994 0 $self->_setMessage("select",SQL_SIMPLE_RC_SYNTAX,"009");
995 0 return SQL_SIMPLE_RC_SYNTAX;
996 }
997 }
998
999 ## making fields
1000 195 ▶ my $middle = ($self->{init}{alias_with_as}) ? " AS " : " ";
Branch: 1 branch
BranchTrueFalseTotal
$self->{'init'}{'alias_with_as'} ? : 0 195 195
1001 195 my @fields;
1002 195 my $table = $self->{work}{tables_inuse}[0];
1003 195 ▶ if (@fields_work)
Branch: 1 branch
BranchTrueFalseTotal
if (@fields_work) { } 181 14 195
1004 {
1005 181 foreach my $field(@fields_work)
1006 {
1007 268 my $alias;
1008 268 ▶ my $distinct = ($fields_distinct{$field}) ? "DISTINCT " : "";
Branch: 1 branch
BranchTrueFalseTotal
$fields_distinct{$field} ? : 3 265 268
1009 ## field is hash?
1010 268 ▶ if (defined($fields_aliases{$field}))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $fields_aliases{$field}) 72 196 268
1011 {
1012 72 $alias = $fields_aliases{$field}{a};
1013 72 $field = $fields_aliases{$field}{f};
1014 }
1015 ## is escape?
1016 268 ▶ if ($field =~ /^\\(.*)/)
Branch: 1 branch
BranchTrueFalseTotal
if ($field =~ /^\\(.*)/) 3 265 268
1017 {
1018 3 ▶ ($alias) ?
Branch: 1 branch
BranchTrueFalseTotal
$alias ? : 1 2 3
1019 push(@fields,$distinct.$1.$middle.$alias) :
1020 push(@fields,$distinct.$1);
1021 3 next;
1022 }
1023 ## have function?
1024 265 my $field_a;
1025 my $field_b;
1026 265 ▶ if ($field =~ /^(.*?)\((.*?)\,(.*)\)/)
Branch: 2 branches
BranchTrueFalseTotal
if ($field =~ /^(.*?)\((.*?)\,(.*)\)/) { } 1 264 265
elsif ($field =~ /^(.*?)\((.*)\)/) { } 18 246 264
1027 {
1028 1 $field_a = $1."(";
1029 1 $field = $2;
1030 1 $field_b = ",".$3.")";
1031 }
1032 elsif ($field =~ /^(.*?)\((.*)\)/)
1033 {
1034 18 $field_a = $1."(";
1035 18 $field = $2;
1036 18 $field_b = ")";
1037 }
1038 else
1039 {
1040 246 $field_a = "";
1041 246 $field_b = "";
1042 }
1043 ## translate field
1044 265 ▶ if ($field =~ /^(.*)\.(.*)$/)
Branch: 1 branch
BranchTrueFalseTotal
if ($field =~ /^(.*)\.(.*)$/) { } 112 153 265
1045 {
1046 112 my $realn = $self->_getAliasCols(1,$field,SQL_SIMPLE_ALIAS_SELECT);
1047 112 ▶ my $table = (!defined($self->{init}{table_realname}{$1})) ? $1 : $self->{init}{table_realname}{$1};
Branch: 1 branch
BranchTrueFalseTotal
!defined($self->{'init'}{'table_realname'}{$1}) ? : 102 10 112
1048 112 my $field = $2;
1049 112 ▶ if ($realn =~ /^.*\..*$/)
Branch: 1 branch
BranchTrueFalseTotal
if ($realn =~ /^.*\..*$/) { } 88 24 112
1050 {
1051 88 ▶ ($alias) ?
Branch: 2 branches
BranchTrueFalseTotal
$alias ? : 28 60 88
$table . '.' . $field ne $realn ? : 26 34 60
1052 push(@fields,$distinct.$field_a.$realn.$field_b.$middle.$alias) :
1053 ($table.".".$field ne $realn) ?
1054 push(@fields,$distinct.$field_a.$realn.$field_b.$middle.$field) :
1055 push(@fields,$distinct.$field_a.$realn.$field_b);
1056 }
1057 else
1058 {
1059 24 ▶ ($alias) ?
Branch: 2 branches
BranchTrueFalseTotal
$alias ? : 15 9 24
$field ne $realn ? : 4 5 9
1060 push(@fields,$distinct.$field_a.$table.".".$realn.$field_b.$middle.$alias) :
1061 ($field ne $realn) ?
1062 push(@fields,$distinct.$field_a.$table.".".$realn.$field_b.$middle.$field) :
1063 push(@fields,$distinct.$field_a.$table.".".$realn.$field_b);
1064 }
1065 }
1066 else
1067 {
1068 153 ▶ if (@{$self->{work}{tables_inuse}} == 1)
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->{'work'}{'tables_inuse'};} == 1) { } 127 26 153
1069 {
1070 127 my $realn = $self->_getAliasCols(2,$field,SQL_SIMPLE_ALIAS_SELECT);
1071 127 ▶ ($alias) ?
Branch: 2 branches
BranchTrueFalseTotal
$alias ? : 18 109 127
$field ne $realn ? : 58 51 109
1072 push(@fields,$distinct.$field_a.$realn.$field_b.$middle.$alias) :
1073 ($field ne $realn) ?
1074 push(@fields,$distinct.$field_a.$realn.$field_b.$middle.$field) :
1075 push(@fields,$distinct.$field_a.$field.$field_b);
1076 }
1077 else
1078 {
1079 26 ▶ if ($alias)
Branch: 1 branch
BranchTrueFalseTotal
if ($alias) { } 10 16 26
1080 {
1081 10 push(@fields,$distinct.$field_a.$field.$field_b.$middle.$alias);
1082 }
1083 else
1084 {
1085 16 foreach my $table(@{$self->{work}{tables_inuse}})
1086 {
1087 32 my $realn = $self->_getAliasCols(3,$field,SQL_SIMPLE_ALIAS_SELECT);
1088 32 ▶ if ($realn ne $field)
Branch: 1 branch
BranchTrueFalseTotal
if ($realn ne $field) 0 32 32
1089 {
1090 0 $alias = $field;
1091 0 $field = $realn;
1092 0 last;
1093 }
1094 }
1095 16 ▶ ($alias) ?
Branch: 1 branch
BranchTrueFalseTotal
$alias ? : 0 16 16
1096 push(@fields,$distinct.$field_a.$field.$field_b.$middle.$alias):
1097 push(@fields,$distinct.$field_a.$field.$field_b);
1098 }
1099 }
1100 }
1101 }
1102 }
1103 else
1104 {
1105 14 push(@fields,"*");
1106 }
1107  
1108 ## make where
1109 195 my $where;
1110 195 ▶ return SQL_SIMPLE_RC_SYNTAX if ($self->_getWhere("select",$argv->{where},\$where));
Branch: 1 branch
BranchTrueFalseTotal
if $self->_getWhere("select", $argv->{"where"}, \$where) 0 195 195
1111  
1112 ## make group_by
1113 195 ▶ for (my $i=0; $i < @group_work; $i++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @group_work) 22 195 217
1114 {
1115 22 ▶ $group_work[$i] = ($group_work[$i] =~ /^(.*)\.(.*)$/) ?
Branch: 1 branch
BranchTrueFalseTotal
$group_work[$i] =~ /^(.*)\.(.*)$/ ? : 13 9 22
1116 $self->_getAliasCols(4,$group_work[$i],SQL_SIMPLE_ALIAS_GROUPBY+SQL_SIMPLE_ALIAS_FQDN) :
1117 $self->_getAliasCols(5,$group_work[$i],SQL_SIMPLE_ALIAS_GROUPBY);
1118 }
1119  
1120 ## make having
1121 195 my $having;
1122 195 ▶ return SQL_SIMPLE_RC_SYNTAX if ($self->_getWhere("select",$argv->{having},\$having));
Branch: 1 branch
BranchTrueFalseTotal
if $self->_getWhere("select", $argv->{"having"}, \$having) 0 195 195
1123  
1124 ## make order
1125 195 my @order;
1126 195 ▶ while (@order_work)
Branch: 1 branch
BranchTrueFalseTotal
if (@order_work) 56 195 251
1127 {
1128 56 my $field = shift(@order_work);
1129 56 ▶ if (ref($field) eq "HASH")
Branch: 1 branch
BranchTrueFalseTotal
if (ref $field eq 'HASH') { } 48 8 56
1130 {
1131 48 foreach my $_id(sort(keys(%{$field})))
1132 {
1133 48 $self->_SelectOrderBy(\@order,$table,$_id,$field->{$_id});
1134 }
1135 }
1136 8 else { $self->_SelectOrderBy(\@order,$table,$field); }
1137 }
1138  
1139 ## make tables
1140 195 my @tables;
1141 195 foreach my $table(@{$self->{work}{tables_inuse}})
1142 {
1143 261 push(@tables,$self->_getAliasTable($table,$argv));
1144 }
1145  
1146 ## build sql command
1147 195 my $sql = "SELECT ".join(", ",@fields)." FROM ".join(", ",@tables);
1148 195 ▶ $sql .= " WHERE ".$where if ($where);
Branch: 1 branch
BranchTrueFalseTotal
if $where 70 125 195
1149 195 ▶ $sql .= " GROUP BY ".join(", ",@group_work) if (@group_work);
Branch: 1 branch
BranchTrueFalseTotal
if @group_work 15 180 195
1150 195 ▶ $sql .= " HAVING ".$having if ($having);
Branch: 1 branch
BranchTrueFalseTotal
if $having 4 191 195
1151 195 ▶ $sql .= " ORDER BY ".join(", ",@order) if (@order);
Branch: 1 branch
BranchTrueFalseTotal
if @order 42 153 195
1152 195 ▶ $sql .= " LIMIT ".$argv->{limit} if (defined($argv->{limit}) && $argv->{limit} > 0);
Branch: 1 branch
BranchTrueFalseTotal
if defined $argv->{"limit"} and $argv->{"limit"} > 0 16 179 195
Condition100%3/3
defined $argv->{"limit"} and $argv->{"limit"} > 0
!ll&&!rl&&r
178116
MC/DC100%2/2
defined $argv->{"limit"} and $argv->{"limit"} > 0
defined $argv->{"limit"} $argv->{"limit"} > 0
Truth table100%3/3
A and B
A= defined $argv->{"limit"}B= $argv->{"limit"} > 0
ABresult
0X0
100
111
1153  
1154 ## cross check cursor_key vs buffer_hashkey
1155 195 $self->{work}{cursor_key_vs_hashkey} = 0;
1156 195 ▶ if (defined($argv->{buffer_hashkey}))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $argv->{"buffer_hashkey"}) 0 195 195
1157 {
1158 0 $self->{work}{buffer_hashkey} = [];
1159 0 ▶ foreach my $key( (ref($argv->{buffer_hashkey}) eq "ARRAY") ? @{$argv->{buffer_hashkey}} : ($argv->{buffer_hashkey}) )
Branch: 1 branch
BranchTrueFalseTotal
ref $argv->{'buffer_hashkey'} eq 'ARRAY' ? : 0 0 0
1160 {
1161 0 push(@{$self->{work}{buffer_hashkey}},$key);
1162 0 ▶ $self->{work}{cursor_key_vs_hashkey}++ if (defined($self->{work}{cursor_key}) && grep(/^$key$/,@{$self->{work}{cursor_key}}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"work"}{"cursor_key"} and grep /^$key$/, @{$$self{"work"}{"cursor_key"};} 0 0 0
Condition0%0/3
defined $self->{"work"}{"cursor_key"} and grep /^$key$/, @{$$self{"work"}{"cursor_key"};}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->{"work"}{"cursor_key"} and grep /^$key$/, @{$$self{"work"}{"cursor_key"};}
defined $self->{"work"}{"cursor_key"} grep /^$key$/, @{$$self{"work"}{"cursor_key"};}
Truth table0%0/3
A and B
A= defined $self->{"work"}{"cursor_key"}B= grep /^$key$/, @{$$self{"work"}{"cursor_key"};}
ABresult
0X0
100
111
1163 }
1164 }
1165  
1166 ## execute
1167 return SQL_SIMPLE_RC_ERROR if ($self->_Call(
1168 command => $sql,
1169 command_type => 0, # (ZERO is read)
1170 buffer => $argv->{buffer},
1171 buffer_options => $argv->{buffer_options},
1172 buffer_hashkey => $argv->{buffer_hashkey},
1173 buffer_arrayref => $argv->{buffer_arrayref},
1174 buffer_hashindex => $argv->{buffer_hashindex},
1175 buffer_reverse => $argv->{buffer_reverse},
1176 buffer_fields => @fields+0,
1177 cursor => $argv->{cursor},
1178 cursor_command => $argv->{cursor_command},
1179 cursor_key => $argv->{cursor_key},
1180 cursor_order => $argv->{cursor_order},
1181 make_only => $argv->{make_only},
1182 flush => $argv->{flush},
1183 sql_save => $argv->{sql_save},
1184 195 ▶ ));
Branch: 1 branch
BranchTrueFalseTotal
if $self->_Call("command", $sql, "command_type", 0, "buffer", $argv->{"buffer"}, "buffer_options", $argv->{"buffer_options"}, "buffer_hashkey", $argv->{"buffer_hashkey"}, "buffer_arrayref", $argv->{"buffer_arrayref"}, "buffer_hashindex", $argv->{"buffer_hashindex"}, "buffer_reverse", $argv->{"buffer_reverse"}, "buffer_fields", @fields + 0, "cursor", $argv->{"cursor"}, "cursor_command", $argv->{"cursor_command"}, "cursor_key", $argv->{"cursor_key"}, "cursor_order", $argv->{"cursor_order"}, "make_only", $argv->{"make_only"}, "flush", $argv->{"flush"}, "sql_save", $argv->{"sql_save"}) 195 0 195
1185 0 ▶ return SQL_SIMPLE_RC_OK if ($self->getRows());
Branch: 1 branch
BranchTrueFalseTotal
if $self->getRows 0 0 0
1186 0 ▶ return SQL_SIMPLE_RC_OK if ($argv->{notfound});
Branch: 1 branch
BranchTrueFalseTotal
if $argv->{"notfound"} 0 0 0
1187  
1188 0 $self->_setMessage("select",SQL_SIMPLE_RC_SYNTAX,"012");
1189 0 return SQL_SIMPLE_RC_EMPTY;
1190 }
1191  
1192 sub _SelectOrderBy()
1193 56 ▶{
Subroutine _SelectOrderBy: called CC=5 SCAR=16.1
1194 56 my $self = shift;
1195 56 my $array = shift;
1196 56 my $table = shift;
1197 56 my $field = shift;
1198 56 my $order = shift;
1199  
1200 56 ▶ if ($field =~ /^(.*?)\.(.*?)$/)
Branch: 1 branch
BranchTrueFalseTotal
if ($field =~ /^(.*?)\.(.*?)$/) { } 41 15 56
1201 {
1202 41 $field = $self->_getAliasCols(6,$field,SQL_SIMPLE_ALIAS_ORDERBY+SQL_SIMPLE_ALIAS_FQDN);
1203 }
1204 else
1205 {
1206 15 $field = $self->_getAliasCols(7,$field,SQL_SIMPLE_ALIAS_ORDERBY);
1207 }
1208 56 ▶ if ($order)
Branch: 1 branch
BranchTrueFalseTotal
if ($order) 48 8 56
1209 {
1210 48 $order = uc($order);
1211 48 ▶ $field .= " ".(($order eq SQL_SIMPLE_ORDER_ASC) ? 'ASC' : ($order eq SQL_SIMPLE_ORDER_DESC) ? 'DESC' : 'USING '.$order);
Branch: 2 branches
BranchTrueFalseTotal
$order eq 'ASC' ? : 33 15 48
$order eq 'DESC' ? : 15 0 15
1212 }
1213 56 push(@{$array},$field);
1214 }
1215  
1216 ################################################################################
1217 ## action: delete
1218 ## return:
1219 ## rc<0 syntax error
1220 ## rc=0 successful
1221 ## rc=1 sql error
1222 ## rc=2 no selected found (no match where found)
1223  
1224 sub Delete()
1225 15 ▶{
Subroutine Delete: called CC=13 SCAR=29.4
Pod documented
1226 15 my $self = shift;
1227 15 my $argv = {@_};
1228  
1229 15 $self->_resetSession();
1230 15 $self->_Dumper("delete",$argv);
1231 15 ▶ $self->Open() if (!defined($self->{init}{dbh}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"init"}{"dbh"} 2 13 15
1232  
1233 ## define the command in load
1234 15 $self->{work}{command} = SQL_SIMPLE_ALIAS_DELETE;
1235  
1236 15 ▶ if ($self->{init}{plugin_fh} && $self->{init}{plugin_fh}->can('Delete') && $self->{init}{plugin_fh}->Delete($argv))
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"init"}{"plugin_fh"} and $self->{"init"}{"plugin_fh"}->can("Delete") and $self->{"init"}{"plugin_fh"}->Delete($argv)) 0 15 15
Condition33%2/6
$self->{"init"}{"plugin_fh"} and $self->{"init"}{"plugin_fh"}->can("Delete") and $self->{"init"}{"plugin_fh"}->Delete($argv)
!ll&&!rl&&r
1500
$self->{"init"}{"plugin_fh"} and $self->{"init"}{"plugin_fh"}->can("Delete")
!ll&&!rl&&r
0150
MC/DC0%0/3
$self->{"init"}{"plugin_fh"} and $self->{"init"}{"plugin_fh"}->can("Delete") and $self->{"init"}{"plugin_fh"}->Delete($argv)
$self->{"init"}{"plugin_fh"} $self->{"init"}{"plugin_fh"}->can("Delete") $self->{"init"}{"plugin_fh"}->Delete($argv)
Truth table25%1/4
A and B and C
A= $self->{"init"}{"plugin_fh"}B= $self->{"init"}{"plugin_fh"}->can("Delete")C= $self->{"init"}{"plugin_fh"}->Delete($argv)
ABCresult
0XX0
10X0
1100
1111
1237 {
1238 0 $self->_setMessage("delete",SQL_SIMPLE_RC_SYNTAX,"037",$self->{argv}{interface},$self->{argv}{driver},$self->getMessage());
1239 0 return SQL_SIMPLE_RC_SYNTAX;
1240 }
1241  
1242 15 ▶ my $saved_commit = $self->_setCommit($argv->{commit}) if (defined($argv->{commit}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $argv->{"commit"} 0 15 15
1243 15 ▶ my $saved_message_log = $self->_setLogMessage($argv->{message_log}) if (defined($argv->{message_log}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $argv->{"message_log"} 0 15 15
1244 15 ▶ my $saved_quote = $self->_setQuote($argv->{quote}) if (defined($argv->{quote}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $argv->{"quote"} 0 15 15
1245 15 ▶ my $saved_sql_save = $self->_setSqlSave($argv->{sql_save}) if (defined($argv->{sql_save}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $argv->{"sql_save"} 0 15 15
1246  
1247 15 my $rc = $self->_Delete(%{$argv});
1248  
1249 15 ▶ $self->_setCommit($saved_commit) if (defined($argv->{commit}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $argv->{"commit"} 0 15 15
1250 15 ▶ $self->setMessgeLog($saved_message_log) if (defined($argv->{message_log}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $argv->{"message_log"} 0 15 15
1251 15 ▶ $self->_setQuote($saved_quote) if (defined($argv->{quote}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $argv->{"quote"} 0 15 15
1252 15 ▶ $self->_setSqlSave($saved_sql_save) if (defined($argv->{sql_save}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $argv->{"sql_save"} 0 15 15
1253  
1254 15 return $rc;
1255 }
1256  
1257 sub _Delete()
1258 15 ▶{
Subroutine _Delete: called CC=11 SCAR=30.1
1259 15 my $self = shift;
1260 15 my $argv = {@_};
1261  
1262 15 ▶ return SQL_SIMPLE_RC_SYNTAX if ($self->_checkTablesEntries("delete",$argv) != SQL_SIMPLE_RC_OK);
Branch: 1 branch
BranchTrueFalseTotal
if $self->_checkTablesEntries("delete", $argv) != 0 0 15 15
1263  
1264 ## make where
1265 15 my $where;
1266 15 ▶ return SQL_SIMPLE_RC_SYNTAX if ($self->_getWhere("delete",$argv->{where},\$where));
Branch: 1 branch
BranchTrueFalseTotal
if $self->_getWhere("delete", $argv->{"where"}, \$where) 0 15 15
1267 15 ▶ if ((!defined($where) || $where eq "") && !$argv->{force})
Branch: 1 branch
BranchTrueFalseTotal
if (!defined($where) || $where eq "" and not $argv->{"force"}) 0 15 15
Condition66%4/6
!defined($where) || $where eq "" and not $argv->{"force"}
!ll&&!rl&&r
1050
not defined $where or $where eq ""
l!l&&r!l&&!r
5010
MC/DC0%0/3
!defined($where) || $where eq "" and not $argv->{"force"}
not defined $where $where eq "" not $argv->{"force"}
Truth table40%2/5
not(A) or B and not(C)
A= not defined $whereB= $where eq ""C= not $argv->{"force"}
ABCresult
00X0
1X00
0100
1X11
0111
1268 {
1269 0 $self->_setMessage("delete",SQL_SIMPLE_RC_SYNTAX,"016");
1270 0 return SQL_SIMPLE_RC_SYNTAX;
1271 }
1272  
1273 ## make tables
1274 15 my @tables;
1275 15 foreach my $table(@{$self->{work}{tables_inuse}})
1276 {
1277 15 push(@tables,$self->_getSchemaName().$table);
1278 }
1279  
1280 ## build sql command
1281 15 my $sql = "DELETE FROM ".join(", ",@tables);
1282 #my $sql = "DELETE FROM ".join(", ",@{$self->{work}{tables_inuse}});
1283 15 ▶ $sql .= " WHERE ".$where if ($where);
Branch: 1 branch
BranchTrueFalseTotal
if $where 10 5 15
1284  
1285 return SQL_SIMPLE_RC_ERROR if ($self->_Call(
1286 command => $sql,
1287 command_type => 1, # (NOT_ZERO is update)
1288 buffer => $argv->{buffer},
1289 buffer_options => $argv->{buffer_options},
1290 buffer_hashkey => $argv->{buffer_hashkey},
1291 buffer_arrayref => $argv->{buffer_arrayref},
1292 make_only => $argv->{make_only},
1293 flush => $argv->{flush},
1294 sql_save => $argv->{sql_save},
1295 15 ▶ ));
Branch: 1 branch
BranchTrueFalseTotal
if $self->_Call("command", $sql, "command_type", 1, "buffer", $argv->{"buffer"}, "buffer_options", $argv->{"buffer_options"}, "buffer_hashkey", $argv->{"buffer_hashkey"}, "buffer_arrayref", $argv->{"buffer_arrayref"}, "make_only", $argv->{"make_only"}, "flush", $argv->{"flush"}, "sql_save", $argv->{"sql_save"}) 15 0 15
1296 0 ▶ return SQL_SIMPLE_RC_OK if ($argv->{notfound});
Branch: 1 branch
BranchTrueFalseTotal
if $argv->{"notfound"} 0 0 0
1297 0 ▶ if ($self->getRows() == 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->getRows == 0) 0 0 0
1298 {
1299 0 $self->_setMessage("delete",SQL_SIMPLE_RC_SYNTAX,"012");
1300 0 return SQL_SIMPLE_RC_EMPTY;
1301 }
1302 0 return SQL_SIMPLE_RC_OK;
1303 }
1304  
1305 ################################################################################
1306 ## action: insert
1307 ## return:
1308 ## rc<0 syntax error
1309 ## rc=0 successful
1310 ## rc=1 sql error
1311 ## rc=2 no selected found (no match where found)
1312  
1313 sub Insert()
1314 22 ▶{
Subroutine Insert: called CC=13 SCAR=30.0
Pod documented
1315 22 my $self = shift;
1316 22 my $argv = {@_};
1317  
1318 22 $self->_resetSession();
1319 22 $self->_Dumper("insert",$argv);
1320 22 ▶ $self->Open() if (!defined($self->{init}{dbh}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"init"}{"dbh"} 0 22 22
1321  
1322 ## define the command in load
1323 22 $self->{work}{command} = SQL_SIMPLE_ALIAS_INSERT;
1324  
1325 22 ▶ if ($self->{init}{plugin_fh} && $self->{init}{plugin_fh}->can('Insert') && $self->{init}{plugin_fh}->Insert($argv))
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"init"}{"plugin_fh"} and $self->{"init"}{"plugin_fh"}->can("Insert") and $self->{"init"}{"plugin_fh"}->Insert($argv)) 0 22 22
Condition33%2/6
$self->{"init"}{"plugin_fh"} and $self->{"init"}{"plugin_fh"}->can("Insert") and $self->{"init"}{"plugin_fh"}->Insert($argv)
!ll&&!rl&&r
2200
$self->{"init"}{"plugin_fh"} and $self->{"init"}{"plugin_fh"}->can("Insert")
!ll&&!rl&&r
0220
MC/DC0%0/3
$self->{"init"}{"plugin_fh"} and $self->{"init"}{"plugin_fh"}->can("Insert") and $self->{"init"}{"plugin_fh"}->Insert($argv)
$self->{"init"}{"plugin_fh"} $self->{"init"}{"plugin_fh"}->can("Insert") $self->{"init"}{"plugin_fh"}->Insert($argv)
Truth table25%1/4
A and B and C
A= $self->{"init"}{"plugin_fh"}B= $self->{"init"}{"plugin_fh"}->can("Insert")C= $self->{"init"}{"plugin_fh"}->Insert($argv)
ABCresult
0XX0
10X0
1100
1111
1326 {
1327 0 $self->_setMessage("insert",SQL_SIMPLE_RC_SYNTAX,"037",$self->{argv}{interface},$self->{argv}{driver},$self->getMessage());
1328 0 return SQL_SIMPLE_RC_SYNTAX;
1329 }
1330  
1331 22 ▶ my $saved_commit = $self->_setCommit($argv->{commit}) if (defined($argv->{commit}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $argv->{"commit"} 0 22 22
1332 22 ▶ my $saved_message_log = $self->_setLogMessage($argv->{message_log}) if (defined($argv->{message_log}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $argv->{"message_log"} 0 22 22
1333 22 ▶ my $saved_quote = $self->_setQuote($argv->{quote}) if (defined($argv->{quote}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $argv->{"quote"} 0 22 22
1334 22 ▶ my $saved_sql_save = $self->_setSqlSave($argv->{sql_save}) if (defined($argv->{sql_save}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $argv->{"sql_save"} 0 22 22
1335  
1336 22 my $rc = $self->_Insert(%{$argv});
1337  
1338 22 ▶ $self->_setCommit($saved_commit) if (defined($argv->{commit}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $argv->{"commit"} 0 22 22
1339 22 ▶ $self->setMessgeLog($saved_message_log) if (defined($argv->{message_log}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $argv->{"message_log"} 0 22 22
1340 22 ▶ $self->_setQuote($saved_quote) if (defined($argv->{quote}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $argv->{"quote"} 0 22 22
1341 22 ▶ $self->_setSqlSave($saved_sql_save) if (defined($argv->{sql_save}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $argv->{"sql_save"} 0 22 22
1342  
1343 22 return $rc;
1344 }
1345  
1346 sub _Insert()
1347 22 ▶{
Subroutine _Insert: called CC=28 SCAR=46.2
1348 22 my $self = shift;
1349 22 my $argv = {@_};
1350  
1351 22 ▶ return SQL_SIMPLE_RC_SYNTAX if ($self->_checkTablesEntries("insert",$argv) != SQL_SIMPLE_RC_OK);
Branch: 1 branch
BranchTrueFalseTotal
if $self->_checkTablesEntries("insert", $argv) != 0 0 22 22
1352  
1353 ## check mandatory options
1354 22 ▶ if (!defined($argv->{fields}))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $argv->{"fields"}) 0 22 22
1355 {
1356 0 $self->_setMessage("insert",SQL_SIMPLE_RC_SYNTAX,"017");
1357 0 return SQL_SIMPLE_RC_SYNTAX;
1358 }
1359  
1360 ## hash: fields=> { fld => value }
1361 ## array: fields=> [ fld1,fld2 }, values=> [ val1,val2 ]
1362 22 ▶ if (ref($argv->{fields}) eq "HASH") {}
Branch: 2 branches
BranchTrueFalseTotal
if (ref $argv->{'fields'} eq 'HASH') { } 11 11 22
elsif (ref $argv->{'fields'} eq 'ARRAY') { } 11 0 11
1363 elsif (ref($argv->{fields}) eq "ARRAY")
1364 {
1365 11 ▶ if (!defined($argv->{values}))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $argv->{"values"}) 0 11 11
1366 {
1367 0 $self->_setMessage("insert",SQL_SIMPLE_RC_SYNTAX,"027");
1368 0 return SQL_SIMPLE_RC_SYNTAX;
1369 }
1370 11 ▶ if (ref($argv->{values}) ne "ARRAY")
Branch: 1 branch
BranchTrueFalseTotal
if (ref $argv->{"values"} ne "ARRAY") 0 11 11
1371 {
1372 0 $self->_setMessage("insert",SQL_SIMPLE_RC_SYNTAX,"041");
1373 0 return SQL_SIMPLE_RC_SYNTAX;
1374 }
1375 }
1376 else
1377 {
1378 0 $self->_setMessage("insert",SQL_SIMPLE_RC_SYNTAX,"018");
1379 0 return SQL_SIMPLE_RC_SYNTAX;
1380 }
1381  
1382 ## validat conflict option
1383 22 ▶ if (defined($argv->{conflict}) && ref($argv->{conflict}) ne "HASH")
Branch: 1 branch
BranchTrueFalseTotal
if (defined $argv->{"conflict"} and ref $argv->{"conflict"} ne "HASH") 0 22 22
Condition33%1/3
defined $argv->{"conflict"} and ref $argv->{"conflict"} ne "HASH"
!ll&&!rl&&r
2200
MC/DC0%0/2
defined $argv->{"conflict"} and ref $argv->{"conflict"} ne "HASH"
defined $argv->{"conflict"} ref $argv->{"conflict"} ne "HASH"
Truth table33%1/3
A and B
A= defined $argv->{"conflict"}B= ref $argv->{"conflict"} ne "HASH"
ABresult
0X0
100
111
1384 {
1385 0 $self->_setMessage("insert",SQL_SIMPLE_RC_SYNTAX,"042");
1386 0 return SQL_SIMPLE_RC_SYNTAX;
1387 }
1388  
1389 ## making fields
1390 22 my @fields;
1391 my @values;
1392  
1393 ## format: fields => { ... }
1394 22 ▶ if (ref($argv->{fields}) eq "HASH")
Branch: 1 branch
BranchTrueFalseTotal
if (ref $argv->{'fields'} eq 'HASH') { } 11 11 22
1395 {
1396 ## mapping field and value
1397 11 my @value_;
1398 11 foreach my $field(sort(keys(%{$argv->{fields}})))
1399 {
1400 16 push(@fields,$self->_getAliasCols(8,$field,SQL_SIMPLE_ALIAS_INSERT));
1401 16 ▶ push(@value_,(!defined($argv->{fields}{$field})) ? "NULL" : $self->{argv}{quote}.$self->_escapeQuote($argv->{fields}{$field}).$self->{argv}{quote});
Branch: 1 branch
BranchTrueFalseTotal
!defined($argv->{'fields'}{$field}) ? : 3 13 16
1402 }
1403 11 @values = ("(".join(",",@value_).")");
1404 }
1405 ## format: fields => [ ... ]
1406 else
1407 {
1408 ## mapping field
1409 11 foreach my $field(@{$argv->{fields}})
1410 {
1411 16 push(@fields,$self->_getAliasCols(9,$field,SQL_SIMPLE_ALIAS_INSERT));
1412 }
1413 11 my @value_;
1414 11 foreach my $value(@{$argv->{values}})
1415 {
1416 ## format: fields => [ col => val ]
1417 22 ▶ if (ref($value) ne "ARRAY")
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value ne 'ARRAY') { } 22 0 22
1418 {
1419 22 ▶ push(@value_,(!defined($value)) ? "NULL" : $self->{argv}{quote}.$self->_escapeQuote($value).$self->{argv}{quote});
Branch: 1 branch
BranchTrueFalseTotal
!defined($value) ? : 6 16 22
1420 }
1421 ## format: fields => [ col => [ val1, ... ] ], field must be 1
1422 else
1423 {
1424 0 my @value2;
1425 0 foreach my $value2(@{$value})
1426 {
1427 0 ▶ push(@value2,(!defined($value2)) ? "NULL" : $self->{argv}{quote}.$self->_escapeQuote($value2).$self->{argv}{quote});
Branch: 1 branch
BranchTrueFalseTotal
!defined($value2) ? : 0 0 0
1428 }
1429 0 push(@values,"(".join(",",@value2).")");
1430 }
1431 }
1432 11 ▶ push(@values, (@fields == 1) ? "(".join("),(",@value_).")" : "(".join(",",@value_).")" ) if (@value_);
Branch: 2 branches
BranchTrueFalseTotal
if @value_ 11 0 11
@fields == 1 ? : 8 3 11
1433 }
1434  
1435 ## make tables
1436 22 my @tables;
1437 22 foreach my $table(@{$self->{work}{tables_inuse}})
1438 {
1439 22 push(@tables,$self->_getSchemaName().$table);
1440 }
1441  
1442 ## build sql
1443 22 my $sql = "INSERT INTO ".join(", ",@tables)." (".join(",",@fields).") VALUES ".join(",",@values);
1444 #my $sql = "INSERT INTO ".join(", ",@{$self->{work}{tables_inuse}})." (".join(",",@fields).") VALUES ".join(",",@values);
1445 22 ▶ if (defined($argv->{conflict}))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $argv->{"conflict"}) 0 22 22
1446 {
1447 0 my @conflict;
1448 0 foreach my $field(sort(keys(%{$argv->{conflict}})))
1449 {
1450 ($argv->{conflict}{$field} =~ /^\\(.*)/) ?
1451 push(@conflict,$self->_getAliasCols(10,$field,SQL_SIMPLE_ALIAS_INSERT)." = ".$1):
1452 0 ▶ push(@conflict,$self->_getAliasCols(11,$field,SQL_SIMPLE_ALIAS_INSERT)." = ".$self->{argv}{quote}.$self->_escapeQuote($argv->{conflict}{$field}).$self->{argv}{quote});
Branch: 1 branch
BranchTrueFalseTotal
$argv->{'conflict'}{$field} =~ /^\\(.*)/ ? : 0 0 0
1453 }
1454 $sql .= ($self->{init}{plugin_id} =~ /^mysql/i || $self->{init}{plugin_id} =~ /^mariadb/i) ?
1455 " ON DUPLICATE KEY UPDATE ".join(", ",@conflict) :
1456 0 ▶ " ON CONFLICT ".(($argv->{conflict_key})?"(".$self->_getAliasCols(12,$argv->{conflict_key},SQL_SIMPLE_ALIAS_INSERT).") ":"")."DO UPDATE SET ".join(", ",@conflict);
Branch: 2 branches
BranchTrueFalseTotal
$self->{'init'}{'plugin_id'} =~ /^mysql/i || $self->{'init'}{'plugin_id'} =~ /^mariadb/i ? : 0 0 0
$argv->{'conflict_key'} ? : 0 0 0
Condition0%0/3
$self->{"init"}{"plugin_id"} =~ /^mysql/i or $self->{"init"}{"plugin_id"} =~ /^mariadb/i
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"init"}{"plugin_id"} =~ /^mysql/i or $self->{"init"}{"plugin_id"} =~ /^mariadb/i
$self->{"init"}{"plugin_id"} =~ /^mysql/i $self->{"init"}{"plugin_id"} =~ /^mariadb/i
Truth table0%0/3
A or B
A= $self->{"init"}{"plugin_id"} =~ /^mysql/iB= $self->{"init"}{"plugin_id"} =~ /^mariadb/i
ABresult
1X1
011
000
1457 }
1458  
1459 ## execute
1460 return SQL_SIMPLE_RC_ERROR if ($self->_Call(
1461 command => $sql,
1462 command_type => 1, # (NOT_ZERO is update)
1463 buffer => $argv->{buffer},
1464 buffer_options => $argv->{buffer_options},
1465 buffer_hashkey => $argv->{buffer_hashkey},
1466 buffer_arrayref => $argv->{buffer_arrayref},
1467 make_only => $argv->{make_only},
1468 flush => $argv->{flush},
1469 sql_save => $argv->{sql_save},
1470 22 ▶ ));
Branch: 1 branch
BranchTrueFalseTotal
if $self->_Call("command", $sql, "command_type", 1, "buffer", $argv->{"buffer"}, "buffer_options", $argv->{"buffer_options"}, "buffer_hashkey", $argv->{"buffer_hashkey"}, "buffer_arrayref", $argv->{"buffer_arrayref"}, "make_only", $argv->{"make_only"}, "flush", $argv->{"flush"}, "sql_save", $argv->{"sql_save"}) 22 0 22
1471 0 return SQL_SIMPLE_RC_OK;
1472 }
1473  
1474 ################################################################################
1475 ## action: update
1476 ## return:
1477 ## rc<0 syntax error
1478 ## rc=0 successful
1479 ## rc=1 sql error
1480 ## rc=2 no selected found (no match where found)
1481  
1482 sub Update()
1483 40 ▶{
Subroutine Update: called CC=13 SCAR=30.0
Pod documented
1484 40 my $self = shift;
1485 40 my $argv = {@_};
1486  
1487 40 $self->_resetSession();
1488 40 $self->_Dumper("update",$argv);
1489 40 ▶ $self->Open() if (!defined($self->{init}{dbh}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"init"}{"dbh"} 0 40 40
1490  
1491 ## define the command in load
1492 40 $self->{work}{command} = SQL_SIMPLE_ALIAS_UPDATE;
1493  
1494 40 ▶ if ($self->{init}{plugin_fh} && $self->{init}{plugin_fh}->can('Update') && $self->{init}{plugin_fh}->Update($argv))
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"init"}{"plugin_fh"} and $self->{"init"}{"plugin_fh"}->can("Update") and $self->{"init"}{"plugin_fh"}->Update($argv)) 0 40 40
Condition33%2/6
$self->{"init"}{"plugin_fh"} and $self->{"init"}{"plugin_fh"}->can("Update") and $self->{"init"}{"plugin_fh"}->Update($argv)
!ll&&!rl&&r
4000
$self->{"init"}{"plugin_fh"} and $self->{"init"}{"plugin_fh"}->can("Update")
!ll&&!rl&&r
0400
MC/DC0%0/3
$self->{"init"}{"plugin_fh"} and $self->{"init"}{"plugin_fh"}->can("Update") and $self->{"init"}{"plugin_fh"}->Update($argv)
$self->{"init"}{"plugin_fh"} $self->{"init"}{"plugin_fh"}->can("Update") $self->{"init"}{"plugin_fh"}->Update($argv)
Truth table25%1/4
A and B and C
A= $self->{"init"}{"plugin_fh"}B= $self->{"init"}{"plugin_fh"}->can("Update")C= $self->{"init"}{"plugin_fh"}->Update($argv)
ABCresult
0XX0
10X0
1100
1111
1495 {
1496 0 $self->_setMessage("update",SQL_SIMPLE_RC_SYNTAX,"037",$self->{argv}{interface},$self->{argv}{driver},$self->getMessage());
1497 0 return SQL_SIMPLE_RC_SYNTAX;
1498 }
1499  
1500 40 ▶ my $saved_commit = $self->_setCommit($argv->{commit}) if (defined($argv->{commit}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $argv->{"commit"} 0 40 40
1501 40 ▶ my $saved_message_log = $self->_setLogMessage($argv->{message_log}) if (defined($argv->{message_log}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $argv->{"message_log"} 0 40 40
1502 40 ▶ my $saved_quote = $self->_setQuote($argv->{quote}) if (defined($argv->{quote}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $argv->{"quote"} 0 40 40
1503 40 ▶ my $saved_sql_save = $self->_setSqlSave($argv->{sql_save}) if (defined($argv->{sql_save}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $argv->{"sql_save"} 0 40 40
1504  
1505 40 my $rc = $self->_Update(%{$argv});
1506  
1507 40 ▶ $self->_setCommit($saved_commit) if (defined($argv->{commit}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $argv->{"commit"} 0 40 40
1508 40 ▶ $self->setMessgeLog($saved_message_log) if (defined($argv->{message_log}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $argv->{"message_log"} 0 40 40
1509 40 ▶ $self->_setQuote($saved_quote) if (defined($argv->{quote}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $argv->{"quote"} 0 40 40
1510 40 ▶ $self->_setSqlSave($saved_sql_save) if (defined($argv->{sql_save}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $argv->{"sql_save"} 0 40 40
1511  
1512 40 return $rc;
1513 }
1514  
1515 sub _Update()
1516 40 ▶{
Subroutine _Update: called CC=19 SCAR=33.8
1517 40 my $self = shift;
1518 40 my $argv = {@_};
1519  
1520 40 ▶ return SQL_SIMPLE_RC_SYNTAX if ($self->_checkTablesEntries("update",$argv) != SQL_SIMPLE_RC_OK);
Branch: 1 branch
BranchTrueFalseTotal
if $self->_checkTablesEntries("update", $argv) != 0 0 40 40
1521  
1522 ## check mandatory options
1523 40 ▶ if (!defined($argv->{fields}))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $argv->{"fields"}) 0 40 40
1524 {
1525 0 $self->_setMessage("update",SQL_SIMPLE_RC_SYNTAX,"017");
1526 0 return SQL_SIMPLE_RC_SYNTAX;
1527 }
1528 40 ▶ if (ref($argv->{fields}) ne "HASH")
Branch: 1 branch
BranchTrueFalseTotal
if (ref $argv->{"fields"} ne "HASH") 0 40 40
1529 {
1530 0 $self->_setMessage("update",SQL_SIMPLE_RC_SYNTAX,"018");
1531 0 return SQL_SIMPLE_RC_SYNTAX;
1532 }
1533  
1534 ## make fields
1535 40 my $ident = 0;
1536 40 my @fields;
1537 40 foreach my $field(sort(keys(%{$argv->{fields}})))
1538 {
1539 54 my $realn = $self->_getAliasCols(13,$field,SQL_SIMPLE_ALIAS_UPDATE);
1540 54 ▶ $ident = 1 if ($realn =~ /^.*\..*$/);
Branch: 1 branch
BranchTrueFalseTotal
if $realn =~ /^.*\..*$/ 22 32 54
1541  
1542 54 ▶ if (!defined($argv->{fields}{$field}))
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $argv->{'fields'}{$field}) { } 2 52 54
elsif ($argv->{'fields'}{$field} =~ /^\\(.*)/) { } 1 51 52
1543 {
1544 2 push(@fields,$realn." = NULL");
1545 }
1546 elsif ($argv->{fields}{$field} =~ /^\\(.*)/)
1547 {
1548 1 my $value = $1;
1549 1 push(@fields,$realn." = ".$value);
1550 }
1551 else
1552 {
1553 ## validate functions as arguments
1554 51 $self->_checkFunctions(\$argv->{fields}{$field},SQL_SIMPLE_ALIAS_UPDATE);
1555 51 push(@fields,$realn." = ".$self->{argv}{quote}.$self->_escapeQuote($argv->{fields}{$field}).$self->{argv}{quote});
1556 }
1557 }
1558  
1559 ## make tables
1560 40 my @tables;
1561 40 foreach my $table(@{$self->{work}{tables_inuse}})
1562 {
1563 51 my $_table = $self->_getAliasTable($table,$argv);
1564  
1565 ## remove alias if not required
1566 51 ▶ $_table = $1 if (!$ident && $_table =~ /^(.*?)\s+.*?$/);
Branch: 1 branch
BranchTrueFalseTotal
if not $ident and $_table =~ /^(.*?)\s+.*?$/ 19 32 51
Condition100%3/3
not $ident and $_table =~ /^(.*?)\s+.*?$/
!ll&&!rl&&r
24819
MC/DC100%2/2
not $ident and $_table =~ /^(.*?)\s+.*?$/
not $ident $_table =~ /^(.*?)\s+.*?$/
Truth table100%3/3
not(A) and B
A= not $identB= $_table =~ /^(.*?)\s+.*?$/
ABresult
0X0
100
111
1567  
1568 51 push(@tables,$_table);
1569 }
1570  
1571 ## make where
1572 40 my $where;
1573 40 ▶ return SQL_SIMPLE_RC_SYNTAX if ($self->_getWhere("update",$argv->{where},\$where));
Branch: 1 branch
BranchTrueFalseTotal
if $self->_getWhere("update", $argv->{"where"}, \$where) 0 40 40
1574 40 ▶ if ((!defined($where) || $where eq "") && !$argv->{force})
Branch: 1 branch
BranchTrueFalseTotal
if (!defined($where) || $where eq "" and not $argv->{"force"}) 0 40 40
Condition66%4/6
!defined($where) || $where eq "" and not $argv->{"force"}
!ll&&!rl&&r
15250
not defined $where or $where eq ""
l!l&&r!l&&!r
25015
MC/DC0%0/3
!defined($where) || $where eq "" and not $argv->{"force"}
not defined $where $where eq "" not $argv->{"force"}
Truth table40%2/5
not(A) or B and not(C)
A= not defined $whereB= $where eq ""C= not $argv->{"force"}
ABCresult
00X0
1X00
0100
1X11
0111
1575 {
1576 0 $self->_setMessage("update",SQL_SIMPLE_RC_SYNTAX,"016");
1577 0 return SQL_SIMPLE_RC_SYNTAX;
1578 }
1579  
1580 ## formata o sql
1581 40 my $sql = "UPDATE ".join(", ",@tables)." SET ".join(", ",@fields);
1582 40 ▶ $sql .= " WHERE ".$where if ($where);
Branch: 1 branch
BranchTrueFalseTotal
if $where 15 25 40
1583  
1584 ## execute
1585 return SQL_SIMPLE_RC_ERROR if ($self->_Call(
1586 command => $sql,
1587 command_type => 1, # (NOT_ZERO is update)
1588 buffer => $argv->{buffer},
1589 buffer_options => $argv->{buffer_options},
1590 buffer_hashkey => $argv->{buffer_hashkey},
1591 buffer_arrayref => $argv->{buffer_arrayref},
1592 make_only => $argv->{make_only},
1593 flush => $argv->{flush},
1594 sql_save => $argv->{sql_save},
1595 40 ▶ ));
Branch: 1 branch
BranchTrueFalseTotal
if $self->_Call("command", $sql, "command_type", 1, "buffer", $argv->{"buffer"}, "buffer_options", $argv->{"buffer_options"}, "buffer_hashkey", $argv->{"buffer_hashkey"}, "buffer_arrayref", $argv->{"buffer_arrayref"}, "make_only", $argv->{"make_only"}, "flush", $argv->{"flush"}, "sql_save", $argv->{"sql_save"}) 40 0 40
1596 0 ▶ return SQL_SIMPLE_RC_OK if ($argv->{notfound});
Branch: 1 branch
BranchTrueFalseTotal
if $argv->{"notfound"} 0 0 0
1597 0 ▶ if ($self->getRows() == 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->getRows == 0) 0 0 0
1598 {
1599 0 $self->_setMessage("update",SQL_SIMPLE_RC_SYNTAX,"012");
1600 0 return SQL_SIMPLE_RC_EMPTY;
1601 }
1602 0 return SQL_SIMPLE_RC_OK;
1603 }
1604  
1605 ################################################################################
1606 ## action: wait db connect
1607 ## return:
1608 ## rc<0 syntax error
1609 ## rc=0 successful
1610 ## rc>0 sql command error
1611  
1612 sub Wait()
1613 0 ▶{
Subroutine Wait: not called CC=9 SCAR=45.0
Pod undocumented
1614 0 my $self = shift;
1615 0 my $argv= {@_};
1616  
1617 0 $self->_Dumper("wait",$argv);
1618  
1619 0 ▶ my $count = 1 if (!defined($argv->{count}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $argv->{"count"} 0 0 0
1620 0 ▶ my $sleep = 5 if (!defined($argv->{interval}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $argv->{"interval"} 0 0 0
1621  
1622 0 ▶ return SQL_SIMPLE_RC_SYNTAX if ($count =~ /^\D+$/);
Branch: 1 branch
BranchTrueFalseTotal
if $count =~ /^\D+$/ 0 0 0
1623 0 ▶ return SQL_SIMPLE_RC_SYNTAX if ($sleep =~ /^\D+$/);
Branch: 1 branch
BranchTrueFalseTotal
if $sleep =~ /^\D+$/ 0 0 0
1624  
1625 0 ▶ while ($count-- > 0)
Branch: 1 branch
BranchTrueFalseTotal
if ($count-- > 0) 0 0 0
1626 {
1627 0 ▶ last if (!$self->Open());
Branch: 1 branch
BranchTrueFalseTotal
unless $self->Open 0 0 0
1628  
1629 0 ▶ sleep($sleep) if ($count && $sleep);
Branch: 1 branch
BranchTrueFalseTotal
if $count and $sleep 0 0 0
Condition0%0/3
$count and $sleep
!ll&&!rl&&r
000
MC/DC0%0/2
$count and $sleep
$count $sleep
Truth table0%0/3
A and B
A= $countB= $sleep
ABresult
0X0
100
111
1630 }
1631 0 return $self->getRC();
1632 }
1633  
1634 ################################################################################
1635 ## action: execute sql command
1636 ## return:
1637 ## rc<0 syntax error
1638 ## rc=0 successful
1639 ## rc>0 sql command error
1640 #
1641 ## callback example:
1642 ## sub myfunc()
1643 ## {
1644 ## my $ref = shift; # input field hash info
1645 ## my $options = shift; # options args
1646 ## return 0; # if ok to continue than return ZERO
1647 ## return 1; # if aboort needed than return NOT_ZERO
1648 ## }
1649  
1650 sub Call()
1651 0 ▶{
Subroutine Call: not called CC=14 SCAR=53.5
Pod documented
1652 0 my $self = shift;
1653 0 my $argv = {@_};
1654  
1655 0 $self->_resetSession();
1656 0 $self->_Dumper("call",$argv);
1657 0 ▶ $self->Open() if (!defined($self->{init}{dbh}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"init"}{"dbh"} 0 0 0
1658  
1659 ## define the command in load
1660 0 ▶ if ($self->{init}{plugin_fh} && $self->{init}{plugin_fh}->can('Call') && $self->{init}{plugin_fh}->Call($argv))
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"init"}{"plugin_fh"} and $self->{"init"}{"plugin_fh"}->can("Call") and $self->{"init"}{"plugin_fh"}->Call($argv)) 0 0 0
Condition0%0/6
$self->{"init"}{"plugin_fh"} and $self->{"init"}{"plugin_fh"}->can("Call") and $self->{"init"}{"plugin_fh"}->Call($argv)
!ll&&!rl&&r
000
$self->{"init"}{"plugin_fh"} and $self->{"init"}{"plugin_fh"}->can("Call")
!ll&&!rl&&r
000
MC/DC0%0/3
$self->{"init"}{"plugin_fh"} and $self->{"init"}{"plugin_fh"}->can("Call") and $self->{"init"}{"plugin_fh"}->Call($argv)
$self->{"init"}{"plugin_fh"} $self->{"init"}{"plugin_fh"}->can("Call") $self->{"init"}{"plugin_fh"}->Call($argv)
Truth table0%0/4
A and B and C
A= $self->{"init"}{"plugin_fh"}B= $self->{"init"}{"plugin_fh"}->can("Call")C= $self->{"init"}{"plugin_fh"}->Call($argv)
ABCresult
0XX0
10X0
1100
1111
1661 {
1662 0 $self->_setMessage("call",SQL_SIMPLE_RC_SYNTAX,"037",$self->{argv}{interface},$self->{argv}{driver},$self->getMessage());
1663 0 return SQL_SIMPLE_RC_SYNTAX;
1664 }
1665 0 ▶ if ($argv->{command} eq "")
Branch: 1 branch
BranchTrueFalseTotal
if ($argv->{"command"} eq "") 0 0 0
1666 {
1667 0 $self->_setMessage("call",SQL_SIMPLE_RC_SYNTAX,"023");
1668 0 return SQL_SIMPLE_RC_SYNTAX;
1669 }
1670  
1671 0 ▶ my $saved_commit = $self->_setCommit($argv->{commit}) if (defined($argv->{commit}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $argv->{"commit"} 0 0 0
1672 0 ▶ my $saved_message_log = $self->_setLogMessage($argv->{message_log}) if (defined($argv->{message_log}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $argv->{"message_log"} 0 0 0
1673 0 ▶ my $saved_quote = $self->_setQuote($argv->{quote}) if (defined($argv->{quote}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $argv->{"quote"} 0 0 0
1674 0 ▶ my $saved_sql_save = $self->_setSqlSave($argv->{sql_save}) if (defined($argv->{sql_save}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $argv->{"sql_save"} 0 0 0
1675  
1676 0 my $rc = $self->_Call(%{$argv});
1677  
1678 0 ▶ $self->_setCommit($saved_commit) if (defined($argv->{commit}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $argv->{"commit"} 0 0 0
1679 0 ▶ $self->setMessgeLog($saved_message_log) if (defined($argv->{message_log}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $argv->{"message_log"} 0 0 0
1680 0 ▶ $self->_setQuote($saved_quote) if (defined($argv->{quote}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $argv->{"quote"} 0 0 0
1681 0 ▶ $self->_setSqlSave($saved_sql_save) if (defined($argv->{sql_save}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $argv->{"sql_save"} 0 0 0
1682  
1683 0 return $rc;
1684 }
1685  
1686 sub _Call()
1687 272 ▶{
Subroutine _Call: called CC=75 SCAR=84.7
1688 272 my $self = shift;
1689 272 my $argv = {@_};
1690  
1691 272 $self->_setLastSQL($argv->{command});
1692  
1693 ## save command (call-sql_save is prior that new-sql_save
1694 272 ▶ if ((defined($argv->{sql_save}) && $argv->{sql_save}) || (defined($self->{argv}{sql_save}) && $self->{argv}{sql_save} && $argv->{command_type}))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $argv->{"sql_save"} and $argv->{"sql_save"} or defined $self->{"argv"}{"sql_save"} and $self->{"argv"}{"sql_save"} and $argv->{"command_type"}) 1 271 272
Condition58%7/12
defined $argv->{"sql_save"} and $argv->{"sql_save"} or defined $self->{"argv"}{"sql_save"} and $self->{"argv"}{"sql_save"} and $argv->{"command_type"}
l!l&&r!l&&!r
10271
defined $argv->{"sql_save"} and $argv->{"sql_save"}
!ll&&!rl&&r
27101
defined $self->{"argv"}{"sql_save"} and $self->{"argv"}{"sql_save"} and $argv->{"command_type"}
!ll&&!rl&&r
27100
defined $self->{"argv"}{"sql_save"} and $self->{"argv"}{"sql_save"}
!ll&&!rl&&r
248230
MC/DC20%1/5
defined $argv->{"sql_save"} and $argv->{"sql_save"} or defined $self->{"argv"}{"sql_save"} and $self->{"argv"}{"sql_save"} and $argv->{"command_type"}
defined $argv->{"sql_save"} $argv->{"sql_save"} defined $self->{"argv"}{"sql_save"} $self->{"argv"}{"sql_save"} $argv->{"command_type"}
Truth table33%3/9
A and B or C and D and E
A= defined $argv->{"sql_save"}B= $argv->{"sql_save"}C= defined $self->{"argv"}{"sql_save"}D= $self->{"argv"}{"sql_save"}E= $argv->{"command_type"}
ABCDEresult
11XXX1
0X1111
101111
0X0XX0
0X10X0
0X1100
100XX0
1010X0
101100
1695 {
1696 1 ▶ return SQL_SIMPLE_RC_ERROR if ($self->Save($argv->{command}));
Branch: 1 branch
BranchTrueFalseTotal
if $self->Save($argv->{"command"}) 0 1 1
1697 }
1698  
1699 ## return if makeonly
1700 272 ▶ return SQL_SIMPLE_RC_ERROR if ($argv->{make_only});
Branch: 1 branch
BranchTrueFalseTotal
if $argv->{"make_only"} 272 0 272
1701  
1702 ## mandatory
1703 0 ▶ if (!defined($self->{init}{dbh}))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"init"}{"dbh"}) 0 0 0
1704 {
1705 0 $self->_setMessage("call",SQL_SIMPLE_RC_SYNTAX,"022");
1706 0 return SQL_SIMPLE_RC_SYNTAX;
1707 }
1708 0 ▶ my $flush_buffer = (!defined($argv->{flush}) || $argv->{flush}) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
!defined($argv->{'flush'}) || $argv->{'flush'} ? : 0 0 0
Condition0%0/3
not defined $argv->{"flush"} or $argv->{"flush"}
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $argv->{"flush"} or $argv->{"flush"}
not defined $argv->{"flush"} $argv->{"flush"}
Truth table0%0/3
not(A) or B
A= not defined $argv->{"flush"}B= $argv->{"flush"}
ABresult
1X1
011
000
1709 0 my $type;
1710  
1711 ## define type of return data
1712 0 ▶ if (!defined($argv->{buffer})) {}
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $argv->{'buffer'}) { } 0 0 0
elsif (ref $argv->{'buffer'} eq 'HASH') { } 0 0 0
1713 elsif (ref($argv->{buffer}) eq "HASH")
1714 {
1715 0 ▶ if (!defined($argv->{buffer_hashkey})) { $type=1; }
Branch: 4 branches
BranchTrueFalseTotal
if (not defined $argv->{'buffer_hashkey'}) { } 0 0 0
elsif (ref $argv->{'buffer_hashkey'} eq 'ARRAY') { } 0 0 0
elsif (ref $argv->{'buffer_hashkey'} eq 'SCALAR') { } 0 0 0
elsif (ref $argv->{'buffer_hashkey'} eq '') { } 0 0 0
1716 0 ▶ elsif (ref($argv->{buffer_hashkey}) eq "ARRAY") { $type = (@{$argv->{buffer_hashkey}} > 1) ? 6 : 5; }
Branch: 1 branch
BranchTrueFalseTotal
@{$argv->{'buffer_hashkey'};} > 1 ? : 0 0 0
1717 0 elsif (ref($argv->{buffer_hashkey}) eq "SCALAR") { $type=5; }
1718 0 elsif (ref($argv->{buffer_hashkey}) eq "") { $type=5; }
1719 else
1720 {
1721 0 $self->_setMessage("call",SQL_SIMPLE_RC_SYNTAX,"046");
1722 0 return SQL_SIMPLE_RC_SYNTAX;
1723 }
1724 0 ▶ if ($flush_buffer)
Branch: 1 branch
BranchTrueFalseTotal
if ($flush_buffer) 0 0 0
1725 {
1726 0 undef(%{$argv->{buffer}});;
1727 0 ▶ undef(@{$argv->{buffer_hashindex}}) if (defined($argv->{buffer_hashindex}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $argv->{"buffer_hashindex"} 0 0 0
1728 }
1729 }
1730 else
1731 {
1732 0 ▶ if (ref($argv->{buffer}) eq "ARRAY")
Branch: 3 branches
BranchTrueFalseTotal
if (ref $argv->{'buffer'} eq 'ARRAY') { } 0 0 0
elsif (ref $argv->{'buffer'} eq 'CODE') { } 0 0 0
elsif (ref $argv->{'buffer'} eq 'SCALAR') { } 0 0 0
1733 {
1734 0 ▶ if (defined($argv->{buffer_arrayref}) && !$argv->{buffer_arrayref})
Branch: 1 branch
BranchTrueFalseTotal
if (defined $argv->{'buffer_arrayref'} and not $argv->{'buffer_arrayref'}) { } 0 0 0
Condition0%0/3
defined $argv->{"buffer_arrayref"} and not $argv->{"buffer_arrayref"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $argv->{"buffer_arrayref"} and not $argv->{"buffer_arrayref"}
defined $argv->{"buffer_arrayref"} not $argv->{"buffer_arrayref"}
Truth table0%0/3
A and not(B)
A= defined $argv->{"buffer_arrayref"}B= not $argv->{"buffer_arrayref"}
ABresult
0X0
100
111
1735 {
1736 0 ▶ if ($argv->{buffer_fields} != 1)
Branch: 1 branch
BranchTrueFalseTotal
if ($argv->{"buffer_fields"} != 1) 0 0 0
1737 {
1738 0 $self->_setMessage("call",SQL_SIMPLE_RC_SYNTAX,"047");
1739 0 return SQL_SIMPLE_RC_SYNTAX;
1740 }
1741 0 $type=7;
1742 }
1743 0 else { $type=2; }
1744 0 ▶ undef(@{$argv->{buffer}}) if ($flush_buffer);
Branch: 1 branch
BranchTrueFalseTotal
if $flush_buffer 0 0 0
1745 }
1746 0 elsif (ref($argv->{buffer}) eq "CODE") { $type=3; }
1747 0 elsif (ref($argv->{buffer}) eq "SCALAR") { $type=4; }
1748 else
1749 {
1750 0 $self->_setMessage("call",SQL_SIMPLE_RC_SYNTAX,"024");
1751 0 return SQL_SIMPLE_RC_SYNTAX;
1752 }
1753  
1754 ## test buffer_hashkey
1755 0 ▶ if (defined($argv->{buffer_hashkey}))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $argv->{"buffer_hashkey"}) 0 0 0
1756 {
1757 0 $self->_setMessage("call",SQL_SIMPLE_RC_SYNTAX,"044");
1758 0 return SQL_SIMPLE_RC_SYNTAX;
1759 }
1760 }
1761  
1762 ## run-PreFetch if exists
1763 0 ▶ if ($self->{init}{plugin_fh} && $self->{init}{plugin_fh}->can('PreFetch') && $self->{init}{plugin_fh}->PreFetch($argv))
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"init"}{"plugin_fh"} and $self->{"init"}{"plugin_fh"}->can("PreFetch") and $self->{"init"}{"plugin_fh"}->PreFetch($argv)) 0 0 0
Condition0%0/6
$self->{"init"}{"plugin_fh"} and $self->{"init"}{"plugin_fh"}->can("PreFetch") and $self->{"init"}{"plugin_fh"}->PreFetch($argv)
!ll&&!rl&&r
000
$self->{"init"}{"plugin_fh"} and $self->{"init"}{"plugin_fh"}->can("PreFetch")
!ll&&!rl&&r
000
MC/DC0%0/3
$self->{"init"}{"plugin_fh"} and $self->{"init"}{"plugin_fh"}->can("PreFetch") and $self->{"init"}{"plugin_fh"}->PreFetch($argv)
$self->{"init"}{"plugin_fh"} $self->{"init"}{"plugin_fh"}->can("PreFetch") $self->{"init"}{"plugin_fh"}->PreFetch($argv)
Truth table0%0/4
A and B and C
A= $self->{"init"}{"plugin_fh"}B= $self->{"init"}{"plugin_fh"}->can("PreFetch")C= $self->{"init"}{"plugin_fh"}->PreFetch($argv)
ABCresult
0XX0
10X0
1100
1111
1764 {
1765 0 $self->_setMessage("prefetch",SQL_SIMPLE_RC_SYNTAX,"037",$self->{argv}{interface},$self->{argv}{driver},$self->getMessage());
1766 0 return SQL_SIMPLE_RC_SYNTAX;
1767 }
1768  
1769 ## prepare command
1770 0 $argv->{command} =~ s/^\s+|\s+$//;
1771 0 ▶ my $sth = $self->{init}{dbh}->prepare($argv->{command}.( ($argv->{command} =~ /\;$/) ? "":";") );
Branch: 1 branch
BranchTrueFalseTotal
$argv->{'command'} =~ /\;$/ ? : 0 0 0
1772  
1773 ## enforce cursor_order if not defined
1774 0 ▶ $self->{work}{cursor_order} = 1 if (!defined($self->{work}{cursor_order}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"work"}{"cursor_order"} 0 0 0
1775  
1776 ## execute command
1777 0 ▶ if (defined($sth))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $sth) { } 0 0 0
1778 {
1779 0 $sth->execute(); # send command to run
1780 0 $self->_setMessage("call"); # save the current status
1781  
1782 ## scan the fields
1783 0 ▶ if (defined($argv->{buffer}))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $argv->{"buffer"}) 0 0 0
1784 {
1785 0 ▶ if ($sth->{NUM_OF_FIELDS})
Branch: 1 branch
BranchTrueFalseTotal
if ($sth->{"NUM_OF_FIELDS"}) 0 0 0
1786 {
1787 0 $self->{init}{cursor}{first} = [];
1788 0 my $ref_saved;
1789 0 ▶ while (my $ref = $sth->fetchrow_hashref())
Branch: 1 branch
BranchTrueFalseTotal
if (my $ref = $sth->fetchrow_hashref) 0 0 0
1790 {
1791 ## get first keys elements
1792 0 ▶ if (defined($self->{work}{cursor_key}) && @{$self->{work}{cursor_key}})
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"work"}{"cursor_key"} and @{$self->{"work"}{"cursor_key"};}) 0 0 0
Condition0%0/3
defined $self->{"work"}{"cursor_key"} and @{$self->{"work"}{"cursor_key"};}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->{"work"}{"cursor_key"} and @{$self->{"work"}{"cursor_key"};}
defined $self->{"work"}{"cursor_key"} @{$self->{"work"}{"cursor_key"};}
Truth table0%0/3
A and B
A= defined $self->{"work"}{"cursor_key"}B= @{$self->{"work"}{"cursor_key"};}
ABresult
0X0
100
111
1793 {
1794 0 ▶ if (!@{$self->{init}{cursor}{first}})
Branch: 1 branch
BranchTrueFalseTotal
unless (@{$self->{"init"}{"cursor"}{"first"};}) 0 0 0
1795 {
1796 0 foreach my $key(@{$self->{work}{cursor_key}})
1797 {
1798 0 push(@{$self->{init}{cursor}{first}},$ref->{$key});
1799 }
1800 }
1801 }
1802  
1803 ## move data
1804 0 ▶ if ($type == 1) { %{$argv->{buffer}} = %{$ref}; }
Branch: 7 branches
BranchTrueFalseTotal
if ($type == 1) { } 0 0 0
elsif ($type == 2) { } 0 0 0
elsif ($type == 3) { } 0 0 0
elsif ($type == 4) { } 0 0 0
elsif ($type == 5) { } 0 0 0
elsif ($type == 6) { } 0 0 0
elsif ($type == 7) { } 0 0 0
1805 elsif ($type == 2)
1806 {
1807 0 ▶ if (!$argv->{buffer_reverse})
Branch: 1 branch
BranchTrueFalseTotal
if (not $argv->{'buffer_reverse'}) { } 0 0 0
1808 {
1809 0 ▶ ($self->{work}{cursor_order}) ? push(@{$argv->{buffer}},$ref): unshift(@{$argv->{buffer}},$ref);
Branch: 1 branch
BranchTrueFalseTotal
$self->{'work'}{'cursor_order'} ? : 0 0 0
1810 }
1811 else
1812 {
1813 0 ▶ ($self->{work}{cursor_order}) ? unshift(@{$argv->{buffer}},$ref): push(@{$argv->{buffer}},$ref);
Branch: 1 branch
BranchTrueFalseTotal
$self->{'work'}{'cursor_order'} ? : 0 0 0
1814 }
1815 }
1816 0 ▶ elsif ($type == 3) { last if (&{$argv->{buffer}}($ref,$argv->{buffer_options})); }
Branch: 1 branch
BranchTrueFalseTotal
if &{$argv->{"buffer"};}($ref, $argv->{"buffer_options"}) 0 0 0
1817 0 elsif ($type == 4) { foreach my $id(keys(%{$ref})) { ${$argv->{buffer}} = $ref->{$id}; }}
1818 elsif ($type == 5)
1819 {
1820 ## save value before remove
1821 0 my $val = $ref->{ $self->{work}{buffer_hashkey}[0] };
1822 0 ▶ $self->{work}{cursor_last_saved}{ $self->{work}{buffer_hashkey}[0] } = $val if ($self->{work}{cursor_key_vs_hashkey});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"work"}{"cursor_key_vs_hashkey"} 0 0 0
1823
1824 ## create hashindex if required
1825 0 ▶ (($self->{work}{cursor_order}) ? push(@{$argv->{buffer_hashindex}},$val) : unshift(@{$argv->{buffer_hashindex}},$val)) if (defined($argv->{buffer_hashindex}));
Branch: 2 branches
BranchTrueFalseTotal
if defined $argv->{"buffer_hashindex"} 0 0 0
$self->{'work'}{'cursor_order'} ? : 0 0 0
1826  
1827 ## remove hashkey from the data buffer
1828 0 delete($ref->{ $self->{work}{buffer_hashkey}[0] });
1829  
1830 ## move data to buffer (hashkey + 1 field data)
1831 0 ▶ if ($argv->{buffer_fields} == 2)
Branch: 1 branch
BranchTrueFalseTotal
if ($argv->{'buffer_fields'} == 2) { } 0 0 0
1832 {
1833 0 my @k = each(%{$ref});
1834 0 $argv->{buffer}->{ $val } = $ref->{$k[0]};
1835 }
1836 else
1837 {
1838 0 $argv->{buffer}->{ $val } = $ref;
1839 }
1840 }
1841 elsif ($type == 6)
1842 {
1843 0 my $addr = $argv->{buffer};
1844 0 my @keys;
1845 0 foreach my $key(@{$argv->{buffer_hashkey}})
1846 {
1847 0 ▶ if (!defined($ref->{$key}))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $ref->{$key}) 0 0 0
1848 {
1849 0 $self->_setMessage("call",SQL_SIMPLE_RC_SYNTAX,"045");
1850 0 return SQL_SIMPLE_RC_SYNTAX;
1851 }
1852
1853 ## save value before remove if match with cursor_key
1854 0 ▶ $self->{work}{cursor_last_saved}{$key} = $ref->{$key} if ($self->{work}{cursor_key_vs_hashkey});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"work"}{"cursor_key_vs_hashkey"} 0 0 0
1855
1856 ## create temporary hashindex if required
1857 0 ▶ push(@keys,$ref->{$key}) if (defined($argv->{buffer_hashindex}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $argv->{"buffer_hashindex"} 0 0 0
1858  
1859 ## switch index over index
1860 0 ▶ $addr->{$ref->{$key}} = {} if (!defined($addr->{$ref->{$key}}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $$addr{$ref->{$key}} 0 0 0
1861 0 $addr = $addr->{$ref->{$key}};
1862  
1863 ## remove hashkey from the data
1864 0 delete($ref->{$key});
1865 }
1866 ## create hashindex if required
1867 0 ▶ (($self->{work}{cursor_order}) ? push(@{$argv->{buffer_hashindex}},\@keys) : unshift(@{$argv->{buffer_hashindex}},\@keys)) if (defined($argv->{buffer_hashindex}));
Branch: 2 branches
BranchTrueFalseTotal
if defined $argv->{"buffer_hashindex"} 0 0 0
$self->{'work'}{'cursor_order'} ? : 0 0 0
1868  
1869 ## move data to buffer
1870 0 ▶ %{$addr} = (keys(%{$ref}) != 1) ? %{$ref} : $ref->{ each(%{$ref}) };
Branch: 1 branch
BranchTrueFalseTotal
keys %{$ref;} != 1 ? : 0 0 0
1871 }
1872 elsif ($type == 7)
1873 {
1874 0 my @key = keys(%{$ref});
1875 0 ▶ if (!$argv->{buffer_reverse})
Branch: 1 branch
BranchTrueFalseTotal
if (not $argv->{'buffer_reverse'}) { } 0 0 0
1876 {
1877 0 ▶ ($self->{work}{cursor_order}) ? push(@{$argv->{buffer}},$ref->{ $key[0] }) : unshift(@{$argv->{buffer}},$ref->{ $key[0] });
Branch: 1 branch
BranchTrueFalseTotal
$self->{'work'}{'cursor_order'} ? : 0 0 0
1878 }
1879 else
1880 {
1881 0 ▶ ($self->{work}{cursor_order}) ? unshift(@{$argv->{buffer}},$ref->{ $key[0] }) : push(@{$argv->{buffer}},$ref->{ $key[0] });
Branch: 1 branch
BranchTrueFalseTotal
$self->{'work'}{'cursor_order'} ? : 0 0 0
1882 }
1883 }
1884 0 $ref_saved = $ref;
1885 }
1886  
1887 ## get last keys elements
1888 0 ▶ if ($ref_saved && defined($self->{work}{cursor_key}) && @{$self->{work}{cursor_key}})
Branch: 1 branch
BranchTrueFalseTotal
if ($ref_saved and defined $self->{"work"}{"cursor_key"} and @{$self->{"work"}{"cursor_key"};}) 0 0 0
Condition0%0/6
$ref_saved and defined $self->{"work"}{"cursor_key"} and @{$self->{"work"}{"cursor_key"};}
!ll&&!rl&&r
000
$ref_saved and defined $self->{"work"}{"cursor_key"}
!ll&&!rl&&r
000
MC/DC0%0/3
$ref_saved and defined $self->{"work"}{"cursor_key"} and @{$self->{"work"}{"cursor_key"};}
$ref_saved defined $self->{"work"}{"cursor_key"} @{$self->{"work"}{"cursor_key"};}
Truth table0%0/4
A and B and C
A= $ref_savedB= defined $self->{"work"}{"cursor_key"}C= @{$self->{"work"}{"cursor_key"};}
ABCresult
0XX0
10X0
1100
1111
1889 {
1890 0 $self->{init}{cursor}{last} = [];
1891 0 foreach my $key(@{$self->{work}{cursor_key}})
1892 {
1893 0 ▶ push(@{$self->{init}{cursor}{last}},(defined($ref_saved->{$key})) ? $ref_saved->{$key} : $self->{work}{cursor_last_saved}{$key});
Branch: 1 branch
BranchTrueFalseTotal
defined $ref_saved->{$key} ? : 0 0 0
1894 }
1895 }
1896 }
1897 }
1898 0 $self->{init}{rows} = $sth->rows(); # get number of extracted lines
1899  
1900 ## close and commit (if need)
1901 0 $sth->finish();
1902 }
1903 else
1904 {
1905 0 $self->_setMessage("call");
1906 }
1907 0 undef($sth);
1908  
1909 ## force commit if required
1910 0 ▶ $self->_Commit(%{$argv}) if ($self->{argv}->{commit} && $argv->{command_type});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"argv"}{"commit"} and $argv->{"command_type"} 0 0 0
Condition0%0/3
$self->{"argv"}{"commit"} and $argv->{"command_type"}
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"argv"}{"commit"} and $argv->{"command_type"}
$self->{"argv"}{"commit"} $argv->{"command_type"}
Truth table0%0/3
A and B
A= $self->{"argv"}{"commit"}B= $argv->{"command_type"}
ABresult
0X0
100
111
1911 0 return $self->getRC();
1912 }
1913  
1914 ################################################################################
1915 ## action: commit command
1916 ## return:
1917 ## rc=0 successful
1918 ## rc>0 sql command error
1919  
1920 sub Commit()
1921 0 ▶{
Subroutine Commit: not called CC=2 SCAR=17.9
Pod undocumented
1922 0 my $self = shift;
1923 0 my $argv = {@_};
1924  
1925 0 $self->_resetSession();
1926 0 $self->_Dumper("commit",$argv);
1927  
1928 0 ▶ return SQL_SIMPLE_RC_OK if (!defined($self->{init}{dbh}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"init"}{"dbh"} 0 0 0
1929 0 return $self->_Commit(%{$argv});
1930 }
1931  
1932 sub _Commit()
1933 0 ▶{
Subroutine _Commit: not called CC=1 SCAR=6.9
1934 0 my $self = shift;
1935 0 my $argv = {@_};
1936  
1937 return $self->_Call(
1938 command => "commit",
1939 command_type => 0, # (ZERO to eliminate the LOOP)
1940 make_only => $argv->{make_only},
1941 flush => $argv->{flush},
1942 sql_save => $argv->{sql_save},
1943 0 );
1944 }
1945  
1946 ################################################################################
1947 ## action: disconnect database
1948 ## return:
1949 ## rc=0 successful
1950 ## rc>0 sql command error
1951  
1952 sub Close()
1953 2 ▶{
Subroutine Close: called CC=2 SCAR=7.0
Pod undocumented
1954 2 my $self = shift;
1955  
1956 2 ▶ return SQL_SIMPLE_RC_OK if (!defined($self->{init}{dbh}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"init"}{"dbh"} 0 2 2
1957  
1958 2 my $rc = $self->{init}{dbh}->disconnect();
1959  
1960 2 $self->_setMessage("close");
1961  
1962 2 undef($self->{init}{dbh});
1963  
1964 2 return $self->getRC();
1965 }
1966  
1967 ##############################################################################
1968 ## action: save the current sql command
1969 ## return:
1970 ## rc=0, successful
1971 ## rc=1, system error (mkdir/openfile)
1972  
1973 sub Save()
1974 1 ▶{
Subroutine Save: called CC=13 SCAR=31.0
Pod undocumented
1975 1 my $self = shift;
1976 1 my @sqls = @_;
1977  
1978 1 $self->_Dumper("save",\@sqls);
1979 1 ▶ $self->{init}{sql_save_ix} = 0 if (!defined($self->{init}{sql_save_ix}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"init"}{"sql_save_ix"} 1 0 1
1980 1 ▶ $self->{init}{sql_save_name} = "sql" if (!defined($self->{init}{sql_save_name}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"init"}{"sql_save_name"} 1 0 1
1981 $self->{init}{sql_save_dir} =
1982 (defined($self->{argv}{sql_save_dir})) ? $self->{argv}{sql_save_dir} :
1983 ($^O ne 'MSWin32') ? File::Spec->catdir("","var","spool","sql") :
1984 1 ▶ File::Spec->catdir("","windows","temp") if (!defined($self->{init}{sql_save_dir}));
Branch: 3 branches
BranchTrueFalseTotal
unless defined $self->{"init"}{"sql_save_dir"} 1 0 1
defined $self->{'argv'}{'sql_save_dir'} ? : 1 0 1
$^O ne 'MSWin32' ? : 0 0 0
1985  
1986 1 require Date::Calc;
1987 1 require File::Path;
1988 1 require IO::File;
1989  
1990 1 my $today = sprintf("%04s%02s%02s",Date::Calc::Today());
1991 my $path = ($self->{argv}{sql_save_bydate}) ?
1992 File::Spec->catdir($self->{init}{sql_save_dir},substr($today,0,4),substr($today,0,6),$today) :
1993 1 ▶ $self->{init}{sql_save_dir};
Branch: 1 branch
BranchTrueFalseTotal
$self->{'argv'}{'sql_save_bydate'} ? : 1 0 1
1994  
1995 1 ▶ if (!stat($path))
Branch: 1 branch
BranchTrueFalseTotal
unless (stat $path) 1 0 1
1996 {
1997 1 eval { &File::Path::mkpath($path); };
1998 1 ▶ if ($@)
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 1 1
1999 {
2000 0 $self->_setMessage("save",SQL_SIMPLE_RC_ERROR,"025",$@);
2001 0 ▶ return ($self->{argv}{sql_save_ignore}) ? SQL_SIMPLE_RC_OK : SQL_SIMPLE_RC_ERROR;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'argv'}{'sql_save_ignore'} ? : 0 0 0
2002 }
2003 }
2004  
2005 1 ▶ $self->{init}{sql_save_logfile} = File::Spec->catpath("", $path,$self->{init}{sql_save_name}.".".($self->{argv}{db}||"public").".".$today.".".$$.".".(++$self->{init}{sql_save_ix}));
Condition50%1/2
$self->{'argv'}{'db'} || 'public'
l!l
10
MC/DC0%0/1
$self->{'argv'}{'db'} || 'public'
$self->{'argv'}{'db'}
Truth table50%1/2
A
A= $self->{'argv'}{'db'}
Aresult
11
00
2006 1 my $fh = IO::File->new(">".$self->{init}{sql_save_logfile});
2007 1 ▶ if (!defined($fh))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $fh) 0 1 1
2008 {
2009 0 $self->_setMessage("save",SQL_SIMPLE_RC_ERROR,"026",$!);
2010 0 ▶ return ($self->{argv}{sql_save_ignore}) ? SQL_SIMPLE_RC_OK : SQL_SIMPLE_RC_ERROR;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'argv'}{'sql_save_ignore'} ? : 0 0 0
2011 }
2012  
2013 1 print $fh join("\n",@sqls),"\n";
2014 1 close($fh);
2015 1 undef($fh);
2016 1 return SQL_SIMPLE_RC_OK;
2017 }
2018  
2019 ################################################################################
2020 ## action: where clause formater, used by: select, insert, delete, update
2021 ## return:
2022 ## rc<0 syntax error
2023 ## rc=0 successful
2024  
2025 sub getWhere()
2026 47 ▶{
Subroutine getWhere: called CC=3 SCAR=11.2
Pod documented
2027  
2028 47 my $self = shift;
2029 47 my $argv = {@_};
2030  
2031 47 $self->{work}{tables_inuse} = [];
2032 47 ▶ if (ref($argv->{table}) eq "ARRAY"){ push(@{$self->{work}{tables_inuse}},@{$argv->{table}}); }
Branch: 2 branches
BranchTrueFalseTotal
if (ref $argv->{'table'} eq 'ARRAY') { } 9 38 47
elsif (ref $argv->{'table'} eq '') { } 38 0 38
2033 38 elsif (ref($argv->{table}) eq "") { push(@{$self->{work}{tables_inuse}},$argv->{table}); }
2034 else
2035 {
2036 0 $self->_setMessage("getWhere",SQL_SIMPLE_RC_SYNTAX,"006");
2037 0 return SQL_SIMPLE_RC_SYNTAX;
2038 }
2039 47 return $self->_getWhere("where",$argv->{where},$argv->{buffer});
2040 }
2041  
2042 sub _getWhere()
2043 492 ▶{
Subroutine _getWhere: called CC=3 SCAR=11.0
2044 492 my $self = shift;
2045 492 my $command = shift;
2046 492 my $where = shift;
2047 492 my $buffer = shift;
2048  
2049 ## return dummy where
2050 492 ▶ return SQL_SIMPLE_RC_OK if (!$where);
Branch: 1 branch
BranchTrueFalseTotal
unless $where 346 146 492
2051  
2052 ## format where
2053 146 my @where_local;
2054 146 ▶ return SQL_SIMPLE_RC_SYNTAX if ($self->_getWhereRecursive($command,0,$where,\@where_local));
Branch: 1 branch
BranchTrueFalseTotal
if $self->_getWhereRecursive($command, 0, $where, \@where_local) 0 146 146
2055  
2056 ## return the where clause
2057 146 ${$buffer} = join(" ",@where_local);
2058 146 return SQL_SIMPLE_RC_OK;
2059 }
2060  
2061 sub _getWhereRecursive()
2062 174 ▶{
Subroutine _getWhereRecursive: called CC=95 SCAR=52.1
2063 174 my $self = shift;
2064 174 my $command = shift;
2065 174 my $level = shift;
2066 174 my $where = shift;
2067 174 my $buffer = shift;
2068  
2069 ## return error if argvs is empty, format error
2070 174 ▶ if ($where eq "")
Branch: 1 branch
BranchTrueFalseTotal
if ($where eq "") 0 174 174
2071 {
2072 0 $self->_setMessage($command,SQL_SIMPLE_RC_SYNTAX,"020");
2073 0 return SQL_SIMPLE_RC_SYNTAX;
2074 }
2075 174 ▶ if (ref($where) eq "")
Branch: 1 branch
BranchTrueFalseTotal
if (ref $where eq "") 0 174 174
2076 {
2077 0 push(@{$buffer},$where);
2078 0 return 0;
2079 }
2080 ## return error if value1 is not array or value type
2081 174 ▶ if (ref($where) ne "ARRAY")
Branch: 1 branch
BranchTrueFalseTotal
if (ref $where ne "ARRAY") 0 174 174
2082 {
2083 0 $self->_setMessage($command,SQL_SIMPLE_RC_SYNTAX,"021");
2084 0 return SQL_SIMPLE_RC_SYNTAX;
2085 }
2086 ## format where
2087 174 my @where_tmp;
2088 174 my $oper_pend = 0;
2089 174 my $oper_text;
2090  
2091 174 ▶ for (my $ix=0; $ix < @{$where};)
Branch: 1 branch
BranchTrueFalseTotal
if ($ix < @{$where;}) 253 173 426
2092 {
2093 253 ▶ undef(@where_tmp) if (@where_tmp && join('',@where_tmp) eq '');
Branch: 1 branch
BranchTrueFalseTotal
if @where_tmp and join("", @where_tmp) eq "" 0 253 253
Condition66%2/3
@where_tmp and join("", @where_tmp) eq ""
!ll&&!rl&&r
174790
MC/DC0%0/2
@where_tmp and join("", @where_tmp) eq ""
@where_tmp join("", @where_tmp) eq ""
Truth table66%2/3
A and B
A= @where_tmpB= join("", @where_tmp) eq ""
ABresult
0X0
100
111
2094  
2095 ###############################################################
2096 ## value1
2097  
2098 253 my $value1 = $where->[$ix++];
2099  
2100 253 ▶ if (ref($value1) ne "")
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value1 ne "") 28 225 253
2101 {
2102 28 my @where_aux;
2103 28 ▶ return SQL_SIMPLE_RC_SYNTAX if ($self->_getWhereRecursive($command,$level+1,$value1,\@where_aux));
Branch: 1 branch
BranchTrueFalseTotal
if $self->_getWhereRecursive($command, $level + 1, $value1, \@where_aux) 0 28 28
2104  
2105 ## append if have valid clauses
2106 28 ▶ if (@where_aux)
Branch: 1 branch
BranchTrueFalseTotal
if (@where_aux) 28 0 28
2107 {
2108 ## valida se requer AND/OR
2109 28 ▶ push(@where_tmp,$oper_text||"AND") if ($oper_pend && @where_tmp);
Branch: 1 branch
BranchTrueFalseTotal
if $oper_pend and @where_tmp 15 13 28
Condition80%4/5
$oper_pend and @where_tmp
!ll&&!rl&&r
13015
$oper_text || 'AND'
l!l
141
MC/DC50%1/2
$oper_pend and @where_tmp
$oper_pend @where_tmp
MC/DC100%1/1
$oper_text || 'AND'
$oper_text
Truth table66%2/3
A and B
A= $oper_pendB= @where_tmp
ABresult
0X0
100
111
Truth table100%2/2
A
A= $oper_text
Aresult
11
00
2110 ## salva o where recursivo
2111 28 push(@where_tmp,join(" ",@where_aux));
2112 28 $oper_pend = 1;
2113 }
2114 28 next;
2115 }
2116  
2117 ## check and/or logical connector
2118 225 ▶ if ($value1 =~ /^(and|\&\&|or|\|\|)$/i)
Branch: 2 branches
BranchTrueFalseTotal
if ($value1 =~ /^(and|\&\&|or|\|\|)$/i) { } 16 209 225
elsif ($oper_pend != 2) { } 201 8 209
2119 {
2120 16 ▶ $oper_text = uc($value1) if ($oper_pend && @where_tmp);
Branch: 1 branch
BranchTrueFalseTotal
if $oper_pend and @where_tmp 16 0 16
Condition33%1/3
$oper_pend and @where_tmp
!ll&&!rl&&r
0016
MC/DC0%0/2
$oper_pend and @where_tmp
$oper_pend @where_tmp
Truth table33%1/3
A and B
A= $oper_pendB= @where_tmp
ABresult
0X0
100
111
2121 16 $oper_pend = 2;
2122 16 next;
2123 }
2124 201 elsif ($oper_pend != 2) { $oper_text = "AND"; }
2125  
2126 ## process value if not escape
2127 209 ▶ if (!($value1 =~ /^\\(.*)/))
Branch: 1 branch
BranchTrueFalseTotal
if (not $value1 =~ /^\\(.*)/) { } 209 0 209
2128 {
2129 ## validate functions as arguments
2130 209 ▶ if ($self->_checkFunctions(\$value1,SQL_SIMPLE_ALIAS_WHERE))
Branch: 4 branches
BranchTrueFalseTotal
if ($self->_checkFunctions(\$value1, 16)) { } 13 196 209
elsif (@{$self->{'work'}{'tables_inuse'};} == 1) { } 135 61 196
elsif ($value1 =~ /^(.*?)\.(.*?)$/ and grep(/^$1$/, @{$$self{'work'}{'tables_inuse'};}) || defined $self->{'init'}{'table_realname'}{$1}) { } 46 15 61
elsif (defined $self->{'work'}{'field_alias'}{$value1}) { } 2 13 15
2131 {}
2132 ## adjusts for single tables
2133 196 elsif (@{$self->{work}{tables_inuse}} == 1)
2134 {
2135 135 $value1 = $self->_getAliasCols(19,$value1,SQL_SIMPLE_ALIAS_WHERE);
2136 }
2137 ## adjusts for multiple tables
2138 57 ▶ elsif ($value1 =~ /^(.*?)\.(.*?)$/ && (grep(/^$1$/,@{$self->{work}{tables_inuse}}) || defined($self->{init}{table_realname}{$1})))
Condition83%5/6
$value1 =~ /^(.*?)\.(.*?)$/ and grep(/^$1$/, @{$$self{"work"}{"tables_inuse"};}) || defined $self->{"init"}{"table_realname"}{$1}
!ll&&!rl&&r
41146
grep /^$1$/, @{$$self{"work"}{"tables_inuse"};} or defined $self->{"init"}{"table_realname"}{$1}
l!l&&r!l&&!r
46011
MC/DC66%2/3
$value1 =~ /^(.*?)\.(.*?)$/ and grep(/^$1$/, @{$$self{"work"}{"tables_inuse"};}) || defined $self->{"init"}{"table_realname"}{$1}
$value1 =~ /^(.*?)\.(.*?)$/ grep /^$1$/, @{$$self{"work"}{"tables_inuse"};} defined $self->{"init"}{"table_realname"}{$1}
Truth table75%3/4
A and B or C
A= $value1 =~ /^(.*?)\.(.*?)$/B= grep /^$1$/, @{$$self{"work"}{"tables_inuse"};}C= defined $self->{"init"}{"table_realname"}{$1}
ABCresult
0XX0
1000
11X1
1011
2139 {
2140 46 $value1 = $self->_getAliasCols(20,$value1,SQL_SIMPLE_ALIAS_WHERE+SQL_SIMPLE_ALIAS_FQDN);
2141 }
2142 elsif (defined($self->{work}{field_alias}{$value1}))
2143 {
2144 2 $value1 = $self->_getAliasCols(28,$self->{work}{field_alias}{$value1},SQL_SIMPLE_ALIAS_WHERE+SQL_SIMPLE_ALIAS_FQDN);
2145 }
2146 ## others adjusts
2147 else
2148 {
2149 13 $value1 = $self->_getAliasCols(21,$value1,SQL_SIMPLE_ALIAS_WHERE);
2150 }
2151 }
2152 else
2153 {
2154 0 $value1 = $1;
2155 }
2156  
2157 ## finis where if no more values
2158 209 ▶ if ($ix >= @{$where})
Branch: 1 branch
BranchTrueFalseTotal
if ($ix >= @{$where;}) 1 208 209
2159 {
2160 1 ▶ push(@where_tmp,$oper_text||"AND") if ($oper_pend && @where_tmp);
Branch: 1 branch
BranchTrueFalseTotal
if $oper_pend and @where_tmp 1 0 1
Condition40%2/5
$oper_pend and @where_tmp
!ll&&!rl&&r
001
$oper_text || 'AND'
l!l
10
MC/DC0%0/2
$oper_pend and @where_tmp
$oper_pend @where_tmp
MC/DC0%0/1
$oper_text || 'AND'
$oper_text
Truth table33%1/3
A and B
A= $oper_pendB= @where_tmp
ABresult
0X0
100
111
Truth table50%1/2
A
A= $oper_text
Aresult
11
00
2161 1 push(@where_tmp,$value1);
2162 1 last;
2163 }
2164  
2165 ###############################################################
2166 ## value2
2167  
2168 ## test value2, if required
2169 208 my $value2 = $where->[$ix++];
2170 208 my $quote = $self->{argv}{quote};
2171  
2172 208 $oper_pend = 1;
2173  
2174 ## value2 is array, multiple values
2175 208 ▶ if (ref($value2) eq "ARRAY")
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value2 eq "ARRAY") 66 142 208
2176 {
2177 66 my @_value2 = @{$value2};
2178 66 my $value2_b = "";
2179 66 my $value2_a = "";
2180 66 my $operator = $value2->[0];
2181 66 my $where_opr = "AND";
2182  
2183 ## value0 is escaped (not operator)
2184 66 ▶ if (!defined($operator)) { $operator = "="; }
Branch: 18 branches
BranchTrueFalseTotal
if (not defined $operator) { } 6 60 66
elsif ($operator =~ /^\\/) { } 1 59 60
elsif ($operator eq '=') { } 4 55 59
elsif ($operator eq '!') { } 25 30 55
elsif ($operator eq '!=') { } 0 30 30
elsif ($operator eq '<>') { } 0 30 30
elsif ($operator eq '<=') { } 0 30 30
elsif ($operator eq '<') { } 5 25 30
elsif ($operator eq '>=') { } 5 20 25
elsif ($operator eq '>') { } 5 15 20
elsif ($operator eq '%%') { } 1 14 15
elsif ($operator eq '^%') { } 2 12 14
elsif ($operator eq '%^') { } 2 10 12
elsif ($operator eq '^^') { } 1 9 10
elsif ($operator eq '!%%') { } 0 9 9
elsif ($operator eq '!^%') { } 2 7 9
elsif ($operator eq '!%^') { } 2 5 7
elsif ($operator eq '!^^') { } 0 5 5
2185 1 elsif ($operator =~ /^\\/) { $operator = "="; }
2186 4 elsif ($operator eq "=") { shift(@_value2); }
2187 25 elsif ($operator eq "!") { shift(@_value2); $operator = "!="; }
2188 0 elsif ($operator eq "!=") { shift(@_value2); $operator = "!="; }
2189 0 elsif ($operator eq "<>") { shift(@_value2); $operator = "!="; }
2190 0 elsif ($operator eq "<=") { shift(@_value2); }
2191 5 elsif ($operator eq "<") { shift(@_value2); }
2192 5 elsif ($operator eq ">=") { shift(@_value2); }
2193 5 elsif ($operator eq ">") { shift(@_value2); }
2194 1 ▶ elsif ($operator eq "%%") { shift(@_value2); $operator = "LIKE"; $value2_b = "%"; $value2_a = "%"; $where_opr = "OR" if (@_value2 > 1); }
Branch: 1 branch
BranchTrueFalseTotal
if @_value2 > 1 0 1 1
2195 2 ▶ elsif ($operator eq "^%") { shift(@_value2); $operator = "LIKE"; $value2_b = "%"; $where_opr = "OR" if (@_value2 > 1); }
Branch: 1 branch
BranchTrueFalseTotal
if @_value2 > 1 1 1 2
2196 2 ▶ elsif ($operator eq "%^") { shift(@_value2); $operator = "LIKE"; $value2_a = "%"; $where_opr = "OR" if (@_value2 > 1); }
Branch: 1 branch
BranchTrueFalseTotal
if @_value2 > 1 1 1 2
2197 1 ▶ elsif ($operator eq "^^") { shift(@_value2); $operator = "LIKE"; $where_opr = "OR" if (@_value2 > 1); }
Branch: 1 branch
BranchTrueFalseTotal
if @_value2 > 1 0 1 1
2198 0 elsif ($operator eq "!%%") { shift(@_value2); $operator = "NOT LIKE"; $value2_b = "%"; $value2_a = "%"; }
2199 2 elsif ($operator eq "!^%") { shift(@_value2); $operator = "NOT LIKE"; $value2_b = "%"; }
2200 2 elsif ($operator eq "!%^") { shift(@_value2); $operator = "NOT LIKE"; $value2_a = "%"; }
2201 0 elsif ($operator eq "!^^") { shift(@_value2); $operator = "NOT LIKE"; }
2202 5 else { $operator = "="; }
2203  
2204 ## construct condition
2205 66 ▶ if ($operator eq "=" || $operator eq "!=")
Branch: 1 branch
BranchTrueFalseTotal
if ($operator eq "=" or $operator eq "!=") 41 25 66
Condition100%3/3
$operator eq "=" or $operator eq "!="
l!l&&r!l&&!r
162525
MC/DC100%2/2
$operator eq "=" or $operator eq "!="
$operator eq "=" $operator eq "!="
Truth table100%3/3
A or B
A= $operator eq "="B= $operator eq "!="
ABresult
1X1
011
000
2206 {
2207 41 ▶ if (@_value2 > 1)
Branch: 1 branch
BranchTrueFalseTotal
if (@_value2 > 1) 8 33 41
2208 {
2209 8 ▶ for (my $i=0; $i < @_value2; $i++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @_value2) 21 8 29
2210 {
2211 21 ▶ if (!defined($_value2[$i]))
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $_value2[$i]) { } 0 21 21
elsif ($_value2[$i] =~ /^\\(.*)/) { } 2 19 21
2212 {
2213 0 $_value2[$i] = 'NULL';
2214 }
2215 elsif ($_value2[$i] =~ /^\\(.*)/)
2216 {
2217 2 my $v = $1;
2218 2 ▶ if ($v =~ /^(\(SELECT\s+.*\))$/)
Branch: 3 branches
BranchTrueFalseTotal
if ($v =~ /^(\(SELECT\s+.*\))$/) { } 2 0 2
elsif ($v =~ /^(.*?)\..*?$/ and grep /^$1$/, @{$$self{'work'}{'tables_valids'};}) { } 0 0 0
elsif (defined $self->{'work'}{'field_alias'}{$v}) { } 0 0 0
2219 {
2220 2 $_value2[$i] = $v;
2221 }
2222 0 ▶ elsif ($v =~ /^(.*?)\..*?$/ && grep(/^$1$/,@{$self->{work}{tables_valids}}))
Condition0%0/3
$v =~ /^(.*?)\..*?$/ and grep /^$1$/, @{$$self{"work"}{"tables_valids"};}
!ll&&!rl&&r
000
MC/DC0%0/2
$v =~ /^(.*?)\..*?$/ and grep /^$1$/, @{$$self{"work"}{"tables_valids"};}
$v =~ /^(.*?)\..*?$/ grep /^$1$/, @{$$self{"work"}{"tables_valids"};}
Truth table0%0/3
A and B
A= $v =~ /^(.*?)\..*?$/B= grep /^$1$/, @{$$self{"work"}{"tables_valids"};}
ABresult
0X0
100
111
2223 {
2224 0 $_value2[$i] = $self->_getAliasCols(22,$v,SQL_SIMPLE_ALIAS_WHERE+SQL_SIMPLE_ALIAS_FQDN);
2225 }
2226 elsif (defined($self->{work}{field_alias}{$v}))
2227 {
2228 0 $_value2[$i] = $self->_getAliasCols(27,$self->{work}{field_alias}{$v},SQL_SIMPLE_ALIAS_WHERE+SQL_SIMPLE_ALIAS_FQDN);
2229 }
2230 else
2231 {
2232 0 $_value2[$i] = $v;
2233 }
2234 }
2235 else
2236 {
2237 19 $_value2[$i] = $quote.$self->_escapeQuote($_value2[$i]).$quote;
2238 }
2239 }
2240 8 $quote = "";
2241 8 ▶ my $not = ($operator eq "!=") ? " NOT" : "";
Branch: 1 branch
BranchTrueFalseTotal
$operator eq '!=' ? : 2 6 8
2242
2243 ## no _escapeQuote required, already done in value2 build
2244 8 ▶ push(@where_tmp,$oper_text||"AND") if ($oper_pend && @where_tmp);
Branch: 1 branch
BranchTrueFalseTotal
if $oper_pend and @where_tmp 1 7 8
Condition60%3/5
$oper_pend and @where_tmp
!ll&&!rl&&r
071
$oper_text || 'AND'
l!l
10
MC/DC50%1/2
$oper_pend and @where_tmp
$oper_pend @where_tmp
MC/DC0%0/1
$oper_text || 'AND'
$oper_text
Truth table66%2/3
A and B
A= $oper_pendB= @where_tmp
ABresult
0X0
100
111
Truth table50%1/2
A
A= $oper_text
Aresult
11
00
2245 8 ▶ (@_value2 == 3 && $_value2[1] eq "'..'") ?
Branch: 1 branch
BranchTrueFalseTotal
@_value2 == 3 && $_value2[1] eq q['..'] ? : 5 3 8
Condition66%2/3
@_value2 == 3 and $_value2[1] eq "'..'"
!ll&&!rl&&r
305
MC/DC50%1/2
@_value2 == 3 and $_value2[1] eq "'..'"
@_value2 == 3 $_value2[1] eq "'..'"
Truth table66%2/3
A and B
A= @_value2 == 3B= $_value2[1] eq "'..'"
ABresult
0X0
100
111
2246 push(@where_tmp,$value1.$not." BETWEEN (".$quote.$_value2[0].$quote.",".$quote.$_value2[2].$quote.")"):
2247 push(@where_tmp,$value1.$not." IN (".$quote.join("$quote,$quote",@_value2).$quote.")");
2248 8 next;
2249 }
2250 }
2251  
2252 ## multiple conditions
2253 58 my @where_aux;
2254 58 foreach my $value(@_value2)
2255 {
2256 58 ▶ if (defined($value))
Branch: 2 branches
BranchTrueFalseTotal
if (defined $value) { } 55 3 58
elsif ($operator eq '=') { } 0 3 3
2257 {
2258 55 ▶ if ($value =~ /^\\(.*)/)
Branch: 1 branch
BranchTrueFalseTotal
if ($value =~ /^\\(.*)/) { } 11 44 55
2259 {
2260 11 my $v = $1;
2261 11 ▶ if ($v =~ /^(\(SELECT\s+.*\))$/)
Branch: 3 branches
BranchTrueFalseTotal
if ($v =~ /^(\(SELECT\s+.*\))$/) { } 4 7 11
elsif ($v =~ /^(.*?)\..*?$/ and grep /^$1$/, @{$$self{'work'}{'tables_valids'};}) { } 0 7 7
elsif (defined $self->{'work'}{'field_alias'}{$v}) { } 0 7 7
2262 {
2263 0 ▶ if ($operator eq "=") { push(@where_aux,$value1." IN ".$1); }
Branch: 2 branches
BranchTrueFalseTotal
if ($operator eq '=') { } 0 4 4
elsif ($operator eq '!=') { } 4 0 4
2264 4 elsif ($operator eq "!=") { push(@where_aux,$value1." NOT IN ".$1); }
2265 0 else { push(@where_aux,$value1." ".$operator." ".$1); }
2266 }
2267 6 ▶ elsif ($v =~ /^(.*?)\..*?$/ && grep(/^$1$/,@{$self->{work}{tables_valids}}))
Condition66%2/3
$v =~ /^(.*?)\..*?$/ and grep /^$1$/, @{$$self{"work"}{"tables_valids"};}
!ll&&!rl&&r
160
MC/DC0%0/2
$v =~ /^(.*?)\..*?$/ and grep /^$1$/, @{$$self{"work"}{"tables_valids"};}
$v =~ /^(.*?)\..*?$/ grep /^$1$/, @{$$self{"work"}{"tables_valids"};}
Truth table66%2/3
A and B
A= $v =~ /^(.*?)\..*?$/B= grep /^$1$/, @{$$self{"work"}{"tables_valids"};}
ABresult
0X0
100
111
2268 {
2269 0 push(@where_aux,$value1." ".$operator." ".$self->_getAliasCols(23,$v,SQL_SIMPLE_ALIAS_WHERE+SQL_SIMPLE_ALIAS_FQDN));
2270 }
2271 elsif (defined($self->{work}{field_alias}{$v}))
2272 {
2273 0 push(@where_aux,$value1." = ".$self->_getAliasCols(26,$self->{work}{field_alias}{$v},SQL_SIMPLE_ALIAS_WHERE+SQL_SIMPLE_ALIAS_FQDN));
2274 }
2275 else
2276 {
2277 7 push(@where_aux,$value1." ".$operator." ".$v);
2278 }
2279 }
2280 else
2281 {
2282 44 push(@where_aux,$value1." ".$operator." ".$quote.$self->_escapeQuote($value2_a.$value.$value2_b).$quote);
2283 }
2284 }
2285 elsif ($operator eq "=")
2286 {
2287 0 push(@where_aux,$value1." IS NULL");
2288 }
2289 else
2290 {
2291 3 push(@where_aux,$value1." IS NOT NULL");
2292 }
2293 }
2294 58 ▶ if (@where_aux > 1)
Branch: 1 branch
BranchTrueFalseTotal
if (@where_aux > 1) 6 52 58
2295 {
2296 6 $where_aux[0] = "(".$where_aux[0];
2297 6 $where_aux[@where_aux-1] .= ")";
2298 }
2299 58 ▶ push(@where_tmp,$oper_text||"AND") if ($oper_pend && @where_tmp);
Branch: 1 branch
BranchTrueFalseTotal
if $oper_pend and @where_tmp 15 43 58
Condition60%3/5
$oper_pend and @where_tmp
!ll&&!rl&&r
04315
$oper_text || 'AND'
l!l
150
MC/DC50%1/2
$oper_pend and @where_tmp
$oper_pend @where_tmp
MC/DC0%0/1
$oper_text || 'AND'
$oper_text
Truth table66%2/3
A and B
A= $oper_pendB= @where_tmp
ABresult
0X0
100
111
Truth table50%1/2
A
A= $oper_text
Aresult
11
00
2300 58 ▶ (@where_aux) ?
Branch: 1 branch
BranchTrueFalseTotal
@where_aux ? : 52 6 58
2301 push(@where_tmp,join(" ".$where_opr." ",@where_aux)) :
2302 push(@where_tmp,$value1." IS NULL");
2303 58 next;
2304 }
2305  
2306 ## enforce operands if required
2307 142 ▶ push(@where_tmp,$oper_text||"AND") if ($oper_pend && @where_tmp);
Branch: 1 branch
BranchTrueFalseTotal
if $oper_pend and @where_tmp 31 111 142
Condition60%3/5
$oper_pend and @where_tmp
!ll&&!rl&&r
011131
$oper_text || 'AND'
l!l
310
MC/DC50%1/2
$oper_pend and @where_tmp
$oper_pend @where_tmp
MC/DC0%0/1
$oper_text || 'AND'
$oper_text
Truth table66%2/3
A and B
A= $oper_pendB= @where_tmp
ABresult
0X0
100
111
Truth table50%1/2
A
A= $oper_text
Aresult
11
00
2308  
2309 ## value2 is single value
2310 142 ▶ if (!defined($value2))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $value2) 6 136 142
2311 {
2312 6 push(@where_tmp,$value1." IS NULL");
2313 6 next;
2314 }
2315 136 ▶ if (ref($value2) eq "")
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value2 eq "") 136 0 136
2316 {
2317 136 ▶ if ($value2 =~ /^\\(.*)/)
Branch: 1 branch
BranchTrueFalseTotal
if ($value2 =~ /^\\(.*)/) { } 29 107 136
2318 {
2319 29 my $v = $1;
2320 29 ▶ if ($v =~ /^(\(SELECT\s+(.*)\))$/)
Branch: 3 branches
BranchTrueFalseTotal
if ($v =~ /^(\(SELECT\s+(.*)\))$/) { } 2 27 29
elsif ($v =~ /^(.*?)\..*?$/ and grep /^$1$/, @{$$self{'work'}{'tables_valids'};}) { } 15 12 27
elsif (defined $self->{'work'}{'field_alias'}{$v}) { } 1 11 12
2321 {
2322 2 push(@where_tmp,$value1." IN ".$1);
2323 }
2324 23 ▶ elsif ($v =~ /^(.*?)\..*?$/ && grep(/^$1$/,@{$self->{work}{tables_valids}}))
Condition100%3/3
$v =~ /^(.*?)\..*?$/ and grep /^$1$/, @{$$self{"work"}{"tables_valids"};}
!ll&&!rl&&r
4815
MC/DC100%2/2
$v =~ /^(.*?)\..*?$/ and grep /^$1$/, @{$$self{"work"}{"tables_valids"};}
$v =~ /^(.*?)\..*?$/ grep /^$1$/, @{$$self{"work"}{"tables_valids"};}
Truth table100%3/3
A and B
A= $v =~ /^(.*?)\..*?$/B= grep /^$1$/, @{$$self{"work"}{"tables_valids"};}
ABresult
0X0
100
111
2325 {
2326 15 push(@where_tmp,$value1." = ".$self->_getAliasCols(24,$v,SQL_SIMPLE_ALIAS_WHERE+SQL_SIMPLE_ALIAS_FQDN));
2327 }
2328 elsif (defined($self->{work}{field_alias}{$v}))
2329 {
2330 1 push(@where_tmp,$value1." = ".$self->_getAliasCols(25,$self->{work}{field_alias}{$v},SQL_SIMPLE_ALIAS_WHERE+SQL_SIMPLE_ALIAS_FQDN));
2331 }
2332 else
2333 {
2334 11 push(@where_tmp,$value1." = ".$v);
2335 }
2336 }
2337 else
2338 {
2339 107 push(@where_tmp,$value1." = ".$quote.$self->_escapeQuote($value2).$quote);
2340 }
2341 136 next;
2342 }
2343  
2344 ## return error if value2 is not array or value type
2345 0 $self->_setMessage($command,SQL_SIMPLE_RC_SYNTAX,"028");
2346 0 return SQL_SIMPLE_RC_SYNTAX;
2347 }
2348 174 ▶ if (@where_tmp)
Branch: 1 branch
BranchTrueFalseTotal
if (@where_tmp) 174 0 174
2349 {
2350 174 push(@{$buffer},join(" ",@where_tmp));
2351 174 ▶ if ($level && @where_tmp > 1)
Branch: 1 branch
BranchTrueFalseTotal
if ($level and @where_tmp > 1) 16 158 174
Condition100%3/3
$level and @where_tmp > 1
!ll&&!rl&&r
1461216
MC/DC100%2/2
$level and @where_tmp > 1
$level @where_tmp > 1
Truth table100%3/3
A and B
A= $levelB= @where_tmp > 1
ABresult
0X0
100
111
2352 {
2353 16 $buffer->[0] = "(".$buffer->[0];
2354 16 $buffer->[@{$buffer}-1] .= ")";
2355 }
2356 }
2357 174 return 0;
2358 }
2359  
2360 ##############################################################################
2361 ## action: get dbh entry point module
2362 ## return: current dbi drive pointer module
2363  
2364 sub getDBH()
2365 0 ▶{
Subroutine getDBH: not called CC=1 SCAR=6.9
Pod documented
2366 0 return $_[0]->{init}{dbh};
2367 }
2368  
2369 ##############################################################################
2370 ## action: get last condition state
2371 ## return: last return code state
2372  
2373 sub getRC()
2374 576 ▶{
Subroutine getRC: called CC=1 SCAR=0.0
Pod documented
2375 576 return $err;
2376 }
2377  
2378 ##############################################################################
2379 ## action: get last message state
2380 ## return: last system message
2381  
2382 sub getMessage()
2383 17 ▶{
Subroutine getMessage: called CC=1 SCAR=0.0
Pod documented
2384 17 return $errstr;
2385 }
2386  
2387 ##############################################################################
2388 ## action: get number of extracted lines
2389 ## return: number of extracted lines
2390  
2391 sub getRows()
2392 0 ▶{
Subroutine getRows: not called CC=1 SCAR=6.9
Pod documented
2393 0 return $_[0]->{init}{rows};
2394 }
2395  
2396 ##############################################################################
2397 ## action: get the last sql command
2398 ## return: last sql command
2399  
2400 sub getLastSQL()
2401 289 ▶{
Subroutine getLastSQL: called CC=1 SCAR=0.0
Pod documented
2402 289 return $_[0]->{init}{sql_command};
2403 }
2404  
2405 ##############################################################################
2406 ## action: get the last cursor pointer
2407 ## return: cursor pointer
2408  
2409 sub getLastCursor()
2410 0 ▶{
Subroutine getLastCursor: not called CC=1 SCAR=6.9
Pod documented
2411 0 my $self = shift;
2412 0 return %{$self->{init}{cursor}};
2413 }
2414  
2415 ##############################################################################
2416 ## action: get the last saved fileset
2417 ## return: last sql logfile
2418  
2419 sub getLastSave()
2420 1 ▶{
Subroutine getLastSave: called CC=1 SCAR=0.0
Pod documented
2421 1 return $_[0]->{init}{sql_save_logfile};
2422 }
2423  
2424 ##############################################################################
2425 ## action: get the table's realname
2426 ## return: name of the table
2427  
2428 sub getAliasTable()
2429 0 ▶{
Subroutine getAliasTable: not called CC=1 SCAR=6.9
Pod documented
2430 0 my $self = shift;
2431 0 return $self->_getAliasTable(@_,{schema=>$self->{init}{schema}});
2432 }
2433  
2434 sub _getAliasTable()
2435 312 ▶{
Subroutine _getAliasTable: called CC=2 SCAR=6.9
2436 312 my $self = shift;
2437 312 my $table = shift;
2438 312 my $argv = shift;
2439  
2440 312 ▶ return $self->_getSchemaName($argv).$table." ".$self->{work}{tables_alias}{$table} if (defined($self->{work}{tables_alias}{$table}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"work"}{"tables_alias"}{$table} 205 107 312
2441 107 return $self->_getSchemaName($argv).$table;
2442 }
2443  
2444 ##############################################################################
2445 ## action: get the schema name if required
2446 ## return: name of the schema
2447  
2448 sub _getSchemaName()
2449 349 ▶{
Subroutine _getSchemaName: called CC=6 SCAR=22.1
2450 349 my $self = shift;
2451 349 my $argv = shift;
2452  
2453 349 ▶ return $argv->{schema}."." if (defined($argv->{schema}) && $argv->{schema} ne "");
Branch: 1 branch
BranchTrueFalseTotal
if defined $argv->{"schema"} and $argv->{"schema"} ne "" 0 349 349
Condition33%1/3
defined $argv->{"schema"} and $argv->{"schema"} ne ""
!ll&&!rl&&r
34900
MC/DC0%0/2
defined $argv->{"schema"} and $argv->{"schema"} ne ""
defined $argv->{"schema"} $argv->{"schema"} ne ""
Truth table33%1/3
A and B
A= defined $argv->{"schema"}B= $argv->{"schema"} ne ""
ABresult
0X0
100
111
2454 349 ▶ return $self->{argv}{schema}."." if (defined($self->{argv}{schema}) && $self->{argv}{schema} ne "" && $self->{init}{schema});
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"argv"}{"schema"} and $self->{"argv"}{"schema"} ne "" and $self->{"init"}{"schema"} 0 349 349
Condition33%2/6
defined $self->{"argv"}{"schema"} and $self->{"argv"}{"schema"} ne "" and $self->{"init"}{"schema"}
!ll&&!rl&&r
34900
defined $self->{"argv"}{"schema"} and $self->{"argv"}{"schema"} ne ""
!ll&&!rl&&r
34900
MC/DC0%0/3
defined $self->{"argv"}{"schema"} and $self->{"argv"}{"schema"} ne "" and $self->{"init"}{"schema"}
defined $self->{"argv"}{"schema"} $self->{"argv"}{"schema"} ne "" $self->{"init"}{"schema"}
Truth table25%1/4
A and B and C
A= defined $self->{"argv"}{"schema"}B= $self->{"argv"}{"schema"} ne ""C= $self->{"init"}{"schema"}
ABCresult
0XX0
10X0
1100
1111
2455 349 return "";
2456 }
2457  
2458 ##############################################################################
2459 ## action: get the table's realname
2460 ## return: name of the table
2461  
2462 sub getAliasCols()
2463 0 ▶{
Subroutine getAliasCols: not called CC=1 SCAR=6.9
Pod documented
2464 0 my $self = shift;
2465 0 return $self->_getAliasCols(0,@_);
2466 }
2467  
2468 ##############################################################################
2469 # 0x01 - return col_real wo/table
2470  
2471 sub _getAliasCols()
2472 660 ▶{
Subroutine _getAliasCols: called CC=26 SCAR=32.6
2473 660 my $self = shift;
2474 660 my $mycall = shift;
2475 660 my $field = shift;
2476 660 my $result = shift;
2477  
2478 660 my $_table;
2479 my $_field;
2480  
2481 ## enforce prefered aliases if defined
2482 660 ▶ $field = $self->{work}{field_alias}{$field} if (defined($self->{work}{field_alias}{$field}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"work"}{"field_alias"}{$field} 6 654 660
2483  
2484 ## field have ident?
2485 660 ▶ if ($field =~ /^(.*?)\.(.*?)$/)
Branch: 1 branch
BranchTrueFalseTotal
if ($field =~ /^(.*?)\.(.*?)$/) { } 306 354 660
2486 {
2487 306 $_table = $1;
2488 306 $_field = $2;
2489 306 ▶ if (defined($self->{work}{field_cols}))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"work"}{"field_cols"}) 78 228 306
2490 {
2491 78 ▶ if (defined($self->{work}{field_cols}{$_table}))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'work'}{'field_cols'}{$_table}) { } 66 12 78
2492 {
2493 66 ▶ if (defined($self->{work}{field_cols}{$_table}{$_field}))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"work"}{"field_cols"}{$_table}{$_field}) 4 62 66
2494 {
2495 4 $_field = $self->{work}{field_cols}{$_table}{$_field};
2496 }
2497 }
2498 else
2499 {
2500 12 ▶ if (defined($self->{work}{tables_alias}{$_table}))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"work"}{"tables_alias"}{$_table}) 6 6 12
2501 {
2502 6 my $a = $self->{work}{tables_alias}{$_table};
2503 6 ▶ if (defined($self->{work}{field_cols}{$a}))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"work"}{"field_cols"}{$a}) 6 0 6
2504 {
2505 6 ▶ if (defined($self->{work}{field_cols}{$a}{$_field}))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"work"}{"field_cols"}{$a}{$_field}) 2 4 6
2506 {
2507 2 $_field = $self->{work}{field_cols}{$a}{$_field};
2508 }
2509 }
2510 }
2511 }
2512  
2513 }
2514 306 ▶ if (!grep(/^$_table$/,@{$self->{work}{tables_inuse}}))
Branch: 1 branch
BranchTrueFalseTotal
unless (grep /^$_table$/, @{$$self{"work"}{"tables_inuse"};}) 104 202 306
2515 {
2516 104 ▶ return $field if (!defined($self->{argv}{tables}) || !defined($self->{argv}{tables}{$_table}));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"argv"}{"tables"} and defined $self->{"argv"}{"tables"}{$_table} 10 94 104
Condition66%2/3
defined $self->{"argv"}{"tables"} and defined $self->{"argv"}{"tables"}{$_table}
!ll&&!rl&&r
01094
MC/DC50%1/2
defined $self->{"argv"}{"tables"} and defined $self->{"argv"}{"tables"}{$_table}
defined $self->{"argv"}{"tables"} defined $self->{"argv"}{"tables"}{$_table}
Truth table66%2/3
A and B
A= defined $self->{"argv"}{"tables"}B= defined $self->{"argv"}{"tables"}{$_table}
ABresult
0X0
100
111
2517 94 $_table = $self->{argv}{tables}{$_table}{name};
2518 }
2519 296 ▶ $_field = $self->{argv}{tables}{ $self->{work}{tables_alias}{$_table} }{cols}{$_field} if (defined($self->{argv}{tables}) && defined($self->{work}{tables_alias}{$_table}) && defined($self->{argv}{tables}{ $self->{work}{tables_alias}{$_table} }{cols}{$_field}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"argv"}{"tables"} and defined $self->{"work"}{"tables_alias"}{$_table} and defined $self->{"argv"}{"tables"}{$self->{"work"}{"tables_alias"}{$_table}}{"cols"}{$_field} 124 172 296
Condition100%6/6
defined $self->{"argv"}{"tables"} and defined $self->{"work"}{"tables_alias"}{$_table} and defined $self->{"argv"}{"tables"}{$self->{"work"}{"tables_alias"}{$_table}}{"cols"}{$_field}
!ll&&!rl&&r
14527124
defined $self->{"argv"}{"tables"} and defined $self->{"work"}{"tables_alias"}{$_table}
!ll&&!rl&&r
7174151
MC/DC100%3/3
defined $self->{"argv"}{"tables"} and defined $self->{"work"}{"tables_alias"}{$_table} and defined $self->{"argv"}{"tables"}{$self->{"work"}{"tables_alias"}{$_table}}{"cols"}{$_field}
defined $self->{"argv"}{"tables"} defined $self->{"work"}{"tables_alias"}{$_table} defined $self->{"argv"}{"tables"}{$self->{"work"}{"tables_alias"}{$_table}}{"cols"}{$_field}
Truth table100%4/4
A and B and C
A= defined $self->{"argv"}{"tables"}B= defined $self->{"work"}{"tables_alias"}{$_table}C= defined $self->{"argv"}{"tables"}{$self->{"work"}{"tables_alias"}{$_table}}{"cols"}{$_field}
ABCresult
0XX0
10X0
1100
1111
2520 296 ▶ $result |= SQL_SIMPLE_ALIAS_FQDN if (@{$self->{work}{tables_inuse}} != 1);
Branch: 1 branch
BranchTrueFalseTotal
if @{$self->{"work"}{"tables_inuse"};} != 1 212 84 296
2521 }
2522 else
2523 {
2524 354 $_field = $field;
2525  
2526 ## single table in use?
2527 354 ▶ if (@{$self->{work}{tables_inuse}} == 1)
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->{'work'}{'tables_inuse'};} == 1) { } 318 36 354
2528 {
2529 318 $_table = $self->{work}{tables_inuse}[0];
2530 318 ▶ $_field = $self->{argv}{tables}{ $self->{work}{tables_alias}{$_table} }{cols}{$_field} if (defined($self->{work}{tables_alias}{$_table}) && defined($self->{argv}{tables}{ $self->{work}{tables_alias}{$_table} }{cols}{$_field}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"work"}{"tables_alias"}{$_table} and defined $self->{"argv"}{"tables"}{$self->{"work"}{"tables_alias"}{$_table}}{"cols"}{$_field} 117 201 318
Condition100%3/3
defined $self->{"work"}{"tables_alias"}{$_table} and defined $self->{"argv"}{"tables"}{$self->{"work"}{"tables_alias"}{$_table}}{"cols"}{$_field}
!ll&&!rl&&r
17526117
MC/DC100%2/2
defined $self->{"work"}{"tables_alias"}{$_table} and defined $self->{"argv"}{"tables"}{$self->{"work"}{"tables_alias"}{$_table}}{"cols"}{$_field}
defined $self->{"work"}{"tables_alias"}{$_table} defined $self->{"argv"}{"tables"}{$self->{"work"}{"tables_alias"}{$_table}}{"cols"}{$_field}
Truth table100%3/3
A and B
A= defined $self->{"work"}{"tables_alias"}{$_table}B= defined $self->{"argv"}{"tables"}{$self->{"work"}{"tables_alias"}{$_table}}{"cols"}{$_field}
ABresult
0X0
100
111
2531 }
2532
2533 ## scan contents
2534 else
2535 {
2536 36 foreach my $t(@{$self->{work}{tables_inuse}})
2537 {
2538 ## ignore table if field not found
2539 72 ▶ next if ( defined($self->{work}{tables_alias}{$t}) && !defined($self->{argv}{tables}{ $self->{work}{tables_alias}{$t} }{cols}{$_field}) );
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"work"}{"tables_alias"}{$t} and not defined $self->{"argv"}{"tables"}{$self->{"work"}{"tables_alias"}{$t}}{"cols"}{$_field} 16 56 72
Condition100%3/3
defined $self->{"work"}{"tables_alias"}{$t} and not defined $self->{"argv"}{"tables"}{$self->{"work"}{"tables_alias"}{$t}}{"cols"}{$_field}
!ll&&!rl&&r
243216
MC/DC100%2/2
defined $self->{"work"}{"tables_alias"}{$t} and not defined $self->{"argv"}{"tables"}{$self->{"work"}{"tables_alias"}{$t}}{"cols"}{$_field}
defined $self->{"work"}{"tables_alias"}{$t} not defined $self->{"argv"}{"tables"}{$self->{"work"}{"tables_alias"}{$t}}{"cols"}{$_field}
Truth table100%3/3
A and not(B)
A= defined $self->{"work"}{"tables_alias"}{$t}B= not defined $self->{"argv"}{"tables"}{$self->{"work"}{"tables_alias"}{$t}}{"cols"}{$_field}
ABresult
0X0
100
111
2540  
2541 ## returns field as is if duplicated
2542 56 ▶ return $field if ($_table);
Branch: 1 branch
BranchTrueFalseTotal
if $_table 28 28 56
2543  
2544 ## define the table by alias
2545 28 $_table = $t;
2546 }
2547 }
2548 }
2549 622 ▶ if ($_table && $result & SQL_SIMPLE_ALIAS_FQDN)
Branch: 1 branch
BranchTrueFalseTotal
if ($_table and $result & 32768) 232 390 622
Condition100%3/3
$_table and $result & 32768
!ll&&!rl&&r
8382232
MC/DC100%2/2
$_table and $result & 32768
$_table $result & 32768
Truth table100%3/3
A and B
A= $_tableB= $result & 32768
ABresult
0X0
100
111
2550 {
2551 232 ▶ $_table = $self->{work}{tables_alias}{$_table} if (defined($self->{work}{tables_alias}{$_table}));
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"work"}{"tables_alias"}{$_table} 118 114 232
2552 232 return $_table.".".$_field;
2553 }
2554 390 return $_field;
2555 }
2556  
2557 ################################################################################
2558 ## action: validate functions and convert the fields named
2559  
2560 sub _checkFunctions()
2561 260 ▶{
Subroutine _checkFunctions: called CC=9 SCAR=22.0
2562 260 my $self = shift;
2563 260 my $value1 = shift;
2564 260 my $result = shift;
2565  
2566 ## test if value is function
2567 260 my $fnc;
2568 260 my $op1 = ${$value1};
2569 260 my $op2 = '';
2570 260 my $lvl;
2571 260 ▶ while (($op1 =~ /^(.*?)\((.*)\)(.*)\)$/) || ($op1 =~ /^(.*?)\((.*)\)$/))
Branch: 1 branch
BranchTrueFalseTotal
if ($op1 =~ /^(.*?)\((.*)\)(.*)\)$/ or $op1 =~ /^(.*?)\((.*)\)$/) 15 260 275
Condition100%3/3
$op1 =~ /^(.*?)\((.*)\)(.*)\)$/ or $op1 =~ /^(.*?)\((.*)\)$/
l!l&&r!l&&!r
213260
MC/DC100%2/2
$op1 =~ /^(.*?)\((.*)\)(.*)\)$/ or $op1 =~ /^(.*?)\((.*)\)$/
$op1 =~ /^(.*?)\((.*)\)(.*)\)$/ $op1 =~ /^(.*?)\((.*)\)$/
Truth table100%3/3
A or B
A= $op1 =~ /^(.*?)\((.*)\)(.*)\)$/B= $op1 =~ /^(.*?)\((.*)\)$/
ABresult
1X1
011
000
2572 {
2573 15 $lvl++;
2574 15 $fnc .= $1."(";
2575 15 ▶ $op1 = $2.((defined($3)) ? ")" : "");
Branch: 1 branch
BranchTrueFalseTotal
defined $3 ? : 2 13 15
2576 15 ▶ $op2 .= (defined($3)) ? ")".$3 : ")";
Branch: 1 branch
BranchTrueFalseTotal
defined $3 ? : 2 13 15
2577 }
2578  
2579 ## process functions if mapped
2580 260 ▶ if ($lvl)
Branch: 1 branch
BranchTrueFalseTotal
if ($lvl) 13 247 260
2581 {
2582 13 ▶ if ($op1 =~ /^(.*?)\,(.*)$/)
Branch: 1 branch
BranchTrueFalseTotal
if ($op1 =~ /^(.*?)\,(.*)$/) { } 2 11 13
2583 {
2584 2 my $o1 = $1;
2585 2 my $o2 = $2;
2586 2 ▶ if ($o1 =~ /^.*?\..*?$/)
Branch: 1 branch
BranchTrueFalseTotal
if ($o1 =~ /^.*?\..*?$/) { } 0 2 2
2587 {
2588 0 $op1 = $self->_getAliasCols(15,$o1,$result+SQL_SIMPLE_ALIAS_FQDN);
2589 }
2590 else
2591 {
2592 2 $op1 = $self->_getAliasCols(16,$o1,$result);
2593 }
2594 2 $op1 .= ",".$o2;
2595 }
2596 else
2597 {
2598 11 ▶ if ($op1 =~ /^.*?\..*?$/)
Branch: 1 branch
BranchTrueFalseTotal
if ($op1 =~ /^.*?\..*?$/) { } 2 9 11
2599 {
2600 2 $op1 = $self->_getAliasCols(17,$op1,$result+SQL_SIMPLE_ALIAS_FQDN);
2601 }
2602 else
2603 {
2604 9 $op1 = $self->_getAliasCols(18,$op1,$result);
2605 }
2606 }
2607 13 ${$value1} = $fnc.$op1.$op2;
2608 }
2609 260 return $lvl;
2610 }
2611  
2612 ################################################################################
2613 ## action: test the argv->{table} and create the tables_inuse list
2614  
2615 sub _checkTablesEntries()
2616 289 ▶{
Subroutine _checkTablesEntries: called CC=13 SCAR=27.4
2617 289 my $self = shift;
2618 289 my $cmnd = shift;
2619 289 my $argv = shift;
2620  
2621 ## tables is missing?
2622 289 ▶ if (!defined($argv->{table}))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $argv->{"table"}) 0 289 289
2623 {
2624 0 $self->_setMessage($cmnd,SQL_SIMPLE_RC_SYNTAX,"005");
2625 0 return SQL_SIMPLE_RC_SYNTAX;
2626 }
2627  
2628 ## validate tables
2629 289 my $tables_work;
2630 289 ▶ if (ref($argv->{table}) eq "")
Branch: 2 branches
BranchTrueFalseTotal
if (ref $argv->{'table'} eq '') { } 203 86 289
elsif (ref $argv->{'table'} eq 'ARRAY' and $self->{'work'}{'command'} == 8 || $self->{'work'}{'command'} == 2) { } 86 0 86
2631 {
2632 203 $tables_work = [$argv->{table}];
2633 }
2634 ▶ elsif (ref($argv->{table}) eq "ARRAY" && ($self->{work}{command} == SQL_SIMPLE_ALIAS_SELECT || $self->{work}{command} == SQL_SIMPLE_ALIAS_UPDATE))
Condition50%3/6
ref $argv->{"table"} eq "ARRAY" and $self->{"work"}{"command"} == 8 || $self->{"work"}{"command"} == 2
!ll&&!rl&&r
0086
$self->{"work"}{"command"} == 8 or $self->{"work"}{"command"} == 2
l!l&&r!l&&!r
75110
MC/DC0%0/3
ref $argv->{"table"} eq "ARRAY" and $self->{"work"}{"command"} == 8 || $self->{"work"}{"command"} == 2
ref $argv->{"table"} eq "ARRAY" $self->{"work"}{"command"} == 8 $self->{"work"}{"command"} == 2
Truth table50%2/4
A and B or C
A= ref $argv->{"table"} eq "ARRAY"B= $self->{"work"}{"command"} == 8C= $self->{"work"}{"command"} == 2
ABCresult
0XX0
1000
11X1
1011
2635 {
2636 86 $tables_work = $argv->{table};
2637 }
2638 else
2639 {
2640 0 $self->_setMessage($cmnd,SQL_SIMPLE_RC_SYNTAX,"006");
2641 0 return SQL_SIMPLE_RC_SYNTAX;
2642 }
2643  
2644 ## assign table as in use
2645 289 $self->{work}{tables_valids} = [];
2646 289 foreach my $table(@{$tables_work})
2647 {
2648 375 ▶ if (grep(/^$table$/,@{$self->{work}{tables_inuse}}))
Branch: 1 branch
BranchTrueFalseTotal
if (grep /^$table$/, @{$$self{"work"}{"tables_inuse"};}) 0 375 375
2649 {
2650 0 $self->_setMessage($cmnd,SQL_SIMPLE_RC_SYNTAX,"033",$table);
2651 0 return SQL_SIMPLE_RC_SYNTAX;
2652 }
2653 375 ▶ if (defined($self->{argv}{tables}))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"argv"}{"tables"}) 313 62 375
2654 {
2655 ## defined as alias in content tables?
2656 313 ▶ if (defined($self->{argv}{tables}{$table}) && defined($self->{argv}{tables}{$table}{name}))
Branch: 2 branches
BranchTrueFalseTotal
if (defined $self->{'argv'}{'tables'}{$table} and defined $self->{'argv'}{'tables'}{$table}{'name'}) { } 163 150 313
elsif (defined $self->{'init'}{'table_realname'}{$table}) { } 70 80 150
Condition66%2/3
defined $self->{"argv"}{"tables"}{$table} and defined $self->{"argv"}{"tables"}{$table}{"name"}
!ll&&!rl&&r
1500163
MC/DC50%1/2
defined $self->{"argv"}{"tables"}{$table} and defined $self->{"argv"}{"tables"}{$table}{"name"}
defined $self->{"argv"}{"tables"}{$table} defined $self->{"argv"}{"tables"}{$table}{"name"}
Truth table66%2/3
A and B
A= defined $self->{"argv"}{"tables"}{$table}B= defined $self->{"argv"}{"tables"}{$table}{"name"}
ABresult
0X0
100
111
2657 {
2658 163 my $realname = $self->{argv}{tables}{$table}{name};
2659 163 ▶ if (defined($self->{work}{tables_alias}{$realname}))
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"work"}{"tables_alias"}{$realname}) 0 163 163
2660 {
2661 0 $self->_setMessage($cmnd,SQL_SIMPLE_RC_SYNTAX,"033",$table);
2662 0 return SQL_SIMPLE_RC_SYNTAX;
2663 }
2664 163 push(@{$self->{work}{tables_inuse}},$realname);
2665 163 $self->{work}{tables_alias}{$realname} = $table;
2666 163 push(@{$self->{work}{tables_valids}},$table);
2667 163 next;
2668 }
2669 elsif (defined($self->{init}{table_realname}{$table}))
2670 {
2671 70 $self->{work}{tables_alias}{$table} = $self->{init}{table_realname}{$table};
2672 70 push(@{$self->{work}{tables_valids}},$self->{init}{table_realname}{$table});
2673 }
2674 }
2675 212 push(@{$self->{work}{tables_inuse}},$table);
2676 }
2677 289 push(@{$self->{work}{tables_valids}},@{$self->{work}{tables_inuse}});
2678 289 return SQL_SIMPLE_RC_OK;
2679 }
2680  
2681 ################################################################################
2682 ## action: set last command sql
2683 ## return: none
2684  
2685 sub _setLastSQL()
2686 563 ▶{
Subroutine _setLastSQL: called CC=1 SCAR=0.0
2687 563 $_[0]->{init}{sql_command} = $_[1];
2688 }
2689  
2690 ################################################################################
2691 ## action: set commit
2692 ## return: old commit
2693  
2694 sub _setCommit()
2695 0 ▶{
Subroutine _setCommit: not called CC=2 SCAR=17.9
2696 0 my $self = shift;
2697 0 my $save = $self->{argv}{commit};
2698 0 ▶ $self->{argv}{commit} = shift || 0;
Condition0%0/2
shift() || 0
l!l
00
MC/DC0%0/1
shift() || 0
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
2699 0 return $save;
2700 }
2701  
2702 ################################################################################
2703 ## action: set message_log
2704 ## return: old message_log
2705  
2706 sub _setLogMessage()
2707 0 ▶{
Subroutine _setLogMessage: not called CC=2 SCAR=17.9
2708 0 my $self = shift;
2709 0 my $save = $self->{argv}{message_log};
2710 0 ▶ $self->{argv}{message_log} = shift || 0 ;
Condition0%0/2
shift() || 0
l!l
00
MC/DC0%0/1
shift() || 0
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
2711 0 return $save;
2712 }
2713  
2714 ################################################################################
2715 ## action: set sql_save
2716 ## return: old sql_save
2717  
2718 sub _setSqlSave()
2719 2 ▶{
Subroutine _setSqlSave: called CC=2 SCAR=6.9
2720 2 my $self = shift;
2721 2 my $save = $self->{argv}{sql_save};
2722 2 ▶ $self->{argv}{sql_save} = shift || 0;
Condition100%2/2
shift() || 0
l!l
11
MC/DC100%1/1
shift() || 0
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
2723 2 return $save;
2724 }
2725  
2726 ################################################################################
2727 ## action: set quote character
2728 ## return: old quote chacracter
2729  
2730 sub _setQuote()
2731 0 ▶{
Subroutine _setQuote: not called CC=5 SCAR=34.0
2732 0 my $self = shift;
2733 0 my $quote = shift;
2734 0 my $save = $self->{argv}{quote};
2735 0 ▶ $self->{argv}{quote} = $quote || "'" if ($quote eq "" || $quote eq '"' || $quote eq "'");
Branch: 1 branch
BranchTrueFalseTotal
if $quote eq "" or $quote eq "\"" or $quote eq "'" 0 0 0
Condition0%0/8
$quote eq "" or $quote eq "\"" or $quote eq "'"
l!l&&r!l&&!r
000
$quote eq "" or $quote eq "\""
l!l&&r!l&&!r
000
$quote || q[']
l!l
00
MC/DC0%0/3
$quote eq "" or $quote eq "\"" or $quote eq "'"
$quote eq "" $quote eq "\"" $quote eq "'"
MC/DC0%0/1
$quote || q[']
$quote
Truth table0%0/4
A or B or C
A= $quote eq ""B= $quote eq "\""C= $quote eq "'"
ABCresult
1XX1
01X1
0011
0000
Truth table0%0/2
A
A= $quote
Aresult
11
00
2736 0 return $save;
2737 }
2738  
2739 ################################################################################
2740 ## action: escape quote in string
2741 ## return: string with escape (if exists)
2742  
2743 sub _escapeQuote()
2744 250 ▶{
Subroutine _escapeQuote: called CC=2 SCAR=7.0
2745 250 my $self = shift;
2746 250 my $value = shift;
2747
2748 ## return if not quote
2749 250 ▶ return $value if ($self->{argv}{quote} eq "");
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"argv"}{"quote"} eq "" 0 250 250
2750
2751 ## escape and return
2752 250 $value =~ s/$self->{argv}{quote}/\\$self->{argv}{quote}/g;
2753 250 return $value;
2754 }
2755  
2756 ################################################################################
2757 ## action: cleanup the last session call
2758 ## return: return code
2759  
2760 sub _resetSession()
2761 291 ▶{
Subroutine _resetSession: called CC=1 SCAR=0.0
2762 291 my $self = shift;
2763 291 $err = 0;
2764 291 $errstr = "";
2765 291 $self->_setLastSQL("");
2766 291 delete ($self->{work});
2767 291 $self->{work} = {};
2768 }
2769  
2770 ################################################################################
2771 ## action: set message state
2772 ## return: return code
2773  
2774 sub _setMessage()
2775 21 ▶{
Subroutine _setMessage: called CC=16 SCAR=42.4
2776 21 my $self = shift;
2777 21 my $command = shift;
2778 21 my $rc = shift;
2779 21 my $code = shift;
2780 21 my @argv = @_;
2781  
2782 21 ▶ if (!defined($rc))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $rc) 4 17 21
2783 {
2784 4 ▶ return $self->_setMessage($command,$self->{init}{dbh}->err+0,"099",'dbh['.$self->{init}{dbh}->errstr().']') if (defined($self->{init}{dbh}) && $self->{init}{dbh}->err);
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"init"}{"dbh"} and $self->{"init"}{"dbh"}->err 0 4 4
Condition33%1/3
defined $self->{"init"}{"dbh"} and $self->{"init"}{"dbh"}->err
!ll&&!rl&&r
040
MC/DC0%0/2
defined $self->{"init"}{"dbh"} and $self->{"init"}{"dbh"}->err
defined $self->{"init"}{"dbh"} $self->{"init"}{"dbh"}->err
Truth table33%1/3
A and B
A= defined $self->{"init"}{"dbh"}B= $self->{"init"}{"dbh"}->err
ABresult
0X0
100
111
2785 4 ▶ return $self->_setMessage($command,$DBI::err+0,"099",'dbi['.$DBI::errstr.']') if ($DBI::err);
Branch: 1 branch
BranchTrueFalseTotal
if $DBI::err 0 4 4
2786  
2787 4 $err = 0;
2788 4 $errstr = "";
2789 4 return $err;
2790 }
2791  
2792 17 $err = $rc;
2793 $errstr = (defined($SQL_SIMPLE_TABLE_OF_MSGS{$code})) ?
2794 17 ▶ $code.$SQL_SIMPLE_TABLE_OF_MSGS{$code}{T}." ".sprintf($SQL_SIMPLE_TABLE_OF_MSGS{$code}{M},$command,@argv) :
Branch: 1 branch
BranchTrueFalseTotal
defined $SQL::SimpleOps::SQL_SIMPLE_TABLE_OF_MSGS{$code} ? : 17 0 17
2795 "999S [message] invalid message code '$code'";
2796  
2797 17 ▶ if ($self->{argv}{message_log})
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"argv"}{"message_log"}) 0 17 17
2798 {
2799 print STDERR $errstr."\n" if ($self->{argv}{message_log} & SQL_SIMPLE_LOG_STD &&
2800 0 ▶ ($SQL_SIMPLE_TABLE_OF_MSGS{$code}{T} ne "W" || !$self->{argv}{message_warning_off}));
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"argv"}{"message_log"} & 2 and $SQL::SimpleOps::SQL_SIMPLE_TABLE_OF_MSGS{$code}{"T"} ne "W" || !$self->{"argv"}{"message_warning_off"} 0 0 0
Condition0%0/6
$self->{"argv"}{"message_log"} & 2 and $SQL::SimpleOps::SQL_SIMPLE_TABLE_OF_MSGS{$code}{"T"} ne "W" || !$self->{"argv"}{"message_warning_off"}
!ll&&!rl&&r
000
$SQL::SimpleOps::SQL_SIMPLE_TABLE_OF_MSGS{$code}{"T"} ne "W" or not $self->{"argv"}{"message_warning_off"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$self->{"argv"}{"message_log"} & 2 and $SQL::SimpleOps::SQL_SIMPLE_TABLE_OF_MSGS{$code}{"T"} ne "W" || !$self->{"argv"}{"message_warning_off"}
$self->{"argv"}{"message_log"} & 2 $SQL::SimpleOps::SQL_SIMPLE_TABLE_OF_MSGS{$code}{"T"} ne "W" not $self->{"argv"}{"message_warning_off"}
Truth table0%0/4
A and B or not(C)
A= $self->{"argv"}{"message_log"} & 2B= $SQL::SimpleOps::SQL_SIMPLE_TABLE_OF_MSGS{$code}{"T"} ne "W"C= not $self->{"argv"}{"message_warning_off"}
ABCresult
0XX0
1000
11X1
1011
2801  
2802 0 ▶ if ($self->{argv}{message_log} & SQL_SIMPLE_LOG_SYS)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"argv"}{"message_log"} & 1) 0 0 0
2803 {
2804 0 require Sys::Syslog;
2805 0 ▶ openlog($self->{argv}{message_syslog_service} || "SQL-SimpleOps", "ndelay,pid", $self->{argv}{message_syslog_facility} || "local0");
Condition0%0/4
$self->{'argv'}{'message_syslog_service'} || 'SQL-SimpleOps'
l!l
00
$self->{'argv'}{'message_syslog_facility'} || 'local0'
l!l
00
MC/DC0%0/1
$self->{'argv'}{'message_syslog_service'} || 'SQL-SimpleOps'
$self->{'argv'}{'message_syslog_service'}
MC/DC0%0/1
$self->{'argv'}{'message_syslog_facility'} || 'local0'
$self->{'argv'}{'message_syslog_facility'}
Truth table0%0/2
A
A= $self->{'argv'}{'message_syslog_service'}
Aresult
11
00
Truth table0%0/2
A
A= $self->{'argv'}{'message_syslog_facility'}
Aresult
11
00
2806 syslog(
2807 ($SQL_SIMPLE_TABLE_OF_MSGS{$code}{T} eq "E") ? "error" :
2808 ($SQL_SIMPLE_TABLE_OF_MSGS{$code}{T} eq "S") ? "error" :
2809 0 ▶ ($SQL_SIMPLE_TABLE_OF_MSGS{$code}{T} eq "W") ? "warning" :
Branch: 3 branches
BranchTrueFalseTotal
$SQL::SimpleOps::SQL_SIMPLE_TABLE_OF_MSGS{$code}{'T'} eq 'E' ? : 0 0 0
$SQL::SimpleOps::SQL_SIMPLE_TABLE_OF_MSGS{$code}{'T'} eq 'S' ? : 0 0 0
$SQL::SimpleOps::SQL_SIMPLE_TABLE_OF_MSGS{$code}{'T'} eq 'W' ? : 0 0 0
2810 "info",
2811 $errstr
2812 );
2813 0 closelog();
2814 }
2815 }
2816 17 return $err;
2817 }
2818  
2819 ################################################################################
2820 ## action: enable/disable show dumper data at each call
2821 ## note: used for debug mode only.
2822  
2823 sub setDumper()
2824 281 ▶{
Subroutine setDumper: called CC=1 SCAR=0.0
Pod documented
2825 281 my $self = shift;
2826 281 return $self->{init}{dumper} = shift;
2827 }
2828  
2829 sub _Dumper()
2830 290 ▶{
Subroutine _Dumper: called CC=2 SCAR=10.8
2831 290 my $self = shift;
2832 290 my $call = shift;
2833 290 my $argv = shift;
2834  
2835 290 ▶ return if (!$self->{init}{dumper});
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"init"}{"dumper"} 290 0 290
2836  
2837 0 require Data::Dumper;
2838 0 ▶ $Data::Dumper::Sortkeys = \sub { my ($hash) = @_; return [ (sort keys %$hash) ]; };
Subroutine __ANON__: not called CC=1 SCAR=6.9
2839  
2840 0 my $dumper = new Data::Dumper([$argv]);
2841  
2842 0 $dumper->Terse(1);
2843  
2844 0 print STDERR $call." = ".$dumper->Dump;
2845 }
2846  
2847 __END__
↑ Summary SimpleOps/DBI/MySQL.pm »