mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-14 23:40:58 +00:00
- Updated MySQLConfig.pm to correctly support very long variable values
- Added test cases for pt-config-diff
This commit is contained in:
@@ -3063,29 +3063,24 @@ sub _parse_config {
|
||||
}
|
||||
elsif ( my $dbh = $args{dbh} ) {
|
||||
$config_data{format} = $args{format} || 'show_variables';
|
||||
my $mysql_version = _get_version($dbh);
|
||||
my $sql = "SHOW /*!40103 GLOBAL*/ VARIABLES";
|
||||
PTDEBUG && _d($dbh, $sql);
|
||||
my $rows = $dbh->selectall_arrayref($sql);
|
||||
$config_data{vars} = { map {
|
||||
my ($variable, $value) = @$_;
|
||||
# MySQL 5.7.6+ implement SHOW VARIABLES by
|
||||
# displaying records from performance_schema
|
||||
# table called global_variables. The table
|
||||
# truncates values at 1024 characters, but
|
||||
# some variables may be set to longer values.
|
||||
# The full value can still be accessed through
|
||||
# the @@global object.
|
||||
if (length($value) >= 1024) {
|
||||
my $var_sql = "SELECT \@\@global.$variable";
|
||||
PTDEBUG && _d($dbh, $var_sql);
|
||||
my $var_sth = $dbh->prepare($var_sql);
|
||||
$var_sth->execute();
|
||||
($value) = $var_sth->fetchrow_array();
|
||||
}
|
||||
$variable => $value
|
||||
} @$rows
|
||||
};
|
||||
$config_data{mysql_version} = _get_version($dbh);
|
||||
$config_data{vars} = {
|
||||
map {
|
||||
my ($variable, $value) = @$_;
|
||||
if ( length($value) == 1024 && $mysql_version ge '5.7.0' ) {
|
||||
my $var_sql = "SELECT \@\@global.$variable";
|
||||
PTDEBUG && _d($dbh, $var_sql);
|
||||
my $var_sth = $dbh->prepare($var_sql);
|
||||
$var_sth->execute();
|
||||
($value) = $var_sth->fetchrow_array();
|
||||
}
|
||||
$variable => $value
|
||||
} @$rows
|
||||
};
|
||||
$config_data{mysql_version} = $mysql_version;
|
||||
}
|
||||
else {
|
||||
die "Unknown config source";
|
||||
|
Reference in New Issue
Block a user