Branch Coverage

lib/DB/Handy.pm
Criterion Covered Total %
branch 1267 1928 65.7


line true false branch
35 0 15 if ($] < "5.006")
37 1 14 if $INC[-1] eq "."
78 14 24 unless (-d $self->{'base_dir'})
82 0 14 if ($@)
96 1 14 if (-d $path)
103 0 14 if ($@)
113 3 37 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 101 unless $self->{'db_name'}
157 0 101 if -f $sch_file
164 0 235 unless exists $TYPE_SIZE{$type}
166 7 228 if ($type eq 'CHAR') { }
79 149 elsif ($type eq 'VARCHAR') { }
167 0 7 unless $size and $size > 0
181 0 101 unless open FH, "> $sch_file"
190 0 101 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 1626 unless $self->{'db_name'}
293 1 1625 unless my $sch = $self->_load_schema($table)
297 1651 34 unless $ix->{'unique'}
299 5 29 if ($self->_idx_lookup_exact($table, $ix, $val) >= 0)
306 14 2849 if (!defined($row->{$cn}) || $row->{$cn} eq '' and defined $sch->{'defaults'}{$cn})
310 0 1620 unless $sch->{'notnull'}
311 7 28 unless defined $row->{$cn} and $row->{$cn} ne ""
313 0 1613 unless $sch->{'checks'}
314 3 8 unless eval_bool($sch->{'checks'}{$cn}, $row)
316 0 1610 unless my $packed = $self->_pack_record($sch, $row)
319 0 1610 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 2325 if ($sql =~ /\(\s*SELECT\b/i)
430 29 0 if ($sql =~ /^(?:SELECT|INSERT|UPDATE|DELETE)\b/i)
435 4 2321 if ($sql =~ /^CREATE\s+DATABASE\s+(\w+)$/i)
436 4 0 $self->create_database($1) ? :
440 29 2292 if ($sql =~ /^USE\s+(\w+)$/i)
441 27 2 $self->use_database($1) ? :
445 0 2292 if ($sql =~ /^DROP\s+DATABASE\s+(\w+)$/i)
446 0 0 $self->drop_database($1) ? :
450 1 2291 if ($sql =~ /^SHOW\s+DATABASES$/i)
453 1 2290 if ($sql =~ /^SHOW\s+TABLES$/i)
456 1 2289 if ($sql =~ /^SHOW\s+(?:INDEXES|INDICES|INDEX)\s+(?:ON|FROM)\s+(\w+)$/i)
458 1 0 defined $ixs ? :
462 2 2287 if ($sql =~ /^DESCRIBE\s+(\w+)$/i)
464 2 0 $cols ? :
468 102 2185 if ($sql =~ /^CREATE\s+TABLE\s+(\w+)\s*\((.+)\)$/is)
474 0 236 if ($cd =~ /^PRIMARY\s+KEY\s*\(\s*(\w+)\s*\)$/is)
479 86 150 if ($cd =~ /^(\w+)\s+(CHAR|VARCHAR)\s*\(\s*(\d+)\s*\)(.*)/is) { }
150 0 elsif ($cd =~ /^(\w+)\s+(\w+)(.*)/is) { }
490 0 236 unless defined $rest
491 1 235 if $rest =~ /\bPRIMARY\s+KEY\b/is
492 15 221 if $rest =~ /\b(?:NOT\s+NULL|PRIMARY\s+KEY)\b/is
493 3 4 defined $1 ? :
7 229 if $rest =~ /\bDEFAULT\s+(?:'([^']*)'|(-?\d+\.?\d*))/is
494 6 230 if $rest =~ /\bCHECK\s*\((.+)\)/is
496 1 101 if defined $pk
497 1 101 unless $self->create_table($tbl, [@cols])
498 0 90 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 2182 if ($sql =~ /^DROP\s+TABLE\s+(\w+)$/i)
509 3 0 $self->drop_table($1) ? :
513 34 2148 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 2147 if ($sql =~ /^DROP\s+INDEX\s+(\w+)\s+ON\s+(\w+)$/i)
520 1 0 $self->drop_index($1, $2) ? :
524 2 2145 if ($sql =~ /^VACUUM\s+(\w+)$/i)
526 2 0 defined $n ? :
531 10 2135 if ($sql =~ /^INSERT\s+INTO\s+(\w+)\s+VALUES\s*\((.+)\)$/i)
533 1 9 unless my $sch = $self->_load_schema($tbl)
537 2 7 if (@v != @cols)
544 7 0 $self->insert($tbl, {%row}) ? :
548 1609 526 if ($sql =~ /^INSERT\s+INTO\s+(\w+)\s*\(([^)]+)\)\s*VALUES\s*\((.+)\)$/i)
554 1593 16 $self->insert($tbl, {%row}) ? :
558 4 522 if ($sql =~ /^INSERT\s+INTO\s+(\w+)\s*\(([^)]+)\)\s+(SELECT\b.+)$/is)
566 4 0 if ($sel =~ /^SELECT\s+(.*?)\s+FROM\s+/is)
570 0 4 if $res->{'type'} eq "error"
581 10 0 @src_cols ? :
584 20 0 defined $src_keys[$i] ? :
586 10 0 if $self->insert($tbl, {%row})
590 487 35 if ($sql =~ /^SELECT\b/i)
593 25 10 if ($sql =~ /^UPDATE\s+(\w+)\s+SET\s+(.+?)(\s+WHERE\s+.+)?$/is)
594 24 1 defined $3 ? :
597 24 1 if ($wc =~ /\bWHERE\s+(.+)/is)
602 17 8 defined $n ? :
606 10 0 if ($sql =~ /^DELETE\s+FROM\s+(\w+)(.*)?$/is)
607 10 0 defined $2 ? :
609 10 0 if ($rest =~ /\bWHERE\s+(.+)/is)
614 10 0 defined $n ? :
646 4 29 if ($sql =~ /\bFROM\s*\(/i)
651 0 29 if ($sql =~ /^SELECT\s*\(/i)
657 0 29 if ref $expanded eq "HASH"
660 4 25 if ($expanded =~ /\(\s*SELECT\b/i)
675 0 4 unless ($sql =~ /^SELECT\s+(.+?)\s+FROM\s+(\w+)(.*)?$/i)
678 4 0 defined $3 ? :
680 0 4 unless my $sch = $self->_load_schema($tbl)
684 4 0 unless ($col_str =~ /^\*$/)
690 0 4 if ($rest =~ s/\bLIMIT\s+(\d+)//i)
693 0 4 if ($rest =~ s/\bOFFSET\s+(\d+)//i)
696 1 3 if ($rest =~ s/\bORDER\s+BY\s+(\w+)(?:\s+(ASC|DESC))?//i)
698 0 1 defined $2 ? :
703 4 0 if ($rest =~ /\bWHERE\s+(.+)/i)
718 0 4 unless open FH, "< $dat"
725 4 28 unless defined $n and $n == $recsize
726 28 0 if (substr($raw, 0, 1) ne "\0")
734 15 13 if &$filter({%qrow})
742 1 3 if (my $ob = $opts{'order_by'})
743 1 0 defined $opts{'order_dir'} ? :
746 3 0 defined $va ? :
3 0 defined $vb ? :
0 3 defined $va && $va =~ /^-?\d+\.?\d*$/ && defined $vb && $vb =~ /^-?\d+\.?\d*$/ ? :
750 0 3 $dir eq 'desc' ? :
755 0 4 defined $opts{'offset'} ? :
756 0 4 if $off
757 0 4 if (defined $opts{'limit'})
759 0 0 if $last > $#results
767 15 0 if (@sel_cols) { }
803 0 27 unless defined $pos
816 4 23 if (_subquery_is_correlated($inner_sql))
828 0 23 if (not $inner_res or $inner_res->{'type'} eq "error")
829 0 0 $inner_res ? :
833 0 23 unless $inner_res->{'data'}
837 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) { }
843 17 0 defined $rv[0] ? :
844 15 2 if ($v =~ /^-?\d+\.?\d*$/) { }
851 10 2 if (@vals) { }
864 1 2 @inner_rows ? :
869 0 8 if (@inner_rows > 1)
872 1 7 if (@inner_rows == 0) { }
877 7 0 defined $rv[0] ? :
878 7 0 $v =~ /^-?\d+\.?\d*$/ ? :
901 27 0 if ($inner_sql =~ /\bFROM\s+(\w+)(?:\s+(?:AS\s+)?(\w+))?/i)
902 24 3 defined $2 ? :
906 0 0 defined $2 ? :
913 4 1 unless $inner_tables{$tbl}
932 30 2635 if (substr($sql, $i, 1) eq "(")
937 29 1 if ($peek =~ /^SELECT\b/i)
946 16 1470 if ($ch eq q[']) { }
1430 40 elsif (not $in_str) { }
952 3 1427 if ($ch eq '(') { }
32 1395 elsif ($ch eq ')') { }
958 2 1 if $depth > 1 and $p2 =~ /^SELECT\b/i
966 27 2 if ($depth == 0 and not $has_nested)
979 27 0 defined $best_start ? :
992 23 28 unless %$outer_row
999 264 0 defined $outer_row->{$qkey} ? :
1000 200 64 $val =~ /^-?\d+\.?\d*$/ ? :
1002 132 132 if (index($qkey, '.') != -1) { }
1045 3 3 if ($part =~ /^(NOT\s+)?EXISTS\s*\((.+)\)\s*$/is)
1048 1 2 $neg ? :
1057 0 3 if ($part =~ /^([\w.]+)\s+(NOT\s+)?IN\s*\((\s*SELECT\b.+)\)\s*$/is)
1060 0 0 $neg ? :
1070 1 2 if ($part =~ /^([\w.]+)\s*(=|!=|<>|<=|>=|<|>)\s*\((\s*SELECT\b.+)\)\s*$/is)
1084 2 0 if ($part =~ /^(\w+)\s*(=|!=|<>|<=|>=|<|>|LIKE)\s*(?:'([^']*)'|(-?\d+\.?\d*))$/i)
1086 0 2 defined $sv ? :
1104 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) { }
1134 6 0 if $cur =~ /\S/
1144 0 6 unless $conds and @$conds
1149 4 2 if (($c->{'type'} || '') eq 'subquery') { }
1163 2 34 if $plain_sub and not &$plain_sub($row)
1170 28 0 $res && $res->{'type'} eq 'rows' ? :
1172 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') { }
1173 5 7 unless @rows
1176 4 4 if @rows
1179 0 0 defined $$row{$c->{'col'}} ? :
1183 0 0 defined $rv[0] ? :
1185 0 0 $num ? :
0 0 if ($num ? $col_val == $rv : $col_val eq $rv)
1190 0 0 if $found and $op eq "NOT_IN"
1191 0 0 if not $found and $op eq "IN"
1194 0 8 if @rows > 1
1196 4 4 if (@rows == 0) { }
1203 4 4 unless defined $rhs
1204 4 0 defined $$row{$c->{'col'}} ? :
1207 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 '>=') { }
1208 0 0 $num ? :
0 0 unless $num ? $lhs == $rhs : $lhs eq $rhs
1211 0 0 $num ? :
0 0 unless $num ? $lhs != $rhs : $lhs ne $rhs
1214 0 0 $num ? :
0 0 unless $num ? $lhs < $rhs : $lhs lt $rhs
1217 4 0 $num ? :
0 4 unless $num ? $lhs > $rhs : $lhs gt $rhs
1220 0 0 $num ? :
0 0 unless $num ? $lhs <= $rhs : $lhs le $rhs
1223 0 0 $num ? :
0 0 unless $num ? $lhs >= $rhs : $lhs ge $rhs
1242 0 4 unless ($sql =~ /^SELECT\s+(.+?)\s+FROM\s*\(/is)
1250 0 4 unless ($paren_start >= 0)
1255 0 4 unless (defined $inner_sql)
1265 4 0 if ($after =~ s/^(?:AS\s+)?(\w+)\s*//i) { }
1274 1 3 if ($after =~ s/\bLIMIT\s+(\d+)//i)
1277 0 4 if ($after =~ s/\bOFFSET\s+(\d+)//i)
1280 1 3 if ($after =~ s/\bORDER\s+BY\s+([\w.]+)(?:\s+(ASC|DESC))?//i)
1286 2 2 if ($after =~ /\bWHERE\s+(.+)/i)
1293 0 4 if (not $inner_res or $inner_res->{'type'} eq "error")
1294 0 0 $inner_res ? :
1298 0 4 unless $inner_res->{'data'}
1307 0 40 $k =~ /\.(\w+)$/ ? :
1315 2 2 if ($outer_where_str =~ /\S/)
1322 1 3 if (my $ob = $outer_opts{'order_by'})
1327 17 0 defined $DB::Handy::a->{$ob} ? :
1330 17 0 defined $DB::Handy::b->{$ob} ? :
1331 17 0 defined $va && $va =~ /^-?\d+\.?\d*$/ && defined $vb && $vb =~ /^-?\d+\.?\d*$/ ? :
1335 0 17 $dir eq 'desc' ? :
1341 0 4 if $off
1342 1 3 if (defined $outer_opts{'limit'})
1344 0 1 if $last > $#qualified_rows
1350 0 4 if ($outer_cols_str =~ /^\s*\*\s*$/) { }
1358 13 0 if (exists $r->{$w}) { }
0 0 elsif ($w =~ /^$alias\.(\w+)$/ and exists $r->{$1}) { }
1368 0 0 if ($k =~ /\.\Q$w\E$/ or $k eq $w)
1395 0 0 if ref $expanded eq "HASH"
1410 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) { }
1417 4 200 if ($ch eq '(') { }
4 196 elsif ($ch eq ')') { }
1422 4 0 if ($depth == 0)
1442 0 2028 unless defined $val
1443 1293 735 if ($type eq 'INT') { }
113 622 elsif ($type eq 'FLOAT') { }
1445 0 1293 if $iv > 2147483647
1446 0 1293 if $iv < '-2147483648'
1453 113 0 if unpack "C", "\1\0"
1456 2 111 if ($b[0] & 128) { }
1481 0 1877 unless -f $idx_file
1483 0 1877 unless open FH, "< $idx_file"
1487 0 1877 unless ($magic eq "SDBIDX1\n")
1494 1877 296906 unless defined $n and $n == $entry_size
1505 0 1730 unless open FH, "> $idx_file"
1522 8006 3411 if ($entries->[$mid][0] lt $key_bytes) { }
1559 12 5 if ($entries->[$pos][1] == $rec_no)
1566 12 0 if $deleted
1573 0 38 unless @$entries
1576 31 7 if (defined $lo_val)
1582 23 15 if (defined $hi_val)
1593 0 37 unless my $sch = $self->_load_schema($table)
1595 0 37 unless $ix
1599 37 0 if (-f $dat)
1601 0 37 unless open FH, "< $dat"
1607 37 79 unless defined $n and $n == $recsize
1608 79 0 if (substr($raw, 0, 1) ne "\0")
1622 0 161 unless $conds and @$conds
1623 129 32 unless %{$sch->{'indexes'};}
1629 0 32 unless my $ix = $col2ix{$c->{'col'}}
1631 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 '>=') { }
1669 181 91 unless %{$sch->{'indexes'};}
1677 6 85 if ($where_expr =~ /^(\w+)\s+BETWEEN\s+$VAL\s+AND\s+$VAL\s*$/i)
1679 0 6 defined $lo_s ? :
1680 0 6 defined $hi_s ? :
1681 0 6 unless my $ix = $col2ix{$col}
1685 10 75 if ($where_expr =~ /^(\w+)\s+$OP\s+$VAL\s+AND\s+\1\s+$OP\s+$VAL\s*$/i)
1687 0 10 defined $v1s ? :
1688 0 10 defined $v2s ? :
1689 0 10 unless my $ix = $col2ix{$col}
1692 9 1 if ($op1 eq '>' or $op1 eq '>=') { }
1721 181 75 unless %{$sch->{'indexes'};}
1723 62 13 if $where_expr =~ /\b(?:OR|NOT|BETWEEN|IN)\b/i
1724 0 13 if $where_expr =~ /\(\s*SELECT\b/i
1731 27 0 if ($part =~ /^(\w+)\s*($OP)\s*($VAL)$/ or $part =~ /^($VAL)\s*($OP)\s*(\w+)$/) { }
1735 27 0 if ($part =~ /^(\w+)\s*($OP)\s*($VAL)$/) { }
1753 0 13 unless @atoms >= 2
1764 4 13 unless my $ix = $col2ix{$a->{'col'}}
1766 0 13 if $op eq "!=" or $op eq "<>"
1768 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 '>=') { }
1779 10 0 if $best_eq = $recs
1793 3 0 if defined $recs and not defined $best_rng
1795 10 3 if defined $best_eq
1814 181 66 unless %{$sch->{'indexes'};}
1816 35 31 unless $where_expr =~ /^\s*(\w+)\s+IN\s*\(([^)]*)\)\s*$/is
1821 30 8 if ($candidate->{'col'} eq $col)
1826 1 30 unless defined $ix
1832 1 86 if (defined $nl) { }
9 77 elsif (defined $sv) { }
1844 0 29 unless @vals
1854 98 2 unless $seen{$rn}++
1879 181 37 unless %{$sch->{'indexes'};}
1881 7 30 if $where_expr =~ /\b(?:AND|NOT)\b/i
1882 0 30 if $where_expr =~ /\(\s*SELECT\b/i
1885 2 28 unless @atoms >= 2
1900 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)$/) { }
1902 0 0 unless my $ix = $col2ix{$col}
1909 0 3 unless my $ix = $col2ix{$col}
1911 0 3 unless defined $recs
1916 0 57 if $op eq "!=" or $op eq "<>"
1917 1 56 unless my $ix = $col2ix{$col}
1919 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 '>=') { }
1938 0 59 unless defined $recs
1940 420 4 unless $seen{$rn}++
1969 0 30 unless $self->{'db_name'}
1978 0 62 unless my $sch = $self->_load_schema($js->{'table'})
1990 0 30 unless defined $cur_rows[0] or not $self->{'_last_err'}
2001 32 0 if ($js->{'on_left'} and $js->{'on_right'})
2012 32 0 if (defined $on_r_alias and defined $on_r_col)
2015 141 3 defined $$rr{"$on_r_alias.$on_r_col"} ? :
2024 1 31 if ($join_type eq 'CROSS' or not defined $on_l_alias) { }
24 7 elsif ($join_type eq 'INNER') { }
6 1 elsif ($join_type eq 'LEFT') { }
1 0 elsif ($join_type eq 'RIGHT') { }
2036 151 0 defined $$lr{"$on_l_alias.$on_l_col"} ? :
2038 151 0 $use_hash ? :
2040 0 131 if $use_hash == 0 and not _join_row_matches($lr, $rr, $on_l_alias, $on_l_col, $on_r_alias, $on_r_col)
2048 35 0 defined $$lr{"$on_l_alias.$on_l_col"} ? :
2051 35 0 $use_hash ? :
2054 29 6 if (@$matches) { }
2071 5 0 defined $$rr{"$on_r_alias.$on_r_col"} ? :
2075 35 0 defined $lr->{$l_alias_key} ? :
2076 6 29 if $lkey eq $rkey
2078 3 2 if (@matched_lefts) { }
2102 17 13 if (@$where_conds)
2110 6 24 if (my $ob = $opts->{'order_by'})
2117 57 0 defined $va && $va =~ /^-?\d+\.?\d*$/ && defined $vb && $vb =~ /^-?\d+\.?\d*$/ ? :
2121 11 46 $dir eq 'desc' ? :
2129 1 29 if $offset
2130 2 28 if (defined $opts->{'limit'})
2132 0 2 if $last > $#cur_rows
2139 26 4 if ($col_specs and @$col_specs)
2144 0 54 if ($cs eq '*') { }
1 53 elsif ($cs =~ /^(\w+)\.\*$/) { }
2157 1 0 $alias_info{$a} ? :
2158 1 0 if ($sch)
2174 177 0 if (exists $r->{$ck}) { }
2181 0 0 if ($k =~ /\.\Q$ck\E$/ or $k eq $ck)
2199 0 62 unless my $sch = $self->_load_schema($table)
2205 0 62 unless (open FH, "< $dat")
2211 62 326 unless defined $n and $n == $recsize
2212 0 326 if substr($raw, 0, 1) eq "\0"
2240 83 0 if ($qname =~ /^(\w+)\.(\w+)$/)
2249 0 0 defined $la ? :
2250 0 0 defined $ra ? :
2251 0 0 unless defined $lv and defined $rv
2254 0 0 if ($lv =~ /^-?\d+\.?\d*$/ and $rv =~ /^-?\d+\.?\d*$/)
2255 0 0 $lv == $rv ? :
2257 0 0 $lv eq $rv ? :
2272 0 17 unless $conds and @$conds
2279 101 0 if (defined $c->{'lhs_alias'}) { }
2286 0 0 if ($k =~ /\.\Q$c->{'lhs_col'}\E$/ or $k eq $c->{'lhs_col'})
2292 1 100 unless defined $lv
2296 0 101 if (defined $c->{'rhs_col'}) { }
2297 0 0 if (defined $c->{'rhs_alias'}) { }
2302 0 0 if ($k =~ /\.\Q$c->{'rhs_col'}\E$/ or $k eq $c->{'rhs_col'})
2312 8 93 unless defined $rv
2317 8 93 if ($op eq "IN" or $op eq "NOT_IN")
2321 0 8 unless defined $cv
2323 8 0 $num2 ? :
4 4 if ($num2 ? $lhs_val == $cv : $lhs_val eq $cv)
2328 0 8 if $found and $op eq "NOT_IN"
2329 4 4 if not $found and $op eq "IN"
2335 81 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') { }
2336 43 38 $num ? :
60 21 unless $num ? $lv == $rv : $lv eq $rv
2339 0 0 $num ? :
0 0 unless $num ? $lv != $rv : $lv ne $rv
2342 0 0 $num ? :
0 0 unless $num ? $lv < $rv : $lv lt $rv
2345 9 0 $num ? :
4 5 unless $num ? $lv > $rv : $lv gt $rv
2348 0 0 $num ? :
0 0 unless $num ? $lv <= $rv : $lv le $rv
2351 3 0 $num ? :
1 2 unless $num ? $lv >= $rv : $lv ge $rv
2356 0 0 unless $lv =~ /^$p$/i
2381 0 30 unless $sql =~ /^SELECT\s+(.+?)\s+FROM\s+(.+)$/is
2392 1 29 if ($from_rest =~ s/\s+OFFSET\s+(\d+)\s*$//i)
2395 2 28 if ($from_rest =~ s/\s+LIMIT\s+(\d+)\s*$//i)
2398 7 23 if ($from_rest =~ s/\s+ORDER\s+BY\s+([\w.]+)(?:\s+(ASC|DESC))?\s*$//i)
2410 17 13 if ($from_rest =~ s/\s+WHERE\s+(.+)$//i)
2424 0 30 unless ($fr =~ s/^(\w+)(?:\s+(?:AS\s+)?(\w+))?//)
2427 30 0 defined $2 ? :
2434 6 26 if (defined $type_kw and $type_kw =~ /LEFT/i) { }
1 25 elsif (defined $type_kw and $type_kw =~ /RIGHT/i) { }
1 24 elsif (defined $type_kw and $type_kw =~ /CROSS/i) { }
2443 0 32 unless defined $alias
2454 0 30 if @join_specs < 2
2460 3 27 if ($sel_str =~ /^\s*\*\s*$/) { }
2474 17 13 if $where_str =~ /\S/
2483 0 17 unless defined $expr and $expr =~ /\S/
2489 12 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) { }
2493 12 0 if ($rhs =~ /^-?\d+\.?\d*$/) { }
2511 0 1 defined $sv ? :
0 1 defined $nl ? :
2513 0 1 $neg ? :
2524 6 0 defined $sv ? :
2551 2211 122 if $self->{'_tables'}{$table}
2553 9 113 unless (-f $sch_file)
2558 0 113 unless (open FH, "< $sch_file")
2566 113 391 if (/^RECSIZE=(\d+)/) { }
272 119 elsif (/^COL=(\w+):(\w+):(\d+)/) { }
1 118 elsif (/^NOTNULL=(\w+)/) { }
0 118 elsif (/^DEFAULT=(\w+):(.+)/) { }
1 117 elsif (/^CHECK=(\w+):(.+)/) { }
0 117 elsif (/^PK=(\w+)/) { }
4 113 elsif (/^IDX=(\w+):(\w+):([01])/) { }
2593 4 0 $cdef ? :
4 0 $cdef ? :
2608 0 12 unless open FH, "> $sch_file"
2617 0 12 unless $sch->{'notnull'}
2620 0 12 unless $sch->{'defaults'}
2623 0 12 unless $sch->{'checks'}
2626 1 11 if $sch->{'pk'}
2635 2912 3 defined $$row{$col->{'name'}} ? :
2638 1857 1058 if ($t eq 'INT') { }
100 958 elsif ($t eq 'FLOAT') { }
2640 0 1857 if $iv > 2147483647
2641 0 1857 if $iv < '-2147483648'
2664 5530 3905 if ($t eq 'INT') { }
293 3612 elsif ($t eq 'FLOAT') { }
2666 3 5527 if $uv > 2147483647
2687 0 10 unless defined $wi
2688 10 0 if ref $wi eq "CODE"
2689 0 0 if ref $wi eq "ARRAY"
2699 92 2909 if ($ch eq '(') { }
92 2817 elsif ($ch eq ')') { }
134 2683 elsif ($ch eq ',' and $depth == 0) { }
2715 102 0 if $cur =~ /\S/
2724 0 2840 unless length $str
2725 933 1907 if ($str =~ s/^'((?:[^']|'')*)'(?:\s*,\s*|\s*$)//) { }
1 1906 elsif ($str =~ s/^(NULL)(?:\s*,\s*|\s*$)//i) { }
1906 0 elsif ($str =~ s/^(-?\d+\.?\d*)(?:\s*,\s*|\s*$)//) { }
2753 0 0 if ($part =~ /^(\w+)\s+(NOT\s+)?IN\s*\(([^)]*)\)\s*$/i)
2761 0 0 defined $sv ? :
0 0 defined $nl ? :
2763 0 0 $neg ? :
2772 0 0 if ($part =~ /^(NOT\s+)?EXISTS\s*\((\d+)\)$/i)
2774 0 0 $val ? :
2775 0 0 if $neg
2781 0 0 if ($part =~ /^(NOT\s+)?EXISTS\s+(\d+)$/i)
2783 0 0 $val ? :
2784 0 0 if $neg
2790 0 0 if ($part =~ /^(\w+)\s*(=|!=|<>|<=|>=|<|>)\s*NULL$/i)
2796 0 0 if ($part =~ /^(\w+)\s+IS\s+(NOT\s+)?NULL$/i)
2798 0 0 $neg ? :
2803 0 0 if ($part =~ /^(\w+)\s*(=|!=|<>|<=|>=|<|>|LIKE)\s*(?:'([^']*)'|(-?\d+\.?\d*))$/i)
2805 0 0 defined $sv ? :
2813 4 2 unless $conds and @$conds
2820 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') { }
2821 0 0 unless $c->{'val'}
2825 0 0 defined $$row{$c->{'col'}} ? :
2828 0 0 unless defined $cv
2830 0 0 $num ? :
0 0 if ($num ? $rv == $cv : $rv eq $cv)
2835 0 0 if $found and $op eq "NOT_IN"
2836 0 0 if not $found and $op eq "IN"
2840 0 0 unless not defined $$row{$c->{'col'}} or $$row{$c->{'col'}} eq ""
2843 0 0 unless defined $$row{$c->{'col'}} and $$row{$c->{'col'}} ne ""
2847 8 0 defined $$row{$c->{'col'}} ? :
2850 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') { }
2851 4 0 $num ? :
0 4 unless $num ? $rv == $cv : $rv eq $cv
2854 0 0 $num ? :
0 0 unless $num ? $rv != $cv : $rv ne $cv
2857 0 0 $num ? :
0 0 unless $num ? $rv < $cv : $rv lt $cv
2860 4 0 $num ? :
2 2 unless $num ? $rv > $cv : $rv gt $cv
2863 0 0 $num ? :
0 0 unless $num ? $rv <= $cv : $rv le $cv
2866 0 0 $num ? :
0 0 unless $num ? $rv >= $cv : $rv ge $cv
2871 0 0 unless $rv =~ /^$p$/i
2888 0 4500 unless defined $expr
2890 0 4500 unless length $expr
2891 0 4500 if $expr =~ /^NULL$/i
2892 89 4411 if $expr =~ /^-?\d+\.?\d*$/
2893 18 4393 if ($expr =~ /^'((?:[^']|'')*)'$/)
2897 0 4393 if ($expr =~ /^\((.+)\)$/s and not $1 =~ /^\s*SELECT\b/i)
2900 9 4384 if ($expr =~ /^CASE\b(.*)\bEND$/is)
2903 4 4380 if ($expr =~ /^COALESCE\s*\((.+)\)$/is)
2906 4 2 if defined $v and $v ne ""
2910 2 4378 if ($expr =~ /^NULLIF\s*\((.+)\)$/is)
2912 0 2 unless @a == 2
2914 2 0 if (defined $va and defined $vb)
2915 2 0 $va =~ /^-?\d+\.?\d*$/ && $vb =~ /^-?\d+\.?\d*$/ ? :
1 1 if $va =~ /^-?\d+\.?\d*$/ && $vb =~ /^-?\d+\.?\d*$/ ? $va == $vb : $va eq $vb
2919 2 4376 if ($expr =~ /^CAST\s*\(\s*(.+?)\s+AS\s+(\w+(?:\s*\(\s*\d+\s*\))?)\s*\)$/is)
2922 0 2 unless defined $v
2923 1 1 if $t =~ /^INT/i
2924 0 1 if $t =~ /^(FLOAT|REAL|DOUBLE|NUMERIC|DECIMAL)/i
2927 9 4367 if ($expr =~ /^(UPPER|LOWER|LENGTH|ABS|SIGN|TRIM|LTRIM|RTRIM)\s*\((.+)\)$/is)
2930 0 9 unless defined $v
2931 2 7 if $fn eq "UPPER"
2932 3 4 if $fn eq "LOWER"
2933 2 2 if $fn eq "LENGTH"
2934 0 2 if $fn eq "ABS"
2935 0 0 $v < 0 ? :
0 0 $v > 0 ? :
0 2 if $fn eq "SIGN"
2936 2 0 if ($fn eq "TRIM")
2940 0 0 if ($fn eq "LTRIM")
2944 0 0 if ($fn eq "RTRIM")
2949 0 4367 if ($expr =~ /^ROUND\s*\((.+)\)$/is)
2952 0 0 unless defined $v
2953 0 0 @a > 1 ? :
2956 0 4367 if ($expr =~ /^(FLOOR|CEIL(?:ING)?)\s*\((.+)\)$/is)
2959 0 0 unless defined $v
2960 0 0 $fn eq 'FLOOR' ? :
2962 0 4367 if ($expr =~ /^MOD\s*\((.+)\)$/is)
2964 0 0 unless @a == 2
2966 0 0 if $b == 0
2969 1 4366 if ($expr =~ /^(?:SUBSTR|SUBSTRING)\s*\((.+)\)$/is)
2972 0 1 if ($inner =~ /^(.+?)\s+FROM\s+(\S+)(?:\s+FOR\s+(.+))?$/is) { }
2979 0 1 unless defined $s
2981 0 1 if $st < 1
2982 1 0 defined $le ? :
2986 0 4366 if ($expr =~ /^CONCAT\s*\((.+)\)$/is)
2991 0 0 defined $v ? :
2999 28 13048 if (defined $p)
3003 6 22 if ($opsym eq "||")
3004 6 0 defined $lv ? :
6 0 defined $rv ? :
3006 0 22 unless defined $lv and defined $rv
3008 10 12 if $opsym eq "+"
3009 0 12 if $opsym eq "-"
3010 6 6 if $opsym eq "*"
3011 0 6 if $opsym eq '/' || $opsym eq '%' and $r == 0
3012 0 6 if $opsym eq "/"
3013 6 0 if $opsym eq "%"
3016 0 4338 if ($expr =~ /^-([\w('.].*)$/s)
3018 0 0 unless defined $v
3021 39 4299 if ($expr =~ /^(\w+)\.(\w+)$/)
3023 9 30 exists $$row{"$a.$c"} ? :
3025 4299 0 if $expr =~ /^\w+$/
3033 0 9 unless ($body =~ /^\s*WHEN\b/i)
3034 0 0 if $body =~ s/^(.+?)\s+(?=WHEN\b)//is
3037 9 0 if $body =~ s/\s*\bELSE\b\s+(.+?)\s*$//is
3041 0 15 if (defined $base) { }
3048 6 9 if $m
3050 3 0 defined $else ? :
3056 35 0 if ($expr =~ /^(.+?)\s*(=|!=|<>|<=|>=|<|>)\s*(.+)$/s)
3059 0 35 unless defined $lv and defined $rv
3061 5 0 $n ? :
5 30 if $op eq "="
3062 0 0 $n ? :
0 30 if $op =~ /^(!|<>)/
3063 10 0 $n ? :
10 20 if $op eq "<"
3064 0 0 $n ? :
0 20 if $op eq ">"
3065 5 0 $n ? :
5 15 if $op eq "<="
3066 15 0 $n ? :
15 0 if $op eq ">="
3068 0 0 if ($expr =~ /^(.+)\s+IS\s+(NOT\s+)?NULL$/is)
3070 0 0 $2 ? :
3083 17 2793 if ($ch eq q['] and not $in_q) { }
17 2776 elsif ($ch eq q['] and $in_q) { }
71 2705 elsif ($in_q) { }
45 2660 elsif ($ch eq '(') { }
45 2615 elsif ($ch eq ')') { }
107 2508 elsif ($ch eq ',' and $d == 0) { }
3110 404 0 if $cur =~ /\S/
3122 2 40185 if ($ch eq q['] and not $in_q) { }
2 40183 elsif ($ch eq q['] and $in_q) { }
0 40183 elsif (not $in_q and $ch eq '(') { }
0 40183 elsif (not $in_q and $ch eq ')') { }
27105 13078 elsif (not $in_q and $d == 0 and $i > 0) { }
3135 29 27076 if (substr($expr, $i) =~ /^($op_pat)/)
3148 0 349 unless defined $expr and $expr =~ /\S/
3156 35 484 if @or > 1
3158 45 439 if @and > 1
3159 2 437 if $expr =~ /^NOT\s+(.+)$/is
3160 2 435 if ($expr =~ /^\((.+)\)$/s and not $1 =~ /^\s*SELECT\b/i)
3177 256 12067 if ($ch eq q['] and not $in_q) { }
256 11811 elsif ($ch eq q['] and $in_q) { }
762 11049 elsif ($in_q) { }
120 10929 elsif ($ch eq '(') { }
120 10809 elsif ($ch eq ')') { }
129 10680 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/) { }
3205 56 73 if ($kw eq "AND")
3208 10 46 if ($before =~ /\bBETWEEN\s+\S+\s*$/i)
3226 108 925 @parts > 1 ? :
3232 3 432 if ($part =~ /^(NOT\s+)?EXISTS\s*\((\d+)\)$/i)
3234 1 2 $v ? :
3235 0 3 if $neg
3238 47 385 if ($part =~ /^([\w.]+)\s+(NOT\s+)?IN\s*\(([^)]*)\)$/is)
3243 3 124 if (defined $nl) { }
9 115 elsif (defined $sv) { }
3254 6 41 $neg ? :
3256 1 384 if $part =~ /^[\w.]+\s*(?:=|!=|<>|<=|>=|<|>)\s*NULL$/is
3257 3 381 if ($part =~ /^([\w.]+)\s+IS\s+(NOT\s+)?NULL$/is)
3258 2 1 $2 ? :
3260 10 371 if ($part =~ /^([\w.]+)\s+(NOT\s+)?BETWEEN\s+(.+?)\s+AND\s+(.+)$/is)
3264 1 9 $neg ? :
3266 5 366 if ($part =~ /^(.+?)\s+(NOT\s+)?LIKE\s+('(?:[^']|'')*'|\S+)$/is)
3271 1 4 $neg ? :
3273 366 0 if ($part =~ /^(.+?)\s*(=|!=|<>|<=|>=|<|>)\s*(.+)$/s)
3278 70 296 if ($rhs =~ /^'((?:[^']|'')*)'$/) { }
3292 45 472 if ($op eq "AND")
3294 292 335 unless &$s($_[0])
3296 35 437 if ($op eq "OR")
3298 445 461 if &$s($_[0])
3300 2 435 if ($op eq "NOT")
3302 1 11 &$s($_[0]) ? :
3309 435 0 defined $c->{'op'} ? :
3310 8 24 $c->{'val'} ? :
4 431 if $op eq "CONST"
3311 1 430 if ($op eq "IS_NULL")
3313 3 0 unless not defined $v
3315 2 428 if ($op eq "IS_NOT_NULL")
3317 6 0 if defined $v
3319 10 418 if ($op eq "BETWEEN" or $op eq "NOT_BETWEEN")
3323 0 50 unless defined $v
3325 50 0 $n ? :
3326 4 46 $neg ? :
3329 47 371 if ($op eq "IN" or $op eq "NOT_IN")
3332 585 0 defined $_[0]{$col} ? :
3335 23 1560 unless defined $cv
3337 1524 36 $n ? :
153 1407 if ($n ? $rv == $cv : $rv eq $cv)
3342 45 540 $neg ? :
3345 5 366 if ($op eq "LIKE" or $op eq "NOT_LIKE")
3349 0 24 unless defined $v
3350 10 14 $v =~ /^$re$/is ? :
3351 3 21 $neg ? :
3358 0 1991 unless defined $lv
3359 0 1991 $rhs_expr =~ /^[\w.]+$/ && !($rhs_expr =~ /^-?\d+\.?\d*$/) ? :
3360 0 1991 unless defined $rv
3362 653 609 $n ? :
1262 729 if $op2 eq "="
3363 8 2 $n ? :
10 719 if $op2 =~ /^(!|<>)/
3364 73 0 $n ? :
73 646 if $op2 eq "<"
3365 392 0 $n ? :
392 254 if $op2 eq ">"
3366 123 0 $n ? :
123 131 if $op2 eq "<="
3367 131 0 $n ? :
131 0 if $op2 eq ">="
3378 31 456 if @up > 1
3379 30 426 if ($sql =~ /\bJOIN\b/i)
3385 0 30 if ($join_sql =~ s/\bHAVING\s+(.+?)(?=\s*(?:ORDER\s+BY|LIMIT|OFFSET|$))//is)
3389 1 29 if ($join_sql =~ s/\bGROUP\s+BY\s+(.+?)(?=\s*(?:HAVING|ORDER\s+BY|LIMIT|OFFSET|$))//is)
3398 30 0 if ($parsed)
3403 1 29 if ($needs_groupby) { }
3416 0 30 unless $rows
3418 1 29 if ($needs_groupby)
3422 1 0 if ($sql =~ /^SELECT\s+(.+?)\s+FROM\b/is)
3426 2 1 if ($c =~ /^(.+?)\s+AS\s+(\w+)\s*$/is) { }
3430 1 0 $c =~ /^(\w+)\.(\w+)$/ ? :
3438 1 0 if (@gb_join) { }
3447 0 0 $col =~ /^(\w+)\.(\w+)$/ && defined $row->{$2} ? :
6 0 defined $row->{$col} ? :
3449 6 0 defined $v ? :
3451 3 3 unless exists $gr{$k}
3469 0 3 if ($having_join ne "")
3474 0 0 unless where_sub($h)->({%out})
3480 1 0 if (defined $opts->{'order_by'})
3484 0 3 defined $DB::Handy::a->{$ob} ? :
3485 0 3 defined $DB::Handy::b->{$ob} ? :
3486 0 3 $va =~ /^-?\d+\.?\d*$/ && $vb =~ /^-?\d+\.?\d*$/ ? :
3489 0 3 $dir eq 'desc' ? :
3492 0 1 if (defined $opts->{'offset'} and $opts->{'offset'} > 0)
3495 0 1 if (defined $opts->{'limit'})
3497 0 0 if $l > $#results
3505 0 426 unless my $p = $self->parse_select($sql)
3508 25 401 if $needs_agg
3509 7 394 unless my $sch = $self->_load_schema($tbl)
3512 304 90 if ($where_expr ne "")
3514 161 143 if ($where_expr =~ /^(\w+)\s*(=|!=|<>|<=|>=|<|>)\s*(?:'([^']*)'|(-?\d+\.?\d*))$/ and not $where_expr =~ /\b(?:OR|AND|NOT|BETWEEN|IN)\b/i)
3518 21 140 defined $sv ? :
3520 32 129 if (defined $idx)
3524 0 32 unless open FH, "< $dat"
3532 0 85 unless defined $n and $n == $rs
3533 0 85 if substr($raw, 0, 1) eq "\0"
3535 85 0 if not $wsub or &$wsub($row)
3546 16 256 if (defined $idx_range)
3550 0 16 unless open FH, "< $dat"
3558 0 95 unless defined $n and $n == $rs
3559 0 95 if substr($raw, 0, 1) eq "\0"
3561 95 0 if not $wsub or &$wsub($row)
3572 12 244 if (defined $idx_partial)
3576 0 12 unless open FH, "< $dat"
3584 0 40 unless defined $n and $n == $rs
3585 0 40 if substr($raw, 0, 1) eq "\0"
3587 25 15 if not $wsub or &$wsub($row)
3595 26 218 if (defined $idx_in)
3599 0 26 unless open FH, "< $dat"
3607 0 90 unless defined $n and $n == $rs
3608 0 90 if substr($raw, 0, 1) eq "\0"
3610 90 0 if not $wsub or &$wsub($row)
3619 27 191 if (defined $idx_or)
3623 0 27 unless open FH, "< $dat"
3631 0 420 unless defined $n and $n == $rs
3632 0 420 if substr($raw, 0, 1) eq "\0"
3634 420 0 if not $wsub or &$wsub($row)
3644 0 281 unless open FH, "< $dat"
3651 281 1577 unless defined $n and $n == $rs
3652 11 1566 if substr($raw, 0, 1) eq "\0"
3654 722 844 if not $ws or &$ws($row)
3664 0 426 unless $sql =~ s/^SELECT\s+//is
3666 4 422 if $sql =~ s/^DISTINCT\s+//is
3668 0 426 unless defined $col_str and defined $rest
3671 426 0 if $rest =~ s/^(\w+)//
3674 0 426 if ($rest =~ /^\s+(\w+)/ and not $1 =~ /^(?:WHERE|GROUP|ORDER|HAVING|LIMIT|OFFSET|INNER|LEFT|RIGHT|JOIN|ON|UNION)$/i)
3678 0 426 unless $tbl
3680 4 422 if $rest =~ s/\s+OFFSET\s+(\d+)\s*$//is
3681 12 414 if $rest =~ s/\s+LIMIT\s+(\d+)\s*$//is
3683 57 369 if ($rest =~ s/(?:^|\s+)ORDER\s+BY\s+(.+?)(?=\s*(?:LIMIT|OFFSET|$))//is)
3689 8 51 if $item =~ s/\s+(ASC|DESC)\s*$//is
3694 3 423 if $rest =~ s/(?:^|\s+)HAVING\s+(.+?)(?=\s*(?:ORDER|LIMIT|OFFSET|$))//is
3697 11 415 if ($rest =~ s/(?:^|\s+)GROUP\s+BY\s+(.+?)(?=\s*(?:HAVING|ORDER|LIMIT|OFFSET|$))//is)
3701 308 118 if $rest =~ /(?:^|\s*)WHERE\s+(.+)/is
3713 8 3405 if ($ch eq q['] and not $in_q) { }
8 3397 elsif ($ch eq q['] and $in_q) { }
45 3352 elsif (not $in_q and $ch eq '(') { }
45 3307 elsif (not $in_q and $ch eq ')') { }
426 2881 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/) { }
3740 54 372 if $cs eq "*"
3745 57 413 if ($c =~ /^(.+?)\s+AS\s+(\w+)\s*$/is) { }
3751 0 413 $expr =~ /^(\w+)\.(\w+)$/ ? :
3766 48 346 if (@$ob)
3771 0 0 defined $ra->{$e} ? :
294 0 if (defined $vv) { }
3772 0 0 defined $rb->{$e} ? :
294 0 if (defined $vv) { }
3773 229 65 $va =~ /^-?\d+\.?\d*$/ && $vb =~ /^-?\d+\.?\d*$/ ? :
3774 37 257 if lc $dir eq "desc"
3775 259 35 if $c
3782 390 4 unless defined $offset
3783 3 391 if $offset
3784 12 382 if (defined $limit)
3786 0 12 if $l > $#sorted
3793 114 1280 if ($star) { }
3804 4 390 if ($distinct)
3808 22 0 defined $r->{$_} ? :
3809 10 12 unless $s{$k}++
3821 0 25 unless my $sch = $self->_load_schema($tbl)
3823 4 21 $where_expr ne '' ? :
3826 0 25 unless open FH, "< $dat"
3833 25 141 unless defined $n and $n == $rs
3834 9 132 if substr($raw, 0, 1) eq "\0"
3836 117 15 if not $ws or &$ws($row)
3842 11 14 if (@$gb) { }
3844 71 0 defined $v ? :
3845 29 42 unless exists $gr{$k}
3856 42 1 defined $grp->[0] ? :
3859 7 36 if ($having ne "")
3864 2 5 unless where_sub($h)->({%out})
3868 9 16 if (@$ob)
3873 0 0 defined $ra->{$e} ? :
22 0 if (defined $vv) { }
3874 0 0 defined $rb->{$e} ? :
22 0 if (defined $vv) { }
3875 8 14 $va =~ /^-?\d+\.?\d*$/ && $vb =~ /^-?\d+\.?\d*$/ ? :
3876 0 22 if lc $dir eq "desc"
3877 22 0 if $c
3882 25 0 unless defined $offset
3883 0 25 if $offset
3884 0 25 if (defined $limit)
3886 0 0 if $l > $#results
3894 32 63 if $expr =~ /^COUNT\s*\(\s*\*\s*\)$/is
3895 1 62 if ($expr =~ /^COUNT\s*\(\s*DISTINCT\s+(.+)\s*\)$/is)
3898 5 0 defined $vv ? :
3901 30 32 if ($expr =~ /^(COUNT|SUM|AVG|MIN|MAX)\s*\((.+)\)$/is)
3905 0 30 unless @vals
3906 0 30 if $fn eq "COUNT"
3907 13 17 if ($fn eq "SUM")
3912 9 8 if ($fn eq "AVG")
3917 2 6 if ($fn eq "MIN")
3918 4 0 $a =~ /^-?\d+\.?\d*$/ && $b =~ /^-?\d+\.?\d*$/ ? :
3920 6 0 if ($fn eq "MAX")
3921 13 0 $a =~ /^-?\d+\.?\d*$/ && $b =~ /^-?\d+\.?\d*$/ ? :
3940 101 22284 if ($ch eq q['] and not $in_q) { }
101 22183 elsif ($ch eq q['] and $in_q) { }
336 21847 elsif ($in_q) { }
105 21742 elsif ($ch eq '(') { }
105 21637 elsif ($ch eq ')') { }
4379 17258 elsif ($d == 0 and not $in_q and $i == 0 || substr($sql, $i - 1, 1) =~ /\s/) { }
3964 4 4375 if (uc substr($sql, $i, 5) eq 'UNION' and $i + 5 < $len and substr($sql, $i + 5, 1) =~ /[\s(]/) { }
16 4359 elsif (uc substr($sql, $i, 9) eq 'INTERSECT' and $i + 9 < $len and substr($sql, $i + 9, 1) =~ /[\s(]/) { }
12 4347 elsif (uc substr($sql, $i, 6) eq 'EXCEPT' and $i + 6 < $len and substr($sql, $i + 6, 1) =~ /[\s(]/) { }
3976 32 4347 if ($klen) { }
3982 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/) { }
4017 487 0 if $cur =~ /\S/
4026 0 31 if $r0->{'type'} eq "error"
4032 0 32 if $r->{'type'} eq "error"
4037 244 0 defined $row->{$_} ? :
4039 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') { }
4044 10 4 unless $s{&$_key($row)}++
4059 33 22 if $in_rhs{$k} and not $seen{$k}++
4070 3 5 if (($rhs_cnt{$k} || 0) > ($used{$k} || 0))
4084 15 2 unless $in_rhs{$k} or $seen{$k}++
4095 6 8 if (($rhs_cnt{$k} || 0) > ($removed{$k} || 0)) { }
4116 26 0 if $part =~ /^(\w+)\s*=\s*(.+)$/
4123 0 25 unless $self->{'db_name'}
4124 0 25 unless my $sch = $self->_load_schema($table)
4129 0 25 unless open FH, "+< $dat"
4139 17 77 unless defined $x and $x == $rs
4140 76 1 if (substr($raw, 0, 1) ne "\0")
4142 35 41 if (not $ws or &$ws($row))
4150 5 4 unless $ix->{'unique'} and exists $$set_exprs{$ix->{'col'}}
4153 4 0 if ($ep >= 0)
4157 0 4 unless open IF_FH, "< $ef"
4163 2 2 if (unpack("N", $rn) != $rno)
4172 0 33 unless $sch->{'notnull'}
4173 11 1 unless exists $set_exprs->{$cn}
4174 1 0 unless (defined $row->{$cn} and $row->{$cn} ne "")
4181 0 32 unless $sch->{'checks'}
4182 6 9 unless exists $set_exprs->{$cn}
4183 5 4 unless (eval_bool($sch->{'checks'}{$cn}, $row))
4194 4 3 unless exists $$set_exprs{$ix->{'col'}}
4236 0 26 unless ref $opts eq "HASH"
4238 0 26 unless (defined $engine)
4240 0 0 if ($opts->{'RaiseError'})
4249 1 25 defined $opts->{'PrintError'} ? :
4254 25 1 if ($database and !defined($opts->{'AutoUse'}) || $opts->{'AutoUse'})
4256 2 23 if ($res->{'type'} eq "error")
4260 0 25 if ($res->{'type'} eq "error")
4273 2 24 if (defined $dsn and $dsn =~ /[=;]/) { }
4279 24 0 defined $dsn ? :
4281 23 3 unless ref $opts eq "HASH"
4288 0 74 unless my $sth = $self->prepare($sql)
4295 0 160 unless (defined $sql and $sql =~ /\S/)
4306 0 15 unless ref $attr eq "HASH"
4307 0 15 unless my $sth = $self->prepare($sql)
4308 0 15 unless $sth->execute(@bind)
4315 0 2 unless my $rows = $self->selectall_arrayref($sql, {"Slice", {}}, @bind)
4326 0 17 unless my $sth = $self->prepare($sql)
4327 0 17 unless $sth->execute(@bind)
4336 0 4 unless my $sth = $self->prepare($sql)
4337 0 4 unless $sth->execute(@bind)
4346 2 7 unless defined $val
4364 0 1 unless my $cols = $self->{'_engine'}->describe_table($table)
4372 0 4 $_->{'not_null'} ? :
4383 1 2 $_[0]{'_disconnected'} ? :
4391 0 8 unless defined $code
4395 1 7 if ($self->{'PrintError'})
4398 2 6 if ($self->{'RaiseError'})
4438 2 162 if (not @bind and @{$self->{'_bind_params'};})
4445 17 147 if (@bind)
4456 8 156 if ($res->{'type'} eq "error")
4461 82 74 if ($res->{'type'} eq "rows")
4476 74 0 if ($res->{'type'} eq "ok")
4478 57 17 if (defined $res->{'message'} and $res->{'message'} =~ /(\d+)\s+row/)
4483 52 22 if ($sql =~ /^\s*INSERT\b/i)
4490 0 0 if (ref $res->{'data'} eq "ARRAY")
4518 80 2 $data && @$data ? :
4519 0 82 unless defined $sql
4522 82 0 if ($sql =~ /^SELECT\s+(.*?)\s+FROM\b/is) { }
4530 12 70 if ($col_str =~ /^\*$/ or $col_str =~ /^\w+\.\*$/)
4531 0 12 unless defined $engine
4533 10 2 if ($sql =~ /\bFROM\s+(\w+)(?:\s+(?:AS\s+)?(\w+))?\s*(?:WHERE|ORDER|GROUP|LIMIT|OFFSET|$)/is and not $sql =~ /\bJOIN\b/i)
4537 0 10 unless $sch
4540 9 1 if (@$data)
4542 0 9 if grep {not $keys{$_};} @names
4547 2 0 if ($sql =~ /\bJOIN\b/i)
4548 0 2 unless defined $engine
4551 2 0 if ($sql =~ /\bFROM\s+(\w+)(?:\s+(?:AS\s+)?(\w+))?/is)
4552 2 0 defined $2 ? :
4557 2 0 defined $2 ? :
4563 0 4 unless $sch
4568 2 0 if (@names)
4570 2 0 if (@$data)
4572 0 2 if grep {not $keys{$_};} @names
4584 16 751 if ($ch eq '(') { }
16 735 elsif ($ch eq ')') { }
46 689 elsif ($ch eq ',' and $depth == 0) { }
4589 70 0 if length $cur
4594 21 95 if ($part =~ /\bAS\s+(\w+)\s*$/is) { }
2 93 elsif ($part =~ /^(\w+)\.(\w+)$/) { }
93 0 elsif ($part =~ /^(\w+)$/) { }
4612 69 1 if (@$data)
4615 0 114 unless $keys{$nm}
4624 1 164 unless defined $self->{'_rows'}
4625 32 132 if $self->{'_cursor'} >= scalar @{$self->{'_rows'};}
4633 7 39 unless my $href = $self->fetchrow_hashref
4634 39 0 @{$self->{'NAME'};} ? :
4641 1 6 unless my $aref = $self->fetchrow_arrayref
4653 0 18 unless defined $self->{'_rows'}
4655 16 2 if (ref $slice eq 'HASH') { }
4703 8 0 unless defined $code
4708 8 0 if ref $dbh
4714 0 22 unless defined $val
4715 15 7 if $val =~ /^-?\d+\.?\d*$/