mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-02 02:34:19 +00:00
WIP MySQL 8 support
This commit is contained in:
@@ -126,6 +126,10 @@ sub BUILDARGS {
|
||||
num_format => '# %1$-'.$label_width.'s %2$3s %3$7s %4$7s %5$7s %6$7s %7$7s %8$7s %9$7s',
|
||||
bool_format => '# %1$-'.$label_width.'s %2$3d%% yes, %3$3d%% no',
|
||||
string_format => '# %1$-'.$label_width.'s %2$s',
|
||||
# MySQL 8 doesn't support partitions.
|
||||
# sub explain_report can handle the error but we need to know if /*!50100 PARTITIONS */
|
||||
# was used or not, to write the correct report headers
|
||||
no_partitions => 0,
|
||||
hidden_attrib => { # Don't sort/print these attribs in the reports.
|
||||
arg => 1, # They're usually handled specially, or not
|
||||
fingerprint => 1, # printed at all.
|
||||
@@ -463,6 +467,7 @@ sub query_report {
|
||||
}
|
||||
}
|
||||
|
||||
my $partitions_msg = $self->{no_partitions} ? '' : '/*!50100 PARTITIONS */';
|
||||
if ( $groupby eq 'fingerprint' ) {
|
||||
# Shorten it if necessary (issue 216 and 292).
|
||||
my $samp_query = $qr->shorten($vals->{samp_query}, $self->{options}->{shorten})
|
||||
@@ -491,7 +496,7 @@ sub query_report {
|
||||
$report .= "$samp_query${mark}\n";
|
||||
}
|
||||
else {
|
||||
$report .= "# EXPLAIN /*!50100 PARTITIONS*/\n$samp_query${mark}\n";
|
||||
$report .= "# EXPLAIN $partitions_msg\n$samp_query${mark}\n";
|
||||
$report .= $self->explain_report($samp_query, $vals->{default_db});
|
||||
}
|
||||
}
|
||||
@@ -501,7 +506,7 @@ sub query_report {
|
||||
if ( $converted
|
||||
&& $converted =~ m/^[\(\s]*select/i ) {
|
||||
# It converted OK to a SELECT
|
||||
$report .= "# Converted for EXPLAIN\n# EXPLAIN /*!50100 PARTITIONS*/\n$converted${mark}\n";
|
||||
$report .= "# Converted for EXPLAIN\n# EXPLAIN $partitions_msg\n$converted${mark}\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1301,7 +1306,16 @@ sub explain_report {
|
||||
PTDEBUG && _d($dbh, "USE", $db);
|
||||
$dbh->do("USE " . $q->quote($db));
|
||||
}
|
||||
my $sth = $dbh->prepare("EXPLAIN /*!50100 PARTITIONS */ $query");
|
||||
my $sth;
|
||||
eval {
|
||||
$sth = $dbh->prepare("EXPLAIN /*!50100 PARTITIONS */ $query");
|
||||
$sth->execute();
|
||||
};
|
||||
if ($EVAL_ERROR) { # MySQL 8.0+ doesn't support PARTITIONS
|
||||
$self->{no_partitions} = 1;
|
||||
$sth = $dbh->prepare("EXPLAIN $query");
|
||||
$sth->execute();
|
||||
}
|
||||
$sth->execute();
|
||||
my $i = 1;
|
||||
while ( my @row = $sth->fetchrow_array() ) {
|
||||
|
Reference in New Issue
Block a user