From bcbb4e59ab267e7b849943976a0a5fc0e116ccaf Mon Sep 17 00:00:00 2001 From: Maciej Dobrzanski Date: Tue, 3 Dec 2024 20:28:01 +0100 Subject: [PATCH] Read @@global object variable when SHOW VARIABLES returns a potentially truncated value --- bin/pt-config-diff | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/bin/pt-config-diff b/bin/pt-config-diff index 927a3191..e8ac523b 100755 --- a/bin/pt-config-diff +++ b/bin/pt-config-diff @@ -3066,7 +3066,25 @@ sub _parse_config { my $sql = "SHOW /*!40103 GLOBAL*/ VARIABLES"; PTDEBUG && _d($dbh, $sql); my $rows = $dbh->selectall_arrayref($sql); - $config_data{vars} = { map { @$_ } @$rows }; + $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); } else {