mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-23 12:47:56 +00:00
PT-1757 Implemented fallback in NibbleIterator
Since now NibbleIterator can fallback to nibble (from one chunk) pt-osc can nibble tables even if due to unacurate stats, it choses one nible as the initial nibbling method.
This commit is contained in:
@@ -3136,6 +3136,7 @@ sub generate_asc_stmt {
|
||||
cols => \@cols,
|
||||
quoter => $q,
|
||||
is_nullable => $tbl_struct->{is_nullable},
|
||||
type_for => $tbl_struct->{type_for},
|
||||
);
|
||||
$asc_stmt->{boundaries}->{$cmp} = $cmp_where->{where};
|
||||
}
|
||||
@@ -3156,6 +3157,7 @@ sub generate_cmp_where {
|
||||
my @slice = @{$args{slice}};
|
||||
my @cols = @{$args{cols}};
|
||||
my $is_nullable = $args{is_nullable};
|
||||
my $type_for = $args{type_for};
|
||||
my $type = $args{type};
|
||||
my $q = $self->{Quoter};
|
||||
|
||||
@@ -3172,13 +3174,14 @@ sub generate_cmp_where {
|
||||
my $ord = $slice[$j];
|
||||
my $col = $cols[$ord];
|
||||
my $quo = $q->quote($col);
|
||||
my $val = ($col && ($type_for->{$col} || '')) eq 'enum' ? "CAST(? AS UNSIGNED)" : "?";
|
||||
if ( $is_nullable->{$col} ) {
|
||||
push @clause, "((? IS NULL AND $quo IS NULL) OR ($quo = ?))";
|
||||
push @clause, "(($val IS NULL AND $quo IS NULL) OR ($quo = $val))";
|
||||
push @r_slice, $ord, $ord;
|
||||
push @r_scols, $col, $col;
|
||||
}
|
||||
else {
|
||||
push @clause, "$quo = ?";
|
||||
push @clause, "$quo = $val";
|
||||
push @r_slice, $ord;
|
||||
push @r_scols, $col;
|
||||
}
|
||||
@@ -3188,15 +3191,16 @@ sub generate_cmp_where {
|
||||
my $col = $cols[$ord];
|
||||
my $quo = $q->quote($col);
|
||||
my $end = $i == $#slice; # Last clause of the whole group.
|
||||
my $val = ($col && ($type_for->{$col} || '')) eq 'enum' ? "CAST(? AS UNSIGNED)" : "?";
|
||||
if ( $is_nullable->{$col} ) {
|
||||
if ( $type =~ m/=/ && $end ) {
|
||||
push @clause, "(? IS NULL OR $quo $type ?)";
|
||||
push @clause, "($val IS NULL OR $quo $type $val)";
|
||||
}
|
||||
elsif ( $type =~ m/>/ ) {
|
||||
push @clause, "((? IS NULL AND $quo IS NOT NULL) OR ($quo $cmp ?))";
|
||||
push @clause, "(($val IS NULL AND $quo IS NOT NULL) OR ($quo $cmp $val)";
|
||||
}
|
||||
else { # If $type =~ m/</ ) {
|
||||
push @clause, "((? IS NOT NULL AND $quo IS NULL) OR ($quo $cmp ?))";
|
||||
push @clauses, "(($val IS NOT NULL AND $quo IS NULL) OR ($quo $cmp $val))";
|
||||
}
|
||||
push @r_slice, $ord, $ord;
|
||||
push @r_scols, $col, $col;
|
||||
@@ -3204,7 +3208,7 @@ sub generate_cmp_where {
|
||||
else {
|
||||
push @r_slice, $ord;
|
||||
push @r_scols, $col;
|
||||
push @clause, ($type =~ m/=/ && $end ? "$quo $type ?" : "$quo $cmp ?");
|
||||
push @clause, ($type =~ m/=/ && $end ? "$quo $type $val" : "$quo $cmp $val");
|
||||
}
|
||||
|
||||
push @clauses, '(' . join(' AND ', @clause) . ')';
|
||||
|
Reference in New Issue
Block a user