Skip to content
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/pt-archiver
Original file line number Diff line number Diff line change
Expand Up @@ -2073,7 +2073,7 @@ sub find_best_index {
sub find_possible_keys {
my ( $self, $dbh, $database, $table, $quoter, $where ) = @_;
return () unless $where;
my $sql = 'EXPLAIN SELECT * FROM ' . $quoter->quote($database, $table)
my $sql = 'EXPLAIN /*!90700 FORMAT=TRADITIONAL */ SELECT * FROM ' . $quoter->quote($database, $table)
. ' WHERE ' . $where;
PTDEBUG && _d($sql);
my $expl = $dbh->selectrow_hashref($sql);
Expand Down
4 changes: 2 additions & 2 deletions bin/pt-duplicate-key-checker
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ sub find_best_index {
sub find_possible_keys {
my ( $self, $dbh, $database, $table, $quoter, $where ) = @_;
return () unless $where;
my $sql = 'EXPLAIN SELECT * FROM ' . $quoter->quote($database, $table)
my $sql = 'EXPLAIN /*!90700 FORMAT=TRADITIONAL */ SELECT * FROM ' . $quoter->quote($database, $table)
. ' WHERE ' . $where;
PTDEBUG && _d($sql);
my $expl = $dbh->selectrow_hashref($sql);
Expand Down Expand Up @@ -2306,7 +2306,7 @@ sub get_key_size {
PTDEBUG && _d('Key', $name, 'exists in', $args{tbl_name}, ':',
$key_exists ? 'yes': 'no');

my $sql = 'EXPLAIN SELECT ' . join(', ', @cols)
my $sql = 'EXPLAIN /*!90700 FORMAT=TRADITIONAL */ SELECT ' . join(', ', @cols)
. ' FROM ' . $args{tbl_name}
. ($key_exists ? " FORCE INDEX (`$name`)" : '')
. ' WHERE ';
Expand Down
2 changes: 1 addition & 1 deletion bin/pt-find
Original file line number Diff line number Diff line change
Expand Up @@ -2020,7 +2020,7 @@ sub find_best_index {
sub find_possible_keys {
my ( $self, $dbh, $database, $table, $quoter, $where ) = @_;
return () unless $where;
my $sql = 'EXPLAIN SELECT * FROM ' . $quoter->quote($database, $table)
my $sql = 'EXPLAIN /*!90700 FORMAT=TRADITIONAL */ SELECT * FROM ' . $quoter->quote($database, $table)
. ' WHERE ' . $where;
PTDEBUG && _d($sql);
my $expl = $dbh->selectrow_hashref($sql);
Expand Down
2 changes: 1 addition & 1 deletion bin/pt-heartbeat
Original file line number Diff line number Diff line change
Expand Up @@ -3899,7 +3899,7 @@ sub find_best_index {
sub find_possible_keys {
my ( $self, $dbh, $database, $table, $quoter, $where ) = @_;
return () unless $where;
my $sql = 'EXPLAIN SELECT * FROM ' . $quoter->quote($database, $table)
my $sql = 'EXPLAIN /*!90700 FORMAT=TRADITIONAL */ SELECT * FROM ' . $quoter->quote($database, $table)
. ' WHERE ' . $where;
PTDEBUG && _d($sql);
my $expl = $dbh->selectrow_hashref($sql);
Expand Down
4 changes: 2 additions & 2 deletions bin/pt-index-usage
Original file line number Diff line number Diff line change
Expand Up @@ -3272,7 +3272,7 @@ sub find_best_index {
sub find_possible_keys {
my ( $self, $dbh, $database, $table, $quoter, $where ) = @_;
return () unless $where;
my $sql = 'EXPLAIN SELECT * FROM ' . $quoter->quote($database, $table)
my $sql = 'EXPLAIN /*!90700 FORMAT=TRADITIONAL */ SELECT * FROM ' . $quoter->quote($database, $table)
. ' WHERE ' . $where;
PTDEBUG && _d($sql);
my $expl = $dbh->selectrow_hashref($sql);
Expand Down Expand Up @@ -4663,7 +4663,7 @@ sub explain_query {
(length $query <= 100 ? $query : substr($query, 0, 100) . "..."));
return;
}
my $sql = "EXPLAIN $query";
my $sql = "EXPLAIN /*!90700 FORMAT=TRADITIONAL */ $query";
PTDEBUG && _d($dbh, $sql);
my $explain = $dbh->selectall_arrayref($sql, { Slice => {} });
PTDEBUG && _d("Result of EXPLAIN:", Dumper($explain));
Expand Down
2 changes: 1 addition & 1 deletion bin/pt-kill
Original file line number Diff line number Diff line change
Expand Up @@ -3143,7 +3143,7 @@ sub find_best_index {
sub find_possible_keys {
my ( $self, $dbh, $database, $table, $quoter, $where ) = @_;
return () unless $where;
my $sql = 'EXPLAIN SELECT * FROM ' . $quoter->quote($database, $table)
my $sql = 'EXPLAIN /*!90700 FORMAT=TRADITIONAL */ SELECT * FROM ' . $quoter->quote($database, $table)
. ' WHERE ' . $where;
PTDEBUG && _d($sql);
my $expl = $dbh->selectrow_hashref($sql);
Expand Down
16 changes: 11 additions & 5 deletions bin/pt-mysql-summary
Original file line number Diff line number Diff line change
Expand Up @@ -972,8 +972,8 @@ collect_mysql_users () {
}

collect_mysql_roles () {
QUERY="SELECT DISTINCT User 'Role Name', if(from_user is NULL,0, 1) Active FROM mysql.user LEFT JOIN mysql.role_edges ON from_user=user WHERE account_locked='Y' AND password_expired='Y' AND authentication_string=''\G"
$CMD_MYSQL $EXT_ARGV -ss -e "$QUERY" 2>/dev/null
QUERY="SELECT DISTINCT User 'Role Name', if(from_user is NULL,0, 1) Active FROM mysql.user LEFT JOIN mysql.role_edges ON from_user=user WHERE account_locked='Y' AND password_expired='Y' AND authentication_string=''"
$CMD_MYSQL $EXT_ARGV -ss -Ee "$QUERY" 2>/dev/null
}

collect_mysql_show_replica_hosts () {
Expand Down Expand Up @@ -2142,9 +2142,15 @@ section_innodb () {

local log_size="$(get_var innodb_log_file_size "$variables_file")"
local log_file="$(get_var innodb_log_files_in_group "$variables_file")"
local log_total=$(awk "BEGIN {printf \"%.2f\n\", ${log_size}*${log_file}}" )
name_val "Log File Size" \
"${log_file} * $(shorten ${log_size} 1) = $(shorten ${log_total} 1)"
if [ -n "$log_size" -a -n "$log_file" ]; then
local log_total=$(awk "BEGIN {printf \"%.2f\n\", ${log_size}*${log_file}}" )
name_val "Log File Size" \
"${log_file} * $(shorten ${log_size} 1) = $(shorten ${log_total} 1)"
else
local log_total="$(get_var innodb_redo_log_capacity "$variables_file")"
name_val "Redo Log Capacity" \
"$(shorten $(get_var innodb_redo_log_capacity "$variables_file") 0)"
fi
name_val "Log Buffer Size" \
"$(shorten $(get_var innodb_log_buffer_size "$variables_file") 0)"
name_val "Flush Method" \
Expand Down
14 changes: 7 additions & 7 deletions bin/pt-online-schema-change
Original file line number Diff line number Diff line change
Expand Up @@ -3462,7 +3462,7 @@ sub find_best_index {
sub find_possible_keys {
my ( $self, $dbh, $database, $table, $quoter, $where ) = @_;
return () unless $where;
my $sql = 'EXPLAIN SELECT * FROM ' . $quoter->quote($database, $table)
my $sql = 'EXPLAIN /*!90700 FORMAT=TRADITIONAL */ SELECT * FROM ' . $quoter->quote($database, $table)
. ' WHERE ' . $where;
PTDEBUG && _d($sql);
my $expl = $dbh->selectrow_hashref($sql);
Expand Down Expand Up @@ -5839,7 +5839,7 @@ sub _one_nibble {
PTDEBUG && _d('One nibble statement:', $nibble_sql);

my $explain_nibble_sql
= "EXPLAIN SELECT "
= "EXPLAIN /*!90700 FORMAT=TRADITIONAL */ SELECT "
. ($args->{select} ? $args->{select}
: join(', ', map{ $tbl->{tbl_struct}->{type_for}->{$_} eq 'enum'
? "CAST(".$q->quote($_)." AS UNSIGNED)" : $q->quote($_) } @$cols))
Expand Down Expand Up @@ -5937,7 +5937,7 @@ sub _nibble_params {
PTDEBUG && _d('Nibble statement:', $nibble_sql);

my $explain_nibble_sql
= "EXPLAIN SELECT "
= "EXPLAIN /*!90700 FORMAT=TRADITIONAL */ SELECT "
. ($args->{select} ? $args->{select}
: join(', ', map { $q->quote($_) } @{$asc->{cols}}))
. " FROM $from"
Expand All @@ -5960,8 +5960,8 @@ sub _nibble_params {
last_ub_sql => $last_ub_sql,
ub_sql => $ub_sql,
nibble_sql => $nibble_sql,
explain_first_lb_sql => "EXPLAIN $first_lb_sql",
explain_ub_sql => "EXPLAIN $ub_sql",
explain_first_lb_sql => "EXPLAIN /*!90700 FORMAT=TRADITIONAL */ $first_lb_sql",
explain_ub_sql => "EXPLAIN /*!90700 FORMAT=TRADITIONAL */ $ub_sql",
explain_nibble_sql => $explain_nibble_sql,
resume_lb_sql => $resume_lb_sql,
sql => {
Expand Down Expand Up @@ -6305,7 +6305,7 @@ sub get_row_estimate {
}
my ($cxn, $tbl) = @args{@required_args};

my $sql = "EXPLAIN SELECT * FROM $tbl->{name} "
my $sql = "EXPLAIN /*!90700 FORMAT=TRADITIONAL */ SELECT * FROM $tbl->{name} "
. "WHERE " . ($args{where} || '1=1');
PTDEBUG && _d($sql);
my $expl = $cxn->dbh()->selectrow_hashref($sql);
Expand Down Expand Up @@ -7055,7 +7055,7 @@ sub _make_range_query {
my $condition = $tbl->{tbl_struct}->{type_for}->{$col} eq 'enum' ? "CAST(? AS UNSIGNED)" : "?";
push @where, $q->quote($col) . " >= " . $condition;

my $sql = "EXPLAIN SELECT /*!40001 SQL_NO_CACHE */ * "
my $sql = "EXPLAIN /*!90700 FORMAT=TRADITIONAL */ SELECT /*!40001 SQL_NO_CACHE */ * "
. "FROM $tbl->{name} FORCE INDEX (" . $q->quote($index) . ") "
. "WHERE " . join(' AND ', @where)
. " /*key_len*/";
Expand Down
7 changes: 3 additions & 4 deletions bin/pt-query-digest
Original file line number Diff line number Diff line change
Expand Up @@ -7799,15 +7799,14 @@ sub explain_report {
}
my $sth;
eval {
$sth = $dbh->prepare("EXPLAIN /*!50100 PARTITIONS*/ $query");
$sth = $dbh->prepare("EXPLAIN /*!50100 PARTITIONS*/ /*!90700 FORMAT=TRADITIONAL */ $query");
$sth->execute();
};
if ($EVAL_ERROR) { # MySQL 8.0+ doesn't support PARTITIONS
$self->{no_partitions} = 1;
$sth = $dbh->prepare("EXPLAIN $query");
$sth = $dbh->prepare("EXPLAIN /*!90700 FORMAT=TRADITIONAL */ $query");
$sth->execute();
}
$sth->execute();
my $i = 1;
while ( my @row = $sth->fetchrow_array() ) {
$explain .= "# *************************** $i. "
Expand Down Expand Up @@ -9023,7 +9022,7 @@ sub find_best_index {
sub find_possible_keys {
my ( $self, $dbh, $database, $table, $quoter, $where ) = @_;
return () unless $where;
my $sql = 'EXPLAIN SELECT * FROM ' . $quoter->quote($database, $table)
my $sql = 'EXPLAIN /*!90700 FORMAT=TRADITIONAL */ SELECT * FROM ' . $quoter->quote($database, $table)
. ' WHERE ' . $where;
PTDEBUG && _d($sql);
my $expl = $dbh->selectrow_hashref($sql);
Expand Down
8 changes: 4 additions & 4 deletions bin/pt-replica-restart
Original file line number Diff line number Diff line change
Expand Up @@ -5480,14 +5480,14 @@ sub watch_server {
}
PTDEBUG && _d('Have GTID:', $have_gtid);

# If GTID is enabled, replica_parallel_workers should be == 0.
# If GTID is enabled, replica_parallel_workers should be == 0 or 1.
# It's currently not possible to know what GTID event the failed trx is.
if ( $have_gtid ) {
my $threads = $dbh->selectrow_hashref(
"SELECT \@\@GLOBAL.${replica_name}_parallel_workers AS threads");
if ( $threads->{threads} > 0 ) {
if ( $threads->{threads} > 1 ) {
die "Cannot skip transactions properly because GTID is enabled "
. "and ${replica_name}_parallel_workers > 0. See 'GLOBAL TRANSACTION IDS' "
. "and ${replica_name}_parallel_workers > 1. See 'GLOBAL TRANSACTION IDS' "
. "in the tool's documentation.\n";
}
}
Expand Down Expand Up @@ -5878,7 +5878,7 @@ introduced in MySQL 5.6.5. It's important to keep in mind that:
=item *

pt-replica-restart will not skip transactions when multiple replication threads
are being used (replica_parallel_workers > 0). pt-replica-restart does not know
are being used (replica_parallel_workers > 1). pt-replica-restart does not know
what the GTID event is of the failed transaction of a specific replica thread.

=item *
Expand Down
Loading
Loading