From ece567129290ac08d2fb85c2f359b1a9f72359fd Mon Sep 17 00:00:00 2001 From: Eduardo Broto Date: Wed, 10 Jul 2019 17:25:23 +0200 Subject: [PATCH] Escape identifiers in table column metrics Otherwise some queries may fail if reserved words were used as field, table or database names. --- mysqltuner.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mysqltuner.pl b/mysqltuner.pl index 6077581..fe63f5c 100755 --- a/mysqltuner.pl +++ b/mysqltuner.pl @@ -5994,7 +5994,7 @@ sub mysql_tables { my $current_type = uc($ctype) . ( $isnull eq 'NO' ? " NOT NULL" : "" ); my $optimal_type = select_str_g( "Optimal_fieldtype", - "SELECT $_ FROM $dbname.$tbname PROCEDURE ANALYSE(100000)" + "SELECT \\`$_\\` FROM \\`$dbname\\`.\\`$tbname\\` PROCEDURE ANALYSE(100000)" ); if ( not defined($optimal_type) or $optimal_type eq '' ) { infoprint " Current Fieldtype: $current_type"; @@ -6006,7 +6006,7 @@ sub mysql_tables { badprint "Consider changing type for column $_ in table $dbname.$tbname"; push( @generalrec, - "ALTER TABLE $dbname.$tbname MODIFY $_ $optimal_type;" + "ALTER TABLE \`$dbname\`.\`$tbname\` MODIFY \`$_\` $optimal_type;" ); }