diff --git a/bin/pt-duplicate-key-checker b/bin/pt-duplicate-key-checker index 57ecf053..96907b47 100755 --- a/bin/pt-duplicate-key-checker +++ b/bin/pt-duplicate-key-checker @@ -3239,9 +3239,16 @@ sub table_is_allowed { my $filter = $self->{filters}; - if ( $db eq 'mysql' && ($tbl eq 'general_log' || $tbl eq 'slow_log') ) { - return 0; - } + return 0 if $db eq 'mysql' && $tbl =~ m/^(?: + general_log + |slow_log + |innodb_index_stats + |innodb_table_stats + |ndb_binlog_index + |slave_master_info + |slave_relay_log_info + |slave_worker_info + )$/x; if ( $filter->{'ignore-tables'}->{$tbl} && ($filter->{'ignore-tables'}->{$tbl} eq '*' diff --git a/bin/pt-index-usage b/bin/pt-index-usage index 22b8de3d..f786206b 100755 --- a/bin/pt-index-usage +++ b/bin/pt-index-usage @@ -4057,9 +4057,16 @@ sub table_is_allowed { my $filter = $self->{filters}; - if ( $db eq 'mysql' && ($tbl eq 'general_log' || $tbl eq 'slow_log') ) { - return 0; - } + return 0 if $db eq 'mysql' && $tbl =~ m/^(?: + general_log + |slow_log + |innodb_index_stats + |innodb_table_stats + |ndb_binlog_index + |slave_master_info + |slave_relay_log_info + |slave_worker_info + )$/x; if ( $filter->{'ignore-tables'}->{$tbl} && ($filter->{'ignore-tables'}->{$tbl} eq '*' diff --git a/bin/pt-mysql-summary b/bin/pt-mysql-summary index 1f3e39b4..3809408d 100755 --- a/bin/pt-mysql-summary +++ b/bin/pt-mysql-summary @@ -2332,8 +2332,10 @@ report_mysql_summary () { TOOL="pt-mysql-summary" -CMD_MYSQL="$(_which mysql)" -CMD_MYSQLDUMP="$( _which mysqldump )" +# These vars are declared earlier in the collect_mysql_info package, +# but if they're still undefined here, try to find them in PATH. +[ "$CMD_MYSQL" ] || CMD_MYSQL="$(_which mysql)" +[ "$CMD_MYSQLDUMP" ] || CMD_MYSQLDUMP="$( _which mysqldump )" check_mysql () { # Check that mysql and mysqldump are in PATH. If not, we're diff --git a/bin/pt-table-checksum b/bin/pt-table-checksum index 7b165d34..f54b12fb 100755 --- a/bin/pt-table-checksum +++ b/bin/pt-table-checksum @@ -6986,9 +6986,16 @@ sub table_is_allowed { my $filter = $self->{filters}; - if ( $db eq 'mysql' && ($tbl eq 'general_log' || $tbl eq 'slow_log') ) { - return 0; - } + return 0 if $db eq 'mysql' && $tbl =~ m/^(?: + general_log + |slow_log + |innodb_index_stats + |innodb_table_stats + |ndb_binlog_index + |slave_master_info + |slave_relay_log_info + |slave_worker_info + )$/x; if ( $filter->{'ignore-tables'}->{$tbl} && ($filter->{'ignore-tables'}->{$tbl} eq '*' @@ -10123,9 +10130,9 @@ sub check_repl_table { } } else { + warn $EVAL_ERROR; die "--replicate database $db does not exist and it cannot be " - . "created automatically. You need to create the database. " - . $EVAL_ERROR; + . "created automatically. You need to create the database.\n"; } } } @@ -10193,9 +10200,9 @@ sub check_repl_table { } } else { + warn $EVAL_ERROR; die "--replicate table $tbl does not exist and it cannot be " - . "created automatically. You need to create the table. " - . $EVAL_ERROR; + . "created automatically. You need to create the table.\n" } } } diff --git a/bin/pt-table-sync b/bin/pt-table-sync index 2db352a8..5502a56b 100755 --- a/bin/pt-table-sync +++ b/bin/pt-table-sync @@ -7734,9 +7734,16 @@ sub table_is_allowed { my $filter = $self->{filters}; - if ( $db eq 'mysql' && ($tbl eq 'general_log' || $tbl eq 'slow_log') ) { - return 0; - } + return 0 if $db eq 'mysql' && $tbl =~ m/^(?: + general_log + |slow_log + |innodb_index_stats + |innodb_table_stats + |ndb_binlog_index + |slave_master_info + |slave_relay_log_info + |slave_worker_info + )$/x; if ( $filter->{'ignore-tables'}->{$tbl} && ($filter->{'ignore-tables'}->{$tbl} eq '*' diff --git a/bin/pt-table-usage b/bin/pt-table-usage index bbac0950..69b8c891 100755 --- a/bin/pt-table-usage +++ b/bin/pt-table-usage @@ -212,7 +212,8 @@ sub get_cxn_params { . join(';', map { "$opts{$_}->{dsn}=$info->{$_}" } grep { defined $info->{$_} } qw(F h P S A)) - . ';mysql_read_default_group=client'; + . ';mysql_read_default_group=client' + . ($info->{L} ? ';mysql_local_infile=1' : ''); } PTDEBUG && _d($dsn); return ($dsn, $info->{u}, $info->{p}); @@ -241,6 +242,9 @@ sub get_dbh { mysql_enable_utf8 => ($cxn_string =~ m/charset=utf8/i ? 1 : 0), }; @{$defaults}{ keys %$opts } = values %$opts; + if (delete $defaults->{L}) { # L for LOAD DATA LOCAL INFILE, our own extension + $defaults->{mysql_local_infile} = 1; + } if ( $opts->{mysql_use_result} ) { $defaults->{mysql_use_result} = 1; diff --git a/bin/pt-upgrade b/bin/pt-upgrade index a28479fd..47d4e910 100755 --- a/bin/pt-upgrade +++ b/bin/pt-upgrade @@ -11980,13 +11980,23 @@ sub main { # ######################################################################## # Do the version-check # ######################################################################## - if ( $o->get('version-check') ne 'off' && (!$o->has('quiet') || !$o->get('quiet')) ) { + if ( $o->get('version-check') ne 'off' + && (!$o->has('quiet') || !$o->get('quiet')) ) { Pingback::version_check( instances => [ map({ +{ dbh => $_->{dbh}, dsn => $_->{dsn} } } @$hosts) ], protocol => $o->get('version-check'), ); } + # ######################################################################## + # Disable the query cache. + # ######################################################################## + if ( $o->get('disable-query-cache') ) { + foreach my $host ( @$hosts ) { + disable_query_cache($host); + } + } + # ######################################################################## # Short version: do it! Long version: this callback does the main work. # The big picture is: @@ -12385,6 +12395,31 @@ sub get_cxn { return $dbh; } +sub disable_query_cache { + my ($host) = @_; + die "I need a host argument" unless $host; + my ($dbh, $host_name) = @{$host}{qw(dbh name)}; + + my $sql = 'SELECT @@query_cache_type'; + PTDEBUG && _d($host_name, $sql); + my ($query_cache_type) = $dbh->selectrow_array($sql); + PTDEBUG && _d($host_name, $query_cache_type); + return if ($query_cache_type || '') =~ m/OFF|0/; + + $sql = q/SET SESSION query_cache_type = OFF/; + eval { + PTDEBUG && _d($host_name, $sql); + $dbh->do($sql); + }; + if ( $EVAL_ERROR ) { + warn $EVAL_ERROR; + die "Failed to $sql on $host_name. Disable the query cache " + . "manually, or specify --no-disable-query-cache.\n"; + } + + return; +} + # Catches signals so we can exit gracefully. sub sig_int { my ( $signal ) = @_; @@ -12693,6 +12728,12 @@ C