Branch Coverage

lib/DB/Handy.pm
Criterion Covered Total %
branch 1242 1892 65.6


line true false branch
35 0 14 if ($] < "5.006")
37 1 13 if $INC[-1] eq "."
78 13 23 unless (-d $self->{'base_dir'})
82 0 13 if ($@)
96 1 13 if (-d $path)
103 0 13 if ($@)
113 3 35 unless (-d $path)
125 0 1 unless (-d $path)
132 0 1 if ($@)
136 1 0 if $self->{'db_name'} eq $db_name
144 0 4 unless (opendir DH, $base)
145 4 8 if not /^\./
155 1 95 unless $self->{'db_name'}
157 0 95 if -f $sch_file
164 0 215 unless exists $TYPE_SIZE{$type}
166 6 209 if ($type eq 'CHAR') { }
72 137 elsif ($type eq 'VARCHAR') { }
167 0 6 unless $size and $size > 0
181 0 95 unless open FH, "> $sch_file"
190 0 95 unless open FH, '> ' . $self->_file($table, "dat")
197 0 3 unless $self->{'db_name'}
199 3 0 if ($sch and $sch->{'indexes'})
202 1 0 if -f $f
207 6 3 if -f $f
211 3 0 if (opendir DH, $dir)
213 0 26 if $f =~ /^\Q$table\E\.[^.]+\.idx$/
223 0 6 unless $self->{'db_name'}
226 0 6 unless opendir DH, $dir
227 22 37 /^(.+)\.sch$/ ? :
234 0 5 unless my $sch = $self->_load_schema($table)
243 0 34 unless $self->{'db_name'}
244 0 34 unless my $sch = $self->_load_schema($table)
247 0 34 unless $col_def
248 0 34 if $sch->{'indexes'}{$idxname}
250 10 24 $unique ? :
254 0 34 unless open FH, ">> $sch_file"
271 0 1 unless $self->{'db_name'}
272 0 1 unless my $sch = $self->_load_schema($table)
273 0 1 unless $sch->{'indexes'}{$idxname}
282 0 1 unless $self->{'db_name'}
283 0 1 unless my $sch = $self->_load_schema($table)
292 0 1611 unless $self->{'db_name'}
293 1 1610 unless my $sch = $self->_load_schema($table)
297 1652 34 unless $ix->{'unique'}
299 5 29 if ($self->_idx_lookup_exact($table, $ix, $val) >= 0)
306 14 2796 if (!defined($row->{$cn}) || $row->{$cn} eq '' and defined $sch->{'defaults'}{$cn})
310 0 1605 unless $sch->{'notnull'}
311 7 32 unless defined $row->{$cn} and $row->{$cn} ne ""
313 0 1598 unless $sch->{'checks'}
314 3 7 unless eval_bool($sch->{'checks'}{$cn}, $row)
316 0 1595 unless my $packed = $self->_pack_record($sch, $row)
319 0 1595 unless open FH, ">> $dat"
336 0 10 unless $self->{'db_name'}
337 0 10 unless my $sch = $self->_load_schema($table)
344 0 10 unless open FH, "+< $dat"
354 10 70 unless defined $n and $n == $recsize
355 65 5 if (substr($raw, 0, 1) ne "\0")
357 12 53 if (not $where_sub or &$where_sub($row))
379 0 2 unless $self->{'db_name'}
380 0 2 unless my $sch = $self->_load_schema($table)
386 0 2 unless open IN_FH, "< $dat"
388 0 2 unless (open OUT_FH, "> $tmp")
397 2 17 unless defined $n and $n == $recsize
398 13 4 if (substr($raw, 0, 1) ne "\0")
406 0 2 unless rename $tmp, $dat
409 0 3 unless $self->_rebuild_index($table, $ix->{'name'})
425 29 2279 if ($sql =~ /\(\s*SELECT\b/i)
430 29 0 if ($sql =~ /^(?:SELECT|INSERT|UPDATE|DELETE)\b/i)
435 4 2275 if ($sql =~ /^CREATE\s+DATABASE\s+(\w+)$/i)
436 4 0 $self->create_database($1) ? :
440 28 2247 if ($sql =~ /^USE\s+(\w+)$/i)
441 26 2 $self->use_database($1) ? :
445 0 2247 if ($sql =~ /^DROP\s+DATABASE\s+(\w+)$/i)
446 0 0 $self->drop_database($1) ? :
450 1 2246 if ($sql =~ /^SHOW\s+DATABASES$/i)
453 1 2245 if ($sql =~ /^SHOW\s+TABLES$/i)
456 1 2244 if ($sql =~ /^SHOW\s+(?:INDEXES|INDICES|INDEX)\s+(?:ON|FROM)\s+(\w+)$/i)
458 1 0 defined $ixs ? :
462 2 2242 if ($sql =~ /^DESCRIBE\s+(\w+)$/i)
464 2 0 $cols ? :
468 96 2146 if ($sql =~ /^CREATE\s+TABLE\s+(\w+)\s*\((.+)\)$/is)
474 0 216 if ($cd =~ /^PRIMARY\s+KEY\s*\(\s*(\w+)\s*\)$/is)
479 78 138 if ($cd =~ /^(\w+)\s+(CHAR|VARCHAR)\s*\(\s*(\d+)\s*\)(.*)/is) { }
138 0 elsif ($cd =~ /^(\w+)\s+(\w+)(.*)/is) { }
490 0 216 unless defined $rest
491 1 215 if $rest =~ /\bPRIMARY\s+KEY\b/is
492 15 201 if $rest =~ /\b(?:NOT\s+NULL|PRIMARY\s+KEY)\b/is
493 3 4 defined $1 ? :
7 209 if $rest =~ /\bDEFAULT\s+(?:'([^']*)'|(-?\d+\.?\d*))/is
494 6 210 if $rest =~ /\bCHECK\s*\((.+)\)/is
496 1 95 if defined $pk
497 1 95 unless $self->create_table($tbl, [@cols])
498 0 84 if (%nn or %defs or %chks or defined $pk)
499 0 11 unless my $sch = $self->_load_schema($tbl)
503 1 10 if defined $pk
508 3 2143 if ($sql =~ /^DROP\s+TABLE\s+(\w+)$/i)
509 3 0 $self->drop_table($1) ? :
513 34 2109 if ($sql =~ /^CREATE\s+(UNIQUE\s+)?INDEX\s+(\w+)\s+ON\s+(\w+)\s*\(\s*(\w+)\s*\)$/i)
515 10 24 $uniq ? :
34 0 $self->create_index($idxname, $tbl, $col, $uniq ? 1 : 0) ? :
519 1 2108 if ($sql =~ /^DROP\s+INDEX\s+(\w+)\s+ON\s+(\w+)$/i)
520 1 0 $self->drop_index($1, $2) ? :
524 2 2106 if ($sql =~ /^VACUUM\s+(\w+)$/i)
526 2 0 defined $n ? :
530 1601 505 if ($sql =~ /^INSERT\s+INTO\s+(\w+)\s*\(([^)]+)\)\s*VALUES\s*\((.+)\)$/i)
536 1585 16 $self->insert($tbl, {%row}) ? :
540 4 501 if ($sql =~ /^INSERT\s+INTO\s+(\w+)\s*\(([^)]+)\)\s+(SELECT\b.+)$/is)
548 4 0 if ($sel =~ /^SELECT\s+(.*?)\s+FROM\s+/is)
552 0 4 if $res->{'type'} eq "error"
563 10 0 @src_cols ? :
566 20 0 defined $src_keys[$i] ? :
568 10 0 if $self->insert($tbl, {%row})
572 466 35 if ($sql =~ /^SELECT\b/i)
575 25 10 if ($sql =~ /^UPDATE\s+(\w+)\s+SET\s+(.+?)(\s+WHERE\s+.+)?$/is)
576 24 1 defined $3 ? :
579 24 1 if ($wc =~ /\bWHERE\s+(.+)/is)
584 17 8 defined $n ? :
588 10 0 if ($sql =~ /^DELETE\s+FROM\s+(\w+)(.*)?$/is)
589 10 0 defined $2 ? :
591 10 0 if ($rest =~ /\bWHERE\s+(.+)/is)
596 10 0 defined $n ? :
628 4 29 if ($sql =~ /\bFROM\s*\(/i)
633 0 29 if ($sql =~ /^SELECT\s*\(/i)
639 0 29 if ref $expanded eq "HASH"
642 4 25 if ($expanded =~ /\(\s*SELECT\b/i)
657 0 4 unless ($sql =~ /^SELECT\s+(.+?)\s+FROM\s+(\w+)(.*)?$/i)
660 4 0 defined $3 ? :
662 0 4 unless my $sch = $self->_load_schema($tbl)
666 4 0 unless ($col_str =~ /^\*$/)
672 0 4 if ($rest =~ s/\bLIMIT\s+(\d+)//i)
675 0 4 if ($rest =~ s/\bOFFSET\s+(\d+)//i)
678 1 3 if ($rest =~ s/\bORDER\s+BY\s+(\w+)(?:\s+(ASC|DESC))?//i)
680 0 1 defined $2 ? :
685 4 0 if ($rest =~ /\bWHERE\s+(.+)/i)
700 0 4 unless open FH, "< $dat"
707 4 28 unless defined $n and $n == $recsize
708 28 0 if (substr($raw, 0, 1) ne "\0")
716 15 13 if &$filter({%qrow})
724 1 3 if (my $ob = $opts{'order_by'})
725 1 0 defined $opts{'order_dir'} ? :
728 3 0 defined $va ? :
3 0 defined $vb ? :
0 3 defined $va && $va =~ /^-?\d+\.?\d*$/ && defined $vb && $vb =~ /^-?\d+\.?\d*$/ ? :
732 0 3 $dir eq 'desc' ? :
737 0 4 defined $opts{'offset'} ? :
738 0 4 if $off
739 0 4 if (defined $opts{'limit'})
741 0 0 if $last > $#results
749 15 0 if (@sel_cols) { }
785 0 27 unless defined $pos
798 4 23 if (_subquery_is_correlated($inner_sql))
810 0 23 if (not $inner_res or $inner_res->{'type'} eq "error")
811 0 0 $inner_res ? :
815 0 23 unless $inner_res->{'data'}
819 12 11 if ($prefix =~ /\bIN\s*$/i or $prefix =~ /\bNOT\s+IN\s*$/i) { }
3 8 elsif ($prefix =~ /\b(?:EXISTS|NOT\s+EXISTS)\s*$/i) { }
825 17 0 defined $rv[0] ? :
826 15 2 if ($v =~ /^-?\d+\.?\d*$/) { }
833 10 2 if (@vals) { }
846 1 2 @inner_rows ? :
851 0 8 if (@inner_rows > 1)
854 1 7 if (@inner_rows == 0) { }
859 7 0 defined $rv[0] ? :
860 7 0 $v =~ /^-?\d+\.?\d*$/ ? :
883 27 0 if ($inner_sql =~ /\bFROM\s+(\w+)(?:\s+(?:AS\s+)?(\w+))?/i)
884 24 3 defined $2 ? :
888 0 0 defined $2 ? :
895 4 1 unless $inner_tables{$tbl}
914 30 2635 if (substr($sql, $i, 1) eq "(")
919 29 1 if ($peek =~ /^SELECT\b/i)
928 16 1470 if ($ch eq q[']) { }
1430 40 elsif (not $in_str) { }
934 3 1427 if ($ch eq '(') { }
32 1395 elsif ($ch eq ')') { }
940 2 1 if $depth > 1 and $p2 =~ /^SELECT\b/i
948 27 2 if ($depth == 0 and not $has_nested)
961 27 0 defined $best_start ? :
974 23 28 unless %$outer_row
981 264 0 defined $outer_row->{$qkey} ? :
982 200 64 $val =~ /^-?\d+\.?\d*$/ ? :
984 132 132 if (index($qkey, '.') != -1) { }
1027 3 3 if ($part =~ /^(NOT\s+)?EXISTS\s*\((.+)\)\s*$/is)
1030 1 2 $neg ? :
1039 0 3 if ($part =~ /^([\w.]+)\s+(NOT\s+)?IN\s*\((\s*SELECT\b.+)\)\s*$/is)
1042 0 0 $neg ? :
1052 1 2 if ($part =~ /^([\w.]+)\s*(=|!=|<>|<=|>=|<|>)\s*\((\s*SELECT\b.+)\)\s*$/is)
1066 2 0 if ($part =~ /^(\w+)\s*(=|!=|<>|<=|>=|<|>|LIKE)\s*(?:'([^']*)'|(-?\d+\.?\d*))$/i)
1068 0 2 defined $sv ? :
1086 0 334 if ($ch eq q['] and not $in_str) { }
0 334 elsif ($ch eq q['] and $in_str) { }
0 334 elsif ($in_str) { }
4 330 elsif ($ch eq '(') { }
4 326 elsif ($ch eq ')') { }
0 326 elsif ($depth == 0 and substr($expr, $i, 5) =~ /^AND\s/i) { }
1116 6 0 if $cur =~ /\S/
1126 0 6 unless $conds and @$conds
1131 4 2 if (($c->{'type'} || '') eq 'subquery') { }
1145 2 34 if $plain_sub and not &$plain_sub($row)
1152 28 0 $res && $res->{'type'} eq 'rows' ? :
1154 12 16 if ($op eq 'EXISTS') { }
8 8 elsif ($op eq 'NOT_EXISTS') { }
0 8 elsif ($op eq 'IN' or $op eq 'NOT_IN') { }
8 0 elsif ($op eq 'CMP') { }
1155 5 7 unless @rows
1158 4 4 if @rows
1161 0 0 defined $$row{$c->{'col'}} ? :
1165 0 0 defined $rv[0] ? :
1167 0 0 $num ? :
0 0 if ($num ? $col_val == $rv : $col_val eq $rv)
1172 0 0 if $found and $op eq "NOT_IN"
1173 0 0 if not $found and $op eq "IN"
1176 0 8 if @rows > 1
1178 4 4 if (@rows == 0) { }
1185 4 4 unless defined $rhs
1186 4 0 defined $$row{$c->{'col'}} ? :
1189 0 4 if ($cop eq '=') { }
0 4 elsif ($cop eq '!=' or $cop eq '<>') { }
0 4 elsif ($cop eq '<') { }
4 0 elsif ($cop eq '>') { }
0 0 elsif ($cop eq '<=') { }
0 0 elsif ($cop eq '>=') { }
1190 0 0 $num ? :
0 0 unless $num ? $lhs == $rhs : $lhs eq $rhs
1193 0 0 $num ? :
0 0 unless $num ? $lhs != $rhs : $lhs ne $rhs
1196 0 0 $num ? :
0 0 unless $num ? $lhs < $rhs : $lhs lt $rhs
1199 4 0 $num ? :
0 4 unless $num ? $lhs > $rhs : $lhs gt $rhs
1202 0 0 $num ? :
0 0 unless $num ? $lhs <= $rhs : $lhs le $rhs
1205 0 0 $num ? :
0 0 unless $num ? $lhs >= $rhs : $lhs ge $rhs
1224 0 4 unless ($sql =~ /^SELECT\s+(.+?)\s+FROM\s*\(/is)
1232 0 4 unless ($paren_start >= 0)
1237 0 4 unless (defined $inner_sql)
1247 4 0 if ($after =~ s/^(?:AS\s+)?(\w+)\s*//i) { }
1256 1 3 if ($after =~ s/\bLIMIT\s+(\d+)//i)
1259 0 4 if ($after =~ s/\bOFFSET\s+(\d+)//i)
1262 1 3 if ($after =~ s/\bORDER\s+BY\s+([\w.]+)(?:\s+(ASC|DESC))?//i)
1268 2 2 if ($after =~ /\bWHERE\s+(.+)/i)
1275 0 4 if (not $inner_res or $inner_res->{'type'} eq "error")
1276 0 0 $inner_res ? :
1280 0 4 unless $inner_res->{'data'}
1289 0 40 $k =~ /\.(\w+)$/ ? :
1297 2 2 if ($outer_where_str =~ /\S/)
1304 1 3 if (my $ob = $outer_opts{'order_by'})
1309 17 0 defined $DB::Handy::a->{$ob} ? :
1312 17 0 defined $DB::Handy::b->{$ob} ? :
1313 17 0 defined $va && $va =~ /^-?\d+\.?\d*$/ && defined $vb && $vb =~ /^-?\d+\.?\d*$/ ? :
1317 0 17 $dir eq 'desc' ? :
1323 0 4 if $off
1324 1 3 if (defined $outer_opts{'limit'})
1326 0 1 if $last > $#qualified_rows
1332 0 4 if ($outer_cols_str =~ /^\s*\*\s*$/) { }
1340 13 0 if (exists $r->{$w}) { }
0 0 elsif ($w =~ /^$alias\.(\w+)$/ and exists $r->{$1}) { }
1350 0 0 if ($k =~ /\.\Q$w\E$/ or $k eq $w)
1377 0 0 if ref $expanded eq "HASH"
1392 0 204 if ($ch eq q['] and not $in_str) { }
0 204 elsif ($ch eq q['] and $in_str) { }
204 0 elsif (not $in_str) { }
1399 4 200 if ($ch eq '(') { }
4 196 elsif ($ch eq ')') { }
1404 4 0 if ($depth == 0)
1424 0 2028 unless defined $val
1425 1293 735 if ($type eq 'INT') { }
113 622 elsif ($type eq 'FLOAT') { }
1427 0 1293 if $iv > 2147483647
1428 0 1293 if $iv < '-2147483648'
1435 113 0 if unpack "C", "\1\0"
1438 2 111 if ($b[0] & 128) { }
1463 0 1877 unless -f $idx_file
1465 0 1877 unless open FH, "< $idx_file"
1469 0 1877 unless ($magic eq "SDBIDX1\n")
1476 1877 296906 unless defined $n and $n == $entry_size
1487 0 1730 unless open FH, "> $idx_file"
1504 8006 3411 if ($entries->[$mid][0] lt $key_bytes) { }
1541 12 5 if ($entries->[$pos][1] == $rec_no)
1548 12 0 if $deleted
1555 0 38 unless @$entries
1558 31 7 if (defined $lo_val)
1564 23 15 if (defined $hi_val)
1575 0 37 unless my $sch = $self->_load_schema($table)
1577 0 37 unless $ix
1581 37 0 if (-f $dat)
1583 0 37 unless open FH, "< $dat"
1589 37 79 unless defined $n and $n == $recsize
1590 79 0 if (substr($raw, 0, 1) ne "\0")
1604 0 147 unless $conds and @$conds
1605 115 32 unless %{$sch->{'indexes'};}
1611 0 32 unless my $ix = $col2ix{$c->{'col'}}
1613 17 15 if ($op eq '=') { }
2 13 elsif ($op eq '<') { }
3 10 elsif ($op eq '<=') { }
4 6 elsif ($op eq '>') { }
6 0 elsif ($op eq '>=') { }
1651 167 91 unless %{$sch->{'indexes'};}
1659 6 85 if ($where_expr =~ /^(\w+)\s+BETWEEN\s+$VAL\s+AND\s+$VAL\s*$/i)
1661 0 6 defined $lo_s ? :
1662 0 6 defined $hi_s ? :
1663 0 6 unless my $ix = $col2ix{$col}
1667 10 75 if ($where_expr =~ /^(\w+)\s+$OP\s+$VAL\s+AND\s+\1\s+$OP\s+$VAL\s*$/i)
1669 0 10 defined $v1s ? :
1670 0 10 defined $v2s ? :
1671 0 10 unless my $ix = $col2ix{$col}
1674 9 1 if ($op1 eq '>' or $op1 eq '>=') { }
1703 167 75 unless %{$sch->{'indexes'};}
1705 62 13 if $where_expr =~ /\b(?:OR|NOT|BETWEEN|IN)\b/i
1706 0 13 if $where_expr =~ /\(\s*SELECT\b/i
1713 27 0 if ($part =~ /^(\w+)\s*($OP)\s*($VAL)$/ or $part =~ /^($VAL)\s*($OP)\s*(\w+)$/) { }
1717 27 0 if ($part =~ /^(\w+)\s*($OP)\s*($VAL)$/) { }
1735 0 13 unless @atoms >= 2
1746 4 13 unless my $ix = $col2ix{$a->{'col'}}
1748 0 13 if $op eq "!=" or $op eq "<>"
1750 10 3 if ($op eq '=') { }
0 3 elsif ($op eq '<') { }
0 3 elsif ($op eq '<=') { }
3 0 elsif ($op eq '>') { }
0 0 elsif ($op eq '>=') { }
1761 10 0 if $best_eq = $recs
1775 3 0 if defined $recs and not defined $best_rng
1777 10 3 if defined $best_eq
1796 167 66 unless %{$sch->{'indexes'};}
1798 35 31 unless $where_expr =~ /^\s*(\w+)\s+IN\s*\(([^)]*)\)\s*$/is
1803 30 19 if ($candidate->{'col'} eq $col)
1808 1 30 unless defined $ix
1814 1 86 if (defined $nl) { }
9 77 elsif (defined $sv) { }
1826 0 29 unless @vals
1836 98 2 unless $seen{$rn}++
1861 167 37 unless %{$sch->{'indexes'};}
1863 7 30 if $where_expr =~ /\b(?:AND|NOT)\b/i
1864 0 30 if $where_expr =~ /\(\s*SELECT\b/i
1867 2 28 unless @atoms >= 2
1882 0 60 if ($atom =~ /^(\w+)\s+BETWEEN\s+($VAL)\s+AND\s+($VAL)\s*$/i) { }
3 57 elsif ($atom =~ /^(\w+)\s+IN\s*\(([^)]*)\)\s*$/i) { }
57 0 elsif ($atom =~ /^(\w+)\s*($OP)\s*($VAL)$/) { }
1884 0 0 unless my $ix = $col2ix{$col}
1891 0 3 unless my $ix = $col2ix{$col}
1893 0 3 unless defined $recs
1898 0 57 if $op eq "!=" or $op eq "<>"
1899 1 56 unless my $ix = $col2ix{$col}
1901 52 4 if ($op eq '=') { }
0 4 elsif ($op eq '<') { }
2 2 elsif ($op eq '<=') { }
0 2 elsif ($op eq '>') { }
2 0 elsif ($op eq '>=') { }
1920 0 59 unless defined $recs
1922 420 4 unless $seen{$rn}++
1951 0 27 unless $self->{'db_name'}
1960 0 56 unless my $sch = $self->_load_schema($js->{'table'})
1972 0 27 unless defined $cur_rows[0] or not $self->{'_last_err'}
1983 29 0 if ($js->{'on_left'} and $js->{'on_right'})
1994 29 0 if (defined $on_r_alias and defined $on_r_col)
1997 135 3 defined $$rr{"$on_r_alias.$on_r_col"} ? :
2006 1 28 if ($join_type eq 'CROSS' or not defined $on_l_alias) { }
22 6 elsif ($join_type eq 'INNER') { }
5 1 elsif ($join_type eq 'LEFT') { }
1 0 elsif ($join_type eq 'RIGHT') { }
2018 145 0 defined $$lr{"$on_l_alias.$on_l_col"} ? :
2020 145 0 $use_hash ? :
2022 0 127 if $use_hash == 0 and not _join_row_matches($lr, $rr, $on_l_alias, $on_l_col, $on_r_alias, $on_r_col)
2030 32 0 defined $$lr{"$on_l_alias.$on_l_col"} ? :
2033 32 0 $use_hash ? :
2036 27 5 if (@$matches) { }
2053 5 0 defined $$rr{"$on_r_alias.$on_r_col"} ? :
2057 35 0 defined $lr->{$l_alias_key} ? :
2058 6 29 if $lkey eq $rkey
2060 3 2 if (@matched_lefts) { }
2084 15 12 if (@$where_conds)
2092 5 22 if (my $ob = $opts->{'order_by'})
2099 54 0 defined $va && $va =~ /^-?\d+\.?\d*$/ && defined $vb && $vb =~ /^-?\d+\.?\d*$/ ? :
2103 11 43 $dir eq 'desc' ? :
2111 1 26 if $offset
2112 2 25 if (defined $opts->{'limit'})
2114 0 2 if $last > $#cur_rows
2121 25 2 if ($col_specs and @$col_specs)
2126 0 52 if ($cs eq '*') { }
1 51 elsif ($cs =~ /^(\w+)\.\*$/) { }
2139 1 0 $alias_info{$a} ? :
2140 1 0 if ($sch)
2156 175 0 if (exists $r->{$ck}) { }
2163 0 0 if ($k =~ /\.\Q$ck\E$/ or $k eq $ck)
2181 0 56 unless my $sch = $self->_load_schema($table)
2187 0 56 unless (open FH, "< $dat")
2193 56 311 unless defined $n and $n == $recsize
2194 0 311 if substr($raw, 0, 1) eq "\0"
2222 75 0 if ($qname =~ /^(\w+)\.(\w+)$/)
2231 0 0 defined $la ? :
2232 0 0 defined $ra ? :
2233 0 0 unless defined $lv and defined $rv
2236 0 0 if ($lv =~ /^-?\d+\.?\d*$/ and $rv =~ /^-?\d+\.?\d*$/)
2237 0 0 $lv == $rv ? :
2239 0 0 $lv eq $rv ? :
2254 0 15 unless $conds and @$conds
2261 97 0 if (defined $c->{'lhs_alias'}) { }
2268 0 0 if ($k =~ /\.\Q$c->{'lhs_col'}\E$/ or $k eq $c->{'lhs_col'})
2274 1 96 unless defined $lv
2278 0 97 if (defined $c->{'rhs_col'}) { }
2279 0 0 if (defined $c->{'rhs_alias'}) { }
2284 0 0 if ($k =~ /\.\Q$c->{'rhs_col'}\E$/ or $k eq $c->{'rhs_col'})
2294 8 89 unless defined $rv
2299 8 89 if ($op eq "IN" or $op eq "NOT_IN")
2303 0 8 unless defined $cv
2305 8 0 $num2 ? :
4 4 if ($num2 ? $lhs_val == $cv : $lhs_val eq $cv)
2310 0 8 if $found and $op eq "NOT_IN"
2311 4 4 if not $found and $op eq "IN"
2317 77 12 if ($op eq '=') { }
0 12 elsif ($op eq '!=' or $op eq '<>') { }
0 12 elsif ($op eq '<') { }
9 3 elsif ($op eq '>') { }
0 3 elsif ($op eq '<=') { }
3 0 elsif ($op eq '>=') { }
0 0 elsif ($op eq 'LIKE') { }
2318 39 38 $num ? :
58 19 unless $num ? $lv == $rv : $lv eq $rv
2321 0 0 $num ? :
0 0 unless $num ? $lv != $rv : $lv ne $rv
2324 0 0 $num ? :
0 0 unless $num ? $lv < $rv : $lv lt $rv
2327 9 0 $num ? :
4 5 unless $num ? $lv > $rv : $lv gt $rv
2330 0 0 $num ? :
0 0 unless $num ? $lv <= $rv : $lv le $rv
2333 3 0 $num ? :
1 2 unless $num ? $lv >= $rv : $lv ge $rv
2338 0 0 unless $lv =~ /^$p$/i
2363 0 27 unless $sql =~ /^SELECT\s+(.+?)\s+FROM\s+(.+)$/is
2374 1 26 if ($from_rest =~ s/\s+OFFSET\s+(\d+)\s*$//i)
2377 2 25 if ($from_rest =~ s/\s+LIMIT\s+(\d+)\s*$//i)
2380 6 21 if ($from_rest =~ s/\s+ORDER\s+BY\s+([\w.]+)(?:\s+(ASC|DESC))?\s*$//i)
2392 15 12 if ($from_rest =~ s/\s+WHERE\s+(.+)$//i)
2406 0 27 unless ($fr =~ s/^(\w+)(?:\s+(?:AS\s+)?(\w+))?//)
2409 27 0 defined $2 ? :
2416 5 24 if (defined $type_kw and $type_kw =~ /LEFT/i) { }
1 23 elsif (defined $type_kw and $type_kw =~ /RIGHT/i) { }
1 22 elsif (defined $type_kw and $type_kw =~ /CROSS/i) { }
2425 0 29 unless defined $alias
2436 0 27 if @join_specs < 2
2442 1 26 if ($sel_str =~ /^\s*\*\s*$/) { }
2456 15 12 if $where_str =~ /\S/
2465 0 15 unless defined $expr and $expr =~ /\S/
2471 10 7 if ($part =~ /^((?:\w+\.)?\w+)\s*(=|!=|<>|<=|>=|<|>)\s*((?:\w+\.)?\w+)$/i and not $part =~ /'/) { }
1 6 elsif ($part =~ /^((?:\w+\.)?\w+)\s+(NOT\s+)?IN\s*\(([^)]*)\)\s*$/i) { }
6 0 elsif ($part =~ /^((?:\w+\.)?\w+)\s*(=|!=|<>|<=|>=|<|>|LIKE)\s*(?:'([^']*)'|(-?\d+\.?\d*))$/i) { }
2475 10 0 if ($rhs =~ /^-?\d+\.?\d*$/) { }
2493 0 1 defined $sv ? :
0 1 defined $nl ? :
2495 0 1 $neg ? :
2506 6 0 defined $sv ? :
2533 2153 111 if $self->{'_tables'}{$table}
2535 8 103 unless (-f $sch_file)
2540 0 103 unless (open FH, "< $sch_file")
2548 103 347 if (/^RECSIZE=(\d+)/) { }
238 109 elsif (/^COL=(\w+):(\w+):(\d+)/) { }
1 108 elsif (/^NOTNULL=(\w+)/) { }
0 108 elsif (/^DEFAULT=(\w+):(.+)/) { }
1 107 elsif (/^CHECK=(\w+):(.+)/) { }
0 107 elsif (/^PK=(\w+)/) { }
4 103 elsif (/^IDX=(\w+):(\w+):([01])/) { }
2575 4 0 $cdef ? :
4 0 $cdef ? :
2590 0 12 unless open FH, "> $sch_file"
2599 0 12 unless $sch->{'notnull'}
2602 0 12 unless $sch->{'defaults'}
2605 0 12 unless $sch->{'checks'}
2608 1 11 if $sch->{'pk'}
2617 2860 2 defined $$row{$col->{'name'}} ? :
2620 1828 1034 if ($t eq 'INT') { }
99 935 elsif ($t eq 'FLOAT') { }
2622 0 1828 if $iv > 2147483647
2623 0 1828 if $iv < '-2147483648'
2646 5381 3765 if ($t eq 'INT') { }
292 3473 elsif ($t eq 'FLOAT') { }
2648 3 5378 if $uv > 2147483647
2669 0 10 unless defined $wi
2670 10 0 if ref $wi eq "CODE"
2671 0 0 if ref $wi eq "ARRAY"
2681 84 2663 if ($ch eq '(') { }
84 2579 elsif ($ch eq ')') { }
120 2459 elsif ($ch eq ',' and $depth == 0) { }
2697 96 0 if $cur =~ /\S/
2706 0 2780 unless length $str
2707 907 1873 if ($str =~ s/^'((?:[^']|'')*)'(?:\s*,\s*|\s*$)//) { }
0 1873 elsif ($str =~ s/^(NULL)(?:\s*,\s*|\s*$)//i) { }
1873 0 elsif ($str =~ s/^(-?\d+\.?\d*)(?:\s*,\s*|\s*$)//) { }
2735 0 0 if ($part =~ /^(\w+)\s+(NOT\s+)?IN\s*\(([^)]*)\)\s*$/i)
2743 0 0 defined $sv ? :
0 0 defined $nl ? :
2745 0 0 $neg ? :
2754 0 0 if ($part =~ /^(NOT\s+)?EXISTS\s*\((\d+)\)$/i)
2756 0 0 $val ? :
2757 0 0 if $neg
2763 0 0 if ($part =~ /^(NOT\s+)?EXISTS\s+(\d+)$/i)
2765 0 0 $val ? :
2766 0 0 if $neg
2772 0 0 if ($part =~ /^(\w+)\s*(=|!=|<>|<=|>=|<|>)\s*NULL$/i)
2778 0 0 if ($part =~ /^(\w+)\s+IS\s+(NOT\s+)?NULL$/i)
2780 0 0 $neg ? :
2785 0 0 if ($part =~ /^(\w+)\s*(=|!=|<>|<=|>=|<|>|LIKE)\s*(?:'([^']*)'|(-?\d+\.?\d*))$/i)
2787 0 0 defined $sv ? :
2795 4 2 unless $conds and @$conds
2802 0 8 if ($op eq 'CONST') { }
0 8 elsif ($op eq 'IN' or $op eq 'NOT_IN') { }
0 8 elsif ($op eq 'IS_NULL') { }
0 8 elsif ($op eq 'IS_NOT_NULL') { }
2803 0 0 unless $c->{'val'}
2807 0 0 defined $$row{$c->{'col'}} ? :
2810 0 0 unless defined $cv
2812 0 0 $num ? :
0 0 if ($num ? $rv == $cv : $rv eq $cv)
2817 0 0 if $found and $op eq "NOT_IN"
2818 0 0 if not $found and $op eq "IN"
2822 0 0 unless not defined $$row{$c->{'col'}} or $$row{$c->{'col'}} eq ""
2825 0 0 unless defined $$row{$c->{'col'}} and $$row{$c->{'col'}} ne ""
2829 8 0 defined $$row{$c->{'col'}} ? :
2832 4 4 if ($op eq '=') { }
0 4 elsif ($op eq '!=' or $op eq '<>') { }
0 4 elsif ($op eq '<') { }
4 0 elsif ($op eq '>') { }
0 0 elsif ($op eq '<=') { }
0 0 elsif ($op eq '>=') { }
0 0 elsif ($op eq 'LIKE') { }
2833 4 0 $num ? :
0 4 unless $num ? $rv == $cv : $rv eq $cv
2836 0 0 $num ? :
0 0 unless $num ? $rv != $cv : $rv ne $cv
2839 0 0 $num ? :
0 0 unless $num ? $rv < $cv : $rv lt $cv
2842 4 0 $num ? :
2 2 unless $num ? $rv > $cv : $rv gt $cv
2845 0 0 $num ? :
0 0 unless $num ? $rv <= $cv : $rv le $cv
2848 0 0 $num ? :
0 0 unless $num ? $rv >= $cv : $rv ge $cv
2853 0 0 unless $rv =~ /^$p$/i
2870 0 4402 unless defined $expr
2872 0 4402 unless length $expr
2873 0 4402 if $expr =~ /^NULL$/i
2874 88 4314 if $expr =~ /^-?\d+\.?\d*$/
2875 18 4296 if ($expr =~ /^'((?:[^']|'')*)'$/)
2879 0 4296 if ($expr =~ /^\((.+)\)$/s and not $1 =~ /^\s*SELECT\b/i)
2882 9 4287 if ($expr =~ /^CASE\b(.*)\bEND$/is)
2885 4 4283 if ($expr =~ /^COALESCE\s*\((.+)\)$/is)
2888 4 2 if defined $v and $v ne ""
2892 2 4281 if ($expr =~ /^NULLIF\s*\((.+)\)$/is)
2894 0 2 unless @a == 2
2896 2 0 if (defined $va and defined $vb)
2897 2 0 $va =~ /^-?\d+\.?\d*$/ && $vb =~ /^-?\d+\.?\d*$/ ? :
1 1 if $va =~ /^-?\d+\.?\d*$/ && $vb =~ /^-?\d+\.?\d*$/ ? $va == $vb : $va eq $vb
2901 2 4279 if ($expr =~ /^CAST\s*\(\s*(.+?)\s+AS\s+(\w+(?:\s*\(\s*\d+\s*\))?)\s*\)$/is)
2904 0 2 unless defined $v
2905 1 1 if $t =~ /^INT/i
2906 0 1 if $t =~ /^(FLOAT|REAL|DOUBLE|NUMERIC|DECIMAL)/i
2909 9 4270 if ($expr =~ /^(UPPER|LOWER|LENGTH|ABS|SIGN|TRIM|LTRIM|RTRIM)\s*\((.+)\)$/is)
2912 0 9 unless defined $v
2913 2 7 if $fn eq "UPPER"
2914 3 4 if $fn eq "LOWER"
2915 2 2 if $fn eq "LENGTH"
2916 0 2 if $fn eq "ABS"
2917 0 0 $v < 0 ? :
0 0 $v > 0 ? :
0 2 if $fn eq "SIGN"
2918 2 0 if ($fn eq "TRIM")
2922 0 0 if ($fn eq "LTRIM")
2926 0 0 if ($fn eq "RTRIM")
2931 0 4270 if ($expr =~ /^ROUND\s*\((.+)\)$/is)
2934 0 0 unless defined $v
2935 0 0 @a > 1 ? :
2938 0 4270 if ($expr =~ /^(FLOOR|CEIL(?:ING)?)\s*\((.+)\)$/is)
2941 0 0 unless defined $v
2942 0 0 $fn eq 'FLOOR' ? :
2944 0 4270 if ($expr =~ /^MOD\s*\((.+)\)$/is)
2946 0 0 unless @a == 2
2948 0 0 if $b == 0
2951 1 4269 if ($expr =~ /^(?:SUBSTR|SUBSTRING)\s*\((.+)\)$/is)
2954 0 1 if ($inner =~ /^(.+?)\s+FROM\s+(\S+)(?:\s+FOR\s+(.+))?$/is) { }
2961 0 1 unless defined $s
2963 0 1 if $st < 1
2964 1 0 defined $le ? :
2968 0 4269 if ($expr =~ /^CONCAT\s*\((.+)\)$/is)
2973 0 0 defined $v ? :
2981 28 12757 if (defined $p)
2985 6 22 if ($opsym eq "||")
2986 6 0 defined $lv ? :
6 0 defined $rv ? :
2988 0 22 unless defined $lv and defined $rv
2990 10 12 if $opsym eq "+"
2991 0 12 if $opsym eq "-"
2992 6 6 if $opsym eq "*"
2993 0 6 if $opsym eq '/' || $opsym eq '%' and $r == 0
2994 0 6 if $opsym eq "/"
2995 6 0 if $opsym eq "%"
2998 0 4241 if ($expr =~ /^-([\w('.].*)$/s)
3000 0 0 unless defined $v
3003 39 4202 if ($expr =~ /^(\w+)\.(\w+)$/)
3005 9 30 exists $$row{"$a.$c"} ? :
3007 4202 0 if $expr =~ /^\w+$/
3015 0 9 unless ($body =~ /^\s*WHEN\b/i)
3016 0 0 if $body =~ s/^(.+?)\s+(?=WHEN\b)//is
3019 9 0 if $body =~ s/\s*\bELSE\b\s+(.+?)\s*$//is
3023 0 15 if (defined $base) { }
3030 6 9 if $m
3032 3 0 defined $else ? :
3038 34 0 if ($expr =~ /^(.+?)\s*(=|!=|<>|<=|>=|<|>)\s*(.+)$/s)
3041 0 34 unless defined $lv and defined $rv
3043 5 0 $n ? :
5 29 if $op eq "="
3044 0 0 $n ? :
0 29 if $op =~ /^(!|<>)/
3045 10 0 $n ? :
10 19 if $op eq "<"
3046 0 0 $n ? :
0 19 if $op eq ">"
3047 4 0 $n ? :
4 15 if $op eq "<="
3048 15 0 $n ? :
15 0 if $op eq ">="
3050 0 0 if ($expr =~ /^(.+)\s+IS\s+(NOT\s+)?NULL$/is)
3052 0 0 $2 ? :
3065 17 2704 if ($ch eq q['] and not $in_q) { }
17 2687 elsif ($ch eq q['] and $in_q) { }
71 2616 elsif ($in_q) { }
45 2571 elsif ($ch eq '(') { }
45 2526 elsif ($ch eq ')') { }
96 2430 elsif ($ch eq ',' and $d == 0) { }
3092 397 0 if $cur =~ /\S/
3104 2 39423 if ($ch eq q['] and not $in_q) { }
2 39421 elsif ($ch eq q['] and $in_q) { }
0 39421 elsif (not $in_q and $ch eq '(') { }
0 39421 elsif (not $in_q and $ch eq ')') { }
26634 12787 elsif (not $in_q and $d == 0 and $i > 0) { }
3117 29 26605 if (substr($expr, $i) =~ /^($op_pat)/)
3130 0 335 unless defined $expr and $expr =~ /\S/
3138 35 470 if @or > 1
3140 45 425 if @and > 1
3141 2 423 if $expr =~ /^NOT\s+(.+)$/is
3142 2 421 if ($expr =~ /^\((.+)\)$/s and not $1 =~ /^\s*SELECT\b/i)
3159 252 11911 if ($ch eq q['] and not $in_q) { }
252 11659 elsif ($ch eq q['] and $in_q) { }
748 10911 elsif ($in_q) { }
120 10791 elsif ($ch eq '(') { }
120 10671 elsif ($ch eq ')') { }
129 10542 elsif ($d == 0 and not $in_q and uc substr($expr, $i, $kl) eq $kw and $i == 0 || substr($expr, $i - 1, 1) =~ /\s/ and $i + $kl < $len and substr($expr, $i + $kl, 1) =~ /\s/) { }
3187 56 73 if ($kw eq "AND")
3190 10 46 if ($before =~ /\bBETWEEN\s+\S+\s*$/i)
3208 108 897 @parts > 1 ? :
3214 3 418 if ($part =~ /^(NOT\s+)?EXISTS\s*\((\d+)\)$/i)
3216 1 2 $v ? :
3217 0 3 if $neg
3220 47 371 if ($part =~ /^([\w.]+)\s+(NOT\s+)?IN\s*\(([^)]*)\)$/is)
3225 3 124 if (defined $nl) { }
9 115 elsif (defined $sv) { }
3236 6 41 $neg ? :
3238 1 370 if $part =~ /^[\w.]+\s*(?:=|!=|<>|<=|>=|<|>)\s*NULL$/is
3239 3 367 if ($part =~ /^([\w.]+)\s+IS\s+(NOT\s+)?NULL$/is)
3240 2 1 $2 ? :
3242 10 357 if ($part =~ /^([\w.]+)\s+(NOT\s+)?BETWEEN\s+(.+?)\s+AND\s+(.+)$/is)
3246 1 9 $neg ? :
3248 5 352 if ($part =~ /^(.+?)\s+(NOT\s+)?LIKE\s+('(?:[^']|'')*'|\S+)$/is)
3253 1 4 $neg ? :
3255 352 0 if ($part =~ /^(.+?)\s*(=|!=|<>|<=|>=|<|>)\s*(.+)$/s)
3260 68 284 if ($rhs =~ /^'((?:[^']|'')*)'$/) { }
3274 45 458 if ($op eq "AND")
3276 292 335 unless &$s($_[0])
3278 35 423 if ($op eq "OR")
3280 445 461 if &$s($_[0])
3282 2 421 if ($op eq "NOT")
3284 1 11 &$s($_[0]) ? :
3291 421 0 defined $c->{'op'} ? :
3292 8 24 $c->{'val'} ? :
4 417 if $op eq "CONST"
3293 1 416 if ($op eq "IS_NULL")
3295 3 0 unless not defined $v
3297 2 414 if ($op eq "IS_NOT_NULL")
3299 6 0 if defined $v
3301 10 404 if ($op eq "BETWEEN" or $op eq "NOT_BETWEEN")
3305 0 50 unless defined $v
3307 50 0 $n ? :
3308 4 46 $neg ? :
3311 47 357 if ($op eq "IN" or $op eq "NOT_IN")
3314 585 0 defined $_[0]{$col} ? :
3317 23 1560 unless defined $cv
3319 1524 36 $n ? :
153 1407 if ($n ? $rv == $cv : $rv eq $cv)
3324 45 540 $neg ? :
3327 5 352 if ($op eq "LIKE" or $op eq "NOT_LIKE")
3331 0 24 unless defined $v
3332 10 14 $v =~ /^$re$/is ? :
3333 3 21 $neg ? :
3340 0 1945 unless defined $lv
3341 0 1945 $rhs_expr =~ /^[\w.]+$/ && !($rhs_expr =~ /^-?\d+\.?\d*$/) ? :
3342 0 1945 unless defined $rv
3344 611 605 $n ? :
1216 729 if $op2 eq "="
3345 8 2 $n ? :
10 719 if $op2 =~ /^(!|<>)/
3346 73 0 $n ? :
73 646 if $op2 eq "<"
3347 392 0 $n ? :
392 254 if $op2 eq ">"
3348 123 0 $n ? :
123 131 if $op2 eq "<="
3349 131 0 $n ? :
131 0 if $op2 eq ">="
3360 31 435 if @up > 1
3361 27 408 if ($sql =~ /\bJOIN\b/i)
3367 0 27 if ($join_sql =~ s/\bHAVING\s+(.+?)(?=\s*(?:ORDER\s+BY|LIMIT|OFFSET|$))//is)
3371 1 26 if ($join_sql =~ s/\bGROUP\s+BY\s+(.+?)(?=\s*(?:HAVING|ORDER\s+BY|LIMIT|OFFSET|$))//is)
3380 27 0 if ($parsed)
3385 1 26 if ($needs_groupby) { }
3398 0 27 unless $rows
3400 1 26 if ($needs_groupby)
3404 1 0 if ($sql =~ /^SELECT\s+(.+?)\s+FROM\b/is)
3408 2 1 if ($c =~ /^(.+?)\s+AS\s+(\w+)\s*$/is) { }
3412 1 0 $c =~ /^(\w+)\.(\w+)$/ ? :
3420 1 0 if (@gb_join) { }
3429 0 0 $col =~ /^(\w+)\.(\w+)$/ && defined $row->{$2} ? :
6 0 defined $row->{$col} ? :
3431 6 0 defined $v ? :
3433 3 3 unless exists $gr{$k}
3451 0 3 if ($having_join ne "")
3456 0 0 unless where_sub($h)->({%out})
3462 1 0 if (defined $opts->{'order_by'})
3466 0 3 defined $DB::Handy::a->{$ob} ? :
3467 0 3 defined $DB::Handy::b->{$ob} ? :
3468 0 3 $va =~ /^-?\d+\.?\d*$/ && $vb =~ /^-?\d+\.?\d*$/ ? :
3471 0 3 $dir eq 'desc' ? :
3474 0 1 if (defined $opts->{'offset'} and $opts->{'offset'} > 0)
3477 0 1 if (defined $opts->{'limit'})
3479 0 0 if $l > $#results
3487 0 408 unless my $p = $self->parse_select($sql)
3490 25 383 if $needs_agg
3491 7 376 unless my $sch = $self->_load_schema($tbl)
3494 290 86 if ($where_expr ne "")
3496 147 143 if ($where_expr =~ /^(\w+)\s*(=|!=|<>|<=|>=|<|>)\s*(?:'([^']*)'|(-?\d+\.?\d*))$/ and not $where_expr =~ /\b(?:OR|AND|NOT|BETWEEN|IN)\b/i)
3500 19 128 defined $sv ? :
3502 32 115 if (defined $idx)
3506 0 32 unless open FH, "< $dat"
3514 0 85 unless defined $n and $n == $rs
3515 0 85 if substr($raw, 0, 1) eq "\0"
3517 85 0 if not $wsub or &$wsub($row)
3528 16 242 if (defined $idx_range)
3532 0 16 unless open FH, "< $dat"
3540 0 95 unless defined $n and $n == $rs
3541 0 95 if substr($raw, 0, 1) eq "\0"
3543 95 0 if not $wsub or &$wsub($row)
3554 12 230 if (defined $idx_partial)
3558 0 12 unless open FH, "< $dat"
3566 0 40 unless defined $n and $n == $rs
3567 0 40 if substr($raw, 0, 1) eq "\0"
3569 25 15 if not $wsub or &$wsub($row)
3577 26 204 if (defined $idx_in)
3581 0 26 unless open FH, "< $dat"
3589 0 90 unless defined $n and $n == $rs
3590 0 90 if substr($raw, 0, 1) eq "\0"
3592 90 0 if not $wsub or &$wsub($row)
3601 27 177 if (defined $idx_or)
3605 0 27 unless open FH, "< $dat"
3613 0 420 unless defined $n and $n == $rs
3614 0 420 if substr($raw, 0, 1) eq "\0"
3616 420 0 if not $wsub or &$wsub($row)
3626 0 263 unless open FH, "< $dat"
3633 263 1517 unless defined $n and $n == $rs
3634 11 1506 if substr($raw, 0, 1) eq "\0"
3636 694 812 if not $ws or &$ws($row)
3646 0 408 unless $sql =~ s/^SELECT\s+//is
3648 3 405 if $sql =~ s/^DISTINCT\s+//is
3650 0 408 unless defined $col_str and defined $rest
3653 408 0 if $rest =~ s/^(\w+)//
3656 0 408 if ($rest =~ /^\s+(\w+)/ and not $1 =~ /^(?:WHERE|GROUP|ORDER|HAVING|LIMIT|OFFSET|INNER|LEFT|RIGHT|JOIN|ON|UNION)$/i)
3660 0 408 unless $tbl
3662 4 404 if $rest =~ s/\s+OFFSET\s+(\d+)\s*$//is
3663 11 397 if $rest =~ s/\s+LIMIT\s+(\d+)\s*$//is
3665 53 355 if ($rest =~ s/(?:^|\s+)ORDER\s+BY\s+(.+?)(?=\s*(?:LIMIT|OFFSET|$))//is)
3671 8 47 if $item =~ s/\s+(ASC|DESC)\s*$//is
3676 3 405 if $rest =~ s/(?:^|\s+)HAVING\s+(.+?)(?=\s*(?:ORDER|LIMIT|OFFSET|$))//is
3679 11 397 if ($rest =~ s/(?:^|\s+)GROUP\s+BY\s+(.+?)(?=\s*(?:HAVING|ORDER|LIMIT|OFFSET|$))//is)
3683 294 114 if $rest =~ /(?:^|\s*)WHERE\s+(.+)/is
3695 8 3269 if ($ch eq q['] and not $in_q) { }
8 3261 elsif ($ch eq q['] and $in_q) { }
45 3216 elsif (not $in_q and $ch eq '(') { }
45 3171 elsif (not $in_q and $ch eq ')') { }
408 2763 elsif (not $in_q and $d == 0 and uc substr($str, $i, 4) eq 'FROM' and $i == 0 || substr($str, $i - 1, 1) =~ /\s/ and $i + 4 >= $len || substr($str, $i + 4, 1) =~ /\s/) { }
3722 43 365 if $cs eq "*"
3727 57 395 if ($c =~ /^(.+?)\s+AS\s+(\w+)\s*$/is) { }
3733 0 395 $expr =~ /^(\w+)\.(\w+)$/ ? :
3748 44 332 if (@$ob)
3753 0 0 defined $ra->{$e} ? :
279 0 if (defined $vv) { }
3754 0 0 defined $rb->{$e} ? :
279 0 if (defined $vv) { }
3755 214 65 $va =~ /^-?\d+\.?\d*$/ && $vb =~ /^-?\d+\.?\d*$/ ? :
3756 37 242 if lc $dir eq "desc"
3757 244 35 if $c
3764 372 4 unless defined $offset
3765 3 373 if $offset
3766 11 365 if (defined $limit)
3768 0 11 if $l > $#sorted
3775 98 1271 if ($star) { }
3786 3 373 if ($distinct)
3790 19 0 defined $r->{$_} ? :
3791 8 11 unless $s{$k}++
3803 0 25 unless my $sch = $self->_load_schema($tbl)
3805 4 21 $where_expr ne '' ? :
3808 0 25 unless open FH, "< $dat"
3815 25 141 unless defined $n and $n == $rs
3816 9 132 if substr($raw, 0, 1) eq "\0"
3818 117 15 if not $ws or &$ws($row)
3824 11 14 if (@$gb) { }
3826 71 0 defined $v ? :
3827 29 42 unless exists $gr{$k}
3838 42 1 defined $grp->[0] ? :
3841 7 36 if ($having ne "")
3846 2 5 unless where_sub($h)->({%out})
3850 9 16 if (@$ob)
3855 0 0 defined $ra->{$e} ? :
22 0 if (defined $vv) { }
3856 0 0 defined $rb->{$e} ? :
22 0 if (defined $vv) { }
3857 8 14 $va =~ /^-?\d+\.?\d*$/ && $vb =~ /^-?\d+\.?\d*$/ ? :
3858 0 22 if lc $dir eq "desc"
3859 22 0 if $c
3864 25 0 unless defined $offset
3865 0 25 if $offset
3866 0 25 if (defined $limit)
3868 0 0 if $l > $#results
3876 32 63 if $expr =~ /^COUNT\s*\(\s*\*\s*\)$/is
3877 1 62 if ($expr =~ /^COUNT\s*\(\s*DISTINCT\s+(.+)\s*\)$/is)
3880 5 0 defined $vv ? :
3883 30 32 if ($expr =~ /^(COUNT|SUM|AVG|MIN|MAX)\s*\((.+)\)$/is)
3887 0 30 unless @vals
3888 0 30 if $fn eq "COUNT"
3889 13 17 if ($fn eq "SUM")
3894 9 8 if ($fn eq "AVG")
3899 2 6 if ($fn eq "MIN")
3900 4 0 $a =~ /^-?\d+\.?\d*$/ && $b =~ /^-?\d+\.?\d*$/ ? :
3902 6 0 if ($fn eq "MAX")
3903 13 0 $a =~ /^-?\d+\.?\d*$/ && $b =~ /^-?\d+\.?\d*$/ ? :
3922 99 21410 if ($ch eq q['] and not $in_q) { }
99 21311 elsif ($ch eq q['] and $in_q) { }
329 20982 elsif ($in_q) { }
105 20877 elsif ($ch eq '(') { }
105 20772 elsif ($ch eq ')') { }
4210 16562 elsif ($d == 0 and not $in_q and $i == 0 || substr($sql, $i - 1, 1) =~ /\s/) { }
3946 4 4206 if (uc substr($sql, $i, 5) eq 'UNION' and $i + 5 < $len and substr($sql, $i + 5, 1) =~ /[\s(]/) { }
16 4190 elsif (uc substr($sql, $i, 9) eq 'INTERSECT' and $i + 9 < $len and substr($sql, $i + 9, 1) =~ /[\s(]/) { }
12 4178 elsif (uc substr($sql, $i, 6) eq 'EXCEPT' and $i + 6 < $len and substr($sql, $i + 6, 1) =~ /[\s(]/) { }
3958 32 4178 if ($klen) { }
3964 2 30 if ($kw eq 'UNION' and $i + 3 <= $len and uc substr($sql, $i, 3) eq 'ALL' and $i + 3 >= $len || substr($sql, $i + 3, 1) =~ /\s/) { }
2 28 elsif ($kw eq 'INTERSECT' and $i + 3 <= $len and uc substr($sql, $i, 3) eq 'ALL' and $i + 3 >= $len || substr($sql, $i + 3, 1) =~ /\s/) { }
3 25 elsif ($kw eq 'EXCEPT' and $i + 3 <= $len and uc substr($sql, $i, 3) eq 'ALL' and $i + 3 >= $len || substr($sql, $i + 3, 1) =~ /\s/) { }
3999 466 0 if $cur =~ /\S/
4008 0 31 if $r0->{'type'} eq "error"
4014 0 32 if $r->{'type'} eq "error"
4019 244 0 defined $row->{$_} ? :
4021 2 30 if ($sep eq 'UNION' or $sep eq '') { }
2 28 elsif ($sep eq 'UNION_ALL') { }
14 14 elsif ($sep eq 'INTERSECT') { }
2 12 elsif ($sep eq 'INTERSECT_ALL') { }
9 3 elsif ($sep eq 'EXCEPT') { }
3 0 elsif ($sep eq 'EXCEPT_ALL') { }
4026 10 4 unless $s{&$_key($row)}++
4041 33 22 if $in_rhs{$k} and not $seen{$k}++
4052 3 5 if (($rhs_cnt{$k} || 0) > ($used{$k} || 0))
4066 15 2 unless $in_rhs{$k} or $seen{$k}++
4077 6 8 if (($rhs_cnt{$k} || 0) > ($removed{$k} || 0)) { }
4098 26 0 if $part =~ /^(\w+)\s*=\s*(.+)$/
4105 0 25 unless $self->{'db_name'}
4106 0 25 unless my $sch = $self->_load_schema($table)
4111 0 25 unless open FH, "+< $dat"
4121 17 77 unless defined $x and $x == $rs
4122 76 1 if (substr($raw, 0, 1) ne "\0")
4124 35 41 if (not $ws or &$ws($row))
4132 6 4 unless $ix->{'unique'} and exists $$set_exprs{$ix->{'col'}}
4135 4 0 if ($ep >= 0)
4139 0 4 unless open IF_FH, "< $ef"
4145 2 2 if (unpack("N", $rn) != $rno)
4154 0 33 unless $sch->{'notnull'}
4155 11 1 unless exists $set_exprs->{$cn}
4156 1 0 unless (defined $row->{$cn} and $row->{$cn} ne "")
4163 0 32 unless $sch->{'checks'}
4164 6 9 unless exists $set_exprs->{$cn}
4165 5 4 unless (eval_bool($sch->{'checks'}{$cn}, $row))
4176 4 3 unless exists $$set_exprs{$ix->{'col'}}
4218 0 25 unless ref $opts eq "HASH"
4220 0 25 unless (defined $engine)
4222 0 0 if ($opts->{'RaiseError'})
4231 1 24 defined $opts->{'PrintError'} ? :
4236 24 1 if ($database and !defined($opts->{'AutoUse'}) || $opts->{'AutoUse'})
4238 2 22 if ($res->{'type'} eq "error")
4242 0 24 if ($res->{'type'} eq "error")
4255 2 23 if (defined $dsn and $dsn =~ /[=;]/) { }
4261 23 0 defined $dsn ? :
4263 22 3 unless ref $opts eq "HASH"
4270 0 74 unless my $sth = $self->prepare($sql)
4277 0 145 unless (defined $sql and $sql =~ /\S/)
4288 0 14 unless ref $attr eq "HASH"
4289 0 14 unless my $sth = $self->prepare($sql)
4290 0 14 unless $sth->execute(@bind)
4297 0 2 unless my $rows = $self->selectall_arrayref($sql, {"Slice", {}}, @bind)
4308 0 16 unless my $sth = $self->prepare($sql)
4309 0 16 unless $sth->execute(@bind)
4318 0 3 unless my $sth = $self->prepare($sql)
4319 0 3 unless $sth->execute(@bind)
4328 2 7 unless defined $val
4346 0 1 unless my $cols = $self->{'_engine'}->describe_table($table)
4354 0 4 $_->{'not_null'} ? :
4365 1 2 $_[0]{'_disconnected'} ? :
4373 0 8 unless defined $code
4377 1 7 if ($self->{'PrintError'})
4380 2 6 if ($self->{'RaiseError'})
4420 2 147 if (not @bind and @{$self->{'_bind_params'};})
4427 16 133 if (@bind)
4438 8 141 if ($res->{'type'} eq "error")
4443 68 73 if ($res->{'type'} eq "rows")
4458 73 0 if ($res->{'type'} eq "ok")
4460 56 17 if (defined $res->{'message'} and $res->{'message'} =~ /(\d+)\s+row/)
4465 51 22 if ($sql =~ /^\s*INSERT\b/i)
4472 0 0 if (ref $res->{'data'} eq "ARRAY")
4490 67 1 $data && @$data ? :
4491 0 68 unless defined $sql
4494 68 0 if ($sql =~ /^SELECT\s+(.*?)\s+FROM\b/is) { }
4502 1 67 if $col_str =~ /(?:^|\s)\*(?:\s|$)/
4507 16 705 if ($ch eq '(') { }
16 689 elsif ($ch eq ')') { }
41 648 elsif ($ch eq ',' and $depth == 0) { }
4512 67 0 if length $cur
4517 21 87 if ($part =~ /\bAS\s+(\w+)\s*$/is) { }
0 87 elsif ($part =~ /^(\w+)\.(\w+)$/) { }
87 0 elsif ($part =~ /^(\w+)$/) { }
4535 66 1 if (@$data)
4538 0 106 unless $keys{$nm}
4547 1 145 unless defined $self->{'_rows'}
4548 29 116 if $self->{'_cursor'} >= scalar @{$self->{'_rows'};}
4556 5 28 unless my $href = $self->fetchrow_hashref
4557 28 0 @{$self->{'NAME'};} ? :
4564 1 5 unless my $aref = $self->fetchrow_arrayref
4576 0 17 unless defined $self->{'_rows'}
4578 15 2 if (ref $slice eq 'HASH') { }
4626 8 0 unless defined $code
4631 8 0 if ref $dbh
4637 0 18 unless defined $val
4638 13 5 if $val =~ /^-?\d+\.?\d*$/