Branch Coverage

blib/lib/SQL/Statement.pm
Criterion Covered Total %
branch 433 610 70.9


line true false branch
45 0 0 if (defined $main::extend_csv and $main::extend_csv or defined $main::extend_sql and $main::extend_sql)
52 0 868 unless defined $flags->{'PrintError'}
53 16 852 unless defined $flags->{'text_numbers'}
54 16 852 unless defined $flags->{'alpha_compare'}
56 868 0 if (&blessed($flags)) { }
69 0 868 unless (&_INSTANCE($parser, 'SQL::Parser'))
72 0 0 if $parser_dialect =~ /^(?:CSV|Excel)$/
86 0 868 if $self->{'already_prepared'}{$sql}
91 850 11 if ($rv) { }
106 9 841 if ($self->{'limit_clause'})
111 17 833 if (defined $self->{'num_placeholders'})
121 229 621 if ($self->{'where_clause'} and not defined $self->{'where_terms'})
146 5 4649 if $self->{'no_execute'}
147 186 4463 if $self->{'procedure'}
151 0 4649 unless $command
155 22 4627 if $self->{'where_clause'} and not defined $self->{'where_terms'}
160 4642 6 &_ARRAY0($self->{'columns'}) ? :
167 4 4644 unless defined $self->{'NUM_OF_ROWS'}
178 0 35 if ($subquery)
183 0 0 if ($subquery =~ /^IMPORT/i) { }
186 0 0 unless $sth = $data->{'Database'}->prepare("SELECT * FROM $subquery")
187 0 0 unless $sth->execute(@$params)
195 0 0 unless $sth = $data->{'Database'}->prepare($subquery)
196 0 0 unless $sth->execute
199 0 0 unless defined $names
208 0 0 unless @tbl_cols
210 0 0 if $self->{'is_ram_table'}
213 0 0 unless $data->{'Database'}->do($create_sql)
221 0 35 unless $eval
224 0 35 if (&_ARRAY(scalar $table->col_names))
262 5 4 if ($self->{'ignore_missing_table'} and $@ || @err || $self->{'errstr'} and grep {$_ =~ /$notblrx/;} @err, $@, $self->{'errstr'})
269 0 7 if $self->{'errstr'}
270 0 7 if $@ or @err
273 0 7 unless $eval
288 0 4275 unless $eval
290 4257 18 if $params
291 4275 0 if scalar $self->columns
292 0 4275 if $self->{'errstr'}
295 0 4275 unless $table->capability('insert_new_row')
301 0 4275 unless $cNum
314 0 12791 if (defined &_INSTANCE($val, 'SQL::Statement::Param')) { }
0 12791 elsif (defined &_INSTANCE($val, 'SQL::Statement::Term')) { }
12242 549 elsif ($val and $val->{'type'} eq 'placeholder') { }
549 0 elsif (defined &_HASH($val)) { }
339 0 4280 if $#$array < $maxCol
341 4280 0 $table->capability('insert_new_row') ? :
353 0 6 unless $eval
356 0 6 if $self->{'errstr'}
364 10 19 if ($self->eval_where($eval, $tname, $array))
367 10 0 if ($table->capability('rowwise_delete') and $table->capability('inplace_delete')) { }
0 0 elsif ($table->capability('rowwise_delete')) { }
369 0 10 if ($table->capability('delete_one_row')) { }
10 0 elsif ($table->capability('delete_current_row')) { }
386 0 19 unless $table->capability('rowwise_delete')
389 6 0 if ($affected)
391 6 0 if ($table->capability('rowwise_delete')) { }
418 0 5 unless $eval
421 3 2 if $valnum
425 0 5 if $self->{'errstr'}
435 7 14 if ($self->eval_where($eval, $tname, $array))
438 0 7 if ($table->capability('update_specific_row'))
446 0 9 if (defined &_INSTANCE($val, 'SQL::Statement::Param')) { }
0 9 elsif (defined &_INSTANCE($val, 'SQL::Statement::Term')) { }
6 3 elsif ($val and $val->{'type'} eq 'placeholder') { }
3 0 elsif (defined &_HASH($val)) { }
473 7 0 if ($table->capability('rowwise_update') and $table->capability('inplace_update')) { }
0 0 elsif ($table->capability('rowwise_update')) { }
477 0 7 if ($table->capability('update_specific_row')) { }
0 7 elsif ($table->capability('update_one_row')) { }
7 0 elsif ($table->capability('update_current_row')) { }
493 0 0 unless $table->capability('update_specific_row')
494 0 0 if $table->capability('update_specific_row')
499 0 21 unless $table->capability('rowwise_update')
502 5 0 if ($affected)
504 5 0 if ($table->capability('rowwise_update')) { }
508 0 0 if ($table->capability('update_specific_row')) { }
0 0 elsif ($table->capability('update_one_row')) { }
537 6 26 if -1 != index($self->{'join'}{'type'}, 'NATURAL')
538 10 22 if -1 != index($self->{'join'}{'clause'}, 'USING')
542 25 7 if $self->{'join'}{'keycols'}
549 16 16 if ($display_combine eq 'NAMED') { }
0 16 elsif ($display_combine eq 'NONE') { }
573 71 1 $display_cols[$_]->table ? :
594 6 18 if $display_combine eq 'NATURAL' and $is_natural{$col}
595 10 0 if $display_combine eq 'USING' and $is_natural{$col} and $is_key_col{$col}
602 6 26 if ($self->{'join'}{'type'} =~ /NATURAL/) { }
607 6 18 if $is_shared{$col}++
623 0 34 unless $eval
626 2 32 if $self->{'errstr'}
627 7 18 if ($self->{'join'}{'keycols'} and $self->{'join'}{'table_order'} and scalar @{$self->{'join'}{'table_order'};} == 0)
633 7 0 unless defined $self->{'join'}{'table_order'}
654 15 17 if $self->{'join'}{'table_order'}
656 17 15 if ref $tableA
657 17 15 if ref $tableB
678 6 38 if -1 != index($self->{'join'}{'type'}, 'NATURAL')
679 10 34 if -1 != index($self->{'join'}{'clause'}, 'USING')
680 7 37 if -1 != index($self->{'join'}{'clause'}, 'ON')
682 7 37 if $share_type eq 'ON' and scalar @{$self->{'join'}{'keycols'};} == 1
684 9 35 if -1 != index($self->{'join'}{'type'}, 'LEFT')
685 3 41 if -1 != index($self->{'join'}{'type'}, 'RIGHT')
686 2 42 if -1 != index($self->{'join'}{'type'}, 'FULL')
689 3 41 if ($right_join)
697 44 0 if 0 != index($tableA, '"')
699 44 0 if 0 != index($tableB, '"')
706 0 44 if ($share_type eq 'ON') { }
17 27 elsif ($share_type eq 'USING') { }
6 21 elsif ($share_type eq 'NATURAL') { }
708 0 0 if $right_join
723 0 12 if ($tableA eq $self->{'dlm'} . 'tmp')
727 6 6 if ($isunqualB{$c})
736 21 23 if ($share_type eq 'ON' or $share_type eq 'IMPLICIT') { }
749 3 41 $right_join ? :
755 139 204 if $pos >= 0
758 12 32 if ($tableA eq $self->{'dlm'} . 'tmp') { }
780 21 23 if ($share_type eq 'ON' or $share_type eq 'IMPLICIT')
789 0 0 if $isunqualA{$k1} and $isunqualA{$k2}
790 0 0 if $isunqualB{$k1} and $isunqualB{$k2}
792 0 62 if defined $whichqual{$k1}
793 0 62 if defined $whichqual{$k2}
795 17 45 if (defined $col_numsA{$k1} and defined $col_numsB{$k2}) { }
3 57 elsif (defined $col_numsA{$k2} and defined $col_numsB{$k1}) { }
811 0 86 unless defined $col_numsA{$c} or defined $col_numsB{$c}
817 43 43 if defined $col_numsA{$f}
818 43 43 if defined $col_numsB{$f}
829 247 47 if ($is_inner_join)
845 311 44 if ($is_inner_join)
851 14 341 if (not defined $rowsB and $join_type ne 'INNER')
853 14 0 unless defined $blankRow
857 355 0 if ($join_type ne 'UNION')
861 11 393 $right_join ? :
872 2 42 if ($join_type eq 'FULL' or $join_type eq 'UNION')
878 4 2 if $visited{$k}
886 4 4 if $table eq $tableA
887 4 4 if $table eq $tableB
889 1 1 if $st_is_NaturalOrUsing
924 176 172 unless defined &_ARRAY($self->{'table_names'})
927 66 106 if (defined $self->{'join'}) { }
929 34 32 unless defined $self->{'join'}{'table'}
936 1 104 unless $eval
939 1 103 if $self->{'errstr'}
969 0 313 if (&_INSTANCE($column, 'SQL::Statement::Param')) { }
972 0 0 if (-1 != (my $idx = index($val, '.'))) { }
1002 118 195 $tableName eq $self->{'dlm'} . 'tmp' && $tbl ne '' ? :
1005 33 280 if (not defined $cnum or $column->{'function'})
1017 0 135 unless defined $cList
1018 32 103 if ($self->{'join'})
1027 17 118 if (@order_by)
1043 6 14 if ($self->{'join'})
1046 1 5 unless defined $pos
1049 19 1 if exists $columns{$tbl}{$col}
1050 1 0 unless defined $pos
1056 32 103 $self->{'join'} ? :
1060 1 134 if $self->limit and not $self->order
1066 8432 241 if ($self->eval_where($e, $tableName, $array, \%funcs))
1068 5 8427 if defined $limit_count and $row_count++ < $offset
1075 1 8426 if defined $limit_count and ++$limit_count >= $limit
1081 5 129 if ($self->distinct)
1085 89 0 defined $_ ? :
13 20 $seen{join "\000", map({defined $_ ? $_ : '';} @{$_;})}++ ? :
1091 19 115 if ($self->{'has_set_functions'})
1094 7 12 if ($self->{'group_by'}) { }
1107 17 117 if (@order_by)
1112 0 20 if $self->{'join'} and $table->is_shared($col)
1125 56 76 if $desc
1132 1 133 if (defined $self->limit)
1140 1 133 if (@extraSortCols)
1155 4 32222 if (not defined $a && defined $b) { }
24164 8058 elsif (&looks_like_number($a) and &looks_like_number($b)) { }
1165 0 8058 $case_fold ? :
1172 8265 458 unless defined $self->{'where_terms'}
1183 30 93 unless $row and scalar @$row
1213 0 4519 if ($name =~ /^(.+)\.([^\.]+)$/)
1219 2 4517 if (defined $self->{'table_func'} and defined $self->{'table_func'}{uc $name}) { }
4475 42 elsif (defined $data->{'Database'}{'sql_ram_tables'} and defined $data->{'Database'}{'sql_ram_tables'}{$name} and $data->{'Database'}{'sql_ram_tables'}{$name}) { }
35 7 elsif ($self->{'is_ram_table'}) { }
1231 0 4475 if $t->{$name}->can('init_table')
1246 0 7 if $err
1247 7 0 if $@
1252 37 4475 unless $table_cols
1255 40 13271 $c =~ /^"/ ? :
1276 0 13311 unless defined $_
1278 13311 0 unless $ncol =~ /\./
1285 0 4642 if $self->{'errstr'}
1295 502 4140 unless ($self->{'all_cols'})
1313 199 487 if ($newcol->{'type'} eq 'column' and -1 != index($newcol->{'value'}, '*')) { }
97 390 elsif ('CREATE' eq $self->command or 'DROP' eq $self->command) { }
1317 0 199 if ($newcol->{'value'} =~ /^(.+)\.\*$/) { }
1320 0 0 unless defined &_STRING($tbl)
1336 0 212 unless defined $t->{$table}
1338 0 212 unless &_ARRAY($tcols)
1342 8 644 if $join and $shared_cols{$colName}++
1358 0 97 unless 'column' eq $newcol->{'type'}
1372 24 366 if ($newcol->{'type'} eq 'setfunc') { }
1375 18 6 if (1 == scalar @cols) { }
1422 7 4635 unless defined &_ARRAY0($self->{'column_defs'})
1423 4140 495 if defined &_ARRAY0($self->{'columns'})
1434 0 662 if $self->{'errstr'}
1453 28 13115 if defined $self->{'ALIASES'}{$c}
1456 1 13142 if ($c =~ /(\S+)\.(\S+)/) { }
13122 20 elsif (++${$i;} >= 0) { }
1470 0 13143 unless $col
1473 13088 55 defined &_INSTANCE($col_obj, 'SQL::Statement::Util::Column') && $col_obj->{'coldef'}{'type'} eq 'column' ? :
1477 210 12933 unless ($is_column and defined $table)
1482 0 13143 if (defined &_INSTANCE($table, 'SQL::Statement::Table'))
1487 2 13141 if ($is_column and not $table) { }
13086 55 elsif ($is_column) { }
1489 0 2 if $is_duplicate->{$c}
1495 0 13086 if $self->{'opts'}{'function_defs'}{$col}
1498 0 0 unless $$col_exists{"$table.$col"} or $$col_exists{lc($table . '.') . $col} or $is_user_def
1502 13107 34 if $is_column or ${$i;} < 0
1517 0 4424 if 0 == scalar @usr_cols
1531 34 4390 if (exists $self->{'join'} and defined &_HASH($self->{'join'}))
1534 6 28 if (-1 != index(uc $join->{'type'}, 'NATURAL')) { }
10 18 elsif ('USING' eq $join->{'clause'}) { }
1549 20 4404 if (defined $self->{'has_set_functions'})
1560 2 13120 if $self->{'errstr'}
1561 34 13086 unless $table and $col
1564 0 13086 if $table and $col and $is_fully->{$ftc}
1569 13086 0 if ($table and $col)
1573 8 13078 if $set_func_nofunc{$c}
1577 20 4402 if (defined $self->{'has_set_functions'})
1579 7 13 if (defined &_ARRAY($self->{'group_by'}))
1585 0 8 if $self->{'errstr'}
1587 0 8 if defined $col and not defined $table
1589 0 8 unless defined $table and defined $col
1594 1 19 if (defined &_HASH($set_fully))
1600 0 1 scalar keys %{$set_fully;} > 1 ? :
1606 17 4404 if ($self->{'sort_spec_list'})
1610 7 13 if defined &_INSTANCE($self->{'sort_spec_list'}[$n], 'SQL::Statement::Order')
1617 0 13 if $self->{'errstr'}
1618 1 12 if defined $col and not defined $table
1620 12 1 if defined $table
1653 0 2 unless ($_[0]{'params'})
1655 0 0 wantarray ? :
1657 0 2 if defined $_[1]
1659 0 2 wantarray ? :
1664 0 12803 unless (defined &_ARRAY($_[0]{'values'}))
1666 0 0 wantarray ? :
1668 12802 1 if (defined $_[1]) { }
1670 0 12802 unless defined $_[0]{'values'}[$_[1]]
1671 12801 1 if defined $_[2]
1675 0 1 wantarray ? :
1683 0 1 wantarray ? :
1696 1 34580 unless ($self->{'columns'})
1698 1 0 wantarray ? :
1701 12801 21779 if (defined $col and $col =~ /^\d+$/) { }
0 21779 elsif (defined $col) { }
1709 0 0 if $c->name eq $col
1713 13213 8566 wantarray ? :
1718 0 0 unless ($_[0]{'columns'})
1721 0 0 if $_[0]{'columns'}[$i]->name eq $_[1]
1729 0 2 unless defined $col_name
1732 0 2 if ($col_name =~ /^(.+)\.(.+)$/) { }
1745 10 0 unless ($scol || '') eq $col
1746 0 0 if defined $tbl and $tbl ne $stbl
1756 0 574 unless defined $col_name
1759 26 548 if defined $self->{'ALIASES'}{$col_name}
1762 449 125 unless (($tbl, $col) = $col_name =~ /^((?:"[^"]+")|(?:[^.]+))\.(.*)$/)
1767 456 118 if (defined $self->{'splitted_all_cols'}) { }
1772 440 282 if (my($stbl, $scol) = $full_col =~ /^((?:"[^"]+")|(?:[^.]+))\.(.*)$/)
1775 24 416 if defined $tbl and $tbl ne $stbl
1776 109 307 if $scol eq $col
1779 99 19 if @rc
1785 348 1228 if defined $tbl and $tbl ne $splitted_col->[0]
1786 436 792 if $splitted_col->[1] eq $col
1823 119 20 unless defined $_[0]{'sort_spec_list'}
1828 18 1 wantarray ? :
1 19 defined $_[1] && &looks_like_number($_[1]) ? :
1836 4701 4424 wantarray ? :
4432 9125 defined $_[1] && &looks_like_number($_[1]) ? :
1862 7 0 unless defined $t1 and defined $t2
1863 0 0 unless $is_table{$t1}++
1864 0 0 unless $is_table{$t2}++
1878 0 0 unless $is_ordered{$t2}
1883 0 0 unless ($is_ordered{$t})
1885 0 0 if $visited{$t}++ < @all_tables
1888 0 0 if (@order < @all_tables)
1894 0 0 if $in_order{$tbl}
1914 9 3 defined $prog ? :
1915 9 3 defined $line ? :
1919 0 12 if $self->{'PrintError'}
1920 1 11 if $self->{'RaiseError'}
1932 0 5 unless $_[0]{'where_terms'}
1955 0 0 if defined $self->{'capabilities'}{$capname}
2033 16086 4029 if ($coldef->{'type'} eq 'setfunc') { }
2035 9 16077 if ($coldef->{'distinct'} eq 'DISTINCT')
2037 3 6 if defined $result->{'uniq'}[$colidx]{$colval}
2042 36 16047 unless defined &_HASH($result->{'agg'}[$colidx])
2046 16038 45 unless (defined $agg->{'max'} and &SQL::Statement::_anycmp($colval, $agg->{'max'}) < 0)
2051 4069 12014 unless (defined $agg->{'min'} and &SQL::Statement::_anycmp($colval, $agg->{'min'}) > 0)
2056 12063 4020 if &looks_like_number($colval)
2061 23 4006 unless defined $result->{'pure'}[$colidx]
2076 41 24 if ($coldef->{'type'} eq 'setfunc') { }
2078 20 21 if ($coldef->{'name'} eq 'COUNT') { }
11 10 elsif ($coldef->{'name'} eq 'MAX') { }
1 9 elsif ($coldef->{'name'} eq 'MIN') { }
8 1 elsif ($coldef->{'name'} eq 'SUM') { }
1 0 elsif ($coldef->{'name'} eq 'AVG') { }
2098 1 0 if $count and $sum
2158 6 1 if (scalar keys %{$$self{'final_rows'};}) { }
2182 19 4005 unless defined &_HASH($self->{'final_rows'}{$rowkey})
2223 6 123 unless (defined $new_col)
2226 5 1 unless 2 == scalar @tmp
2238 44 406 $_[0]{'rowpos'} >= $_[0]{'maxrow'} ? :
2284 5189 28 unless ($table_name =~ /"/)