diff --git a/bin/pt-table-sync b/bin/pt-table-sync index 6ee71bd6..5ddfc8c9 100755 --- a/bin/pt-table-sync +++ b/bin/pt-table-sync @@ -5434,7 +5434,7 @@ sub __get_boundaries { if ( $row ) { my $i = 0; $ub = $s->{boundaries}->{'<='}; - $ub =~ s/\?/$q->quote_val($row->{$s->{scols}->[$i]}, $self->{tbl_struct}->{is_numeric}->{$s->{scols}->[$i++]} || 0)/eg; + $ub =~ s/\?/$q->quote_val($row->{$s->{scols}->[$i++]})/eg; } else { PTDEBUG && _d('No upper boundary'); @@ -5466,7 +5466,7 @@ sub __make_boundary_sql { my $tmp = $self->{cached_row}; my $i = 0; $lb = $s->{boundaries}->{'>'}; - $lb =~ s/\?/$q->quote_val($tmp->{$s->{scols}->[$i]}, $self->{tbl_struct}->{is_numeric}->{$s->{scols}->[$i++]} || 0)/eg; + $lb =~ s/\?/$q->quote_val($tmp->{$s->{scols}->[$i++]})/eg; $sql .= $args{where} ? " AND $lb" : " WHERE $lb"; } $sql .= " ORDER BY " . join(',', map { $q->quote($_) } @{$self->{key_cols}}) diff --git a/bin/pt-table-usage b/bin/pt-table-usage index 1806fd9d..d72ca5b9 100755 --- a/bin/pt-table-usage +++ b/bin/pt-table-usage @@ -6,7 +6,32 @@ use strict; use warnings FATAL => 'all'; -use constant PTDEBUG => $ENV{PTDEBUG} || 0; + +# This tool is "fat-packed": most of its dependent modules are embedded +# in this file. Setting %INC to this file for each module makes Perl aware +# of this so it will not try to load the module from @INC. See the tool's +# documentation for a full list of dependencies. +BEGIN { + $INC{$_} = __FILE__ for map { (my $pkg = "$_.pm") =~ s!::!/!g; $pkg } (qw( + DSNParser + OptionParser + SlowLogParser + Transformers + QueryRewriter + QueryParser + FileIterator + SQLParser + TableUsage + Daemon + Runtime + Progress + Pipeline + Quoter + TableParser + MysqldumpParser + SchemaQualifier + )); +} # ########################################################################### # DSNParser package diff --git a/bin/pt-upgrade b/bin/pt-upgrade index 29edff55..172bb4a2 100755 --- a/bin/pt-upgrade +++ b/bin/pt-upgrade @@ -5413,6 +5413,12 @@ sub _chunk_char { } PTDEBUG && _d("Base", $base, "chars:", @chars); + die "Cannot chunk table $db_tbl using the character column " + . "$chunk_col, most likely because all values start with the " + . "same character. This table must be synced separately by " + . "specifying a list of --algorithms without the Chunk algorithm" + if $base == 1; + $sql = "SELECT MAX(LENGTH($qchunk_col)) FROM $db_tbl " . ($args{where} ? "WHERE $args{where} " : "") @@ -6982,9 +6988,10 @@ sub lock_and_wait { my $ms = $self->{MasterSlave}; my $tries = $args{wait_retry_args}->{tries} || 3; my $wait; + my $sleep = $args{wait_retry_args}->{wait} || 10; $self->{Retry}->retry( tries => $tries, - wait => sub { sleep $args{wait_retry_args}->{wait} || 10 }, + wait => sub { sleep($sleep) }, try => sub { my ( %args ) = @_; @@ -7015,7 +7022,7 @@ sub lock_and_wait { . "the slave is running."; } if ( $tries - $args{tryno} ) { - $msg .= " Sleeping $wait seconds then retrying " + $msg .= " Sleeping $sleep seconds then retrying " . ($tries - $args{tryno}) . " more times."; } warn "$msg\n"; @@ -7067,30 +7074,6 @@ sub lock_and_wait { return $result; } -sub have_all_privs { - my ( $self, $dbh, $db, $tbl ) = @_; - my $db_tbl = $self->{Quoter}->quote($db, $tbl); - my $sql = "SHOW FULL COLUMNS FROM $db_tbl"; - PTDEBUG && _d('Permissions check:', $sql); - my $cols = $dbh->selectall_arrayref($sql, {Slice => {}}); - my ($hdr_name) = grep { m/privileges/i } keys %{$cols->[0]}; - my $privs = $cols->[0]->{$hdr_name}; - $sql = "DELETE FROM $db_tbl LIMIT 0"; # FULL COLUMNS doesn't show all privs - PTDEBUG && _d('Permissions check:', $sql); - eval { $dbh->do($sql); }; - my $can_delete = $EVAL_ERROR ? 0 : 1; - - PTDEBUG && _d('User privs on', $db_tbl, ':', $privs, - ($can_delete ? 'delete' : '')); - if ( $privs =~ m/select/ && $privs =~ m/insert/ && $privs =~ m/update/ - && $can_delete ) { - PTDEBUG && _d('User has all privs'); - return 1; - } - PTDEBUG && _d('User does not have all privs'); - return 0; -} - sub _d { my ($package, undef, $line) = caller 0; @_ = map { (my $temp = $_) =~ s/\n/\n# /g; $temp; } @@ -7625,7 +7608,7 @@ sub __get_boundaries { if ( $row ) { my $i = 0; $ub = $s->{boundaries}->{'<='}; - $ub =~ s/\?/$q->quote_val($row->{$s->{scols}->[$i]}, $self->{tbl_struct}->{is_numeric}->{$s->{scols}->[$i++]} || 0)/eg; + $ub =~ s/\?/$q->quote_val($row->{$s->{scols}->[$i++]})/eg; } else { PTDEBUG && _d('No upper boundary'); @@ -7657,7 +7640,7 @@ sub __make_boundary_sql { my $tmp = $self->{cached_row}; my $i = 0; $lb = $s->{boundaries}->{'>'}; - $lb =~ s/\?/$q->quote_val($tmp->{$s->{scols}->[$i]}, $self->{tbl_struct}->{is_numeric}->{$s->{scols}->[$i++]} || 0)/eg; + $lb =~ s/\?/$q->quote_val($tmp->{$s->{scols}->[$i++]})/eg; $sql .= $args{where} ? " AND $lb" : " WHERE $lb"; } $sql .= " ORDER BY " . join(',', map { $q->quote($_) } @{$self->{key_cols}})