Bug #79008 mysql_upgrade fails if table name contains dots because of incorrect escaping
Submitted: 28 Oct 2015 21:27 Modified: 29 Oct 2015 5:59
Reporter: Kevin Dyer Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S2 (Serious)
Version:5.6.25, 5.6.27 OS:Any
Assigned to: CPU Architecture:Any
Tags: mysql_upgrade, mysqlcheck

[28 Oct 2015 21:27] Kevin Dyer
Description:
We have a service that creates a table with the fully qualified hostname as a result the table name contains dots.

mysqlcheck: Got error: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.`example`.`com` FOR UPGRADE' at line 1 when executing 'CHECK TABLE ... FOR UPGRADE'
FATAL ERROR: Upgrade failed

The offending line shows back ticks escaping each portion of the fqdn table name.

How to repeat:
To repeat create a table containing dots
Run mysql_upgrade

Suggested fix:
Clearly the script attempts to escape the name but needs to quote the whole table name. e.g.

`host.example.com` FOR UPGRADE

Workaround is to rename the table, run mysql_upgrade and revert the name.
Presumably --force may be an alternative workaround.
[29 Oct 2015 5:59] MySQL Verification Team
Hello Kevin Dyer,

Thank you for the report.

Thanks,
Umesh
[29 Oct 2015 6:00] MySQL Verification Team
// 5.6.27

mysql> use test
Database changed
mysql> create table `www.example.com`(id int,name varchar(100));
Query OK, 0 rows affected (0.01 sec)

mysql> \q
Bye
[root@cluster-repo ~]# mysql_upgrade -uroot --force --verbose
Looking for 'mysql' as: mysql
Looking for 'mysqlcheck' as: mysqlcheck
Running 'mysqlcheck with default connection arguments
Running 'mysqlcheck with default connection arguments
mysql.columns_priv                                 OK
mysql.db                                           OK
mysql.event                                        OK
mysql.func                                         OK
mysql.general_log                                  OK
mysql.help_category                                OK
mysql.help_keyword                                 OK
mysql.help_relation                                OK
mysql.help_topic                                   OK
mysql.innodb_index_stats                           OK
mysql.innodb_table_stats                           OK
mysql.ndb_binlog_index                             OK
mysql.plugin                                       OK
mysql.proc                                         OK
mysql.procs_priv                                   OK
mysql.proxies_priv                                 OK
mysql.servers                                      OK
mysql.slave_master_info                            OK
mysql.slave_relay_log_info                         OK
mysql.slave_worker_info                            OK
mysql.slow_log                                     OK
mysql.tables_priv                                  OK
mysql.time_zone                                    OK
mysql.time_zone_leap_second                        OK
mysql.time_zone_name                               OK
mysql.time_zone_transition                         OK
mysql.time_zone_transition_type                    OK
mysql.user                                         OK
Running 'mysql_fix_privilege_tables'...
Running 'mysqlcheck with default connection arguments
Running 'mysqlcheck with default connection arguments
mysqlcheck: Got error: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.`com`  FOR UPGRADE' at line 1 when executing 'CHECK TABLE ...  FOR UPGRADE'
FATAL ERROR: Upgrade failed