line |
!l |
l&&!r |
l&&r |
condition |
207
|
0 |
0 |
0 |
$errstr =~ /connect|Unknown message type: ''/i and not $errstr =~ /(?:column|relation) "/ |
221
|
0 |
0 |
0 |
$$self{'use_fulltext'} and $$self{'old_fulltext'} |
319
|
0 |
0 |
0 |
$$self{'sphinx'} and $$self{'table'}{$table}{$_}{'sphinx'} |
334
|
0 |
0 |
0 |
$stem and length $search_str_stem |
|
0 |
0 |
0 |
$stem and length $search_str_stem and $$self{'auto_accurate_on_slow'} |
|
0 |
0 |
0 |
$stem and length $search_str_stem and $$self{'auto_accurate_on_slow'} and $search_str_stem =~ /\b\w{$$self{'auto_accurate_on_slow'}}\b/ |
342
|
0 |
0 |
0 |
$double and ($$self{'accurate'} xor not $stem) |
346
|
0 |
0 |
0 |
!$$self{'no_boolean'} && $$param{'adv_query' . $param_num} eq 'on' |
415
|
0 |
0 |
0 |
$$self{'dbh'} and keys %{$$self{'dbh'};} |
422
|
0 |
0 |
0 |
$$self{'dbh'} and $$self{'connected'} |
504
|
0 |
0 |
0 |
$$self{'trace_level'} and $$self{'trace'} |
527
|
0 |
0 |
0 |
$double and ($$self{'accurate'} xor not $stem) |
682
|
0 |
0 |
0 |
$self->can_query and $self->err_parse(\$cmd, $DBI::err, $DBI::errstr) |
701
|
0 |
0 |
0 |
!($work{'die'} || $$self{'die'} || $$self{'fatal'}) && (!$$self{'error_chain_tries'} || $$self{'errors_chain'} < $$self{'error_chain_tries'}) && (!$$self{'error_tries'} || $$self{'errors'} < $$self{'error_tries'}) |
716
|
0 |
0 |
0 |
$self->can_query and $self->err_parse(\$query, $DBI::err, $DBI::errstr) |
721
|
0 |
0 |
0 |
$self->can_query and $self->err_parse(\$query, $DBI::err, $DBI::errstr, 1) |
732
|
0 |
0 |
0 |
$$self{'no_dbirows'} && $ret |
737
|
0 |
0 |
0 |
@_ and $self->prepare(@_) |
759
|
0 |
0 |
0 |
$$self{'explain'} and $$self{'EXPLAIN'} |
764
|
0 |
0 |
0 |
$$self{'sth'} and keys %$_ |
801
|
0 |
0 |
0 |
@hash and %{$hash[0];} |
810
|
0 |
0 |
0 |
$$self{'no_quote_null'} and $s =~ /^null$/i |
811
|
0 |
0 |
0 |
$$self{'dbh'} and not $q |
864
|
0 |
0 |
0 |
$$self{'error_tries'} and $$self{'errors'} > $$self{'error_tries'} |
|
0 |
0 |
0 |
$$self{'error_chain_tries'} and $$self{'errors_chain'} > $$self{'error_chain_tries'} |
877
|
0 |
0 |
0 |
$sth and not $err || $$self{'sth'} |
879
|
0 |
0 |
0 |
not $err and $$self{'dbh'} |
885
|
0 |
0 |
0 |
$errtype and grep {$errtype eq $_;} 'fatal', 'syntax', 'ignore' |
889
|
0 |
0 |
0 |
$errtype and grep {$errtype eq $_;} 'retry' |
891
|
0 |
0 |
0 |
$errtype eq 'install_db' and $$self{'auto_install_db'}-- > 0 |
913
|
0 |
0 |
0 |
$$self{'auto_repair'} and $errtype eq 'repair' |
921
|
0 |
0 |
0 |
$$self{'auto_repair_selected'} and !$repair || $$self{'auto_repair_selected'} && $$self{'table_param'}{$repair}{'no_auto_repair'} |
990
|
0 |
0 |
0 |
$$table{$row}{'unique'} and $$table{$row}{'unique'} =~ /\D/ |
993
|
0 |
0 |
0 |
$$self{'driver'} =~ /pg/i and $$self{'use_fulltext'} |
1025
|
0 |
0 |
0 |
$$table{$row}{'primary'} and $$table{$row}{'type'} =~ /char/i |
1036
|
0 |
0 |
0 |
$$self{'codepage'} eq 'utf-8' and $$self{'driver'} =~ /mysql/ |
1049
|
0 |
0 |
0 |
$type eq 'varchar' and $$table{$_}{'type'} =~ /^smallint$/i |
1050
|
0 |
0 |
0 |
$type eq 'varchar' and $$table{$_}{'type'} =~ /^int$/i |
1051
|
0 |
0 |
0 |
$type eq 'varchar' and $$table{$_}{'type'} =~ /^bigint$/i |
1054
|
0 |
0 |
0 |
$$table{$_}{$type} and $_ ne $row |
1068
|
0 |
0 |
0 |
$$table{$_}{$type} and $_ ne $row |
|
0 |
0 |
0 |
$$table{$_}{$type} and $_ ne $row and $$table{$_}{$type} eq $$table{$row}{$type} |
1076
|
0 |
0 |
0 |
$$table{$_}{'length_max'} and $$table{$_}{'length_max'} < $want |
1097
|
0 |
0 |
0 |
$$table{$row}{'type'} =~ /^varchar$/i and $$table{$row}{'primary'} |
|
0 |
0 |
0 |
$$table{$row}{'type'} =~ /^varchar$/i and $$table{$row}{'primary'} and $$self{'codepage'} eq 'utf-8' |
1131
|
0 |
0 |
0 |
$$table{$row}{'unsigned'} && $$self{'UNSIGNED'} |
|
0 |
0 |
0 |
defined $$table{$row}{'default'} && !$$table{$row}{'auto_increment'} |
|
0 |
0 |
0 |
$$table{$row}{'unique'} && $$table{$row}{'unique'} =~ /^\d+$/ |
1172
|
0 |
0 |
0 |
$$table{$row}{'index'} > 1 && $$table{$row}{'index'} < $$table{$row}{'length'} |
|
0 |
0 |
0 |
$$table{$row}{'index'} and $$self{'index in create table'} |
1228
|
0 |
0 |
0 |
$$self{'cp'} && $$self{'DEFAULT CHARACTER SET'} |
1283
|
0 |
0 |
0 |
$$self{'driver'} =~ /pg/i and grep {$$self{'database'} eq $_;} @_ |
1332
|
0 |
0 |
0 |
$table_insert and @_ |
1381
|
0 |
0 |
0 |
$$self{'table'}{$table}{$_}{'array_insert'} and not $$self{'table'}{$table}{$_}{'no_insert_update'} |
1468
|
0 |
0 |
0 |
ref $$self{'table_param'}{$table}{'filter'} eq 'CODE' and $$self{'table_param'}{$table}{'filter'}($self, $values) |
1484
|
0 |
0 |
0 |
%{{} unless $$self{'table'}{$table}{$_};} and $$self{'table'}{$table}{$_}{'primary'} || $$self{'table'}{$table}{$_}{'unique'} |
|
0 |
0 |
0 |
%{{} unless $$self{'table'}{$table}{$_};} and $$self{'table'}{$table}{$_}{'primary'} || $$self{'table'}{$table}{$_}{'unique'} and $$self{'table'}{$table}{$_}{'type'} ne 'serial' |
1502
|
0 |
0 |
0 |
!($_ =~ /$bymask/) && $_ && %{{} unless $$self{'table'}{$table}{$_};} && defined $$values{$_} |
|
0 |
0 |
0 |
$_ and %{{} unless $$self{'table'}{$table}{$_};} |
1511
|
0 |
0 |
0 |
$where and $bywhere |
1512
|
0 |
0 |
0 |
$whereignore and $where || $bywhere |
1515
|
0 |
0 |
0 |
$set || $lwhere || !$$self{'ON DUPLICATE KEY UPDATE'} and $bywhere || $where || $whereignore |
1526
|
0 |
0 |
0 |
$set and int $_ |
1594
|
0 |
0 |
0 |
ref $$self{'table_param'}{$table}{'filter'} eq 'CODE' and $$self{'table_param'}{$table}{'filter'}($self, $hash) |
1600
|
0 |
0 |
0 |
$$self{'table'}{$table}{$_}{'type'} eq $$self{'char_type'} and $$self{'table'}{$table}{$_}{'length'} |
1628
|
0 |
0 |
0 |
defined $$hash{$_} and length $$hash{$_} |
|
0 |
0 |
0 |
defined $$hash{$_} and length $$hash{$_} and keys %{$$self{'table'}{$table}{$_};} |
1659
|
0 |
0 |
0 |
$$self{'table'}{$table}{'name'} and $$self{'table'}{$table}{'ext'} |
|
0 |
0 |
0 |
$$self{'table'}{$table}{'name'} and $$self{'table'}{$table}{'ext'} and $search_str =~ m[^([^/|"]+[^\s/|"])\.([^/\."|]+)$] |
|
0 |
0 |
0 |
$$self{'table'}{$table}{'tiger'} and $search_str =~ /^\s*([A-Z0-9]{39})\s*$/i |
1681
|
0 |
0 |
0 |
$param_num and not $questions |
1686
|
0 |
0 |
0 |
defined $$param{'q' . $param_num} and $$param{'q' . $param_num} =~ s/(\w+\S?[=:](?:".+?"|\S+))// |
1713
|
0 |
0 |
0 |
$$self{'enable_xor_query'} and $$param{'glueg' . $param_num} eq 'xor' |
1714
|
0 |
0 |
0 |
$$self{'enable_xor_query'} and $$param{'gluel' . $param_num} eq 'xor' |
1715
|
0 |
0 |
0 |
my($days) = $$param{'search_days' . $param_num} =~ /(\d+)/ and $1 |
|
0 |
0 |
0 |
my($days) = $$param{'search_days' . $param_num} =~ /(\d+)/ and $1 and %{{} unless $$self{'table'}{$table}{'time'};} |
1724
|
0 |
0 |
0 |
not $$self{'no_online'} and defined $$param{'online' . $param_num} |
1733
|
0 |
0 |
0 |
$$self{'path_complete'} and $$param{'path' . $param_num} |
|
0 |
0 |
0 |
$$self{'path_complete'} and $$param{'path' . $param_num} and not $$param{'path' . $param_num} =~ m[^[ !/\*]] |
|
0 |
0 |
0 |
$$self{'path_complete'} and $$param{'path' . $param_num} and not $$param{'path' . $param_num} =~ m[^[ !/\*]] and $$param{'path' . $param_num} ne 'EMPTY' |
|
0 |
0 |
0 |
!$$self{'no_regex'} && ($$param{'path' . $param_num} =~ /^\s*reg?e?x?p?:\s*/i || $$param{'path_mode' . $param_num} =~ /[r~]/i) |
|
0 |
0 |
0 |
$$self{'path_complete'} and $$param{'path' . $param_num} and not $$param{'path' . $param_num} =~ m[^[ !/\*]] and $$param{'path' . $param_num} ne 'EMPTY' and not !$$self{'no_regex'} && ($$param{'path' . $param_num} =~ /^\s*reg?e?x?p?:\s*/i || $$param{'path_mode' . $param_num} =~ /[r~]/i) |
1778
|
0 |
0 |
0 |
$pib =~ s/\:$_(\W|$)/$config{$item}{$_}{'to'}$1/g and ++$group_not |
1782
|
0 |
0 |
0 |
not $$self{'no_regex'} and $pib =~ /\s*reg?e?x?p?:\s*/ || $$param{$item . '_mode' . $param_num} =~ /[r~]/i |
1795
|
0 |
0 |
0 |
$pib and $num_cond < 50 |
1803
|
0 |
0 |
0 |
$$self{'enable_xor_query'} and $cond =~ /(xor)/i |
1809
|
0 |
0 |
0 |
!$$self{'no_slow'} || $$self{'table'}{$table}{$item}{'fast_not'} and $pi =~ s/^\s*[\!\-]\s*//g |
1822
|
0 |
0 |
0 |
not $$self{'no_regex'} and $pi =~ s/^\s*reg?e?x?p?:\s*//gi || $$param{$item . '_mode' . $param_num} =~ /[r~]/i |
|
0 |
0 |
0 |
not $$self{'no_soundex'} and $pi =~ s/^\s*sou?n?d?e?x?:\s*//gi || $$param{$item . '_mode' . $param_num} =~ /[s\@]/i |
1835
|
0 |
0 |
0 |
$$self{'no_empty'} and !($pi =~ /\S/) || $pi =~ /^\s*[%_]+\s*$/ |
1849
|
0 |
0 |
0 |
$$self{'sphinx'} and $$self{'table'}{$table}{$item}{'nav_num_field'} |
|
0 |
0 |
0 |
$$self{'sphinx'} and $$self{'table'}{$table}{$item}{'nav_num_field'} and $pi =~ /^\d+$/ |
1864
|
0 |
0 |
0 |
(!$$self{'no_slow'} || $$self{'table'}{$table}{$item}{'fast_not'}) && ($$param{$item . '_mode' . $param_num} =~ /[n!]/i ? ' NOT ' : ' ') |
1886
|
0 |
0 |
0 |
$$param{'adv_query' . $param_num} eq 'on' and not $search_str =~ /((^|\s)\W+\S)|\S\W+(\s|$)/ |
|
0 |
0 |
0 |
$$param{'adv_query' . $param_num} eq 'on' and not $search_str =~ /((^|\s)\W+\S)|\S\W+(\s|$)/ and $search_str =~ /\s/ |
1892
|
0 |
0 |
0 |
not $$self{'use_q_file_fallback'} and my(%tparam) = $self->q_file($table, $search_str) |
|
0 |
0 |
0 |
not $$self{'sphinx'} || $$self{'no_slow'} and $search_str =~ /^\s*\*+\S+/ |
|
0 |
0 |
0 |
not $$self{'sphinx'} || $$self{'no_slow'} and $search_str =~ /^\s*\*+\S+/ and $$self{'table'}{$table}{'path'} |
|
0 |
0 |
0 |
not $$self{'sphinx'} || $$self{'no_slow'} and $search_str =~ /^\s*\*+\S+/ and $$self{'table'}{$table}{'path'} and $$self{'table'}{$table}{'name'} |
|
0 |
0 |
0 |
not $$self{'sphinx'} || $$self{'no_slow'} and $search_str =~ /^\s*\*+\S+/ and $$self{'table'}{$table}{'path'} and $$self{'table'}{$table}{'name'} and $$self{'table'}{$table}{'ext'} |
1918
|
0 |
0 |
0 |
not $$param{'adv_query' . $param_num} and $$self{'ignore_index_fulltext'} || !grep({$$self{'sphinx'} and $$self{'table'}{$table}{$_}{'sphinx'} unless $$self{'table'}{$table}{$_}{'fulltext'};} keys %{$$self{'table'}{$table};}) |
1931
|
0 |
0 |
0 |
!$$self{'no_slow'} && ($$self{'table'}{$table}{$_}{'like_bef'} || $$self{'table_param'}{$table}{'like_bef'} || $$self{'like_bef'}) |
1961
|
0 |
0 |
0 |
not $$self{'sphinx'} and $local_cond > 1 |
1963
|
0 |
0 |
0 |
$after and $ask |
1976
|
0 |
0 |
0 |
$ask && ($close ? ' ) ' x $close : '') |
2012
|
0 |
0 |
0 |
($$self{'allow_count_all'} || $$self{'table'}{$table}{$_}{'allow_count'}) && $$param{'count_' . $_} eq 'on' |
2028
|
0 |
0 |
0 |
$$self{'table'}{$table}{$_}{'allow_count'} && $$param{'count_' . $_} eq 'on' |
2045
|
0 |
0 |
0 |
$$self{'use_sphinx'} and $$self{'sphinx_dbi'} |
|
0 |
0 |
0 |
$$self{'use_sphinx'} and $$self{'sphinx_dbi'} and length $$param{'q'} |
2189
|
0 |
0 |
0 |
$$self{'use_q_file_fallback'} and not $$self{'sphinx'} |
2195
|
0 |
0 |
0 |
$$self{'use_sphinx'} and $$self{'sphinx_dbi'} |
|
0 |
0 |
0 |
$$self{'use_sphinx'} and $$self{'sphinx_dbi'} and length $$param{'q'} |
|
0 |
0 |
0 |
$$self{'use_sphinx'} and $$self{'sphinx_dbi'} and length $$param{'q'} and $file_fallback || !$self->q_file($table, $$param{'q'}) |
2258
|
0 |
0 |
0 |
not $$self{'sphinx'} and $$self{'shard'} |
2295
|
0 |
0 |
0 |
$$self{'use_sphinx'} and $config{'client_bot'} |
2296
|
0 |
0 |
0 |
$$self{'use_sphinx'} and $$self{'no_sphinx_like'} |
2300
|
0 |
0 |
0 |
not $$self{'sphinx'} and $$self{'shard'} |
2342
|
0 |
0 |
0 |
$$self{'use_sphinx'} and @$ids |
2506
|
0 |
0 |
0 |
$$self{'no_slow'} and not $min_data |
2545
|
0 |
0 |
0 |
$$self{'ignore_index'} || $$self{'table_param'}{$table}{'ignore_index'} and not $$self{'no_index'} || $$self{'table_param'}{$table}{'no_index'} |
2554
|
0 |
0 |
0 |
$$self{'ignore_index_fulltext'} and $$self{'table_param'}{$table}{'ignore_index_fulltext'} |
2561
|
0 |
0 |
0 |
$$self{'sphinx'} and $$self{'table_param'}{$table}{'stemmed_index'} |
|
0 |
0 |
0 |
$$self{'sphinx'} and $$self{'table_param'}{$table}{'stemmed_index'} and not $$param{'accurate'} |
2570
|
0 |
0 |
0 |
$table && !$$self{'no_column_prepend_table'} |
2601
|
0 |
0 |
0 |
$$self{'OPTION'} and &psmisc::is_hash($$self{'option'}) |
2612
|
0 |
0 |
0 |
$$self{'limit_offset'} && !$$self{'OFFSET'} |
|
0 |
0 |
0 |
$$self{'OFFSET'} && $$self{'limit_offset'} |
2633
|
0 |
0 |
0 |
$$self{'page'} eq 'rnd' and $$param{'count_f'} eq 'on' |
2832
|
0 |
0 |
0 |
$^O eq 'MSWin32' and $$self{'driver'} eq 'pgpp' |
2919
|
0 |
0 |
0 |
$_ and $$self{'SET NAMES'} |
line |
l |
!l |
condition |
458
|
0 |
0 |
$$self{'error_log'} ||= [] |
510
|
0 |
0 |
$$self{'default'} ||= \%default |
553
|
0 |
0 |
$$self{'driver'} ||= 'mysql5' |
567
|
0 |
0 |
$$self{'cp_int'} ||= 'utf-8' |
568
|
0 |
0 |
$$self{'cp_out'} ||= 'utf-8' |
622
|
0 |
0 |
$$self{'user_params'} ||= sub {
my $self = shift();
($tq, $rq, $vq) = $self->quotes;
my $param = {map({%$_;} @_)};
foreach my $from (keys %{$$self{'param_trans_int'};}) {
my $to = $$self{'param_trans_int'}{$from} || $from;
$$param{$from} = 1 if $$param{$from} eq 'on';
$$self{$to} = &psmisc::check_int($$param{$from}, $$self{$to . '_min'}, $$self{$to . '_max'}, $$self{$to . '_default'});
};
$self->cp_client($work{'codepage'} || $$param{'codepage'} || $config{'codepage'});
}
|
627
|
0 |
0 |
$$self{'dump'} ||= sub {
my $self = shift();
$self->log('dmp', caller, ':=', join(':', %$self));
return 0;
}
|
639
|
0 |
0 |
$$self{'quotes'} ||= sub {
my $self = shift();
$$self{'tq'} ||= $$self{'table quote'};
$$self{'rq'} ||= $$self{'row quote'};
$$self{'vq'} ||= $$self{'value quote'};
return $$self{'table quote'}, $$self{'row quote'}, $$self{'value quote'};
}
|
644
|
0 |
0 |
$$self{'sleep'} ||= sub {
my $self = shift();
$self->log('dev', 'sql_sleeper', @_);
return &psmisc::sleeper(@_);
}
|
649
|
0 |
0 |
$$self{'drh_init'} ||= sub {
my $self = shift();
$$self{'drh'} ||= 'DBI'->install_driver($$self{'dbi'});
return 0;
}
|
666
|
0 |
0 |
$$self{'repair'} ||= sub {
my $self = shift();
my $tim = &psmisc::timer();
@_ = sort(keys %{$$self{'table'};}) unless @_;
@_ = grep({$$self{'table'}{$_} if $_;} @_);
$self->log('info', 'Repairing table...', @_);
$self->flush unless $$self{'no_repair_flush'};
local $$self{'error_tries'} = 0;
$self->query_log('REPAIR TABLE ' . join(',', map($self->tquote("$$self{'table_prefix'}$_"), @_)) . ($$self{'rep_quick'} ? ' ' . $$self{'QUICK'} : '') . ($$self{'rep_ext'} ? ' ' . $$self{'EXTENDED'} : '') . ($$self{'rep_frm'} ? ' ' . $$self{'USE_FRM'} : ''));
$self->flush;
$self->log('time', 'Repair per', &psmisc::human('time_period', &$tim()));
return 0;
}
|
672
|
0 |
0 |
$$self{'queries_time'} / $$self{'queries'} || 1 |
673
|
0 |
0 |
$$self{'query_time'} ||= sub {
my $self = shift();
++$$self{'queries'};
$$self{'queries_time'} += $_[0];
$$self{'queries_avg'} = $$self{'queries_time'} / $$self{'queries'} || 1;
}
|
687
|
0 |
0 |
&$tim() || 1 |
697
|
0 |
0 |
$$self{'do'} ||= sub {
my $self = shift();
my $ret;
return $ret if $self->keep;
$self->err(0);
foreach my $cmd (@_) {
next unless $cmd;
do {
{
$self->log('dmpbef', 'do(' . $$self{'database'} . '):[', $cmd, '] ');
my $tim = &psmisc::timer();
$ret += $$self{'dbh'}->do($cmd) if $$self{'dbh'};
$self->log('dmp', 'do(' . $$self{'database'} . '):[', $cmd, '] = ', $ret, ' per', &psmisc::human('time_period', &$tim()), 'rps', &psmisc::human('float', $ret / (&$tim() || 1)));
$self->query_time(&$tim());
}
} while $self->can_query and $self->err_parse(\$cmd, $DBI::err, $DBI::errstr);
};
return $ret;
}
|
704
|
0 |
0 |
$$self{'can_query'} ||= sub {
my $self = shift();
return !($work{'die'} || $$self{'die'} || $$self{'fatal'}) && (!$$self{'error_chain_tries'} || $$self{'errors_chain'} < $$self{'error_chain_tries'}) && (!$$self{'error_tries'} || $$self{'errors'} < $$self{'error_tries'});
}
|
733
|
0 |
0 |
$$self{'prepare'} ||= sub {
my $self = shift();
my($query) = @_;
return 1 if $self->keep;
$self->log('dmpbef', "prepare query {$query}");
return 2 unless $query;
$self->err(0);
my $ret;
my $tim = &psmisc::timer();
do {
{
next unless $$self{'dbh'};
$$self{'sth'}->finish if $$self{'sth'};
$$self{'sth'} = $$self{'dbh'}->prepare($query);
redo if $self->can_query and $self->err_parse(\$query, $DBI::err, $DBI::errstr, 1);
last unless $$self{'sth'};
$ret = $$self{'sth'}->execute;
}
} while $self->can_query and $self->err_parse(\$query, $DBI::err, $DBI::errstr);
$self->query_time(&$tim());
return 3 if $DBI::err;
$$self{'dbirows'} = 0 if ($$self{'dbirows'} = $DBI::rows) == 4294967294;
$$self{'dbirows'} = $$self{'limit'} if $$self{'no_dbirows'};
return $$self{'no_dbirows'} && $ret ? undef : !int($ret);
}
|
742
|
0 |
0 |
$$self{'sth'}->fetchrow_hashref || {} |
751
|
0 |
0 |
$$self{'line'} ||= sub {
my $self = shift();
return {} if @_ and $self->prepare(@_);
return {} if not $$self{'sth'} or $$self{'sth'}->err;
my $tim = &psmisc::timer();
local $_ = $$self{'sth'}->fetchrow_hashref || {};
$_ = scalar &psmisc::cp_trans_hash($$self{'codepage'}, $$self{'cp_out'}, $_) if $$self{'codepage'} ne $$self{'cp_out'};
$$self{'queries_time'} += &$tim();
$self->log('dmp', 'line(' . $$self{'database'} . '):[', @_, '] = ', scalar keys %$_, ' per', &psmisc::human('time_period', &$tim()), 'err=', $self->err) if (caller 2)[0] ne 'pssql';
return $_;
}
|
778
|
0 |
0 |
&$tim() || 1 |
791
|
0 |
0 |
$$self{'query'} ||= sub {
my $self = shift();
my $tim = &psmisc::timer();
my @hash;
foreach my $query (@_) {
next unless $query;
local $$self{'explain'} = 0, $self->query_log($$self{'EXPLAIN'} . ' ' . $query) if $$self{'explain'} and $$self{'EXPLAIN'};
local $_ = $self->line($query);
next unless keys %$_;
push @hash, $_;
next unless $$self{'sth'} and keys %$_;
my $tim = &psmisc::timer();
while ($_ = $$self{'sth'}->fetchrow_hashref) {
if ($$self{'codepage'} ne $$self{'cp_out'}) {
push @hash, scalar &psmisc::cp_trans_hash($$self{'codepage'}, $$self{'cp_out'}, $_);
}
else {
push @hash, $_;
};
};
$$self{'queries_time'} += &$tim();
};
$self->log('dmp', 'query(' . $$self{'database'} . '):[', @_, '] = ', scalar @hash, ' per', &psmisc::human('time_period', &$tim()), 'rps', &psmisc::human('float', scalar(@hash) / (&$tim() || 1)), 'err=', $self->err);
$$self{'dbirows'} = scalar @hash if $$self{'no_dbirows'} or $$self{'dbirows'} <= 0;
if ($$self{'codepage'} eq 'utf-8') {
foreach $_ (@hash) {
utf8::decode($_) foreach (grep {not ref $_;} %$_);
};
};
return wantarray ? @hash : \@hash;
}
|
797
|
0 |
0 |
$$self{'query_log'} ||= sub {
my $self = shift();
my @ret;
foreach $_ (@_) {
push @ret, $self->query_print($self->query($_));
};
return wantarray ? @ret : \@ret;
}
|
806
|
0 |
0 |
$$self{'query_print'} ||= sub {
my $self = shift();
my(@hash) = @_;
return unless @hash and %{$hash[0];};
$self->log('dbg', 'sql query', $_);
$self->log('dbg', '|', join("\t|", keys %{$hash[0];})) if keys %{$hash[0];};
$self->log('dbg', '|', join("\t|", values %{$_;})) foreach (@hash);
return wantarray ? @_ : \@_;
}
|
812
|
0 |
0 |
$q ||= q['] |
816
|
0 |
0 |
$$self{'quote'} ||= sub {
my $self = shift();
my($s, $q, $qmask) = @_;
return $s if $$self{'no_quote_null'} and $s =~ /^null$/i;
return $$self{'dbh'}->quote(defined $s ? $s : '') if $$self{'dbh'} and not $q;
$q ||= q['];
if ($$self{'quote_slash'}) {
$s =~ s/($q|\\)/\\$1/g;
}
else {
$s =~ s/($q)/$1$1/g;
};
return $q . $s . $q;
}
|
820
|
0 |
0 |
$$self{'squotes'} ||= sub {
my $self = shift();
return ' ' . $self->quote(@_) . ' ';
}
|
824
|
0 |
0 |
$$self{'tquote'} ||= sub {
my $self = shift();
return $$self{'tq'} . $_[0] . $$self{'tq'};
}
|
828
|
0 |
0 |
$$self{'rquote'} ||= sub {
my $self = shift();
return $$self{'rq'} . $_[0] . $$self{'rq'};
}
|
836
|
0 |
0 |
$$self{'filter_row'} ||= sub {
my $self = shift();
my($table, $filter, $values) = @_;
local %_;
map {$_{$_} = $$values{$_};} grep({$$self{'table'}{$table}{$_}{$filter};} keys %{$$self{'table'}{$table};});
return wantarray ? %_ : \%_;
}
|
844
|
0 |
0 |
$errtype ||= 'connection' |
936
|
0 |
0 |
$$self{'err_parse'} ||= sub {
my $self = shift();
my($cmd, $err, $errstr, $sth) = @_;
$err ||= $DBI::err;
$errstr ||= $DBI::errstr;
my $state = $$self{'dbh'}->state if $$self{'dbh'};
my $errtype = $self->error_type($err, $errstr);
$errtype ||= 'connection' unless $$self{'dbh'};
$$self{'fatal'} = 1 if $errtype eq 'fatal';
$self->log('dev', 'err_parse st0 ret1 ', 'wdi=', $work{'die'}, 'di=', $$self{'die'}, 'fa=', $$self{'fatal'}, 'er=', $$self{'errors'} >= $$self{'error_tries'}, $$self{'errors'}, $$self{'error_tries'}, $errtype, $state), CORE::sleep 1, (return $self->err(1)) if $work{'die'} or $$self{'die'} or $$self{'fatal'} or $$self{'error_tries'} and $$self{'errors'} > $$self{'error_tries'} or $$self{'error_chain_tries'} and $$self{'errors_chain'} > $$self{'error_chain_tries'};
$self->log('err', 'err_parse: IMPOSIBLE! !$err and !$self->{sth}'), $self->err('sth'), (return 0) if $sth and not $err || $$self{'sth'};
$$self{'errors_chain'} = 0, (return $self->err(0)) if not $err and $$self{'dbh'};
++$$self{'errors_chain'};
++$$self{'errors'};
$self->log('err', "SQL: error[$err,$errstr,$errtype,$state] on executing {$$cmd} [sleep:$$self{'error_sleep'}] dbh=[$$self{'dbh'}]");
$self->log('dev', "err_parse st3 ret0 fatal=$errtype"), $self->err($errtype), (return 0) if $errtype and grep {$errtype eq $_;} 'fatal', 'syntax', 'ignore';
$self->log('dev', "err_parse sleep($$self{'error_sleep'}), ret1 ");
$self->sleep($$self{'error_sleep'}, 'sql_parse') if $$self{'error_sleep'};
$self->log('dev', "err_parse st3 ret1 fatal=$errtype"), (return $self->err($errtype)) if $errtype and grep {$errtype eq $_;} 'retry';
if ($errtype eq 'install_db' and $$self{'auto_install_db'}-- > 0) {
$self->log('info', 'SQL: trying automatic install db');
$self->create_databases(@_);
return $self->err($errtype);
};
$self->log('info', "SQL: trying reconnect[$$self{'connected'}]"), $self->reconnect, (return $self->err('dbh')) unless $$self{'dbh'};
if ($errtype eq 'install' or $errtype eq 'upgrade') {
if ($$self{'auto_install'}-- > 0) {
$self->log('dev', 'SQL:install err ');
$self->log('info', 'SQL: trying automatic install');
$self->$errtype;
return $self->err($errtype);
}
else {
$self->log('dev', 'SQL:NOinstall err ');
$self->err($errtype);
return 0;
};
};
$self->log('err', 'SQL: connection error, trying reconnect and retry last query'), $self->dropconnect, $self->reconnect, (return $self->err($errtype)) if $errtype eq 'connection';
if ($$self{'auto_repair'} and $errtype eq 'repair') {
my($repair) = $errstr =~ m['(?:.*[\\/])*(\w+)(?:\.my\w)?']i;
$repair = $$self{'current_table'} unless %{{} unless $$self{'table'}{$repair};};
if ($$self{'auto_repairs'}{$repair} < $$self{'auto_repairs_max'}) {
my $sl = int rand $$self{'auto_repair'} + 1;
$self->log('info', 'pre repair sleeping', $sl);
$self->sleep($sl);
if ($sl == 0 or $$self{'force_repair'}) {
$self->log('info', 'denied repair', $repair), (return $self->err(1)) if $$self{'auto_repair_selected'} and !$repair || $$self{'auto_repair_selected'} && $$self{'table_param'}{$repair}{'no_auto_repair'};
++$$self{'auto_repairs'}{$repair};
$self->log('info', 'SQL: trying automatic repair', $repair);
$self->repair($repair);
$$self{'rep_ext'} = $$self{'rep_frm'} = 1;
$$self{'rep_quick'} = 0;
return $self->err($errtype);
};
};
};
$self->log('dev', 'err_parse st2 ret1 no dbh', $err, $errstr), (return $self->err('dbh')) unless $$self{'dbh'};
$self->log('dev', "err_parse unknown error ret($$self{'err_retry_unknown'}), end: [$err], [$errstr], [$errtype]");
return $self->err($$self{'err_retry_unknown'});
}
|
940
|
0 |
0 |
$$self{'install'} ||= sub {
my $self = shift();
return $self->create_databases(@_) + $self->create_tables;
}
|
963
|
0 |
0 |
$$self{'create_database'} ||= sub {
my $self = shift();
my $ret;
local $_;
local(@_) = $$self{'database'} unless @_;
$self->drh_init if $$self{'use_drh'};
foreach my $db (@_) {
if ($$self{'use_drh'}) {
$ret += $_ = $$self{'drh'}->func('createdb', $db, $$self{'host'}, $$self{'user'}, $$self{'pass'}, 'admin');
}
elsif ($$self{'driver'} =~ /pg/i) {
{
my $db = $$self{'dbname'};
local $$self{'dbname'} = 'postgres';
local $$self{'database'} = undef;
local $$self{'in_connect'} = undef;
$self->do("CREATE DATABASE $rq$db$rq WITH ENCODING $vq$$self{'cp'}$vq");
};
$self->reconnect;
};
$self->log('info', 'install database ', $db, '=', $ret);
};
return $ret;
}
|
967
|
0 |
0 |
$$self{'create_databases'} ||= sub {
my $self = shift();
return $self->create_database($$self{'database'});
}
|
978
|
0 |
0 |
$$self{'create_tables'} ||= sub {
my $self = shift();
my(%table) = %{{} unless $$self{'table'};};
my @ret;
foreach my $tab (sort keys %table) {
$self->log('dev', 'creating table', $tab);
push @ret, $$self{'create_table'}($self, $tab, $table{$tab});
push @ret, $$self{'create_index'}($self, $tab, $table{$tab}) unless $$self{'index in create table'};
};
return @ret;
}
|
1234
|
0 |
0 |
$$self{'create_table'} ||= sub {
my $self = shift();
my($tab, $table) = @_;
my(@subq, @ret);
return undef if $tab =~ /^\W/;
my(@primary, %unique, %fulltext, @do);
foreach my $row (sort {$$table{$b}{'order'} <=> $$table{$a}{'order'};} keys %$table) {
push @primary, $rq . $row . $rq if $$table{$row}{'primary'};
push @{$fulltext{$$table{$row}{'fulltext'}};}, $rq . $row . $rq if $$table{$row}{'fulltext'};
push @{$unique{$$table{$row}{'unique'}};}, $rq . $row . $rq if $$table{$row}{'unique'} and $$table{$row}{'unique'} =~ /\D/;
};
if ($$self{'driver'} =~ /pg/i and $$self{'use_fulltext'}) {
push(@do, "DROP TRIGGER $$self{'IF EXISTS'} ${tab}_update_$_ ON $tab", $$self{'old_fulltext'} ? "CREATE TRIGGER ${tab}_update_$_ BEFORE UPDATE OR INSERT ON $tab FOR EACH ROW EXECUTE PROCEDURE tsearch2($rq$_$rq, " . join(', ', @{[] unless $fulltext{$_};}) . ')' : "CREATE TRIGGER ${tab}_update_$_ BEFORE UPDATE OR INSERT ON $tab FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger($rq$_$rq, $vq$$self{'fulltext_config'}$vq, " . join(', ', @{[] unless $fulltext{$_};}) . ')'), $$table{$_} = {'order', -9999, 'type', 'tsvector'} foreach (keys %fulltext);
};
foreach my $row (grep {keys %{$$table{$_};};} keys %$table) {
$$table{$row}{'varchar'} = 1 if $$table{$row}{'type'} =~ /^varchar$/i;
};
foreach my $row (sort {$$table{$b}{'order'} <=> $$table{$a}{'order'};} grep({keys %{$$table{$_};};} keys %$table)) {
next if $row =~ /^\W/;
$$table{$row}{'length'} = &psmisc::min($$self{'varchar_max'}, $$table{$row}{'length'});
my $length = $$table{$row}{'length'};
unless (defined $length) {
{
my(@types, @maxs);
push @types, 'primary' if $$table{$row}{'primary'} and $$table{$row}{'type'} =~ /char/i;
push @types, 'fulltext' if $$table{$row}{'fulltext'};
push @types, 'unique' if $$table{$row}{'unique'};
push @types, 'varchar' if $$table{$row}{'varchar'};
last unless @types;
foreach my $type (@types) {
my $max;
$max = $$self{$type . '_max'};
$max /= 3 if $$self{'codepage'} eq 'utf-8' and $$self{'driver'} =~ /mysql/;
my($same, $nowtotal);
foreach $_ (grep {$_;} keys %{$table;}) {
$nowtotal += 2 if $type eq 'varchar' and $$table{$_}{'type'} =~ /^smallint$/i;
$nowtotal += 4 if $type eq 'varchar' and $$table{$_}{'type'} =~ /^int$/i;
$nowtotal += 8 if $type eq 'varchar' and $$table{$_}{'type'} =~ /^bigint$/i;
next unless $$table{$_}{$type} eq $$table{$row}{$type};
next unless $$table{$_}{$type} and $_ ne $row;
$nowtotal += $$table{$_}{'length'};
++$same unless $$table{$_}{'length'};
};
$max -= $nowtotal;
my $want = $max / ($same + 1);
$nowtotal = 0;
foreach $_ (grep {not $$table{$_}{'length'} if $$table{$_}{$type} and $_ ne $row and $$table{$_}{$type} eq $$table{$row}{$type};} keys %{$table;}) {
--$same, $max -= $$table{$_}{'length_max'}, $nowtotal += $$table{$_}{'length_max'} if $$table{$_}{'length_max'} and $$table{$_}{'length_max'} < $want;
};
$max /= $same + 1 if $same;
$max = int $max;
push @maxs, $max;
};
push @maxs, $$table{$row}{'length_max'} if $$table{$row}{'length_max'};
push @maxs, $$self{'varchar_max'} if $$table{$row}{'type'} =~ /^varchar$/i;
push @maxs, $$self{'key_length'} / 3 if $$table{$row}{'type'} =~ /^varchar$/i and $$table{$row}{'primary'} and $$self{'codepage'} eq 'utf-8';
$length = &psmisc::min(grep({$_ > 0;} @maxs));
$$table{$row}{'length'} ||= $length;
$length = int $length;
};
};
push @subq, $rq . $row . $rq . " $$table{$row}{'type'} " . ($length ? "($length) " : '') . ($$table{$row}{'unsigned'} && $$self{'UNSIGNED'} ? ' ' . $$self{'UNSIGNED'} : '') . (!$$table{$row}{'auto_increment'} ? $$table{$row}{'not null'} ? ' NOT NULL ' : '' : '') . (defined $$table{$row}{'default'} && !$$table{$row}{'auto_increment'} ? ' DEFAULT ' . ($$table{$row}{'default'} eq 'NULL' ? 'NULL' : "$vq$$table{$row}{'default'}$vq") . ' ' : '') . ($$table{$row}{'unique'} && $$table{$row}{'unique'} =~ /^\d+$/ ? ' UNIQUE ' : '') . ($$table{$row}{'auto_increment'} && 1 ? ' ' . $$self{'AUTO_INCREMENT'} . ' ' : '') . "$$table{$row}{'param'}";
};
push @subq, 'PRIMARY KEY (' . join(',', @primary) . ')' if @primary;
foreach my $row (sort {$$table{$b}{'order'} <=> $$table{$a}{'order'};} keys %$table) {
push @subq, 'INDEX ' . $rq . $row . $$self{'index_postfix'} . $rq . ' (' . $rq . $row . $rq . ($$table{$row}{'index'} > 1 && $$table{$row}{'index'} < $$table{$row}{'length'} ? '(' . $$table{$row}{'index'} . ')' : '') . ')' if $$table{$row}{'index'} and $$self{'index in create table'};
push @primary, $rq . $row . $rq if $$table{$row}{'primary'};
};
push @subq, 'UNIQUE ' . ($$self{'unique name'} ? $rq . $_ . $rq : '') . ' (' . join(',', @{$unique{$_};}) . ')' foreach (grep @{$unique{$_};}, keys %unique);
if ($$self{'index in create table'}) {
push @subq, "FULLTEXT $rq$_$rq (" . join(',', @{$fulltext{$_};}) . ')' foreach (grep @{$fulltext{$_};}, keys %fulltext);
};
return map({$self->do($_);} grep({$_;} !@subq ? () : 'CREATE TABLE ' . $$self{'IF NOT EXISTS'} . " $tq$$self{'table_prefix'}$tab$tq (" . join(',', @subq) . join(' ', '', grep({$_;} $$self{'table_constraint'}, $$self{'table_param'}{$tab}{'table_constraint'})) . ') ' . $$self{'table options'} . ' ' . $$self{'table_param'}{$tab}{'table options'} . ($$self{'cp'} && $$self{'DEFAULT CHARACTER SET'} ? " $$self{'DEFAULT CHARACTER SET'} $vq$$self{'cp'}$vq " : '') . ';', @do));
}
|
1260
|
0 |
0 |
$$self{'create_index'} ||= sub {
my $self = shift();
my @ret;
my($tab, $table) = @_;
my @subq;
foreach my $row (sort {$$table{$b}{'order'} <=> $$table{$a}{'order'};} keys %$table) {
next if $row =~ /^\W/;
push @ret, 'CREATE INDEX ' . $$self{'index_IF NOT EXISTS'} . ' ' . $rq . $row . ($$self{'index_name_table'} ? '_' . $tab : '') . $$self{'index_postfix'} . $rq . ' ON ' . " $tq$$self{'table_prefix'}$tab$tq ( $rq$row$rq )" if $$table{$row}{'index'};
};
return $self->do(@ret);
}
|
1264
|
0 |
0 |
$$self{'create_indexes'} ||= sub {
$self->create_index($_, $$self{'table'}{$_}) foreach (keys %{$$self{'table'};});
}
|
1277
|
0 |
0 |
$$self{'drop_table'} ||= sub {
my $self = shift();
my @ret;
foreach my $tab (@_) {
my $sql;
next if $tab =~ /^\W/ or not $tab =~ /\w/;
$sql .= 'DROP TABLE ' . $$self{'IF EXISTS'} . " $tq$$self{'table_prefix'}$tab$tq $$self{'CASCADE'}";
push @ret, $sql;
};
return $self->do(@ret);
}
|
1301
|
0 |
0 |
$$self{'drop_database'} ||= sub {
my $self = shift();
my @ret;
@_ = $$self{'database'} unless @_;
my $rec = 1 if $$self{'driver'} =~ /pg/i and grep {$$self{'database'} eq $_;} @_;
if ($rec) {
local $$self{'dbname'} = undef;
local $$self{'database'} = undef;
$$self{'dbname'} = $$self{'database'} = 'postgres' if $$self{'driver'} =~ /pg/i;
$self->reconnect;
};
foreach my $tab (@_) {
my $sql;
next if $tab =~ /^\W/ or not $tab =~ /\w/;
$sql .= 'DROP DATABASE ' . $$self{'IF EXISTS'} . " $tq$$self{'table_prefix'}$tab$tq";
push @ret, $sql;
};
@ret = $self->do(@ret);
if ($rec) {
$self->reconnect;
};
return @ret;
}
|
1306
|
0 |
0 |
$$self{'drop_tables'} ||= sub {
my $self = shift();
@_ = keys %{{} unless $$self{'table'};} unless @_;
return $self->drop_table(@_);
}
|
1317
|
0 |
0 |
$$self{'insert_fields'} ||= sub {
my $self = shift();
my $table = shift() || $$self{'current_table'};
return grep({$$self{'table'}{$table}{$_}{'array_insert'};} keys %{$$self{'table'}{$table};});
}
|
1324
|
0 |
0 |
$$self{'insert_order'} ||= sub {
my $self = shift();
my $table = shift() || $$self{'current_table'};
return (sort {$$self{'table'}{$table}{$b}{'order'} <=> $$self{'table'}{$table}{$a}{'order'};} $self->insert_fields($table));
}
|
1400
|
0 |
0 |
$$self{'stat'}{'time'}{'time'} || 1 |
|
0 |
0 |
time - $$self{'stat'}{'time'}{'full'} || 1 |
1420
|
0 |
0 |
$$self{'insert_cached'} ||= sub {
my $self = shift();
my $table = shift();
my $table_insert = $table || $$self{'current_table'};
my @dummy;
++$$self{'inserts'}, ++$$self{'table_updated'}{$table_insert}, push(@{$$self{'insert_buffer'}{$table_insert};}, \@_) if $table_insert and @_;
foreach my $table ($table ? $table : keys %{$$self{'insert_buffer'};}) {
$$self{'insert_block'}{$table} //= $$self{'table_param'}{$table}{'insert_by'} || $$self{'insert_by'};
if ($$self{'insert_block'}{$table}-- <= 1 or not scalar @_ or time - ($$self{'insert_buffer_time'}{$table} ||= time) > $$self{'insert_cached_time'}) {
$$self{'stat'}{'time'}{'count'} += scalar @{[] unless $$self{'insert_buffer'}{$table_insert};};
$$self{'insert_buffer_time'}{$table} = time;
$$self{'current_table'} = $table;
$self->do(join('', ($$self{'ON DUPLICATE KEY UPDATE'} ? $$self{'INSERT'} : $$self{'REPLACE'}) . " $$self{$$self{'insert_options'}} INTO $tq$$self{'table_prefix'}$table$tq (", join(',', map({$rq . $_ . $rq;} $self->insert_order($table))), ") VALUES\n", join(",\n", map({join '', '(', join(',', map({$self->quote(scalar &psmisc::cp_trans($$self{'cp_in'}, $$self{'codepage'}, $$_));} @{$_;}[0 .. scalar($self->insert_fields($table)) - 1], @dummy = (map {\$$self{'table'}{$table}{$_}{'default'};} $self->insert_order($table))[scalar @{$_;} .. scalar($self->insert_fields($table)) - 1])), ')';} @{$$self{'insert_buffer'}{$table};})), !$$self{'ON DUPLICATE KEY UPDATE'} ? '' : " \n" . $$self{'ON DUPLICATE KEY UPDATE'} . ' ' . join(',', map({$rq . $_ . $rq . '=VALUES(' . $rq . $_ . $rq . ')';} (sort {$$self{'table'}{$table}{$b}{'order'} <=> $$self{'table'}{$table}{$a}{'order'};} grep({not $$self{'table'}{$table}{$_}{'added'} if $$self{'table'}{$table}{$_}{'array_insert'} and not $$self{'table'}{$table}{$_}{'no_insert_update'};} keys %{$$self{'table'}{$table};})))), ';')), delete $$self{'insert_buffer'}{$table} if scalar @{[] unless $$self{'insert_buffer'}{$table};};
$$self{'insert_block'}{$table} = $$self{'table_param'}{$table}{'insert_by'} || $$self{'insert_by'};
$$self{'stat'}{'time'}{'time'} += time - $$self{'insert_buffer_time'}{$table};
&psmisc::schedule([$$self{'stat_every'}, $$self{'stat_every'}], sub {
$self->log('time', 'inserts', $$self{'stat'}{'time'}{'count'}, 'per', &psmisc::human('time_period', $$self{'stat'}{'time'}{'time'}), 'at', &psmisc::human('float', $$self{'stat'}{'time'}{'count'} / ($$self{'stat'}{'time'}{'time'} || 1)), 'rps', 'full', &psmisc::human('float', $$self{'stat'}{'time'}{'count'} / (time - $$self{'stat'}{'time'}{'full'} || 1)), 'rps');
$$self{'stat'}{'time'} = {'full', time};
}
) if $$self{'stat_every'};
};
};
return undef;
}
|
1447
|
0 |
0 |
$$self{'flush_insert'} ||= sub {
my $self = shift();
$self->insert_cached(@_);
0;
}
|
1453
|
0 |
0 |
$$self{'insert'} ||= sub {
my $self = shift();
my(@ret) = $self->insert_cached(@_);
$self->flush_insert($_[0]) if scalar @_ > 1;
return @ret;
}
|
1478
|
0 |
0 |
$by ||= [grep({$$self{'table'}{$table}{$_}{'unique'} unless $$self{'table'}{$table}{$_}{'primary'};} keys %{{} unless $$self{'table'}{$table};})] |
1529
|
0 |
0 |
$$self{'update'} ||= sub {
my $self = shift();
my $table = shift() || $$self{'current_table'};
my($by, $values, $where, $set, $setignore, $whereignore) = @_;
return unless %{{} unless $$self{'table'}{$table};};
$$self{'current_table'} = $table;
next if ref $$self{'table_param'}{$table}{'filter'} eq 'CODE' and $$self{'table_param'}{$table}{'filter'}($self, $values);
$$self{'handler_insert'}($table, $values) if ref $$self{'handler_insert'} eq 'CODE';
$self->stem_insert($table, $values);
local $$self{'handler_insert'} = undef;
local $$self{'stem_insert'} = sub {
}
;
local @_;
$by ||= [grep({$$self{'table'}{$table}{$_}{'unique'} unless $$self{'table'}{$table}{$_}{'primary'};} keys %{{} unless $$self{'table'}{$table};})];
my $bymask = '^(' . join(')|(', @$by) . ')$';
my $bywhere = join(' AND ', map(("$rq$_$rq=" . $self->quote($$values{$_})), grep({not $$self{'table'}{$table}{$_}{'auto_increment'} if %{{} unless $$self{'table'}{$table}{$_};} and $$self{'table'}{$table}{$_}{'primary'} || $$self{'table'}{$table}{$_}{'unique'} and $$self{'table'}{$table}{$_}{'type'} ne 'serial';} @$by)));
$set ||= join(', ', map({$rq . $_ . $rq . '=' . $self->quote($self->cut($$values{$_}, $$self{'table'}{$table}{$_}{'length'}));} @_ = grep((!($_ =~ /$bymask/) && $_ && %{{} unless $$self{'table'}{$table}{$_};} && defined $$values{$_}), keys %$values), @_ ? () : grep({defined $$values{$_} if $_ and %{{} unless $$self{'table'}{$table}{$_};};} keys %$values)));
$set = 'SET ' . $set if $set;
my $lwhere = $where;
$where = '' if $where eq 1;
$where = ' AND ' . $where if $where and $bywhere;
$whereignore = ' AND ' . $whereignore if $whereignore and $where || $bywhere;
local $_;
$_ = $self->do("UPDATE $$self{$$self{'update_options'}} $$self{'IGNORE'} $tq$$self{'table_prefix'}$table$tq $set $setignore WHERE $bywhere $where $whereignore") if $set || $lwhere || !$$self{'ON DUPLICATE KEY UPDATE'} and $bywhere || $where || $whereignore;
$self->insert_data($table, $values), $self->flush_insert($table) unless $set and int $_ or $lwhere;
return undef;
}
|
1540
|
0 |
0 |
$$self{'insert_hash'} ||= sub {
my $self = shift();
return $self->insert_data(@_) unless $$self{'driver'} =~ /pg/i;
my $table = shift() || $$self{'current_table'};
my $ret;
foreach $_ (@_) {
$ret += $self->update($table, undef, $_);
};
return $ret;
}
|
1548
|
0 |
0 |
$$self{'cut'} ||= sub {
my $self = shift();
return $_[0] unless $_[1];
return $_[0] = substr($_[0], 0, $_[1]);
}
|
1645
|
0 |
0 |
$$self{'insert_data'} ||= sub {
my $self = shift();
my $table = shift() || $$self{'current_table'};
foreach my $hash (@_) {
next unless $hash;
$$hash{$_} = $$self{'table'}{$table}{$_}{'default_insert'} || ($$self{'table'}{$table}{$_}{'array_insert'} ? $$self{'table'}{$table}{$_}{'default'} : undef) foreach (grep {not defined $$hash{$_};} keys %{$$self{'table'}{$table};});
next if grep {not $$hash{$_} if $$self{'table'}{$table}{$_}{'insert_min'};} keys %{$$self{'table'}{$table};};
$self->handler_insert0($table, $hash);
next if ref $$self{'table_param'}{$table}{'filter'} eq 'CODE' and $$self{'table_param'}{$table}{'filter'}($self, $hash);
$self->handler_insert($table, $hash);
$self->stem_insert($table, $hash);
$self->cut($$hash{$_}, $$self{'table'}{$table}{$_}{'length'}) foreach (grep {length $$hash{$_} > $$self{'table'}{$table}{$_}{'length'} if $$self{'table'}{$table}{$_}{'type'} eq $$self{'char_type'} and $$self{'table'}{$table}{$_}{'length'};} keys %{$$self{'table'}{$table};});
local $$self{'table'}{$table} = $$self{'table'}{$table};
my $chanded;
++$chanded == 1 ? $self->flush_insert($table) : (), $$self{'table'}{$table}{$_}{'array_insert'} = 1 foreach (grep {not $$self{'table'}{$table}{$_}{'array_insert'} if defined $$hash{$_} and length $$hash{$_} and keys %{$$self{'table'}{$table}{$_};};} keys %{$$self{'table'}{$table};});
$self->insert_cached($table, \@{$hash;}{$self->insert_order($table)});
$self->handler_insert2($table, $hash);
};
return undef;
}
|
1651
|
0 |
0 |
$$self{'insert_hash_hash'} ||= sub {
my $self = shift();
my $table = shift() || $$self{'current_table'};
foreach my $hash (@_) {
$self->insert_hash($table, values %$hash);
};
return undef;
}
|
1668
|
0 |
0 |
$$self{'q_file'} ||= sub {
my $self = shift();
my $table = shift() || $$self{'current_table'};
my $search_str = shift();
my %tparam;
if ($$self{'table'}{$table}{'name'} and $$self{'table'}{$table}{'ext'} and $search_str =~ m[^([^/|"]+[^\s/|"])\.([^/\."|]+)$]) {
(%tparam) = ('name', $1, 'ext', $2);
}
elsif ($$self{'table'}{$table}{'tiger'} and $search_str =~ /^\s*([A-Z0-9]{39})\s*$/i) {
(%tparam) = ('tiger', uc $1);
};
return %tparam;
}
|
1980
|
0 |
0 |
$$self{'where_body'} ||= sub {
my $self = shift();
my($param_orig, $param_num, $table, $after) = @_;
my $param = {%{{} unless $param_orig;}};
$table ||= $$self{'current_table'};
my($search_str_add, $ask, $close);
my $questions = 0;
map((++$questions), grep(defined($$param{$_ . $param_num}), @{['q', keys %{$$self{'table'}{$table};}] unless $config{'user_param_founded'};}));
return if $param_num and not $questions or ++$$self{'rec_stop'} > 20;
my $first = 1;
my $local_cond = 0;
while (defined $$param{'q' . $param_num} and $$param{'q' . $param_num} =~ s/(\w+\S?[=:](?:".+?"|\S+))//) {
local $_ = $1;
s/^(\S+):/$1=/;
my $lparam = get_params_one(undef, $_);
$$lparam{$_} =~ s/^"|"$//g, $$param{$_} = $$lparam{$_} foreach (keys %$lparam);
};
foreach my $preset ($$param{'q' . $param_num} =~ /:(\S+)/g) {
foreach my $sets (keys %{$config{'preset'};}) {
if ($config{'preset'}{$sets}{$preset}) {
$$param{'q' . $param_num} =~ s/:$preset//;
foreach $_ (keys %{$config{'preset'}{$sets}{$preset}{'set'};}) {
$$param{$_ . $param_num} .= ($$param{$_ . $param_num} ? ' ' : '') . $config{'preset'}{$sets}{$preset}{'set'}{$_};
};
};
};
};
my $search_str = $$param{'q' . $param_num};
my $glueg = $$param{'glueg' . $param_num} eq 'or' ? ' OR ' : ' AND ';
my $gluel = $$param{'gluel' . $param_num} eq 'or' ? ' OR ' : ' AND ';
$glueg = ' XOR ' if $$self{'enable_xor_query'} and $$param{'glueg' . $param_num} eq 'xor';
$gluel = ' XOR ' if $$self{'enable_xor_query'} and $$param{'gluel' . $param_num} eq 'xor';
if (my($days) = $$param{'search_days' . $param_num} =~ /(\d+)/ and $1 and %{{} unless $$self{'table'}{$table}{'time'};}) {
$ask .= ' ' . ($$self{'no_column_prepend_table'} ? () : "$tq$$self{'table_prefix'}$table$tq.") . "$rq" . "time$rq ";
if ($$param{'search_days_mode' . $param_num} eq 'l') {
$ask .= '<';
}
else {
$ask .= '>';
};
$days = int(time) - $days * 24 * 60 * 60;
$ask .= '= ' . ($$self{'sphinx'} ? $days : $self->squotes($days));
};
if (not $$self{'no_online'} and defined $$param{'online' . $param_num}) {
if ($$param{'online' . $param_num} eq 'on') {
$$param{'online' . $param_num} = $config{'online_minutes'};
};
if ($$param{'online' . $param_num} > 0) {
$$param{'live' . $param_num} = int(time) + $$self{'timediff'} - int($$param{'online' . $param_num}) * 60;
$$param{'live_mode' . $param_num} = 'g';
};
};
if ($$self{'path_complete'} and $$param{'path' . $param_num} and not $$param{'path' . $param_num} =~ m[^[ !/\*]] and $$param{'path' . $param_num} ne 'EMPTY' and not !$$self{'no_regex'} && ($$param{'path' . $param_num} =~ /^\s*reg?e?x?p?:\s*/i || $$param{'path_mode' . $param_num} =~ /[r~]/i)) {
$search_str_add .= ' /' . $$param{'path' . $param_num} . '/ ';
delete $$param{'path' . $param_num};
};
foreach my $item ((sort {$$self{'table'}{$table}{$b}{'order'} <=> $$self{'table'}{$table}{$a}{'order'} unless $$self{'table'}{$table}{$b}{'weight'} <=> $$self{'table'}{$table}{$a}{'weight'};} grep({$$self{'table'}{$table}{$_}{'nav_hide'} unless $$self{'nav_all'} or $$self{'table'}{$table}{$_}{'nav_num_field'} or $$self{'table'}{$table}{$_}{'nav_field'};} keys %{$$self{'table'}{$table};})), @{$$self{'table_param'}{$table}{'join_fields'};}) {
next if $$self{'no_index'} or $$self{'ignore_index'} or $$self{'table_param'}{$table}{'no_index'} or $$self{'table_param'}{$table}{'ignore_index'} or not $$param{$item . $param_num} =~ /\S/;
my $lask;
++$local_cond, $lask .= $gluel if $ask;
my $pib = $$param{$item . $param_num};
$pib =~ s/^\s*|\s*$//g;
my($group_not, $group_not_close);
$pib =~ s/\:$_(\W|$)/$config{$item}{$_}{'to'}$1/g and ++$group_not foreach (grep {defined $config{$item}{$_}{'to'};} keys %{ref $config{$item} eq 'HASH' ? $config{$item} : {};});
next if $pib eq '';
my($brstr, $space);
if ($$self{'table'}{$table}{$item}{'no_split_space'} or not $$self{'no_regex'} and $pib =~ /\s*reg?e?x?p?:\s*/ || $$param{$item . '_mode' . $param_num} =~ /[r~]/i) {
$space = '\\s+';
}
else {
$brstr = '|\\s+';
};
$brstr = $space . '\\&+' . $space . '|' . $space . '\\|+' . $space . '|(\\s+AND\\s+)|\\s+OR\\s+' . $brstr;
my $num_cond = 0;
my($next_cond, $llask);
do {
my($pi, $cond);
$cond = $next_cond;
if ($pib =~ /($brstr)/) {
($pib, $pi, $next_cond) = ($', $`, $1);
}
else {
$pi = $pib, $pib = '';
};
if ($num_cond++) {
if ($cond =~ /(and)|\&+/i) {
$llask .= ' AND ';
}
elsif ($$self{'enable_xor_query'} and $cond =~ /(xor)/i) {
$llask .= ' XOR ';
}
elsif ($cond =~ /(or)|\|+|\s+|^$/i) {
$llask .= ' OR ';
};
};
my $not = 1 if !$$self{'no_slow'} || $$self{'table'}{$table}{$item}{'fast_not'} and $pi =~ s/^\s*[\!\-]\s*//g;
$llask .= ' NOT ' . ($group_not ? (++$group_not_close, ' ( ') : '') if $not;
if ($$self{'table_param'}{$table}{'name_to_base'}{$item}) {
$llask .= ' ' . $$self{'table_param'}{$table}{'name_to_base'}{$item} . ' ';
}
else {
$llask .= ' ' . ($$self{'no_column_prepend_table'} ? () : "$tq$$self{'table_prefix'}$table$tq.") . "$rq$item" . "$rq ";
};
my $dequote_;
if (not $$self{'no_regex'} and $pi =~ s/^\s*reg?e?x?p?:\s*//gi || $$param{$item . '_mode' . $param_num} =~ /[r~]/i) {
$llask .= ' REGEXP ';
}
elsif (not $$self{'no_soundex'} and $pi =~ s/^\s*sou?n?d?e?x?:\s*//gi || $$param{$item . '_mode' . $param_num} =~ /[s\@]/i) {
$llask .= ' SOUNDS LIKE ';
}
elsif ($pi =~ /[*?]/) {
$pi =~ s/%/\\%/g;
++$dequote_ if $pi =~ s/_/\\_/g;
$pi =~ tr/*?/%_/;
next if $$self{'no_empty'} and !($pi =~ /\S/) || $pi =~ /^\s*[%_]+\s*$/;
$llask .= ' LIKE ';
}
elsif ($$param{$item . '_mode' . $param_num} =~ /notnull/i) {
$llask .= 'IS NOT NULL';
next;
}
elsif ($$param{$item . '_mode' . $param_num} =~ /null/i) {
$llask .= 'IS NULL';
next;
}
elsif ($$param{$item . '_mode' . $param_num} =~ /[g>]/i) {
$llask .= ($not ? '<' : '>') . '= ';
}
elsif ($$param{$item . '_mode' . $param_num} =~ /[l<]/i) {
$llask .= ($not ? '>' : '<') . '= ';
}
else {
$llask .= '= ';
};
$pi =~ s/(^\s*)|(\s*$)//g;
$pi = &psmisc::human('number_k', $pi) if $item eq 'size';
$work{'bold_' . $item} .= ' ' . $pi;
unless ($$self{'sphinx'} and $$self{'table'}{$table}{$item}{'nav_num_field'} and $pi =~ /^\d+$/) {
$pi = $pi ne 'EMPTY' ? $self->squotes($pi) : $self->squotes('');
};
$pi =~ s/\\_/_/g if $dequote_;
$llask .= $pi
} while $pib and $num_cond < 50;
$llask .= ' ) ' x $group_not_close;
$group_not_close = 0;
$lask .= ($num_cond > 1 ? ' ( ' : '') . $llask . ($num_cond > 1 ? ' ) ' : '');
$ask .= ((!$$self{'no_slow'} || $$self{'table'}{$table}{$item}{'fast_not'}) && ($$param{$item . '_mode' . $param_num} =~ /[n!]/i ? ' NOT ' : ' ')) . $lask;
};
$work{'search_str'} .= ' ' . $search_str . ' ' . $search_str_add;
if ($search_str =~ /\S/ or $search_str_add) {
unless ($$param{'page'} > 1 or $$param{'order'} or $$param{'no_querystat'}) {
++$work{'query'}{$search_str};
map {++$work{'word'}{$_};} grep($_, split(/[\W_]+/, $search_str, 0));
};
++$local_cond, $ask .= $gluel if $ask;
$$param{'adv_query' . $param_num} = 'on' if $search_str =~ /\S+\*+\s*/ or $search_str =~ /(^|\s+)(([+\-><~]+\()|\")[^"()]*\S+\s+\S+[^"()]*[\"\)]($|\s+)/ or $search_str =~ /(^|\s+)[\~\+\-\<\>]\S+/;
$search_str =~ s/(\S+)/+$1/g if $$param{'adv_query' . $param_num} eq 'on' and not $search_str =~ /((^|\s)\W+\S)|\S\W+(\s|$)/ and $search_str =~ /\s/;
$ask .= $search_str =~ s/^\s*\!\s*// ? ' NOT ' : '';
if (not $$self{'use_q_file_fallback'} and my(%tparam) = $self->q_file($table, $search_str)) {
$ask .= ' ( ' . $self->where_body(\%tparam, undef, $table) . ' ) ';
}
elsif (not $$self{'sphinx'} || $$self{'no_slow'} and $search_str =~ /^\s*\*+\S+/ and $$self{'table'}{$table}{'path'} and $$self{'table'}{$table}{'name'} and $$self{'table'}{$table}{'ext'}) {
my(%tparam) = ('path', '/' . $search_str, 'name', $search_str, 'ext', $search_str, 'gluel', 'or');
$ask .= ' ( ' . $self->where_body(\%tparam, undef, $table) . ' ) ';
}
else {
$search_str .= $search_str_add;
$$self{'handler_search_str'}($table, \$search_str) if ref $$self{'handler_search_str'} eq 'CODE';
my $search_str_stem = $self->stem($search_str) if grep {$$self{'table'}{$table}{$_}{'stem'};} keys %{$$self{'table'}{$table};};
local $$param{'adv_query' . $param_num} = 'on' if $$self{'ignore_index'} or $$self{'table_param'}{$table}{'ignore_index'};
if (not $$param{'adv_query' . $param_num} and $$self{'ignore_index_fulltext'} || !grep({$$self{'sphinx'} and $$self{'table'}{$table}{$_}{'sphinx'} unless $$self{'table'}{$table}{$_}{'fulltext'};} keys %{$$self{'table'}{$table};}) or not $$self{'match'}) {
$_ = join(' OR ', map({"$rq$_$rq LIKE " . $self->squotes((!$$self{'no_slow'} && ($$self{'table'}{$table}{$_}{'like_bef'} || $$self{'table_param'}{$table}{'like_bef'} || $$self{'like_bef'}) ? '%' : '') . $search_str . '%');} grep({not $$self{'table'}{$table}{$_}{'q_skip'} if $$self{'table'}{$table}{$_}{'q'} or $$self{'table'}{$table}{$_}{'nav_field'};} keys %{$$self{'table'}{$table};})));
$ask .= ' ( ' . $_ . ' ) ' if $_;
}
else {
$ask .= $self->match($param, $param_num, $table, $search_str, $search_str_stem);
};
};
};
if (not $$self{'sphinx'} and $local_cond > 1) {
$ask = ' ( ' . $ask . ' ) ';
};
$ask = $glueg . $ask if $after and $ask;
return $ask . ($ask && ($close ? ' ) ' x $close : '')) . $self->where_body($param, $param_num + (defined $param_num ? 1 : ($$param{'search_prev'} ? 0 : 1)), $table, $ask ? 1 : 0);
}
|
1997
|
0 |
0 |
$$self{'where'} ||= sub {
my $self = shift();
my($param, undef, $table) = @_;
$$self{'rec_stop'} = 0;
my $where = $self->where_body(@_);
if ($$self{'table_param'}{$table}{'where_extra'}) {
$where .= ' AND ' if length $where;
$where .= $$self{'table_param'}{$table}{'where_extra'};
};
return ' WHERE ' . $where if $where;
return undef;
}
|
2039
|
0 |
0 |
$$self{'count'} ||= sub {
my $self = shift();
my($param, $table) = @_;
$self->limit_calc($self, $param, $table);
return undef if $$self{'query_count'}{$table}++ or $$self{'ignore_index'} or $$self{'table_param'}{$table}{'ignore_index'};
my @ask;
$$param{'count_f'} = 'on' if $$self{'page'} eq 'rnd';
push @ask, ' COUNT(*) ' if $$param{'count_f'} eq 'on';
push @ask, " SUM($tq$table$tq.$rq$_$rq) " foreach (grep((($$self{'allow_count_all'} || $$self{'table'}{$table}{$_}{'allow_count'}) && $$param{'count_' . $_} eq 'on'), sort(keys %{$$self{'table'}{$table};})));
if (@ask) {
my(%tmp_para) = %$param;
local $$self{'dbirows'};
delete $tmp_para{'online'};
my $where = $self->where(\%tmp_para, undef, $table);
return unless $$self{'allow_null_count'} or $where;
my $from = join(' ', $tq . $$self{'table_prefix'} . $table . $tq, $self->join_what(undef, $param, $table));
my $req = ' SELECT ' . join(' , ', @ask) . " FROM $from $where ";
&psmisc::flush();
@ask = values %{$self->query($req)->[0];};
$$self{'stat'}{'found'}{'files'} = pop @ask if $$param{'count_f'} eq 'on';
foreach $_ (grep(($$self{'table'}{$table}{$_}{'allow_count'} && $$param{'count_' . $_} eq 'on'), sort(keys %{$$self{'table'}{$table};}))) {
my $t = pop @ask;
$$self{'stat'}{'found'}{$_} = $t if $t;
};
};
$$self{'calc_count'}($self, $param, $table);
return undef;
}
|
2046
|
0 |
0 |
$$self{'can_select'} ||= sub {
my $self = shift();
my($param, $table) = @_;
my $where = $self->where($param, undef, $table);
return $where if $where;
return '0E0' if $$self{'use_sphinx'} and $$self{'sphinx_dbi'} and length $$param{'q'};
}
|
2050
|
0 |
0 |
$opt ||= {} |
2266
|
0 |
0 |
$ids{$from} ||= [] |
2274
|
0 |
0 |
$ids{$from} || (next) |
2375
|
0 |
0 |
$$self{'select'} ||= sub {
my $self = shift();
my($table, $param, $opt) = @_;
$opt ||= {};
$$self{'current_table'} = $table;
my $select;
my $ids = [];
my $idsh = {};
my %id;
my $ret = [];
$$self{'founded_max'} = $$self{'dbirows'} = 0;
my(@fail, @selects);
my $file_fallback;
my $n;
my $post_process = sub ($) {
my($ret) = @_;
foreach my $r (@$ret) {
$$r{$_} ||= $$idsh{$$r{'id'}}{$_} foreach (keys %{{} unless $$idsh{$$r{'id'}};});
};
@$ret = (sort {$$idsh{$$a{'id'}}{'n'} <=> $$idsh{$$b{'id'}}{'n'};} @$ret);
foreach $_ (@fail) {
next if scalar @$ret < $$_{'n'};
$$ret[$$_{'n'}]{'__fulltext_fail'} = $$_{'q'};
};
@fail = ();
}
;
my $do_select = sub {
my $count;
foreach my $s (@_) {
my $select;
my($count_add, $idst);
($select, $idst, $count_add) = &$s() if &psmisc::is_code($s);
if (&psmisc::is_array_size($idst)) {
$ids = $idst;
my $nn = $$self{'sphinx_dbi'}{'limit_offset'} || $$self{'limit_offset'};
$idsh = {map({$$_{'n'} //= ++$nn;
$$_{'id'}, $_;} @$ids)};
};
$count += $count_add;
($select) = $s if &psmisc::is_hash($s);
local $$self{'limit_body'} = sub {
}
if &psmisc::is_array_size($ids);
if (&psmisc::is_hash($select)) {
foreach my $s (sort {$$select{$a} <=> $$select{$b};} keys %$select) {
my $r;
$r = $$self{'shard_dbis'}{$$select{$s}}->query(scalar &psmisc::cp_trans($$self{'cp_in'}, $$self{'codepage'}, $self->select_body($s, $param))) if $s;
next unless $r;
foreach my $l (@$r) {
$$l{'id'} //= &psmisc::join_url($l);
};
$r = [grep({not $id{$$_{'id'}}++;} @$r)];
&$post_process($r);
$count += scalar @$r;
$$opt{'row'}(@$r), &psmisc::code_run($$opt{'flush'}), next if &psmisc::is_code($$opt{'row'});
push @$ret, @$r;
};
}
else {
foreach my $select (&psmisc::array($select)) {
my $r;
$r = $self->query(scalar &psmisc::cp_trans($$self{'cp_in'}, $$self{'codepage'}, $self->select_body($select, $param))) if $select;
next unless $r;
map {$$_{'id'} //= &psmisc::join_url($_);} @$r;
$r = [grep({not $id{$$_{'id'}}++;} @$r)];
$count += scalar @$r;
push @$ret, @$r;
};
};
last if $count >= $$self{'limit'};
}
continue {
++$n;
};
return $count;
}
;
push @selects, sub {
my $ask;
my $search_str = $$param{'q'};
if (my(%tparam) = $self->q_file($table, $search_str)) {
$ask .= ' ( ' . $self->where_body(\%tparam, undef, $table) . ' ) ';
};
}
if $$self{'use_q_file_fallback'} and not $$self{'sphinx'};
push @selects, sub {
my $ids = [];
my %id;
if ($$self{'use_sphinx'} and $$self{'sphinx_dbi'} and length $$param{'q'} and $file_fallback || !$self->q_file($table, $$param{'q'})) {
($tq, $rq, $vq) = $self->quotes;
local $$self{'sphinx_dbi'}{'option'}{'max_query_time'} = 2000 if $config{'client_bot'};
my $idsl = [];
push @$idsl, grep({not $id{$$_{'id'}}++;} @{$$self{'sphinx_dbi'}->select($table, $param);});
$$self{'founded_max'} = $$self{'sphinx_dbi'}{'option'}{'cutoff'};
if (@$ids + @$idsl < $$self{'limit'}) {
++$work{'fulltext_fail'} unless @$ids;
local $$param{'q'} = $$param{'q'};
foreach my $func (sub {
$_[0] =~ s/\s*"\s*$// if $_[0] =~ s/^\s*"\s*//;
}
, sub {
$_[0] =~ s/(\w\s+)(\w)/$1 | $2/g;
}
) {
if (&$func($$param{'q'})) {
local $$param{'no_querystat'} = 1;
local $$self{'sphinx_dbi'}{'limit_minus'} = scalar @$idsl;
local $$self{'sphinx_dbi'}{'limit_offset'};
local $$self{'sphinx_dbi'}{'page'} = 0 if $$self{'sphinx_dbi'}{'limit_minus'};
my $ids_add = $$self{'sphinx_dbi'}->select($table, $param);
$$self{'founded_max'} = $$self{'sphinx_dbi'}{'option'}{'cutoff'};
push @fail, {'n', scalar @$ids + scalar(@$idsl), 'q', $$param{'q'}} if @$ids_add;
unless (@$ids_add) {
++$work{'fulltext_fail_or'};
};
push @$idsl, grep({not $id{$$_{'id'}}++;} @$ids_add);
};
last if @$ids + @$idsl >= $$self{'limit'};
};
};
if (@$idsl) {
my $wheregen = sub {
@_ = &psmisc::array(@_);
return " WHERE ${rq}id$rq IN (" . join(',', map({$$_{'id'};} @_)) . ')' if @_;
}
;
if (not $$self{'sphinx'} and $$self{'shard'}) {
my %ids;
foreach my $r (@$idsl) {
foreach my $from (reverse sort keys %{$$self{'shard_dbis'};}) {
if ($$r{'id'} >= $from) {
push @{$ids{$from} ||= [];}, $r;
last;
};
};
};
$select = {};
foreach my $from (keys %{$$self{'shard_dbis'};}) {
my $w = $ids{$from} || (next);
$$select{&$wheregen($w)} = $from;
};
}
else {
$select = &$wheregen($idsl);
};
push @$ids, @$idsl;
};
};
local $$self{'limit_body'} = sub {
}
if @$ids;
($tq, $rq, $vq) = $self->quotes;
my $count;
unless ($select or $$self{'use_sphinx'} and $config{'client_bot'}) {
unless ($$self{'use_sphinx'} and $$self{'no_sphinx_like'}) {
if (not $$self{'sphinx'} and $$self{'shard'}) {
foreach my $from (sort keys %{$$self{'shard_dbis'};}) {
local $$self{'limit_from'} = $$self{'limit_offset'} + $count if $count;
local $$self{'limit_minus'} = $count;
$select = {};
$$select{"/* $from */" . $self->where($param, undef, $table)} = $from;
$count += &$do_select($select);
$select = undef;
last if $count >= $$self{'limit'};
};
}
else {
$select = $self->where($param, undef, $table);
};
};
$$self{'founded_max'} = 0;
};
return $select, $ids, $count;
}
;
my $count = &$do_select(@selects);
if ($$self{'use_sphinx'} and @$ids) {
my $n = 0;
&$post_process($ret);
};
$$self{'dbirows'} ||= $count;
return wantarray ? @$ret : $ret;
}
|
2380
|
0 |
0 |
$$self{'select_log'} ||= sub {
my $self = shift();
my($table, $param) = @_;
return $self->query_log($self->select_body($self->where($param, undef, $table), $param, $table));
}
|
2458
|
0 |
0 |
$$self{'join_what'} ||= sub {
my $self = shift();
my($where, $param, $table) = @_;
$table ||= $$self{'current_table'};
my @join;
foreach my $jt (keys %{$$self{'table_join'}{$table};}) {
local(@_) = grep({$$self{'table'}{$jt}{$_} if $_;} keys %{$$self{'table_join'}{$table}{$jt}{'on'};});
push @join, ' LEFT JOIN ' . $tq . $$self{'table_prefix'} . $jt . $tq . ' ON ' . '(' . join(', ', map({$tq . $$self{'table_prefix'} . $table . $tq . '.' . $rq . $$self{'table_join'}{$table}{$jt}{'on'}{$_} . $rq . ' = ' . $tq . $$self{'table_prefix'} . $jt . $tq . '.' . $rq . $_ . $rq;} @_)) . ')' if @_;
unless (@_) {
@_ = grep({$$self{'table'}{$jt}{$_} if $_;} keys %{$$self{'table_join'}{$table}{$jt}{'using'};});
@_ = grep({$$self{'table'}{$jt}{$_}{'primary'};} keys %{$$self{'table'}{$jt};}) unless @_;
push @join, ' LEFT JOIN ' . $tq . $$self{'table_prefix'} . $jt . $tq . ' USING ' . '(' . join(', ', map({$rq . $_ . $rq;} @_)) . ')' if @_;
};
};
return join(' ', @join);
}
|
2490
|
0 |
0 |
$$self{'join_where'} ||= sub {
my $self = shift();
my($where, $param, $table) = @_;
my @what;
$table ||= $$self{'current_table'};
foreach my $jt (sort keys %{$$self{'table_join'}{$table};}) {
local $_ = join(', ', map({$tq . $$self{'table_prefix'} . $jt . $tq . '.' . $rq . $$self{'table_join'}{$table}{$jt}{'fields'}{$_} . $rq . ' AS ' . $rq . $_ . $rq;} grep({$$self{'table'}{$jt}{$$self{'table_join'}{$table}{$jt}{'fields'}{$_}};} sort(keys %{$$self{'table_join'}{$table}{$jt}{'fields'};}))));
$_ ||= "$tq$$self{'table_prefix'}$jt" . "$tq.*";
push @what, $_;
};
return join(', ', grep({$_;} @what));
}
|
2500
|
0 |
0 |
$$param{$by . $ordern} || (next) |
2533
|
0 |
0 |
$$self{$by . 'by'} ||= sub {
my $self = shift();
my($param, $table) = @_;
$table ||= $$self{'current_table'};
my($sql, %order);
foreach my $ordern ('', 0..10) {
my $order = $$param{$by . $ordern} || (next);
last if $$self{'ignore_index'} or $$self{'table_param'}{$table}{'ignore_index'};
my $min_data;
++$min_data foreach (grep {defined $$param{$_} if $$self{'table'}{$table}{$_}{'sort_min'};} keys %{$$self{'table'}{$table};});
last if $$self{'no_slow'} and not $min_data;
foreach my $join (grep {$order eq $_;} grep({not $$self{'table'}{$table}{$_}{'no_order'} unless $$self{'table'}{$table}{$_}{'sort'};} keys %{$$self{'table'}{$table};}), @{$$self{'table_param'}{$table}{'join_fields'};}) {
my($intable) = grep({keys %{$$self{'table'}{$_}{$join};};} $table, keys %{$config{'sql'}{'table_join'}{$table};});
$order{($$self{'no_column_prepend_table'} ? '' : $tq . $intable . $tq . '.') . $rq . $join . $rq . ($$param{$by . '_mode' . $ordern} ? ' DESC ' : ' ASC')} = $ordern;
};
};
if (keys %order) {
$sql .= ' ' . uc($by) . ' BY ' . join(', ', (sort {$order{$a} <=> $order{$b};} keys %order));
};
return $sql;
}
|
2606
|
0 |
0 |
$$self{'select_body'} ||= sub {
my $self = shift();
my($where, $param, $table) = @_;
$table ||= $$self{'current_table'};
($tq, $rq, $vq) = $self->quotes;
$self->limit_calc($param, $table);
if ($$self{'ignore_index'} || $$self{'table_param'}{$table}{'ignore_index'} and not $$self{'no_index'} || $$self{'table_param'}{$table}{'no_index'}) {
local(@_) = ();
local(%_) = ();
foreach $_ (keys %{$$self{'table'}{$table};}) {
++$_{$$self{'table'}{$table}{$_}{'fulltext'}} if $$self{'table'}{$table}{$_}{'fulltext'};
push @_, $_ if $$self{'table'}{$table}{$_}{'index'};
};
push @_, keys %_ unless $$self{'ignore_index_fulltext'} and $$self{'table_param'}{$table}{'ignore_index_fulltext'};
$work{'sql_select_index'} = 'IGNORE INDEX (' . join(',', @_) . ')';
};
my $from;
if ($table) {
if ($$self{'sphinx'} and $$self{'table_param'}{$table}{'stemmed_index'} and not $$param{'accurate'}) {
$from .= "$tq$$self{'table_param'}{$table}{'stemmed_index'}$tq ";
}
else {
$from .= "$tq$$self{'table_prefix'}$table$tq ";
};
};
unless ($$self{'no_join'}) {
$from .= $work{'sql_select_index'} . ' ' . $self->join_what($where, $param, $table);
};
$from = 'FROM ' . $from if $from;
my $sql = $from . ' ' . $where;
my(@what) = (($table && !$$self{'no_column_prepend_table'} ? $tq . $$self{'table_prefix'} . $table . $tq . '.' : '') . '*', $work{'what_relevance'}{$table}, $$self{'table_param'}{$table}{'what_extra'});
if (defined $$self{'table'}{$table}{$$param{'distinct'}}) {
@what = ("DISTINCT $rq$$param{'distinct'}$rq", $$self{'table_param'}{$table}{'what_extra'});
}
else {
unless ($$self{'no_join'}) {
@what = ($self->join_where($where, $param, $table), @what);
};
};
$sql = join(', ', grep({$_;} @what)) . ' ' . $sql;
my $priority;
$priority = $$self{'HIGH_PRIORITY'} unless $config{'client_bot'} or $config{'client_no_high_priority'};
$sql = " SELECT $$self{'SELECT_FLAGS'} $priority " . $sql;
$sql .= $self->groupby($param, $table);
$sql .= $self->orderby($param, $table);
$sql .= $self->limit_body;
if ($$self{'OPTION'} and &psmisc::is_hash($$self{'option'})) {
$sql .= $$self{'OPTION'} . ' ' . join(', ', map({"$_=$$self{'option'}{$_}";} keys %{$$self{'option'};}));
};
$sql .= $$self{'select_append'};
return $sql;
}
|
2617
|
0 |
0 |
$$self{'limit_body'} ||= sub {
my $self = shift();
return unless $$self{'limit_offset'} or $$self{'limit'};
return ' LIMIT ' . ($$self{'limit_offset'} && !$$self{'OFFSET'} ? $$self{'limit_offset'} . ',' : '') . $$self{'limit'} . ($$self{'OFFSET'} && $$self{'limit_offset'} ? ' ' . $$self{'OFFSET'} . ' ' . $$self{'limit_offset'} : '') . ' ';
return '';
}
|
2629
|
0 |
0 |
$$self{'limit'} || 1 |
|
0 |
0 |
$$self{'limit'} || 1 |
2635
|
0 |
0 |
$$self{'calc_count'} ||= sub {
my $self = shift();
my($param, $table, $count) = @_;
return if $work{'calc_count'}{$table}++;
$$self{'founded'} = $count || ($$self{'dbirows'} > $$self{'stat'}{'found'}{'files'} && $$self{'dbirows'} < $$self{'limit'} ? $$self{'dbirows'} + $$self{'limit_offset'} : $$self{'stat'}{'found'}{'files'});
$$self{'founded'} = 0 if $$self{'founded'} < 0 or not $$self{'founded'};
$$self{'page_last'} = $$self{'limit'} > 0 ? int($$self{'founded'} / ($$self{'limit'} || 1)) + ($$self{'founded'} % ($$self{'limit'} || 1) ? 1 : 0) : 0;
$$self{'page'} = int rand $$self{'page_last'} if $$self{'page'} eq 'rnd' and $$param{'count_f'} eq 'on';
}
|
2645
|
0 |
0 |
$$param{'show_from'} || 0 |
2652
|
0 |
0 |
$$self{'limit_calc'} ||= sub {
my $self = shift();
my($param) = @_;
$$self{'limit_offset'} = int($$self{'page'} > 0 ? $$self{'limit'} * ($$self{'page'} - 1) : $$param{'show_from'} || 0);
$$self{'limit_offset'} -= $$self{'limit_from'} - $$self{'limit_minus'} if $$self{'limit_offset'};
$$self{'limit'} -= $$self{'limit_minus'};
return undef;
}
|
2659
|
0 |
0 |
$$self{'lock_tables'} ||= sub {
my $self = shift();
return $self->do($$self{'LOCK TABLES'} . ' ' . join(' ', @_)) if $$self{'LOCK TABLES'};
}
|
2666
|
0 |
0 |
$$self{'unlock_tables'} ||= sub {
my $self = shift();
return $self->do($$self{'UNLOCK TABLES'} . ' ' . join(' ', @_)) if $$self{'UNLOCK TABLES'};
}
|
2679
|
0 |
0 |
$$self{'stat_string'} ||= sub {
my $self = shift();
return 'sqlstat: ' . join(' ', map({"$_=$$self{$_};";} grep({$$self{$_};} @_ || sort(keys %{$$self{'statable'};}))), map({"$_=" . &psmisc::human('time_period', $$self{$_}) . ';';} grep({$$self{$_};} @_ || sort(keys %{$$self{'statable_time'};}))));
}
|
2683
|
0 |
0 |
$$self{'log_stat'} ||= sub {
my $self = shift();
$self->log('stat', $self->stat_string(@_));
}
|
2691
|
0 |
0 |
$$self{'check_data'} ||= sub {
my $self = shift();
local(@_) = sort(grep({$_;} keys %{$$self{'table'};}));
return 0 unless @_;
return 0;
return $self->query('SELECT * FROM ' . join(',', map({"$tq$_$tq";} @_)) . ' WHERE 1 LIMIT 1');
}
|
2700
|
0 |
0 |
$$self{'check_data_every_table'} ||= sub {
my $self = shift();
local(@_) = sort(grep({$_;} keys %{$$self{'table'};}));
return 0 unless @_;
foreach my $table (@_) {
$self->query_log("SELECT * FROM $tq$table$tq LIMIT 1");
};
}
|
2707
|
0 |
0 |
$$self{'on_connect1'} ||= sub {
my $self = shift();
$self->check_data if $$self{'auto_check'};
}
|
2713
|
0 |
0 |
$$self{'table_stat'} ||= sub {
my $self = shift();
$self->log('info', 'totals:', @_, map({$_, '=', values %{$self->line("SELECT COUNT(*) FROM $rq$$self{'table_prefix'}$_$rq ");};} grep({$_;} @_ || keys %{$$self{'table'};})));
}
|
2725
|
0 |
0 |
$$self{'next_user_prepare'} ||= sub {
my $self = shift();
delete $$self{$_} foreach ('founded', 'queries', 'queries_time', 'errors_chain', 'errors', 'connect_tried', 'error_log');
$$self{'stat'}{'found'} = {};
$$self{'on_user' . $_}($self) foreach (grep {ref $$self{'on_user' . $_} eq 'CODE';} '', 1..5);
}
|
2731
|
0 |
0 |
$$self{'next_user'} ||= sub {
my $self = shift();
$self->user_params(@_);
$self->next_user_prepare(@_);
$$self{'sphinx_dbi'}->next_user(@_) if $$self{'sphinx_dbi'};
}
|
2817
|
0 |
0 |
$$self{'stem'} ||= sub {
my $self = shift();
local $_ = lc scalar &psmisc::cp_trans($$self{'cp_in'}, $$self{'cp_int'}, $_[0]);
$$self{'stem_version'} = 4 if $$self{'stem_version'} <= 1;
if ($$self{'stem_version'} == 2) {
s/(\d)(\D)/$1 $2/g;
s/(\D)(\d)/$1 $2/g;
tr/\x{410}-\x{42f}/\x{430}-\x{44f}/;
s/[\x{44a}\x{44c}]//g;
s/kn/n/g;
tr/\x{430}\x{431}\x{432}\x{433}\x{434}\x{435}\x{436}\x{437}\x{438}\x{439}\x{43a}\x{43b}\x{43c}\x{43d}\x{43e}\x{43f}\x{440}\x{441}\x{442}\x{443}\x{444}\x{445}\x{446}\x{447}\x{448}\x{449}\x{44b}\x{44d}\x{44e}\x{44f}\x{451}/abvgdejsiiklmnoprstufhccssieuae/;
tr/ekouw/acaav/;
s/'//g;
s/\W/ /g if $_[1];
s/_/ /g;
s/(?:rd|nd)\b/d/g;
s/ay\b/y/g;
s/\B[aeisuo]\b//g;
s/av/af/g;
s/sch/s/g;
s/ph/f/g;
s/\s+/ /g;
s/(\w)\1+/$1/g;
}
elsif ($$self{'stem_version'} == 3) {
s/(\d)(\D)/$1 $2/g;
s/(\D)(\d)/$1 $2/g;
tr/\x{410}-\x{42f}/\x{430}-\x{44f}/;
s/[\x{44a}\x{44c}]//g;
s/kn/n/g;
tr/\x{430}\x{431}\x{432}\x{433}\x{434}\x{435}\x{436}\x{437}\x{438}\x{439}\x{43a}\x{43b}\x{43c}\x{43d}\x{43e}\x{43f}\x{440}\x{441}\x{442}\x{443}\x{444}\x{445}\x{446}\x{447}\x{448}\x{449}\x{44b}\x{44d}\x{44e}\x{44f}\x{451}/abvgdejsiiklmnoprstufhccssieuae/;
s/ks/x/g;
tr/kw/cv/;
s/'//g;
s/\W/ /g if $_[1];
s/_/ /g;
s/(?:rd|nd)\b/d/g;
s/ay\b/y/g;
s/\B[aeisuo]\b//g;
s/av/af/g;
s/sch/s/g;
s/ph/f/g;
s/\s+/ /g;
s/(?:(?!xxx)|(?=xxxx))(\w)\1+(?:(?
|
2828
|
0 |
0 |
$$self{'stem_insert'} ||= sub {
my $self = shift();
my($table, $col) = @_;
return 1 unless ref $$self{'stem'} eq 'CODE';
$$col{'stem'} = join(' ', map({$self->stem($$col{$_}, 1);} grep({$$col{$_} if $$self{'table'}{$table}{$_}{'stem'};} keys %$col)));
return undef;
}
|
2842
|
0 |
0 |
$$self{'last_insert_id'} ||= sub {
my $self = shift();
my $table = shift() || $$self{'current_table'};
if ($^O eq 'MSWin32' and $$self{'driver'} eq 'pgpp') {
my($field) = grep({$$self{'table'}{$table}{$_}{'auto_increment'} unless $$self{'table'}{$table}{$_}{'type'} eq 'serial';} keys %{$$self{'table'}{$table};});
return $self->line("SELECT currval('${table}_${field}_seq') as lastid")->{'lastid'};
}
else {
return $$self{'dbh'}->last_insert_id(undef, undef, $table, undef);
};
}
|
2845
|
0 |
0 |
$$self{'dump_cp'} ||= sub {
$self->log('dev', map({"$_ = $$self{$_}; ";} 'codepage', 'cp', 'cp_in', 'cp_out', 'cp_int', 'cp_set_names'));
}
|
2851
|
0 |
0 |
$$self{'cp_client'} ||= sub {
my $self = shift();
$$self{'cp_in'} = $_[0] if $_[0];
$$self{'cp_out'} = $_[1] || $$self{'cp_in'} if $_[1] or $_[0];
return $$self{'cp_in'}, $$self{'cp_out'};
}
|
2862
|
0 |
0 |
$$self{'index_disable'} ||= sub {
my $self = shift();
my $tim = &psmisc::timer();
$self->log('info', 'Disabling indexes on', @_);
$self->log('err', 'ALTER TABLE ... DISABLE KEYS available in mysql >= 4'), return if $$self{'driver'} eq 'mysql3' or not $$self{'driver'} =~ /mysql/;
$self->do("ALTER TABLE $tq$config{'table_prefix'}$_$tq DISABLE KEYS") foreach (@_);
$self->log('time', 'Disable index per', &psmisc::human('time_period', &$tim()), 'sec');
}
|
2873
|
0 |
0 |
$$self{'index_enable'} ||= sub {
my $self = shift();
my $tim = &psmisc::timer();
$self->log('info', 'Enabling indexes on', @_);
$self->log('err', 'ALTER TABLE ... DISABLE KEYS available in mysql >= 4'), return if $$self{'driver'} eq 'mysql3' or not $$self{'driver'} =~ /mysql/;
$self->do("ALTER TABLE $tq$config{'table_prefix'}$_$tq ENABLE KEYS") foreach (@_);
$self->log('time', 'Enable index per ', &psmisc::human('time_period', &$tim()));
}
|
2887
|
0 |
0 |
$$self{$action} ||= sub {
my $self = shift();
@_ = sort(keys %{$$self{'table'};}) unless @_;
@_ = grep({$$self{'table'}{$_} if $_;} @_);
$self->log('err', 'not defined action', $action), return unless $$self{uc $action};
$self->log('info', $action, @_);
my $tim = &psmisc::timer();
foreach $_ ($$self{'bulk_service'} ? \@_ : @_) {
$self->query_log($$self{uc $action} . ' ' . join(',', map($self->tquote("$$self{'table_prefix'}$_"), &psmisc::array($_))));
};
$self->log('time', $action, 'per ', &psmisc::human('time_period', &$tim()));
}
|
2909
|
0 |
0 |
$$self{'retry_off'} ||= sub {
my $self = shift();
return if %{{} unless $$self{'retry_save'};};
$$self{'retry_save'}{$_} = $$self{$_}, $$self{$_} = 0 foreach (@{$$self{'retry_vars'};});
}
|
2915
|
0 |
0 |
$$self{'retry_on'} ||= sub {
my $self = shift();
return unless %{{} unless $$self{'retry_save'};};
$$self{$_} = $$self{'retry_save'}{$_} foreach (@{$$self{'retry_vars'};});
$$self{'retry_save'} = {};
}
|
2920
|
0 |
0 |
$$self{'set_names'} ||= sub {
my $self = shift();
local $_ = $_[0] || $$self{'cp_set_names'};
$self->do($$self{'SET NAMES'} . " $vq$_$vq") if $_ and $$self{'SET NAMES'};
}
|
line |
l |
!l&&r |
!l&&!r |
condition |
90
|
0 |
4 |
0 |
defined $config{'row'} ? $config{'row'}{$row} : undef or $row{$row} |
127
|
0 |
1 |
0 |
$row{'id'} ||= row('uint', 'auto_increment', 1, 'primary', 1) |
|
0 |
1 |
0 |
$row{'added'} ||= row('time', 'default_insert', int time, 'no_insert_update', 1) |
129
|
0 |
1 |
0 |
$row{'year'} ||= row('uint16') |
130
|
0 |
1 |
0 |
$row{'size'} ||= row('uint64') |
154
|
0 |
0 |
0 |
$errstr =~ /syntax|unrecognized token/i or $errstr =~ /misuse of aggregate/ |
302
|
0 |
0 |
0 |
$ENV{'MOD_PERL'} || $ENV{'FCGI_ROLE'} |
306
|
0 |
0 |
0 |
$ENV{'MOD_PERL'} or $ENV{'FCGI_ROLE'} |
354
|
0 |
0 |
0 |
$work{'what_relevance'}{$table} ||= $match . " AS $rq" . "relev$rq" |
|
0 |
0 |
0 |
$$self{'select_relevance'} or $$self{'table_param'}{$table}{'select_relevance'} |
500
|
0 |
0 |
0 |
$$self{'dbname'} ||= $$self{'database'} |
530
|
0 |
0 |
0 |
$glue ||= $$self{'fulltext_glue'} |
557
|
0 |
0 |
0 |
$$self{$_} //= $$self{'default'}{$$self{'driver'}}{$_} |
561
|
0 |
0 |
0 |
$$self{'dbi'} ||= $$self{'driver'} |
563
|
0 |
0 |
0 |
$$self{$$self{'codepage'}} || $$self{'codepage'} |
565
|
0 |
0 |
0 |
$$self{'cp_set_names'} ||= $_ |
616
|
0 |
0 |
0 |
$$self{'param_trans_int'}{$from} || $from |
621
|
0 |
0 |
0 |
$work{'codepage'} || $$param{'codepage'} || $config{'codepage'} |
631
|
0 |
0 |
0 |
$$self{'tq'} ||= $$self{'table quote'} |
632
|
0 |
0 |
0 |
$$self{'rq'} ||= $$self{'row quote'} |
633
|
0 |
0 |
0 |
$$self{'vq'} ||= $$self{'value quote'} |
647
|
0 |
0 |
0 |
$$self{'drh'} ||= 'DBI'->install_driver($$self{'dbi'}) |
739
|
0 |
0 |
0 |
not $$self{'sth'} or $$self{'sth'}->err |
783
|
0 |
0 |
0 |
$$self{'no_dbirows'} or $$self{'dbirows'} <= 0 |
829
|
0 |
0 |
0 |
$$self{'vquote'} ||= $$self{'quote'} |
840
|
0 |
0 |
0 |
$err ||= $DBI::err |
841
|
0 |
0 |
0 |
$errstr ||= $DBI::errstr |
864
|
0 |
0 |
0 |
$work{'die'} or $$self{'die'} |
|
0 |
0 |
0 |
$work{'die'} or $$self{'die'} or $$self{'fatal'} |
|
0 |
0 |
0 |
$work{'die'} or $$self{'die'} or $$self{'fatal'} or $$self{'error_tries'} and $$self{'errors'} > $$self{'error_tries'} |
|
0 |
0 |
0 |
$work{'die'} or $$self{'die'} or $$self{'fatal'} or $$self{'error_tries'} and $$self{'errors'} > $$self{'error_tries'} or $$self{'error_chain_tries'} and $$self{'errors_chain'} > $$self{'error_chain_tries'} |
877
|
0 |
0 |
0 |
$err || $$self{'sth'} |
898
|
0 |
0 |
0 |
$errtype eq 'install' or $errtype eq 'upgrade' |
920
|
0 |
0 |
0 |
$sl == 0 or $$self{'force_repair'} |
921
|
0 |
0 |
0 |
!$repair || $$self{'auto_repair_selected'} && $$self{'table_param'}{$repair}{'no_auto_repair'} |
1105
|
0 |
0 |
0 |
$$table{$row}{'length'} ||= $length |
1272
|
0 |
0 |
0 |
$tab =~ /^\W/ or not $tab =~ /\w/ |
1294
|
0 |
0 |
0 |
$tab =~ /^\W/ or not $tab =~ /\w/ |
1312
|
0 |
0 |
0 |
shift() || $$self{'current_table'} |
1320
|
0 |
0 |
0 |
shift() || $$self{'current_table'} |
1328
|
0 |
0 |
0 |
$table || $$self{'current_table'} |
1336
|
0 |
0 |
0 |
$$self{'table_param'}{$table}{'insert_by'} || $$self{'insert_by'} |
|
0 |
0 |
0 |
$$self{'insert_block'}{$table} //= $$self{'table_param'}{$table}{'insert_by'} || $$self{'insert_by'} |
1340
|
0 |
0 |
0 |
$$self{'insert_block'}{$table}-- <= 1 or not scalar @_ |
|
0 |
0 |
0 |
$$self{'insert_buffer_time'}{$table} ||= time |
|
0 |
0 |
0 |
$$self{'insert_block'}{$table}-- <= 1 or not scalar @_ or time - ($$self{'insert_buffer_time'}{$table} ||= time) > $$self{'insert_cached_time'} |
1394
|
0 |
0 |
0 |
$$self{'table_param'}{$table}{'insert_by'} || $$self{'insert_by'} |
1456
|
0 |
0 |
0 |
shift() || $$self{'current_table'} |
1484
|
0 |
0 |
0 |
$$self{'table'}{$table}{$_}{'primary'} || $$self{'table'}{$table}{$_}{'unique'} |
1502
|
0 |
0 |
0 |
$set ||= join(', ', map({$rq . $_ . $rq . '=' . $self->quote($self->cut($$values{$_}, $$self{'table'}{$table}{$_}{'length'}));} @_ = grep((!($_ =~ /$bymask/) && $_ && %{{} unless $$self{'table'}{$table}{$_};} && defined $$values{$_}), keys %$values), @_ ? () : grep({defined $$values{$_} if $_ and %{{} unless $$self{'table'}{$table}{$_};};} keys %$values))) |
1512
|
0 |
0 |
0 |
$where || $bywhere |
1515
|
0 |
0 |
0 |
$set || $lwhere || !$$self{'ON DUPLICATE KEY UPDATE'} |
|
0 |
0 |
0 |
$bywhere || $where || $whereignore |
1526
|
0 |
0 |
0 |
$set and int $_ or $lwhere |
1533
|
0 |
0 |
0 |
shift() || $$self{'current_table'} |
1553
|
0 |
0 |
0 |
shift() || $$self{'current_table'} |
1572
|
0 |
0 |
0 |
$$self{'table'}{$table}{$_}{'default_insert'} || ($$self{'table'}{$table}{$_}{'array_insert'} ? $$self{'table'}{$table}{$_}{'default'} : undef) |
1648
|
0 |
0 |
0 |
shift() || $$self{'current_table'} |
1654
|
0 |
0 |
0 |
shift() || $$self{'current_table'} |
1674
|
0 |
0 |
0 |
$table ||= $$self{'current_table'} |
1681
|
0 |
0 |
0 |
$param_num and not $questions or ++$$self{'rec_stop'} > 20 |
1751
|
0 |
0 |
0 |
$$self{'nav_all'} or $$self{'table'}{$table}{$_}{'nav_num_field'} |
|
0 |
0 |
0 |
$$self{'nav_all'} or $$self{'table'}{$table}{$_}{'nav_num_field'} or $$self{'table'}{$table}{$_}{'nav_field'} |
1765
|
0 |
0 |
0 |
$$self{'no_index'} or $$self{'ignore_index'} |
|
0 |
0 |
0 |
$$self{'no_index'} or $$self{'ignore_index'} or $$self{'table_param'}{$table}{'no_index'} |
|
0 |
0 |
0 |
$$self{'no_index'} or $$self{'ignore_index'} or $$self{'table_param'}{$table}{'no_index'} or $$self{'table_param'}{$table}{'ignore_index'} |
|
0 |
0 |
0 |
$$self{'no_index'} or $$self{'ignore_index'} or $$self{'table_param'}{$table}{'no_index'} or $$self{'table_param'}{$table}{'ignore_index'} or not $$param{$item . $param_num} =~ /\S/ |
1782
|
0 |
0 |
0 |
$pib =~ /\s*reg?e?x?p?:\s*/ || $$param{$item . '_mode' . $param_num} =~ /[r~]/i |
|
0 |
0 |
0 |
$$self{'table'}{$table}{$item}{'no_split_space'} or not $$self{'no_regex'} and $pib =~ /\s*reg?e?x?p?:\s*/ || $$param{$item . '_mode' . $param_num} =~ /[r~]/i |
1809
|
0 |
0 |
0 |
!$$self{'no_slow'} || $$self{'table'}{$table}{$item}{'fast_not'} |
1822
|
0 |
0 |
0 |
$pi =~ s/^\s*reg?e?x?p?:\s*//gi || $$param{$item . '_mode' . $param_num} =~ /[r~]/i |
|
0 |
0 |
0 |
$pi =~ s/^\s*sou?n?d?e?x?:\s*//gi || $$param{$item . '_mode' . $param_num} =~ /[s\@]/i |
1835
|
0 |
0 |
0 |
!($pi =~ /\S/) || $pi =~ /^\s*[%_]+\s*$/ |
1872
|
0 |
0 |
0 |
$search_str =~ /\S/ or $search_str_add |
1873
|
0 |
0 |
0 |
$$param{'page'} > 1 or $$param{'order'} |
|
0 |
0 |
0 |
$$param{'page'} > 1 or $$param{'order'} or $$param{'no_querystat'} |
1882
|
0 |
0 |
0 |
$search_str =~ /\S+\*+\s*/ or $search_str =~ /(^|\s+)(([+\-><~]+\()|\")[^"()]*\S+\s+\S+[^"()]*[\"\)]($|\s+)/ |
|
0 |
0 |
0 |
$search_str =~ /\S+\*+\s*/ or $search_str =~ /(^|\s+)(([+\-><~]+\()|\")[^"()]*\S+\s+\S+[^"()]*[\"\)]($|\s+)/ or $search_str =~ /(^|\s+)[\~\+\-\<\>]\S+/ |
1892
|
0 |
0 |
0 |
$$self{'sphinx'} || $$self{'no_slow'} |
1914
|
0 |
0 |
0 |
$$self{'ignore_index'} or $$self{'table_param'}{$table}{'ignore_index'} |
1918
|
0 |
0 |
0 |
$$self{'ignore_index_fulltext'} || !grep({$$self{'sphinx'} and $$self{'table'}{$table}{$_}{'sphinx'} unless $$self{'table'}{$table}{$_}{'fulltext'};} keys %{$$self{'table'}{$table};}) |
|
0 |
0 |
0 |
not $$param{'adv_query' . $param_num} and $$self{'ignore_index_fulltext'} || !grep({$$self{'sphinx'} and $$self{'table'}{$table}{$_}{'sphinx'} unless $$self{'table'}{$table}{$_}{'fulltext'};} keys %{$$self{'table'}{$table};}) or not $$self{'match'} |
1935
|
0 |
0 |
0 |
$$self{'table'}{$table}{$_}{'q'} or $$self{'table'}{$table}{$_}{'nav_field'} |
2005
|
0 |
0 |
0 |
$$self{'query_count'}{$table}++ or $$self{'ignore_index'} |
|
0 |
0 |
0 |
$$self{'query_count'}{$table}++ or $$self{'ignore_index'} or $$self{'table_param'}{$table}{'ignore_index'} |
2020
|
0 |
0 |
0 |
$$self{'allow_null_count'} or $where |
2072
|
0 |
0 |
0 |
$$r{$_} ||= $$idsh{$$r{'id'}}{$_} |
2100
|
0 |
0 |
0 |
$$self{'sphinx_dbi'}{'limit_offset'} || $$self{'limit_offset'} |
2101
|
0 |
0 |
0 |
$$_{'n'} //= ++$nn |
2125
|
0 |
0 |
0 |
$$l{'id'} //= &psmisc::join_url($l) |
2149
|
0 |
0 |
0 |
$$_{'id'} //= &psmisc::join_url($_) |
2195
|
0 |
0 |
0 |
$file_fallback || !$self->q_file($table, $$param{'q'}) |
2295
|
0 |
0 |
0 |
$select or $$self{'use_sphinx'} and $config{'client_bot'} |
2373
|
0 |
0 |
0 |
$$self{'dbirows'} ||= $count |
2385
|
0 |
0 |
0 |
$table ||= $$self{'current_table'} |
2464
|
0 |
0 |
0 |
$table ||= $$self{'current_table'} |
2481
|
0 |
0 |
0 |
$_ ||= "$tq$$self{'table_prefix'}$jt" . "$tq.*" |
2496
|
0 |
0 |
0 |
$table ||= $$self{'current_table'} |
2501
|
0 |
0 |
0 |
$$self{'ignore_index'} or $$self{'table_param'}{$table}{'ignore_index'} |
2539
|
0 |
0 |
0 |
$table ||= $$self{'current_table'} |
2545
|
0 |
0 |
0 |
$$self{'ignore_index'} || $$self{'table_param'}{$table}{'ignore_index'} |
|
0 |
0 |
0 |
$$self{'no_index'} || $$self{'table_param'}{$table}{'no_index'} |
2588
|
0 |
0 |
0 |
$config{'client_bot'} or $config{'client_no_high_priority'} |
2610
|
0 |
0 |
0 |
$$self{'limit_offset'} or $$self{'limit'} |
2624
|
0 |
0 |
0 |
$count || ($$self{'dbirows'} > $$self{'stat'}{'found'}{'files'} && $$self{'dbirows'} < $$self{'limit'} ? $$self{'dbirows'} + $$self{'limit_offset'} : $$self{'stat'}{'found'}{'files'}) |
2628
|
0 |
0 |
0 |
$$self{'founded'} < 0 or not $$self{'founded'} |
2676
|
0 |
0 |
0 |
@_ || sort(keys %{$$self{'statable'};}) |
|
0 |
0 |
0 |
@_ || sort(keys %{$$self{'statable_time'};}) |
2712
|
0 |
0 |
0 |
@_ || keys %{$$self{'table'};} |
2831
|
0 |
0 |
0 |
shift() || $$self{'current_table'} |
2849
|
0 |
0 |
0 |
$_[1] || $$self{'cp_in'} |
|
0 |
0 |
0 |
$_[1] or $_[0] |
2856
|
0 |
0 |
0 |
$$self{'driver'} eq 'mysql3' or not $$self{'driver'} =~ /mysql/ |
2867
|
0 |
0 |
0 |
$$self{'driver'} eq 'mysql3' or not $$self{'driver'} =~ /mysql/ |
2918
|
0 |
0 |
0 |
$_[0] || $$self{'cp_set_names'} |